diff --git a/.gitignore b/.gitignore index f8a16bc..bc62b68 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/.phpcs-cache /clover.xml /coveralls-upload.json /phpunit.xml diff --git a/composer.json b/composer.json index 3e40031..55b8f18 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,9 @@ "forum": "https://discourse.laminas.dev" }, "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + }, "sort-packages": true, "platform": { "php": "7.4.99" @@ -39,7 +42,7 @@ "symfony/var-dumper": "^5.0.1 || ^6.0" }, "require-dev": { - "laminas/laminas-coding-standard": "~1.0.0", + "laminas/laminas-coding-standard": "~2.4.0", "phpunit/phpunit": "^9.3" }, "suggest": { diff --git a/composer.lock b/composer.lock index ffd29b4..cbd438d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "75ac174304e9420f758a70adb4b31362", + "content-hash": "c5f65de09d8a241704f618732917eef1", "packages": [ { "name": "brick/varexporter", @@ -1481,6 +1481,81 @@ } ], "packages-dev": [ + { + "name": "dealerdirect/phpcodesniffer-composer-installer", + "version": "v0.7.2", + "source": { + "type": "git", + "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", + "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", + "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0 || ^2.0", + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" + }, + "require-dev": { + "composer/composer": "*", + "php-parallel-lint/php-parallel-lint": "^1.3.1", + "phpcompatibility/php-compatibility": "^9.0" + }, + "type": "composer-plugin", + "extra": { + "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + }, + "autoload": { + "psr-4": { + "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Franck Nijhof", + "email": "franck.nijhof@dealerdirect.com", + "homepage": "http://www.frenck.nl", + "role": "Developer / IT Manager" + }, + { + "name": "Contributors", + "homepage": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer Standards Composer Installer Plugin", + "homepage": "http://www.dealerdirect.com", + "keywords": [ + "PHPCodeSniffer", + "PHP_CodeSniffer", + "code quality", + "codesniffer", + "composer", + "installer", + "phpcbf", + "phpcs", + "plugin", + "qa", + "quality", + "standard", + "standards", + "style guide", + "stylecheck", + "tests" + ], + "support": { + "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues", + "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer" + }, + "time": "2022-02-04T12:51:07+00:00" + }, { "name": "doctrine/instantiator", "version": "1.4.1", @@ -1553,31 +1628,39 @@ }, { "name": "laminas/laminas-coding-standard", - "version": "1.0.0", + "version": "2.4.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-coding-standard.git", - "reference": "08880ce2fbfe62d471cd3cb766a91da630b32539" + "reference": "eb076dd86aa93dd424856b150c9b6f76c1fdfabc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-coding-standard/zipball/08880ce2fbfe62d471cd3cb766a91da630b32539", - "reference": "08880ce2fbfe62d471cd3cb766a91da630b32539", + "url": "https://api.github.com/repos/laminas/laminas-coding-standard/zipball/eb076dd86aa93dd424856b150c9b6f76c1fdfabc", + "reference": "eb076dd86aa93dd424856b150c9b6f76c1fdfabc", "shasum": "" }, "require": { - "laminas/laminas-zendframework-bridge": "^1.0", - "squizlabs/php_codesniffer": "^2.7" + "dealerdirect/phpcodesniffer-composer-installer": "^0.7", + "php": "^7.4 || ^8.0", + "slevomat/coding-standard": "^7.0", + "squizlabs/php_codesniffer": "^3.6", + "webimpress/coding-standard": "^1.2" }, - "replace": { - "zendframework/zend-coding-standard": "self.version" + "conflict": { + "phpstan/phpdoc-parser": ">=1.6.0" + }, + "type": "phpcodesniffer-standard", + "autoload": { + "psr-4": { + "LaminasCodingStandard\\": "src/LaminasCodingStandard/" + } }, - "type": "library", "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "description": "Laminas coding standard", + "description": "Laminas Coding Standard", "homepage": "https://laminas.dev", "keywords": [ "Coding Standard", @@ -1591,69 +1674,13 @@ "rss": "https://github.com/laminas/laminas-coding-standard/releases.atom", "source": "https://github.com/laminas/laminas-coding-standard" }, - "time": "2019-12-31T16:28:26+00:00" - }, - { - "name": "laminas/laminas-zendframework-bridge", - "version": "1.6.1", - "source": { - "type": "git", - "url": "https://github.com/laminas/laminas-zendframework-bridge.git", - "reference": "e112dd2c099f4f6142c16fc65fda89a638e06885" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-zendframework-bridge/zipball/e112dd2c099f4f6142c16fc65fda89a638e06885", - "reference": "e112dd2c099f4f6142c16fc65fda89a638e06885", - "shasum": "" - }, - "require": { - "php": ">=7.4, <8.2" - }, - "require-dev": { - "phpunit/phpunit": "^9.5.14", - "psalm/plugin-phpunit": "^0.15.2", - "squizlabs/php_codesniffer": "^3.6.2", - "vimeo/psalm": "^4.21.0" - }, - "type": "library", - "extra": { - "laminas": { - "module": "Laminas\\ZendFrameworkBridge" - } - }, - "autoload": { - "files": [ - "src/autoload.php" - ], - "psr-4": { - "Laminas\\ZendFrameworkBridge\\": "src//" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "Alias legacy ZF class names to Laminas Project equivalents.", - "keywords": [ - "ZendFramework", - "autoloading", - "laminas", - "zf" - ], - "support": { - "forum": "https://discourse.laminas.dev/", - "issues": "https://github.com/laminas/laminas-zendframework-bridge/issues", - "rss": "https://github.com/laminas/laminas-zendframework-bridge/releases.atom", - "source": "https://github.com/laminas/laminas-zendframework-bridge" - }, "funding": [ { "url": "https://funding.communitybridge.org/projects/laminas-project", "type": "community_bridge" } ], - "time": "2022-07-29T13:28:29+00:00" + "time": "2022-08-24T17:45:47+00:00" }, { "name": "myclabs/deep-copy", @@ -1825,6 +1852,50 @@ }, "time": "2022-02-21T01:04:05+00:00" }, + { + "name": "phpstan/phpdoc-parser", + "version": "1.5.1", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpdoc-parser.git", + "reference": "981cc368a216c988e862a75e526b6076987d1b50" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/981cc368a216c988e862a75e526b6076987d1b50", + "reference": "981cc368a216c988e862a75e526b6076987d1b50", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^1.5", + "phpstan/phpstan-strict-rules": "^1.0", + "phpunit/phpunit": "^9.5", + "symfony/process": "^5.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "PHPStan\\PhpDocParser\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPDoc parser with support for nullable, intersection and generic types", + "support": { + "issues": "https://github.com/phpstan/phpdoc-parser/issues", + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.5.1" + }, + "time": "2022-05-05T11:32:40+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "9.2.17", @@ -3205,66 +3276,100 @@ ], "time": "2020-09-28T06:39:44+00:00" }, + { + "name": "slevomat/coding-standard", + "version": "7.2.1", + "source": { + "type": "git", + "url": "https://github.com/slevomat/coding-standard.git", + "reference": "aff06ae7a84e4534bf6f821dc982a93a5d477c90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/aff06ae7a84e4534bf6f821dc982a93a5d477c90", + "reference": "aff06ae7a84e4534bf6f821dc982a93a5d477c90", + "shasum": "" + }, + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7", + "php": "^7.2 || ^8.0", + "phpstan/phpdoc-parser": "^1.5.1", + "squizlabs/php_codesniffer": "^3.6.2" + }, + "require-dev": { + "phing/phing": "2.17.3", + "php-parallel-lint/php-parallel-lint": "1.3.2", + "phpstan/phpstan": "1.4.10|1.7.1", + "phpstan/phpstan-deprecation-rules": "1.0.0", + "phpstan/phpstan-phpunit": "1.0.0|1.1.1", + "phpstan/phpstan-strict-rules": "1.2.3", + "phpunit/phpunit": "7.5.20|8.5.21|9.5.20" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-master": "7.x-dev" + } + }, + "autoload": { + "psr-4": { + "SlevomatCodingStandard\\": "SlevomatCodingStandard" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", + "support": { + "issues": "https://github.com/slevomat/coding-standard/issues", + "source": "https://github.com/slevomat/coding-standard/tree/7.2.1" + }, + "funding": [ + { + "url": "https://github.com/kukulich", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/slevomat/coding-standard", + "type": "tidelift" + } + ], + "time": "2022-05-25T10:58:12+00:00" + }, { "name": "squizlabs/php_codesniffer", - "version": "2.9.2", + "version": "3.7.1", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "2acf168de78487db620ab4bc524135a13cfe6745" + "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/2acf168de78487db620ab4bc524135a13cfe6745", - "reference": "2acf168de78487db620ab4bc524135a13cfe6745", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/1359e176e9307e906dc3d890bcc9603ff6d90619", + "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619", "shasum": "" }, "require": { "ext-simplexml": "*", "ext-tokenizer": "*", "ext-xmlwriter": "*", - "php": ">=5.1.2" + "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" }, "bin": [ - "scripts/phpcs", - "scripts/phpcbf" + "bin/phpcs", + "bin/phpcbf" ], "type": "library", "extra": { "branch-alias": { - "dev-master": "2.x-dev" + "dev-master": "3.x-dev" } }, - "autoload": { - "classmap": [ - "CodeSniffer.php", - "CodeSniffer/CLI.php", - "CodeSniffer/Exception.php", - "CodeSniffer/File.php", - "CodeSniffer/Fixer.php", - "CodeSniffer/Report.php", - "CodeSniffer/Reporting.php", - "CodeSniffer/Sniff.php", - "CodeSniffer/Tokens.php", - "CodeSniffer/Reports/", - "CodeSniffer/Tokenizers/", - "CodeSniffer/DocGenerators/", - "CodeSniffer/Standards/AbstractPatternSniff.php", - "CodeSniffer/Standards/AbstractScopeSniff.php", - "CodeSniffer/Standards/AbstractVariableSniff.php", - "CodeSniffer/Standards/IncorrectPatternException.php", - "CodeSniffer/Standards/Generic/Sniffs/", - "CodeSniffer/Standards/MySource/Sniffs/", - "CodeSniffer/Standards/PEAR/Sniffs/", - "CodeSniffer/Standards/PSR1/Sniffs/", - "CodeSniffer/Standards/PSR2/Sniffs/", - "CodeSniffer/Standards/Squiz/Sniffs/", - "CodeSniffer/Standards/Zend/Sniffs/" - ] - }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" @@ -3276,7 +3381,7 @@ } ], "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "http://www.squizlabs.com/php-codesniffer", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", "keywords": [ "phpcs", "standards" @@ -3286,7 +3391,7 @@ "source": "https://github.com/squizlabs/PHP_CodeSniffer", "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" }, - "time": "2018-11-07T22:31:41+00:00" + "time": "2022-06-18T07:21:10+00:00" }, { "name": "theseer/tokenizer", @@ -3337,6 +3442,61 @@ } ], "time": "2021-07-28T10:34:58+00:00" + }, + { + "name": "webimpress/coding-standard", + "version": "1.2.4", + "source": { + "type": "git", + "url": "https://github.com/webimpress/coding-standard.git", + "reference": "cd0c4b0b97440c337c1f7da17b524674ca2f9ca9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webimpress/coding-standard/zipball/cd0c4b0b97440c337c1f7da17b524674ca2f9ca9", + "reference": "cd0c4b0b97440c337c1f7da17b524674ca2f9ca9", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0", + "squizlabs/php_codesniffer": "^3.6.2" + }, + "require-dev": { + "phpunit/phpunit": "^9.5.13" + }, + "type": "phpcodesniffer-standard", + "extra": { + "dev-master": "1.2.x-dev", + "dev-develop": "1.3.x-dev" + }, + "autoload": { + "psr-4": { + "WebimpressCodingStandard\\": "src/WebimpressCodingStandard/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "description": "Webimpress Coding Standard", + "keywords": [ + "Coding Standard", + "PSR-2", + "phpcs", + "psr-12", + "webimpress" + ], + "support": { + "issues": "https://github.com/webimpress/coding-standard/issues", + "source": "https://github.com/webimpress/coding-standard/tree/1.2.4" + }, + "funding": [ + { + "url": "https://github.com/michalbundyra", + "type": "github" + } + ], + "time": "2022-02-15T19:52:12+00:00" } ], "aliases": [], diff --git a/config/module.config.php b/config/module.config.php index 6a0b8b1..37ce6b1 100644 --- a/config/module.config.php +++ b/config/module.config.php @@ -1,4 +1,7 @@ [ 'template_path_stack' => [ diff --git a/phpcs.xml b/phpcs.xml index 0310a7b..0f279ea 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,10 +1,22 @@ - - + + + + + + + + + + - src - test config/module.config.php config/laminas-developer-tools.local.php.dist + src + test + + + diff --git a/src/Collector/AbstractCollector.php b/src/Collector/AbstractCollector.php index 39728b5..0883f75 100644 --- a/src/Collector/AbstractCollector.php +++ b/src/Collector/AbstractCollector.php @@ -1,12 +1,16 @@ data); @@ -25,12 +32,18 @@ public function __serialize() /** * @deprecated since 2.3.0, this method will be removed in version 3.0.0 of this component. * {@see Serializable} as alternative + * + * @inheritDoc */ public function serialize() { return $this->__serialize(); } + /** + * @param string $data + * @return void + */ public function __unserialize($data) { $this->data = unserialize($data); @@ -39,6 +52,8 @@ public function __unserialize($data) /** * @deprecated since 2.3.0, this method will be removed in version 3.0.0 of this component. * {@see Serializable} as alternative + * + * @inheritDoc */ public function unserialize($data) { diff --git a/src/Collector/AutoHideInterface.php b/src/Collector/AutoHideInterface.php index 08185fe..210fddb 100644 --- a/src/Collector/AutoHideInterface.php +++ b/src/Collector/AutoHideInterface.php @@ -1,5 +1,7 @@ applicationConfig) ? $this->unserializeArray($this->applicationConfig) : null; } + /** + * @return string + */ public function __serialize() { return serialize(['config' => $this->config, 'applicationConfig' => $this->applicationConfig]); @@ -87,12 +92,18 @@ public function __serialize() /** * @deprecated since 2.3.0, this method will be removed in version 3.0.0 of this component. * {@see Serializable} as alternative + * + * @inheritDoc */ public function serialize() { return $this->__serialize(); } + /** + * @param string $serialized + * @return void + */ public function __unserialize($serialized) { $data = unserialize($serialized); @@ -103,6 +114,8 @@ public function __unserialize($serialized) /** * @deprecated since 2.3.0, this method will be removed in version 3.0.0 of this component. * {@see Serializable} as alternative + * + * @inheritDoc */ public function unserialize($serialized) { @@ -112,7 +125,7 @@ public function unserialize($serialized) /** * Replaces the un-serializable items in an array with stubs * - * @param array|\Traversable $data + * @param array|Traversable $data * @return array */ private function makeArraySerializable($data) diff --git a/src/Collector/DbCollector.php b/src/Collector/DbCollector.php index 71a287f..7c0e8c4 100644 --- a/src/Collector/DbCollector.php +++ b/src/Collector/DbCollector.php @@ -1,23 +1,27 @@ profiler); @@ -129,12 +135,18 @@ public function __serialize() /** * @deprecated since 2.3.0, this method will be removed in version 3.0.0 of this component. * {@see Serializable} as alternative + * + * @inheritDoc */ public function serialize() { return $this->__serialize(); } + /** + * @param string $profiler + * @return void + */ public function __unserialize($profiler) { $this->profiler = unserialize($profiler); @@ -143,6 +155,8 @@ public function __unserialize($profiler) /** * @deprecated since 2.3.0, this method will be removed in version 3.0.0 of this component. * {@see Serializable} as alternative + * + * @inheritDoc */ public function unserialize($profiler) { diff --git a/src/Collector/EventCollectorInterface.php b/src/Collector/EventCollectorInterface.php index 3ba060b..7d8cd06 100644 --- a/src/Collector/EventCollectorInterface.php +++ b/src/Collector/EventCollectorInterface.php @@ -1,5 +1,7 @@ getError() === Application::ERROR_EXCEPTION) { $this->data = [ - 'exception' => new SerializableException($mvcEvent->getParam('exception')) + 'exception' => new SerializableException($mvcEvent->getParam('exception')), ]; } } @@ -56,7 +58,7 @@ public function hasException() */ public function hasPreviousException() { - return (isset($this->data['exception']) && $this->data['exception']->getPrevious() !== null); + return isset($this->data['exception']) && $this->data['exception']->getPrevious() !== null; } /** diff --git a/src/Collector/MailCollector.php b/src/Collector/MailCollector.php index da66819..ceaa1e7 100644 --- a/src/Collector/MailCollector.php +++ b/src/Collector/MailCollector.php @@ -1,17 +1,18 @@ data['memory'] = memory_get_peak_usage(true); - $this->data['end'] = memory_get_usage(true); + $this->data['end'] = memory_get_usage(true); } /** * Saves the current memory usage. * * @param string $id - * @param EventInterface $event */ public function collectEvent($id, EventInterface $event) { @@ -99,11 +107,11 @@ public function getApplicationEventMemory() $previous = null; foreach ($app as $name => $context) { - $result[$name] = $context; - $result[$name]['difference'] = ($previous) - ? ($context['memory'] - $previous['memory']) - : ($context['memory']); - $previous = prev($app); + $result[$name] = $context; + $result[$name]['difference'] = $previous + ? $context['memory'] - $previous['memory'] + : $context['memory']; + $previous = prev($app); next($app); } diff --git a/src/Collector/RequestCollector.php b/src/Collector/RequestCollector.php index c72852d..6ba6400 100644 --- a/src/Collector/RequestCollector.php +++ b/src/Collector/RequestCollector.php @@ -1,18 +1,32 @@ getRouteMatch(); + $views = []; + $match = $mvcEvent->getRouteMatch(); $viewModel = $mvcEvent->getViewModel(); $addToViewFromModel = function (ModelInterface $child) use (&$views) { @@ -51,7 +65,7 @@ public function collect(MvcEvent $mvcEvent) $views[] = [ 'template' => $child->getTemplate(), - 'vars' => $vars, + 'vars' => $vars, ]; }; @@ -59,20 +73,19 @@ public function collect(MvcEvent $mvcEvent) $this->addChildrenToView($viewModel, $addToViewFromModel); $this->data = [ - 'views' => $views, - 'method' => $mvcEvent->getRequest()->getMethod(), - 'status' => $mvcEvent->getResponse()->getStatusCode(), - 'route' => ($match === null) ? 'N/A' : $match->getMatchedRouteName(), - 'action' => ($match === null) ? 'N/A' : $match->getParam('action', 'N/A'), - 'controller' => ($match === null) ? 'N/A' : $match->getParam('controller', 'N/A'), - 'other_route_parameters' => ($match === null) ? 'N/A' : array_filter($match->getParams(), function ($key) { + 'views' => $views, + 'method' => $mvcEvent->getRequest()->getMethod(), + 'status' => $mvcEvent->getResponse()->getStatusCode(), + 'route' => $match === null ? 'N/A' : $match->getMatchedRouteName(), + 'action' => $match === null ? 'N/A' : $match->getParam('action', 'N/A'), + 'controller' => $match === null ? 'N/A' : $match->getParam('controller', 'N/A'), + 'other_route_parameters' => $match === null ? 'N/A' : array_filter($match->getParams(), function ($key) { return ! in_array($key, ['action', 'controller']); }, ARRAY_FILTER_USE_KEY), ]; } /** - * @param ModelInterface $viewModel * @param callable $addToViewFromModel */ protected function addChildrenToView(ModelInterface $viewModel, $addToViewFromModel) @@ -139,6 +152,7 @@ public function getControllerName() /** * Returns parameters except controller and actions + * * @return array */ public function getOtherParameters() diff --git a/src/Collector/TimeCollector.php b/src/Collector/TimeCollector.php index 8a40739..6747957 100644 --- a/src/Collector/TimeCollector.php +++ b/src/Collector/TimeCollector.php @@ -1,18 +1,28 @@ $context) { - $result[$index] = $context; - $result[$index]['elapsed'] = ($previous) - ? ($context['time'] - $previous['time']) - : ($context['time'] - $this->data['start']); - $previous = prev($app); + $result[$index] = $context; + $result[$index]['elapsed'] = $previous + ? $context['time'] - $previous['time'] + : $context['time'] - $this->data['start']; + $previous = prev($app); next($app); } @@ -125,7 +134,6 @@ public function getApplicationEventTimes() /** * Determine the start time * - * @param MvcEvent $mvcEvent * @return float */ private function marshalStartTime(MvcEvent $mvcEvent) diff --git a/src/Controller/IndexController.php b/src/Controller/IndexController.php index c77c34f..00a7e1f 100644 --- a/src/Controller/IndexController.php +++ b/src/Controller/IndexController.php @@ -1,5 +1,7 @@ */ interface EventContextInterface { /** * Sets the event. * - * @param EventInterface $event * @return void */ public function setEvent(EventInterface $event); diff --git a/src/EventLogging/EventContextProvider.php b/src/EventLogging/EventContextProvider.php index a34ff99..cc15e05 100644 --- a/src/EventLogging/EventContextProvider.php +++ b/src/EventLogging/EventContextProvider.php @@ -1,33 +1,41 @@ */ class EventContextProvider implements EventContextInterface { - /** - * @var EventInterface - */ + /** @var EventInterface */ protected $event; - /** - * - * @var array - */ + /** @var array */ private $debugBacktrace = []; /** * @param EventInterface|null $event (Optional) The event to provide context to. * The event must be set either here or with {@see setEvent()} before any other methods can be used. */ - public function __construct(EventInterface $event = null) + public function __construct(?EventInterface $event = null) { if ($event) { $this->setEvent($event); @@ -36,6 +44,7 @@ public function __construct(EventInterface $event = null) /** * @see \Laminas\DeveloperTools\EventLogging\EventContextInterface::setEvent() + * * @param EventInterface $event The event to add context to. * @return void */ @@ -46,6 +55,7 @@ public function setEvent(EventInterface $event) /** * @see \Laminas\DeveloperTools\EventLogging\EventContextInterface::getEvent() + * * @return EventInterface */ public function getEvent() @@ -105,7 +115,7 @@ private function getDebugBacktrace() { if (! $this->debugBacktrace) { //Remove the levels this method introduces - $trace = debug_backtrace(); + $trace = debug_backtrace(); $this->debugBacktrace = array_splice($trace, 2); } diff --git a/src/Exception/CollectorException.php b/src/Exception/CollectorException.php index 1db5f73..c47b93a 100644 --- a/src/Exception/CollectorException.php +++ b/src/Exception/CollectorException.php @@ -1,7 +1,11 @@ (http://symfony.com/) - * @license http://symfony.com/doc/current/contributing/code/license.html MIT license - * * @param array $trace * @param string $file * @param integer $line @@ -118,23 +130,23 @@ protected function filterTrace($trace, $file, $line) ]; foreach ($trace as $entry) { - $class = ''; + $class = ''; $namespace = ''; if (isset($entry['class'])) { - $parts = explode('\\', $entry['class']); - $class = array_pop($parts); + $parts = explode('\\', $entry['class']); + $class = array_pop($parts); $namespace = implode('\\', $parts); } $filteredTrace[] = [ 'namespace' => $namespace, 'short_class' => $class, - 'class' => isset($entry['class']) ? $entry['class'] : '', - 'type' => isset($entry['type']) ? $entry['type'] : '', + 'class' => $entry['class'] ?? '', + 'type' => $entry['type'] ?? '', 'function' => $entry['function'], - 'file' => isset($entry['file']) ? $entry['file'] : null, - 'line' => isset($entry['line']) ? $entry['line'] : null, + 'file' => $entry['file'] ?? null, + 'line' => $entry['line'] ?? null, 'args' => isset($entry['args']) ? $this->filterArgs($entry['args']) : [], ]; } @@ -145,9 +157,6 @@ protected function filterTrace($trace, $file, $line) /** * This function uses code coming from Symfony 2. * - * @copyright Copyright (c) Fabien Potencier (http://symfony.com/) - * @license http://symfony.com/doc/current/contributing/code/license.html MIT license - * * @param array $args * @param integer $level * @return array @@ -192,6 +201,9 @@ protected function filterArgs($args, $level = 0) return $result; } + /** + * @return string + */ public function __serialize() { return serialize($this->data); @@ -200,12 +212,18 @@ public function __serialize() /** * @deprecated since 2.3.0, this method will be removed in version 3.0.0 of this component. * {@see Serializable} as alternative + * + * @inheritDoc */ public function serialize() { return $this->__serialize(); } + /** + * @param string $data + * @return void + */ public function __unserialize($data) { $this->data = unserialize($data); @@ -214,6 +232,8 @@ public function __unserialize($data) /** * @deprecated since 2.3.0, this method will be removed in version 3.0.0 of this component. * {@see Serializable} as alternative + * + * @inheritDoc */ public function unserialize($data) { diff --git a/src/Listener/EventLoggingListenerAggregate.php b/src/Listener/EventLoggingListenerAggregate.php index c50a10e..88d1265 100644 --- a/src/Listener/EventLoggingListenerAggregate.php +++ b/src/Listener/EventLoggingListenerAggregate.php @@ -1,5 +1,7 @@ * @since 0.0.3 */ class EventLoggingListenerAggregate { - /** - * @var EventCollectorInterface[] - */ + /** @var EventCollectorInterface[] */ protected $collectors; - /** - * @var string[] The event identifiers to collect - */ + /** @var string[] The event identifiers to collect */ protected $identifiers; /** - * Constructor. - * * @param EventCollectorInterface[] $collectors * @param string[] $identifiers */ public function __construct(array $collectors, array $identifiers) { - $this->collectors = array_map( + $this->collectors = array_map( function (CollectorInterface $collector) { return $collector; }, @@ -50,7 +48,9 @@ function ($identifier) { } /** - * {@inheritdoc} + * Attach events to a shared event manager + * + * @return void */ public function attachShared(SharedEventManagerInterface $events) { @@ -60,7 +60,9 @@ public function attachShared(SharedEventManagerInterface $events) } /** - * {@inheritdoc} + * Detach events from a shared event manager + * + * @return void */ public function detachShared(SharedEventManagerInterface $events) { @@ -70,8 +72,7 @@ public function detachShared(SharedEventManagerInterface $events) /** * Callback to process events * - * @param EventInterface $event - * @return bool + * @return void * @throws ServiceNotFoundException */ public function onCollectEvent(EventInterface $event) diff --git a/src/Listener/FirePhpListener.php b/src/Listener/FirePhpListener.php index 0486d72..87d1e92 100644 --- a/src/Listener/FirePhpListener.php +++ b/src/Listener/FirePhpListener.php @@ -1,5 +1,7 @@ serviceLocator = $serviceLocator; } /** - * {@inheritdoc} + * @inheritDoc */ public function attach(EventManagerInterface $events, $priority = 1) { @@ -45,8 +40,6 @@ public function attach(EventManagerInterface $events, $priority = 1) /** * ProfilerEvent::EVENT_COLLECTED event callback. - * - * @param ProfilerEvent $event */ public function onCollected(ProfilerEvent $event) { diff --git a/src/Listener/FlushListener.php b/src/Listener/FlushListener.php index 748452a..fe9a0e6 100644 --- a/src/Listener/FlushListener.php +++ b/src/Listener/FlushListener.php @@ -1,5 +1,7 @@ options = $options; @@ -44,7 +38,7 @@ public function __construct(ServiceLocatorInterface $serviceLocator, Options $op } /** - * {@inheritdoc} + * @inheritDoc */ public function attach(EventManagerInterface $events, $priority = 1) { @@ -58,7 +52,6 @@ public function attach(EventManagerInterface $events, $priority = 1) /** * MvcEvent::EVENT_FINISH event callback * - * @param MvcEvent $event * @throws ServiceNotFoundException */ public function onFinish(MvcEvent $event) diff --git a/src/Listener/StorageListener.php b/src/Listener/StorageListener.php index f92fdd9..596032d 100644 --- a/src/Listener/StorageListener.php +++ b/src/Listener/StorageListener.php @@ -1,5 +1,7 @@ serviceLocator = $serviceLocator; } /** - * {@inheritdoc} + * @inheritDoc */ public function attach(EventManagerInterface $events, $priority = 1) { @@ -45,8 +40,6 @@ public function attach(EventManagerInterface $events, $priority = 1) /** * ProfilerEvent::EVENT_COLLECTED event callback. - * - * @param ProfilerEvent $event */ public function onCollected(ProfilerEvent $event) { diff --git a/src/Listener/ToolbarListener.php b/src/Listener/ToolbarListener.php index 1f16e18..4ec8523 100644 --- a/src/Listener/ToolbarListener.php +++ b/src/Listener/ToolbarListener.php @@ -1,5 +1,7 @@ getResponse(); - $headers = $response->getHeaders(); - if ($headers->has('Content-Type') + $headers = $response->getHeaders(); + if ( + $headers->has('Content-Type') && false === strpos($headers->get('Content-Type')->getFieldValue(), 'html') ) { return; @@ -100,32 +111,30 @@ public function onCollected(ProfilerEvent $event) /** * Tries to injects the toolbar into the view. The toolbar is only injected in well * formed HTML by replacing the closing body tag, leaving ESI untouched. - * - * @param ProfilerEvent $event */ protected function injectToolbar(ProfilerEvent $event) { - $entries = $this->renderEntries($event); - $response = $event->getApplication()->getResponse(); + $entries = $this->renderEntries($event); + $response = $event->getApplication()->getResponse(); $toolbarView = new ViewModel(['entries' => $entries]); $toolbarView->setTemplate('laminas-developer-tools/toolbar/toolbar'); - $toolbar = $this->renderer->render($toolbarView); + $toolbar = $this->renderer->render($toolbarView); - $toolbarCss = new ViewModel([ + $toolbarCss = new ViewModel([ 'position' => $this->options->getToolbarPosition(), ]); $toolbarCss->setTemplate('laminas-developer-tools/toolbar/style'); - $style = $this->renderer->render($toolbarCss); + $style = $this->renderer->render($toolbarCss); - $toolbarJs = new ViewModel(); + $toolbarJs = new ViewModel(); $toolbarJs->setTemplate('laminas-developer-tools/toolbar/script'); - $script = $this->renderer->render($toolbarJs); + $script = $this->renderer->render($toolbarJs); - $toolbar = str_replace(['$', '\\\\'], ['\$', '\\\\\\'], $toolbar); + $toolbar = str_replace(['$', '\\\\'], ['\$', '\\\\\\'], $toolbar); $content = $response->getBody(); - $isHTML5 = stripos($content, '') === 0; + $isHtml5 = stripos($content, '') === 0; if (preg_match('/<\/body>(?![\s\S]*<\/body>)/i', $content)) { $injected = preg_replace( @@ -135,16 +144,16 @@ protected function injectToolbar(ProfilerEvent $event) 1 ); - $prepend = $isHTML5 + $prepend = $isHtml5 ? (preg_match('/<\/head>/i', $injected) ? 'head' : 'body') : 'body'; $injected = preg_replace('/<\/' . $prepend . '>/i', $style . "\n", $injected, 1); } else { - $injected = $isHTML5 + $injected = $isHtml5 ? (stripos($content, '') !== false ? preg_replace('/<\/html>/i', $style . $toolbar . $script . "\n", $content, 1) - : '' . $content . $style. $toolbar . $script) + : '' . $content . $style . $toolbar . $script) : $content; } @@ -154,14 +163,13 @@ protected function injectToolbar(ProfilerEvent $event) /** * Renders all toolbar entries. * - * @param ProfilerEvent $event * @return array * @throws InvalidOptionException */ protected function renderEntries(ProfilerEvent $event) { - $entries = []; - $report = $event->getReport(); + $entries = []; + $report = $event->getReport(); $laminasEntry = new ViewModel([ 'php_version' => phpversion(), 'has_intl' => extension_loaded('intl'), @@ -180,7 +188,8 @@ protected function renderEntries(ProfilerEvent $event) try { $collectorInstance = $report->getCollector($name); - if ($this->options->getToolbarAutoHide() + if ( + $this->options->getToolbarAutoHide() && $collectorInstance instanceof AutoHideInterface && $collectorInstance->canHide() ) { @@ -213,7 +222,7 @@ protected function renderEntries(ProfilerEvent $event) } if ($report->hasErrors()) { - $errorTpl = new ViewModel(['errors' => $report->getErrors()]); + $errorTpl = new ViewModel(['errors' => $report->getErrors()]); $errorTpl->setTemplate('laminas-developer-tools/toolbar/error'); $entries[] = $this->renderer->render($errorTpl); } @@ -253,8 +262,8 @@ protected function getLatestVersion($currentVersion) } return [ - ($cache[1] === 'yes') ? true : false, - $cache[2] + $cache[1] === 'yes' ? true : false, + $cache[2], ]; } } @@ -267,8 +276,8 @@ protected function getLatestVersion($currentVersion) sprintf( '%d|%s|%s', time(), - ($isLatest) ? 'yes' : 'no', - ($latest === null) ? 'N/A' : $latest + $isLatest ? 'yes' : 'no', + $latest ?? 'N/A' ) ); diff --git a/src/MatchInterface.php b/src/MatchInterface.php index bba6f86..d993a3d 100644 --- a/src/MatchInterface.php +++ b/src/MatchInterface.php @@ -1,5 +1,7 @@ getTarget()->getEventManager(); $configuration = $event->getConfigListener()->getMergedConfig(false); - if (isset($configuration['laminas-developer-tools']['profiler']['enabled']) + if ( + isset($configuration['laminas-developer-tools']['profiler']['enabled']) && $configuration['laminas-developer-tools']['profiler']['enabled'] === true ) { $eventManager->trigger(ProfilerEvent::EVENT_PROFILER_INIT, $event); @@ -60,7 +73,6 @@ public function onLoadModulesPost($event) /** * Laminas\Mvc\MvcEvent::EVENT_BOOTSTRAP event callback * - * @param EventInterface $event * @throws Exception\InvalidOptionException * @throws Exception\ProfilerException */ @@ -79,7 +91,7 @@ public function onBootstrap(EventInterface $event) return; } - $em = $app->getEventManager(); + $em = $app->getEventManager(); $report = $sm->get(Report::class); if ($options->canFlushEarly()) { @@ -92,7 +104,7 @@ public function onBootstrap(EventInterface $event) } if ($options->eventCollectionEnabled()) { - $sem = $em->getSharedManager(); + $sem = $em->getSharedManager(); $eventLoggingListener = $sm->get(Listener\EventLoggingListenerAggregate::class); $eventLoggingListener->attachShared($sem); } @@ -111,20 +123,23 @@ public function onBootstrap(EventInterface $event) } /** - * @inheritdoc + * @inheritDoc */ public function getConfig() { return include __DIR__ . '/../config/module.config.php'; } + /** + * @inheritDoc + */ public function getViewHelperConfig() { return [ // Legacy Zend Framework aliases - 'aliases' => [ - 'ZendDeveloperToolsTime' => 'LaminasDeveloperToolsTime', - 'ZendDeveloperToolsMemory' => 'LaminasDeveloperToolsMemory', + 'aliases' => [ + 'ZendDeveloperToolsTime' => 'LaminasDeveloperToolsTime', + 'ZendDeveloperToolsMemory' => 'LaminasDeveloperToolsMemory', 'ZendDeveloperToolsDetailArray' => 'LaminasDeveloperToolsDetailArray', ], 'invokables' => [ @@ -136,31 +151,31 @@ public function getViewHelperConfig() } /** - * @inheritdoc + * @inheritDoc */ public function getServiceConfig() { return [ - 'aliases' => [ - 'Laminas\DeveloperTools\ReportInterface' => Report::class, + 'aliases' => [ + ReportInterface::class => Report::class, // Legacy Zend Framework aliases - 'ZendDeveloperTools\ReportInterface' => 'Laminas\DeveloperTools\ReportInterface', - \ZendDeveloperTools\Report::class => Report::class, + 'ZendDeveloperTools\ReportInterface' => ReportInterface::class, + \ZendDeveloperTools\Report::class => Report::class, 'ZendDeveloperTools\ExceptionCollector' => 'Laminas\DeveloperTools\ExceptionCollector', - 'ZendDeveloperTools\RequestCollector' => 'Laminas\DeveloperTools\RequestCollector', - 'ZendDeveloperTools\ConfigCollector' => 'Laminas\DeveloperTools\ConfigCollector', - 'ZendDeveloperTools\MailCollector' => 'Laminas\DeveloperTools\MailCollector', - 'ZendDeveloperTools\MemoryCollector' => 'Laminas\DeveloperTools\MemoryCollector', - 'ZendDeveloperTools\TimeCollector' => 'Laminas\DeveloperTools\TimeCollector', - 'ZendDeveloperTools\FlushListener' => 'Laminas\DeveloperTools\FlushListener', - \ZendDeveloperTools\Profiler::class => Profiler::class, - 'ZendDeveloperTools\Config' => 'Laminas\DeveloperTools\Config', - 'ZendDeveloperTools\Event' => 'Laminas\DeveloperTools\Event', - 'ZendDeveloperTools\StorageListener' => 'Laminas\DeveloperTools\StorageListener', - \ZendDeveloperTools\Listener\ToolbarListener::class => Listener\ToolbarListener::class, - \ZendDeveloperTools\Listener\ProfilerListener::class => Listener\ProfilerListener::class, - \ZendDeveloperTools\Listener\EventLoggingListenerAggregate::class + 'ZendDeveloperTools\RequestCollector' => 'Laminas\DeveloperTools\RequestCollector', + 'ZendDeveloperTools\ConfigCollector' => 'Laminas\DeveloperTools\ConfigCollector', + 'ZendDeveloperTools\MailCollector' => 'Laminas\DeveloperTools\MailCollector', + 'ZendDeveloperTools\MemoryCollector' => 'Laminas\DeveloperTools\MemoryCollector', + 'ZendDeveloperTools\TimeCollector' => 'Laminas\DeveloperTools\TimeCollector', + 'ZendDeveloperTools\FlushListener' => 'Laminas\DeveloperTools\FlushListener', + \ZendDeveloperTools\Profiler::class => Profiler::class, + 'ZendDeveloperTools\Config' => 'Laminas\DeveloperTools\Config', + 'ZendDeveloperTools\Event' => 'Laminas\DeveloperTools\Event', + 'ZendDeveloperTools\StorageListener' => 'Laminas\DeveloperTools\StorageListener', + ToolbarListener::class => Listener\ToolbarListener::class, + ProfilerListener::class => Listener\ProfilerListener::class, + EventLoggingListenerAggregate::class => Listener\EventLoggingListenerAggregate::class, 'ZendDeveloperTools\DbCollector' => 'Laminas\DeveloperTools\DbCollector', ], @@ -174,35 +189,35 @@ public function getServiceConfig() 'Laminas\DeveloperTools\TimeCollector' => Collector\TimeCollector::class, 'Laminas\DeveloperTools\FlushListener' => Listener\FlushListener::class, ], - 'factories' => [ - Profiler::class => function ($sm) { + 'factories' => [ + Profiler::class => function ($sm) { $a = new Profiler($sm->get(Report::class)); $a->setEvent($sm->get('Laminas\DeveloperTools\Event')); return $a; }, - 'Laminas\DeveloperTools\Config' => function ($sm) { + 'Laminas\DeveloperTools\Config' => function ($sm) { $config = $sm->get('Configuration'); - $config = isset($config['laminas-developer-tools']) ? $config['laminas-developer-tools'] : null; + $config = $config['laminas-developer-tools'] ?? null; return new Options($config, $sm->get(Report::class)); }, - 'Laminas\DeveloperTools\Event' => function ($sm) { + 'Laminas\DeveloperTools\Event' => function ($sm) { $event = new ProfilerEvent(); $event->setReport($sm->get(Report::class)); $event->setApplication($sm->get('Application')); return $event; }, - 'Laminas\DeveloperTools\StorageListener' => function ($sm) { + 'Laminas\DeveloperTools\StorageListener' => function ($sm) { return new Listener\StorageListener($sm); }, - Listener\ToolbarListener::class => function ($sm) { + Listener\ToolbarListener::class => function ($sm) { return new Listener\ToolbarListener( $sm->get('ViewRenderer'), $sm->get('Laminas\DeveloperTools\Config') ); }, - Listener\ProfilerListener::class => function ($sm) { + Listener\ProfilerListener::class => function ($sm) { return new Listener\ProfilerListener($sm, $sm->get('Laminas\DeveloperTools\Config')); }, Listener\EventLoggingListenerAggregate::class => function ($sm) { @@ -213,7 +228,7 @@ public function getServiceConfig() $config->getEventIdentifiers() ); }, - 'Laminas\DeveloperTools\DbCollector' => function ($sm) { + 'Laminas\DeveloperTools\DbCollector' => function ($sm) { $p = false; $db = new Collector\DbCollector(); diff --git a/src/Options.php b/src/Options.php index a04a3be..ea98059 100644 --- a/src/Options.php +++ b/src/Options.php @@ -1,29 +1,32 @@ false, 'strict' => true, 'flush_early' => false, 'cache_dir' => 'data/cache', 'matcher' => [], - 'collectors' => [ + 'collectors' => [ 'db' => DbCollector::class, 'exception' => ExceptionCollector::class, 'request' => RequestCollector::class, @@ -35,22 +38,21 @@ class Options extends AbstractOptions /** * Defaults for event-level logging + * * @var array */ protected $events = [ - 'enabled' => false, - 'collectors' => [ + 'enabled' => false, + 'collectors' => [ 'memory' => MemoryCollector::class, 'time' => TimeCollector::class, ], 'identifiers' => [ - 'all' => '*' - ] + 'all' => '*', + ], ]; - /** - * @var array - */ + /** @var array */ protected $toolbar = [ 'enabled' => false, 'auto_hide' => false, @@ -66,11 +68,8 @@ class Options extends AbstractOptions ]; /** - * Overloading Constructor. - * * @param array|Traversable|null $options - * @param ReportInterface $report - * @throws \Laminas\Stdlib\Exception\InvalidArgumentException + * @throws InvalidArgumentException */ public function __construct($options, ReportInterface $report) { @@ -131,7 +130,6 @@ public function setEvents(array $options) } } - /** * Sets Profiler matcher options. * @@ -166,7 +164,7 @@ protected function setCollectors($options) } foreach ($options as $name => $collector) { - if (($collector === false || $collector === null)) { + if ($collector === false || $collector === null) { unset($this->profiler['collectors'][$name]); continue; } @@ -201,7 +199,7 @@ public function setEventCollectors(array $options) } foreach ($options as $name => $collector) { - if (($collector === false || $collector === null)) { + if ($collector === false || $collector === null) { unset($this->events['collectors'][$name]); continue; } @@ -227,7 +225,7 @@ public function setEventIdentifiers(array $options) } foreach ($options as $name => $identifier) { - if (($identifier === false || $identifier === null)) { + if ($identifier === false || $identifier === null) { unset($this->events['identifiers'][$name]); continue; } @@ -266,9 +264,9 @@ public function isStrict() */ public function canFlushEarly() { - return ($this->profiler['flush_early'] + return $this->profiler['flush_early'] && ! $this->profiler['strict'] - && ! $this->toolbar['enabled']); + && ! $this->toolbar['enabled']; } /** @@ -314,7 +312,6 @@ public function getEventIdentifiers() return $this->events['identifiers']; } - /** * Sets Toolbar options. * diff --git a/src/Profiler.php b/src/Profiler.php index ac8758a..d616c28 100644 --- a/src/Profiler.php +++ b/src/Profiler.php @@ -1,15 +1,23 @@ report = $report; @@ -105,7 +98,6 @@ public function setErrorMode($mode) /** * Set the profiler event object. * - * @param EventInterface $event * @return self */ public function setEvent(EventInterface $event) @@ -133,12 +125,11 @@ public function getEvent() /** * Set the event manager instance * - * @param EventManagerInterface $eventManager * @return self */ public function setEventManager(EventManagerInterface $eventManager) { - $eventManager->addIdentifiers([__CLASS__, get_called_class(), 'profiler']); + $eventManager->addIdentifiers([self::class, static::class, 'profiler']); $this->eventManager = $eventManager; return $this; @@ -185,7 +176,6 @@ public function addCollector($collector) * Runs all collectors. * * @triggers ProfilerEvent::EVENT_COLLECTED - * @param MvcEvent $mvcEvent * @return Profiler * @throws Exception\ProfilerException */ diff --git a/src/ProfilerEvent.php b/src/ProfilerEvent.php index a79211c..ce91685 100644 --- a/src/ProfilerEvent.php +++ b/src/ProfilerEvent.php @@ -1,5 +1,7 @@ '; $r[] = ''; $r[] = $label; $r[] = ''; - $extraCss = ''; $newLine = false; foreach ($details as $entry) { if ($newLine === true) { $r[] = ''; } diff --git a/src/View/Helper/Memory.php b/src/View/Helper/Memory.php index c845912..086a416 100644 --- a/src/View/Helper/Memory.php +++ b/src/View/Helper/Memory.php @@ -1,9 +1,13 @@ getMockBuilder(Mvc\Application::class) + $application = $this->getMockBuilder(Mvc\Application::class) ->disableOriginalConstructor() ->getMock(); $serviceManager = $this->getMockBuilder(ServiceManager\ServiceManager::class) diff --git a/test/Collector/MemoryCollectorTest.php b/test/Collector/MemoryCollectorTest.php index 01df9b0..fd88c76 100644 --- a/test/Collector/MemoryCollectorTest.php +++ b/test/Collector/MemoryCollectorTest.php @@ -1,5 +1,7 @@ assertEquals($original->getMessage(), $serializable->getMessage()); } @@ -20,10 +22,10 @@ public function testSerializableExceptionUsesPreviousExceptionMessage() /** * @requires PHP 7 */ - public function testSerializableExceptionReportsCallToUndefinedMethod() + public function testSerializableExceptionReportsCallToUndefinedMethod(): void { try { - (new stdClass)->iDoNotExist(); + (new stdClass())->iDoNotExist(); } catch (Throwable $exception) { $serializable = new SerializableException($exception); $this->assertEquals('Call to undefined method stdClass::iDoNotExist()', $serializable->getMessage()); diff --git a/test/Listener/ToolbarListenerTest.php b/test/Listener/ToolbarListenerTest.php index 1aee55f..94e830d 100644 --- a/test/Listener/ToolbarListenerTest.php +++ b/test/Listener/ToolbarListenerTest.php @@ -1,5 +1,7 @@ + */ + public function provideHTMLBodyWithInjectedFlag(): array { return [ 'not HTML5 has head and body' => ['', true], - 'not HTML5 has body' => ['', true], - 'not HTML5 not has body' => ['', false], - 'HTML5 with head' => ['', true], - 'HTML5 without head' => ['', true], - 'HTML5 without body' => ['test', true], + 'not HTML5 has body' => ['', true], + 'not HTML5 not has body' => ['', false], + 'HTML5 with head' => ['', true], + 'HTML5 without head' => ['', true], + 'HTML5 without body' => ['test', true], ]; } /** * @dataProvider provideHTMLBodyWithInjectedFlag + * @param non-empty-string $htmlBody */ - public function testOnCollected($htmlBody, $injected) + public function testOnCollected(string $htmlBody, bool $injected): void { $viewRenderer = $this->createMock(PhpRenderer::class); $viewRenderer->expects($this->any()) @@ -39,8 +45,8 @@ public function testOnCollected($htmlBody, $injected) ->willReturn('script'); $profilerEvent = $this->createMock(ProfilerEvent::class); - $application = $this->createMock(Application::class); - $request = $this->createMock(Request::class); + $application = $this->createMock(Application::class); + $request = $this->createMock(Request::class); $application->expects($this->once()) ->method('getRequest') ->willReturn($request); diff --git a/test/ModuleTest.php b/test/ModuleTest.php index 3299cff..a8a3397 100644 --- a/test/ModuleTest.php +++ b/test/ModuleTest.php @@ -1,13 +1,18 @@ getConfig(); @@ -15,7 +20,7 @@ public function testGetConfig() $this->assertIsArray($config); } - public function testConfigSerialization() + public function testConfigSerialization(): void { $module = new Module(); $config = $module->getConfig(); diff --git a/test/OptionsTest.php b/test/OptionsTest.php index 28e44ab..df9bd7d 100644 --- a/test/OptionsTest.php +++ b/test/OptionsTest.php @@ -1,24 +1,30 @@ createMock(ReportInterface::class); - $options = new Options($dist['laminas-developer-tools'], $reportMock); + $options = new Options($dist['laminas-developer-tools'], $reportMock); $this->assertTrue($options->isEnabled()); $this->assertTrue($options->isToolbarEnabled()); } - public function blacklistFlags() + /** + * @return Generator> + */ + public function blacklistFlags(): Generator { yield 'null' => [null]; yield 'false' => [false]; @@ -26,12 +32,12 @@ public function blacklistFlags() /** * @see https://framework.zend.com/security/advisory/ZF2019-01 + * * @dataProvider blacklistFlags - * @param null|bool $flagValue */ - public function testOnlyWhitelistedToolbarEntriesShouldBeEnabled(?bool $flagValue) + public function testOnlyWhitelistedToolbarEntriesShouldBeEnabled(?bool $flagValue): void { - $reportMock = $this->createMock(ReportInterface::class); + $reportMock = $this->createMock(ReportInterface::class); /** @var ReportInterface $reportMock */ $options = new Options([], $reportMock); $toolbarOptions = [