From da4266c8e657ced5b27eea898cf6df025666dbca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Sat, 13 Mar 2021 13:54:06 +0100 Subject: [PATCH] qa: add `laminas-coding-standard` in v2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- .gitignore | 1 + composer.json | 2 +- composer.lock | 306 +++++++++++++++--- config/application.config.php | 12 +- ...-tools-mvc-auth-oauth2-override.global.php | 6 +- config/autoload/global-development.php | 4 +- config/autoload/global.php | 2 +- module/Application/config/module.config.php | 10 +- .../src/Controller/IndexController.php | 6 + module/Application/src/Module.php | 3 + .../ZZIndexControllerDevModeTest.php | 7 +- module/Application/view/error/404.phtml | 5 +- module/Application/view/error/index.phtml | 2 - phpcs.xml | 41 +-- 14 files changed, 308 insertions(+), 99 deletions(-) diff --git a/.gitignore b/.gitignore index 2b11662..fb6d857 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ config/development.config.php data/cache/* .phpunit.result.cache +.phpcs-cache diff --git a/composer.json b/composer.json index 68a0ff8..26bb975 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "require-dev": { "laminas-api-tools/api-tools-admin": "^1.6", "laminas-api-tools/api-tools-asset-manager": "^1.2", - "laminas/laminas-coding-standard": "~1.0.0", + "laminas/laminas-coding-standard": "^2.1", "laminas/laminas-composer-autoloading": "^2.1", "laminas/laminas-developer-tools": "^1.2.1", "laminas/laminas-test": "^3.4", diff --git a/composer.lock b/composer.lock index 85220c3..0f930de 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": "cb97c8a5e2567d6dc9ebd7dcb58ff179", + "content-hash": "6f7556e68eb9af38724071c337fae19c", "packages": [ { "name": "brick/varexporter", @@ -2935,6 +2935,72 @@ } ], "packages-dev": [ + { + "name": "dealerdirect/phpcodesniffer-composer-installer", + "version": "v0.7.1", + "source": { + "type": "git", + "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", + "reference": "fe390591e0241955f22eb9ba327d137e501c771c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/fe390591e0241955f22eb9ba327d137e501c771c", + "reference": "fe390591e0241955f22eb9ba327d137e501c771c", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0 || ^2.0", + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.0 || ^3.0 || ^4.0" + }, + "require-dev": { + "composer/composer": "*", + "phpcompatibility/php-compatibility": "^9.0", + "sensiolabs/security-checker": "^4.1.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" + } + ], + "description": "PHP_CodeSniffer Standards Composer Installer Plugin", + "homepage": "http://www.dealerdirect.com", + "keywords": [ + "PHPCodeSniffer", + "PHP_CodeSniffer", + "code quality", + "codesniffer", + "composer", + "installer", + "phpcs", + "plugin", + "qa", + "quality", + "standard", + "standards", + "style guide", + "stylecheck", + "tests" + ], + "time": "2020-12-07T18:04:37+00:00" + }, { "name": "doctrine/instantiator", "version": "1.4.0", @@ -3493,37 +3559,49 @@ }, { "name": "laminas/laminas-coding-standard", - "version": "1.0.0", + "version": "2.1.4", "source": { "type": "git", "url": "https://github.com/laminas/laminas-coding-standard.git", - "reference": "08880ce2fbfe62d471cd3cb766a91da630b32539" + "reference": "d75f1acf615232e108da2d2cf5a7df3e527b8f38" }, "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/d75f1acf615232e108da2d2cf5a7df3e527b8f38", + "reference": "d75f1acf615232e108da2d2cf5a7df3e527b8f38", "shasum": "" }, "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7", "laminas/laminas-zendframework-bridge": "^1.0", - "squizlabs/php_codesniffer": "^2.7" + "php": "^7.3 || ~8.0.0", + "slevomat/coding-standard": "^6.4.1", + "squizlabs/php_codesniffer": "^3.5.8", + "webimpress/coding-standard": "^1.1.6" }, - "replace": { - "zendframework/zend-coding-standard": "self.version" + "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", "laminas" ], - "time": "2019-12-31T16:28:26+00:00" + "funding": [ + { + "url": "https://funding.communitybridge.org/projects/laminas-project", + "type": "community_bridge" + } + ], + "time": "2020-10-26T07:33:05+00:00" }, { "name": "laminas/laminas-composer-autoloading", @@ -4219,6 +4297,55 @@ ], "time": "2020-12-19T10:15:11+00:00" }, + { + "name": "phpstan/phpdoc-parser", + "version": "0.4.9", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpdoc-parser.git", + "reference": "98a088b17966bdf6ee25c8a4b634df313d8aa531" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/98a088b17966bdf6ee25c8a4b634df313d8aa531", + "reference": "98a088b17966bdf6ee25c8a4b634df313d8aa531", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "consistence/coding-standard": "^3.5", + "ergebnis/composer-normalize": "^2.0.2", + "jakub-onderka/php-parallel-lint": "^0.9.2", + "phing/phing": "^2.16.0", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^0.12.26", + "phpstan/phpstan-strict-rules": "^0.12", + "phpunit/phpunit": "^6.3", + "slevomat/coding-standard": "^4.7.2", + "symfony/process": "^4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.4-dev" + } + }, + "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", + "time": "2020-08-03T20:32:43+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "9.2.5", @@ -5902,66 +6029,96 @@ ], "time": "2020-11-11T09:19:24+00:00" }, + { + "name": "slevomat/coding-standard", + "version": "6.4.1", + "source": { + "type": "git", + "url": "https://github.com/slevomat/coding-standard.git", + "reference": "696dcca217d0c9da2c40d02731526c1e25b65346" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/696dcca217d0c9da2c40d02731526c1e25b65346", + "reference": "696dcca217d0c9da2c40d02731526c1e25b65346", + "shasum": "" + }, + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7", + "php": "^7.1 || ^8.0", + "phpstan/phpdoc-parser": "0.4.5 - 0.4.9", + "squizlabs/php_codesniffer": "^3.5.6" + }, + "require-dev": { + "phing/phing": "2.16.3", + "php-parallel-lint/php-parallel-lint": "1.2.0", + "phpstan/phpstan": "0.12.48", + "phpstan/phpstan-deprecation-rules": "0.12.5", + "phpstan/phpstan-phpunit": "0.12.16", + "phpstan/phpstan-strict-rules": "0.12.5", + "phpunit/phpunit": "7.5.20|8.5.5|9.4.0" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-master": "6.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.", + "funding": [ + { + "url": "https://github.com/kukulich", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/slevomat/coding-standard", + "type": "tidelift" + } + ], + "time": "2020-10-05T12:39:37+00:00" + }, { "name": "squizlabs/php_codesniffer", - "version": "2.9.2", + "version": "3.5.8", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "2acf168de78487db620ab4bc524135a13cfe6745" + "reference": "9d583721a7157ee997f235f327de038e7ea6dac4" }, "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/9d583721a7157ee997f235f327de038e7ea6dac4", + "reference": "9d583721a7157ee997f235f327de038e7ea6dac4", "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" @@ -5973,12 +6130,12 @@ } ], "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" ], - "time": "2018-11-07T22:31:41+00:00" + "time": "2020-10-23T02:01:07+00:00" }, { "name": "symfony/polyfill-ctype", @@ -6344,6 +6501,57 @@ ], "time": "2020-07-12T23:59:07+00:00" }, + { + "name": "webimpress/coding-standard", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/webimpress/coding-standard.git", + "reference": "fbeb31ee876b3c493779d3aa717ebb57ef258e6a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webimpress/coding-standard/zipball/fbeb31ee876b3c493779d3aa717ebb57ef258e6a", + "reference": "fbeb31ee876b3c493779d3aa717ebb57ef258e6a", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0", + "squizlabs/php_codesniffer": "^3.5.8" + }, + "require-dev": { + "phpunit/phpunit": "^9.4.3" + }, + "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" + ], + "funding": [ + { + "url": "https://github.com/michalbundyra", + "type": "github" + } + ], + "time": "2021-01-11T18:13:55+00:00" + }, { "name": "webmozart/assert", "version": "1.10.0", diff --git a/config/application.config.php b/config/application.config.php index c31e6d1..d2eb614 100644 --- a/config/application.config.php +++ b/config/application.config.php @@ -16,15 +16,15 @@ 'module_listener_options' => [ 'module_paths' => [ './module', - './vendor' + './vendor', ], // Using __DIR__ to ensure cross-platform compatibility. Some platforms -- // e.g., IBM i -- have problems with globs that are not qualified. - 'config_glob_paths' => [realpath(__DIR__) . '/autoload/{,*.}{global,local}.php'], - 'config_cache_key' => 'application.config.cache', - 'config_cache_enabled' => true, - 'module_map_cache_key' => 'application.module.cache', + 'config_glob_paths' => [realpath(__DIR__) . '/autoload/{,*.}{global,local}.php'], + 'config_cache_key' => 'application.config.cache', + 'config_cache_enabled' => true, + 'module_map_cache_key' => 'application.module.cache', 'module_map_cache_enabled' => true, - 'cache_dir' => 'data/cache/', + 'cache_dir' => 'data/cache/', ], ]; diff --git a/config/autoload/api-tools-mvc-auth-oauth2-override.global.php b/config/autoload/api-tools-mvc-auth-oauth2-override.global.php index 733425c..1f2ba73 100644 --- a/config/autoload/api-tools-mvc-auth-oauth2-override.global.php +++ b/config/autoload/api-tools-mvc-auth-oauth2-override.global.php @@ -5,10 +5,14 @@ * and overrides the Laminas\ApiTools\OAuth2\Service\OAuth2Server to provide the ability to create named * OAuth2\Server instances. */ + +use Laminas\ApiTools\MvcAuth\Factory\NamedOAuth2ServerFactory; +use Laminas\ApiTools\OAuth2\Service\OAuth2Server; + return [ 'service_manager' => [ 'factories' => [ - \Laminas\ApiTools\OAuth2\Service\OAuth2Server::class => \Laminas\ApiTools\MvcAuth\Factory\NamedOAuth2ServerFactory::class, + OAuth2Server::class => NamedOAuth2ServerFactory::class, ], ], ]; diff --git a/config/autoload/global-development.php b/config/autoload/global-development.php index 1d4efb7..df8c735 100644 --- a/config/autoload/global-development.php +++ b/config/autoload/global-development.php @@ -9,10 +9,10 @@ use Laminas\ApiTools\Admin\Model\ModulePathSpec; return [ - 'view_manager' => [ + 'view_manager' => [ 'display_exceptions' => true, ], - 'api-tools-admin' => [ + 'api-tools-admin' => [ 'path_spec' => ModulePathSpec::PSR_4, ], 'api-tools-configuration' => [ diff --git a/config/autoload/global.php b/config/autoload/global.php index 1f9775f..cd7b8ca 100644 --- a/config/autoload/global.php +++ b/config/autoload/global.php @@ -10,7 +10,7 @@ 'api-tools-content-negotiation' => [ 'selectors' => [], ], - 'db' => [ + 'db' => [ 'adapters' => [ 'dummy' => [], ], diff --git a/module/Application/config/module.config.php b/module/Application/config/module.config.php index 3a93e13..f3c68cd 100644 --- a/module/Application/config/module.config.php +++ b/module/Application/config/module.config.php @@ -11,10 +11,10 @@ use Laminas\ServiceManager\Factory\InvokableFactory; return [ - 'router' => [ + 'router' => [ 'routes' => [ 'home' => [ - 'type' => 'Literal', + 'type' => 'Literal', 'options' => [ 'route' => '/', 'defaults' => [ @@ -25,7 +25,7 @@ ], ], ], - 'controllers' => [ + 'controllers' => [ 'factories' => [ Controller\IndexController::class => InvokableFactory::class, ], @@ -36,13 +36,13 @@ 'doctype' => 'HTML5', 'not_found_template' => 'error/404', 'exception_template' => 'error/index', - 'template_map' => [ + 'template_map' => [ 'layout/layout' => __DIR__ . '/../view/layout/layout.phtml', 'application/index/index' => __DIR__ . '/../view/application/index/index.phtml', 'error/404' => __DIR__ . '/../view/error/404.phtml', 'error/index' => __DIR__ . '/../view/error/index.phtml', ], - 'template_path_stack' => [ + 'template_path_stack' => [ __DIR__ . '/../view', ], ], diff --git a/module/Application/src/Controller/IndexController.php b/module/Application/src/Controller/IndexController.php index 7f2bf61..87c14a4 100644 --- a/module/Application/src/Controller/IndexController.php +++ b/module/Application/src/Controller/IndexController.php @@ -9,11 +9,17 @@ namespace Application\Controller; use Laminas\ApiTools\Admin\Module as AdminModule; +use Laminas\Http\Response; use Laminas\Mvc\Controller\AbstractActionController; use Laminas\View\Model\ViewModel; +use function class_exists; + class IndexController extends AbstractActionController { + /** + * @return Response|ViewModel + */ public function indexAction() { if (class_exists(AdminModule::class, false)) { diff --git a/module/Application/src/Module.php b/module/Application/src/Module.php index 716483e..1a3520f 100644 --- a/module/Application/src/Module.php +++ b/module/Application/src/Module.php @@ -10,6 +10,9 @@ class Module { + /** + * @return array + */ public function getConfig() { return include __DIR__ . '/../config/module.config.php'; diff --git a/module/Application/test/Controller/ZZIndexControllerDevModeTest.php b/module/Application/test/Controller/ZZIndexControllerDevModeTest.php index d90330f..c81ea06 100644 --- a/module/Application/test/Controller/ZZIndexControllerDevModeTest.php +++ b/module/Application/test/Controller/ZZIndexControllerDevModeTest.php @@ -8,7 +8,6 @@ namespace ApplicationTest\Controller; -use Application\Controller\IndexController; use Laminas\Stdlib\ArrayUtils; use Laminas\Test\PHPUnit\Controller\AbstractHttpControllerTestCase; @@ -26,17 +25,17 @@ public function setUp(): void // such as sample view templates, path stacks, module_listener_options, // etc. $configOverrides = [ - 'modules' => [ + 'modules' => [ 'Laminas\ApiTools\Admin', 'Laminas\ApiTools\Admin\Ui', ], 'module_listener_options' => [ 'config_cache_enabled' => false, - 'config_glob_paths' => [ + 'config_glob_paths' => [ __DIR__ . '/../../../../config/autoload/{,*.}{global,local}.php', __DIR__ . '/../../../../config/autoload/{,*.}{global,local}-development.php', ], - ] + ], ]; $this->setApplicationConfig(ArrayUtils::merge( diff --git a/module/Application/view/error/404.phtml b/module/Application/view/error/404.phtml index 81954ce..18d6244 100644 --- a/module/Application/view/error/404.phtml +++ b/module/Application/view/error/404.phtml @@ -27,14 +27,13 @@ if (! empty($this->reason)) : $reasonMessage = 'We cannot determine at this time why a 404 was generated.'; break; } -?> + ?>

controller)) : ?> -
Controller:
escapeHtml($this->controller) ?> @@ -51,7 +50,6 @@ if (! empty($this->reason)) : display_exceptions)) : ?> - exception) && ($this->exception instanceof \Throwable || $this->exception instanceof \Exception)) : ?>
@@ -100,7 +98,6 @@ if (! empty($this->reason)) : -

No Exception available

diff --git a/module/Application/view/error/index.phtml b/module/Application/view/error/index.phtml index 2790d6e..3ac43ad 100644 --- a/module/Application/view/error/index.phtml +++ b/module/Application/view/error/index.phtml @@ -2,7 +2,6 @@

message ?>

display_exceptions)) : ?> - exception) && ($this->exception instanceof \Throwable || $this->exception instanceof \Exception)) : ?>
@@ -51,7 +50,6 @@ -

No Exception available

diff --git a/phpcs.xml b/phpcs.xml index f4002d1..fd317f9 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,26 +1,22 @@ - - Laminas coding standard + - - + + - + + - - - - - - - - - - - - - - + + + + + config + src + module + + public/index.php src/remove-package-artifacts.php @@ -30,9 +26,6 @@ *.phtml - - config - module - public/index.php - src + +