From 5acefc9bfb656c0e544ea8b0f728adb3f79f9630 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sat, 13 Jul 2024 02:36:51 +0200 Subject: [PATCH 1/4] Pass phpstan level 1 --- .ddev/commands/web/phpstan | 7 + composer.json | 1 + composer.lock | 604 +++++++++++++++++- phpstan-baseline.neon | 13 + phpstan.dist.neon | 9 + src/N98/Magento/Application/Config.php | 3 +- src/N98/Magento/Application/ConfigFile.php | 4 +- .../Command/Admin/User/CreateUserCommand.php | 4 +- .../Command/Database/ImportCommand.php | 6 - .../Command/Eav/Attribute/ViewCommand.php | 4 +- 10 files changed, 641 insertions(+), 14 deletions(-) create mode 100755 .ddev/commands/web/phpstan create mode 100644 phpstan-baseline.neon create mode 100644 phpstan.dist.neon diff --git a/.ddev/commands/web/phpstan b/.ddev/commands/web/phpstan new file mode 100755 index 000000000..b365b081c --- /dev/null +++ b/.ddev/commands/web/phpstan @@ -0,0 +1,7 @@ +#!/bin/bash + +## Description: run PHPStan +## Usage: phpstan +## Example: ddev phpstan + +XDEBUG_MODE=off php vendor/bin/phpstan analyze "$@" diff --git a/composer.json b/composer.json index c978008a7..3cc72aaeb 100644 --- a/composer.json +++ b/composer.json @@ -33,6 +33,7 @@ "require-dev": { "ext-simplexml": "*", "bamarni/symfony-console-autocomplete": "^1.2.0", + "composer/composer": "^2.7", "friendsofphp/php-cs-fixer": "^3.4", "mikey179/vfsstream": "^1.6", "phing/phing": "~2.17.0", diff --git a/composer.lock b/composer.lock index e70a683ea..844f63290 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": "4030da981d8fe9a2636b5e323c51867a", + "content-hash": "feed411e176f9c495015a465512c9621", "packages": [ { "name": "fakerphp/faker", @@ -2143,6 +2143,338 @@ ], "time": "2022-12-23T10:58:28+00:00" }, + { + "name": "composer/ca-bundle", + "version": "1.5.1", + "source": { + "type": "git", + "url": "https://github.com/composer/ca-bundle.git", + "reference": "063d9aa8696582f5a41dffbbaf3c81024f0a604a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/ca-bundle/zipball/063d9aa8696582f5a41dffbbaf3c81024f0a604a", + "reference": "063d9aa8696582f5a41dffbbaf3c81024f0a604a", + "shasum": "" + }, + "require": { + "ext-openssl": "*", + "ext-pcre": "*", + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.10", + "psr/log": "^1.0 || ^2.0 || ^3.0", + "symfony/phpunit-bridge": "^4.2 || ^5", + "symfony/process": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\CaBundle\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle.", + "keywords": [ + "cabundle", + "cacert", + "certificate", + "ssl", + "tls" + ], + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/ca-bundle/issues", + "source": "https://github.com/composer/ca-bundle/tree/1.5.1" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2024-07-08T15:28:20+00:00" + }, + { + "name": "composer/class-map-generator", + "version": "1.3.4", + "source": { + "type": "git", + "url": "https://github.com/composer/class-map-generator.git", + "reference": "b1b3fd0b4eaf3ddf3ee230bc340bf3fff454a1a3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/class-map-generator/zipball/b1b3fd0b4eaf3ddf3ee230bc340bf3fff454a1a3", + "reference": "b1b3fd0b4eaf3ddf3ee230bc340bf3fff454a1a3", + "shasum": "" + }, + "require": { + "composer/pcre": "^2.1 || ^3.1", + "php": "^7.2 || ^8.0", + "symfony/finder": "^4.4 || ^5.3 || ^6 || ^7" + }, + "require-dev": { + "phpstan/phpstan": "^1.6", + "phpstan/phpstan-deprecation-rules": "^1", + "phpstan/phpstan-phpunit": "^1", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/filesystem": "^5.4 || ^6", + "symfony/phpunit-bridge": "^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\ClassMapGenerator\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "https://seld.be" + } + ], + "description": "Utilities to scan PHP code and generate class maps.", + "keywords": [ + "classmap" + ], + "support": { + "issues": "https://github.com/composer/class-map-generator/issues", + "source": "https://github.com/composer/class-map-generator/tree/1.3.4" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2024-06-12T14:13:04+00:00" + }, + { + "name": "composer/composer", + "version": "2.7.7", + "source": { + "type": "git", + "url": "https://github.com/composer/composer.git", + "reference": "291942978f39435cf904d33739f98d7d4eca7b23" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/composer/zipball/291942978f39435cf904d33739f98d7d4eca7b23", + "reference": "291942978f39435cf904d33739f98d7d4eca7b23", + "shasum": "" + }, + "require": { + "composer/ca-bundle": "^1.0", + "composer/class-map-generator": "^1.3.3", + "composer/metadata-minifier": "^1.0", + "composer/pcre": "^2.1 || ^3.1", + "composer/semver": "^3.3", + "composer/spdx-licenses": "^1.5.7", + "composer/xdebug-handler": "^2.0.2 || ^3.0.3", + "justinrainbow/json-schema": "^5.2.11", + "php": "^7.2.5 || ^8.0", + "psr/log": "^1.0 || ^2.0 || ^3.0", + "react/promise": "^2.8 || ^3", + "seld/jsonlint": "^1.4", + "seld/phar-utils": "^1.2", + "seld/signal-handler": "^2.0", + "symfony/console": "^5.4.11 || ^6.0.11 || ^7", + "symfony/filesystem": "^5.4 || ^6.0 || ^7", + "symfony/finder": "^5.4 || ^6.0 || ^7", + "symfony/polyfill-php73": "^1.24", + "symfony/polyfill-php80": "^1.24", + "symfony/polyfill-php81": "^1.24", + "symfony/process": "^5.4 || ^6.0 || ^7" + }, + "require-dev": { + "phpstan/phpstan": "^1.11.0", + "phpstan/phpstan-deprecation-rules": "^1.2.0", + "phpstan/phpstan-phpunit": "^1.4.0", + "phpstan/phpstan-strict-rules": "^1.6.0", + "phpstan/phpstan-symfony": "^1.4.0", + "symfony/phpunit-bridge": "^6.4.1 || ^7.0.1" + }, + "suggest": { + "ext-openssl": "Enabling the openssl extension allows you to access https URLs for repositories and packages", + "ext-zip": "Enabling the zip extension allows you to unzip archives", + "ext-zlib": "Allow gzip compression of HTTP requests" + }, + "bin": [ + "bin/composer" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.7-dev" + }, + "phpstan": { + "includes": [ + "phpstan/rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "Composer\\": "src/Composer/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "https://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "https://seld.be" + } + ], + "description": "Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.", + "homepage": "https://getcomposer.org/", + "keywords": [ + "autoload", + "dependency", + "package" + ], + "support": { + "irc": "ircs://irc.libera.chat:6697/composer", + "issues": "https://github.com/composer/composer/issues", + "security": "https://github.com/composer/composer/security/policy", + "source": "https://github.com/composer/composer/tree/2.7.7" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2024-06-10T20:11:12+00:00" + }, + { + "name": "composer/metadata-minifier", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/composer/metadata-minifier.git", + "reference": "c549d23829536f0d0e984aaabbf02af91f443207" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/metadata-minifier/zipball/c549d23829536f0d0e984aaabbf02af91f443207", + "reference": "c549d23829536f0d0e984aaabbf02af91f443207", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "composer/composer": "^2", + "phpstan/phpstan": "^0.12.55", + "symfony/phpunit-bridge": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\MetadataMinifier\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "Small utility library that handles metadata minification and expansion.", + "keywords": [ + "composer", + "compression" + ], + "support": { + "issues": "https://github.com/composer/metadata-minifier/issues", + "source": "https://github.com/composer/metadata-minifier/tree/1.0.0" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2021-04-07T13:37:33+00:00" + }, { "name": "composer/pcre", "version": "3.1.4", @@ -2295,6 +2627,86 @@ ], "time": "2023-08-31T09:50:34+00:00" }, + { + "name": "composer/spdx-licenses", + "version": "1.5.8", + "source": { + "type": "git", + "url": "https://github.com/composer/spdx-licenses.git", + "reference": "560bdcf8deb88ae5d611c80a2de8ea9d0358cc0a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/spdx-licenses/zipball/560bdcf8deb88ae5d611c80a2de8ea9d0358cc0a", + "reference": "560bdcf8deb88ae5d611c80a2de8ea9d0358cc0a", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^0.12.55", + "symfony/phpunit-bridge": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Spdx\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "SPDX licenses list and validation library.", + "keywords": [ + "license", + "spdx", + "validator" + ], + "support": { + "irc": "ircs://irc.libera.chat:6697/composer", + "issues": "https://github.com/composer/spdx-licenses/issues", + "source": "https://github.com/composer/spdx-licenses/tree/1.5.8" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2023-11-20T07:44:33+00:00" + }, { "name": "composer/xdebug-handler", "version": "3.0.5", @@ -2642,6 +3054,71 @@ ], "time": "2024-06-16T14:17:03+00:00" }, + { + "name": "justinrainbow/json-schema", + "version": "5.3.0", + "source": { + "type": "git", + "url": "https://github.com/jsonrainbow/json-schema.git", + "reference": "feb2ca6dd1cebdaf1ed60a4c8de2e53ce11c4fd8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jsonrainbow/json-schema/zipball/feb2ca6dd1cebdaf1ed60a4c8de2e53ce11c4fd8", + "reference": "feb2ca6dd1cebdaf1ed60a4c8de2e53ce11c4fd8", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "~2.2.20||~2.15.1", + "json-schema/json-schema-test-suite": "1.2.0", + "phpunit/phpunit": "^4.8.35" + }, + "bin": [ + "bin/validate-json" + ], + "type": "library", + "autoload": { + "psr-4": { + "JsonSchema\\": "src/JsonSchema/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bruno Prieto Reis", + "email": "bruno.p.reis@gmail.com" + }, + { + "name": "Justin Rainbow", + "email": "justin.rainbow@gmail.com" + }, + { + "name": "Igor Wiedler", + "email": "igor@wiedler.ch" + }, + { + "name": "Robert Schönthal", + "email": "seroscho@googlemail.com" + } + ], + "description": "A library to validate a json schema.", + "homepage": "https://github.com/justinrainbow/json-schema", + "keywords": [ + "json", + "schema" + ], + "support": { + "issues": "https://github.com/jsonrainbow/json-schema/issues", + "source": "https://github.com/jsonrainbow/json-schema/tree/5.3.0" + }, + "time": "2024-07-06T21:00:26+00:00" + }, { "name": "mikey179/vfsstream", "version": "v1.6.11", @@ -5064,6 +5541,70 @@ ], "time": "2020-09-28T06:39:44+00:00" }, + { + "name": "seld/jsonlint", + "version": "1.11.0", + "source": { + "type": "git", + "url": "https://github.com/Seldaek/jsonlint.git", + "reference": "1748aaf847fc731cfad7725aec413ee46f0cc3a2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/1748aaf847fc731cfad7725aec413ee46f0cc3a2", + "reference": "1748aaf847fc731cfad7725aec413ee46f0cc3a2", + "shasum": "" + }, + "require": { + "php": "^5.3 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.11", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0 || ^8.5.13" + }, + "bin": [ + "bin/jsonlint" + ], + "type": "library", + "autoload": { + "psr-4": { + "Seld\\JsonLint\\": "src/Seld/JsonLint/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "https://seld.be" + } + ], + "description": "JSON Linter", + "keywords": [ + "json", + "linter", + "parser", + "validator" + ], + "support": { + "issues": "https://github.com/Seldaek/jsonlint/issues", + "source": "https://github.com/Seldaek/jsonlint/tree/1.11.0" + }, + "funding": [ + { + "url": "https://github.com/Seldaek", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/seld/jsonlint", + "type": "tidelift" + } + ], + "time": "2024-07-11T14:55:45+00:00" + }, { "name": "seld/phar-utils", "version": "1.2.1", @@ -5112,6 +5653,67 @@ }, "time": "2022-08-31T10:31:18+00:00" }, + { + "name": "seld/signal-handler", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/Seldaek/signal-handler.git", + "reference": "04a6112e883ad76c0ada8e4a9f7520bbfdb6bb98" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Seldaek/signal-handler/zipball/04a6112e883ad76c0ada8e4a9f7520bbfdb6bb98", + "reference": "04a6112e883ad76c0ada8e4a9f7520bbfdb6bb98", + "shasum": "" + }, + "require": { + "php": ">=7.2.0" + }, + "require-dev": { + "phpstan/phpstan": "^1", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-phpunit": "^1", + "phpstan/phpstan-strict-rules": "^1.3", + "phpunit/phpunit": "^7.5.20 || ^8.5.23", + "psr/log": "^1 || ^2 || ^3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Seld\\Signal\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "Simple unix signal handler that silently fails where signals are not supported for easy cross-platform development", + "keywords": [ + "posix", + "sigint", + "signal", + "sigterm", + "unix" + ], + "support": { + "issues": "https://github.com/Seldaek/signal-handler/issues", + "source": "https://github.com/Seldaek/signal-handler/tree/2.0.2" + }, + "time": "2023-09-03T09:24:00+00:00" + }, { "name": "symfony/filesystem", "version": "v5.4.40", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 000000000..a17e272c4 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,13 @@ +parameters: + ignoreErrors: + - + # Level 1 + message: "#^Call to an undefined static method N98\\\\Util\\\\OperatingSystem\\:\\:getCurrentPhpBinary\\(\\)\\.$#" + count: 1 + path: src/N98/Magento/Command/Installer/SubCommand/InstallComposer.php + + - + # Level 1 + message: "#^Call to an undefined static method N98\\\\Util\\\\OperatingSystem\\:\\:locateProgram\\(\\)\\.$#" + count: 1 + path: src/N98/Magento/Command/Installer/SubCommand/InstallComposer.php diff --git a/phpstan.dist.neon b/phpstan.dist.neon new file mode 100644 index 000000000..ded2c35ea --- /dev/null +++ b/phpstan.dist.neon @@ -0,0 +1,9 @@ +includes: + - phar://phpstan.phar/conf/bleedingEdge.neon +parameters: + paths: + - src + scanDirectories: + - magento + level: 1 + treatPhpDocTypesAsCertain: false diff --git a/src/N98/Magento/Application/Config.php b/src/N98/Magento/Application/Config.php index 1c1972668..3258e4280 100644 --- a/src/N98/Magento/Application/Config.php +++ b/src/N98/Magento/Application/Config.php @@ -150,8 +150,7 @@ public function registerCustomCommands(Application $application) $this->output->writeln( sprintf( 'Can not add nonexistent command class "%s" as command to the application', - $commandClass, - $commandName + $commandClass ) ); $this->debugWriteln( diff --git a/src/N98/Magento/Application/ConfigFile.php b/src/N98/Magento/Application/ConfigFile.php index 1c8c0bb2e..cd81bb879 100644 --- a/src/N98/Magento/Application/ConfigFile.php +++ b/src/N98/Magento/Application/ConfigFile.php @@ -18,7 +18,7 @@ * * @package N98\Magento\Application */ -class ConfigFile +final class ConfigFile { /** * @var string @@ -37,7 +37,7 @@ class ConfigFile */ public static function createFromFile($path) { - $configFile = new static(); + $configFile = new self(); $configFile->loadFile($path); return $configFile; diff --git a/src/N98/Magento/Command/Admin/User/CreateUserCommand.php b/src/N98/Magento/Command/Admin/User/CreateUserCommand.php index 860fbffe2..3d4d7da94 100644 --- a/src/N98/Magento/Command/Admin/User/CreateUserCommand.php +++ b/src/N98/Magento/Command/Admin/User/CreateUserCommand.php @@ -60,8 +60,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int ->setRoleType('G') ->save(); - // @todo check cmuench correct class name? - $resourceAll = ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_2) ? + $resourceAll = ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_2 + && class_exists('Mage_Backend_Model_Acl_Config')) ? Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL : 'all'; // give "all" privileges to role diff --git a/src/N98/Magento/Command/Database/ImportCommand.php b/src/N98/Magento/Command/Database/ImportCommand.php index 6efc22e40..9ff0a58dd 100644 --- a/src/N98/Magento/Command/Database/ImportCommand.php +++ b/src/N98/Magento/Command/Database/ImportCommand.php @@ -174,12 +174,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int return 0; } - public function asText() - { - return parent::asText() . "\n" . - $this->getCompressionHelp(); - } - /** * @param InputInterface $input * diff --git a/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php b/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php index e3c77fc5c..f761fa178 100644 --- a/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php +++ b/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php @@ -62,8 +62,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($flatIndexes) { $key = array_key_first($flatIndexes); $flatIndexes = implode(',', $flatIndexes[$key]['fields']); + $table[] = ['Flat-Indexes', $key . ' - ' . $flatIndexes]; + } else { + $table[] = ['Flat-Indexes', '']; } - $table[] = ['Flat-Indexes', $flatIndexes ? $key . ' - ' . $flatIndexes : '']; if ($attribute->getFrontend()) { $table[] = ['Frontend-Label', $attribute->getFrontend()->getLabel()]; From e95330549d74c51e1f0d6b4cbbc1600ef0e6bb2c Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sat, 13 Jul 2024 14:18:21 +0200 Subject: [PATCH 2/4] Updated composer.lock --- composer.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.lock b/composer.lock index d19bd2a73..6aa094bad 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": "0c12577e0329bb5cf6c8f3a3b788eb99", + "content-hash": "2e4eb914eaf242ad8e42ec4efa3b51ee", "packages": [ { "name": "fakerphp/faker", From c6590e81993351cc4c11c2dd4d5a962a72a0343a Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 31 Jul 2024 09:44:04 +0200 Subject: [PATCH 3/4] Reverted change & updated baseline --- phpstan-baseline.neon => phpstan.dist.baseline.neon | 7 +++++-- phpstan.dist.neon | 1 + src/N98/Magento/Application/ConfigFile.php | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) rename phpstan-baseline.neon => phpstan.dist.baseline.neon (78%) diff --git a/phpstan-baseline.neon b/phpstan.dist.baseline.neon similarity index 78% rename from phpstan-baseline.neon rename to phpstan.dist.baseline.neon index a17e272c4..ea950978c 100644 --- a/phpstan-baseline.neon +++ b/phpstan.dist.baseline.neon @@ -1,13 +1,16 @@ parameters: ignoreErrors: - - # Level 1 + message: "#^Unsafe usage of new static\\(\\)\\.$#" + count: 1 + path: src/N98/Magento/Application/ConfigFile.php + + - message: "#^Call to an undefined static method N98\\\\Util\\\\OperatingSystem\\:\\:getCurrentPhpBinary\\(\\)\\.$#" count: 1 path: src/N98/Magento/Command/Installer/SubCommand/InstallComposer.php - - # Level 1 message: "#^Call to an undefined static method N98\\\\Util\\\\OperatingSystem\\:\\:locateProgram\\(\\)\\.$#" count: 1 path: src/N98/Magento/Command/Installer/SubCommand/InstallComposer.php diff --git a/phpstan.dist.neon b/phpstan.dist.neon index ded2c35ea..6268a7507 100644 --- a/phpstan.dist.neon +++ b/phpstan.dist.neon @@ -1,4 +1,5 @@ includes: + - phpstan.dist.baseline.neon - phar://phpstan.phar/conf/bleedingEdge.neon parameters: paths: diff --git a/src/N98/Magento/Application/ConfigFile.php b/src/N98/Magento/Application/ConfigFile.php index cd81bb879..1c8c0bb2e 100644 --- a/src/N98/Magento/Application/ConfigFile.php +++ b/src/N98/Magento/Application/ConfigFile.php @@ -18,7 +18,7 @@ * * @package N98\Magento\Application */ -final class ConfigFile +class ConfigFile { /** * @var string @@ -37,7 +37,7 @@ final class ConfigFile */ public static function createFromFile($path) { - $configFile = new self(); + $configFile = new static(); $configFile->loadFile($path); return $configFile; From 3b1744b5a9c960f42d4c44ec89ea63e771200125 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 31 Jul 2024 09:48:21 +0200 Subject: [PATCH 4/4] Reverted change & updated baseline --- .github/workflows/phpstan.yml | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/phpstan.yml diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 000000000..09a35c906 --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -0,0 +1,42 @@ +name: PHPStan + +on: + push: + pull_request: + workflow_call: + # Allow manually triggering the workflow. + workflow_dispatch: + +jobs: + phpstan: + name: Analyze + runs-on: ${{ matrix.operating-system }} + strategy: + matrix: + operating-system: [ubuntu-latest] + php-versions: ['7.4', '8.3'] + + steps: + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + + - uses: actions/checkout@v4 + + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install dependencies + run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-* + + - name: PHPStan Static Analysis + run: XDEBUG_MODE=off php vendor/bin/phpstan.phar analyze