diff --git a/app/composer.lock b/app/composer.lock index 9e8f25004..279b2ed2d 100644 --- a/app/composer.lock +++ b/app/composer.lock @@ -3448,16 +3448,16 @@ }, { "name": "phpstan/phpstan", - "version": "2.1.0", + "version": "2.1.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "2392d360fdf54ea253aa6c68cad1d4ba2e54e927" + "reference": "cd6e973e04b4c2b94c86e8612b5a65f0da0e08e7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/2392d360fdf54ea253aa6c68cad1d4ba2e54e927", - "reference": "2392d360fdf54ea253aa6c68cad1d4ba2e54e927", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/cd6e973e04b4c2b94c86e8612b5a65f0da0e08e7", + "reference": "cd6e973e04b4c2b94c86e8612b5a65f0da0e08e7", "shasum": "" }, "require": { @@ -3502,7 +3502,7 @@ "type": "github" } ], - "time": "2024-12-31T07:30:03+00:00" + "time": "2025-01-05T16:43:48+00:00" }, { "name": "phpstan/phpstan-deprecation-rules", @@ -3653,12 +3653,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "43628df4c324d77a9e4e6e5b7d0479586b5ee2b6" + "reference": "a717959d5f0bf7c9a881efdbb7ec0da4454a14ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/43628df4c324d77a9e4e6e5b7d0479586b5ee2b6", - "reference": "43628df4c324d77a9e4e6e5b7d0479586b5ee2b6", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/a717959d5f0bf7c9a881efdbb7ec0da4454a14ac", + "reference": "a717959d5f0bf7c9a881efdbb7ec0da4454a14ac", "shasum": "" }, "conflict": { @@ -3902,6 +3902,7 @@ "grumpydictator/firefly-iii": "<6.1.17", "gugoan/economizzer": "<=0.9.0.0-beta1", "guzzlehttp/guzzle": "<6.5.8|>=7,<7.4.5", + "guzzlehttp/oauth-subscriber": "<0.8.1", "guzzlehttp/psr7": "<1.9.1|>=2,<2.4.5", "haffner/jh_captcha": "<=2.1.3|>=3,<=3.0.2", "harvesthq/chosen": "<1.8.7", @@ -4062,6 +4063,8 @@ "neos/media-browser": "<7.3.19|>=8,<8.0.16|>=8.1,<8.1.11|>=8.2,<8.2.11|>=8.3,<8.3.9", "neos/neos": ">=1.1,<1.1.3|>=1.2,<1.2.13|>=2,<2.0.4|>=2.3,<3.0.20|>=3.1,<3.1.18|>=3.2,<3.2.14|>=3.3,<5.3.10|>=7,<7.0.9|>=7.1,<7.1.7|>=7.2,<7.2.6|>=7.3,<7.3.4|>=8,<8.0.2", "neos/swiftmailer": "<5.4.5", + "nesbot/carbon": "<2.72.6|>=3,<3.8.4", + "netcarver/textile": "<=4.1.2", "netgen/tagsbundle": ">=3.4,<3.4.11|>=4,<4.0.15", "nette/application": ">=2,<2.0.19|>=2.1,<2.1.13|>=2.2,<2.2.10|>=2.3,<2.3.14|>=2.4,<2.4.16|>=3,<3.0.6", "nette/nette": ">=2,<2.0.19|>=2.1,<2.1.13", @@ -4129,7 +4132,7 @@ "phpmyfaq/phpmyfaq": "<3.2.5|==3.2.5|>=3.2.10,<=4.0.1", "phpoffice/common": "<0.2.9", "phpoffice/phpexcel": "<1.8.1", - "phpoffice/phpspreadsheet": "<1.29.4|>=2,<2.1.3|>=2.2,<2.3.2|>=3.3,<3.4", + "phpoffice/phpspreadsheet": "<=1.29.6|>=2,<=2.1.5|>=2.2,<=2.3.4|>=3,<3.7", "phpseclib/phpseclib": "<2.0.47|>=3,<3.0.36", "phpservermon/phpservermon": "<3.6", "phpsysinfo/phpsysinfo": "<3.4.3", @@ -4255,6 +4258,7 @@ "squizlabs/php_codesniffer": ">=1,<2.8.1|>=3,<3.0.1", "ssddanbrown/bookstack": "<24.05.1", "starcitizentools/citizen-skin": ">=2.6.3,<2.31", + "starcitizentools/tabber-neue": ">=1.9.1,<2.7.2", "statamic/cms": "<=5.16", "stormpath/sdk": "<9.9.99", "studio-42/elfinder": "<=2.1.64", @@ -4410,7 +4414,7 @@ "xpressengine/xpressengine": "<3.0.15", "yab/quarx": "<2.4.5", "yeswiki/yeswiki": "<=4.4.4", - "yetiforce/yetiforce-crm": "<=6.4", + "yetiforce/yetiforce-crm": "<6.5", "yidashi/yii2cmf": "<=2", "yii2mod/yii2-cms": "<1.9.2", "yiisoft/yii": "<1.1.29", @@ -4500,7 +4504,7 @@ "type": "tidelift" } ], - "time": "2025-01-02T23:04:41+00:00" + "time": "2025-01-08T21:04:52+00:00" }, { "name": "shipmonk/composer-dependency-analyser", @@ -4740,16 +4744,16 @@ }, { "name": "spaze/phpstan-disallowed-calls", - "version": "v4.0.1", + "version": "v4.1.1", "source": { "type": "git", "url": "https://github.com/spaze/phpstan-disallowed-calls.git", - "reference": "0f030fd3fb770ee7c262445c8ad3c0b470a32ac5" + "reference": "3ea4de4944c58f3acfb1de6e991c9907076f7eec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spaze/phpstan-disallowed-calls/zipball/0f030fd3fb770ee7c262445c8ad3c0b470a32ac5", - "reference": "0f030fd3fb770ee7c262445c8ad3c0b470a32ac5", + "url": "https://api.github.com/repos/spaze/phpstan-disallowed-calls/zipball/3ea4de4944c58f3acfb1de6e991c9907076f7eec", + "reference": "3ea4de4944c58f3acfb1de6e991c9907076f7eec", "shasum": "" }, "require": { @@ -4795,7 +4799,7 @@ ], "support": { "issues": "https://github.com/spaze/phpstan-disallowed-calls/issues", - "source": "https://github.com/spaze/phpstan-disallowed-calls/tree/v4.0.1" + "source": "https://github.com/spaze/phpstan-disallowed-calls/tree/v4.1.1" }, "funding": [ { @@ -4803,7 +4807,7 @@ "type": "github" } ], - "time": "2024-11-13T17:17:13+00:00" + "time": "2025-01-09T21:09:31+00:00" }, { "name": "spaze/phpstan-disallowed-calls-nette", diff --git a/app/disallowed-calls.neon b/app/disallowed-calls.neon index 8a69ada80..6cad4c33a 100644 --- a/app/disallowed-calls.neon +++ b/app/disallowed-calls.neon @@ -17,6 +17,8 @@ parameters: message: 'use methods from MichalSpacekCz\Http\Cookies' - function: 'preg_*()' + exclude: + - 'preg_quote()' message: 'use the Preg class from composer/pcre' disallowedStaticCalls: - diff --git a/app/phpstan-vendor.neon b/app/phpstan-vendor.neon index db23c532d..b8362c0ba 100644 --- a/app/phpstan-vendor.neon +++ b/app/phpstan-vendor.neon @@ -210,6 +210,11 @@ parameters: allowIn: - vendor/nette/*.php disallowedStaticCalls: + - + method: 'Tracy\Debugger::dump()' + message: 'use logger instead' + allowIn: + - vendor/tracy/tracy/src/Tracy/functions.php - method: 'Tracy\Debugger::barDump()' message: 'use logger instead, debug bar is not visible in production' diff --git a/app/vendor/composer/installed.json b/app/vendor/composer/installed.json index 2cad89d24..4738c5061 100644 --- a/app/vendor/composer/installed.json +++ b/app/vendor/composer/installed.json @@ -2089,17 +2089,17 @@ }, { "name": "phpstan/phpstan", - "version": "2.1.0", - "version_normalized": "2.1.0.0", + "version": "2.1.1", + "version_normalized": "2.1.1.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "2392d360fdf54ea253aa6c68cad1d4ba2e54e927" + "reference": "cd6e973e04b4c2b94c86e8612b5a65f0da0e08e7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/2392d360fdf54ea253aa6c68cad1d4ba2e54e927", - "reference": "2392d360fdf54ea253aa6c68cad1d4ba2e54e927", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/cd6e973e04b4c2b94c86e8612b5a65f0da0e08e7", + "reference": "cd6e973e04b4c2b94c86e8612b5a65f0da0e08e7", "shasum": "" }, "require": { @@ -2108,7 +2108,7 @@ "conflict": { "phpstan/phpstan-shim": "*" }, - "time": "2024-12-31T07:30:03+00:00", + "time": "2025-01-05T16:43:48+00:00", "bin": [ "phpstan", "phpstan.phar" @@ -2468,12 +2468,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "43628df4c324d77a9e4e6e5b7d0479586b5ee2b6" + "reference": "a717959d5f0bf7c9a881efdbb7ec0da4454a14ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/43628df4c324d77a9e4e6e5b7d0479586b5ee2b6", - "reference": "43628df4c324d77a9e4e6e5b7d0479586b5ee2b6", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/a717959d5f0bf7c9a881efdbb7ec0da4454a14ac", + "reference": "a717959d5f0bf7c9a881efdbb7ec0da4454a14ac", "shasum": "" }, "conflict": { @@ -2717,6 +2717,7 @@ "grumpydictator/firefly-iii": "<6.1.17", "gugoan/economizzer": "<=0.9.0.0-beta1", "guzzlehttp/guzzle": "<6.5.8|>=7,<7.4.5", + "guzzlehttp/oauth-subscriber": "<0.8.1", "guzzlehttp/psr7": "<1.9.1|>=2,<2.4.5", "haffner/jh_captcha": "<=2.1.3|>=3,<=3.0.2", "harvesthq/chosen": "<1.8.7", @@ -2877,6 +2878,8 @@ "neos/media-browser": "<7.3.19|>=8,<8.0.16|>=8.1,<8.1.11|>=8.2,<8.2.11|>=8.3,<8.3.9", "neos/neos": ">=1.1,<1.1.3|>=1.2,<1.2.13|>=2,<2.0.4|>=2.3,<3.0.20|>=3.1,<3.1.18|>=3.2,<3.2.14|>=3.3,<5.3.10|>=7,<7.0.9|>=7.1,<7.1.7|>=7.2,<7.2.6|>=7.3,<7.3.4|>=8,<8.0.2", "neos/swiftmailer": "<5.4.5", + "nesbot/carbon": "<2.72.6|>=3,<3.8.4", + "netcarver/textile": "<=4.1.2", "netgen/tagsbundle": ">=3.4,<3.4.11|>=4,<4.0.15", "nette/application": ">=2,<2.0.19|>=2.1,<2.1.13|>=2.2,<2.2.10|>=2.3,<2.3.14|>=2.4,<2.4.16|>=3,<3.0.6", "nette/nette": ">=2,<2.0.19|>=2.1,<2.1.13", @@ -2944,7 +2947,7 @@ "phpmyfaq/phpmyfaq": "<3.2.5|==3.2.5|>=3.2.10,<=4.0.1", "phpoffice/common": "<0.2.9", "phpoffice/phpexcel": "<1.8.1", - "phpoffice/phpspreadsheet": "<1.29.4|>=2,<2.1.3|>=2.2,<2.3.2|>=3.3,<3.4", + "phpoffice/phpspreadsheet": "<=1.29.6|>=2,<=2.1.5|>=2.2,<=2.3.4|>=3,<3.7", "phpseclib/phpseclib": "<2.0.47|>=3,<3.0.36", "phpservermon/phpservermon": "<3.6", "phpsysinfo/phpsysinfo": "<3.4.3", @@ -3070,6 +3073,7 @@ "squizlabs/php_codesniffer": ">=1,<2.8.1|>=3,<3.0.1", "ssddanbrown/bookstack": "<24.05.1", "starcitizentools/citizen-skin": ">=2.6.3,<2.31", + "starcitizentools/tabber-neue": ">=1.9.1,<2.7.2", "statamic/cms": "<=5.16", "stormpath/sdk": "<9.9.99", "studio-42/elfinder": "<=2.1.64", @@ -3225,7 +3229,7 @@ "xpressengine/xpressengine": "<3.0.15", "yab/quarx": "<2.4.5", "yeswiki/yeswiki": "<=4.4.4", - "yetiforce/yetiforce-crm": "<=6.4", + "yetiforce/yetiforce-crm": "<6.5", "yidashi/yii2cmf": "<=2", "yii2mod/yii2-cms": "<1.9.2", "yiisoft/yii": "<1.1.29", @@ -3279,7 +3283,7 @@ "zfr/zfr-oauth2-server-module": "<0.1.2", "zoujingli/thinkadmin": "<=6.1.53" }, - "time": "2025-01-02T23:04:41+00:00", + "time": "2025-01-08T21:04:52+00:00", "default-branch": true, "type": "metapackage", "notification-url": "https://packagist.org/downloads/", @@ -3907,17 +3911,17 @@ }, { "name": "spaze/phpstan-disallowed-calls", - "version": "v4.0.1", - "version_normalized": "4.0.1.0", + "version": "v4.1.1", + "version_normalized": "4.1.1.0", "source": { "type": "git", "url": "https://github.com/spaze/phpstan-disallowed-calls.git", - "reference": "0f030fd3fb770ee7c262445c8ad3c0b470a32ac5" + "reference": "3ea4de4944c58f3acfb1de6e991c9907076f7eec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spaze/phpstan-disallowed-calls/zipball/0f030fd3fb770ee7c262445c8ad3c0b470a32ac5", - "reference": "0f030fd3fb770ee7c262445c8ad3c0b470a32ac5", + "url": "https://api.github.com/repos/spaze/phpstan-disallowed-calls/zipball/3ea4de4944c58f3acfb1de6e991c9907076f7eec", + "reference": "3ea4de4944c58f3acfb1de6e991c9907076f7eec", "shasum": "" }, "require": { @@ -3933,7 +3937,7 @@ "phpunit/phpunit": "^8.5.14 || ^10.1 || ^11.0", "spaze/coding-standard": "^1.7" }, - "time": "2024-11-13T17:17:13+00:00", + "time": "2025-01-09T21:09:31+00:00", "type": "phpstan-extension", "extra": { "phpstan": { @@ -3965,7 +3969,7 @@ ], "support": { "issues": "https://github.com/spaze/phpstan-disallowed-calls/issues", - "source": "https://github.com/spaze/phpstan-disallowed-calls/tree/v4.0.1" + "source": "https://github.com/spaze/phpstan-disallowed-calls/tree/v4.1.1" }, "funding": [ { diff --git a/app/vendor/composer/installed.php b/app/vendor/composer/installed.php index 60035a9b2..fd3842219 100644 --- a/app/vendor/composer/installed.php +++ b/app/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'spaze/michalspacek.cz', 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '53ccdd4e3bfed40f4fe0a708fec39406a888c21a', + 'reference' => 'a80820cc549bcb1f1dc305f0dc92f9bb559f1846', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -326,9 +326,9 @@ 'dev_requirement' => true, ), 'phpstan/phpstan' => array( - 'pretty_version' => '2.1.0', - 'version' => '2.1.0.0', - 'reference' => '2392d360fdf54ea253aa6c68cad1d4ba2e54e927', + 'pretty_version' => '2.1.1', + 'version' => '2.1.1.0', + 'reference' => 'cd6e973e04b4c2b94c86e8612b5a65f0da0e08e7', 'type' => 'library', 'install_path' => __DIR__ . '/../phpstan/phpstan', 'aliases' => array(), @@ -403,7 +403,7 @@ 'roave/security-advisories' => array( 'pretty_version' => 'dev-latest', 'version' => 'dev-latest', - 'reference' => '43628df4c324d77a9e4e6e5b7d0479586b5ee2b6', + 'reference' => 'a717959d5f0bf7c9a881efdbb7ec0da4454a14ac', 'type' => 'metapackage', 'install_path' => null, 'aliases' => array( @@ -468,7 +468,7 @@ 'spaze/michalspacek.cz' => array( 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '53ccdd4e3bfed40f4fe0a708fec39406a888c21a', + 'reference' => 'a80820cc549bcb1f1dc305f0dc92f9bb559f1846', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -511,9 +511,9 @@ 'dev_requirement' => false, ), 'spaze/phpstan-disallowed-calls' => array( - 'pretty_version' => 'v4.0.1', - 'version' => '4.0.1.0', - 'reference' => '0f030fd3fb770ee7c262445c8ad3c0b470a32ac5', + 'pretty_version' => 'v4.1.1', + 'version' => '4.1.1.0', + 'reference' => '3ea4de4944c58f3acfb1de6e991c9907076f7eec', 'type' => 'phpstan-extension', 'install_path' => __DIR__ . '/../spaze/phpstan-disallowed-calls', 'aliases' => array(), diff --git a/app/vendor/phpstan/phpstan/README.md b/app/vendor/phpstan/phpstan/README.md index 481e37a1e..abae67ecf 100644 --- a/app/vendor/phpstan/phpstan/README.md +++ b/app/vendor/phpstan/phpstan/README.md @@ -64,6 +64,8 @@ can be checked before you run the actual line.     Route4Me: Route Optimizer and Route Planner Software
+Belsimpel +    TicketSwap diff --git a/app/vendor/phpstan/phpstan/phpstan.phar b/app/vendor/phpstan/phpstan/phpstan.phar index 2bf867359..293c4441c 100755 Binary files a/app/vendor/phpstan/phpstan/phpstan.phar and b/app/vendor/phpstan/phpstan/phpstan.phar differ diff --git a/app/vendor/phpstan/phpstan/phpstan.phar.asc b/app/vendor/phpstan/phpstan/phpstan.phar.asc index 0339007fd..c645cd748 100644 --- a/app/vendor/phpstan/phpstan/phpstan.phar.asc +++ b/app/vendor/phpstan/phpstan/phpstan.phar.asc @@ -1,16 +1,16 @@ -----BEGIN PGP SIGNATURE----- -iQIzBAABCgAdFiEEynwsejDI6OEnSoR2UcZzBf/C5cAFAmdznWEACgkQUcZzBf/C -5cAdoA//dmRyUyjyVwbfP9j9d2u554JWJ3aOlJb5r3XrXITlVg46QcBXz4GsrhP1 -/CrGUwz5LOMzDxfvDs/N223I4d0SiAlbB+StQjpXXTX182cZ3p+3QdkZQLoI7QQc -SxpFV9VEXlrKtVH9iDjTgXR/WHseVv5X16BJ67jJhTM6Vzqh5UnFit+Oop+W1Dbw -NHfngQuZVGI2Felr3cL6FPsfT5cXwY+igb8VgRAA1v+u9+O0OdRA205T4idEvANv -BP3nawt8awx9e3RdijVUS+6DuvK8Fsa7BW68nklmbIFHXhXmMOUZvHgCSThN+b39 -8Oaj1tuj8IM8Ur46yIkmF0yc1+lizKxVa4h3AcUphnXxIsM9WxCPtC1RcVT/XHGA -8gW1QeVS/HkcAu1hrKnbgyj7kJ1T6oEDyV1n6ty9+M2mh54G74epTuTK+CVI8QA0 -3GbmQgJRd1PTC/EPfZNmPywRDD7yoMSKvHmOUP5NMHBsYhVPJILdIJAGEI/0G9as -xxGDXk5zJNgn8OtR5GwLJw9GBBVMhuwYomvN/B/7rEz0qGT9/tsZlVosc9tod5cS -4AwLDEQlNZatYmADPNfJc4wd+NuKV32s+srJedP8sXyPE8yCBX0PXv1FO1s9DUzK -Qy1aLGWdhhT2AADQoyt7AUoEej9537wVB9fVmdCv1PzxrrMMzZQ= -=PoVL +iQIzBAABCgAdFiEEynwsejDI6OEnSoR2UcZzBf/C5cAFAmd6tp8ACgkQUcZzBf/C +5cCYSg//eO+kZhjgn2+iXQssspB2QIY36NGKKuxHFi5eQWNhRKFKM6jIIdqmcU2g +aawEQbg6OQMGK1e07LqUOTKPw0fjz2f9YcfxwkC+Q6rDix/8ir5LhO8XfDXdWtvW +424B+6B1OOXeuGPp7HqQqS7EVE6WJXgpvJ/a7xIDAe+FIvCE52qXhjywpaXMGftA +HpnAUIENH9o4888JDeLSn/OfDUip10DN0A5aNZRDZzyooikkWdODStVnPg6WHSxc +Z5at+8voemu7X+LgQ9U9jo04tNlH7SW0I6+j+DUsLl6CTh+cpx/OT1hv/QPDVb0E +Q2l5RQb6CIFMcs74wM5qN+I3atcGmKrfiUdqR8C1sTGgFiI8zVWPOvFkOyWtXsaM +sOXL0jnlhUPkclu4ue1lL8mrmbBabeHa+3PMcq/2eMj8VdzeSxg0xPRttai/byey +Ax3I181cXr4Ijrve07rVHsar8AxW4r1LxAYOWTO8krwBg2A33Usgxkx7tMpbUcvY +Y50z+islNF4K3YTicWE6gQm1RXEfrdc79tla0+6IAmMdGC2SvW6nbBOM0P7tji4l +FuAEI7Yn8KFFkuU2zAaBvRSFAFR3acQs9TQMPr0F9ZXVfgBM7Tm73SEQvWNd5SWl +rUi2CcHF6Fcxud80PY3PdN6UXSkW5ZES2sl6Pk3ZgT1cWD//gS4= +=GIIK -----END PGP SIGNATURE----- diff --git a/app/vendor/spaze/phpstan-disallowed-calls/composer.json b/app/vendor/spaze/phpstan-disallowed-calls/composer.json index e52f87b25..8ae1241a4 100644 --- a/app/vendor/spaze/phpstan-disallowed-calls/composer.json +++ b/app/vendor/spaze/phpstan-disallowed-calls/composer.json @@ -41,9 +41,9 @@ }, "scripts": { "lint": "vendor/bin/parallel-lint --colors src/ tests/", - "lint-7.x": "vendor/bin/parallel-lint --colors src/ tests/ --exclude tests/src/TypesEverywhere.php --exclude tests/src/AttributesEverywhere.php --exclude tests/src/disallowed/functionCallsNamedParams.php --exclude tests/src/disallowed-allow/functionCallsNamedParams.php --exclude tests/src/disallowed/attributeUsages.php --exclude tests/src/disallowed-allow/attributeUsages.php --exclude tests/src/disallowed/constantDynamicUsages.php --exclude tests/src/disallowed-allow/constantDynamicUsages.php --exclude tests/src/Enums.php --exclude tests/src/disallowed/controlStructures.php --exclude tests/src/disallowed-allow/controlStructures.php", - "lint-8.0": "vendor/bin/parallel-lint --colors src/ tests/ --exclude tests/src/TypesEverywhere.php --exclude tests/src/AttributesEverywhere.php --exclude tests/src/disallowed/constantDynamicUsages.php --exclude tests/src/disallowed-allow/constantDynamicUsages.php --exclude tests/src/Enums.php", - "lint-8.1": "vendor/bin/parallel-lint --colors src/ tests/ --exclude tests/src/AttributesEverywhere.php --exclude tests/src/disallowed/constantDynamicUsages.php --exclude tests/src/disallowed-allow/constantDynamicUsages.php", + "lint-7.x": "vendor/bin/parallel-lint --colors src/ tests/ --exclude tests/src/TypesEverywhere.php --exclude tests/src/AttributesEverywhere.php --exclude tests/src/disallowed/functionCallsNamedParams.php --exclude tests/src/disallowed-allow/functionCallsNamedParams.php --exclude tests/src/disallowed/attributeUsages.php --exclude tests/src/disallowed-allow/attributeUsages.php --exclude tests/src/disallowed/constantDynamicUsages.php --exclude tests/src/disallowed-allow/constantDynamicUsages.php --exclude tests/src/Enums.php --exclude tests/src/disallowed/controlStructures.php --exclude tests/src/disallowed-allow/controlStructures.php --exclude tests/src/disallowed/firstClassCallable.php --exclude tests/src/disallowed-allow/firstClassCallable.php --exclude tests/src/disallowed/callableParameters.php --exclude tests/src/disallowed-allow/callableParameters.php", + "lint-8.0": "vendor/bin/parallel-lint --colors src/ tests/ --exclude tests/src/TypesEverywhere.php --exclude tests/src/AttributesEverywhere.php --exclude tests/src/disallowed/constantDynamicUsages.php --exclude tests/src/disallowed-allow/constantDynamicUsages.php --exclude tests/src/Enums.php --exclude tests/src/disallowed/firstClassCallable.php --exclude tests/src/disallowed-allow/firstClassCallable.php", + "lint-8.1": "vendor/bin/parallel-lint --colors src/ tests/ --exclude tests/src/AttributesEverywhere.php --exclude tests/src/disallowed/constantDynamicUsages.php --exclude tests/src/disallowed-allow/constantDynamicUsages.php --exclude tests/src/disallowed/firstClassCallable.php --exclude tests/src/disallowed-allow/firstClassCallable.php", "lint-8.2": "vendor/bin/parallel-lint --colors src/ tests/ --exclude tests/src/disallowed/constantDynamicUsages.php --exclude tests/src/disallowed-allow/constantDynamicUsages.php", "lint-neon": "vendor/bin/neon-lint .", "phpcs": "vendor/bin/phpcs src/ tests/", diff --git a/app/vendor/spaze/phpstan-disallowed-calls/extension.neon b/app/vendor/spaze/phpstan-disallowed-calls/extension.neon index c7950d3b8..880a9d24e 100644 --- a/app/vendor/spaze/phpstan-disallowed-calls/extension.neon +++ b/app/vendor/spaze/phpstan-disallowed-calls/extension.neon @@ -252,8 +252,10 @@ services: - Spaze\PHPStan\Rules\Disallowed\Identifier\Identifier - Spaze\PHPStan\Rules\Disallowed\Normalizer\Normalizer - Spaze\PHPStan\Rules\Disallowed\RuleErrors\DisallowedAttributeRuleErrors + - Spaze\PHPStan\Rules\Disallowed\RuleErrors\DisallowedCallableParameterRuleErrors(forbiddenFunctionCalls: %disallowedFunctionCalls%, forbiddenMethodCalls: %disallowedMethodCalls%, forbiddenStaticCalls: %disallowedStaticCalls%) - Spaze\PHPStan\Rules\Disallowed\RuleErrors\DisallowedConstantRuleErrors - Spaze\PHPStan\Rules\Disallowed\RuleErrors\DisallowedControlStructureRuleErrors + - Spaze\PHPStan\Rules\Disallowed\RuleErrors\DisallowedFunctionRuleErrors - Spaze\PHPStan\Rules\Disallowed\RuleErrors\DisallowedMethodRuleErrors - Spaze\PHPStan\Rules\Disallowed\RuleErrors\DisallowedNamespaceRuleErrors - Spaze\PHPStan\Rules\Disallowed\RuleErrors\DisallowedCallsRuleErrors diff --git a/app/vendor/spaze/phpstan-disallowed-calls/src/Allowed/Allowed.php b/app/vendor/spaze/phpstan-disallowed-calls/src/Allowed/Allowed.php index 44ead1bbd..256049838 100644 --- a/app/vendor/spaze/phpstan-disallowed-calls/src/Allowed/Allowed.php +++ b/app/vendor/spaze/phpstan-disallowed-calls/src/Allowed/Allowed.php @@ -181,7 +181,7 @@ private function getArgType(array $args, Scope $scope, Param $param): ?Type if (!isset($found)) { $found = $args[$param->getPosition() - 1] ?? null; } - return isset($found) ? $scope->getType($found->value) : null; + return isset($found, $found->value) ? $scope->getType($found->value) : null; } diff --git a/app/vendor/spaze/phpstan-disallowed-calls/src/Calls/FunctionCalls.php b/app/vendor/spaze/phpstan-disallowed-calls/src/Calls/FunctionCalls.php index 05e4dbe90..a0da19d77 100644 --- a/app/vendor/spaze/phpstan-disallowed-calls/src/Calls/FunctionCalls.php +++ b/app/vendor/spaze/phpstan-disallowed-calls/src/Calls/FunctionCalls.php @@ -5,16 +5,14 @@ use PhpParser\Node; use PhpParser\Node\Expr\FuncCall; -use PhpParser\Node\Name; use PHPStan\Analyser\Scope; -use PHPStan\Reflection\ReflectionProvider; use PHPStan\Rules\IdentifierRuleError; use PHPStan\Rules\Rule; use PHPStan\ShouldNotHappenException; use Spaze\PHPStan\Rules\Disallowed\DisallowedCall; use Spaze\PHPStan\Rules\Disallowed\DisallowedCallFactory; -use Spaze\PHPStan\Rules\Disallowed\RuleErrors\DisallowedCallsRuleErrors; -use Spaze\PHPStan\Rules\Disallowed\RuleErrors\ErrorIdentifiers; +use Spaze\PHPStan\Rules\Disallowed\RuleErrors\DisallowedCallableParameterRuleErrors; +use Spaze\PHPStan\Rules\Disallowed\RuleErrors\DisallowedFunctionRuleErrors; /** * Reports on dynamically calling a disallowed function. @@ -25,28 +23,32 @@ class FunctionCalls implements Rule { - private DisallowedCallsRuleErrors $disallowedCallsRuleErrors; + private DisallowedFunctionRuleErrors $disallowedFunctionRuleErrors; + + private DisallowedCallableParameterRuleErrors $disallowedCallableParameterRuleErrors; /** @var list */ private array $disallowedCalls; - private ReflectionProvider $reflectionProvider; - /** - * @param DisallowedCallsRuleErrors $disallowedCallsRuleErrors + * @param DisallowedFunctionRuleErrors $disallowedFunctionRuleErrors + * @param DisallowedCallableParameterRuleErrors $disallowedCallableParameterRuleErrors * @param DisallowedCallFactory $disallowedCallFactory - * @param ReflectionProvider $reflectionProvider * @param array $forbiddenCalls * @phpstan-param ForbiddenCallsConfig $forbiddenCalls * @noinspection PhpUndefinedClassInspection ForbiddenCallsConfig is a type alias defined in PHPStan config * @throws ShouldNotHappenException */ - public function __construct(DisallowedCallsRuleErrors $disallowedCallsRuleErrors, DisallowedCallFactory $disallowedCallFactory, ReflectionProvider $reflectionProvider, array $forbiddenCalls) - { - $this->disallowedCallsRuleErrors = $disallowedCallsRuleErrors; + public function __construct( + DisallowedFunctionRuleErrors $disallowedFunctionRuleErrors, + DisallowedCallableParameterRuleErrors $disallowedCallableParameterRuleErrors, + DisallowedCallFactory $disallowedCallFactory, + array $forbiddenCalls + ) { + $this->disallowedFunctionRuleErrors = $disallowedFunctionRuleErrors; + $this->disallowedCallableParameterRuleErrors = $disallowedCallableParameterRuleErrors; $this->disallowedCalls = $disallowedCallFactory->createFromConfig($forbiddenCalls); - $this->reflectionProvider = $reflectionProvider; } @@ -64,30 +66,9 @@ public function getNodeType(): string */ public function processNode(Node $node, Scope $scope): array { - if (!($node->name instanceof Name)) { - return []; - } - $namespacedName = $node->name->getAttribute('namespacedName'); - if ($namespacedName !== null && !($namespacedName instanceof Name)) { - throw new ShouldNotHappenException(); - } - $displayName = $node->name->getAttribute('originalName'); - if ($displayName !== null && !($displayName instanceof Name)) { - throw new ShouldNotHappenException(); - } - foreach ([$namespacedName, $node->name] as $name) { - if ($name && $this->reflectionProvider->hasFunction($name, $scope)) { - $functionReflection = $this->reflectionProvider->getFunction($name, $scope); - $definedIn = $functionReflection->isBuiltin() ? null : $functionReflection->getFileName(); - } else { - $definedIn = null; - } - $message = $this->disallowedCallsRuleErrors->get($node, $scope, (string)$name, (string)($displayName ?? $node->name), $definedIn, $this->disallowedCalls, ErrorIdentifiers::DISALLOWED_FUNCTION); - if ($message) { - return $message; - } - } - return []; + $errors = $this->disallowedFunctionRuleErrors->get($node, $scope, $this->disallowedCalls); + $paramErrors = $this->disallowedCallableParameterRuleErrors->getForFunction($node, $scope); + return $errors || $paramErrors ? array_merge($errors, $paramErrors) : []; } } diff --git a/app/vendor/spaze/phpstan-disallowed-calls/src/Calls/FunctionFirstClassCallables.php b/app/vendor/spaze/phpstan-disallowed-calls/src/Calls/FunctionFirstClassCallables.php new file mode 100644 index 000000000..73a73f96e --- /dev/null +++ b/app/vendor/spaze/phpstan-disallowed-calls/src/Calls/FunctionFirstClassCallables.php @@ -0,0 +1,67 @@ + + */ +class FunctionFirstClassCallables implements Rule +{ + + private DisallowedFunctionRuleErrors $disallowedFunctionRuleErrors; + + /** @var list */ + private array $disallowedCalls; + + + /** + * @param DisallowedFunctionRuleErrors $disallowedFunctionRuleErrors + * @param DisallowedCallFactory $disallowedCallFactory + * @param array $forbiddenCalls + * @phpstan-param ForbiddenCallsConfig $forbiddenCalls + * @noinspection PhpUndefinedClassInspection ForbiddenCallsConfig is a type alias defined in PHPStan config + * @throws ShouldNotHappenException + */ + public function __construct( + DisallowedFunctionRuleErrors $disallowedFunctionRuleErrors, + DisallowedCallFactory $disallowedCallFactory, + array $forbiddenCalls + ) { + $this->disallowedFunctionRuleErrors = $disallowedFunctionRuleErrors; + $this->disallowedCalls = $disallowedCallFactory->createFromConfig($forbiddenCalls); + } + + + public function getNodeType(): string + { + return FunctionCallableNode::class; + } + + + /** + * @param FunctionCallableNode $node + * @param Scope $scope + * @return list + * @throws ShouldNotHappenException + */ + public function processNode(Node $node, Scope $scope): array + { + $originalNode = $node->getOriginalNode(); + return $this->disallowedFunctionRuleErrors->get($originalNode, $scope, $this->disallowedCalls); + } + +} diff --git a/app/vendor/spaze/phpstan-disallowed-calls/src/Calls/MethodCalls.php b/app/vendor/spaze/phpstan-disallowed-calls/src/Calls/MethodCalls.php index 38f9fc5fe..aa4d7d6d5 100644 --- a/app/vendor/spaze/phpstan-disallowed-calls/src/Calls/MethodCalls.php +++ b/app/vendor/spaze/phpstan-disallowed-calls/src/Calls/MethodCalls.php @@ -11,6 +11,7 @@ use PHPStan\ShouldNotHappenException; use Spaze\PHPStan\Rules\Disallowed\DisallowedCall; use Spaze\PHPStan\Rules\Disallowed\DisallowedCallFactory; +use Spaze\PHPStan\Rules\Disallowed\RuleErrors\DisallowedCallableParameterRuleErrors; use Spaze\PHPStan\Rules\Disallowed\RuleErrors\DisallowedMethodRuleErrors; /** @@ -26,22 +27,30 @@ class MethodCalls implements Rule private DisallowedMethodRuleErrors $disallowedMethodRuleErrors; + private DisallowedCallableParameterRuleErrors $disallowedCallableParameterRuleErrors; + /** @var list */ private array $disallowedCalls; /** * @param DisallowedMethodRuleErrors $disallowedMethodRuleErrors + * @param DisallowedCallableParameterRuleErrors $disallowedCallableParameterRuleErrors * @param DisallowedCallFactory $disallowedCallFactory * @param array $forbiddenCalls * @phpstan-param ForbiddenCallsConfig $forbiddenCalls * @noinspection PhpUndefinedClassInspection ForbiddenCallsConfig is a type alias defined in PHPStan config * @throws ShouldNotHappenException */ - public function __construct(DisallowedMethodRuleErrors $disallowedMethodRuleErrors, DisallowedCallFactory $disallowedCallFactory, array $forbiddenCalls) - { + public function __construct( + DisallowedMethodRuleErrors $disallowedMethodRuleErrors, + DisallowedCallableParameterRuleErrors $disallowedCallableParameterRuleErrors, + DisallowedCallFactory $disallowedCallFactory, + array $forbiddenCalls + ) { $this->disallowedMethodRuleErrors = $disallowedMethodRuleErrors; $this->disallowedCalls = $disallowedCallFactory->createFromConfig($forbiddenCalls); + $this->disallowedCallableParameterRuleErrors = $disallowedCallableParameterRuleErrors; } @@ -59,7 +68,9 @@ public function getNodeType(): string */ public function processNode(Node $node, Scope $scope): array { - return $this->disallowedMethodRuleErrors->get($node->var, $node, $scope, $this->disallowedCalls); + $errors = $this->disallowedMethodRuleErrors->get($node->var, $node, $scope, $this->disallowedCalls); + $paramErrors = $this->disallowedCallableParameterRuleErrors->getForMethod($node->var, $node, $scope); + return $errors || $paramErrors ? array_merge($errors, $paramErrors) : []; } } diff --git a/app/vendor/spaze/phpstan-disallowed-calls/src/Calls/MethodFirstClassCallables.php b/app/vendor/spaze/phpstan-disallowed-calls/src/Calls/MethodFirstClassCallables.php new file mode 100644 index 000000000..276dea4ef --- /dev/null +++ b/app/vendor/spaze/phpstan-disallowed-calls/src/Calls/MethodFirstClassCallables.php @@ -0,0 +1,66 @@ +StaticFirstClassCallables + * + * @package Spaze\PHPStan\Rules\Disallowed + * @implements Rule + */ +class MethodFirstClassCallables implements Rule +{ + + private DisallowedMethodRuleErrors $disallowedMethodRuleErrors; + + /** @var list */ + private array $disallowedCalls; + + + /** + * @param DisallowedMethodRuleErrors $disallowedMethodRuleErrors + * @param DisallowedCallFactory $disallowedCallFactory + * @param array $forbiddenCalls + * @phpstan-param ForbiddenCallsConfig $forbiddenCalls + * @noinspection PhpUndefinedClassInspection ForbiddenCallsConfig is a type alias defined in PHPStan config + * @throws ShouldNotHappenException + */ + public function __construct(DisallowedMethodRuleErrors $disallowedMethodRuleErrors, DisallowedCallFactory $disallowedCallFactory, array $forbiddenCalls) + { + $this->disallowedMethodRuleErrors = $disallowedMethodRuleErrors; + $this->disallowedCalls = $disallowedCallFactory->createFromConfig($forbiddenCalls); + } + + + public function getNodeType(): string + { + return MethodCallableNode::class; + } + + + /** + * @param MethodCallableNode $node + * @param Scope $scope + * @return list + * @throws ShouldNotHappenException + */ + public function processNode(Node $node, Scope $scope): array + { + $originalNode = $node->getOriginalNode(); + return $this->disallowedMethodRuleErrors->get($originalNode->var, $originalNode, $scope, $this->disallowedCalls); + } + +} diff --git a/app/vendor/spaze/phpstan-disallowed-calls/src/Calls/NewCalls.php b/app/vendor/spaze/phpstan-disallowed-calls/src/Calls/NewCalls.php index 4c1951d39..d03638951 100644 --- a/app/vendor/spaze/phpstan-disallowed-calls/src/Calls/NewCalls.php +++ b/app/vendor/spaze/phpstan-disallowed-calls/src/Calls/NewCalls.php @@ -13,6 +13,7 @@ use PHPStan\ShouldNotHappenException; use Spaze\PHPStan\Rules\Disallowed\DisallowedCall; use Spaze\PHPStan\Rules\Disallowed\DisallowedCallFactory; +use Spaze\PHPStan\Rules\Disallowed\RuleErrors\DisallowedCallableParameterRuleErrors; use Spaze\PHPStan\Rules\Disallowed\RuleErrors\DisallowedCallsRuleErrors; use Spaze\PHPStan\Rules\Disallowed\RuleErrors\ErrorIdentifiers; @@ -24,25 +25,33 @@ */ class NewCalls implements Rule { - private const CONSTRUCT = '::__construct'; + public const CONSTRUCT = '__construct'; private DisallowedCallsRuleErrors $disallowedCallsRuleErrors; + private DisallowedCallableParameterRuleErrors $disallowedCallableParameterRuleErrors; + /** @var list */ private array $disallowedCalls; /** * @param DisallowedCallsRuleErrors $disallowedCallsRuleErrors + * @param DisallowedCallableParameterRuleErrors $disallowedCallableParameterRuleErrors * @param DisallowedCallFactory $disallowedCallFactory * @param array $forbiddenCalls * @phpstan-param ForbiddenCallsConfig $forbiddenCalls * @noinspection PhpUndefinedClassInspection ForbiddenCallsConfig is a type alias defined in PHPStan config * @throws ShouldNotHappenException */ - public function __construct(DisallowedCallsRuleErrors $disallowedCallsRuleErrors, DisallowedCallFactory $disallowedCallFactory, array $forbiddenCalls) - { + public function __construct( + DisallowedCallsRuleErrors $disallowedCallsRuleErrors, + DisallowedCallableParameterRuleErrors $disallowedCallableParameterRuleErrors, + DisallowedCallFactory $disallowedCallFactory, + array $forbiddenCalls + ) { $this->disallowedCallsRuleErrors = $disallowedCallsRuleErrors; + $this->disallowedCallableParameterRuleErrors = $disallowedCallableParameterRuleErrors; $this->disallowedCalls = $disallowedCallFactory->createFromConfig($forbiddenCalls); } @@ -89,11 +98,11 @@ public function processNode(Node $node, Scope $scope): array $definedIn = $reflection ? $reflection->getFileName() : null; foreach ($names as $name) { - $name .= self::CONSTRUCT; - $errors = array_merge( - $errors, - $this->disallowedCallsRuleErrors->get($node, $scope, $name, $type->getClassName() . self::CONSTRUCT, $definedIn, $this->disallowedCalls, ErrorIdentifiers::DISALLOWED_NEW) - ); + $ruleErrors = $this->disallowedCallsRuleErrors->get($node, $scope, $name . '::' . self::CONSTRUCT, $type->getClassName() . '::' . self::CONSTRUCT, $definedIn, $this->disallowedCalls, ErrorIdentifiers::DISALLOWED_NEW); + $paramErrors = $this->disallowedCallableParameterRuleErrors->getForConstructor(new Name($name), $node, $scope); + if ($errors || $ruleErrors || $paramErrors) { + $errors = array_merge($errors, $ruleErrors, $paramErrors); + } } } diff --git a/app/vendor/spaze/phpstan-disallowed-calls/src/Calls/StaticCalls.php b/app/vendor/spaze/phpstan-disallowed-calls/src/Calls/StaticCalls.php index e9b2a6840..faa4a2296 100644 --- a/app/vendor/spaze/phpstan-disallowed-calls/src/Calls/StaticCalls.php +++ b/app/vendor/spaze/phpstan-disallowed-calls/src/Calls/StaticCalls.php @@ -11,6 +11,7 @@ use PHPStan\ShouldNotHappenException; use Spaze\PHPStan\Rules\Disallowed\DisallowedCall; use Spaze\PHPStan\Rules\Disallowed\DisallowedCallFactory; +use Spaze\PHPStan\Rules\Disallowed\RuleErrors\DisallowedCallableParameterRuleErrors; use Spaze\PHPStan\Rules\Disallowed\RuleErrors\DisallowedMethodRuleErrors; /** @@ -26,22 +27,30 @@ class StaticCalls implements Rule private DisallowedMethodRuleErrors $disallowedMethodRuleErrors; + private DisallowedCallableParameterRuleErrors $disallowedCallableParameterRuleErrors; + /** @var list */ private array $disallowedCalls; /** * @param DisallowedMethodRuleErrors $disallowedMethodRuleErrors + * @param DisallowedCallableParameterRuleErrors $disallowedCallableParameterRuleErrors * @param DisallowedCallFactory $disallowedCallFactory * @param array $forbiddenCalls * @phpstan-param ForbiddenCallsConfig $forbiddenCalls * @noinspection PhpUndefinedClassInspection ForbiddenCallsConfig is a type alias defined in PHPStan config * @throws ShouldNotHappenException */ - public function __construct(DisallowedMethodRuleErrors $disallowedMethodRuleErrors, DisallowedCallFactory $disallowedCallFactory, array $forbiddenCalls) - { + public function __construct( + DisallowedMethodRuleErrors $disallowedMethodRuleErrors, + DisallowedCallableParameterRuleErrors $disallowedCallableParameterRuleErrors, + DisallowedCallFactory $disallowedCallFactory, + array $forbiddenCalls + ) { $this->disallowedMethodRuleErrors = $disallowedMethodRuleErrors; $this->disallowedCalls = $disallowedCallFactory->createFromConfig($forbiddenCalls); + $this->disallowedCallableParameterRuleErrors = $disallowedCallableParameterRuleErrors; } @@ -59,7 +68,9 @@ public function getNodeType(): string */ public function processNode(Node $node, Scope $scope): array { - return $this->disallowedMethodRuleErrors->get($node->class, $node, $scope, $this->disallowedCalls); + $errors = $this->disallowedMethodRuleErrors->get($node->class, $node, $scope, $this->disallowedCalls); + $paramErrors = $this->disallowedCallableParameterRuleErrors->getForMethod($node->class, $node, $scope); + return $errors || $paramErrors ? array_merge($errors, $paramErrors) : []; } } diff --git a/app/vendor/spaze/phpstan-disallowed-calls/src/Calls/StaticFirstClassCallables.php b/app/vendor/spaze/phpstan-disallowed-calls/src/Calls/StaticFirstClassCallables.php new file mode 100644 index 000000000..a864a4601 --- /dev/null +++ b/app/vendor/spaze/phpstan-disallowed-calls/src/Calls/StaticFirstClassCallables.php @@ -0,0 +1,66 @@ +MethodFirstClassCallables + * + * @package Spaze\PHPStan\Rules\Disallowed + * @implements Rule + */ +class StaticFirstClassCallables implements Rule +{ + + private DisallowedMethodRuleErrors $disallowedMethodRuleErrors; + + /** @var list */ + private array $disallowedCalls; + + + /** + * @param DisallowedMethodRuleErrors $disallowedMethodRuleErrors + * @param DisallowedCallFactory $disallowedCallFactory + * @param array $forbiddenCalls + * @phpstan-param ForbiddenCallsConfig $forbiddenCalls + * @noinspection PhpUndefinedClassInspection ForbiddenCallsConfig is a type alias defined in PHPStan config + * @throws ShouldNotHappenException + */ + public function __construct(DisallowedMethodRuleErrors $disallowedMethodRuleErrors, DisallowedCallFactory $disallowedCallFactory, array $forbiddenCalls) + { + $this->disallowedMethodRuleErrors = $disallowedMethodRuleErrors; + $this->disallowedCalls = $disallowedCallFactory->createFromConfig($forbiddenCalls); + } + + + public function getNodeType(): string + { + return StaticMethodCallableNode::class; + } + + + /** + * @param StaticMethodCallableNode $node + * @param Scope $scope + * @return list + * @throws ShouldNotHappenException + */ + public function processNode(Node $node, Scope $scope): array + { + $originalNode = $node->getOriginalNode(); + return $this->disallowedMethodRuleErrors->get($originalNode->class, $originalNode, $scope, $this->disallowedCalls); + } + +} diff --git a/app/vendor/spaze/phpstan-disallowed-calls/src/PHPStan1Compatibility.php b/app/vendor/spaze/phpstan-disallowed-calls/src/PHPStan1Compatibility.php new file mode 100644 index 000000000..da2a3e359 --- /dev/null +++ b/app/vendor/spaze/phpstan-disallowed-calls/src/PHPStan1Compatibility.php @@ -0,0 +1,31 @@ +isClassStringType(); + } else { + // PHPStan 2.x + return $type->isClassString(); + } + } + +} diff --git a/app/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedCallableParameterRuleErrors.php b/app/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedCallableParameterRuleErrors.php new file mode 100644 index 000000000..a3bdf8f42 --- /dev/null +++ b/app/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedCallableParameterRuleErrors.php @@ -0,0 +1,206 @@ + */ + private array $disallowedFunctionCalls; + + /** @var list */ + private array $disallowedCalls; + + private ReflectionProvider $reflectionProvider; + + + /** + * @param TypeResolver $typeResolver + * @param DisallowedFunctionRuleErrors $disallowedFunctionRuleErrors + * @param DisallowedMethodRuleErrors $disallowedMethodRuleErrors + * @param DisallowedCallFactory $disallowedCallFactory + * @param ReflectionProvider $reflectionProvider + * @param array $forbiddenFunctionCalls + * @phpstan-param ForbiddenCallsConfig $forbiddenFunctionCalls + * @param array $forbiddenMethodCalls + * @phpstan-param ForbiddenCallsConfig $forbiddenMethodCalls + * @param array $forbiddenStaticCalls + * @phpstan-param ForbiddenCallsConfig $forbiddenStaticCalls + * @noinspection PhpUndefinedClassInspection ForbiddenCallsConfig is a type alias defined in PHPStan config + * @throws ShouldNotHappenException + */ + public function __construct( + TypeResolver $typeResolver, + DisallowedFunctionRuleErrors $disallowedFunctionRuleErrors, + DisallowedMethodRuleErrors $disallowedMethodRuleErrors, + DisallowedCallFactory $disallowedCallFactory, + ReflectionProvider $reflectionProvider, + array $forbiddenFunctionCalls, + array $forbiddenMethodCalls, + array $forbiddenStaticCalls + ) { + $this->typeResolver = $typeResolver; + $this->disallowedFunctionRuleErrors = $disallowedFunctionRuleErrors; + $this->disallowedMethodRuleErrors = $disallowedMethodRuleErrors; + $this->disallowedFunctionCalls = $disallowedCallFactory->createFromConfig($forbiddenFunctionCalls); + $this->disallowedCalls = $disallowedCallFactory->createFromConfig(array_merge($forbiddenMethodCalls, $forbiddenStaticCalls)); + $this->reflectionProvider = $reflectionProvider; + } + + + /** + * @param FuncCall $node + * @param Scope $scope + * @return list + * @throws ShouldNotHappenException + */ + public function getForFunction(FuncCall $node, Scope $scope): array + { + $ruleErrors = []; + foreach ($this->typeResolver->getNamesFromCall($node, $scope) as $name) { + if (!$this->reflectionProvider->hasFunction($name, $scope)) { + continue; + } + $reflection = $this->reflectionProvider->getFunction($name, $scope); + $errors = $this->getErrors($node, $scope, $reflection); + if ($errors) { + $ruleErrors = array_merge($ruleErrors, $errors); + } + } + return $ruleErrors; + } + + + /** + * @param Name|Expr $class + * @param MethodCall|StaticCall $node + * @param Scope $scope + * @return list + * @throws ShouldNotHappenException + */ + public function getForMethod($class, CallLike $node, Scope $scope): array + { + $names = $this->typeResolver->getNamesFromCall($node, $scope); + return $this->getForMethods($class, $names, $node, $scope); + } + + + /** + * @param Name|Expr $class + * @param New_ $node + * @param Scope $scope + * @return list + * @throws ShouldNotHappenException + */ + public function getForConstructor($class, New_ $node, Scope $scope): array + { + return $this->getForMethods($class, [new Name(NewCalls::CONSTRUCT)], $node, $scope); + } + + + /** + * @param Name|Expr $class + * @param list $names + * @param CallLike $node + * @param Scope $scope + * @return list + * @throws ShouldNotHappenException + */ + public function getForMethods($class, array $names, CallLike $node, Scope $scope): array + { + $ruleErrors = []; + $classType = $this->typeResolver->getType($class, $scope); + if (PHPStan1Compatibility::isClassString($classType)->yes()) { + $classType = $classType->getClassStringObjectType(); + } + foreach ($classType->getObjectTypeOrClassStringObjectType()->getObjectClassNames() as $className) { + if (!$this->reflectionProvider->hasClass($className)) { + continue; + } + $classReflection = $this->reflectionProvider->getClass($className); + foreach ($names as $name) { + if (!$classReflection->hasMethod($name->toString())) { + continue; + } + $reflection = $classReflection->getMethod($name->toString(), $scope); + $errors = $this->getErrors($node, $scope, $reflection); + if ($errors) { + $ruleErrors = array_merge($ruleErrors, $errors); + } + } + } + return $ruleErrors; + } + + + /** + * @param Scope $scope + * @param CallLike $node + * @param ExtendedMethodReflection|FunctionReflection $reflection + * @return list + * @throws ShouldNotHappenException + */ + private function getErrors(CallLike $node, Scope $scope, $reflection): array + { + $ruleErrors = []; + $parametersAcceptor = ParametersAcceptorSelector::selectFromArgs($scope, $node->getArgs(), $reflection->getVariants()); + $reorderedArgs = ArgumentsNormalizer::reorderArgs($parametersAcceptor, $node->getArgs()) ?? $node->getArgs(); + foreach ($parametersAcceptor->getParameters() as $key => $parameter) { + if (!TypeCombinator::removeNull($parameter->getType())->isCallable()->yes() || !isset($reorderedArgs[$key])) { + continue; + } + $callableType = $scope->getType($reorderedArgs[$key]->value); + foreach ($callableType->getConstantStrings() as $constantString) { + $errors = $this->disallowedFunctionRuleErrors->getByString($constantString->getValue(), $scope, $this->disallowedFunctionCalls); + if ($errors) { + $ruleErrors = array_merge($ruleErrors, $errors); + } + } + foreach ($callableType->getConstantArrays() as $constantArray) { + foreach ($constantArray->findTypeAndMethodNames() as $typeAndMethodName) { + if ($typeAndMethodName->isUnknown()) { + continue; + } + $method = $typeAndMethodName->getMethod(); + foreach ($typeAndMethodName->getType()->getObjectClassNames() as $class) { + $errors = $this->disallowedMethodRuleErrors->getByString($class, $method, $scope, $this->disallowedCalls); + if ($errors) { + $ruleErrors = array_merge($ruleErrors, $errors); + } + } + } + } + } + return $ruleErrors; + } + +} diff --git a/app/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedFunctionRuleErrors.php b/app/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedFunctionRuleErrors.php new file mode 100644 index 000000000..8e835d893 --- /dev/null +++ b/app/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedFunctionRuleErrors.php @@ -0,0 +1,92 @@ +disallowedCallsRuleErrors = $disallowedCallsRuleErrors; + $this->reflectionProvider = $reflectionProvider; + $this->typeResolver = $typeResolver; + } + + + /** + * @param FuncCall $node + * @param Scope $scope + * @param list $disallowedCalls + * @return list + * @throws ShouldNotHappenException + */ + public function get(FuncCall $node, Scope $scope, array $disallowedCalls): array + { + $displayName = $node->name->getAttribute('originalName'); + if ($displayName !== null && !($displayName instanceof Name)) { + throw new ShouldNotHappenException(); + } + foreach ($this->typeResolver->getNamesFromCall($node, $scope) as $name) { + $errors = $this->getErrors($name, $scope, $node, $displayName, $disallowedCalls); + if ($errors) { + return $errors; + } + } + return []; + } + + + /** + * @param string $name + * @param Scope $scope + * @param list $disallowedCalls + * @return list + * @throws ShouldNotHappenException + */ + public function getByString(string $name, Scope $scope, array $disallowedCalls): array + { + return $this->getErrors(new Name($name), $scope, null, null, $disallowedCalls); + } + + + /** + * @param Name $name + * @param Scope $scope + * @param FuncCall|null $node + * @param Name|null $displayName + * @param list $disallowedCalls + * @return list + * @throws ShouldNotHappenException + */ + private function getErrors(Name $name, Scope $scope, ?FuncCall $node, ?Name $displayName, array $disallowedCalls): array + { + if ($this->reflectionProvider->hasFunction($name, $scope)) { + $functionReflection = $this->reflectionProvider->getFunction($name, $scope); + $definedIn = $functionReflection->isBuiltin() ? null : $functionReflection->getFileName(); + } else { + $definedIn = null; + } + return $this->disallowedCallsRuleErrors->get($node, $scope, (string)$name, (string)($displayName ?? $name), $definedIn, $disallowedCalls, ErrorIdentifiers::DISALLOWED_FUNCTION); + } + +} diff --git a/app/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedMethodRuleErrors.php b/app/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedMethodRuleErrors.php index eb80b6be0..4b19d61d7 100644 --- a/app/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedMethodRuleErrors.php +++ b/app/vendor/spaze/phpstan-disallowed-calls/src/RuleErrors/DisallowedMethodRuleErrors.php @@ -7,15 +7,16 @@ use PhpParser\Node\Expr\CallLike; use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\StaticCall; -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\Rules\IdentifierRuleError; use PHPStan\ShouldNotHappenException; +use PHPStan\Type\Type; use Spaze\PHPStan\Rules\Disallowed\DisallowedCall; use Spaze\PHPStan\Rules\Disallowed\Formatter\Formatter; +use Spaze\PHPStan\Rules\Disallowed\PHPStan1Compatibility; use Spaze\PHPStan\Rules\Disallowed\Type\TypeResolver; class DisallowedMethodRuleErrors @@ -44,48 +45,86 @@ public function __construct( * @param MethodCall|StaticCall $node * @param Scope $scope * @param list $disallowedCalls - * @return list + * @return list * @throws ShouldNotHappenException */ public function get($class, CallLike $node, Scope $scope, array $disallowedCalls): array { - if (!isset($node->name) || !($node->name instanceof Identifier)) { - return []; - } - $calledOnType = $this->typeResolver->getType($class, $scope); - if ($calledOnType->canCallMethods()->yes() && $calledOnType->hasMethod($node->name->name)->yes()) { - $method = $calledOnType->getMethod($node->name->name, $scope); - $declaringClass = $method->getDeclaringClass(); - $classNames = $calledOnType->getObjectClassNames(); - if (count($classNames) === 0) { - $calledAs = null; - } else { - $calledAs = $this->formatter->getFullyQualified($this->formatter->formatIdentifier($classNames), $method); + if (PHPStan1Compatibility::isClassString($calledOnType)->yes()) { + $calledOnType = $calledOnType->getClassStringObjectType(); + } + $errors = []; + foreach ($this->typeResolver->getNamesFromCall($node, $scope) as $name) { + $methodErrors = $this->getErrors($calledOnType, $name->toString(), $node, $scope, $disallowedCalls); + if ($methodErrors) { + $errors = array_merge($errors, $methodErrors); } + } + return $errors; + } - $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 { + + /** + * @param string $class + * @param string $method + * @param Scope $scope + * @param list $disallowedCalls + * @return list + * @throws ShouldNotHappenException + */ + public function getByString(string $class, string $method, Scope $scope, array $disallowedCalls): array + { + $className = new Name($class); + $calledOnType = $this->typeResolver->getType($className, $scope); + return $this->getErrors($calledOnType, $method, null, $scope, $disallowedCalls); + } + + + /** + * @param Type $calledOnType + * @param string $methodName + * @param MethodCall|StaticCall|null $node + * @param Scope $scope + * @param list $disallowedCalls + * @return list + * @throws ShouldNotHappenException + */ + private function getErrors(Type $calledOnType, string $methodName, ?CallLike $node, Scope $scope, array $disallowedCalls): array + { + if (!$calledOnType->canCallMethods()->yes() || !$calledOnType->hasMethod($methodName)->yes()) { return []; } - return $this->getRuleErrors([$declaringClass], $method, $node, $scope, $calledAs, $disallowedCalls); + + $method = $calledOnType->getMethod($methodName, $scope); + $declaringClass = $method->getDeclaringClass(); + $classNames = array_map(fn($class): string => $class->isAnonymous() ? 'class@anonymous' : $class->getName(), $calledOnType->getObjectClassReflections()); + if (count($classNames) === 0) { + $calledAs = null; + } else { + $calledAs = $this->formatter->getFullyQualified($this->formatter->formatIdentifier($classNames), $method); + } + + $classes = [$declaringClass]; + $traits = $declaringClass->getTraits(); + if ($traits) { + $classes = array_merge($classes, array_values($traits)); + } + $interfaces = $declaringClass->getInterfaces(); + if ($interfaces) { + $classes = array_merge($classes, array_values($interfaces)); + } + return $this->getRuleErrors($classes, $method, $node, $scope, $calledAs, $disallowedCalls); } /** * @param list $classes * @param list $disallowedCalls - * @return list + * @return list * @throws ShouldNotHappenException */ - private function getRuleErrors(array $classes, MethodReflection $method, CallLike $node, Scope $scope, ?string $calledAs, array $disallowedCalls): array + 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())) { diff --git a/app/vendor/spaze/phpstan-disallowed-calls/src/Type/TypeResolver.php b/app/vendor/spaze/phpstan-disallowed-calls/src/Type/TypeResolver.php index dace673c5..857889586 100644 --- a/app/vendor/spaze/phpstan-disallowed-calls/src/Type/TypeResolver.php +++ b/app/vendor/spaze/phpstan-disallowed-calls/src/Type/TypeResolver.php @@ -3,15 +3,33 @@ namespace Spaze\PHPStan\Rules\Disallowed\Type; +use PhpParser\Node; use PhpParser\Node\Expr; +use PhpParser\Node\Expr\FuncCall; +use PhpParser\Node\Expr\MethodCall; +use PhpParser\Node\Expr\StaticCall; +use PhpParser\Node\Expr\Variable; +use PhpParser\Node\Identifier; use PhpParser\Node\Name; +use PhpParser\Node\Scalar\String_; use PHPStan\Analyser\Scope; +use PHPStan\ShouldNotHappenException; use PHPStan\Type\ObjectType; use PHPStan\Type\Type; +use Spaze\PHPStan\Rules\Disallowed\Normalizer\Normalizer; class TypeResolver { + private Normalizer $normalizer; + + + public function __construct(Normalizer $normalizer) + { + $this->normalizer = $normalizer; + } + + /** * @param Name|Expr $class * @param Scope $scope @@ -22,4 +40,45 @@ public function getType($class, Scope $scope): Type return $class instanceof Name ? new ObjectType($scope->resolveName($class)) : $scope->getType($class); } + + public function getVariableStringValue(Variable $variable, Scope $scope): ?string + { + $variableNameNode = $variable->name; + $variableName = $variableNameNode instanceof String_ ? $variableNameNode->value : $variableNameNode; + if (!is_string($variableName)) { + return null; + } + $value = $scope->getVariableType($variableName)->getConstantScalarValues()[0] ?? null; + return is_string($value) ? $value : null; + } + + + /** + * @param FuncCall|MethodCall|StaticCall $node + * @param Scope $scope + * @return list + * @throws ShouldNotHappenException + */ + public function getNamesFromCall(Node $node, Scope $scope): array + { + if ($node->name instanceof Name) { + $namespacedName = $node->name->getAttribute('namespacedName'); + if ($namespacedName !== null && !($namespacedName instanceof Name)) { + throw new ShouldNotHappenException(); + } + return $namespacedName !== null ? [$namespacedName, $node->name] : [$node->name]; + } elseif ($node->name instanceof String_) { + return [new Name($this->normalizer->normalizeNamespace($node->name->value))]; + } elseif ($node->name instanceof Variable) { + $value = $this->getVariableStringValue($node->name, $scope); + if (!is_string($value)) { + return []; + } + return [new Name($this->normalizer->normalizeNamespace($value))]; + } elseif ($node->name instanceof Identifier) { + return [new Name($node->name->name)]; + } + return []; + } + } diff --git a/app/vendor/spaze/phpstan-disallowed-calls/src/Usages/ClassConstantUsages.php b/app/vendor/spaze/phpstan-disallowed-calls/src/Usages/ClassConstantUsages.php index ed0c8de1b..abe32b011 100644 --- a/app/vendor/spaze/phpstan-disallowed-calls/src/Usages/ClassConstantUsages.php +++ b/app/vendor/spaze/phpstan-disallowed-calls/src/Usages/ClassConstantUsages.php @@ -108,7 +108,9 @@ private function getConstantRuleErrors(Scope $scope, string $constant, Type $typ } $usedOnType = $type->getObjectTypeOrClassStringObjectType(); - $displayName = $usedOnType->getObjectClassNames() ? $this->getFullyQualified($usedOnType->getObjectClassNames(), $constant) : null; + $classes = $usedOnType->getObjectClassReflections(); + $classNames = array_map(fn($class): string => $class->isAnonymous() ? 'class@anonymous' : $class->getName(), $classes); + $displayName = $classNames ? $this->getFullyQualified($classNames, $constant) : null; if ($usedOnType->getConstantStrings()) { $classNames = array_map( function (ConstantStringType $constantString): string {