diff --git a/modules/comments/data/ArticleCommentMapper.php b/modules/comments/data/ArticleCommentMapper.php index 89980d258..904ca74c2 100644 --- a/modules/comments/data/ArticleCommentMapper.php +++ b/modules/comments/data/ArticleCommentMapper.php @@ -46,7 +46,7 @@ class ArticleCommentMapper extends APFObject { * @version * Version 0.1, 22.08.2007
*/ - public function loadArticleCommentByID($commentId) { + public function loadArticleCommentByID(string $commentId) { $SQL = $this->getConnection(); $select = 'SELECT ArticleCommentID, Name, EMail, Comment, Date, Time diff --git a/modules/contact/biz/ContactManager.php b/modules/contact/biz/ContactManager.php index 9dd9584c6..42f313d63 100644 --- a/modules/contact/biz/ContactManager.php +++ b/modules/contact/biz/ContactManager.php @@ -167,7 +167,7 @@ private function getNotificationText(array $values = []) { * @version * Version 0.1, 19.10.2011
*/ - private function fillPlaceHolders($text, array $values = []) { + private function fillPlaceHolders(string $text, array $values = []) { foreach ($values as $key => $value) { $text = str_replace('{' . $key . '}', $value, $text); } @@ -188,7 +188,7 @@ private function fillPlaceHolders($text, array $values = []) { * @version * Version 0.1, 19.10.2011
*/ - private function getEmailTemplateContent($namespace, $template) { + private function getEmailTemplateContent(string $namespace, string $template) { $loader = RootClassLoader::getLoaderByNamespace($namespace); $rootPath = $loader->getRootPath(); $vendor = $loader->getVendorName(); diff --git a/modules/contact/data/ContactMapper.php b/modules/contact/data/ContactMapper.php index 3d05bada5..a935c9f01 100644 --- a/modules/contact/data/ContactMapper.php +++ b/modules/contact/data/ContactMapper.php @@ -83,7 +83,7 @@ public function loadRecipients() { * Version 0.2, 04.06.2006
* Version 0.3, 04.03.2007
*/ - public function loadRecipientById($id) { + public function loadRecipientById(string $id) { /* @var $recipients ContactFormRecipient[] */ $recipients = $this->loadRecipients(); diff --git a/modules/usermanagement/pres/condition/UmgtGroupCondition.php b/modules/usermanagement/pres/condition/UmgtGroupCondition.php index 72535475b..29bbf1411 100644 --- a/modules/usermanagement/pres/condition/UmgtGroupCondition.php +++ b/modules/usermanagement/pres/condition/UmgtGroupCondition.php @@ -33,7 +33,7 @@ */ class UmgtGroupCondition extends UserDependentContentConditionBase implements UserDependentContentCondition { - public function matches($conditionKey, UmgtUser $user = null) { + public function matches(string $conditionKey, UmgtUser $user = null) { if ($user === null) { return false; diff --git a/modules/usermanagement/pres/condition/UmgtLoggedInCondition.php b/modules/usermanagement/pres/condition/UmgtLoggedInCondition.php index e3a8cfa5d..ac69b6011 100644 --- a/modules/usermanagement/pres/condition/UmgtLoggedInCondition.php +++ b/modules/usermanagement/pres/condition/UmgtLoggedInCondition.php @@ -31,7 +31,7 @@ */ class UmgtLoggedInCondition extends UserDependentContentConditionBase implements UserDependentContentCondition { - public function matches($conditionKey, UmgtUser $user = null) { + public function matches(string $conditionKey, UmgtUser $user = null) { return $user !== null; } diff --git a/modules/usermanagement/pres/condition/UmgtLoggedOutCondition.php b/modules/usermanagement/pres/condition/UmgtLoggedOutCondition.php index 4e8b2630d..45e679be1 100644 --- a/modules/usermanagement/pres/condition/UmgtLoggedOutCondition.php +++ b/modules/usermanagement/pres/condition/UmgtLoggedOutCondition.php @@ -31,7 +31,7 @@ */ class UmgtLoggedOutCondition extends UserDependentContentConditionBase implements UserDependentContentCondition { - public function matches($conditionKey, UmgtUser $user = null) { + public function matches(string $conditionKey, UmgtUser $user = null) { return $user === null; } diff --git a/modules/usermanagement/pres/condition/UmgtNotPermissionCondition.php b/modules/usermanagement/pres/condition/UmgtNotPermissionCondition.php index 6a0619fcc..e7f7eab7e 100644 --- a/modules/usermanagement/pres/condition/UmgtNotPermissionCondition.php +++ b/modules/usermanagement/pres/condition/UmgtNotPermissionCondition.php @@ -34,7 +34,7 @@ */ class UmgtNotPermissionCondition extends UserDependentContentConditionBase implements UserDependentContentCondition { - public function matches($conditionKey, UmgtUser $user = null) { + public function matches(string $conditionKey, UmgtUser $user = null) { if ($user === null) { return true; diff --git a/modules/usermanagement/pres/condition/UmgtNotRoleCondition.php b/modules/usermanagement/pres/condition/UmgtNotRoleCondition.php index e087d5e83..d70ef232e 100644 --- a/modules/usermanagement/pres/condition/UmgtNotRoleCondition.php +++ b/modules/usermanagement/pres/condition/UmgtNotRoleCondition.php @@ -31,7 +31,7 @@ */ class UmgtNotRoleCondition extends UmgtRoleConditionBase implements UserDependentContentCondition { - public function matches($conditionKey, UmgtUser $user = null) { + public function matches(string $conditionKey, UmgtUser $user = null) { if ($user === null) { return true; diff --git a/modules/usermanagement/pres/condition/UmgtPermissionCondition.php b/modules/usermanagement/pres/condition/UmgtPermissionCondition.php index c289cfdc1..dc3fd55ad 100644 --- a/modules/usermanagement/pres/condition/UmgtPermissionCondition.php +++ b/modules/usermanagement/pres/condition/UmgtPermissionCondition.php @@ -33,7 +33,7 @@ */ class UmgtPermissionCondition extends UmgtRoleConditionBase implements UserDependentContentCondition { - public function matches($conditionKey, UmgtUser $user = null) { + public function matches(string $conditionKey, UmgtUser $user = null) { if ($user === null) { return false; diff --git a/modules/usermanagement/pres/condition/UmgtRoleCondition.php b/modules/usermanagement/pres/condition/UmgtRoleCondition.php index fe56e11d4..16bae0d4d 100644 --- a/modules/usermanagement/pres/condition/UmgtRoleCondition.php +++ b/modules/usermanagement/pres/condition/UmgtRoleCondition.php @@ -31,7 +31,7 @@ */ class UmgtRoleCondition extends UmgtRoleConditionBase implements UserDependentContentCondition { - public function matches($conditionKey, UmgtUser $user = null) { + public function matches(string $conditionKey, UmgtUser $user = null) { if ($user === null) { return false; diff --git a/modules/usermanagement/pres/condition/UserDependentContentCondition.php b/modules/usermanagement/pres/condition/UserDependentContentCondition.php index 26637037d..ce5c9eaf6 100644 --- a/modules/usermanagement/pres/condition/UserDependentContentCondition.php +++ b/modules/usermanagement/pres/condition/UserDependentContentCondition.php @@ -39,7 +39,7 @@ interface UserDependentContentCondition { * * @return boolean true in case the condition matches, false otherwise. */ - public function matches($conditionKey, UmgtUser $user = null); + public function matches(string $conditionKey, UmgtUser $user = null); /** * @return string The condition key. diff --git a/modules/usermanagement/pres/documentcontroller/UmgtBaseController.php b/modules/usermanagement/pres/documentcontroller/UmgtBaseController.php index d8ffe27d7..a336f71e5 100644 --- a/modules/usermanagement/pres/documentcontroller/UmgtBaseController.php +++ b/modules/usermanagement/pres/documentcontroller/UmgtBaseController.php @@ -49,7 +49,7 @@ abstract class UmgtBaseController extends BaseDocumentController { * @version * Version 0.1, 26.12.2008
*/ - protected function generateLink($linkParams, $baseURL = null) { + protected function generateLink(array $linkParams = [], $baseURL = null) { if ($baseURL === null) { $baseURL = $this->getRequest()->getRequestUri(); } diff --git a/modules/usermanagement/pres/documentcontroller/login/LoginController.php b/modules/usermanagement/pres/documentcontroller/login/LoginController.php index 1a30bd7f1..961231c18 100644 --- a/modules/usermanagement/pres/documentcontroller/login/LoginController.php +++ b/modules/usermanagement/pres/documentcontroller/login/LoginController.php @@ -129,7 +129,7 @@ public function transformContent() { * @version * Version 0.1, 21.05.2011
*/ - private function loadUser($username, $password) { + private function loadUser(string $username, string $password) { /* @var $umgt UmgtManager */ $umgt = $this->getDIServiceObject('APF\modules\usermanagement\biz', 'UmgtManager'); @@ -151,7 +151,7 @@ private function loadUser($username, $password) { } } - public function createAutoLogin($user) { + public function createAutoLogin(UmgtUser $user) { /* @var $umgt UmgtManager */ $umgt = $this->getDIServiceObject('APF\modules\usermanagement\biz', 'UmgtManager'); diff --git a/modules/usermanagement/pres/documentcontroller/login/ResetPasswordController.php b/modules/usermanagement/pres/documentcontroller/login/ResetPasswordController.php index a1f626aa4..8c1cf8972 100644 --- a/modules/usermanagement/pres/documentcontroller/login/ResetPasswordController.php +++ b/modules/usermanagement/pres/documentcontroller/login/ResetPasswordController.php @@ -108,8 +108,6 @@ public function transformContent() { } elseif ($form->isSent() && !$form->isValid()) { // error message $form->setPlaceHolder('resetpw-error', $this->getTemplate('resetpw-error')->transformTemplate()); - } else { - // nothing to do here } $form->transformOnPlace(); diff --git a/modules/usermanagement/pres/documentcontroller/user/UserEditController.php b/modules/usermanagement/pres/documentcontroller/user/UserEditController.php index 6534ea479..2b691ef30 100644 --- a/modules/usermanagement/pres/documentcontroller/user/UserEditController.php +++ b/modules/usermanagement/pres/documentcontroller/user/UserEditController.php @@ -146,7 +146,7 @@ public function transformContent() { } - private function getMarkerClass(FormControl &$control) { + private function getMarkerClass(FormControl $control) { $marker = $control->getAttribute(AbstractFormValidator::$CUSTOM_MARKER_CLASS_ATTRIBUTE); if (empty($marker)) { $marker = AbstractFormValidator::$DEFAULT_MARKER_CLASS; diff --git a/tests/suites/tools/link/LinkGeneratorTest.php b/tests/suites/tools/link/LinkGeneratorTest.php index 2c7bf4151..0d1966705 100644 --- a/tests/suites/tools/link/LinkGeneratorTest.php +++ b/tests/suites/tools/link/LinkGeneratorTest.php @@ -47,7 +47,7 @@ public function testSimpleLinkScheme() { ); } - public function testUrlCreationFromString() { + public function testUrlCreationFromString1() { $scheme = 'https'; $domain = 'www.domain.tld'; $path = '/path/to/dir'; @@ -61,6 +61,23 @@ public function testUrlCreationFromString() { $this->assertEquals($paramValue, $url->getQueryParameter($paramName)); } + public function testUrlCreationFromString2() { + $this->expectException(UrlFormatException::class); + Url::fromString('////'); + } + + public function testUrlCreationFromReferrer1() { + $this->expectException(UrlFormatException::class); + Url::fromReferrer(); + } + + public function testUrlCreationFromReferrer2() { + $_SERVER['HTTP_REFERER'] = '/foo'; + $url = Url::fromReferrer(); + $this->assertEquals('/foo', $url->getPath()); + unset($_SERVER['HTTP_REFERER']); + } + public function testFrontControllerUrlGeneration() { $url = Url::fromString('')->setHost('localhost')->setScheme('http'); $link = LinkGenerator::generateUrl( @@ -595,4 +612,14 @@ public function testEncodeRfc3986() { $this->assertEquals('/?a[x]=1&a[y]=2&b[0]=1&b[1]=2¶m name=param value', $link); } + public function testResetQuery() { + + $query = ['foo' => 'bar', 'bar' => 'baz']; + $url = new Url(null, null, null, null, $query); + $this->assertEquals($url->getQuery(), $query); + + $url->resetQuery(); + $this->assertEquals($url->getQuery(), []); + } + } diff --git a/tools/filesystem/FilesystemItem.php b/tools/filesystem/FilesystemItem.php index 8a6f24cc7..91c83a113 100644 --- a/tools/filesystem/FilesystemItem.php +++ b/tools/filesystem/FilesystemItem.php @@ -190,7 +190,7 @@ public function getOwner() { * @version Version 0.1, 01.05.2012 */ public function getParentFolder() { - return new Folder($this->getBasePath()); + return (new Folder())->open($this->getBasePath()); } /** diff --git a/tools/html/taglib/GetIterator.php b/tools/html/taglib/GetIterator.php index 74349ce61..fc2b7fede 100644 --- a/tools/html/taglib/GetIterator.php +++ b/tools/html/taglib/GetIterator.php @@ -40,7 +40,7 @@ trait GetIterator { * * @return Iterator */ - public function getIterator($name) { + public function getIterator(string $name) { /* @var $this DomNode */ return $this->getChildNode('name', $name, Iterator::class); } diff --git a/tools/link/Url.php b/tools/link/Url.php index ab29ea3fc..23efa188e 100644 --- a/tools/link/Url.php +++ b/tools/link/Url.php @@ -59,7 +59,7 @@ final class Url { * @version * Version 0.1, 29.03.2011
*/ - public function __construct($scheme, $host, $port, $path, array $query = [], $anchor = null) { + public function __construct(string $scheme = null, string $host = null, int $port = null, string $path = null, array $query = [], string $anchor = null) { $this->scheme = $scheme; $this->host = $host; $this->port = $port; @@ -80,7 +80,7 @@ public function __construct($scheme, $host, $port, $path, array $query = [], $an * @version * Version 0.1, 29.03.2011
*/ - public static function fromString($url) { + public static function fromString(string $url) { // the ugly "@" is only introduced to convert the E_WARNING into an exception $parts = @parse_url($url); @@ -123,7 +123,7 @@ public static function fromString($url) { * Version 0.1, 29.03.2011
* Version 0.2, 05.09.2015 (ID#258: support nested query parameters)
*/ - private static function getQueryParams($query) { + private static function getQueryParams(string $query = null) { // reverse resolve encoded ampersands $query = str_replace('&', '&', $query); @@ -152,7 +152,7 @@ private static function getQueryParams($query) { * Version 0.1, 29.03.2011
* Version 0.2, 09.03.2013 (Now uses standard PHP variables in stead of a Registry value to allow better url input filter manipulation)
*/ - public static function fromCurrent($absolute = false) { + public static function fromCurrent(bool $absolute = false) { return self::getRequestStatic()->getUrl($absolute); } @@ -168,7 +168,7 @@ public static function fromCurrent($absolute = false) { * @version * Version 0.1, 07.09.2011
*/ - public static function fromReferrer($absolute = false) { + public static function fromReferrer(bool $absolute = false) { return self::getRequestStatic()->getReferrerUrl($absolute); } @@ -187,7 +187,7 @@ public function getScheme() { * @version * Version 0.1, 04.04.2011
*/ - public function setScheme($scheme) { + public function setScheme(string $scheme = null) { $this->scheme = $scheme; return $this; @@ -208,7 +208,7 @@ public function getHost() { * @version * Version 0.1, 04.04.2011
*/ - public function setHost($host) { + public function setHost(string $host = null) { $this->host = $host; return $this; @@ -229,7 +229,7 @@ public function getPort() { * @version * Version 0.1, 04.04.2011
*/ - public function setPort($port) { + public function setPort(int $port = null) { $this->port = $port; return $this; @@ -250,7 +250,7 @@ public function getPath() { * @version * Version 0.1, 04.04.2011
*/ - public function setPath($path) { + public function setPath(string $path = null) { $this->path = $path; return $this; @@ -280,7 +280,7 @@ public function getQuery() { * @version * Version 0.1, 04.04.2011
*/ - public function setQuery(array $query) { + public function setQuery(array $query = null) { $this->query = $query; return $this; @@ -301,7 +301,7 @@ public function getAnchor() { * @version * Version 0.1, 04.04.2011
*/ - public function setAnchor($anchor) { + public function setAnchor(string $anchor = null) { $this->anchor = $anchor; return $this; @@ -319,7 +319,7 @@ public function setAnchor($anchor) { * @version * Version 0.1, 04.04.2011
*/ - public function getQueryParameter($name, $default = null) { + public function getQueryParameter(string $name, $default = null) { return isset($this->query[$name]) ? $this->query[$name] : $default; } @@ -373,7 +373,7 @@ public function resetQuery() { * @version * Version 0.1, 04.04.2011
*/ - public function setQueryParameter($name, $value) { + public function setQueryParameter(string $name, $value) { $this->query[$name] = $value; return $this; diff --git a/tools/media/actions/StreamMediaAction.php b/tools/media/actions/StreamMediaAction.php index 89055c7ed..d998111da 100644 --- a/tools/media/actions/StreamMediaAction.php +++ b/tools/media/actions/StreamMediaAction.php @@ -99,7 +99,7 @@ public function run() { * * @return bool True in case the given extension is allowed, false otherwise. */ - private function isAllowedExtension(array $extensions, $extension) { + private function isAllowedExtension(array $extensions, string $extension) { $extension = strtolower($extension); return isset($extensions[$extension]); @@ -111,7 +111,7 @@ private function isAllowedExtension(array $extensions, $extension) { * * @return string Desired mime type, */ - private function getMimeType(array $extensions, $extension) { + private function getMimeType(array $extensions, string $extension) { $extension = strtolower($extension); return $extensions[$extension]; @@ -185,12 +185,12 @@ private function getAllowedExtensions() { return $this->getExtensions(); } catch (ConfigurationException $e) { return [ - 'png' => 'image/png', + 'png' => 'image/png', 'jpeg' => 'image/jpg', - 'jpg' => 'image/jpg', - 'gif' => 'image/gif', - 'css' => 'text/css', - 'js' => 'text/javascript' + 'jpg' => 'image/jpg', + 'gif' => 'image/gif', + 'css' => 'text/css', + 'js' => 'text/javascript' ]; } } diff --git a/tools/soap/ExtendedSoapClientService.php b/tools/soap/ExtendedSoapClientService.php index 4dde9148a..4befe082b 100644 --- a/tools/soap/ExtendedSoapClientService.php +++ b/tools/soap/ExtendedSoapClientService.php @@ -72,18 +72,18 @@ public function __construct() { /** * Use UTF-8 encoding to be compatible with most of the services (e.g. JAVA services). */ - 'encoding' => 'UTF-8', + 'encoding' => 'UTF-8', /** * Setting the boolean trace option enables use of the methods SoapClient->__getLastRequest, * SoapClient->__getLastRequestHeaders, SoapClient->__getLastResponse and SoapClient->__getLastResponseHeaders. */ - 'trace' => true, + 'trace' => true, /** * The exceptions option is a boolean value defining whether soap errors throw exceptions of type SoapFault. */ - 'exceptions' => true + 'exceptions' => true ]; } @@ -193,7 +193,7 @@ protected function getClient() { *

* Please note that the object mapping feature of PHP's SOAP client implementation is * NOT working with this method. If you want to use it, please use the - * executeRequest() function. + * __call() function. * * @example * @@ -220,7 +220,7 @@ protected function getClient() { * @version * Version 0.1, 26.01.2012
*/ - public function executeRequest($action, $request, $oneWay = null) { + public function executeRequest(string $action, string $request, bool $oneWay = null) { // lazily construct the client to be able to configure it by nice setter methods. $client = $this->getClient(); @@ -270,7 +270,7 @@ public function getSoapVersion() { * @version * Version 0.1, 26.01.2012
*/ - public function setLocation($location) { + public function setLocation(string $location) { $this->options['location'] = $location; // reconfiguration requires to create a new instance. @@ -304,7 +304,7 @@ public function getWsdlUrl() { * @version * Version 0.1, 26.01.2012
*/ - public function setWsdlUrl($wsdlUrl) { + public function setWsdlUrl(string $wsdlUrl) { $this->wsdlUrl = $wsdlUrl; } @@ -319,7 +319,7 @@ public function setWsdlUrl($wsdlUrl) { * @version * Version 0.1, 04.05.2012
*/ - public function setHttpAuthUsername($username) { + public function setHttpAuthUsername(string $username) { $this->options['login'] = $username; // reconfiguration requires to create a new instance. @@ -339,7 +339,7 @@ public function setHttpAuthUsername($username) { * @version * Version 0.1, 04.05.2012
*/ - public function setHttpAuthPassword($password) { + public function setHttpAuthPassword(string $password) { $this->options['password'] = $password; // reconfiguration requires to create a new instance. @@ -414,7 +414,7 @@ public function setCacheWsdl($cacheWsdl) { * @version * Version 0.1, 26.01.2012
*/ - public function setEncoding($encoding) { + public function setEncoding(string $encoding) { $this->options['encoding'] = $encoding; // reconfiguration requires to create a new instance. @@ -559,7 +559,7 @@ public function getTypes() { * @version * Version 0.1, 09.02.2012
*/ - public function setCookie($name, $value) { + public function setCookie(string $name, string $value) { $this->getClient()->__setCookie($name, $value); } @@ -585,7 +585,7 @@ public function setSoapHeaders($headers) { * @version * Version 0.1, 29.08.2012
*/ - public function setProxyHost($host) { + public function setProxyHost(string $host) { $this->options['proxy_host'] = $host; // reconfiguration requires to create a new instance. @@ -603,7 +603,7 @@ public function setProxyHost($host) { * @version * Version 0.1, 29.08.2012
*/ - public function setProxyPort($port) { + public function setProxyPort(string $port) { $this->options['proxy_port'] = $port; // reconfiguration requires to create a new instance. @@ -621,7 +621,7 @@ public function setProxyPort($port) { * @version * Version 0.1, 29.08.2012
*/ - public function setProxyUsername($username) { + public function setProxyUsername(string $username) { $this->options['proxy_login'] = $username; // reconfiguration requires to create a new instance. @@ -639,7 +639,7 @@ public function setProxyUsername($username) { * @version * Version 0.1, 29.08.2012
*/ - public function setProxyPassword($password) { + public function setProxyPassword(string $password) { $this->options['proxy_password'] = $password; // reconfiguration requires to create a new instance. @@ -657,7 +657,7 @@ public function setProxyPassword($password) { * @version * Version 0.1, 29.08.2012
*/ - public function setUserAgent($userAgent) { + public function setUserAgent(string $userAgent) { $this->options['user_agent'] = $userAgent; // reconfiguration requires to create a new instance. diff --git a/tools/soap/WsdlObjectMapping.php b/tools/soap/WsdlObjectMapping.php index 2a50225b3..0cbb164b7 100644 --- a/tools/soap/WsdlObjectMapping.php +++ b/tools/soap/WsdlObjectMapping.php @@ -77,7 +77,7 @@ class WsdlObjectMapping extends APFObject { * @version * Version 0.1, 29.02.2012
*/ - public function __construct($wsdlType = null, $phpClassName = null) { + public function __construct(string $wsdlType = null, string $phpClassName = null) { $this->wsdlType = $wsdlType; $this->phpClassName = $phpClassName; } @@ -87,7 +87,7 @@ public function __construct($wsdlType = null, $phpClassName = null) { * * @return WsdlObjectMapping This object for further usage. */ - public function setPhpClassName($phpClassName) { + public function setPhpClassName(string $phpClassName) { $this->phpClassName = $phpClassName; return $this; @@ -102,7 +102,7 @@ public function getPhpClassName() { * * @return WsdlObjectMapping This object for further usage. */ - public function setWsdlType($wsdlType) { + public function setWsdlType(string $wsdlType) { $this->wsdlType = $wsdlType; return $this;