diff --git a/site/composer.lock b/site/composer.lock index b8b83036c..32892e8af 100644 --- a/site/composer.lock +++ b/site/composer.lock @@ -3330,16 +3330,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.22.1", + "version": "1.23.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "65c39594fbd8c67abfc68bb323f86447bab79cc0" + "reference": "a2b24135c35852b348894320d47b3902a94bc494" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/65c39594fbd8c67abfc68bb323f86447bab79cc0", - "reference": "65c39594fbd8c67abfc68bb323f86447bab79cc0", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/a2b24135c35852b348894320d47b3902a94bc494", + "reference": "a2b24135c35852b348894320d47b3902a94bc494", "shasum": "" }, "require": { @@ -3371,9 +3371,9 @@ "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.22.1" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.23.0" }, - "time": "2023-06-29T20:46:06+00:00" + "time": "2023-07-23T22:17:56+00:00" }, { "name": "phpstan/phpstan", @@ -3553,19 +3553,19 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "bd50a5b0522c94e65c90eb8d8cc040a630a07b0c" + "reference": "69dafab8a5dffa4d6a4d6dab1ebadf48aca449c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/bd50a5b0522c94e65c90eb8d8cc040a630a07b0c", - "reference": "bd50a5b0522c94e65c90eb8d8cc040a630a07b0c", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/69dafab8a5dffa4d6a4d6dab1ebadf48aca449c7", + "reference": "69dafab8a5dffa4d6a4d6dab1ebadf48aca449c7", "shasum": "" }, "conflict": { "3f/pygmentize": "<1.2", "admidio/admidio": "<4.2.10", "adodb/adodb-php": "<=5.20.20|>=5.21,<=5.21.3", - "aheinze/cockpit": "<=2.2.1", + "aheinze/cockpit": "<2.2", "aimeos/aimeos-typo3": "<19.10.12|>=20,<20.10.5", "akaunting/akaunting": "<2.1.13", "akeneo/pim-community-dev": "<5.0.119|>=6,<6.0.53", @@ -3625,7 +3625,7 @@ "catfan/medoo": "<1.7.5", "centreon/centreon": "<22.10-beta.1", "cesnet/simplesamlphp-module-proxystatistics": "<3.1", - "cockpit-hq/cockpit": "<2.4.1", + "cockpit-hq/cockpit": "<2.6", "codeception/codeception": "<3.1.3|>=4,<4.1.22", "codeigniter/framework": "<=3.0.6", "codeigniter4/framework": "<4.3.5", @@ -3637,7 +3637,7 @@ "contao-components/mediaelement": ">=2.14.2,<2.21.1", "contao/contao": ">=4,<4.4.56|>=4.5,<4.9.40|>=4.10,<4.11.7|>=4.13,<4.13.21|>=5.1,<5.1.4", "contao/core": ">=2,<3.5.39", - "contao/core-bundle": "<4.9.40|>=4.10,<4.11.7|>=4.13,<4.13.21|>=5.1,<5.1.4|= 4.10.0", + "contao/core-bundle": "<4.9.42|>=4.10,<4.13.28|>=5,<5.1.10|= 4.10.0", "contao/listing-bundle": ">=4,<4.4.8", "contao/managed-edition": "<=1.5", "cosenary/instagram": "<=2.3", @@ -3706,6 +3706,7 @@ "fixpunkt/fp-masterquiz": "<2.2.1|>=3,<3.5.2", "fixpunkt/fp-newsletter": "<1.1.1|>=2,<2.1.2|>=2.2,<3.2.6", "flarum/core": "<1.7", + "flarum/framework": "<=0.1-beta.7.1", "flarum/mentions": "<1.6.3", "flarum/sticky": ">=0.1-beta.14,<=0.1-beta.15", "flarum/tags": "<=0.1-beta.13", @@ -3727,8 +3728,9 @@ "funadmin/funadmin": "<=3.2|>=3.3.2,<=3.3.3", "gaoming13/wechat-php-sdk": "<=1.10.2", "genix/cms": "<=1.1.11", - "getgrav/grav": "<1.7.42", + "getgrav/grav": "<=1.7.42.1", "getkirby/cms": "= 3.8.0|<3.5.8.2|>=3.6,<3.6.6.2|>=3.7,<3.7.5.1", + "getkirby/kirby": "<=2.5.12", "getkirby/panel": "<2.5.14", "getkirby/starterkit": "<=3.7.0.2", "gilacms/gila": "<=1.11.4", @@ -3777,6 +3779,7 @@ "joomla/archive": "<1.1.12|>=2,<2.0.1", "joomla/filesystem": "<1.6.2|>=2,<2.0.1", "joomla/filter": "<1.4.4|>=2,<2.0.1", + "joomla/framework": ">=2.5.4,<=3.8.12", "joomla/input": ">=2,<2.0.2", "joomla/joomla-cms": ">=3,<3.9.12", "joomla/session": "<1.3.1", @@ -3831,14 +3834,14 @@ "melisplatform/melis-front": "<5.0.1", "mezzio/mezzio-swoole": "<3.7|>=4,<4.3", "mgallegos/laravel-jqgrid": "<=1.3", - "microweber/microweber": "= 1.1.18|<=1.3.4", + "microweber/microweber": "<=1.3.4|= 1.1.18", "miniorange/miniorange-saml": "<1.4.3", "mittwald/typo3_forum": "<1.2.1", "mobiledetect/mobiledetectlib": "<2.8.32", - "modx/revolution": "<= 2.8.3-pl|<2.8", + "modx/revolution": "<2.8|<= 2.8.3-pl", "mojo42/jirafeau": "<4.4", "monolog/monolog": ">=1.8,<1.12", - "moodle/moodle": "<4.2-rc.2|= 3.7|= 3.9|= 3.8|= 4.2.0|= 3.11", + "moodle/moodle": "<4.2-rc.2|= 3.4.3|= 3.5|= 3.7|= 3.9|= 3.8|= 4.2.0|= 3.11", "movim/moxl": ">=0.8,<=0.10", "mpdf/mpdf": "<=7.1.7", "mustache/mustache": ">=2,<2.14.1", @@ -3861,7 +3864,7 @@ "nzo/url-encryptor-bundle": ">=4,<4.3.2|>=5,<5.0.1", "october/backend": "<1.1.2", "october/cms": "= 1.1.1|= 1.0.471|= 1.0.469|>=1.0.319,<1.0.469", - "october/october": ">=1.0.319,<1.0.466|>=2.1,<2.1.12", + "october/october": "<1.0.466|>=2.1,<2.1.12", "october/rain": "<1.0.472|>=1.1,<1.1.2", "october/system": "<1.0.476|>=1.1,<1.1.12|>=2,<2.2.34|>=3,<3.0.66", "onelogin/php-saml": "<2.10.4", @@ -3909,7 +3912,7 @@ "pimcore/customer-management-framework-bundle": "<3.4.1", "pimcore/data-hub": "<1.2.4", "pimcore/perspective-editor": "<1.5.1", - "pimcore/pimcore": "<10.5.24", + "pimcore/pimcore": "<10.6.4", "pixelfed/pixelfed": "<=0.11.4", "pocketmine/bedrock-protocol": "<8.0.2", "pocketmine/pocketmine-mp": "<4.22.3|>=5,<5.2.1|< 4.18.0-ALPHA2|>= 4.0.0-BETA5, < 4.4.2", @@ -4070,10 +4073,10 @@ "twig/twig": "<1.44.7|>=2,<2.15.3|>=3,<3.4.3", "typo3/cms": "<2.0.5|>=3,<3.0.3|>=6.2,<=6.2.38|>=7,<7.6.32|>=8,<8.7.38|>=9,<9.5.29|>=10,<10.4.35|>=11,<11.5.23|>=12,<12.2", "typo3/cms-backend": ">=7,<=7.6.50|>=8,<=8.7.39|>=9,<=9.5.24|>=10,<=10.4.13|>=11,<=11.1", - "typo3/cms-core": "<8.7.51|>=9,<9.5.40|>=10,<10.4.36|>=11,<11.5.23|>=12,<12.2", + "typo3/cms-core": "<8.7.51|>=9,<9.5.42|>=10,<10.4.39|>=11,<11.5.30|>=12,<12.4.4", "typo3/cms-form": ">=8,<=8.7.39|>=9,<=9.5.24|>=10,<=10.4.13|>=11,<=11.1", "typo3/flow": ">=1,<1.0.4|>=1.1,<1.1.1|>=2,<2.0.1|>=2.3,<2.3.16|>=3,<3.0.12|>=3.1,<3.1.10|>=3.2,<3.2.13|>=3.3,<3.3.13|>=4,<4.0.6", - "typo3/html-sanitizer": ">=1,<1.5|>=2,<2.1.1", + "typo3/html-sanitizer": ">=1,<1.5.1|>=2,<2.1.2", "typo3/neos": ">=1.1,<1.1.3|>=1.2,<1.2.13|>=2,<2.0.4|>=2.3,<2.3.99|>=3,<3.0.20|>=3.1,<3.1.18|>=3.2,<3.2.14|>=3.3,<3.3.23|>=4,<4.0.17|>=4.1,<4.1.16|>=4.2,<4.2.12|>=4.3,<4.3.3", "typo3/phar-stream-wrapper": ">=1,<2.1.1|>=3,<3.1.1", "typo3/swiftmailer": ">=4.1,<4.1.99|>=5.4,<5.4.5", @@ -4189,36 +4192,36 @@ "type": "tidelift" } ], - "time": "2023-07-20T19:04:25+00:00" + "time": "2023-07-25T19:04:12+00:00" }, { "name": "slevomat/coding-standard", - "version": "8.13.1", + "version": "8.13.4", "source": { "type": "git", "url": "https://github.com/slevomat/coding-standard.git", - "reference": "a13c15e20f2d307a1ca8dec5313ec462a4466470" + "reference": "4b2af2fb17773656d02fbfb5d18024ebd19fe322" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/a13c15e20f2d307a1ca8dec5313ec462a4466470", - "reference": "a13c15e20f2d307a1ca8dec5313ec462a4466470", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/4b2af2fb17773656d02fbfb5d18024ebd19fe322", + "reference": "4b2af2fb17773656d02fbfb5d18024ebd19fe322", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0", "php": "^7.2 || ^8.0", - "phpstan/phpdoc-parser": "^1.22.0", + "phpstan/phpdoc-parser": "^1.23.0", "squizlabs/php_codesniffer": "^3.7.1" }, "require-dev": { "phing/phing": "2.17.4", "php-parallel-lint/php-parallel-lint": "1.3.2", - "phpstan/phpstan": "1.10.21", + "phpstan/phpstan": "1.10.26", "phpstan/phpstan-deprecation-rules": "1.1.3", "phpstan/phpstan-phpunit": "1.3.13", "phpstan/phpstan-strict-rules": "1.5.1", - "phpunit/phpunit": "7.5.20|8.5.21|9.6.8|10.2.2" + "phpunit/phpunit": "7.5.20|8.5.21|9.6.8|10.2.6" }, "type": "phpcodesniffer-standard", "extra": { @@ -4242,7 +4245,7 @@ ], "support": { "issues": "https://github.com/slevomat/coding-standard/issues", - "source": "https://github.com/slevomat/coding-standard/tree/8.13.1" + "source": "https://github.com/slevomat/coding-standard/tree/8.13.4" }, "funding": [ { @@ -4254,7 +4257,7 @@ "type": "tidelift" } ], - "time": "2023-06-25T12:52:34+00:00" + "time": "2023-07-25T10:28:55+00:00" }, { "name": "spaze/coding-standard", @@ -4306,16 +4309,16 @@ }, { "name": "spaze/phpstan-disallowed-calls", - "version": "v2.15.1", + "version": "v2.16.0", "source": { "type": "git", "url": "https://github.com/spaze/phpstan-disallowed-calls.git", - "reference": "f80ca038a4052224c562f07d43cfe913113192d0" + "reference": "c7a80cc9747e6307bfa6f5ea88ed3f9b1804790c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spaze/phpstan-disallowed-calls/zipball/f80ca038a4052224c562f07d43cfe913113192d0", - "reference": "f80ca038a4052224c562f07d43cfe913113192d0", + "url": "https://api.github.com/repos/spaze/phpstan-disallowed-calls/zipball/c7a80cc9747e6307bfa6f5ea88ed3f9b1804790c", + "reference": "c7a80cc9747e6307bfa6f5ea88ed3f9b1804790c", "shasum": "" }, "require": { @@ -4361,7 +4364,7 @@ ], "support": { "issues": "https://github.com/spaze/phpstan-disallowed-calls/issues", - "source": "https://github.com/spaze/phpstan-disallowed-calls/tree/v2.15.1" + "source": "https://github.com/spaze/phpstan-disallowed-calls/tree/v2.16.0" }, "funding": [ { @@ -4369,7 +4372,7 @@ "type": "github" } ], - "time": "2023-07-01T21:33:24+00:00" + "time": "2023-07-26T11:37:27+00:00" }, { "name": "spaze/phpstan-disallowed-calls-nette", diff --git a/site/vendor/composer/installed.json b/site/vendor/composer/installed.json index 3b016213b..b2d6732ec 100644 --- a/site/vendor/composer/installed.json +++ b/site/vendor/composer/installed.json @@ -1974,17 +1974,17 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.22.1", - "version_normalized": "1.22.1.0", + "version": "1.23.0", + "version_normalized": "1.23.0.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "65c39594fbd8c67abfc68bb323f86447bab79cc0" + "reference": "a2b24135c35852b348894320d47b3902a94bc494" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/65c39594fbd8c67abfc68bb323f86447bab79cc0", - "reference": "65c39594fbd8c67abfc68bb323f86447bab79cc0", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/a2b24135c35852b348894320d47b3902a94bc494", + "reference": "a2b24135c35852b348894320d47b3902a94bc494", "shasum": "" }, "require": { @@ -2001,7 +2001,7 @@ "phpunit/phpunit": "^9.5", "symfony/process": "^5.2" }, - "time": "2023-06-29T20:46:06+00:00", + "time": "2023-07-23T22:17:56+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -2018,7 +2018,7 @@ "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.22.1" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.23.0" }, "install-path": "../phpstan/phpdoc-parser" }, @@ -2371,19 +2371,19 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "bd50a5b0522c94e65c90eb8d8cc040a630a07b0c" + "reference": "69dafab8a5dffa4d6a4d6dab1ebadf48aca449c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/bd50a5b0522c94e65c90eb8d8cc040a630a07b0c", - "reference": "bd50a5b0522c94e65c90eb8d8cc040a630a07b0c", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/69dafab8a5dffa4d6a4d6dab1ebadf48aca449c7", + "reference": "69dafab8a5dffa4d6a4d6dab1ebadf48aca449c7", "shasum": "" }, "conflict": { "3f/pygmentize": "<1.2", "admidio/admidio": "<4.2.10", "adodb/adodb-php": "<=5.20.20|>=5.21,<=5.21.3", - "aheinze/cockpit": "<=2.2.1", + "aheinze/cockpit": "<2.2", "aimeos/aimeos-typo3": "<19.10.12|>=20,<20.10.5", "akaunting/akaunting": "<2.1.13", "akeneo/pim-community-dev": "<5.0.119|>=6,<6.0.53", @@ -2443,7 +2443,7 @@ "catfan/medoo": "<1.7.5", "centreon/centreon": "<22.10-beta.1", "cesnet/simplesamlphp-module-proxystatistics": "<3.1", - "cockpit-hq/cockpit": "<2.4.1", + "cockpit-hq/cockpit": "<2.6", "codeception/codeception": "<3.1.3|>=4,<4.1.22", "codeigniter/framework": "<=3.0.6", "codeigniter4/framework": "<4.3.5", @@ -2455,7 +2455,7 @@ "contao-components/mediaelement": ">=2.14.2,<2.21.1", "contao/contao": ">=4,<4.4.56|>=4.5,<4.9.40|>=4.10,<4.11.7|>=4.13,<4.13.21|>=5.1,<5.1.4", "contao/core": ">=2,<3.5.39", - "contao/core-bundle": "<4.9.40|>=4.10,<4.11.7|>=4.13,<4.13.21|>=5.1,<5.1.4|= 4.10.0", + "contao/core-bundle": "<4.9.42|>=4.10,<4.13.28|>=5,<5.1.10|= 4.10.0", "contao/listing-bundle": ">=4,<4.4.8", "contao/managed-edition": "<=1.5", "cosenary/instagram": "<=2.3", @@ -2524,6 +2524,7 @@ "fixpunkt/fp-masterquiz": "<2.2.1|>=3,<3.5.2", "fixpunkt/fp-newsletter": "<1.1.1|>=2,<2.1.2|>=2.2,<3.2.6", "flarum/core": "<1.7", + "flarum/framework": "<=0.1-beta.7.1", "flarum/mentions": "<1.6.3", "flarum/sticky": ">=0.1-beta.14,<=0.1-beta.15", "flarum/tags": "<=0.1-beta.13", @@ -2545,8 +2546,9 @@ "funadmin/funadmin": "<=3.2|>=3.3.2,<=3.3.3", "gaoming13/wechat-php-sdk": "<=1.10.2", "genix/cms": "<=1.1.11", - "getgrav/grav": "<1.7.42", + "getgrav/grav": "<=1.7.42.1", "getkirby/cms": "= 3.8.0|<3.5.8.2|>=3.6,<3.6.6.2|>=3.7,<3.7.5.1", + "getkirby/kirby": "<=2.5.12", "getkirby/panel": "<2.5.14", "getkirby/starterkit": "<=3.7.0.2", "gilacms/gila": "<=1.11.4", @@ -2595,6 +2597,7 @@ "joomla/archive": "<1.1.12|>=2,<2.0.1", "joomla/filesystem": "<1.6.2|>=2,<2.0.1", "joomla/filter": "<1.4.4|>=2,<2.0.1", + "joomla/framework": ">=2.5.4,<=3.8.12", "joomla/input": ">=2,<2.0.2", "joomla/joomla-cms": ">=3,<3.9.12", "joomla/session": "<1.3.1", @@ -2649,14 +2652,14 @@ "melisplatform/melis-front": "<5.0.1", "mezzio/mezzio-swoole": "<3.7|>=4,<4.3", "mgallegos/laravel-jqgrid": "<=1.3", - "microweber/microweber": "= 1.1.18|<=1.3.4", + "microweber/microweber": "<=1.3.4|= 1.1.18", "miniorange/miniorange-saml": "<1.4.3", "mittwald/typo3_forum": "<1.2.1", "mobiledetect/mobiledetectlib": "<2.8.32", - "modx/revolution": "<= 2.8.3-pl|<2.8", + "modx/revolution": "<2.8|<= 2.8.3-pl", "mojo42/jirafeau": "<4.4", "monolog/monolog": ">=1.8,<1.12", - "moodle/moodle": "<4.2-rc.2|= 3.7|= 3.9|= 3.8|= 4.2.0|= 3.11", + "moodle/moodle": "<4.2-rc.2|= 3.4.3|= 3.5|= 3.7|= 3.9|= 3.8|= 4.2.0|= 3.11", "movim/moxl": ">=0.8,<=0.10", "mpdf/mpdf": "<=7.1.7", "mustache/mustache": ">=2,<2.14.1", @@ -2679,7 +2682,7 @@ "nzo/url-encryptor-bundle": ">=4,<4.3.2|>=5,<5.0.1", "october/backend": "<1.1.2", "october/cms": "= 1.1.1|= 1.0.471|= 1.0.469|>=1.0.319,<1.0.469", - "october/october": ">=1.0.319,<1.0.466|>=2.1,<2.1.12", + "october/october": "<1.0.466|>=2.1,<2.1.12", "october/rain": "<1.0.472|>=1.1,<1.1.2", "october/system": "<1.0.476|>=1.1,<1.1.12|>=2,<2.2.34|>=3,<3.0.66", "onelogin/php-saml": "<2.10.4", @@ -2727,7 +2730,7 @@ "pimcore/customer-management-framework-bundle": "<3.4.1", "pimcore/data-hub": "<1.2.4", "pimcore/perspective-editor": "<1.5.1", - "pimcore/pimcore": "<10.5.24", + "pimcore/pimcore": "<10.6.4", "pixelfed/pixelfed": "<=0.11.4", "pocketmine/bedrock-protocol": "<8.0.2", "pocketmine/pocketmine-mp": "<4.22.3|>=5,<5.2.1|< 4.18.0-ALPHA2|>= 4.0.0-BETA5, < 4.4.2", @@ -2888,10 +2891,10 @@ "twig/twig": "<1.44.7|>=2,<2.15.3|>=3,<3.4.3", "typo3/cms": "<2.0.5|>=3,<3.0.3|>=6.2,<=6.2.38|>=7,<7.6.32|>=8,<8.7.38|>=9,<9.5.29|>=10,<10.4.35|>=11,<11.5.23|>=12,<12.2", "typo3/cms-backend": ">=7,<=7.6.50|>=8,<=8.7.39|>=9,<=9.5.24|>=10,<=10.4.13|>=11,<=11.1", - "typo3/cms-core": "<8.7.51|>=9,<9.5.40|>=10,<10.4.36|>=11,<11.5.23|>=12,<12.2", + "typo3/cms-core": "<8.7.51|>=9,<9.5.42|>=10,<10.4.39|>=11,<11.5.30|>=12,<12.4.4", "typo3/cms-form": ">=8,<=8.7.39|>=9,<=9.5.24|>=10,<=10.4.13|>=11,<=11.1", "typo3/flow": ">=1,<1.0.4|>=1.1,<1.1.1|>=2,<2.0.1|>=2.3,<2.3.16|>=3,<3.0.12|>=3.1,<3.1.10|>=3.2,<3.2.13|>=3.3,<3.3.13|>=4,<4.0.6", - "typo3/html-sanitizer": ">=1,<1.5|>=2,<2.1.1", + "typo3/html-sanitizer": ">=1,<1.5.1|>=2,<2.1.2", "typo3/neos": ">=1.1,<1.1.3|>=1.2,<1.2.13|>=2,<2.0.4|>=2.3,<2.3.99|>=3,<3.0.20|>=3.1,<3.1.18|>=3.2,<3.2.14|>=3.3,<3.3.23|>=4,<4.0.17|>=4.1,<4.1.16|>=4.2,<4.2.12|>=4.3,<4.3.3", "typo3/phar-stream-wrapper": ">=1,<2.1.1|>=3,<3.1.1", "typo3/swiftmailer": ">=4.1,<4.1.99|>=5.4,<5.4.5", @@ -2971,7 +2974,7 @@ "zfr/zfr-oauth2-server-module": "<0.1.2", "zoujingli/thinkadmin": "<6.0.22" }, - "time": "2023-07-20T19:04:25+00:00", + "time": "2023-07-25T19:04:12+00:00", "default-branch": true, "type": "metapackage", "notification-url": "https://packagist.org/downloads/", @@ -3012,35 +3015,35 @@ }, { "name": "slevomat/coding-standard", - "version": "8.13.1", - "version_normalized": "8.13.1.0", + "version": "8.13.4", + "version_normalized": "8.13.4.0", "source": { "type": "git", "url": "https://github.com/slevomat/coding-standard.git", - "reference": "a13c15e20f2d307a1ca8dec5313ec462a4466470" + "reference": "4b2af2fb17773656d02fbfb5d18024ebd19fe322" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/a13c15e20f2d307a1ca8dec5313ec462a4466470", - "reference": "a13c15e20f2d307a1ca8dec5313ec462a4466470", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/4b2af2fb17773656d02fbfb5d18024ebd19fe322", + "reference": "4b2af2fb17773656d02fbfb5d18024ebd19fe322", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0", "php": "^7.2 || ^8.0", - "phpstan/phpdoc-parser": "^1.22.0", + "phpstan/phpdoc-parser": "^1.23.0", "squizlabs/php_codesniffer": "^3.7.1" }, "require-dev": { "phing/phing": "2.17.4", "php-parallel-lint/php-parallel-lint": "1.3.2", - "phpstan/phpstan": "1.10.21", + "phpstan/phpstan": "1.10.26", "phpstan/phpstan-deprecation-rules": "1.1.3", "phpstan/phpstan-phpunit": "1.3.13", "phpstan/phpstan-strict-rules": "1.5.1", - "phpunit/phpunit": "7.5.20|8.5.21|9.6.8|10.2.2" + "phpunit/phpunit": "7.5.20|8.5.21|9.6.8|10.2.6" }, - "time": "2023-06-25T12:52:34+00:00", + "time": "2023-07-25T10:28:55+00:00", "type": "phpcodesniffer-standard", "extra": { "branch-alias": { @@ -3064,7 +3067,7 @@ ], "support": { "issues": "https://github.com/slevomat/coding-standard/issues", - "source": "https://github.com/slevomat/coding-standard/tree/8.13.1" + "source": "https://github.com/slevomat/coding-standard/tree/8.13.4" }, "funding": [ { @@ -3470,17 +3473,17 @@ }, { "name": "spaze/phpstan-disallowed-calls", - "version": "v2.15.1", - "version_normalized": "2.15.1.0", + "version": "v2.16.0", + "version_normalized": "2.16.0.0", "source": { "type": "git", "url": "https://github.com/spaze/phpstan-disallowed-calls.git", - "reference": "f80ca038a4052224c562f07d43cfe913113192d0" + "reference": "c7a80cc9747e6307bfa6f5ea88ed3f9b1804790c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spaze/phpstan-disallowed-calls/zipball/f80ca038a4052224c562f07d43cfe913113192d0", - "reference": "f80ca038a4052224c562f07d43cfe913113192d0", + "url": "https://api.github.com/repos/spaze/phpstan-disallowed-calls/zipball/c7a80cc9747e6307bfa6f5ea88ed3f9b1804790c", + "reference": "c7a80cc9747e6307bfa6f5ea88ed3f9b1804790c", "shasum": "" }, "require": { @@ -3496,7 +3499,7 @@ "spaze/coding-standard": "^1.7", "symfony/polyfill-php80": "^1.27" }, - "time": "2023-07-01T21:33:24+00:00", + "time": "2023-07-26T11:37:27+00:00", "type": "phpstan-extension", "extra": { "phpstan": { @@ -3528,7 +3531,7 @@ ], "support": { "issues": "https://github.com/spaze/phpstan-disallowed-calls/issues", - "source": "https://github.com/spaze/phpstan-disallowed-calls/tree/v2.15.1" + "source": "https://github.com/spaze/phpstan-disallowed-calls/tree/v2.16.0" }, "funding": [ { diff --git a/site/vendor/composer/installed.php b/site/vendor/composer/installed.php index 915266a1c..dad50f48d 100644 --- a/site/vendor/composer/installed.php +++ b/site/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'spaze/michalspacek.cz', 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '7c766412154691051035dcd11931bb2b614d209f', + 'reference' => '876e81b678a8c85d9a5611446ace274079c5929b', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -302,9 +302,9 @@ 'dev_requirement' => true, ), 'phpstan/phpdoc-parser' => array( - 'pretty_version' => '1.22.1', - 'version' => '1.22.1.0', - 'reference' => '65c39594fbd8c67abfc68bb323f86447bab79cc0', + 'pretty_version' => '1.23.0', + 'version' => '1.23.0.0', + 'reference' => 'a2b24135c35852b348894320d47b3902a94bc494', 'type' => 'library', 'install_path' => __DIR__ . '/../phpstan/phpdoc-parser', 'aliases' => array(), @@ -379,7 +379,7 @@ 'roave/security-advisories' => array( 'pretty_version' => 'dev-latest', 'version' => 'dev-latest', - 'reference' => 'bd50a5b0522c94e65c90eb8d8cc040a630a07b0c', + 'reference' => '69dafab8a5dffa4d6a4d6dab1ebadf48aca449c7', 'type' => 'metapackage', 'install_path' => NULL, 'aliases' => array( @@ -388,9 +388,9 @@ 'dev_requirement' => true, ), 'slevomat/coding-standard' => array( - 'pretty_version' => '8.13.1', - 'version' => '8.13.1.0', - 'reference' => 'a13c15e20f2d307a1ca8dec5313ec462a4466470', + 'pretty_version' => '8.13.4', + 'version' => '8.13.4.0', + 'reference' => '4b2af2fb17773656d02fbfb5d18024ebd19fe322', 'type' => 'phpcodesniffer-standard', 'install_path' => __DIR__ . '/../slevomat/coding-standard', 'aliases' => array(), @@ -435,7 +435,7 @@ 'spaze/michalspacek.cz' => array( 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '7c766412154691051035dcd11931bb2b614d209f', + 'reference' => '876e81b678a8c85d9a5611446ace274079c5929b', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -469,9 +469,9 @@ 'dev_requirement' => false, ), 'spaze/phpstan-disallowed-calls' => array( - 'pretty_version' => 'v2.15.1', - 'version' => '2.15.1.0', - 'reference' => 'f80ca038a4052224c562f07d43cfe913113192d0', + 'pretty_version' => 'v2.16.0', + 'version' => '2.16.0.0', + 'reference' => 'c7a80cc9747e6307bfa6f5ea88ed3f9b1804790c', 'type' => 'phpstan-extension', 'install_path' => __DIR__ . '/../spaze/phpstan-disallowed-calls', 'aliases' => array(), diff --git a/site/vendor/phpstan/phpdoc-parser/src/Parser/PhpDocParser.php b/site/vendor/phpstan/phpdoc-parser/src/Parser/PhpDocParser.php index c92b8093a..7b56e3bda 100644 --- a/site/vendor/phpstan/phpdoc-parser/src/Parser/PhpDocParser.php +++ b/site/vendor/phpstan/phpdoc-parser/src/Parser/PhpDocParser.php @@ -14,6 +14,7 @@ use function array_key_exists; use function array_values; use function count; +use function rtrim; use function str_replace; use function trim; @@ -49,6 +50,9 @@ class PhpDocParser /** @var bool */ private $useIndexAttributes; + /** @var bool */ + private $textBetweenTagsBelongsToDescription; + /** * @param array{lines?: bool, indexes?: bool} $usedAttributes */ @@ -58,7 +62,8 @@ public function __construct( bool $requireWhitespaceBeforeDescription = false, bool $preserveTypeAliasesWithInvalidTypes = false, array $usedAttributes = [], - bool $parseDoctrineAnnotations = false + bool $parseDoctrineAnnotations = false, + bool $textBetweenTagsBelongsToDescription = false ) { $this->typeParser = $typeParser; @@ -68,6 +73,7 @@ public function __construct( $this->parseDoctrineAnnotations = $parseDoctrineAnnotations; $this->useLinesAttributes = $usedAttributes['lines'] ?? false; $this->useIndexAttributes = $usedAttributes['indexes'] ?? false; + $this->textBetweenTagsBelongsToDescription = $textBetweenTagsBelongsToDescription; } @@ -214,25 +220,54 @@ private function parseText(TokenIterator $tokens): Ast\PhpDoc\PhpDocTextNode { $text = ''; - while (!$tokens->isCurrentTokenType(Lexer::TOKEN_PHPDOC_EOL)) { - $text .= $tokens->getSkippedHorizontalWhiteSpaceIfAny() . $tokens->joinUntil(Lexer::TOKEN_PHPDOC_EOL, Lexer::TOKEN_CLOSE_PHPDOC, Lexer::TOKEN_END); + $endTokens = [Lexer::TOKEN_PHPDOC_EOL, Lexer::TOKEN_CLOSE_PHPDOC, Lexer::TOKEN_END]; + if ($this->textBetweenTagsBelongsToDescription) { + $endTokens = [Lexer::TOKEN_CLOSE_PHPDOC, Lexer::TOKEN_END]; + } + + $savepoint = false; + // if the next token is EOL, everything below is skipped and empty string is returned + while ($this->textBetweenTagsBelongsToDescription || !$tokens->isCurrentTokenType(Lexer::TOKEN_PHPDOC_EOL)) { + $tmpText = $tokens->getSkippedHorizontalWhiteSpaceIfAny() . $tokens->joinUntil(Lexer::TOKEN_PHPDOC_EOL, ...$endTokens); + $text .= $tmpText; + + // stop if we're not at EOL - meaning it's the end of PHPDoc if (!$tokens->isCurrentTokenType(Lexer::TOKEN_PHPDOC_EOL)) { break; } + if ($this->textBetweenTagsBelongsToDescription) { + if (!$savepoint) { + $tokens->pushSavePoint(); + $savepoint = true; + } elseif ($tmpText !== '') { + $tokens->dropSavePoint(); + $tokens->pushSavePoint(); + } + } + $tokens->pushSavePoint(); $tokens->next(); - if ($tokens->isCurrentTokenType(Lexer::TOKEN_PHPDOC_TAG, Lexer::TOKEN_DOCTRINE_TAG, Lexer::TOKEN_PHPDOC_EOL, Lexer::TOKEN_CLOSE_PHPDOC, Lexer::TOKEN_END)) { + // if we're at EOL, check what's next + // if next is a PHPDoc tag, EOL, or end of PHPDoc, stop + if ($tokens->isCurrentTokenType(Lexer::TOKEN_PHPDOC_TAG, Lexer::TOKEN_DOCTRINE_TAG, ...$endTokens)) { $tokens->rollback(); break; } + // otherwise if the next is text, continue building the description string + $tokens->dropSavePoint(); $text .= $tokens->getDetectedNewline() ?? "\n"; } + if ($savepoint) { + $tokens->rollback(); + $text = rtrim($text, $tokens->getDetectedNewline() ?? "\n"); + } + return new Ast\PhpDoc\PhpDocTextNode(trim($text, " \t")); } @@ -241,9 +276,19 @@ private function parseOptionalDescriptionAfterDoctrineTag(TokenIterator $tokens) { $text = ''; - while (!$tokens->isCurrentTokenType(Lexer::TOKEN_PHPDOC_EOL)) { - $text .= $tokens->getSkippedHorizontalWhiteSpaceIfAny() . $tokens->joinUntil(Lexer::TOKEN_PHPDOC_TAG, Lexer::TOKEN_DOCTRINE_TAG, Lexer::TOKEN_PHPDOC_EOL, Lexer::TOKEN_CLOSE_PHPDOC, Lexer::TOKEN_END); + $endTokens = [Lexer::TOKEN_PHPDOC_EOL, Lexer::TOKEN_CLOSE_PHPDOC, Lexer::TOKEN_END]; + if ($this->textBetweenTagsBelongsToDescription) { + $endTokens = [Lexer::TOKEN_CLOSE_PHPDOC, Lexer::TOKEN_END]; + } + + $savepoint = false; + + // if the next token is EOL, everything below is skipped and empty string is returned + while ($this->textBetweenTagsBelongsToDescription || !$tokens->isCurrentTokenType(Lexer::TOKEN_PHPDOC_EOL)) { + $tmpText = $tokens->getSkippedHorizontalWhiteSpaceIfAny() . $tokens->joinUntil(Lexer::TOKEN_PHPDOC_TAG, Lexer::TOKEN_DOCTRINE_TAG, Lexer::TOKEN_PHPDOC_EOL, ...$endTokens); + $text .= $tmpText; + // stop if we're not at EOL - meaning it's the end of PHPDoc if (!$tokens->isCurrentTokenType(Lexer::TOKEN_PHPDOC_EOL)) { if (!$tokens->isPrecededByHorizontalWhitespace()) { return trim($text . $this->parseText($tokens)->text, " \t"); @@ -278,18 +323,37 @@ private function parseOptionalDescriptionAfterDoctrineTag(TokenIterator $tokens) break; } + if ($this->textBetweenTagsBelongsToDescription) { + if (!$savepoint) { + $tokens->pushSavePoint(); + $savepoint = true; + } elseif ($tmpText !== '') { + $tokens->dropSavePoint(); + $tokens->pushSavePoint(); + } + } + $tokens->pushSavePoint(); $tokens->next(); - if ($tokens->isCurrentTokenType(Lexer::TOKEN_PHPDOC_TAG, Lexer::TOKEN_DOCTRINE_TAG, Lexer::TOKEN_PHPDOC_EOL, Lexer::TOKEN_CLOSE_PHPDOC, Lexer::TOKEN_END)) { + // if we're at EOL, check what's next + // if next is a PHPDoc tag, EOL, or end of PHPDoc, stop + if ($tokens->isCurrentTokenType(Lexer::TOKEN_PHPDOC_TAG, Lexer::TOKEN_DOCTRINE_TAG, ...$endTokens)) { $tokens->rollback(); break; } + // otherwise if the next is text, continue building the description string + $tokens->dropSavePoint(); $text .= $tokens->getDetectedNewline() ?? "\n"; } + if ($savepoint) { + $tokens->rollback(); + $text = rtrim($text, $tokens->getDetectedNewline() ?? "\n"); + } + return trim($text, " \t"); } diff --git a/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/AnnotationHelper.php b/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/AnnotationHelper.php index d015f9566..f6081af13 100644 --- a/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/AnnotationHelper.php +++ b/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/AnnotationHelper.php @@ -25,12 +25,9 @@ use PHPStan\PhpDocParser\Ast\Type\ObjectShapeItemNode; use PHPStan\PhpDocParser\Ast\Type\ObjectShapeNode; use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode; -use function count; use function in_array; use function sprintf; -use function strlen; use function strtolower; -use const T_DOC_COMMENT_STRING; /** * @internal @@ -67,11 +64,11 @@ static function () use ($phpcsFile, $docCommentOpenPointer, $name): array { if ($parsedDocComment !== null) { foreach ($parsedDocComment->getNode()->getTags() as $node) { - $annotationStartPointer = self::getStartPointer($phpcsFile, $parsedDocComment->getOpenPointer(), $node); + $annotationStartPointer = $parsedDocComment->getNodeStartPointer($phpcsFile, $node); $annotations[] = new Annotation( $node, $annotationStartPointer, - self::getEndPointer($phpcsFile, $parsedDocComment, $annotationStartPointer, $node) + $parsedDocComment->getNodeEndPointer($phpcsFile, $node, $annotationStartPointer) ); } } @@ -309,64 +306,6 @@ public static function isAnnotationUseless( ); } - private static function getStartPointer(File $phpcsFile, int $docCommentOpenPointer, PhpDocTagNode $annotationNode): int - { - $tokens = $phpcsFile->getTokens(); - - $tagStartLine = $tokens[$docCommentOpenPointer]['line'] + $annotationNode->getAttribute('startLine') - 1; - - $searchPointer = $docCommentOpenPointer + 1; - for ($i = $docCommentOpenPointer + 1; $i < $tokens[$docCommentOpenPointer]['comment_closer']; $i++) { - if ($tagStartLine === $tokens[$i]['line']) { - $searchPointer = $i; - break; - } - } - - return TokenHelper::findNext($phpcsFile, TokenHelper::$annotationTokenCodes, $searchPointer); - } - - private static function getEndPointer( - File $phpcsFile, - ParsedDocComment $parsedDocComment, - int $annotationStartPointer, - PhpDocTagNode $annotationNode - ): int - { - $tokens = $phpcsFile->getTokens(); - - $annotationContent = $parsedDocComment->getTokens()->getContentBetween( - $annotationNode->getAttribute(Attribute::START_INDEX), - $annotationNode->getAttribute(Attribute::END_INDEX) + 1 - ); - $annotationLength = strlen($annotationContent); - - $searchPointer = $annotationStartPointer; - - $content = ''; - for ($i = $annotationStartPointer; $i < count($tokens); $i++) { - $content .= $tokens[$i]['content']; - - if (strlen($content) >= $annotationLength) { - $searchPointer = $i; - break; - } - } - - $nextAnnotationStartPointer = TokenHelper::findNext( - $phpcsFile, - TokenHelper::$annotationTokenCodes, - $searchPointer + 1, - $parsedDocComment->getClosePointer() - ); - - $pointerAfter = $nextAnnotationStartPointer ?? $parsedDocComment->getClosePointer(); - - $stringPointerBefore = TokenHelper::findPrevious($phpcsFile, T_DOC_COMMENT_STRING, $pointerAfter - 1, $searchPointer); - - return $stringPointerBefore ?? $searchPointer; - } - private static function changeAnnotationNode(PhpDocTagNode $tagNode, Node $nodeToChange, Node $changedNode): PhpDocTagNode { static $visitor; diff --git a/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/DocCommentHelper.php b/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/DocCommentHelper.php index 40339b819..ffed9954d 100644 --- a/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/DocCommentHelper.php +++ b/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/DocCommentHelper.php @@ -12,6 +12,7 @@ use function in_array; use function preg_match; use function sprintf; +use function stripos; use function strtolower; use function trim; use const T_ABSTRACT; @@ -130,7 +131,7 @@ public static function hasInheritdocAnnotation(File $phpcsFile, int $pointer): b } foreach ($parsedDocComment->getNode()->children as $child) { - if ($child instanceof PhpDocTextNode && strtolower($child->text) === '{@inheritdoc}') { + if ($child instanceof PhpDocTextNode && stripos($child->text, '{@inheritdoc}') !== false) { return true; } diff --git a/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/ParsedDocComment.php b/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/ParsedDocComment.php index 8eccb3d6f..2c4fa0113 100644 --- a/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/ParsedDocComment.php +++ b/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/ParsedDocComment.php @@ -2,8 +2,16 @@ namespace SlevomatCodingStandard\Helpers; +use PHP_CodeSniffer\Files\File; +use PHPStan\PhpDocParser\Ast\Attribute; +use PHPStan\PhpDocParser\Ast\Node; use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode; use PHPStan\PhpDocParser\Parser\TokenIterator; +use function array_merge; +use function count; +use function strlen; +use function trim; +use const T_DOC_COMMENT_STRING; /** * @internal @@ -51,4 +59,50 @@ public function getTokens(): TokenIterator return $this->tokens; } + public function getNodeStartPointer(File $phpcsFile, Node $node): int + { + $tokens = $phpcsFile->getTokens(); + + $tagStartLine = $tokens[$this->openPointer]['line'] + $node->getAttribute('startLine') - 1; + + $searchPointer = $this->openPointer + 1; + for ($i = $this->openPointer + 1; $i < $this->closePointer; $i++) { + if ($tagStartLine === $tokens[$i]['line']) { + $searchPointer = $i; + break; + } + } + + return TokenHelper::findNext($phpcsFile, array_merge(TokenHelper::$annotationTokenCodes, [T_DOC_COMMENT_STRING]), $searchPointer); + } + + public function getNodeEndPointer(File $phpcsFile, Node $node, int $nodeStartPointer): int + { + $tokens = $phpcsFile->getTokens(); + + $content = trim($this->tokens->getContentBetween( + $node->getAttribute(Attribute::START_INDEX), + $node->getAttribute(Attribute::END_INDEX) + 1 + )); + $length = strlen($content); + + $searchPointer = $nodeStartPointer; + + $content = ''; + for ($i = $nodeStartPointer; $i < count($tokens); $i++) { + $content .= $tokens[$i]['content']; + + if (strlen($content) >= $length) { + $searchPointer = $i; + break; + } + } + + return TokenHelper::findPrevious( + $phpcsFile, + array_merge(TokenHelper::$annotationTokenCodes, [T_DOC_COMMENT_STRING]), + $searchPointer + ); + } + } diff --git a/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/PhpDocParserHelper.php b/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/PhpDocParserHelper.php index 257565c14..6cc06d61a 100644 --- a/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/PhpDocParserHelper.php +++ b/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/PhpDocParserHelper.php @@ -42,6 +42,7 @@ public static function getParser(): PhpDocParser true, true, $usedAttributes, + true, true ); } diff --git a/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Attributes/RequireAttributeAfterDocCommentSniff.php b/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Attributes/RequireAttributeAfterDocCommentSniff.php index e78063dd3..9729e99a9 100644 --- a/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Attributes/RequireAttributeAfterDocCommentSniff.php +++ b/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Attributes/RequireAttributeAfterDocCommentSniff.php @@ -65,7 +65,7 @@ public function process(File $phpcsFile, $attributeOpenerPointer): void $attributeStartPointer = TokenHelper::findFirstTokenOnLine($phpcsFile, $firstAttributeOpenerPointer); $fix = $phpcsFile->addFixableError( - 'Attribute should be placed before documentation comment.', + 'Attribute should be placed after documentation comment.', $attributeOpenerPointer, self::CODE_ATTRIBUTE_BEFORE_DOC_COMMENT ); diff --git a/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Commenting/DocCommentSpacingSniff.php b/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Commenting/DocCommentSpacingSniff.php index 5f9675c8e..f2ac58b73 100644 --- a/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Commenting/DocCommentSpacingSniff.php +++ b/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Commenting/DocCommentSpacingSniff.php @@ -17,7 +17,6 @@ use function array_key_exists; use function array_keys; use function array_map; -use function array_merge; use function array_values; use function asort; use function count; @@ -35,7 +34,6 @@ use function usort; use const T_DOC_COMMENT_OPEN_TAG; use const T_DOC_COMMENT_STAR; -use const T_DOC_COMMENT_STRING; use const T_DOC_COMMENT_WHITESPACE; class DocCommentSpacingSniff implements Sniff @@ -103,34 +101,27 @@ public function process(File $phpcsFile, $docCommentOpenerPointer): void $tokens = $phpcsFile->getTokens(); - $firstContentStartPointer = TokenHelper::findNextExcluding( + if (TokenHelper::findNextExcluding( $phpcsFile, [T_DOC_COMMENT_WHITESPACE, T_DOC_COMMENT_STAR], $docCommentOpenerPointer + 1, $tokens[$docCommentOpenerPointer]['comment_closer'] - ); - - if ($firstContentStartPointer === null) { + ) === null) { return; } - $firstContentEndPointer = $firstContentStartPointer; - $actualPointer = $firstContentStartPointer; - do { - /** @var int $actualPointer */ - $actualPointer = TokenHelper::findNextExcluding( - $phpcsFile, - [T_DOC_COMMENT_STAR, T_DOC_COMMENT_WHITESPACE], - $actualPointer + 1, - $tokens[$docCommentOpenerPointer]['comment_closer'] + 1 - ); + $parsedDocComment = DocCommentHelper::parseDocComment($phpcsFile, $docCommentOpenerPointer); - if ($tokens[$actualPointer]['code'] !== T_DOC_COMMENT_STRING) { - break; - } + if ($parsedDocComment === null) { + return; + } - $firstContentEndPointer = $actualPointer; - } while (true); + $firstContentStartPointer = $parsedDocComment->getNodeStartPointer($phpcsFile, $parsedDocComment->getNode()->children[0]); + $firstContentEndPointer = $parsedDocComment->getNodeEndPointer( + $phpcsFile, + $parsedDocComment->getNode()->children[0], + $firstContentStartPointer + ); $annotations = AnnotationHelper::getAnnotations($phpcsFile, $docCommentOpenerPointer); usort($annotations, static function (Annotation $a, Annotation $b): int { @@ -142,11 +133,7 @@ public function process(File $phpcsFile, $docCommentOpenerPointer): void /** @var int $lastContentEndPointer */ $lastContentEndPointer = $annotationsCount > 0 - ? TokenHelper::findPrevious( - $phpcsFile, - array_merge(TokenHelper::$annotationTokenCodes, [T_DOC_COMMENT_STRING]), - $tokens[$docCommentOpenerPointer]['comment_closer'] - 1 - ) + ? $annotations[$annotationsCount - 1]->getEndPointer() : $firstContentEndPointer; $this->checkLinesBeforeFirstContent($phpcsFile, $docCommentOpenerPointer, $firstContentStartPointer); diff --git a/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/ControlStructures/AbstractControlStructureSpacing.php b/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/ControlStructures/AbstractControlStructureSpacing.php index cfcdcd3f2..2c1bb8077 100644 --- a/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/ControlStructures/AbstractControlStructureSpacing.php +++ b/site/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/ControlStructures/AbstractControlStructureSpacing.php @@ -217,7 +217,9 @@ protected function checkLinesBefore(File $phpcsFile, int $controlStructurePointe $phpcsFile->fixer->replaceToken($pointerBefore, 'method()` calls -2. `disallowedStaticCalls` - for static calls `Class::method()` -3. `disallowedFunctionCalls` - for functions like `function()` -4. `disallowedConstants` - for constants like `DATE_ISO8601` or `DateTime::ISO8601` (which needs to be split to `class: DateTime` & `constant: ISO8601` in the configuration, see notes below) -5. `disallowedNamespaces` or `disallowedClasses` - for usages of classes or classes from a namespace -6. `disallowedSuperglobals` - for usages of superglobal variables like `$GLOBALS` or `$_POST` -7. `disallowedAttributes` - for attributes like `#[Entity(class: Foo::class, something: true)]` - -Use them to add rules to your `phpstan.neon` config file. I like to use a separate file (`disallowed-calls.neon`) for these which I'll include later on in the main `phpstan.neon` config file. Here's an example, update to your needs: - -```neon -parameters: - disallowedMethodCalls: - - - method: 'PotentiallyDangerous\Logger::log()' # `function` is an alias of `method` - message: 'use our own logger instead' - errorTip: 'see https://our-docs.example/logging on how logging should be used' - - - method: 'Redis::connect()' - message: 'use our own Redis instead' - errorIdentifier: 'redis.connect' - - disallowedStaticCalls: - - - method: 'PotentiallyDangerous\Debugger::log()' - message: 'use our own logger instead' - - disallowedFunctionCalls: - - - function: 'var_dump()' # `method` is an alias of `function` - message: 'use logger instead' - - - function: 'print_r()' - message: 'use logger instead' - - disallowedConstants: - - - constant: 'DATE_ISO8601' - message: 'use DATE_ATOM instead' - - - class: 'DateTimeInterface' - constant: 'ISO8601' - message: 'use DateTimeInterface::ATOM instead' - - disallowedNamespaces: # `disallowedClasses` is an alias of `disallowedNamespaces` - - - class: 'Symfony\Component\HttpFoundation\RequestStack' # `class` is an alias of `namespace` - message: 'pass Request via controller instead' - allowIn: - - tests/* - - - namespace: 'Assert\*' # `namespace` is an alias of `class` - message: 'use Webmozart\Assert instead' - - disallowedSuperglobals: - - - superglobal: '$_GET' - message: 'use the Request methods instead' - - disallowedAttributes: - - - attribute: Entity - message: 'use our own custom Entity instead' -``` +The extension supports versatile [custom rules](docs/custom-rules.md), too. -The `message` key is optional. Functions and methods can be specified with or without `()`. Omitting `()` is not recommended though to avoid confusing method calls with class constants. +### Allow some previously disallowed calls or usages -If you want to disallow multiple calls, constants, class constants (same-class only), classes, namespaces or variables that share the same `message` and other config keys, you can use a list or an array to specify them all: -```neon -parameters: - disallowedFunctionCalls: - - - function: - - 'var_dump()' - - 'print_r()' - message: 'use logger instead' - - disallowedConstants: - - - class: 'DateTimeInterface' - constant: ['ISO8601', 'RFC3339', 'W3C'] - message: 'use DateTimeInterface::ATOM instead' -``` +Let's say you have disallowed `foo()` with custom rules. But you want to re-allow it when used in your custom wrapper, or when the first parameter equals, or not, a specified value. The extension offers multiple ways of doing that: -The optional `errorTip` key can be used to show an additional message prefixed with 💡 that's rendered below the error message in the analysis result. +- [Ignore errors](docs/allow-ignore-errors.md) the PHPStan way +- [Allow in paths](docs/allow-in-paths.md) +- [Allow in methods or functions](docs/allow-in-methods.md) +- [Allow with specified parameters](docs/allow-with-parameters.md) +- [Allow with specified flags](docs/allow-with-flags.md) -The `errorIdentifier` key is optional. It can be used to provide a unique identifier to the PHPStan error. +[Re-allowing attributes](docs/allow-attributes.md) uses a similar [configuration](docs/allow-attributes.md). -Use wildcard (`*`) to ignore all functions, methods, classes, namespaces starting with a prefix, for example: -```neon -parameters: - disallowedFunctionCalls: - - - function: 'pcntl_*()' -``` -The wildcard makes most sense when used as the rightmost character of the function or method name, optionally followed by `()`, but you can use it anywhere for example to disallow all functions that end with `y`: `function: '*y()'`. The matching is powered by [`fnmatch`](https://www.php.net/function.fnmatch) so you can use even multiple wildcards if you wish because w\*y n\*t. -If there's this one function, method, namespace, attribute (or multiple of them) that you'd like to exclude from the set, you can do that with `exclude`: -```neon -parameters: - disallowedFunctionCalls: - - - function: 'pcntl_*()' - exclude: - - 'pcntl_foobar()' -``` -This config would disallow all `pcntl` functions except (an imaginary) `pcntl_foobar()`. -Please note `exclude` also accepts [`fnmatch`](https://www.php.net/function.fnmatch) patterns so please be careful to not create a contradicting config, and that it can accept both a string and an array of strings. - -Another option how to limit the set of functions or methods selected by the `function` or `method` directive is a file path in which these are defined which mostly makes sense when a [`fnmatch`](https://www.php.net/function.fnmatch) pattern is used in those directives. -Imagine a use case in which you want to disallow any function or method defined in any namespace, or none at all, by this legacy package: -```neon -parameters: - disallowedFunctionCalls: - - - function: '*' - definedIn: - - 'vendor/foo/bar' - disallowedMethodCalls: - - - method: '*' - definedIn: - - 'vendor/foo/bar' - filesRootDir: %rootDir%/../../.. -``` -Relative paths in `definedIn` are resolved based on the current working directory. When running PHPStan from a directory or subdirectory which is not your "root" directory, the paths will probably not work. -Use `filesRootDir` in that case to specify an absolute root directory, you can use [`%rootDir%`](https://phpstan.org/config-reference#expanding-paths) to start with PHPStan's root directory (usually `/something/something/vendor/phpstan/phpstan`) and then `..` from there to your "root" directory. -`filesRootDir` is also used to configure all `allowIn` directives, see below. +## Disallow disabled functions & classes -You can treat some language constructs as functions and disallow it in `disallowedFunctionCalls`. Currently detected language constructs are: -- `die()` -- `echo()` -- `empty()` -- `eval()` -- `exit()` -- `print()` - -To disallow naive object creation (`new ClassName()` or `new $classname`), disallow `NameSpace\ClassName::__construct` in `disallowedMethodCalls`. Works even when there's no constructor defined in that class. - -### Disallowing constants - -Constants are a special breed. First, a constant needs to be disallowed on the declaring class. That means, that instead of disallowing `Date::ISO8601` or `DateTimeImmutable::ISO8601`, you need to disallow `DateTimeInterface::ISO8601`. -The reason for this is that one might expect that disallowing e.g. `Date::ISO8601` (disallowing on a "used on" class) would also disallow `DateTimeImmutable::ISO8601`, which unfortunately wouldn't be the case. - -Second, disallowing constants doesn't support wildcards. The only real-world use case I could think of is the `Date*::CONSTANT` case and that can be easily solved by disallowing `DateTimeInterface::CONSTANT` already. - -Last but not least, class constants have to be specified using two keys: `class` and `constant`: -```neon -parameters: - disallowedConstants: - - - class: 'DateTimeInterface' - constant: 'ISO8601' - message: 'use DateTimeInterface::ATOM instead' -``` -Using the fully-qualified name would result in the constant being replaced with its actual value. Otherwise, the extension would see `constant: "Y-m-d\TH:i:sO"` instead of `constant: DateTimeInterface::ISO8601` for example. +Use the [provided generator](docs/disallow-disabled-functions-classes.md) to generate a configuration snippet from PHP's `disable_functions` & `disable_classes` configuration directives. ## Example output @@ -256,324 +72,13 @@ Using the fully-qualified name would result in the constant being replaced with ------ -------------------------------------------------------- ``` -## Allow some previously disallowed calls or attributes - -Sometimes, the method, the function, or the constant needs to be called or used once in your code, for example in a custom wrapper. You can use PHPStan's [`ignoreErrors` feature](https://github.com/phpstan/phpstan#ignore-error-messages-with-regular-expressions) to ignore that one call: - -```neon -ignoreErrors: - - - message: '#^Calling Redis::connect\(\) is forbidden, use our own Redis instead#' # Needed for the constructor - path: application/libraries/Redis/Redis.php - - - message: '#^Calling print_r\(\) is forbidden, use logger instead#' # Used with $return = true - paths: - - application/libraries/Tls/Certificate.php - - application/libraries/Tls/CertificateSigningRequest.php - - application/libraries/Tls/PublicKey.php -``` - -You can also allow some previously disallowed calls and usages using the `allowIn` configuration key, for example: - -```neon -parameters: - disallowedMethodCalls: - - - method: 'PotentiallyDangerous\Logger::log()' - message: 'use our own logger instead' - allowIn: - - path/to/some/file-*.php - - tests/*.test.php -``` - -Paths in `allowIn` support [fnmatch()](https://www.php.net/function.fnmatch) patterns. - -Relative paths in `allowIn` are resolved based on the current working directory. When running PHPStan from a directory or subdirectory which is not your "root" directory, the paths will probably not work. -Use `filesRootDir` in that case to specify an absolute root directory for all `allowIn` paths. Absolute paths might change between machines (for example your local development machine and a continuous integration machine) but you -can use [`%rootDir%`](https://phpstan.org/config-reference#expanding-paths) to start with PHPStan's root directory (usually `/something/something/vendor/phpstan/phpstan`) and then `..` from there to your "root" directory. - -For example when PHPStan is installed in `/home/foo/vendor/phpstan/phpstan` and you're using a configuration like this: -```neon -parameters: - filesRootDir: %rootDir%/../../.. - disallowedMethodCalls: - - - method: 'PotentiallyDangerous\Logger::log()' - allowIn: - - path/to/some/file-*.php -``` -then `Logger::log()` will be allowed in `/home/foo/path/to/some/file-bar.php`. - -If you need to disallow a methods or a function call, a constant, a namespace, a class, a superglobal, or an attribute usage only in certain paths, as an inverse of `allowIn`, you can use `allowExceptIn` (or the `disallowIn` alias): -```neon -parameters: - filesRootDir: %rootDir%/../../.. - disallowedMethodCalls: - - - method: 'PotentiallyDangerous\Logger::log()' - allowExceptIn: - - path/to/some/dir/*.php -``` -This will disallow `PotentiallyDangerous\Logger::log()` calls in `%rootDir%/../../../path/to/some/dir/*.php`. - -Please note that before version 2.15, `filesRootDir` was called `allowInRootDir` which is still supported, but deprecated. - -To allow a previously disallowed method or function only when called from a different method or function in any file, use `allowInFunctions` (or `allowInMethods` alias): - -```neon -parameters: - disallowedMethodCalls: - - - method: 'PotentiallyDangerous\Logger::log()' - message: 'use our own logger instead' - allowInMethods: - - Foo\Bar\Baz::method() -``` - -And vice versa, if you need to disallow a method or a function call only when done from a particular method or function, use `allowExceptInFunctions` (with aliases `allowExceptInMethods`, `disallowInFunctions`, `disallowInMethods`): - -```neon -parameters: - disallowedMethodCalls: - - - method: 'Controller::redirect()' - message: 'redirect in startup() instead' - allowExceptInMethods: - - Controller\Foo\Bar\*::__construct() -``` - -The function or method names support [fnmatch()](https://www.php.net/function.fnmatch) patterns. - -### Allow with specified parameters only - -You can also narrow down the allowed items when called with some parameters (applies only to disallowed method, static & function calls, for obvious reasons). _Please note that for now, only scalar values are supported in the configuration, not arrays._ - -For example, you want to disallow calling `print_r()` but want to allow `print_r(..., true)`. -This can be done with optional `allowParamsInAllowed` or `allowParamsAnywhere` configuration keys: - -```neon -parameters: - disallowedMethodCalls: - - - method: 'PotentiallyDangerous\Logger::log()' - message: 'use our own logger instead' - allowIn: - - path/to/some/file-*.php - - tests/*.test.php - allowParamsInAllowed: - - - position: 1 - name: 'message' - value: 'foo' - - - position: 2 - name: 'alert' - value: true - allowParamsAnywhere: - - - position: 2 - name: 'alert' - value: true -``` - -When using `allowParamsInAllowed`, calls will be allowed only when they are in one of the `allowIn` paths, and are called with all parameters listed in `allowParamsInAllowed`. -With `allowParamsAnywhere`, calls are allowed when called with all parameters listed no matter in which file. In the example above, the `log()` method will be disallowed unless called as: -- `log(..., true)` (or `log(..., alert: true)`) anywhere -- `log('foo', true)` (or `log(message: 'foo', alert: true)`) in `another/file.php` or `optional/path/to/log.tests.php` - -Use `allowParamsInAllowedAnyValue` and `allowParamsAnywhereAnyValue` if you don't care about the parameter's value but want to make sure the parameter is passed. -Following the previous example: - -```neon -parameters: - disallowedMethodCalls: - - - method: 'PotentiallyDangerous\Logger::log()' - message: 'use our own logger instead' - allowIn: - - path/to/some/file-*.php - - tests/*.test.php - allowParamsInAllowedAnyValue: - - - position: 2 - name: 'alert' - allowParamsAnywhereAnyValue: - - - position: 1 - name: 'message' -``` -means that you should use (`...` means any value): -- `log(...)` (or `log(message: ...)`) anywhere -- `log(..., ...)` (or `log(message: ..., alert: ...)`) in `another/file.php` or `optional/path/to/log.tests.php` - -Such configuration only makes sense when both the parameters of `log()` are optional. If they are required, omitting them would result in an error already detected by PHPStan itself. - -### Allow calls except when a param has a specified value - -Sometimes, it's handy to disallow a function or a method call only when a parameter matches a configured value but allow it otherwise. _Please note that currently only scalar values are supported, not arrays._ - -For example the `hash()` function, it's fine using it with algorithm families like SHA-2 & SHA-3 (not for passwords though) but you'd like PHPStan to report when it's used with MD5 like `hash('md5', ...)`. -You can use `allowExceptParams` (or `disallowParams`), `allowExceptCaseInsensitiveParams` (or `disallowCaseInsensitiveParams`), `allowExceptParamsInAllowed` (or `disallowParamsInAllowed`) config options to disallow only some calls: - -```neon -parameters: - disallowedFunctionCalls: - - - function: 'hash()' - allowExceptCaseInsensitiveParams: - - - position: 1 - name: 'algo' - value: 'md5' -``` - -This will disallow `hash()` call where the first parameter (or the named parameter `algo`) is `'md5'`. `allowExceptCaseInsensitiveParams` is used because the first parameter of `hash()` is case-insensitive (so you can also use `'MD5'`, or even `'Md5'` & `'mD5'` if you wish). -To disallow only exact matches, use `allowExceptParams`: - -```neon -parameters: - disallowedFunctionCalls: - - - function: 'foo()' - allowExceptParams: - - - position: 2 - value: 'baz' -``` -will disallow `foo('bar', 'baz')` but not `foo('bar', 'BAZ')`. - -It's also possible to disallow functions and methods previously allowed by path (using `allowIn`) or by function/method name (`allowInMethods`) when they're called with specified parameters, and allow when called with any other parameter. This is done using the `allowExceptParamsInAllowed` config option. - -Take this example configuration: - -```neon -parameters: - disallowedFunctionCalls: - - - function: 'waldo()' - allowIn: - - 'views/*' - allowExceptParamsInAllowed: - - - position: 2 - value: 'quux' -``` - -Calling `waldo()` is disallowed, and allowed back again only when the file is in the `views/` subdirectory **and** `waldo()` is called in the file with a 2nd parameter being the string `quux`. - -As already demonstrated above, named parameters are also supported: - -```neon -parameters: - disallowedFunctionCalls: - - - function: 'json_decode()' - message: 'set the $flags parameter to `JSON_THROW_ON_ERROR` to throw a JsonException' - allowParamsAnywhere: - - - position: 4 - name: 'flags' - value: ::JSON_THROW_ON_ERROR -``` - -This format allows to detect the value in both cases whether it's used with a traditional positional parameter (e.g. `json_decode($foo, null, 512, JSON_THROW_ON_ERROR)`) or a named parameter (e.g. `json_decode($foo, flags: JSON_THROW_ON_ERROR)`). -All keys are optional but if you don't specify `name`, the named parameter will not be found in a call like e.g. `json_decode($foo, null, 512, JSON_THROW_ON_ERROR)`. -And vice versa, if you don't specify the `position` key, only the named parameter will be found matching this definition, not the positional one. - -You can use shortcuts like -```neon -parameters: - disallowedFunctionCalls: - # ... - allowParamsAnywhere: - 2: true - foo: 'bar' - allowParamsAnywhereAnyValue: - - 2 - - foo -``` - -which internally expands to - -```neon -parameters: - disallowedFunctionCalls: - # ... - allowParamsAnywhere: - - - position: 2 - value: true - - - name: foo - value: 'bar' - allowParamsAnywhereAnyValue: - - - position: 2 - - - name: foo -``` - -But because the "positional _or_ named" limitation described above applies here as well, I generally don't recommend using these shortcuts and instead recommend specifying both `position` and `name` keys. - -### Allow with specified parameter flags only - -Some functions can be called with _flags_ or _bitmasks_, for example - -```php -json_encode($foo, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT); -``` -Let's say you want to disallow `json_encode()` except when called with `JSON_HEX_APOS` (integer `4`) flag. In the call above, the value of the second parameter (`JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT`) is `13` (`1 | 4 | 8`). -For the extension to be able to "find" the `4` in `13`, you need to use the `ParamFlags` family of config options: - -- `allowParamFlagsInAllowed` -- `allowParamFlagsAnywhere` -- `allowExceptParamFlagsInAllowed` or `disallowParamFlagsInAllowed` -- `allowExceptParamFlags` or `disallowParamFlags` - -They work like their non-flags `Param` counterparts except they're looking if specific bits in the mask parameter are set. - -The `json_encode()` example mentioned above would look like the following snippet: - -```neon -parameters: - disallowedFunctionCalls: - function: 'json_encode' - allowParamFlagsAnywhere: - - - position: 2 - value: ::JSON_HEX_APOS -``` - -### Allowing previously disallowed attributes -Disallowed PHP attributes can be allowed again using the same configuration as what methods and functions use. For example, to require `#[Entity]` attribute to always specify `$repositoryClass` argument, you can use configuration similar to the one below. First, we disallow all `#[Entity]` attributes, then re-allow them only if they contain the parameter (with any value): -```neon -parameters: - disallowedAttributes: - - - attribute: Entity - message: 'you must specify $repositoryClass parameter with Entity' - allowParamsAnywhereAnyValue: - - - position: 1 - name: repositoryClass -``` - ## Case-(in)sensitivity Function names, method names, class names, namespaces are matched irrespective of their case (disallowing `print_r` will also find `print_R` calls), while anything else like constants, file names, paths are not. -## Detect disallowed calls without any other PHPStan rules - -If you want to use this PHPStan extension without running any other PHPStan rules, you can use `phpstan.neon` config file that looks like this (the `customRulesetUsed: true` and the missing `level` key are the important bits): +## No other rules -```neon -parameters: - customRulesetUsed: true -includes: - - vendor/spaze/phpstan-disallowed-calls/extension.neon - - vendor/spaze/phpstan-disallowed-calls/disallowed-dangerous-calls.neon - - vendor/spaze/phpstan-disallowed-calls/disallowed-execution-calls.neon -``` +You can also use this extension [without any other PHPStan rules](docs/phpstan-custom-ruleset.md). This may be useful if you want to for example check a third-party code for some calls or usage of something. ## Running tests diff --git a/site/vendor/spaze/phpstan-disallowed-calls/docs/README.md b/site/vendor/spaze/phpstan-disallowed-calls/docs/README.md new file mode 100644 index 000000000..0bc59133c --- /dev/null +++ b/site/vendor/spaze/phpstan-disallowed-calls/docs/README.md @@ -0,0 +1 @@ +You may want to read [the README in the parent directory](../README.md) first. diff --git a/site/vendor/spaze/phpstan-disallowed-calls/docs/allow-attributes.md b/site/vendor/spaze/phpstan-disallowed-calls/docs/allow-attributes.md new file mode 100644 index 000000000..1f406bdd4 --- /dev/null +++ b/site/vendor/spaze/phpstan-disallowed-calls/docs/allow-attributes.md @@ -0,0 +1,14 @@ +## Allowing previously disallowed attributes + +Disallowed PHP attributes can be allowed again using the same configuration as what methods and functions use. For example, to require `#[Entity]` attribute to always specify `$repositoryClass` argument, you can use configuration similar to the one below. First, we disallow all `#[Entity]` attributes, then re-allow them only if they contain the parameter (with any value): +```neon +parameters: + disallowedAttributes: + - + attribute: Entity + message: 'you must specify $repositoryClass parameter with Entity' + allowParamsAnywhereAnyValue: + - + position: 1 + name: repositoryClass +``` diff --git a/site/vendor/spaze/phpstan-disallowed-calls/docs/allow-ignore-errors.md b/site/vendor/spaze/phpstan-disallowed-calls/docs/allow-ignore-errors.md new file mode 100644 index 000000000..ec03fa2bc --- /dev/null +++ b/site/vendor/spaze/phpstan-disallowed-calls/docs/allow-ignore-errors.md @@ -0,0 +1,18 @@ +## Allow some previously disallowed calls or attributes + +Sometimes, the method, the function, or the constant needs to be called or used once in your code, for example in a custom wrapper. You can use PHPStan's [`ignoreErrors` feature](https://github.com/phpstan/phpstan#ignore-error-messages-with-regular-expressions) to ignore that one call: + +```neon +ignoreErrors: + - + message: '#^Calling Redis::connect\(\) is forbidden, use our own Redis instead#' # Needed for the constructor + path: application/libraries/Redis/Redis.php + - + message: '#^Calling print_r\(\) is forbidden, use logger instead#' # Used with $return = true + paths: + - application/libraries/Tls/Certificate.php + - application/libraries/Tls/CertificateSigningRequest.php + - application/libraries/Tls/PublicKey.php +``` + +The extension's configuration using custom rules is flexible enough to allow a call with specified attributes only for example. diff --git a/site/vendor/spaze/phpstan-disallowed-calls/docs/allow-in-methods.md b/site/vendor/spaze/phpstan-disallowed-calls/docs/allow-in-methods.md new file mode 100644 index 000000000..9f47fcd4a --- /dev/null +++ b/site/vendor/spaze/phpstan-disallowed-calls/docs/allow-in-methods.md @@ -0,0 +1,27 @@ +## Allow in methods or functions + +To allow a previously disallowed method or function only when called from a different method or function in any file, use `allowInFunctions` (or `allowInMethods` alias): + +```neon +parameters: + disallowedMethodCalls: + - + method: 'PotentiallyDangerous\Logger::log()' + message: 'use our own logger instead' + allowInMethods: + - Foo\Bar\Baz::method() +``` + +And vice versa, if you need to disallow a method or a function call only when done from a particular method or function, use `allowExceptInFunctions` (with aliases `allowExceptInMethods`, `disallowInFunctions`, `disallowInMethods`): + +```neon +parameters: + disallowedMethodCalls: + - + method: 'Controller::redirect()' + message: 'redirect in startup() instead' + allowExceptInMethods: + - Controller\Foo\Bar\*::__construct() +``` + +The function or method names support [fnmatch()](https://www.php.net/function.fnmatch) patterns. diff --git a/site/vendor/spaze/phpstan-disallowed-calls/docs/allow-in-paths.md b/site/vendor/spaze/phpstan-disallowed-calls/docs/allow-in-paths.md new file mode 100644 index 000000000..9476ffebe --- /dev/null +++ b/site/vendor/spaze/phpstan-disallowed-calls/docs/allow-in-paths.md @@ -0,0 +1,46 @@ +## Allow in paths + +You can allow some previously disallowed calls and usages using the `allowIn` configuration key, for example: + +```neon +parameters: + disallowedMethodCalls: + - + method: 'PotentiallyDangerous\Logger::log()' + message: 'use our own logger instead' + allowIn: + - path/to/some/file-*.php + - tests/*.test.php +``` + +Paths in `allowIn` support [fnmatch()](https://www.php.net/function.fnmatch) patterns. + +Relative paths in `allowIn` are resolved based on the current working directory. When running PHPStan from a directory or subdirectory which is not your "root" directory, the paths will probably not work. +Use `filesRootDir` in that case to specify an absolute root directory for all `allowIn` paths. Absolute paths might change between machines (for example your local development machine and a continuous integration machine) but you +can use [`%rootDir%`](https://phpstan.org/config-reference#expanding-paths) to start with PHPStan's root directory (usually `/something/something/vendor/phpstan/phpstan`) and then `..` from there to your "root" directory. + +For example when PHPStan is installed in `/home/foo/vendor/phpstan/phpstan` and you're using a configuration like this: +```neon +parameters: + filesRootDir: %rootDir%/../../.. + disallowedMethodCalls: + - + method: 'PotentiallyDangerous\Logger::log()' + allowIn: + - path/to/some/file-*.php +``` +then `Logger::log()` will be allowed in `/home/foo/path/to/some/file-bar.php`. + +If you need to disallow a methods or a function call, a constant, a namespace, a class, a superglobal, or an attribute usage only in certain paths, as an inverse of `allowIn`, you can use `allowExceptIn` (or the `disallowIn` alias): +```neon +parameters: + filesRootDir: %rootDir%/../../.. + disallowedMethodCalls: + - + method: 'PotentiallyDangerous\Logger::log()' + allowExceptIn: + - path/to/some/dir/*.php +``` +This will disallow `PotentiallyDangerous\Logger::log()` calls in `%rootDir%/../../../path/to/some/dir/*.php`. + +Please note that before version 2.15, `filesRootDir` was called `allowInRootDir` which is still supported, but deprecated. diff --git a/site/vendor/spaze/phpstan-disallowed-calls/docs/allow-with-flags.md b/site/vendor/spaze/phpstan-disallowed-calls/docs/allow-with-flags.md new file mode 100644 index 000000000..0ced319ab --- /dev/null +++ b/site/vendor/spaze/phpstan-disallowed-calls/docs/allow-with-flags.md @@ -0,0 +1,28 @@ +## Allow with specified parameter flags only + +Some functions can be called with _flags_ or _bitmasks_, for example + +```php +json_encode($foo, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT); +``` +Let's say you want to disallow `json_encode()` except when called with `JSON_HEX_APOS` (integer `4`) flag. In the call above, the value of the second parameter (`JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT`) is `13` (`1 | 4 | 8`). +For the extension to be able to "find" the `4` in `13`, you need to use the `ParamFlags` family of config options: + +- `allowParamFlagsInAllowed` +- `allowParamFlagsAnywhere` +- `allowExceptParamFlagsInAllowed` or `disallowParamFlagsInAllowed` +- `allowExceptParamFlags` or `disallowParamFlags` + +They work like their non-flags `Param` counterparts except they're looking if specific bits in the mask parameter are set. + +The `json_encode()` example mentioned above would look like the following snippet: + +```neon +parameters: + disallowedFunctionCalls: + function: 'json_encode' + allowParamFlagsAnywhere: + - + position: 2 + value: ::JSON_HEX_APOS +``` diff --git a/site/vendor/spaze/phpstan-disallowed-calls/docs/allow-with-parameters.md b/site/vendor/spaze/phpstan-disallowed-calls/docs/allow-with-parameters.md new file mode 100644 index 000000000..c20ef829c --- /dev/null +++ b/site/vendor/spaze/phpstan-disallowed-calls/docs/allow-with-parameters.md @@ -0,0 +1,170 @@ +## Allow with specified parameters only + +You can also narrow down the allowed items when called with some parameters (applies only to disallowed method, static & function calls, for obvious reasons). _Please note that for now, only scalar values are supported in the configuration, not arrays._ + +For example, you want to disallow calling `print_r()` but want to allow `print_r(..., true)`. +This can be done with optional `allowParamsInAllowed` or `allowParamsAnywhere` configuration keys: + +```neon +parameters: + disallowedMethodCalls: + - + method: 'PotentiallyDangerous\Logger::log()' + message: 'use our own logger instead' + allowIn: + - path/to/some/file-*.php + - tests/*.test.php + allowParamsInAllowed: + - + position: 1 + name: 'message' + value: 'foo' + - + position: 2 + name: 'alert' + value: true + allowParamsAnywhere: + - + position: 2 + name: 'alert' + value: true +``` + +When using `allowParamsInAllowed`, calls will be allowed only when they are in one of the `allowIn` paths, and are called with all parameters listed in `allowParamsInAllowed`. +With `allowParamsAnywhere`, calls are allowed when called with all parameters listed no matter in which file. In the example above, the `log()` method will be disallowed unless called as: +- `log(..., true)` (or `log(..., alert: true)`) anywhere +- `log('foo', true)` (or `log(message: 'foo', alert: true)`) in `another/file.php` or `optional/path/to/log.tests.php` + +Use `allowParamsInAllowedAnyValue` and `allowParamsAnywhereAnyValue` if you don't care about the parameter's value but want to make sure the parameter is passed. +Following the previous example: + +```neon +parameters: + disallowedMethodCalls: + - + method: 'PotentiallyDangerous\Logger::log()' + message: 'use our own logger instead' + allowIn: + - path/to/some/file-*.php + - tests/*.test.php + allowParamsInAllowedAnyValue: + - + position: 2 + name: 'alert' + allowParamsAnywhereAnyValue: + - + position: 1 + name: 'message' +``` +means that you should use (`...` means any value): +- `log(...)` (or `log(message: ...)`) anywhere +- `log(..., ...)` (or `log(message: ..., alert: ...)`) in `another/file.php` or `optional/path/to/log.tests.php` + +Such configuration only makes sense when both the parameters of `log()` are optional. If they are required, omitting them would result in an error already detected by PHPStan itself. + +### Allow calls except when a param has a specified value + +Sometimes, it's handy to disallow a function or a method call only when a parameter matches a configured value but allow it otherwise. _Please note that currently only scalar values are supported, not arrays._ + +For example the `hash()` function, it's fine using it with algorithm families like SHA-2 & SHA-3 (not for passwords though) but you'd like PHPStan to report when it's used with MD5 like `hash('md5', ...)`. +You can use `allowExceptParams` (or `disallowParams`), `allowExceptCaseInsensitiveParams` (or `disallowCaseInsensitiveParams`), `allowExceptParamsInAllowed` (or `disallowParamsInAllowed`) config options to disallow only some calls: + +```neon +parameters: + disallowedFunctionCalls: + - + function: 'hash()' + allowExceptCaseInsensitiveParams: + - + position: 1 + name: 'algo' + value: 'md5' +``` + +This will disallow `hash()` call where the first parameter (or the named parameter `algo`) is `'md5'`. `allowExceptCaseInsensitiveParams` is used because the first parameter of `hash()` is case-insensitive (so you can also use `'MD5'`, or even `'Md5'` & `'mD5'` if you wish). +To disallow only exact matches, use `allowExceptParams`: + +```neon +parameters: + disallowedFunctionCalls: + - + function: 'foo()' + allowExceptParams: + - + position: 2 + value: 'baz' +``` +will disallow `foo('bar', 'baz')` but not `foo('bar', 'BAZ')`. + +It's also possible to disallow functions and methods previously allowed by path (using `allowIn`) or by function/method name (`allowInMethods`) when they're called with specified parameters, and allow when called with any other parameter. This is done using the `allowExceptParamsInAllowed` config option. + +Take this example configuration: + +```neon +parameters: + disallowedFunctionCalls: + - + function: 'waldo()' + allowIn: + - 'views/*' + allowExceptParamsInAllowed: + - + position: 2 + value: 'quux' +``` + +Calling `waldo()` is disallowed, and allowed back again only when the file is in the `views/` subdirectory **and** `waldo()` is called in the file with a 2nd parameter being the string `quux`. + +As already demonstrated above, named parameters are also supported: + +```neon +parameters: + disallowedFunctionCalls: + - + function: 'json_decode()' + message: 'set the $flags parameter to `JSON_THROW_ON_ERROR` to throw a JsonException' + allowParamsAnywhere: + - + position: 4 + name: 'flags' + value: ::JSON_THROW_ON_ERROR +``` + +This format allows to detect the value in both cases whether it's used with a traditional positional parameter (e.g. `json_decode($foo, null, 512, JSON_THROW_ON_ERROR)`) or a named parameter (e.g. `json_decode($foo, flags: JSON_THROW_ON_ERROR)`). +All keys are optional but if you don't specify `name`, the named parameter will not be found in a call like e.g. `json_decode($foo, null, 512, JSON_THROW_ON_ERROR)`. +And vice versa, if you don't specify the `position` key, only the named parameter will be found matching this definition, not the positional one. + +You can use shortcuts like +```neon +parameters: + disallowedFunctionCalls: + # ... + allowParamsAnywhere: + 2: true + foo: 'bar' + allowParamsAnywhereAnyValue: + - 2 + - foo +``` + +which internally expands to + +```neon +parameters: + disallowedFunctionCalls: + # ... + allowParamsAnywhere: + - + position: 2 + value: true + - + name: foo + value: 'bar' + allowParamsAnywhereAnyValue: + - + position: 2 + - + name: foo +``` + +But because the "positional _or_ named" limitation described above applies here as well, I generally don't recommend using these shortcuts and instead recommend specifying both `position` and `name` keys. diff --git a/site/vendor/spaze/phpstan-disallowed-calls/docs/configuration-bundled.md b/site/vendor/spaze/phpstan-disallowed-calls/docs/configuration-bundled.md new file mode 100644 index 000000000..4900f024f --- /dev/null +++ b/site/vendor/spaze/phpstan-disallowed-calls/docs/configuration-bundled.md @@ -0,0 +1,40 @@ +## Using bundled configuration files + +You can start by including `disallowed-dangerous-calls.neon` in your `phpstan.neon`: + +```neon +includes: + - vendor/spaze/phpstan-disallowed-calls/disallowed-dangerous-calls.neon +``` + +`disallowed-dangerous-calls.neon` can also serve as a template when you'd like to extend the configuration to disallow some other functions or methods, copy it and modify to your needs. +You can also allow a previously disallowed dangerous call in a defined path (see below) in your own config by using the same `call` or `method` key. + +If you want to disallow program execution functions (`exec()`, `shell_exec()` & friends) including the backtick operator (`` `...` ``, disallowed when `shell_exec()` is disallowed), include `disallowed-execution-calls.neon`: + +```neon +includes: + - vendor/spaze/phpstan-disallowed-calls/disallowed-execution-calls.neon +``` + +I'd recommend you include both: + +```neon +includes: + - vendor/spaze/phpstan-disallowed-calls/disallowed-dangerous-calls.neon + - vendor/spaze/phpstan-disallowed-calls/disallowed-execution-calls.neon +``` + +To disallow some insecure or potentially insecure calls (like `md5()`, `sha1()`, `mysql_query()`), include `disallowed-insecure-calls.neon`: + +```neon +includes: + - vendor/spaze/phpstan-disallowed-calls/disallowed-insecure-calls.neon +``` + +Some function calls are better when done for example with some parameters set to a defined value ("strict calls"). For example `in_array()` better also check for types to prevent some type juggling bugs. Include `disallowed-loose-calls.neon` to disallow calls without such parameters set ("loose calls"). + +```neon +includes: + - vendor/spaze/phpstan-disallowed-calls/disallowed-loose-calls.neon +``` diff --git a/site/vendor/spaze/phpstan-disallowed-calls/docs/custom-rules.md b/site/vendor/spaze/phpstan-disallowed-calls/docs/custom-rules.md new file mode 100644 index 000000000..0f5a812c6 --- /dev/null +++ b/site/vendor/spaze/phpstan-disallowed-calls/docs/custom-rules.md @@ -0,0 +1,163 @@ +## Custom rules + +There are several different types (and configuration keys) that can be disallowed: + +1. `disallowedMethodCalls` - for detecting `$object->method()` calls +2. `disallowedStaticCalls` - for static calls `Class::method()` +3. `disallowedFunctionCalls` - for functions like `function()` +4. `disallowedConstants` - for constants like `DATE_ISO8601` or `DateTime::ISO8601` (which needs to be split to `class: DateTime` & `constant: ISO8601` in the configuration, see notes below) +5. `disallowedNamespaces` or `disallowedClasses` - for usages of classes or classes from a namespace +6. `disallowedSuperglobals` - for usages of superglobal variables like `$GLOBALS` or `$_POST` +7. `disallowedAttributes` - for attributes like `#[Entity(class: Foo::class, something: true)]` + +Use them to add rules to your `phpstan.neon` config file. I like to use a separate file (`disallowed-calls.neon`) for these which I'll include later on in the main `phpstan.neon` config file. Here's an example, update to your needs: + +```neon +parameters: + disallowedMethodCalls: + - + method: 'PotentiallyDangerous\Logger::log()' # `function` is an alias of `method` + message: 'use our own logger instead' + errorTip: 'see https://our-docs.example/logging on how logging should be used' + - + method: 'Redis::connect()' + message: 'use our own Redis instead' + errorIdentifier: 'redis.connect' + + disallowedStaticCalls: + - + method: 'PotentiallyDangerous\Debugger::log()' + message: 'use our own logger instead' + + disallowedFunctionCalls: + - + function: 'var_dump()' # `method` is an alias of `function` + message: 'use logger instead' + - + function: 'print_r()' + message: 'use logger instead' + + disallowedConstants: + - + constant: 'DATE_ISO8601' + message: 'use DATE_ATOM instead' + - + class: 'DateTimeInterface' + constant: 'ISO8601' + message: 'use DateTimeInterface::ATOM instead' + + disallowedNamespaces: # `disallowedClasses` is an alias of `disallowedNamespaces` + - + class: 'Symfony\Component\HttpFoundation\RequestStack' # `class` is an alias of `namespace` + message: 'pass Request via controller instead' + allowIn: + - tests/* + - + namespace: 'Assert\*' # `namespace` is an alias of `class` + message: 'use Webmozart\Assert instead' + + disallowedSuperglobals: + - + superglobal: '$_GET' + message: 'use the Request methods instead' + + disallowedAttributes: + - + attribute: Entity + message: 'use our own custom Entity instead' +``` + +The `message` key is optional. Functions and methods can be specified with or without `()`. Omitting `()` is not recommended though to avoid confusing method calls with class constants. + +### Disallowing multiple items + +If you want to disallow multiple calls, constants, class constants (same-class only), classes, namespaces or variables that share the same `message` and other config keys, you can use a list or an array to specify them all: +```neon +parameters: + disallowedFunctionCalls: + - + function: + - 'var_dump()' + - 'print_r()' + message: 'use logger instead' + + disallowedConstants: + - + class: 'DateTimeInterface' + constant: ['ISO8601', 'RFC3339', 'W3C'] + message: 'use DateTimeInterface::ATOM instead' +``` + +### Error tips + +The optional `errorTip` key can be used to show an additional message prefixed with 💡 that's rendered below the error message in the analysis result. + +### Error identifiers + +The `errorIdentifier` key is optional. It can be used to provide a unique identifier to the PHPStan error. + +### Wildcards + +Use wildcard (`*`) to ignore all functions, methods, classes, namespaces starting with a prefix, for example: +```neon +parameters: + disallowedFunctionCalls: + - + function: 'pcntl_*()' +``` +The wildcard makes most sense when used as the rightmost character of the function or method name, optionally followed by `()`, but you can use it anywhere for example to disallow all functions that end with `y`: `function: '*y()'`. The matching is powered by [`fnmatch`](https://www.php.net/function.fnmatch) so you can use even multiple wildcards if you wish because w\*y n\*t. + +### Wildcards, but exclude this one function + +If there's this one function, method, namespace, attribute (or multiple of them) that you'd like to exclude from the set, you can do that with `exclude`: +```neon +parameters: + disallowedFunctionCalls: + - + function: 'pcntl_*()' + exclude: + - 'pcntl_foobar()' +``` +This config would disallow all `pcntl` functions except (an imaginary) `pcntl_foobar()`. +Please note `exclude` also accepts [`fnmatch`](https://www.php.net/function.fnmatch) patterns so please be careful to not create a contradicting config, and that it can accept both a string and an array of strings. + +### Wildcards, except when defined in this path + +Another option how to limit the set of functions or methods selected by the `function` or `method` directive is a file path in which these are defined which mostly makes sense when a [`fnmatch`](https://www.php.net/function.fnmatch) pattern is used in those directives. +Imagine a use case in which you want to disallow any function or method defined in any namespace, or none at all, by this legacy package: +```neon +parameters: + disallowedFunctionCalls: + - + function: '*' + definedIn: + - 'vendor/foo/bar' + disallowedMethodCalls: + - + method: '*' + definedIn: + - 'vendor/foo/bar' + filesRootDir: %rootDir%/../../.. +``` + +### Resolving relative paths + +Relative paths in `definedIn` are resolved based on the current working directory. When running PHPStan from a directory or subdirectory which is not your "root" directory, the paths will probably not work. +Use `filesRootDir` in that case to specify an absolute root directory, you can use [`%rootDir%`](https://phpstan.org/config-reference#expanding-paths) to start with PHPStan's root directory (usually `/something/something/vendor/phpstan/phpstan`) and then `..` from there to your "root" directory. +`filesRootDir` is also used to configure all `allowIn` directives, see below. The extension supports multiple directives you can use to re-allow a previously disallowed items. + +### Language constructs and constructors + +You can treat some language constructs as functions and disallow it in `disallowedFunctionCalls`. Currently detected language constructs are: +- `die()` +- `echo()` +- `empty()` +- `eval()` +- `exit()` +- `print()` + +To disallow naive object creation (`new ClassName()` or `new $classname`), disallow `NameSpace\ClassName::__construct` in `disallowedMethodCalls`. Works even when there's no constructor defined in that class. + +### Constants + +When [disallowing constants](disallowing-constants.md) please be aware of limitations and special requirements, see [docs](disallowing-constants.md). diff --git a/site/vendor/spaze/phpstan-disallowed-calls/docs/disallow-disabled-functions-classes.md b/site/vendor/spaze/phpstan-disallowed-calls/docs/disallow-disabled-functions-classes.md new file mode 100644 index 000000000..3180127f7 --- /dev/null +++ b/site/vendor/spaze/phpstan-disallowed-calls/docs/disallow-disabled-functions-classes.md @@ -0,0 +1,5 @@ +### Disallow disabled functions & classes + +Run `bin/generate-from-disabled.php` to generate a configuration based on the `disable_functions` & `disable_classes` PHP options. The configuration will be dumped to STDOUT in NEON format, you can save it to a file and include it in your PHPStan configuration. + +The file needs to be pre-generated because different environments often have different PHP configurations and if disabled functions & classes would be disallowed dynamically, the configuration would vary when executed for example in dev & CI environments. diff --git a/site/vendor/spaze/phpstan-disallowed-calls/docs/disallowing-constants.md b/site/vendor/spaze/phpstan-disallowed-calls/docs/disallowing-constants.md new file mode 100644 index 000000000..ddd81d162 --- /dev/null +++ b/site/vendor/spaze/phpstan-disallowed-calls/docs/disallowing-constants.md @@ -0,0 +1,17 @@ +## Disallowing constants + +Constants are a special breed. First, a constant needs to be disallowed on the declaring class. That means, that instead of disallowing `Date::ISO8601` or `DateTimeImmutable::ISO8601`, you need to disallow `DateTimeInterface::ISO8601`. +The reason for this is that one might expect that disallowing e.g. `Date::ISO8601` (disallowing on a "used on" class) would also disallow `DateTimeImmutable::ISO8601`, which unfortunately wouldn't be the case. + +Second, disallowing constants doesn't support wildcards. The only real-world use case I could think of is the `Date*::CONSTANT` case and that can be easily solved by disallowing `DateTimeInterface::CONSTANT` already. + +Last but not least, class constants have to be specified using two keys: `class` and `constant`: +```neon +parameters: + disallowedConstants: + - + class: 'DateTimeInterface' + constant: 'ISO8601' + message: 'use DateTimeInterface::ATOM instead' +``` +Using the fully-qualified name would result in the constant being replaced with its actual value. Otherwise, the extension would see `constant: "Y-m-d\TH:i:sO"` instead of `constant: DateTimeInterface::ISO8601` for example. diff --git a/site/vendor/spaze/phpstan-disallowed-calls/docs/phpstan-custom-ruleset.md b/site/vendor/spaze/phpstan-disallowed-calls/docs/phpstan-custom-ruleset.md new file mode 100644 index 000000000..5e14c9327 --- /dev/null +++ b/site/vendor/spaze/phpstan-disallowed-calls/docs/phpstan-custom-ruleset.md @@ -0,0 +1,12 @@ +## Detect disallowed calls without any other PHPStan rules + +If you want to use this PHPStan extension without running any other PHPStan rules, you can use `phpstan.neon` config file that looks like this (the `customRulesetUsed: true` and the missing `level` key are the important bits): + +```neon +parameters: + customRulesetUsed: true +includes: + - vendor/spaze/phpstan-disallowed-calls/extension.neon + - vendor/spaze/phpstan-disallowed-calls/disallowed-dangerous-calls.neon + - vendor/spaze/phpstan-disallowed-calls/disallowed-execution-calls.neon +``` diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/Allowed/AllowedConfig.php b/site/vendor/spaze/phpstan-disallowed-calls/src/Allowed/AllowedConfig.php index 44801f72e..0d40e4731 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/Allowed/AllowedConfig.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/Allowed/AllowedConfig.php @@ -8,16 +8,16 @@ class AllowedConfig { - /** @var string[] */ + /** @var list */ private $allowIn; - /** @var string[] */ + /** @var list */ private $allowExceptIn; - /** @var string[] */ + /** @var list */ private $allowInCalls; - /** @var string[] */ + /** @var list */ private $allowExceptInCalls; /** @var array */ @@ -34,10 +34,10 @@ class AllowedConfig /** - * @param string[] $allowIn - * @param string[] $allowExceptIn - * @param string[] $allowInCalls - * @param string[] $allowExceptInCalls + * @param list $allowIn + * @param list $allowExceptIn + * @param list $allowInCalls + * @param list $allowExceptInCalls * @param array $allowParamsInAllowed * @param array $allowParamsAnywhere * @param array $allowExceptParamsInAllowed @@ -65,7 +65,7 @@ public function __construct( /** - * @return string[] + * @return list */ public function getAllowIn(): array { @@ -74,7 +74,7 @@ public function getAllowIn(): array /** - * @return string[] + * @return list */ public function getAllowExceptIn(): array { @@ -83,7 +83,7 @@ public function getAllowExceptIn(): array /** - * @return string[] + * @return list */ public function getAllowInCalls(): array { @@ -92,7 +92,7 @@ public function getAllowInCalls(): array /** - * @return string[] + * @return list */ public function getAllowExceptInCalls(): array { diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/EchoCalls.php b/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/EchoCalls.php index 5641a723f..a94caa0b7 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/EchoCalls.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/EchoCalls.php @@ -25,7 +25,7 @@ class EchoCalls implements Rule /** @var DisallowedCallsRuleErrors */ private $disallowedCallsRuleErrors; - /** @var DisallowedCall[] */ + /** @var list */ private $disallowedCalls; @@ -53,7 +53,7 @@ public function getNodeType(): string /** * @param Echo_ $node * @param Scope $scope - * @return RuleError[] + * @return list * @throws ShouldNotHappenException */ public function processNode(Node $node, Scope $scope): array diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/EmptyCalls.php b/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/EmptyCalls.php index 899c903cb..af44beaac 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/EmptyCalls.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/EmptyCalls.php @@ -25,7 +25,7 @@ class EmptyCalls implements Rule /** @var DisallowedCallsRuleErrors */ private $disallowedCallsRuleErrors; - /** @var DisallowedCall[] */ + /** @var list */ private $disallowedCalls; @@ -53,7 +53,7 @@ public function getNodeType(): string /** * @param Empty_ $node * @param Scope $scope - * @return RuleError[] + * @return list * @throws ShouldNotHappenException */ public function processNode(Node $node, Scope $scope): array diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/EvalCalls.php b/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/EvalCalls.php index c78a954e1..d630d5f3c 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/EvalCalls.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/EvalCalls.php @@ -25,7 +25,7 @@ class EvalCalls implements Rule /** @var DisallowedCallsRuleErrors */ private $disallowedCallsRuleErrors; - /** @var DisallowedCall[] */ + /** @var list */ private $disallowedCalls; @@ -53,7 +53,7 @@ public function getNodeType(): string /** * @param Eval_ $node * @param Scope $scope - * @return RuleError[] + * @return list * @throws ShouldNotHappenException */ public function processNode(Node $node, Scope $scope): array diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/ExitDieCalls.php b/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/ExitDieCalls.php index 73dbed13b..2afcfa9d4 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/ExitDieCalls.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/ExitDieCalls.php @@ -25,7 +25,7 @@ class ExitDieCalls implements Rule /** @var DisallowedCallsRuleErrors */ private $disallowedCallsRuleErrors; - /** @var DisallowedCall[] */ + /** @var list */ private $disallowedCalls; @@ -53,7 +53,7 @@ public function getNodeType(): string /** * @param Exit_ $node * @param Scope $scope - * @return RuleError[] + * @return list * @throws ShouldNotHappenException */ public function processNode(Node $node, Scope $scope): array diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/FunctionCalls.php b/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/FunctionCalls.php index 81c9a5b2b..b239047d3 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/FunctionCalls.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/FunctionCalls.php @@ -27,7 +27,7 @@ class FunctionCalls implements Rule /** @var DisallowedCallsRuleErrors */ private $disallowedCallsRuleErrors; - /** @var DisallowedCall[] */ + /** @var list */ private $disallowedCalls; /** @var ReflectionProvider */ @@ -60,7 +60,7 @@ public function getNodeType(): string /** * @param FuncCall $node * @param Scope $scope - * @return RuleError[] + * @return list * @throws ShouldNotHappenException */ public function processNode(Node $node, Scope $scope): array diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/MethodCalls.php b/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/MethodCalls.php index b6a9eba01..6c8be923c 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/MethodCalls.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/MethodCalls.php @@ -27,7 +27,7 @@ class MethodCalls implements Rule /** @var DisallowedMethodRuleErrors */ private $disallowedMethodRuleErrors; - /** @var DisallowedCall[] */ + /** @var list */ private $disallowedCalls; @@ -55,7 +55,7 @@ public function getNodeType(): string /** * @param MethodCall $node * @param Scope $scope - * @return RuleError[] + * @return list * @throws ShouldNotHappenException */ public function processNode(Node $node, Scope $scope): array diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/NewCalls.php b/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/NewCalls.php index c105a5e6d..5b75a0f82 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/NewCalls.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/NewCalls.php @@ -28,7 +28,7 @@ class NewCalls implements Rule /** @var DisallowedCallsRuleErrors */ private $disallowedCallsRuleErrors; - /** @var DisallowedCall[] */ + /** @var list */ private $disallowedCalls; @@ -56,7 +56,7 @@ public function getNodeType(): string /** * @param New_ $node * @param Scope $scope - * @return RuleError[] + * @return list * @throws ShouldNotHappenException */ public function processNode(Node $node, Scope $scope): array diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/PrintCalls.php b/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/PrintCalls.php index 65a85ccba..affdb0ef9 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/PrintCalls.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/PrintCalls.php @@ -25,7 +25,7 @@ class PrintCalls implements Rule /** @var DisallowedCallsRuleErrors */ private $disallowedCallsRuleErrors; - /** @var DisallowedCall[] */ + /** @var list */ private $disallowedCalls; @@ -53,7 +53,7 @@ public function getNodeType(): string /** * @param Print_ $node * @param Scope $scope - * @return RuleError[] + * @return list * @throws ShouldNotHappenException */ public function processNode(Node $node, Scope $scope): array diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/ShellExecCalls.php b/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/ShellExecCalls.php index 0f0195832..dd83f5362 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/ShellExecCalls.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/ShellExecCalls.php @@ -29,7 +29,7 @@ class ShellExecCalls implements Rule /** @var DisallowedCallsRuleErrors */ private $disallowedCallsRuleErrors; - /** @var DisallowedCall[] */ + /** @var list */ private $disallowedCalls; @@ -57,7 +57,7 @@ public function getNodeType(): string /** * @param ShellExec $node * @param Scope $scope - * @return RuleError[] + * @return list * @throws ShouldNotHappenException */ public function processNode(Node $node, Scope $scope): array diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/StaticCalls.php b/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/StaticCalls.php index 30b879bf1..4f46764d7 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/StaticCalls.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/Calls/StaticCalls.php @@ -27,7 +27,7 @@ class StaticCalls implements Rule /** @var DisallowedMethodRuleErrors */ private $disallowedMethodRuleErrors; - /** @var DisallowedCall[] */ + /** @var list */ private $disallowedCalls; @@ -55,7 +55,7 @@ public function getNodeType(): string /** * @param StaticCall $node * @param Scope $scope - * @return RuleError[] + * @return list * @throws ShouldNotHappenException */ public function processNode(Node $node, Scope $scope): array diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/Disallowed.php b/site/vendor/spaze/phpstan-disallowed-calls/src/Disallowed.php index 3e449f8dd..405cf18b1 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/Disallowed.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/Disallowed.php @@ -7,25 +7,25 @@ interface Disallowed { /** - * @return string[] + * @return list */ public function getAllowIn(): array; /** - * @return string[] + * @return list */ public function getAllowExceptIn(): array; /** - * @return string[] + * @return list */ public function getAllowInCalls(): array; /** - * @return string[] + * @return list */ public function getAllowExceptInCalls(): array; diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedAttributeFactory.php b/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedAttributeFactory.php index c6f922c42..1b36edc8f 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedAttributeFactory.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedAttributeFactory.php @@ -27,7 +27,7 @@ public function __construct(Allowed $allowed, Normalizer $normalizer) /** * @param array $config * @phpstan-param DisallowedAttributesConfig $config - * @return DisallowedAttribute[] + * @return list * @throws UnsupportedParamTypeInConfigException */ public function createFromConfig(array $config): array @@ -37,11 +37,11 @@ public function createFromConfig(array $config): array $attributes = $disallowed['attribute']; $excludes = []; foreach ((array)($disallowed['exclude'] ?? []) as $exclude) { - $excludes[] = $this->normalizer->normalizeNamespace($exclude); + $excludes[] = $this->normalizer->normalizeAttribute($exclude); } foreach ((array)$attributes as $attribute) { $disallowedAttribute = new DisallowedAttribute( - $this->normalizer->normalizeNamespace($attribute), + $this->normalizer->normalizeAttribute($attribute), $excludes, $disallowed['message'] ?? null, $this->allowed->getConfig($disallowed), diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedCallFactory.php b/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedCallFactory.php index ec2da5bf2..907f564ca 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedCallFactory.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedCallFactory.php @@ -34,7 +34,7 @@ public function __construct(Formatter $formatter, Normalizer $normalizer, Allowe * @param array $config * @phpstan-param ForbiddenCallsConfig $config * @noinspection PhpUndefinedClassInspection ForbiddenCallsConfig is a type alias defined in PHPStan config - * @return DisallowedCall[] + * @return list * @throws ShouldNotHappenException */ public function createFromConfig(array $config): array diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedConstant.php b/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedConstant.php index e3b517dfa..d26a9a6d5 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedConstant.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedConstant.php @@ -14,10 +14,10 @@ class DisallowedConstant implements Disallowed /** @var string|null */ private $message; - /** @var string[] */ + /** @var list */ private $allowIn; - /** @var string[] */ + /** @var list */ private $allowExceptIn; /** @var string|null */ @@ -30,8 +30,8 @@ class DisallowedConstant implements Disallowed /** * @param string $constant * @param string|null $message - * @param string[] $allowIn - * @param string[] $allowExceptIn + * @param list $allowIn + * @param list $allowExceptIn * @param string|null $errorIdentifier * @param string|null $errorTip */ diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedConstantFactory.php b/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedConstantFactory.php index e6c72de24..df731537e 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedConstantFactory.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedConstantFactory.php @@ -20,8 +20,8 @@ public function __construct(Normalizer $normalizer) /** - * @param array $config - * @return DisallowedConstant[] + * @param array, allowExceptIn?:list, disallowIn?:list, errorIdentifier?:string, errorTip?:string}> $config + * @return list * @throws ShouldNotHappenException */ public function createFromConfig(array $config): array diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedNamespace.php b/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedNamespace.php index 209e86347..71d52b13c 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedNamespace.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedNamespace.php @@ -17,10 +17,10 @@ class DisallowedNamespace implements Disallowed /** @var string|null */ private $message; - /** @var string[] */ + /** @var list */ private $allowIn; - /** @var string[] */ + /** @var list */ private $allowExceptIn; /** @var string|null */ @@ -34,8 +34,8 @@ class DisallowedNamespace implements Disallowed * @param string $namespace * @param list $excludes * @param string|null $message - * @param string[] $allowIn - * @param string[] $allowExceptIn + * @param list $allowIn + * @param list $allowExceptIn * @param string|null $errorIdentifier * @param string|null $errorTip */ diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedNamespaceFactory.php b/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedNamespaceFactory.php index 8d017cd79..4a92081ce 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedNamespaceFactory.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedNamespaceFactory.php @@ -20,8 +20,8 @@ public function __construct(Normalizer $normalizer) /** - * @param array, message?:string, allowIn?:string[], allowExceptIn?:string[], disallowIn?:string[], errorIdentifier?:string, errorTip?:string}> $config - * @return DisallowedNamespace[] + * @param array, message?:string, allowIn?:list, allowExceptIn?:list, disallowIn?:list, errorIdentifier?:string, errorTip?:string}> $config + * @return list */ public function createFromConfig(array $config): array { diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedSuperglobalFactory.php b/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedSuperglobalFactory.php index eaa4d005f..10a5f3bef 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedSuperglobalFactory.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedSuperglobalFactory.php @@ -25,8 +25,8 @@ class DisallowedSuperglobalFactory implements DisallowedVariableFactory /** - * @param array $config - * @return DisallowedVariable[] + * @param array, allowExceptIn?:list, disallowIn?:list, errorIdentifier?:string, errorTip?:string}> $config + * @return list * @throws ShouldNotHappenException */ public function getDisallowedVariables(array $config): array diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedVariable.php b/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedVariable.php index 8d0df8e0f..9a86ae4ab 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedVariable.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedVariable.php @@ -14,10 +14,10 @@ class DisallowedVariable implements Disallowed /** @var string|null */ private $message; - /** @var string[] */ + /** @var list */ private $allowIn; - /** @var string[] */ + /** @var list */ private $allowExceptIn; /** @var string|null */ @@ -30,8 +30,8 @@ class DisallowedVariable implements Disallowed /** * @param string $variable * @param string|null $message - * @param string[] $allowIn - * @param string[] $allowExceptIn + * @param list $allowIn + * @param list $allowExceptIn * @param string|null $errorIdentifier * @param string|null $errorTip */ diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedVariableFactory.php b/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedVariableFactory.php index e35c5d918..5a67ef3d6 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedVariableFactory.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/DisallowedVariableFactory.php @@ -7,8 +7,8 @@ interface DisallowedVariableFactory { /** - * @param array $config - * @return DisallowedVariable[] + * @param array, allowExceptIn?:list, disallowIn?:list, errorIdentifier?:string}> $config + * @return list */ public function getDisallowedVariables(array $config): array; diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/Normalizer/Normalizer.php b/site/vendor/spaze/phpstan-disallowed-calls/src/Normalizer/Normalizer.php index a8ed67f7f..0f9ac7bc4 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/Normalizer/Normalizer.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/Normalizer/Normalizer.php @@ -8,7 +8,7 @@ class Normalizer public function normalizeCall(string $call): string { - $call = substr($call, -2) === '()' ? substr($call, 0, -2) : $call; + $call = $this->removeParentheses($call); return $this->normalizeNamespace($call); } @@ -18,4 +18,19 @@ public function normalizeNamespace(string $namespace): string return ltrim($namespace, '\\'); } + + public function normalizeAttribute(string $attribute): string + { + $attribute = ltrim($attribute, '#['); + $attribute = rtrim($attribute, ']'); + $attribute = $this->removeParentheses($attribute); + return $this->normalizeNamespace($attribute); + } + + + private function removeParentheses(string $element): string + { + return substr($element, -2) === '()' ? substr($element, 0, -2) : $element; + } + } diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedAttributeRuleErrors.php b/site/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedAttributeRuleErrors.php index a619b33eb..9021c51ef 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedAttributeRuleErrors.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedAttributeRuleErrors.php @@ -31,8 +31,8 @@ public function __construct(Allowed $allowed, Identifier $identifier) /** * @param Attribute $attribute * @param Scope $scope - * @param DisallowedAttribute[] $disallowedAttributes - * @return RuleError[] + * @param list $disallowedAttributes + * @return list */ public function get(Attribute $attribute, Scope $scope, array $disallowedAttributes): array { diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedCallsRuleErrors.php b/site/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedCallsRuleErrors.php index 5407430c1..4057cdd82 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedCallsRuleErrors.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedCallsRuleErrors.php @@ -40,9 +40,9 @@ public function __construct(Allowed $allowed, Identifier $identifier, FilePath $ * @param string $name * @param string|null $displayName * @param string|null $definedIn - * @param DisallowedCall[] $disallowedCalls + * @param list $disallowedCalls * @param string|null $message - * @return RuleError[] + * @return list * @throws ShouldNotHappenException */ public function get(?CallLike $node, Scope $scope, string $name, ?string $displayName, ?string $definedIn, array $disallowedCalls, ?string $message = null): array diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedConstantRuleErrors.php b/site/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedConstantRuleErrors.php index a2c50d4b4..e4c8b9059 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedConstantRuleErrors.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedConstantRuleErrors.php @@ -28,8 +28,8 @@ public function __construct(AllowedPath $allowedPath) * @param string $constant * @param Scope $scope * @param string|null $displayName - * @param DisallowedConstant[] $disallowedConstants - * @return RuleError[] + * @param list $disallowedConstants + * @return list * @throws ShouldNotHappenException */ public function get(string $constant, Scope $scope, ?string $displayName, array $disallowedConstants): array diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedMethodRuleErrors.php b/site/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedMethodRuleErrors.php index 5d169ef05..f7ee76324 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedMethodRuleErrors.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedMethodRuleErrors.php @@ -10,6 +10,8 @@ use PhpParser\Node\Identifier; use PhpParser\Node\Name; use PHPStan\Analyser\Scope; +use PHPStan\Reflection\ClassReflection; +use PHPStan\Reflection\MethodReflection; use PHPStan\Rules\RuleError; use PHPStan\ShouldNotHappenException; use Spaze\PHPStan\Rules\Disallowed\DisallowedCall; @@ -44,8 +46,8 @@ public function __construct( * @param Name|Expr $class * @param MethodCall|StaticCall $node * @param Scope $scope - * @param DisallowedCall[] $disallowedCalls - * @return RuleError[] + * @param list $disallowedCalls + * @return list * @throws ShouldNotHappenException */ public function get($class, CallLike $node, Scope $scope, array $disallowedCalls): array @@ -65,21 +67,39 @@ public function get($class, CallLike $node, Scope $scope, array $disallowedCalls $calledAs = $this->formatter->getFullyQualified($this->formatter->formatIdentifier($classNames), $method); } - foreach ($declaringClass->getTraits() as $trait) { - if ($trait->hasMethod($method->getName())) { - $declaredAs = $this->formatter->getFullyQualified($trait->getDisplayName(), $method); - $message = $this->disallowedCallsRuleErrors->get($node, $scope, $declaredAs, $calledAs, $trait->getFileName(), $disallowedCalls); - if ($message) { - return $message; - } - } + $ruleErrors = $this->getRuleErrors(array_values($declaringClass->getTraits()), $method, $node, $scope, $calledAs, $disallowedCalls); + if ($ruleErrors) { + return $ruleErrors; + } + $ruleErrors = $this->getRuleErrors(array_values($declaringClass->getInterfaces()), $method, $node, $scope, $calledAs, $disallowedCalls); + if ($ruleErrors) { + return $ruleErrors; } } else { return []; } + return $this->getRuleErrors([$declaringClass], $method, $node, $scope, $calledAs, $disallowedCalls); + } - $declaredAs = $this->formatter->getFullyQualified($declaringClass->getDisplayName(false), $method); - return $this->disallowedCallsRuleErrors->get($node, $scope, $declaredAs, $calledAs, $declaringClass->getFileName(), $disallowedCalls); + + /** + * @param list $classes + * @param list $disallowedCalls + * @return list + * @throws ShouldNotHappenException + */ + private function getRuleErrors(array $classes, MethodReflection $method, CallLike $node, Scope $scope, ?string $calledAs, array $disallowedCalls): array + { + foreach ($classes as $class) { + if ($class->hasMethod($method->getName())) { + $declaredAs = $this->formatter->getFullyQualified($class->getDisplayName(false), $method); + $ruleErrors = $this->disallowedCallsRuleErrors->get($node, $scope, $declaredAs, $calledAs, $class->getFileName(), $disallowedCalls); + if ($ruleErrors) { + return $ruleErrors; + } + } + } + return []; } } diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedNamespaceRuleErrors.php b/site/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedNamespaceRuleErrors.php index 14dfe1d43..3b5a1dcb3 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedNamespaceRuleErrors.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedNamespaceRuleErrors.php @@ -31,8 +31,8 @@ public function __construct(AllowedPath $allowedPath, Identifier $identifier) * @param string $namespace * @param string $description * @param Scope $scope - * @param DisallowedNamespace[] $disallowedNamespaces - * @return RuleError[] + * @param list $disallowedNamespaces + * @return list */ public function getDisallowedMessage(string $namespace, string $description, Scope $scope, array $disallowedNamespaces): array { diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedVariableRuleErrors.php b/site/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedVariableRuleErrors.php index 1e02d78d1..5a900efe3 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedVariableRuleErrors.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedVariableRuleErrors.php @@ -26,8 +26,8 @@ public function __construct(AllowedPath $allowedPath) /** * @param string $variable * @param Scope $scope - * @param DisallowedVariable[] $disallowedVariables - * @return RuleError[] + * @param list $disallowedVariables + * @return list * @throws ShouldNotHappenException */ public function get(string $variable, Scope $scope, array $disallowedVariables): array diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/Usages/AttributeUsages.php b/site/vendor/spaze/phpstan-disallowed-calls/src/Usages/AttributeUsages.php index 6bad3828f..4515c60a7 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/Usages/AttributeUsages.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/Usages/AttributeUsages.php @@ -23,7 +23,7 @@ class AttributeUsages implements Rule /** @var DisallowedAttributeRuleErrors */ private $disallowedAttributeRuleErrors; - /** @var DisallowedAttribute[] */ + /** @var list */ private $disallowedAttributes; /** @var list */ @@ -53,7 +53,7 @@ public function getNodeType(): string /** - * @param AttributeGroup[] $attributeGroups + * @param list $attributeGroups */ private function addAttrs(array $attributeGroups): void { @@ -69,9 +69,9 @@ public function processNode(Node $node, Scope $scope): array { $this->attributes = []; if ($node instanceof ClassLike) { - $this->addAttrs($node->attrGroups); + $this->addAttrs(array_values($node->attrGroups)); } elseif ($node instanceof FunctionLike) { - $this->addAttrs($node->getAttrGroups()); + $this->addAttrs(array_values($node->getAttrGroups())); } else { return []; } diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/Usages/ClassConstantUsages.php b/site/vendor/spaze/phpstan-disallowed-calls/src/Usages/ClassConstantUsages.php index efd45fee8..fb0ba0b9e 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/Usages/ClassConstantUsages.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/Usages/ClassConstantUsages.php @@ -37,7 +37,7 @@ class ClassConstantUsages implements Rule /** @var Formatter */ private $formatter; - /** @var DisallowedConstant[] */ + /** @var list */ private $disallowedConstants; @@ -46,7 +46,7 @@ class ClassConstantUsages implements Rule * @param DisallowedConstantFactory $disallowedConstantFactory * @param TypeResolver $typeResolver * @param Formatter $formatter - * @param array $disallowedConstants + * @param array}> $disallowedConstants * @throws ShouldNotHappenException */ public function __construct( @@ -72,7 +72,7 @@ public function getNodeType(): string /** * @param Node $node * @param Scope $scope - * @return RuleError[] + * @return list * @throws ShouldNotHappenException */ public function processNode(Node $node, Scope $scope): array diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/Usages/ConstantUsages.php b/site/vendor/spaze/phpstan-disallowed-calls/src/Usages/ConstantUsages.php index 91919b013..69b4519fd 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/Usages/ConstantUsages.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/Usages/ConstantUsages.php @@ -25,14 +25,14 @@ class ConstantUsages implements Rule /** @var DisallowedConstantRuleErrors */ private $disallowedConstantRuleError; - /** @var DisallowedConstant[] */ + /** @var list */ private $disallowedConstants; /** * @param DisallowedConstantRuleErrors $disallowedConstantRuleErrors * @param DisallowedConstantFactory $disallowedConstantFactory - * @param array $disallowedConstants + * @param array}> $disallowedConstants * @throws ShouldNotHappenException */ public function __construct(DisallowedConstantRuleErrors $disallowedConstantRuleErrors, DisallowedConstantFactory $disallowedConstantFactory, array $disallowedConstants) @@ -51,7 +51,7 @@ public function getNodeType(): string /** * @param ConstFetch $node * @param Scope $scope - * @return RuleError[] + * @return list * @throws ShouldNotHappenException */ public function processNode(Node $node, Scope $scope): array diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/Usages/NamespaceUsages.php b/site/vendor/spaze/phpstan-disallowed-calls/src/Usages/NamespaceUsages.php index 0b1e4996c..815f03c72 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/Usages/NamespaceUsages.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/Usages/NamespaceUsages.php @@ -32,7 +32,7 @@ class NamespaceUsages implements Rule /** @var DisallowedNamespaceRuleErrors */ private $disallowedNamespaceRuleErrors; - /** @var DisallowedNamespace[] */ + /** @var list */ private $disallowedNamespace; /** @var Normalizer */ @@ -43,7 +43,7 @@ class NamespaceUsages implements Rule * @param DisallowedNamespaceRuleErrors $disallowedNamespaceRuleErrors * @param DisallowedNamespaceFactory $disallowNamespaceFactory * @param Normalizer $normalizer - * @param array $forbiddenNamespaces + * @param array}> $forbiddenNamespaces */ public function __construct( DisallowedNamespaceRuleErrors $disallowedNamespaceRuleErrors, @@ -66,7 +66,7 @@ public function getNodeType(): string /** * @param Node $node * @param Scope $scope - * @return RuleError[] + * @return list */ public function processNode(Node $node, Scope $scope): array { diff --git a/site/vendor/spaze/phpstan-disallowed-calls/src/Usages/VariableUsages.php b/site/vendor/spaze/phpstan-disallowed-calls/src/Usages/VariableUsages.php index 1e3ddf69d..4c06502b3 100644 --- a/site/vendor/spaze/phpstan-disallowed-calls/src/Usages/VariableUsages.php +++ b/site/vendor/spaze/phpstan-disallowed-calls/src/Usages/VariableUsages.php @@ -24,13 +24,13 @@ class VariableUsages implements Rule /** @var DisallowedVariableRuleErrors */ private $disallowedVariableRuleErrors; - /** @var DisallowedVariable[] */ + /** @var list */ private $disallowedVariables; /** * @param DisallowedVariableRuleErrors $disallowedVariableRuleErrors - * @param DisallowedVariable[] $disallowedVariables + * @param list $disallowedVariables */ public function __construct(DisallowedVariableRuleErrors $disallowedVariableRuleErrors, array $disallowedVariables) { @@ -48,7 +48,7 @@ public function getNodeType(): string /** * @param Node $node * @param Scope $scope - * @return RuleError[] + * @return list * @throws ShouldNotHappenException */ public function processNode(Node $node, Scope $scope): array