From 974dbcd60f2f57b7f63ca5887fda041bbb977e03 Mon Sep 17 00:00:00 2001 From: Robert Brodie Date: Thu, 20 Jul 2023 10:31:50 -0400 Subject: [PATCH 1/6] SP-638 Regenerate lock file and dependencies under PHP 8.0 --- composer.lock | 57 +- vendor/autoload.php | 2 +- vendor/composer/autoload_psr4.php | 2 +- vendor/composer/autoload_real.php | 10 +- vendor/composer/autoload_static.php | 16 +- vendor/composer/installed.json | 63 +- vendor/composer/installed.php | 24 +- vendor/composer/platform_check.php | 4 +- vendor/phpcsstandards/phpcsextra/CHANGELOG.md | 52 +- vendor/phpcsstandards/phpcsextra/README.md | 72 +- .../CodeAnalysis/NoEchoSprintfStandard.xml | 25 + .../NoLongClosuresStandard.xml | 42 + .../RequireFinalMethodsInTraitsStandard.xml | 33 + .../DisallowMixedGroupUseStandard.xml | 39 + .../UseStatements/KeywordSpacingStandard.xml | 29 + .../NoUselessAliasesStandard.xml | 30 + .../Docs/WhiteSpace/CommaSpacingStandard.xml | 94 +++ .../Sniffs/Arrays/DuplicateArrayKeySniff.php | 9 +- .../ConstructorDestructorReturnSniff.php | 21 +- .../CodeAnalysis/NoEchoSprintfSniff.php | 131 ++++ .../NoLongClosuresSniff.php | 233 ++++++ .../RequireFinalMethodsInTraitsSniff.php | 120 +++ .../DisallowMixedGroupUseSniff.php | 248 ++++++ .../UseStatements/KeywordSpacingSniff.php | 207 +++++ .../UseStatements/NoUselessAliasesSniff.php | 164 ++++ .../Sniffs/WhiteSpace/CommaSpacingSniff.php | 408 ++++++++++ .../phpcsstandards/phpcsextra/composer.json | 2 +- .../Tests/Files/LineEndingsUnitTest.1.inc | 36 +- .../Tests/Files/LineEndingsUnitTest.2.inc | 10 +- .../Tests/Files/LineEndingsUnitTest.css | 6 +- .../Tests/Files/LineEndingsUnitTest.js | 4 +- .../ContextSensitiveKeywordsTest.inc | 454 +++++------ .../StableCommentWhitespaceWinTest.inc | 124 +-- .../StableCommentWhitespaceWinTest.php | 734 +++++++++--------- .../symfony/deprecation-contracts/.gitignore | 3 + vendor/symfony/deprecation-contracts/LICENSE | 2 +- .../symfony/deprecation-contracts/README.md | 2 +- .../deprecation-contracts/composer.json | 4 +- vendor/symfony/yaml/CHANGELOG.md | 16 - vendor/symfony/yaml/Command/LintCommand.php | 57 +- vendor/symfony/yaml/Dumper.php | 38 +- .../symfony/yaml/Exception/ParseException.php | 10 +- vendor/symfony/yaml/Inline.php | 108 +-- vendor/symfony/yaml/LICENSE | 2 +- vendor/symfony/yaml/Parser.php | 64 +- vendor/symfony/yaml/Tag/TaggedValue.php | 2 +- vendor/symfony/yaml/Unescaper.php | 82 +- vendor/symfony/yaml/Yaml.php | 1 - vendor/symfony/yaml/composer.json | 5 +- .../wpcs/WordPress-Core/ruleset.xml | 29 + vendor/wp-coding-standards/wpcs/composer.json | 4 +- 51 files changed, 2935 insertions(+), 999 deletions(-) create mode 100644 vendor/phpcsstandards/phpcsextra/Universal/Docs/CodeAnalysis/NoEchoSprintfStandard.xml create mode 100644 vendor/phpcsstandards/phpcsextra/Universal/Docs/FunctionDeclarations/NoLongClosuresStandard.xml create mode 100644 vendor/phpcsstandards/phpcsextra/Universal/Docs/FunctionDeclarations/RequireFinalMethodsInTraitsStandard.xml create mode 100644 vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/DisallowMixedGroupUseStandard.xml create mode 100644 vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/KeywordSpacingStandard.xml create mode 100644 vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/NoUselessAliasesStandard.xml create mode 100644 vendor/phpcsstandards/phpcsextra/Universal/Docs/WhiteSpace/CommaSpacingStandard.xml create mode 100644 vendor/phpcsstandards/phpcsextra/Universal/Sniffs/CodeAnalysis/NoEchoSprintfSniff.php create mode 100644 vendor/phpcsstandards/phpcsextra/Universal/Sniffs/FunctionDeclarations/NoLongClosuresSniff.php create mode 100644 vendor/phpcsstandards/phpcsextra/Universal/Sniffs/FunctionDeclarations/RequireFinalMethodsInTraitsSniff.php create mode 100644 vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/DisallowMixedGroupUseSniff.php create mode 100644 vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/KeywordSpacingSniff.php create mode 100644 vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/NoUselessAliasesSniff.php create mode 100644 vendor/phpcsstandards/phpcsextra/Universal/Sniffs/WhiteSpace/CommaSpacingSniff.php create mode 100644 vendor/symfony/deprecation-contracts/.gitignore diff --git a/composer.lock b/composer.lock index 2fbcd16b..4d1df9e8 100644 --- a/composer.lock +++ b/composer.lock @@ -695,25 +695,25 @@ }, { "name": "symfony/deprecation-contracts", - "version": "v3.3.0", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf" + "reference": "26954b3d62a6c5fd0ea8a2a00c0353a14978d05c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf", - "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/26954b3d62a6c5fd0ea8a2a00c0353a14978d05c", + "reference": "26954b3d62a6c5fd0ea8a2a00c0353a14978d05c", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.0.2" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.4-dev" + "dev-main": "3.0-dev" }, "thanks": { "name": "symfony/contracts", @@ -742,7 +742,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.3.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.0.2" }, "funding": [ { @@ -758,7 +758,7 @@ "type": "tidelift" } ], - "time": "2023-05-23T14:45:45+00:00" + "time": "2022-01-02T09:55:41+00:00" }, { "name": "symfony/polyfill-ctype", @@ -844,20 +844,20 @@ }, { "name": "symfony/yaml", - "version": "v6.3.0", + "version": "v6.0.19", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "a9a8337aa641ef2aa39c3e028f9107ec391e5927" + "reference": "deec3a812a0305a50db8ae689b183f43d915c884" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/a9a8337aa641ef2aa39c3e028f9107ec391e5927", - "reference": "a9a8337aa641ef2aa39c3e028f9107ec391e5927", + "url": "https://api.github.com/repos/symfony/yaml/zipball/deec3a812a0305a50db8ae689b183f43d915c884", + "reference": "deec3a812a0305a50db8ae689b183f43d915c884", "shasum": "" }, "require": { - "php": ">=8.1", + "php": ">=8.0.2", "symfony/polyfill-ctype": "^1.8" }, "conflict": { @@ -866,6 +866,9 @@ "require-dev": { "symfony/console": "^5.4|^6.0" }, + "suggest": { + "symfony/console": "For validating YAML files using the lint command" + }, "bin": [ "Resources/bin/yaml-lint" ], @@ -895,7 +898,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v6.3.0" + "source": "https://github.com/symfony/yaml/tree/v6.0.19" }, "funding": [ { @@ -911,7 +914,7 @@ "type": "tidelift" } ], - "time": "2023-04-28T13:28:14+00:00" + "time": "2023-01-11T11:50:03+00:00" } ], "packages-dev": [ @@ -995,21 +998,21 @@ }, { "name": "phpcsstandards/phpcsextra", - "version": "1.0.4", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHPCSExtra.git", - "reference": "029af41e270ae73f10c0e9a1ce376b12da4e4810" + "reference": "61a9be9f74a53735f7c421d7de8dc64fa80488e6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/029af41e270ae73f10c0e9a1ce376b12da4e4810", - "reference": "029af41e270ae73f10c0e9a1ce376b12da4e4810", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/61a9be9f74a53735f7c421d7de8dc64fa80488e6", + "reference": "61a9be9f74a53735f7c421d7de8dc64fa80488e6", "shasum": "" }, "require": { "php": ">=5.4", - "phpcsstandards/phpcsutils": "^1.0.6", + "phpcsstandards/phpcsutils": "^1.0.8", "squizlabs/php_codesniffer": "^3.7.1" }, "require-dev": { @@ -1054,7 +1057,7 @@ "issues": "https://github.com/PHPCSStandards/PHPCSExtra/issues", "source": "https://github.com/PHPCSStandards/PHPCSExtra" }, - "time": "2023-06-17T22:57:40+00:00" + "time": "2023-07-19T19:40:11+00:00" }, { "name": "phpcsstandards/phpcsutils", @@ -1192,19 +1195,19 @@ "source": { "type": "git", "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", - "reference": "0734364f65df0cfb9e8d858b47f9c98fb0743372" + "reference": "1767f3a1169407d84f1d17e4cd9d80844d693e9e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/0734364f65df0cfb9e8d858b47f9c98fb0743372", - "reference": "0734364f65df0cfb9e8d858b47f9c98fb0743372", + "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/1767f3a1169407d84f1d17e4cd9d80844d693e9e", + "reference": "1767f3a1169407d84f1d17e4cd9d80844d693e9e", "shasum": "" }, "require": { "ext-filter": "*", "php": ">=5.4", - "phpcsstandards/phpcsextra": "^1.0", - "phpcsstandards/phpcsutils": "^1.0.7", + "phpcsstandards/phpcsextra": "^1.1.0", + "phpcsstandards/phpcsutils": "^1.0.8", "squizlabs/php_codesniffer": "^3.7.2" }, "require-dev": { @@ -1241,7 +1244,7 @@ "source": "https://github.com/WordPress/WordPress-Coding-Standards", "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki" }, - "time": "2023-07-11T09:36:30+00:00" + "time": "2023-07-20T05:44:11+00:00" } ], "aliases": [], diff --git a/vendor/autoload.php b/vendor/autoload.php index e7abdaf2..dd870c0a 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -22,4 +22,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInitbf29e92a4eb299ce8b74cb0d23ab0c24::getLoader(); +return ComposerAutoloaderInit056b4614544da4979dc4893803506afc::getLoader(); diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index 503b1150..20f4985a 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -8,7 +8,7 @@ return array( 'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'), 'Symfony\\Component\\Yaml\\' => array($vendorDir . '/symfony/yaml'), - 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-factory/src', $vendorDir . '/psr/http-message/src'), + 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src', $vendorDir . '/psr/http-factory/src'), 'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'), 'PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\' => array($vendorDir . '/dealerdirect/phpcodesniffer-composer-installer/src'), 'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'), diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 4d970d00..6213077c 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInitbf29e92a4eb299ce8b74cb0d23ab0c24 +class ComposerAutoloaderInit056b4614544da4979dc4893803506afc { private static $loader; @@ -24,16 +24,16 @@ public static function getLoader() require __DIR__ . '/platform_check.php'; - spl_autoload_register(array('ComposerAutoloaderInitbf29e92a4eb299ce8b74cb0d23ab0c24', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit056b4614544da4979dc4893803506afc', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInitbf29e92a4eb299ce8b74cb0d23ab0c24', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit056b4614544da4979dc4893803506afc', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInitbf29e92a4eb299ce8b74cb0d23ab0c24::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit056b4614544da4979dc4893803506afc::getInitializer($loader)); $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticInitbf29e92a4eb299ce8b74cb0d23ab0c24::$files; + $filesToLoad = \Composer\Autoload\ComposerStaticInit056b4614544da4979dc4893803506afc::$files; $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 17bcadf1..de48ce8a 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInitbf29e92a4eb299ce8b74cb0d23ab0c24 +class ComposerStaticInit056b4614544da4979dc4893803506afc { public static $files = array ( '7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php', @@ -48,8 +48,8 @@ class ComposerStaticInitbf29e92a4eb299ce8b74cb0d23ab0c24 ), 'Psr\\Http\\Message\\' => array ( - 0 => __DIR__ . '/..' . '/psr/http-factory/src', - 1 => __DIR__ . '/..' . '/psr/http-message/src', + 0 => __DIR__ . '/..' . '/psr/http-message/src', + 1 => __DIR__ . '/..' . '/psr/http-factory/src', ), 'Psr\\Http\\Client\\' => array ( @@ -147,11 +147,11 @@ class ComposerStaticInitbf29e92a4eb299ce8b74cb0d23ab0c24 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInitbf29e92a4eb299ce8b74cb0d23ab0c24::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInitbf29e92a4eb299ce8b74cb0d23ab0c24::$prefixDirsPsr4; - $loader->fallbackDirsPsr4 = ComposerStaticInitbf29e92a4eb299ce8b74cb0d23ab0c24::$fallbackDirsPsr4; - $loader->prefixesPsr0 = ComposerStaticInitbf29e92a4eb299ce8b74cb0d23ab0c24::$prefixesPsr0; - $loader->classMap = ComposerStaticInitbf29e92a4eb299ce8b74cb0d23ab0c24::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit056b4614544da4979dc4893803506afc::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit056b4614544da4979dc4893803506afc::$prefixDirsPsr4; + $loader->fallbackDirsPsr4 = ComposerStaticInit056b4614544da4979dc4893803506afc::$fallbackDirsPsr4; + $loader->prefixesPsr0 = ComposerStaticInit056b4614544da4979dc4893803506afc::$prefixesPsr0; + $loader->classMap = ComposerStaticInit056b4614544da4979dc4893803506afc::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 6ee35b75..85d52392 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -584,22 +584,22 @@ }, { "name": "phpcsstandards/phpcsextra", - "version": "1.0.4", - "version_normalized": "1.0.4.0", + "version": "1.1.0", + "version_normalized": "1.1.0.0", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHPCSExtra.git", - "reference": "029af41e270ae73f10c0e9a1ce376b12da4e4810" + "reference": "61a9be9f74a53735f7c421d7de8dc64fa80488e6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/029af41e270ae73f10c0e9a1ce376b12da4e4810", - "reference": "029af41e270ae73f10c0e9a1ce376b12da4e4810", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/61a9be9f74a53735f7c421d7de8dc64fa80488e6", + "reference": "61a9be9f74a53735f7c421d7de8dc64fa80488e6", "shasum": "" }, "require": { "php": ">=5.4", - "phpcsstandards/phpcsutils": "^1.0.6", + "phpcsstandards/phpcsutils": "^1.0.8", "squizlabs/php_codesniffer": "^3.7.1" }, "require-dev": { @@ -609,7 +609,7 @@ "phpcsstandards/phpcsdevtools": "^1.2.1", "phpunit/phpunit": "^4.5 || ^5.0 || ^6.0 || ^7.0" }, - "time": "2023-06-17T22:57:40+00:00", + "time": "2023-07-19T19:40:11+00:00", "type": "phpcodesniffer-standard", "extra": { "branch-alias": { @@ -1002,27 +1002,27 @@ }, { "name": "symfony/deprecation-contracts", - "version": "v3.3.0", - "version_normalized": "3.3.0.0", + "version": "v3.0.2", + "version_normalized": "3.0.2.0", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf" + "reference": "26954b3d62a6c5fd0ea8a2a00c0353a14978d05c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf", - "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/26954b3d62a6c5fd0ea8a2a00c0353a14978d05c", + "reference": "26954b3d62a6c5fd0ea8a2a00c0353a14978d05c", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.0.2" }, - "time": "2023-05-23T14:45:45+00:00", + "time": "2022-01-02T09:55:41+00:00", "type": "library", "extra": { "branch-alias": { - "dev-main": "3.4-dev" + "dev-main": "3.0-dev" }, "thanks": { "name": "symfony/contracts", @@ -1052,7 +1052,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.3.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.0.2" }, "funding": [ { @@ -1157,21 +1157,21 @@ }, { "name": "symfony/yaml", - "version": "v6.3.0", - "version_normalized": "6.3.0.0", + "version": "v6.0.19", + "version_normalized": "6.0.19.0", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "a9a8337aa641ef2aa39c3e028f9107ec391e5927" + "reference": "deec3a812a0305a50db8ae689b183f43d915c884" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/a9a8337aa641ef2aa39c3e028f9107ec391e5927", - "reference": "a9a8337aa641ef2aa39c3e028f9107ec391e5927", + "url": "https://api.github.com/repos/symfony/yaml/zipball/deec3a812a0305a50db8ae689b183f43d915c884", + "reference": "deec3a812a0305a50db8ae689b183f43d915c884", "shasum": "" }, "require": { - "php": ">=8.1", + "php": ">=8.0.2", "symfony/polyfill-ctype": "^1.8" }, "conflict": { @@ -1180,7 +1180,10 @@ "require-dev": { "symfony/console": "^5.4|^6.0" }, - "time": "2023-04-28T13:28:14+00:00", + "suggest": { + "symfony/console": "For validating YAML files using the lint command" + }, + "time": "2023-01-11T11:50:03+00:00", "bin": [ "Resources/bin/yaml-lint" ], @@ -1211,7 +1214,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v6.3.0" + "source": "https://github.com/symfony/yaml/tree/v6.0.19" }, "funding": [ { @@ -1236,19 +1239,19 @@ "source": { "type": "git", "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", - "reference": "0734364f65df0cfb9e8d858b47f9c98fb0743372" + "reference": "1767f3a1169407d84f1d17e4cd9d80844d693e9e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/0734364f65df0cfb9e8d858b47f9c98fb0743372", - "reference": "0734364f65df0cfb9e8d858b47f9c98fb0743372", + "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/1767f3a1169407d84f1d17e4cd9d80844d693e9e", + "reference": "1767f3a1169407d84f1d17e4cd9d80844d693e9e", "shasum": "" }, "require": { "ext-filter": "*", "php": ">=5.4", - "phpcsstandards/phpcsextra": "^1.0", - "phpcsstandards/phpcsutils": "^1.0.7", + "phpcsstandards/phpcsextra": "^1.1.0", + "phpcsstandards/phpcsutils": "^1.0.8", "squizlabs/php_codesniffer": "^3.7.2" }, "require-dev": { @@ -1261,7 +1264,7 @@ "suggest": { "ext-mbstring": "For improved results" }, - "time": "2023-07-11T09:36:30+00:00", + "time": "2023-07-20T05:44:11+00:00", "default-branch": true, "type": "phpcodesniffer-standard", "installation-source": "dist", diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 3d6d5afa..89a92442 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'bitpay/bitpay-checkout-for-woocommerce', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '3fcd4db8afe2dbb91e959dc62939343d8946e91c', + 'reference' => 'd7b24e39f64517e0c9006014d7ad1d4109289891', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -13,7 +13,7 @@ 'bitpay/bitpay-checkout-for-woocommerce' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '3fcd4db8afe2dbb91e959dc62939343d8946e91c', + 'reference' => 'd7b24e39f64517e0c9006014d7ad1d4109289891', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -83,9 +83,9 @@ 'dev_requirement' => false, ), 'phpcsstandards/phpcsextra' => array( - 'pretty_version' => '1.0.4', - 'version' => '1.0.4.0', - 'reference' => '029af41e270ae73f10c0e9a1ce376b12da4e4810', + 'pretty_version' => '1.1.0', + 'version' => '1.1.0.0', + 'reference' => '61a9be9f74a53735f7c421d7de8dc64fa80488e6', 'type' => 'phpcodesniffer-standard', 'install_path' => __DIR__ . '/../phpcsstandards/phpcsextra', 'aliases' => array(), @@ -164,9 +164,9 @@ 'dev_requirement' => true, ), 'symfony/deprecation-contracts' => array( - 'pretty_version' => 'v3.3.0', - 'version' => '3.3.0.0', - 'reference' => '7c3aff79d10325257a001fcf92d991f24fc967cf', + 'pretty_version' => 'v3.0.2', + 'version' => '3.0.2.0', + 'reference' => '26954b3d62a6c5fd0ea8a2a00c0353a14978d05c', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/deprecation-contracts', 'aliases' => array(), @@ -182,9 +182,9 @@ 'dev_requirement' => false, ), 'symfony/yaml' => array( - 'pretty_version' => 'v6.3.0', - 'version' => '6.3.0.0', - 'reference' => 'a9a8337aa641ef2aa39c3e028f9107ec391e5927', + 'pretty_version' => 'v6.0.19', + 'version' => '6.0.19.0', + 'reference' => 'deec3a812a0305a50db8ae689b183f43d915c884', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/yaml', 'aliases' => array(), @@ -193,7 +193,7 @@ 'wp-coding-standards/wpcs' => array( 'pretty_version' => 'dev-develop', 'version' => 'dev-develop', - 'reference' => '0734364f65df0cfb9e8d858b47f9c98fb0743372', + 'reference' => '1767f3a1169407d84f1d17e4cd9d80844d693e9e', 'type' => 'phpcodesniffer-standard', 'install_path' => __DIR__ . '/../wp-coding-standards/wpcs', 'aliases' => array( diff --git a/vendor/composer/platform_check.php b/vendor/composer/platform_check.php index 4c3a5d68..b168ddd5 100644 --- a/vendor/composer/platform_check.php +++ b/vendor/composer/platform_check.php @@ -4,8 +4,8 @@ $issues = array(); -if (!(PHP_VERSION_ID >= 80100)) { - $issues[] = 'Your Composer dependencies require a PHP version ">= 8.1.0". You are running ' . PHP_VERSION . '.'; +if (!(PHP_VERSION_ID >= 80002)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 8.0.2". You are running ' . PHP_VERSION . '.'; } if ($issues) { diff --git a/vendor/phpcsstandards/phpcsextra/CHANGELOG.md b/vendor/phpcsstandards/phpcsextra/CHANGELOG.md index 62e346e7..9e06a2e6 100644 --- a/vendor/phpcsstandards/phpcsextra/CHANGELOG.md +++ b/vendor/phpcsstandards/phpcsextra/CHANGELOG.md @@ -14,13 +14,60 @@ This projects adheres to [Keep a CHANGELOG](http://keepachangelog.com/) and uses _Nothing yet._ +## [1.1.0] - 2023-07-19 + +### Added + +#### Universal + +* :wrench: :books: New `Universal.CodeAnalysis.NoEchoSprintf` sniff to detect use of the inefficient `echo [v]sprintf(...);` combi and recommends using `[v]printf()` instead. [#242] +* :bar_chart: :books: New `Universal.FunctionDeclarations.NoLongClosures` sniff to detect "long" closures and recommend using a named function instead. [#240] + The sniff offers the following properties to influence its behaviour: `recommendedLines` (defaults to `5`), `maxLines` (defaults to `8`), `ignoreCommentLines` (defaults to `true`) and `ignoreEmptyLines` (defaults to `true`). +* :wrench: :bar_chart: :books: New `Universal.FunctionDeclarations.RequireFinalMethodsInTraits` sniff to enforce non-private, non-abstract methods in traits to be declared as `final`. [#243], [#245] + There is a separate `NonFinalMagicMethodFound` error code for magic methods to allow those to be excluded from the check. +* :wrench: :bar_chart: :books: New `Universal.UseStatements.DisallowMixedGroupUse` sniff to disallow group use statements which import a combination of namespace/OO construct, functions and/or constants in one statement. [#241], [#246] + Note: the fixer will use a semi-standardized format for group use statements. If there are more specific requirements for the formatting of group use statements, the ruleset configurator should ensure that additional sniffs are included in the ruleset to enforce the required format. +* :wrench: :bar_chart: :books: New `Universal.UseStatements.KeywordSpacing` sniff to enforce the use of a single space after the `use`, `function`, `const` keywords and both before and after the `as` keyword in import `use` statements. [#247] + The sniff has modular error codes to allow for disabling individual checks. +* :wrench: :books: New `Universal.UseStatements.NoUselessAliases` sniff to detect useless aliases (aliasing something to its original name) in import use statements. [#244] + Note: as OO and function names in PHP are case-insensitive, aliasing to the same name, using a different case is also considered useless. +* :wrench: :bar_chart: :books: New `Universal.WhiteSpace.CommaSpacing` sniff to enforce that there is no space before a comma and exactly one space, or a new line, after a comma. [#254] + Additionally, the sniff also enforces that the comma should follow the code and not be placed after a trailing comment. + The sniff has modular error codes to allow for disabling individual checks and checks in certain contexts. + The sniff will respect a potentially set [`php_version` configuration option][php_version-config] when deciding how to handle the spacing after a heredoc/nowdoc closer. + +### Changed + +#### Universal + +* Minor performance improvements for the `Universal.Arrays.DuplicateArrayKey` and the `Universal.CodeAnalysis.ConstructorDestructorReturn` sniffs. [#251], [#252] + +#### Other + +* Composer: The minimum `PHPCSUtils` requirement has been updated to `^1.0.8` (was `^1.0.6`). [#249], [#254] +* Various housekeeping. + +[#240]: https://github.com/PHPCSStandards/PHPCSExtra/pull/240 +[#241]: https://github.com/PHPCSStandards/PHPCSExtra/pull/241 +[#242]: https://github.com/PHPCSStandards/PHPCSExtra/pull/242 +[#243]: https://github.com/PHPCSStandards/PHPCSExtra/pull/243 +[#244]: https://github.com/PHPCSStandards/PHPCSExtra/pull/244 +[#245]: https://github.com/PHPCSStandards/PHPCSExtra/pull/245 +[#246]: https://github.com/PHPCSStandards/PHPCSExtra/pull/246 +[#247]: https://github.com/PHPCSStandards/PHPCSExtra/pull/247 +[#249]: https://github.com/PHPCSStandards/PHPCSExtra/pull/249 +[#251]: https://github.com/PHPCSStandards/PHPCSExtra/pull/251 +[#252]: https://github.com/PHPCSStandards/PHPCSExtra/pull/252 +[#254]: https://github.com/PHPCSStandards/PHPCSExtra/pull/254 + + ## [1.0.4] - 2023-06-18 ### Changed #### Other -* Composer: The minimum `PHPCSUtils` requirement has been updated to `^1.0.6` (was ^1.0.0). [#237] +* Composer: The minimum `PHPCSUtils` requirement has been updated to `^1.0.6` (was `^1.0.0`). [#237] * Various housekeeping. ### Fixed @@ -183,7 +230,7 @@ For the full list of features, please see the changelogs of the alpha/rc release * Updated the sniffs for compatibility with PHPCSUtils 1.0.0-alpha4. [#134] * Updated the sniffs to correctly handle PHP 8.0/8.1/8.2 features whenever relevant. * Readme: Updated installation instructions for compatibility with Composer 2.2+. [#101] -* Composer: The minimum `PHP_CodeSniffer` requirement has been updated to `^3.7.1` (was ^3.3.1). [#115], [#130] +* Composer: The minimum `PHP_CodeSniffer` requirement has been updated to `^3.7.1` (was `^3.3.1`). [#115], [#130] * Composer: The package will now identify itself as a static analysis tool. Thanks [@GaryJones]! [#126] * All non-`abstract` classes in this package are now `final`. [#121] * All XML documentation now has a schema annotation. [#128] @@ -441,6 +488,7 @@ This initial alpha release contains the following sniffs: [php_version-config]: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options#setting-the-php-version [Unreleased]: https://github.com/PHPCSStandards/PHPCSExtra/compare/stable...HEAD +[1.1.0]: https://github.com/PHPCSStandards/PHPCSExtra/compare/1.0.4...1.1.0 [1.0.4]: https://github.com/PHPCSStandards/PHPCSExtra/compare/1.0.3...1.0.4 [1.0.3]: https://github.com/PHPCSStandards/PHPCSExtra/compare/1.0.2...1.0.3 [1.0.2]: https://github.com/PHPCSStandards/PHPCSExtra/compare/1.0.1...1.0.2 diff --git a/vendor/phpcsstandards/phpcsextra/README.md b/vendor/phpcsstandards/phpcsextra/README.md index 2120ce3d..51c90888 100644 --- a/vendor/phpcsstandards/phpcsextra/README.md +++ b/vendor/phpcsstandards/phpcsextra/README.md @@ -46,7 +46,7 @@ Minimum Requirements * PHP 5.4 or higher. * [PHP_CodeSniffer][phpcs-gh] version **3.7.1** or higher. -* [PHPCSUtils][phpcsutils-gh] version **1.0.0** or higher. +* [PHPCSUtils][phpcsutils-gh] version **1.0.8** or higher. Installation @@ -61,7 +61,7 @@ Installing via Composer is highly recommended. Run the following from the root of your project: ```bash composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true -composer require --dev phpcsstandards/phpcsextra:"^1.0" +composer require --dev phpcsstandards/phpcsextra:"^1.1.0" ``` ### Composer Global Installation @@ -69,7 +69,7 @@ composer require --dev phpcsstandards/phpcsextra:"^1.0" Alternatively, you may want to install this standard globally: ```bash composer global config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true -composer global require --dev phpcsstandards/phpcsextra:"^1.0" +composer global require --dev phpcsstandards/phpcsextra:"^1.1.0" ``` ### Updating to a newer version @@ -220,6 +220,10 @@ Require a consistent modifier keyword order for class declarations. If a [`php_version` configuration option][php_version-config] has been passed to PHPCS using either `--config-set` or `--runtime-set`, it will be respected by the sniff. In effect, this means that the sniff will only report on PHP4-style constructors if the configured PHP version is less than 8.0. +#### `Universal.CodeAnalysis.NoEchoSprintf` :wrench: :books: + +Detects use of the inefficient `echo [v]sprintf(...);` combi. Use `[v]printf()` instead. + #### `Universal.CodeAnalysis.ForeachUniqueAssignment` :wrench: :books: Detects `foreach` control structures which use the same variable for both the key as well as the value assignment as this will lead to unexpected - and most likely unintended - behaviour. @@ -278,6 +282,26 @@ Enforce for a file to either declare (global/namespaced) functions or declare OO * Also note: This sniff has no opinion on multiple OO structures being declared in one file. If you want to sniff for that, use the PHPCS native `Generic.Files.OneObjectStructurePerFile` sniff. +#### `Universal.FunctionDeclarations.NoLongClosures` :bar_chart: :books: + +Detects "long" closures and recommends using a named function instead. + +The sniff is configurable by setting any of the following properties in a custom ruleset: +* `recommendedLines` (int): determines when a warning will be thrown. + Defaults to `5`, meaning a warning with the errorcode `ExceedsRecommended` will be thrown if the closure is more than 5 lines long. +* `maxLines` (int): determines when an error will be thrown. + Defaults to `8`, meaning that an error with the errorcode `ExceedsMaximum` will be thrown if the closure is more than 8 lines long. +* `ignoreCommentLines` (bool): whether or not comment-only lines should be ignored for the lines count. + Defaults to `true`. +* `ignoreEmptyLines` (bool): whether or not blank lines should be ignored for the lines count. + Defaults to `true`. + +#### `Universal.FunctionDeclarations.RequireFinalMethodsInTraits` :wrench: :bar_chart: :books: + +Enforce non-private, non-abstract methods in traits to be declared as `final`. + +The available error codes are: `NonFinalMethodFound` and `NonFinalMagicMethodFound`. + #### `Universal.Lists.DisallowLongListSyntax` :wrench: :books: Disallow the use of long `list`s. @@ -368,6 +392,13 @@ The available error codes are: `UnionTypeSpacesBefore`, `UnionTypeSpacesAfter`, Disallow short open echo tags ` + + + + + + + printf('text %s text', $var); +echo callMe('text %s text', $var); + ]]> + + + echo sprintf('text %s text', $var); +echo vsprintf('text %s text', [$var]); + ]]> + + + diff --git a/vendor/phpcsstandards/phpcsextra/Universal/Docs/FunctionDeclarations/NoLongClosuresStandard.xml b/vendor/phpcsstandards/phpcsextra/Universal/Docs/FunctionDeclarations/NoLongClosuresStandard.xml new file mode 100644 index 00000000..dc84e0b1 --- /dev/null +++ b/vendor/phpcsstandards/phpcsextra/Universal/Docs/FunctionDeclarations/NoLongClosuresStandard.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + diff --git a/vendor/phpcsstandards/phpcsextra/Universal/Docs/FunctionDeclarations/RequireFinalMethodsInTraitsStandard.xml b/vendor/phpcsstandards/phpcsextra/Universal/Docs/FunctionDeclarations/RequireFinalMethodsInTraitsStandard.xml new file mode 100644 index 00000000..4b2622de --- /dev/null +++ b/vendor/phpcsstandards/phpcsextra/Universal/Docs/FunctionDeclarations/RequireFinalMethodsInTraitsStandard.xml @@ -0,0 +1,33 @@ + + + + + + + + final public function bar() {} + final public static function baz() {} + + // Also valid (out of scope): + protected abstract function overload() {} + private function okay() {} +} + ]]> + + + public function bar() {} + protected static function baz() {} +} + ]]> + + + diff --git a/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/DisallowMixedGroupUseStandard.xml b/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/DisallowMixedGroupUseStandard.xml new file mode 100644 index 00000000..2b930f27 --- /dev/null +++ b/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/DisallowMixedGroupUseStandard.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + diff --git a/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/KeywordSpacingStandard.xml b/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/KeywordSpacingStandard.xml new file mode 100644 index 00000000..55d430e2 --- /dev/null +++ b/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/KeywordSpacingStandard.xml @@ -0,0 +1,29 @@ + + + + + + + + function strpos; +use const PHP_EOL as MY_EOL; + ]]> + + + function strpos; +use + const + PHP_EOL + as + MY_EOL; + ]]> + + + diff --git a/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/NoUselessAliasesStandard.xml b/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/NoUselessAliasesStandard.xml new file mode 100644 index 00000000..39bb90d1 --- /dev/null +++ b/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/NoUselessAliasesStandard.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + diff --git a/vendor/phpcsstandards/phpcsextra/Universal/Docs/WhiteSpace/CommaSpacingStandard.xml b/vendor/phpcsstandards/phpcsextra/Universal/Docs/WhiteSpace/CommaSpacingStandard.xml new file mode 100644 index 00000000..503ae6f7 --- /dev/null +++ b/vendor/phpcsstandards/phpcsextra/Universal/Docs/WhiteSpace/CommaSpacingStandard.xml @@ -0,0 +1,94 @@ + + + + + + + + , $param2, $param3); + +function_call( + $param1, + $param2, + $param3 +); + +$array = array($item1, $item2, $item3); +$array = [ + $item1, + $item2, +]; + +list(, $a, $b,,) = $array; +list( + , + $a, + $b, +) = $array; + ]]> + + + , $param2,$param3); + +function_call( + $a + ,$b + ,$c +); + +$array = array($item1,$item2 , $item3); +$array = [ + $item1, + $item2 , +]; + +list( ,$a, $b ,,) = $array; +list( + , + $a, + $b , +) = $array; + ]]> + + + + + + + + , // Comment. + $param2, /* Comment. */ +); + ]]> + + + , + $param2 /* Comment. */, +); + ]]> + + + diff --git a/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Arrays/DuplicateArrayKeySniff.php b/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Arrays/DuplicateArrayKeySniff.php index 92532e5c..f9ed534b 100644 --- a/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Arrays/DuplicateArrayKeySniff.php +++ b/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Arrays/DuplicateArrayKeySniff.php @@ -69,7 +69,7 @@ final class DuplicateArrayKeySniff extends AbstractArrayDeclarationSniff private $currentMaxIntKeyGt8; /** - * The current PHP version. + * PHP version as configured or -1 if unknown. * * @since 1.0.0 * @@ -97,6 +97,9 @@ public function processArray(File $phpcsFile) $this->keysSeenGt8 = []; if (isset($this->phpVersion) === false) { + // Set default value to prevent this code from running every time the sniff is triggered. + $this->phpVersion = -1; + $phpVersion = Helper::getConfigData('php_version'); if ($phpVersion !== null) { $this->phpVersion = (int) $phpVersion; @@ -146,7 +149,7 @@ public function processKey(File $phpcsFile, $startPtr, $endPtr, $itemNr) /* * Check if we've seen the key before. */ - if ((isset($this->phpVersion) === false || $this->phpVersion < 80000) + if (($this->phpVersion === -1 || $this->phpVersion < 80000) && isset($this->keysSeenLt8[$key]) === true ) { $errors['phplt8'] = [ @@ -166,7 +169,7 @@ public function processKey(File $phpcsFile, $startPtr, $endPtr, $itemNr) $errors['phplt8']['data_subset'][] = $this->tokens[$firstNonEmptyFirstSeen]['line']; } - if ((isset($this->phpVersion) === false || $this->phpVersion >= 80000) + if (($this->phpVersion === -1 || $this->phpVersion >= 80000) && isset($this->keysSeenGt8[$key]) === true ) { $errors['phpgt8'] = [ diff --git a/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/CodeAnalysis/ConstructorDestructorReturnSniff.php b/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/CodeAnalysis/ConstructorDestructorReturnSniff.php index d199019e..ce66d4d1 100644 --- a/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/CodeAnalysis/ConstructorDestructorReturnSniff.php +++ b/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/CodeAnalysis/ConstructorDestructorReturnSniff.php @@ -31,6 +31,15 @@ final class ConstructorDestructorReturnSniff implements Sniff { + /** + * PHP version as configured or 0 if unknown. + * + * @since 1.1.0 + * + * @var int + */ + private $phpVersion; + /** * Registers the tokens that this sniff wants to listen for. * @@ -56,6 +65,16 @@ public function register() */ public function process(File $phpcsFile, $stackPtr) { + if (isset($this->phpVersion) === false || \defined('PHP_CODESNIFFER_IN_TESTS')) { + // Set default value to prevent this code from running every time the sniff is triggered. + $this->phpVersion = 0; + + $phpVersion = Helper::getConfigData('php_version'); + if ($phpVersion !== null) { + $this->phpVersion = (int) $phpVersion; + } + } + $scopePtr = Scopes::validDirectScope($phpcsFile, $stackPtr, Tokens::$ooScopeTokens); if ($scopePtr === false) { // Not an OO method. @@ -69,7 +88,7 @@ public function process(File $phpcsFile, $stackPtr) $functionType = \sprintf('A "%s()" magic method', $functionNameLC); } else { // If the PHP version is explicitly set to PHP 8.0 or higher, ignore PHP 4-style constructors. - if ((int) Helper::getConfigData('php_version') >= 80000) { + if ($this->phpVersion >= 80000) { return; } diff --git a/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/CodeAnalysis/NoEchoSprintfSniff.php b/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/CodeAnalysis/NoEchoSprintfSniff.php new file mode 100644 index 00000000..3273e228 --- /dev/null +++ b/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/CodeAnalysis/NoEchoSprintfSniff.php @@ -0,0 +1,131 @@ + + */ + private $targetFunctions = [ + 'sprintf' => 'printf', + 'vsprintf' => 'vprintf', + ]; + + /** + * Returns an array of tokens this test wants to listen for. + * + * @since 1.1.0 + * + * @return array + */ + public function register() + { + return [\T_ECHO]; + } + + /** + * Processes this test, when one of its tokens is encountered. + * + * @since 1.1.0 + * + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. + * + * @return void + */ + public function process(File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + $skip = Tokens::$emptyTokens; + $skip[] = \T_NS_SEPARATOR; + + $next = $phpcsFile->findNext($skip, ($stackPtr + 1), null, true); + if ($next === false + || $tokens[$next]['code'] !== \T_STRING + || isset($this->targetFunctions[\strtolower($tokens[$next]['content'])]) === false + ) { + // Not our target. + return; + } + + $detectedFunction = \strtolower($tokens[$next]['content']); + + $openParens = $phpcsFile->findNext(Tokens::$emptyTokens, ($next + 1), null, true); + if ($next === false + || $tokens[$openParens]['code'] !== \T_OPEN_PARENTHESIS + || isset($tokens[$openParens]['parenthesis_closer']) === false + ) { + // Live coding/parse error. + return; + } + + $closeParens = $tokens[$openParens]['parenthesis_closer']; + $afterFunctionCall = $phpcsFile->findNext(Tokens::$emptyTokens, ($closeParens + 1), null, true); + if ($afterFunctionCall === false + || ($tokens[$afterFunctionCall]['code'] !== \T_SEMICOLON + && $tokens[$afterFunctionCall]['code'] !== \T_CLOSE_TAG) + ) { + // Live coding/parse error or compound echo statement. + return; + } + + $fix = $phpcsFile->addFixableError( + 'Unnecessary "echo %s(...)" found. Use "%s(...)" instead.', + $next, + 'Found', + [ + $tokens[$next]['content'], + $this->targetFunctions[$detectedFunction], + ] + ); + + if ($fix === true) { + $phpcsFile->fixer->beginChangeset(); + + // Remove echo and whitespace. + $phpcsFile->fixer->replaceToken($stackPtr, ''); + + for ($i = ($stackPtr + 1); $i < $next; $i++) { + if ($tokens[$i]['code'] !== \T_WHITESPACE) { + break; + } + + $phpcsFile->fixer->replaceToken($i, ''); + } + + $phpcsFile->fixer->replaceToken($next, $this->targetFunctions[$detectedFunction]); + + $phpcsFile->fixer->endChangeset(); + } + } +} diff --git a/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/FunctionDeclarations/NoLongClosuresSniff.php b/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/FunctionDeclarations/NoLongClosuresSniff.php new file mode 100644 index 00000000..13abb9fe --- /dev/null +++ b/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/FunctionDeclarations/NoLongClosuresSniff.php @@ -0,0 +1,233 @@ +recommendedLines = (int) $this->recommendedLines; + $this->maxLines = (int) $this->maxLines; + + $tokens = $phpcsFile->getTokens(); + + if (isset($tokens[$stackPtr]['scope_opener'], $tokens[$stackPtr]['scope_closer']) === false) { + // Live coding/parse error. Shouldn't be possible as in that case tokenizer won't retokenize to T_CLOSURE. + return; // @codeCoverageIgnore + } + + $opener = $tokens[$stackPtr]['scope_opener']; + $closer = $tokens[$stackPtr]['scope_closer']; + + $currentLine = $tokens[$opener]['line']; + $closerLine = $tokens[$closer]['line']; + + $codeLines = 0; + $commentLines = 0; + $blankLines = 0; + + // Check whether the line of the scope opener needs to be counted, but ignore trailing comments on that line. + $firstNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($opener + 1), $closer, true); + if ($firstNonEmpty !== false && $tokens[$firstNonEmpty]['line'] === $currentLine) { + ++$codeLines; + } + + // Check whether the line of the scope closer needs to be counted. + if ($closerLine !== $currentLine) { + $hasCommentTokens = false; + $hasCodeTokens = false; + for ($i = ($closer - 1); $tokens[$i]['line'] === $closerLine && $i > $opener; $i--) { + if (isset(Tokens::$emptyTokens[$tokens[$i]['code']]) === false) { + $hasCodeTokens = true; + } elseif (isset(Tokens::$commentTokens[$tokens[$i]['code']]) === true) { + $hasCommentTokens = true; + } + } + + if ($hasCodeTokens === true) { + ++$codeLines; + } elseif ($hasCommentTokens === true) { + ++$commentLines; + } + } + + // We've already examined the opener line, so move to the next line. + for ($i = ($opener + 1); $tokens[$i]['line'] === $currentLine && $i < $closer; $i++); + $currentLine = $tokens[$i]['line']; + + // Walk tokens. + while ($currentLine !== $closerLine) { + $hasCommentTokens = false; + $hasCodeTokens = false; + + while ($tokens[$i]['line'] === $currentLine) { + if (isset(Tokens::$emptyTokens[$tokens[$i]['code']]) === false) { + $hasCodeTokens = true; + } elseif (isset(Tokens::$commentTokens[$tokens[$i]['code']]) === true) { + $hasCommentTokens = true; + } + + ++$i; + } + + if ($hasCodeTokens === true) { + ++$codeLines; + } elseif ($hasCommentTokens === true) { + ++$commentLines; + } else { + // Only option left is that this is an empty line. + ++$blankLines; + } + + $currentLine = $tokens[$i]['line']; + } + + $nonBlankLines = ($codeLines + $commentLines); + $totalLines = ($codeLines + $commentLines + $blankLines); + $phpcsFile->recordMetric($stackPtr, self::METRIC_NAME_CODE, $codeLines . ' lines'); + $phpcsFile->recordMetric($stackPtr, self::METRIC_NAME_COMMENTS, $nonBlankLines . ' lines'); + $phpcsFile->recordMetric($stackPtr, self::METRIC_NAME_ALL, $totalLines . ' lines'); + + $lines = $codeLines; + if ($this->ignoreCommentLines === false) { + $lines += $commentLines; + } + if ($this->ignoreEmptyLines === false) { + $lines += $blankLines; + } + + $errorSuffix = ' Declare a named function instead. Found closure containing %s lines'; + + if ($lines > $this->maxLines) { + $phpcsFile->addError( + 'Closures which are longer than %s lines are forbidden.' . $errorSuffix, + $stackPtr, + 'ExceedsMaximum', + [$this->maxLines, $lines] + ); + + return; + } + + if ($lines > $this->recommendedLines) { + $phpcsFile->addWarning( + 'It is recommended for closures to contain %s lines or less.' . $errorSuffix, + $stackPtr, + 'ExceedsRecommended', + [$this->recommendedLines, $lines] + ); + } + } +} diff --git a/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/FunctionDeclarations/RequireFinalMethodsInTraitsSniff.php b/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/FunctionDeclarations/RequireFinalMethodsInTraitsSniff.php new file mode 100644 index 00000000..da9e2415 --- /dev/null +++ b/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/FunctionDeclarations/RequireFinalMethodsInTraitsSniff.php @@ -0,0 +1,120 @@ +getTokens(); + if (isset($tokens[$stackPtr]['parenthesis_opener']) === false) { + // Parse error/live coding. + return; + } + + $scopePtr = Scopes::validDirectScope($phpcsFile, $stackPtr, \T_TRAIT); + if ($scopePtr === false) { + // Not a trait method. + return; + } + + $methodProps = FunctionDeclarations::getProperties($phpcsFile, $stackPtr); + if ($methodProps['scope'] === 'private') { + // Private methods can't be final. + return; + } + + if ($methodProps['is_final'] === true) { + // Already final, nothing to do. + $phpcsFile->recordMetric($stackPtr, self::METRIC_NAME, 'final'); + return; + } + + if ($methodProps['is_abstract'] === true) { + // Abstract classes can't be final. + $phpcsFile->recordMetric($stackPtr, self::METRIC_NAME, 'abstract'); + return; + } + + $phpcsFile->recordMetric($stackPtr, self::METRIC_NAME, 'not abstract, not final'); + + $methodName = FunctionDeclarations::getName($phpcsFile, $stackPtr); + $magic = ''; + $code = 'NonFinalMethodFound'; + if (FunctionDeclarations::isMagicMethodName($methodName) === true) { + // Use separate error code for magic methods. + $magic = 'magic '; + $code = 'NonFinalMagicMethodFound'; + } + + $data = [ + $methodProps['scope'], + $magic, + $methodName, + ObjectDeclarations::getName($phpcsFile, $scopePtr), + ]; + + $fix = $phpcsFile->addFixableError( + 'The non-abstract, %s %smethod "%s()" in trait %s should be declared as final.', + $stackPtr, + $code, + $data + ); + + if ($fix === true) { + $phpcsFile->fixer->addContentBefore($stackPtr, 'final '); + } + } +} diff --git a/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/DisallowMixedGroupUseSniff.php b/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/DisallowMixedGroupUseSniff.php new file mode 100644 index 00000000..3303eac1 --- /dev/null +++ b/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/DisallowMixedGroupUseSniff.php @@ -0,0 +1,248 @@ +findNext([\T_SEMICOLON, \T_CLOSE_TAG], ($stackPtr + 1)); + $groupStart = $phpcsFile->findNext(\T_OPEN_USE_GROUP, ($stackPtr + 1), $endOfStatement); + + if ($groupStart === false) { + // Not a group use statement. Just record the metric. + if ($totalCount === 1) { + $phpcsFile->recordMetric($stackPtr, self::METRIC_NAME, 'single import'); + } else { + $phpcsFile->recordMetric($stackPtr, self::METRIC_NAME, 'multi import'); + } + + return; + } + + if ($totalCount === 1 + || ($ooCount !== 0 && $functionCount === 0 && $constantCount === 0) + || ($ooCount === 0 && $functionCount !== 0 && $constantCount === 0) + || ($ooCount === 0 && $functionCount === 0 && $constantCount !== 0) + ) { + // Not a *mixed* group use statement. + $phpcsFile->recordMetric($stackPtr, self::METRIC_NAME, 'group use, single type'); + return; + } + + $phpcsFile->recordMetric($stackPtr, self::METRIC_NAME, 'group use, multi type'); + + // Build up the error message. + $foundPhrases = []; + if ($ooCount > 1) { + $foundPhrases[] = \sprintf('%d namespaces/OO names', $ooCount); + } elseif ($ooCount === 1) { + $foundPhrases[] = \sprintf('%d namespace/OO name', $ooCount); + } + + if ($functionCount > 1) { + $foundPhrases[] = \sprintf('%d functions', $functionCount); + } elseif ($functionCount === 1) { + $foundPhrases[] = \sprintf('%d function', $functionCount); + } + + if ($constantCount > 1) { + $foundPhrases[] = \sprintf('%d constants', $constantCount); + } elseif ($constantCount === 1) { + $foundPhrases[] = \sprintf('%d constant', $constantCount); + } + + if (\count($foundPhrases) === 2) { + $found = \implode(' and ', $foundPhrases); + } else { + $found = \array_shift($foundPhrases) . ', '; + $found .= \implode(' and ', $foundPhrases); + } + + $error = 'Group use statements should import one type of construct.' + . ' Mixed group use statement found importing %s.'; + $code = 'Found'; + $data = [$found]; + + $hasComment = $phpcsFile->findNext(Tokens::$commentTokens, ($stackPtr + 1), $endOfStatement); + if ($hasComment !== false) { + // Don't attempt to auto-fix is there are comments or PHPCS annotations in the statement. + $phpcsFile->addError($error, $stackPtr, $code, $data); + return; + } + + $fix = $phpcsFile->addFixableError($error, $stackPtr, $code, $data); + + if ($fix === false) { + return; + } + + /* + * Fix it. + * + * This fixer complies with the following (arbitrary) requirements: + * - It will re-use the original base "group" name, i.e. the part before \{. + * - It take take aliases into account, but only when something is aliased to a different name. + * Aliases re-using the original name will be removed. + * - The fix will not add a trailing comma after the last group use sub-statement. + * This is a PHP 7.2+ feature. + * If a standard wants to enforce trailing commas, they should use a separate sniff for that. + * - If there is only 1 statement of a certain type, the replacement will be a single + * import use statement, not a group use statement. + */ + + $phpcsFile->fixer->beginChangeset(); + + // Ensure that a potential close PHP tag ending the statement is not removed. + $tokens = $phpcsFile->getTokens(); + $endRemoval = $endOfStatement; + if ($tokens[$endOfStatement]['code'] !== \T_SEMICOLON) { + $endRemoval = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($endOfStatement - 1), null, true); + } + + // Remove old statement with the exception of the `use` keyword. + for ($i = ($stackPtr + 1); $i <= $endRemoval; $i++) { + $phpcsFile->fixer->replaceToken($i, ''); + } + + // Build up the new use import statements. + $newStatements = []; + + $useIndent = \str_repeat(' ', ($tokens[$stackPtr]['column'] - 1)); + $insideIndent = $useIndent . \str_repeat(' ', 4); + + $baseGroupName = GetTokensAsString::noEmpties($phpcsFile, ($stackPtr + 1), ($groupStart - 1)); + + foreach ($useStatements as $type => $statements) { + $count = \count($statements); + if ($count === 0) { + continue; + } + + $typeName = $type . ' '; + if ($type === 'name') { + $typeName = ''; + } + + if ($count === 1) { + $fqName = \reset($statements); + $alias = \key($statements); + + $newStatement = 'use ' . $typeName . $fqName; + + $unqualifiedName = \ltrim(\substr($fqName, \strrpos($fqName, '\\')), '\\'); + if ($unqualifiedName !== $alias) { + $newStatement .= ' as ' . $alias; + } + + $newStatement .= ';'; + + $newStatements[] = $newStatement; + continue; + } + + // Multiple statements, add a single-type group use statement. + $newStatement = 'use ' . $typeName . $baseGroupName . '{' . $phpcsFile->eolChar; + + foreach ($statements as $alias => $fqName) { + $partialName = \str_replace($baseGroupName, '', $fqName); + $newStatement .= $insideIndent . $partialName; + + $unqualifiedName = \ltrim(\substr($partialName, \strrpos($partialName, '\\')), '\\'); + if ($unqualifiedName !== $alias) { + $newStatement .= ' as ' . $alias; + } + + $newStatement .= ',' . $phpcsFile->eolChar; + } + + // Remove trailing comma after last statement as that's PHP 7.2+. + $newStatement = \rtrim($newStatement, ',' . $phpcsFile->eolChar); + + $newStatement .= $phpcsFile->eolChar . $useIndent . '};'; + $newStatements[] = $newStatement; + } + + $replacement = \implode($phpcsFile->eolChar . $useIndent, $newStatements); + + $phpcsFile->fixer->replaceToken($stackPtr, $replacement); + + $phpcsFile->fixer->endChangeset(); + } +} diff --git a/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/KeywordSpacingSniff.php b/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/KeywordSpacingSniff.php new file mode 100644 index 00000000..ffef7cb8 --- /dev/null +++ b/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/KeywordSpacingSniff.php @@ -0,0 +1,207 @@ + string) + */ + protected $keywords = [ + 'const' => true, + 'function' => true, + ]; + + /** + * Returns an array of tokens this sniff wants to listen for. + * + * @since 1.1.0 + * + * @return array + */ + public function register() + { + return [\T_USE]; + } + + /** + * Processes this test, when one of its tokens is encountered. + * + * @since 1.1.0 + * + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in the + * stack passed in $tokens. + * + * @return void + */ + public function process(File $phpcsFile, $stackPtr) + { + if (UseStatements::isImportUse($phpcsFile, $stackPtr) === false) { + // Trait or closure use statement. + return; + } + + $tokens = $phpcsFile->getTokens(); + $endOfStatement = $phpcsFile->findNext([\T_SEMICOLON, \T_CLOSE_TAG], ($stackPtr + 1)); + if ($endOfStatement === false) { + // Live coding or parse error. + return; + } + + // Check the spacing after the `use` keyword. + $this->checkSpacingAfterKeyword($phpcsFile, $stackPtr, $tokens[$stackPtr]['content']); + + // Check the spacing before and after each `as` keyword. + $current = $stackPtr; + do { + $current = $phpcsFile->findNext(\T_AS, ($current + 1), $endOfStatement); + if ($current === false) { + break; + } + + // Prevent false positives when "as" is used within a "name". + if (isset(Tokens::$emptyTokens[$tokens[($current - 1)]['code']]) === true) { + $this->checkSpacingBeforeKeyword($phpcsFile, $current, $tokens[$current]['content']); + $this->checkSpacingAfterKeyword($phpcsFile, $current, $tokens[$current]['content']); + } + } while (true); + + /* + * Check the spacing after `function` and `const` keywords. + */ + $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); + if (isset($this->keywords[\strtolower($tokens[$nextNonEmpty]['content'])]) === true) { + // Keyword found at start of statement, applies to whole statement. + $this->checkSpacingAfterKeyword($phpcsFile, $nextNonEmpty, $tokens[$nextNonEmpty]['content']); + return; + } + + // This may still be a group use statement with function/const substatements. + $openGroup = $phpcsFile->findNext(\T_OPEN_USE_GROUP, ($stackPtr + 1), $endOfStatement); + if ($openGroup === false) { + // Not a group use statement. + return; + } + + $closeGroup = $phpcsFile->findNext(\T_CLOSE_USE_GROUP, ($openGroup + 1), $endOfStatement); + + $current = $openGroup; + do { + $current = $phpcsFile->findNext(Tokens::$emptyTokens, ($current + 1), $closeGroup, true); + if ($current === false) { + return; + } + + if (isset($this->keywords[\strtolower($tokens[$current]['content'])]) === true) { + $this->checkSpacingAfterKeyword($phpcsFile, $current, $tokens[$current]['content']); + } + + // We're within the use group, so find the next comma. + $current = $phpcsFile->findNext(\T_COMMA, ($current + 1), $closeGroup); + } while ($current !== false); + } + + /** + * Check the spacing before a found keyword. + * + * @since 1.1.0 + * + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the keyword in the token stack. + * @param string $content The keyword as found. + * + * @return void + */ + public function checkSpacingBeforeKeyword(File $phpcsFile, $stackPtr, $content) + { + $contentLC = \strtolower($content); + $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); + + SpacesFixer::checkAndFix( + $phpcsFile, + $stackPtr, + $prevNonEmpty, + 1, // Expected spaces. + 'Expected %s before the "' . $contentLC . '" keyword. Found: %s', + 'SpaceBefore' . \ucfirst($contentLC), + 'error', + 0, // Severity. + \sprintf(self::METRIC_NAME_BEFORE, $contentLC) + ); + } + + /** + * Check the spacing after a found keyword. + * + * @since 1.1.0 + * + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the keyword in the token stack. + * @param string $content The keyword as found. + * + * @return void + */ + public function checkSpacingAfterKeyword(File $phpcsFile, $stackPtr, $content) + { + $contentLC = \strtolower($content); + $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); + + SpacesFixer::checkAndFix( + $phpcsFile, + $stackPtr, + $nextNonEmpty, + 1, // Expected spaces. + 'Expected %s after the "' . $contentLC . '" keyword. Found: %s', + 'SpaceAfter' . \ucfirst($contentLC), + 'error', + 0, // Severity. + \sprintf(self::METRIC_NAME_AFTER, $contentLC) + ); + } +} diff --git a/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/NoUselessAliasesSniff.php b/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/NoUselessAliasesSniff.php new file mode 100644 index 00000000..ebf7fe27 --- /dev/null +++ b/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/NoUselessAliasesSniff.php @@ -0,0 +1,164 @@ +findNext([\T_SEMICOLON, \T_CLOSE_TAG], ($stackPtr + 1)); + if ($endOfStatement === false) { + // Parse error or live coding. + return; + } + + $hasAliases = $phpcsFile->findNext(\T_AS, ($stackPtr + 1), $endOfStatement); + if ($hasAliases === false) { + // This use import statement does not alias anything, bow out. + return; + } + + $useStatements = UseStatements::splitImportUseStatement($phpcsFile, $stackPtr); + if (\count($useStatements, \COUNT_RECURSIVE) <= 3) { + // No statements found. Shouldn't be possible, but still. Bow out. + return; + } + + $tokens = $phpcsFile->getTokens(); + + // Collect all places where aliases are used in this use statement. + $aliasPtrs = []; + $currentAs = $hasAliases; + do { + $aliasPtr = $phpcsFile->findNext(Tokens::$emptyTokens, ($currentAs + 1), null, true); + if ($aliasPtr !== false && $tokens[$aliasPtr]['code'] === \T_STRING) { + $aliasPtrs[$currentAs] = $aliasPtr; + } + + $currentAs = $phpcsFile->findNext(\T_AS, ($currentAs + 1), $endOfStatement); + } while ($currentAs !== false); + + // Now check the names in each use statement for useless aliases. + foreach ($useStatements as $type => $statements) { + foreach ($statements as $alias => $fqName) { + $unqualifiedName = \ltrim(\substr($fqName, \strrpos($fqName, '\\')), '\\'); + + $uselessAlias = false; + if ($type === 'const') { + // Do a case-sensitive comparison for constants. + if ($unqualifiedName === $alias) { + $uselessAlias = true; + } + } elseif (NamingConventions::isEqual($unqualifiedName, $alias)) { + $uselessAlias = true; + } + + if ($uselessAlias === false) { + continue; + } + + // Now check if this is actually used as an alias or just the actual name. + foreach ($aliasPtrs as $asPtr => $aliasPtr) { + if ($tokens[$aliasPtr]['content'] !== $alias) { + continue; + } + + // Make sure this is really the right one. + $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($asPtr - 1), null, true); + if ($tokens[$prev]['code'] !== \T_STRING + || $tokens[$prev]['content'] !== $unqualifiedName + ) { + continue; + } + + $error = 'Useless alias "%s" found for import of "%s"'; + $code = 'Found'; + $data = [$alias, $fqName]; + + // Okay, so this is the one which should be flagged. + $hasComments = $phpcsFile->findNext(Tokens::$commentTokens, ($prev + 1), $aliasPtr); + if ($hasComments !== false) { + // Don't auto-fix if there are comments. + $phpcsFile->addError($error, $aliasPtr, $code, $data); + break; + } + + $fix = $phpcsFile->addFixableError($error, $aliasPtr, $code, $data); + + if ($fix === true) { + $phpcsFile->fixer->beginChangeset(); + + for ($i = ($prev + 1); $i <= $aliasPtr; $i++) { + $phpcsFile->fixer->replaceToken($i, ''); + } + + $phpcsFile->fixer->endChangeset(); + } + + break; + } + } + } + } +} diff --git a/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/WhiteSpace/CommaSpacingSniff.php b/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/WhiteSpace/CommaSpacingSniff.php new file mode 100644 index 00000000..29e5b335 --- /dev/null +++ b/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/WhiteSpace/CommaSpacingSniff.php @@ -0,0 +1,408 @@ +phpVersion) === false || \defined('PHP_CODESNIFFER_IN_TESTS')) { + // Set default value to prevent this code from running every time the sniff is triggered. + $this->phpVersion = 0; + + $phpVersion = Helper::getConfigData('php_version'); + if ($phpVersion !== null) { + $this->phpVersion = (int) $phpVersion; + } + } + + $this->processSpacingBefore($phpcsFile, $stackPtr); + $this->processSpacingAfter($phpcsFile, $stackPtr); + } + + /** + * Check the spacing before the comma. + * + * @since 1.1.0 + * + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. + * + * @return void + */ + protected function processSpacingBefore(File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + $prevNonWhitespace = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true); + $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); + $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); + + if ($prevNonWhitespace !== $prevNonEmpty + && $tokens[$prevNonEmpty]['code'] !== \T_COMMA + && $tokens[$prevNonEmpty]['line'] !== $tokens[$nextNonEmpty]['line'] + ) { + // Special case: comma after a trailing comment - the comma should be moved to before the comment. + $fix = $phpcsFile->addFixableError( + 'Comma found after comment, expected the comma after the end of the code', + $stackPtr, + 'CommaAfterComment' + ); + + if ($fix === true) { + $phpcsFile->fixer->beginChangeset(); + + $phpcsFile->fixer->replaceToken($stackPtr, ''); + $phpcsFile->fixer->addContent($prevNonEmpty, ','); + + // Clean up potential trailing whitespace left behind, but don't remove blank lines. + $nextNonWhitespace = $phpcsFile->findNext(\T_WHITESPACE, ($stackPtr + 1), null, true); + if ($tokens[($stackPtr - 1)]['code'] === \T_WHITESPACE + && $tokens[($stackPtr - 1)]['line'] === $tokens[$stackPtr]['line'] + && $tokens[$stackPtr]['line'] !== $tokens[$nextNonWhitespace]['line'] + ) { + $phpcsFile->fixer->replaceToken(($stackPtr - 1), ''); + } + + $phpcsFile->fixer->endChangeset(); + } + return; + } + + if ($tokens[$prevNonWhitespace]['code'] === \T_COMMA) { + // This must be a list assignment with ignored items. Ignore. + return; + } + + if (isset(Tokens::$blockOpeners[$tokens[$prevNonWhitespace]['code']]) === true + || $tokens[$prevNonWhitespace]['code'] === \T_OPEN_SHORT_ARRAY + || $tokens[$prevNonWhitespace]['code'] === \T_OPEN_USE_GROUP + ) { + // Should only realistically be possible for lists. Leave for a block brace spacing sniff to sort out. + return; + } + + $expectedSpaces = 0; + + if ($tokens[$prevNonEmpty]['code'] === \T_END_HEREDOC + || $tokens[$prevNonEmpty]['code'] === \T_END_NOWDOC + ) { + /* + * If php_version is explicitly set to PHP < 7.3, enforce a new line between the closer and the comma. + * + * If php_version is *not* explicitly set, let the indent be leading and only enforce + * a new line between the closer and the comma when this is an old-style heredoc/nowdoc. + */ + if ($this->phpVersion !== 0 && $this->phpVersion < 70300) { + $expectedSpaces = 'newline'; + } + + if ($this->phpVersion === 0 + && \ltrim($tokens[$prevNonEmpty]['content']) === $tokens[$prevNonEmpty]['content'] + ) { + $expectedSpaces = 'newline'; + } + } + + $error = 'Expected %1$s between "' . $this->escapePlaceholders($tokens[$prevNonWhitespace]['content']) + . '" and the comma. Found: %2$s'; + $codeSuffix = $this->getSuffix($phpcsFile, $stackPtr); + $metricSuffix = $this->codeSuffixToMetric($codeSuffix); + + SpacesFixer::checkAndFix( + $phpcsFile, + $stackPtr, + $prevNonWhitespace, + $expectedSpaces, + $error, + 'SpaceBefore' . $codeSuffix, + 'error', + 0, + self::METRIC_NAME_BEFORE . $metricSuffix + ); + } + + /** + * Check the spacing after the comma. + * + * @since 1.1.0 + * + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. + * + * @return void + */ + protected function processSpacingAfter(File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + $nextNonWhitespace = $phpcsFile->findNext(\T_WHITESPACE, ($stackPtr + 1), null, true); + if ($nextNonWhitespace === false) { + // Live coding/parse error. Ignore. + return; + } + + if ($tokens[$nextNonWhitespace]['code'] === \T_COMMA) { + // This must be a list assignment with ignored items. Ignore. + return; + } + + if ($tokens[$nextNonWhitespace]['code'] === \T_CLOSE_CURLY_BRACKET + || $tokens[$nextNonWhitespace]['code'] === \T_CLOSE_SQUARE_BRACKET + || $tokens[$nextNonWhitespace]['code'] === \T_CLOSE_PARENTHESIS + || $tokens[$nextNonWhitespace]['code'] === \T_CLOSE_SHORT_ARRAY + || $tokens[$nextNonWhitespace]['code'] === \T_CLOSE_USE_GROUP + ) { + // Ignore. Leave for a block spacing sniff to sort out. + return; + } + + $nextToken = $tokens[($stackPtr + 1)]; + + $error = 'Expected %1$s between the comma and "' + . $this->escapePlaceholders($tokens[$nextNonWhitespace]['content']) . '". Found: %2$s'; + + $codeSuffix = $this->getSuffix($phpcsFile, $stackPtr); + $metricSuffix = $this->codeSuffixToMetric($codeSuffix); + + if ($nextToken['code'] === \T_WHITESPACE) { + if ($nextToken['content'] === ' ') { + $phpcsFile->recordMetric($stackPtr, self::METRIC_NAME_AFTER . $metricSuffix, '1 space'); + return; + } + + // Note: this check allows for trailing whitespace between the comma and a new line char. + // The trailing whitespace is not the concern of this sniff. + if (\ltrim($nextToken['content'], ' ') === $phpcsFile->eolChar) { + $phpcsFile->recordMetric($stackPtr, self::METRIC_NAME_AFTER . $metricSuffix, 'a new line'); + return; + } + + $errorCode = 'TooMuchSpaceAfter' . $codeSuffix; + + $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); + if (isset(Tokens::$commentTokens[$tokens[$nextNonWhitespace]['code']]) === true + && ($nextNonEmpty === false || $tokens[$stackPtr]['line'] !== $tokens[$nextNonEmpty]['line']) + ) { + // Separate error code to allow for aligning trailing comments. + $errorCode = 'TooMuchSpaceAfterCommaBeforeTrailingComment'; + } + + SpacesFixer::checkAndFix( + $phpcsFile, + $stackPtr, + $nextNonWhitespace, + 1, + $error, + $errorCode, + 'error', + 0, + self::METRIC_NAME_AFTER . $metricSuffix + ); + return; + } + + SpacesFixer::checkAndFix( + $phpcsFile, + $stackPtr, + $nextNonWhitespace, + 1, + $error, + 'NoSpaceAfter' . $codeSuffix, + 'error', + 0, + self::METRIC_NAME_AFTER . $metricSuffix + ); + } + + /** + * Escape arbitrary token content for *printf() placeholders. + * + * @since 1.1.0 + * + * @param string $text Arbitrary text string. + * + * @return string + */ + private function escapePlaceholders($text) + { + return \preg_replace('`(?:^|[^%])(%)(?:[^%]|$)`', '%%', \trim($text)); + } + + /** + * Retrieve a text string for use as a suffix to an error code. + * + * This allows for modular error codes, which in turn allow for selectively excluding + * error codes. + * + * {@internal Closure use will be parentheses owner in PHPCS 4.x, this code will + * need an update for that in due time.} + * + * @since 1.1.0 + * + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. + * + * @return string + */ + private function getSuffix($phpcsFile, $stackPtr) + { + $opener = Parentheses::getLastOpener($phpcsFile, $stackPtr); + if ($opener === false) { + return ''; + } + + $tokens = $phpcsFile->getTokens(); + + $owner = Parentheses::getOwner($phpcsFile, $opener); + if ($owner !== false) { + switch ($tokens[$owner]['code']) { + case \T_FUNCTION: + case \T_CLOSURE: + case \T_FN: + return 'InFunctionDeclaration'; + + case \T_DECLARE: + return 'InDeclare'; + + case \T_ANON_CLASS: + case \T_ISSET: + case \T_UNSET: + return 'InFunctionCall'; + + // Long array, long list, isset, unset, empty, exit, eval, control structures. + default: + return ''; + } + } + + $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($opener - 1), null, true); + + if (isset(Collections::nameTokens()[$tokens[$prevNonEmpty]['code']]) === true) { + return 'InFunctionCall'; + } + + switch ($tokens[$prevNonEmpty]['code']) { + case \T_USE: + return 'InClosureUse'; + + case \T_VARIABLE: + case \T_SELF: + case \T_STATIC: + case \T_PARENT: + return 'InFunctionCall'; + + default: + return ''; + } + } + + /** + * Transform a suffix for an error code into a suffix for a metric. + * + * @since 1.1.0 + * + * @param string $suffix Error code suffix. + * + * @return string + */ + private function codeSuffixToMetric($suffix) + { + return \strtolower(\preg_replace('`([A-Z])`', ' $1', $suffix)); + } +} diff --git a/vendor/phpcsstandards/phpcsextra/composer.json b/vendor/phpcsstandards/phpcsextra/composer.json index 9e56a009..f4bbf2b9 100644 --- a/vendor/phpcsstandards/phpcsextra/composer.json +++ b/vendor/phpcsstandards/phpcsextra/composer.json @@ -22,7 +22,7 @@ "require" : { "php" : ">=5.4", "squizlabs/php_codesniffer" : "^3.7.1", - "phpcsstandards/phpcsutils" : "^1.0.6" + "phpcsstandards/phpcsutils" : "^1.0.8" }, "require-dev" : { "php-parallel-lint/php-parallel-lint": "^1.3.2", diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.1.inc b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.1.inc index b143fb4c..a2d3ed20 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.1.inc +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.1.inc @@ -1,18 +1,18 @@ - - - - - -group('a.id, - uc.name, - ag.title, - ua.name' - ); -} + + + + + +group('a.id, + uc.name, + ag.title, + ua.name' + ); +} diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.2.inc b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.2.inc index 260d7fd2..3723b5ad 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.2.inc +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.2.inc @@ -1,5 +1,5 @@ - - - -
...more HTML...
- + + + +
...more HTML...
+ diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.css b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.css index c182ac4d..a8c96255 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.css +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.css @@ -1,3 +1,3 @@ -#login-container { - margin-left: -225px; -} +#login-container { + margin-left: -225px; +} diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.js b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.js index 02600992..49c58d8e 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.js +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.js @@ -1,2 +1,2 @@ -alert('hi'); -alert('hi'); +alert('hi'); +alert('hi'); diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.inc index e3c10ad8..82fe5643 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.inc +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.inc @@ -1,227 +1,227 @@ - 'a', - 2 => 'b', - /* testMatchDefaultIsKeyword */ default => 'default', -}; - -$closure = /* testFnIsKeyword */ fn () => 'string'; - -function () { - /* testYieldIsKeyword */ yield $f; - /* testYieldFromIsKeyword */ yield from someFunction(); -}; - -/* testDeclareIsKeyword */ declare(ticks=1): -/* testEndDeclareIsKeyword */ enddeclare; - -if (true /* testAndIsKeyword */ and false /* testOrIsKeyword */ or null /* testXorIsKeyword */ xor 0) { - -} - -$anonymousClass = new /* testAnonymousClassIsKeyword */ class {}; -$anonymousClass2 = new class /* testExtendsInAnonymousClassIsKeyword */ extends SomeParent {}; -$anonymousClass3 = new class /* testImplementsInAnonymousClassIsKeyword */ implements SomeInterface {}; - -$instantiated1 = new /* testClassInstantiationParentIsKeyword */ parent(); -$instantiated2 = new /* testClassInstantiationSelfIsKeyword */ SELF; -$instantiated3 = new /* testClassInstantiationStaticIsKeyword */ static($param); - -class Foo extends /* testNamespaceInNameIsKeyword */ namespace\Exception -{} - -function /* testKeywordAfterFunctionShouldBeString */ eval() {} -function /* testKeywordAfterFunctionByRefShouldBeString */ &switch() {} + 'a', + 2 => 'b', + /* testMatchDefaultIsKeyword */ default => 'default', +}; + +$closure = /* testFnIsKeyword */ fn () => 'string'; + +function () { + /* testYieldIsKeyword */ yield $f; + /* testYieldFromIsKeyword */ yield from someFunction(); +}; + +/* testDeclareIsKeyword */ declare(ticks=1): +/* testEndDeclareIsKeyword */ enddeclare; + +if (true /* testAndIsKeyword */ and false /* testOrIsKeyword */ or null /* testXorIsKeyword */ xor 0) { + +} + +$anonymousClass = new /* testAnonymousClassIsKeyword */ class {}; +$anonymousClass2 = new class /* testExtendsInAnonymousClassIsKeyword */ extends SomeParent {}; +$anonymousClass3 = new class /* testImplementsInAnonymousClassIsKeyword */ implements SomeInterface {}; + +$instantiated1 = new /* testClassInstantiationParentIsKeyword */ parent(); +$instantiated2 = new /* testClassInstantiationSelfIsKeyword */ SELF; +$instantiated3 = new /* testClassInstantiationStaticIsKeyword */ static($param); + +class Foo extends /* testNamespaceInNameIsKeyword */ namespace\Exception +{} + +function /* testKeywordAfterFunctionShouldBeString */ eval() {} +function /* testKeywordAfterFunctionByRefShouldBeString */ &switch() {} diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.inc index 6ca7026d..dc98eb01 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.inc +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.inc @@ -1,63 +1,63 @@ - - - + + - * @copyright 2020 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; - -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; -use PHP_CodeSniffer\Util\Tokens; - -class StableCommentWhitespaceWinTest extends AbstractMethodUnitTest -{ - - - /** - * Test that comment tokenization with new lines at the end of the comment is stable. - * - * @param string $testMarker The comment prefacing the test. - * @param array $expectedTokens The tokenization expected. - * - * @dataProvider dataCommentTokenization - * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize - * - * @return void - */ - public function testCommentTokenization($testMarker, $expectedTokens) - { - $tokens = self::$phpcsFile->getTokens(); - $comment = $this->getTargetToken($testMarker, Tokens::$commentTokens); - - foreach ($expectedTokens as $key => $tokenInfo) { - $this->assertSame(constant($tokenInfo['type']), $tokens[$comment]['code']); - $this->assertSame($tokenInfo['type'], $tokens[$comment]['type']); - $this->assertSame($tokenInfo['content'], $tokens[$comment]['content']); - - ++$comment; - } - - }//end testCommentTokenization() - - - /** - * Data provider. - * - * @see testCommentTokenization() - * - * @return array - */ - public function dataCommentTokenization() - { - return [ - [ - '/* testSingleLineSlashComment */', - [ - [ - 'type' => 'T_COMMENT', - 'content' => '// Comment -', - ], - [ - 'type' => 'T_WHITESPACE', - 'content' => ' -', - ], - ], - ], - [ - '/* testSingleLineSlashCommentTrailing */', - [ - [ - 'type' => 'T_COMMENT', - 'content' => '// Comment -', - ], - [ - 'type' => 'T_WHITESPACE', - 'content' => ' -', - ], - ], - ], - [ - '/* testSingleLineSlashAnnotation */', - [ - [ - 'type' => 'T_PHPCS_DISABLE', - 'content' => '// phpcs:disable Stnd.Cat -', - ], - [ - 'type' => 'T_WHITESPACE', - 'content' => ' -', - ], - ], - ], - [ - '/* testMultiLineSlashComment */', - [ - [ - 'type' => 'T_COMMENT', - 'content' => '// Comment1 -', - ], - [ - 'type' => 'T_COMMENT', - 'content' => '// Comment2 -', - ], - [ - 'type' => 'T_COMMENT', - 'content' => '// Comment3 -', - ], - [ - 'type' => 'T_WHITESPACE', - 'content' => ' -', - ], - ], - ], - [ - '/* testMultiLineSlashCommentWithIndent */', - [ - [ - 'type' => 'T_COMMENT', - 'content' => '// Comment1 -', - ], - [ - 'type' => 'T_WHITESPACE', - 'content' => ' ', - ], - [ - 'type' => 'T_COMMENT', - 'content' => '// Comment2 -', - ], - [ - 'type' => 'T_WHITESPACE', - 'content' => ' ', - ], - [ - 'type' => 'T_COMMENT', - 'content' => '// Comment3 -', - ], - [ - 'type' => 'T_WHITESPACE', - 'content' => ' -', - ], - ], - ], - [ - '/* testMultiLineSlashCommentWithAnnotationStart */', - [ - [ - 'type' => 'T_PHPCS_IGNORE', - 'content' => '// phpcs:ignore Stnd.Cat -', - ], - [ - 'type' => 'T_COMMENT', - 'content' => '// Comment2 -', - ], - [ - 'type' => 'T_COMMENT', - 'content' => '// Comment3 -', - ], - [ - 'type' => 'T_WHITESPACE', - 'content' => ' -', - ], - ], - ], - [ - '/* testMultiLineSlashCommentWithAnnotationMiddle */', - [ - [ - 'type' => 'T_COMMENT', - 'content' => '// Comment1 -', - ], - [ - 'type' => 'T_PHPCS_IGNORE', - 'content' => '// @phpcs:ignore Stnd.Cat -', - ], - [ - 'type' => 'T_COMMENT', - 'content' => '// Comment3 -', - ], - [ - 'type' => 'T_WHITESPACE', - 'content' => ' -', - ], - ], - ], - [ - '/* testMultiLineSlashCommentWithAnnotationEnd */', - [ - [ - 'type' => 'T_COMMENT', - 'content' => '// Comment1 -', - ], - [ - 'type' => 'T_COMMENT', - 'content' => '// Comment2 -', - ], - [ - 'type' => 'T_PHPCS_IGNORE', - 'content' => '// phpcs:ignore Stnd.Cat -', - ], - [ - 'type' => 'T_WHITESPACE', - 'content' => ' -', - ], - ], - ], - [ - '/* testSingleLineSlashCommentNoNewLineAtEnd */', - [ - [ - 'type' => 'T_COMMENT', - 'content' => '// Slash ', - ], - [ - 'type' => 'T_CLOSE_TAG', - 'content' => '?> -', - ], - ], - ], - [ - '/* testSingleLineHashComment */', - [ - [ - 'type' => 'T_COMMENT', - 'content' => '# Comment -', - ], - [ - 'type' => 'T_WHITESPACE', - 'content' => ' -', - ], - ], - ], - [ - '/* testSingleLineHashCommentTrailing */', - [ - [ - 'type' => 'T_COMMENT', - 'content' => '# Comment -', - ], - [ - 'type' => 'T_WHITESPACE', - 'content' => ' -', - ], - ], - ], - [ - '/* testMultiLineHashComment */', - [ - [ - 'type' => 'T_COMMENT', - 'content' => '# Comment1 -', - ], - [ - 'type' => 'T_COMMENT', - 'content' => '# Comment2 -', - ], - [ - 'type' => 'T_COMMENT', - 'content' => '# Comment3 -', - ], - [ - 'type' => 'T_WHITESPACE', - 'content' => ' -', - ], - ], - ], - [ - '/* testMultiLineHashCommentWithIndent */', - [ - [ - 'type' => 'T_COMMENT', - 'content' => '# Comment1 -', - ], - [ - 'type' => 'T_WHITESPACE', - 'content' => ' ', - ], - [ - 'type' => 'T_COMMENT', - 'content' => '# Comment2 -', - ], - [ - 'type' => 'T_WHITESPACE', - 'content' => ' ', - ], - [ - 'type' => 'T_COMMENT', - 'content' => '# Comment3 -', - ], - [ - 'type' => 'T_WHITESPACE', - 'content' => ' -', - ], - ], - ], - [ - '/* testSingleLineHashCommentNoNewLineAtEnd */', - [ - [ - 'type' => 'T_COMMENT', - 'content' => '# Hash ', - ], - [ - 'type' => 'T_CLOSE_TAG', - 'content' => '?> -', - ], - ], - ], - [ - '/* testCommentAtEndOfFile */', - [ - [ - 'type' => 'T_COMMENT', - 'content' => '/* Comment', - ], - ], - ], - ]; - - }//end dataCommentTokenization() - - -}//end class + + * @copyright 2020 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Tokenizer; + +use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +use PHP_CodeSniffer\Util\Tokens; + +class StableCommentWhitespaceWinTest extends AbstractMethodUnitTest +{ + + + /** + * Test that comment tokenization with new lines at the end of the comment is stable. + * + * @param string $testMarker The comment prefacing the test. + * @param array $expectedTokens The tokenization expected. + * + * @dataProvider dataCommentTokenization + * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize + * + * @return void + */ + public function testCommentTokenization($testMarker, $expectedTokens) + { + $tokens = self::$phpcsFile->getTokens(); + $comment = $this->getTargetToken($testMarker, Tokens::$commentTokens); + + foreach ($expectedTokens as $key => $tokenInfo) { + $this->assertSame(constant($tokenInfo['type']), $tokens[$comment]['code']); + $this->assertSame($tokenInfo['type'], $tokens[$comment]['type']); + $this->assertSame($tokenInfo['content'], $tokens[$comment]['content']); + + ++$comment; + } + + }//end testCommentTokenization() + + + /** + * Data provider. + * + * @see testCommentTokenization() + * + * @return array + */ + public function dataCommentTokenization() + { + return [ + [ + '/* testSingleLineSlashComment */', + [ + [ + 'type' => 'T_COMMENT', + 'content' => '// Comment +', + ], + [ + 'type' => 'T_WHITESPACE', + 'content' => ' +', + ], + ], + ], + [ + '/* testSingleLineSlashCommentTrailing */', + [ + [ + 'type' => 'T_COMMENT', + 'content' => '// Comment +', + ], + [ + 'type' => 'T_WHITESPACE', + 'content' => ' +', + ], + ], + ], + [ + '/* testSingleLineSlashAnnotation */', + [ + [ + 'type' => 'T_PHPCS_DISABLE', + 'content' => '// phpcs:disable Stnd.Cat +', + ], + [ + 'type' => 'T_WHITESPACE', + 'content' => ' +', + ], + ], + ], + [ + '/* testMultiLineSlashComment */', + [ + [ + 'type' => 'T_COMMENT', + 'content' => '// Comment1 +', + ], + [ + 'type' => 'T_COMMENT', + 'content' => '// Comment2 +', + ], + [ + 'type' => 'T_COMMENT', + 'content' => '// Comment3 +', + ], + [ + 'type' => 'T_WHITESPACE', + 'content' => ' +', + ], + ], + ], + [ + '/* testMultiLineSlashCommentWithIndent */', + [ + [ + 'type' => 'T_COMMENT', + 'content' => '// Comment1 +', + ], + [ + 'type' => 'T_WHITESPACE', + 'content' => ' ', + ], + [ + 'type' => 'T_COMMENT', + 'content' => '// Comment2 +', + ], + [ + 'type' => 'T_WHITESPACE', + 'content' => ' ', + ], + [ + 'type' => 'T_COMMENT', + 'content' => '// Comment3 +', + ], + [ + 'type' => 'T_WHITESPACE', + 'content' => ' +', + ], + ], + ], + [ + '/* testMultiLineSlashCommentWithAnnotationStart */', + [ + [ + 'type' => 'T_PHPCS_IGNORE', + 'content' => '// phpcs:ignore Stnd.Cat +', + ], + [ + 'type' => 'T_COMMENT', + 'content' => '// Comment2 +', + ], + [ + 'type' => 'T_COMMENT', + 'content' => '// Comment3 +', + ], + [ + 'type' => 'T_WHITESPACE', + 'content' => ' +', + ], + ], + ], + [ + '/* testMultiLineSlashCommentWithAnnotationMiddle */', + [ + [ + 'type' => 'T_COMMENT', + 'content' => '// Comment1 +', + ], + [ + 'type' => 'T_PHPCS_IGNORE', + 'content' => '// @phpcs:ignore Stnd.Cat +', + ], + [ + 'type' => 'T_COMMENT', + 'content' => '// Comment3 +', + ], + [ + 'type' => 'T_WHITESPACE', + 'content' => ' +', + ], + ], + ], + [ + '/* testMultiLineSlashCommentWithAnnotationEnd */', + [ + [ + 'type' => 'T_COMMENT', + 'content' => '// Comment1 +', + ], + [ + 'type' => 'T_COMMENT', + 'content' => '// Comment2 +', + ], + [ + 'type' => 'T_PHPCS_IGNORE', + 'content' => '// phpcs:ignore Stnd.Cat +', + ], + [ + 'type' => 'T_WHITESPACE', + 'content' => ' +', + ], + ], + ], + [ + '/* testSingleLineSlashCommentNoNewLineAtEnd */', + [ + [ + 'type' => 'T_COMMENT', + 'content' => '// Slash ', + ], + [ + 'type' => 'T_CLOSE_TAG', + 'content' => '?> +', + ], + ], + ], + [ + '/* testSingleLineHashComment */', + [ + [ + 'type' => 'T_COMMENT', + 'content' => '# Comment +', + ], + [ + 'type' => 'T_WHITESPACE', + 'content' => ' +', + ], + ], + ], + [ + '/* testSingleLineHashCommentTrailing */', + [ + [ + 'type' => 'T_COMMENT', + 'content' => '# Comment +', + ], + [ + 'type' => 'T_WHITESPACE', + 'content' => ' +', + ], + ], + ], + [ + '/* testMultiLineHashComment */', + [ + [ + 'type' => 'T_COMMENT', + 'content' => '# Comment1 +', + ], + [ + 'type' => 'T_COMMENT', + 'content' => '# Comment2 +', + ], + [ + 'type' => 'T_COMMENT', + 'content' => '# Comment3 +', + ], + [ + 'type' => 'T_WHITESPACE', + 'content' => ' +', + ], + ], + ], + [ + '/* testMultiLineHashCommentWithIndent */', + [ + [ + 'type' => 'T_COMMENT', + 'content' => '# Comment1 +', + ], + [ + 'type' => 'T_WHITESPACE', + 'content' => ' ', + ], + [ + 'type' => 'T_COMMENT', + 'content' => '# Comment2 +', + ], + [ + 'type' => 'T_WHITESPACE', + 'content' => ' ', + ], + [ + 'type' => 'T_COMMENT', + 'content' => '# Comment3 +', + ], + [ + 'type' => 'T_WHITESPACE', + 'content' => ' +', + ], + ], + ], + [ + '/* testSingleLineHashCommentNoNewLineAtEnd */', + [ + [ + 'type' => 'T_COMMENT', + 'content' => '# Hash ', + ], + [ + 'type' => 'T_CLOSE_TAG', + 'content' => '?> +', + ], + ], + ], + [ + '/* testCommentAtEndOfFile */', + [ + [ + 'type' => 'T_COMMENT', + 'content' => '/* Comment', + ], + ], + ], + ]; + + }//end dataCommentTokenization() + + +}//end class diff --git a/vendor/symfony/deprecation-contracts/.gitignore b/vendor/symfony/deprecation-contracts/.gitignore new file mode 100644 index 00000000..c49a5d8d --- /dev/null +++ b/vendor/symfony/deprecation-contracts/.gitignore @@ -0,0 +1,3 @@ +vendor/ +composer.lock +phpunit.xml diff --git a/vendor/symfony/deprecation-contracts/LICENSE b/vendor/symfony/deprecation-contracts/LICENSE index 0ed3a246..406242ff 100644 --- a/vendor/symfony/deprecation-contracts/LICENSE +++ b/vendor/symfony/deprecation-contracts/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2020-present Fabien Potencier +Copyright (c) 2020-2022 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/symfony/deprecation-contracts/README.md b/vendor/symfony/deprecation-contracts/README.md index 9814864c..4957933a 100644 --- a/vendor/symfony/deprecation-contracts/README.md +++ b/vendor/symfony/deprecation-contracts/README.md @@ -22,5 +22,5 @@ trigger_deprecation('symfony/blockchain', '8.9', 'Using "%s" is deprecated, use This will generate the following message: `Since symfony/blockchain 8.9: Using "bitcoin" is deprecated, use "fabcoin" instead.` -While not recommended, the deprecation notices can be completely ignored by declaring an empty +While not necessarily recommended, the deprecation notices can be completely ignored by declaring an empty `function trigger_deprecation() {}` in your application. diff --git a/vendor/symfony/deprecation-contracts/composer.json b/vendor/symfony/deprecation-contracts/composer.json index c6d02d87..1c1b4ba0 100644 --- a/vendor/symfony/deprecation-contracts/composer.json +++ b/vendor/symfony/deprecation-contracts/composer.json @@ -15,7 +15,7 @@ } ], "require": { - "php": ">=8.1" + "php": ">=8.0.2" }, "autoload": { "files": [ @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-main": "3.4-dev" + "dev-main": "3.0-dev" }, "thanks": { "name": "symfony/contracts", diff --git a/vendor/symfony/yaml/CHANGELOG.md b/vendor/symfony/yaml/CHANGELOG.md index 0c2021f4..b9561b2a 100644 --- a/vendor/symfony/yaml/CHANGELOG.md +++ b/vendor/symfony/yaml/CHANGELOG.md @@ -1,22 +1,6 @@ CHANGELOG ========= -6.3 ---- - - * Add support to dump int keys as strings by using the `Yaml::DUMP_NUMERIC_KEY_AS_STRING` flag - -6.2 ---- - - * Add support for `!php/enum` and `!php/enum *->value` - * Deprecate the `!php/const:` tag in key which will be replaced by the `!php/const` tag (without the colon) since 3.4 - -6.1 ---- - - * In cases where it will likely improve readability, strings containing single quotes will be double-quoted - 5.4 --- diff --git a/vendor/symfony/yaml/Command/LintCommand.php b/vendor/symfony/yaml/Command/LintCommand.php index 95352ac1..1412360c 100644 --- a/vendor/symfony/yaml/Command/LintCommand.php +++ b/vendor/symfony/yaml/Command/LintCommand.php @@ -36,7 +36,7 @@ #[AsCommand(name: 'lint:yaml', description: 'Lint a YAML file and outputs encountered errors')] class LintCommand extends Command { - private Parser $parser; + private $parser; private ?string $format = null; private bool $displayCorrectFiles; private ?\Closure $directoryIteratorProvider; @@ -46,18 +46,18 @@ public function __construct(string $name = null, callable $directoryIteratorProv { parent::__construct($name); - $this->directoryIteratorProvider = null === $directoryIteratorProvider ? null : $directoryIteratorProvider(...); - $this->isReadableProvider = null === $isReadableProvider ? null : $isReadableProvider(...); + $this->directoryIteratorProvider = null === $directoryIteratorProvider || $directoryIteratorProvider instanceof \Closure ? $directoryIteratorProvider : \Closure::fromCallable($directoryIteratorProvider); + $this->isReadableProvider = null === $isReadableProvider || $isReadableProvider instanceof \Closure ? $isReadableProvider : \Closure::fromCallable($isReadableProvider); } /** - * @return void + * {@inheritdoc} */ protected function configure() { $this ->addArgument('filename', InputArgument::IS_ARRAY, 'A file, a directory or "-" for reading from STDIN') - ->addOption('format', null, InputOption::VALUE_REQUIRED, sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions()))) + ->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format') ->addOption('exclude', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Path(s) to exclude') ->addOption('parse-tags', null, InputOption::VALUE_NEGATABLE, 'Parse custom tags', null) ->setHelp(<<format = $input->getOption('format'); $flags = $input->getOption('parse-tags'); + if ('github' === $this->format && !class_exists(GithubActionReporter::class)) { + throw new \InvalidArgumentException('The "github" format is only available since "symfony/console" >= 5.3.'); + } + if (null === $this->format) { // Autodetect format according to CI environment $this->format = class_exists(GithubActionReporter::class) && GithubActionReporter::isGithubActionEnvironment() ? 'github' : 'txt'; @@ -127,7 +131,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int return $this->display($io, $filesInfo); } - private function validate(string $content, int $flags, string $file = null): array + private function validate(string $content, int $flags, string $file = null) { $prevErrorHandler = set_error_handler(function ($level, $message, $file, $line) use (&$prevErrorHandler) { if (\E_USER_DEPRECATED === $level) { @@ -150,12 +154,16 @@ private function validate(string $content, int $flags, string $file = null): arr private function display(SymfonyStyle $io, array $files): int { - return match ($this->format) { - 'txt' => $this->displayTxt($io, $files), - 'json' => $this->displayJson($io, $files), - 'github' => $this->displayTxt($io, $files, true), - default => throw new InvalidArgumentException(sprintf('Supported formats are "%s".', implode('", "', $this->getAvailableFormatOptions()))), - }; + switch ($this->format) { + case 'txt': + return $this->displayTxt($io, $files); + case 'json': + return $this->displayJson($io, $files); + case 'github': + return $this->displayTxt($io, $files, true); + default: + throw new InvalidArgumentException(sprintf('The format "%s" is not supported.', $this->format)); + } } private function displayTxt(SymfonyStyle $io, array $filesInfo, bool $errorAsGithubAnnotations = false): int @@ -176,7 +184,7 @@ private function displayTxt(SymfonyStyle $io, array $filesInfo, bool $errorAsGit $io->text(' ERROR '.($info['file'] ? sprintf(' in %s', $info['file']) : '')); $io->text(sprintf(' >> %s', $info['message'])); - if (str_contains($info['message'], 'PARSE_CUSTOM_TAGS')) { + if (false !== strpos($info['message'], 'PARSE_CUSTOM_TAGS')) { $suggestTagOption = true; } @@ -205,7 +213,7 @@ private function displayJson(SymfonyStyle $io, array $filesInfo): int ++$errors; } - if (isset($v['message']) && str_contains($v['message'], 'PARSE_CUSTOM_TAGS')) { + if (isset($v['message']) && false !== strpos($v['message'], 'PARSE_CUSTOM_TAGS')) { $v['message'] .= ' Use the --parse-tags option if you want parse custom tags.'; } }); @@ -239,10 +247,12 @@ private function getParser(): Parser private function getDirectoryIterator(string $directory): iterable { - $default = fn ($directory) => new \RecursiveIteratorIterator( - new \RecursiveDirectoryIterator($directory, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS), - \RecursiveIteratorIterator::LEAVES_ONLY - ); + $default = function ($directory) { + return new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator($directory, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS), + \RecursiveIteratorIterator::LEAVES_ONLY + ); + }; if (null !== $this->directoryIteratorProvider) { return ($this->directoryIteratorProvider)($directory, $default); @@ -253,7 +263,9 @@ private function getDirectoryIterator(string $directory): iterable private function isReadable(string $fileOrDirectory): bool { - $default = is_readable(...); + $default = function ($fileOrDirectory) { + return is_readable($fileOrDirectory); + }; if (null !== $this->isReadableProvider) { return ($this->isReadableProvider)($fileOrDirectory, $default); @@ -265,12 +277,7 @@ private function isReadable(string $fileOrDirectory): bool public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void { if ($input->mustSuggestOptionValuesFor('format')) { - $suggestions->suggestValues($this->getAvailableFormatOptions()); + $suggestions->suggestValues(['txt', 'json', 'github']); } } - - private function getAvailableFormatOptions(): array - { - return ['txt', 'json', 'github']; - } } diff --git a/vendor/symfony/yaml/Dumper.php b/vendor/symfony/yaml/Dumper.php index 04646c5c..c7e78e76 100644 --- a/vendor/symfony/yaml/Dumper.php +++ b/vendor/symfony/yaml/Dumper.php @@ -66,12 +66,10 @@ public function dump(mixed $input, int $inline = 0, int $indent = 0, int $flags $output .= "\n"; } - if (\is_int($key) && Yaml::DUMP_NUMERIC_KEY_AS_STRING & $flags) { - $key = (string) $key; - } - - if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value) && str_contains($value, "\n") && !str_contains($value, "\r")) { - $blockIndentationIndicator = $this->getBlockIndentationIndicator($value); + if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value) && false !== strpos($value, "\n") && false === strpos($value, "\r")) { + // If the first line starts with a space character, the spec requires a blockIndicationIndicator + // http://www.yaml.org/spec/1.2/spec.html#id2793979 + $blockIndentationIndicator = (' ' === substr($value, 0, 1)) ? (string) $this->indentation : ''; if (isset($value[-2]) && "\n" === $value[-2] && "\n" === $value[-1]) { $blockChompingIndicator = '+'; @@ -97,8 +95,10 @@ public function dump(mixed $input, int $inline = 0, int $indent = 0, int $flags if ($value instanceof TaggedValue) { $output .= sprintf('%s%s !%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', $value->getTag()); - if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value->getValue()) && str_contains($value->getValue(), "\n") && !str_contains($value->getValue(), "\r\n")) { - $blockIndentationIndicator = $this->getBlockIndentationIndicator($value->getValue()); + if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value->getValue()) && false !== strpos($value->getValue(), "\n") && false === strpos($value->getValue(), "\r\n")) { + // If the first line starts with a space character, the spec requires a blockIndicationIndicator + // http://www.yaml.org/spec/1.2/spec.html#id2793979 + $blockIndentationIndicator = (' ' === substr($value->getValue(), 0, 1)) ? (string) $this->indentation : ''; $output .= sprintf(' |%s', $blockIndentationIndicator); foreach (explode("\n", $value->getValue()) as $row) { @@ -142,8 +142,10 @@ private function dumpTaggedValue(TaggedValue $value, int $inline, int $indent, i { $output = sprintf('%s!%s', $prefix ? $prefix.' ' : '', $value->getTag()); - if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value->getValue()) && str_contains($value->getValue(), "\n") && !str_contains($value->getValue(), "\r\n")) { - $blockIndentationIndicator = $this->getBlockIndentationIndicator($value->getValue()); + if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value->getValue()) && false !== strpos($value->getValue(), "\n") && false === strpos($value->getValue(), "\r\n")) { + // If the first line starts with a space character, the spec requires a blockIndicationIndicator + // http://www.yaml.org/spec/1.2/spec.html#id2793979 + $blockIndentationIndicator = (' ' === substr($value->getValue(), 0, 1)) ? (string) $this->indentation : ''; $output .= sprintf(' |%s', $blockIndentationIndicator); foreach (explode("\n", $value->getValue()) as $row) { @@ -159,20 +161,4 @@ private function dumpTaggedValue(TaggedValue $value, int $inline, int $indent, i return $output."\n".$this->dump($value->getValue(), $inline - 1, $indent, $flags); } - - private function getBlockIndentationIndicator(string $value): string - { - $lines = explode("\n", $value); - - // If the first line (that is neither empty nor contains only spaces) - // starts with a space character, the spec requires a block indentation indicator - // http://www.yaml.org/spec/1.2/spec.html#id2793979 - foreach ($lines as $line) { - if ('' !== trim($line, ' ')) { - return (' ' === substr($line, 0, 1)) ? (string) $this->indentation : ''; - } - } - - return ''; - } } diff --git a/vendor/symfony/yaml/Exception/ParseException.php b/vendor/symfony/yaml/Exception/ParseException.php index c1a77ad1..005470a3 100644 --- a/vendor/symfony/yaml/Exception/ParseException.php +++ b/vendor/symfony/yaml/Exception/ParseException.php @@ -51,8 +51,6 @@ public function getSnippet(): string /** * Sets the snippet of code near the error. - * - * @return void */ public function setSnippet(string $snippet) { @@ -73,8 +71,6 @@ public function getParsedFile(): string /** * Sets the filename where the error occurred. - * - * @return void */ public function setParsedFile(string $parsedFile) { @@ -93,8 +89,6 @@ public function getParsedLine(): int /** * Sets the line where the error occurred. - * - * @return void */ public function setParsedLine(int $parsedLine) { @@ -103,12 +97,12 @@ public function setParsedLine(int $parsedLine) $this->updateRepr(); } - private function updateRepr(): void + private function updateRepr() { $this->message = $this->rawMessage; $dot = false; - if (str_ends_with($this->message, '.')) { + if ('.' === substr($this->message, -1)) { $this->message = substr($this->message, 0, -1); $dot = true; } diff --git a/vendor/symfony/yaml/Inline.php b/vendor/symfony/yaml/Inline.php index c2a93bab..88508d5c 100644 --- a/vendor/symfony/yaml/Inline.php +++ b/vendor/symfony/yaml/Inline.php @@ -34,7 +34,7 @@ class Inline private static bool $objectForMap = false; private static bool $constantSupport = false; - public static function initialize(int $flags, int $parsedLineNumber = null, string $parsedFilename = null): void + public static function initialize(int $flags, int $parsedLineNumber = null, string $parsedFilename = null) { self::$exceptionOnInvalidType = (bool) (Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE & $flags); self::$objectSupport = (bool) (Yaml::PARSE_OBJECT & $flags); @@ -110,13 +110,9 @@ public static function dump(mixed $value, int $flags = 0): string return self::dumpNull($flags); case $value instanceof \DateTimeInterface: - return $value->format(match (true) { - !$length = \strlen(rtrim($value->format('u'), '0')) => 'c', - $length < 4 => 'Y-m-d\TH:i:s.vP', - default => 'Y-m-d\TH:i:s.uP', - }); + return $value->format('c'); case $value instanceof \UnitEnum: - return sprintf('!php/const %s::%s', $value::class, $value->name); + return sprintf('!php/const %s::%s', \get_class($value), $value->name); case \is_object($value): if ($value instanceof TaggedValue) { return '!'.$value->getTag().' '.self::dump($value->getValue(), $flags); @@ -127,7 +123,13 @@ public static function dump(mixed $value, int $flags = 0): string } if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \stdClass || $value instanceof \ArrayObject)) { - return self::dumpHashArray($value, $flags); + $output = []; + + foreach ($value as $key => $val) { + $output[] = sprintf('%s: %s', self::dump($key, $flags), self::dump($val, $flags)); + } + + return sprintf('{ %s }', implode(', ', $output)); } if (Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE & $flags) { @@ -156,7 +158,7 @@ public static function dump(mixed $value, int $flags = 0): string $repr = str_ireplace('INF', '.Inf', $repr); } elseif (floor($value) == $value && $repr == $value) { // Preserve float data type since storing a whole number will result in integer value. - if (!str_contains($repr, 'E')) { + if (false === strpos($repr, 'E')) { $repr = $repr.'.0'; } } @@ -175,14 +177,6 @@ public static function dump(mixed $value, int $flags = 0): string case Escaper::requiresDoubleQuoting($value): return Escaper::escapeWithDoubleQuotes($value); case Escaper::requiresSingleQuoting($value): - $singleQuoted = Escaper::escapeWithSingleQuotes($value); - if (!str_contains($value, "'")) { - return $singleQuoted; - } - // Attempt double-quoting the string instead to see if it's more efficient. - $doubleQuoted = Escaper::escapeWithDoubleQuotes($value); - - return \strlen($doubleQuoted) < \strlen($singleQuoted) ? $doubleQuoted : $singleQuoted; case Parser::preg_match('{^[0-9]+[_0-9]*$}', $value): case Parser::preg_match(self::getHexRegex(), $value): case Parser::preg_match(self::getTimestampRegex(), $value): @@ -230,23 +224,9 @@ private static function dumpArray(array $value, int $flags): string return sprintf('[%s]', implode(', ', $output)); } - return self::dumpHashArray($value, $flags); - } - - /** - * Dumps hash array to a YAML string. - * - * @param array|\ArrayObject|\stdClass $value The hash array to dump - * @param int $flags A bit field of Yaml::DUMP_* constants to customize the dumped YAML string - */ - private static function dumpHashArray(array|\ArrayObject|\stdClass $value, int $flags): string - { + // hash $output = []; foreach ($value as $key => $val) { - if (\is_int($key) && Yaml::DUMP_NUMERIC_KEY_AS_STRING & $flags) { - $key = (string) $key; - } - $output[] = sprintf('%s: %s', self::dump($key, $flags), self::dump($val, $flags)); } @@ -377,12 +357,12 @@ private static function parseSequence(string $sequence, int $flags, int &$i = 0, $value = self::parseScalar($sequence, $flags, [',', ']'], $i, null === $tag, $references, $isQuoted); // the value can be an array if a reference has been resolved to an array var - if (\is_string($value) && !$isQuoted && str_contains($value, ': ')) { + if (\is_string($value) && !$isQuoted && false !== strpos($value, ': ')) { // embedded mapping? try { $pos = 0; $value = self::parseMapping('{'.$value.'}', $flags, $pos, $references); - } catch (\InvalidArgumentException) { + } catch (\InvalidArgumentException $e) { // no, it's not } } @@ -444,7 +424,7 @@ private static function parseMapping(string $mapping, int $flags, int &$i = 0, a throw new ParseException('Missing mapping key.', self::$parsedLineNumber + 1, $mapping); } - if ('!php/const' === $key || '!php/enum' === $key) { + if ('!php/const' === $key) { $key .= ' '.self::parseScalar($mapping, $flags, [':'], $i, false); $key = self::evaluateScalar($key, $flags); } @@ -561,7 +541,7 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer $isQuotedString = false; $scalar = trim($scalar); - if (str_starts_with($scalar, '*')) { + if (0 === strpos($scalar, '*')) { if (false !== $pos = strpos($scalar, '#')) { $value = substr($scalar, 1, $pos - 2); } else { @@ -593,7 +573,7 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer return false; case '!' === $scalar[0]: switch (true) { - case str_starts_with($scalar, '!!str '): + case 0 === strpos($scalar, '!!str '): $s = (string) substr($scalar, 6); if (\in_array($s[0] ?? '', ['"', "'"], true)) { @@ -602,9 +582,9 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer } return $s; - case str_starts_with($scalar, '! '): + case 0 === strpos($scalar, '! '): return substr($scalar, 2); - case str_starts_with($scalar, '!php/object'): + case 0 === strpos($scalar, '!php/object'): if (self::$objectSupport) { if (!isset($scalar[12])) { throw new ParseException('Missing value for tag "!php/object".', self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); @@ -618,7 +598,7 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer } return null; - case str_starts_with($scalar, '!php/const'): + case 0 === strpos($scalar, '!php/const'): if (self::$constantSupport) { if (!isset($scalar[11])) { throw new ParseException('Missing value for tag "!php/const".', self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); @@ -636,43 +616,9 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer } return null; - case str_starts_with($scalar, '!php/enum'): - if (self::$constantSupport) { - if (!isset($scalar[11])) { - throw new ParseException('Missing value for tag "!php/enum".', self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); - } - - $i = 0; - $enum = self::parseScalar(substr($scalar, 10), 0, null, $i, false); - if ($useValue = str_ends_with($enum, '->value')) { - $enum = substr($enum, 0, -7); - } - if (!\defined($enum)) { - throw new ParseException(sprintf('The enum "%s" is not defined.', $enum), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); - } - - $value = \constant($enum); - - if (!$value instanceof \UnitEnum) { - throw new ParseException(sprintf('The string "%s" is not the name of a valid enum.', $enum), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); - } - if (!$useValue) { - return $value; - } - if (!$value instanceof \BackedEnum) { - throw new ParseException(sprintf('The enum "%s" defines no value next to its name.', $enum), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); - } - - return $value->value; - } - if (self::$exceptionOnInvalidType) { - throw new ParseException(sprintf('The string "%s" could not be parsed as an enum. Did you forget to pass the "Yaml::PARSE_CONSTANT" flag to the parser?', $scalar), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); - } - - return null; - case str_starts_with($scalar, '!!float '): + case 0 === strpos($scalar, '!!float '): return (float) substr($scalar, 8); - case str_starts_with($scalar, '!!binary '): + case 0 === strpos($scalar, '!!binary '): return self::evaluateBinaryScalar(substr($scalar, 9)); } @@ -710,21 +656,17 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer return (float) str_replace('_', '', $scalar); case Parser::preg_match(self::getTimestampRegex(), $scalar): // When no timezone is provided in the parsed date, YAML spec says we must assume UTC. - $time = new \DateTimeImmutable($scalar, new \DateTimeZone('UTC')); + $time = new \DateTime($scalar, new \DateTimeZone('UTC')); if (Yaml::PARSE_DATETIME & $flags) { return $time; } - if ('' !== rtrim($time->format('u'), '0')) { - return (float) $time->format('U.u'); - } - try { if (false !== $scalar = $time->getTimestamp()) { return $scalar; } - } catch (\ValueError) { + } catch (\ValueError $e) { // no-op } @@ -752,7 +694,7 @@ private static function parseTag(string $value, int &$i, int $flags): ?string } // Is followed by a scalar and is a built-in tag - if ('' !== $tag && (!isset($value[$nextOffset]) || !\in_array($value[$nextOffset], ['[', '{'], true)) && ('!' === $tag[0] || \in_array($tag, ['str', 'php/const', 'php/enum', 'php/object'], true))) { + if ('' !== $tag && (!isset($value[$nextOffset]) || !\in_array($value[$nextOffset], ['[', '{'], true)) && ('!' === $tag[0] || 'str' === $tag || 'php/const' === $tag || 'php/object' === $tag)) { // Manage in {@link self::evaluateScalar()} return null; } diff --git a/vendor/symfony/yaml/LICENSE b/vendor/symfony/yaml/LICENSE index 0138f8f0..00837045 100644 --- a/vendor/symfony/yaml/LICENSE +++ b/vendor/symfony/yaml/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-present Fabien Potencier +Copyright (c) 2004-2023 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/symfony/yaml/Parser.php b/vendor/symfony/yaml/Parser.php index ddfbcfd8..b0c05259 100644 --- a/vendor/symfony/yaml/Parser.php +++ b/vendor/symfony/yaml/Parser.php @@ -99,7 +99,7 @@ public function parse(string $value, int $flags = 0): mixed return $data; } - private function doParse(string $value, int $flags): mixed + private function doParse(string $value, int $flags) { $this->currentLineNb = -1; $this->currentLine = ''; @@ -107,7 +107,10 @@ private function doParse(string $value, int $flags): mixed $this->lines = explode("\n", $value); $this->numberOfParsedLines = \count($this->lines); $this->locallySkippedLineNumbers = []; - $this->totalNumberOfLines ??= $this->numberOfParsedLines; + + if (null === $this->totalNumberOfLines) { + $this->totalNumberOfLines = $this->numberOfParsedLines; + } if (!$this->moveToNextLine()) { return null; @@ -158,7 +161,7 @@ private function doParse(string $value, int $flags): mixed } // array - if (isset($values['value']) && str_starts_with(ltrim($values['value'], ' '), '-')) { + if (isset($values['value']) && 0 === strpos(ltrim($values['value'], ' '), '-')) { // Inline first child $currentLineNumber = $this->getRealCurrentLineNb(); @@ -167,7 +170,7 @@ private function doParse(string $value, int $flags): mixed $sequenceYaml .= "\n".$this->getNextEmbedBlock($sequenceIndentation, true); $data[] = $this->parseBlock($currentLineNumber, rtrim($sequenceYaml), $flags); - } elseif (!isset($values['value']) || '' == trim($values['value'], ' ') || str_starts_with(ltrim($values['value'], ' '), '#')) { + } elseif (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) { $data[] = $this->parseBlock($this->getRealCurrentLineNb() + 1, $this->getNextEmbedBlock(null, true) ?? '', $flags); } elseif (null !== $subTag = $this->getLineTag(ltrim($values['value'], ' '), $flags)) { $data[] = new TaggedValue( @@ -198,14 +201,9 @@ private function doParse(string $value, int $flags): mixed array_pop($this->refsBeingParsed); } } elseif ( - // @todo in 7.0 remove legacy "(?:!?!php/const:)?" self::preg_match('#^(?P(?:![^\s]++\s++)?(?:'.Inline::REGEX_QUOTED_STRING.'|(?:!?!php/const:)?[^ \'"\[\{!].*?)) *\:(( |\t)++(?P.+))?$#u', rtrim($this->currentLine), $values) - && (!str_contains($values['key'], ' #') || \in_array($values['key'][0], ['"', "'"])) + && (false === strpos($values['key'], ' #') || \in_array($values['key'][0], ['"', "'"])) ) { - if (str_starts_with($values['key'], '!php/const:')) { - trigger_deprecation('symfony/yaml', '6.2', 'YAML syntax for key "%s" is deprecated and replaced by "!php/const %s".', $values['key'], substr($values['key'], 11)); - } - if ($context && 'sequence' == $context) { throw new ParseException('You cannot define a mapping item when in a sequence.', $this->currentLineNb + 1, $this->currentLine, $this->filename); } @@ -299,7 +297,7 @@ private function doParse(string $value, int $flags): mixed $subTag = null; if ($mergeNode) { // Merge keys - } elseif (!isset($values['value']) || '' === $values['value'] || str_starts_with($values['value'], '#') || (null !== $subTag = $this->getLineTag($values['value'], $flags)) || '<<' === $key) { + } elseif (!isset($values['value']) || '' === $values['value'] || 0 === strpos($values['value'], '#') || (null !== $subTag = $this->getLineTag($values['value'], $flags)) || '<<' === $key) { // hash // if next line is less indented or equal, then it means that the current value is null if (!$this->isNextLineIndented() && !$this->isNextLineUnIndentedCollection()) { @@ -447,7 +445,7 @@ private function doParse(string $value, int $flags): mixed throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename); } - if (str_contains($line, ': ')) { + if (false !== strpos($line, ': ')) { throw new ParseException('Mapping values are not allowed in multi-line blocks.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename); } @@ -457,7 +455,7 @@ private function doParse(string $value, int $flags): mixed $value .= ' '; } - if ('' !== $trimmedLine && str_ends_with($line, '\\')) { + if ('' !== $trimmedLine && '\\' === substr($line, -1)) { $value .= ltrim(substr($line, 0, -1)); } elseif ('' !== $trimmedLine) { $value .= $trimmedLine; @@ -466,7 +464,7 @@ private function doParse(string $value, int $flags): mixed if ('' === $trimmedLine) { $previousLineWasNewline = true; $previousLineWasTerminatedWithBackslash = false; - } elseif (str_ends_with($line, '\\')) { + } elseif ('\\' === substr($line, -1)) { $previousLineWasNewline = false; $previousLineWasTerminatedWithBackslash = true; } else { @@ -477,7 +475,7 @@ private function doParse(string $value, int $flags): mixed try { return Inline::parse(trim($value)); - } catch (ParseException) { + } catch (ParseException $e) { // fall-through to the ParseException thrown below } } @@ -503,7 +501,7 @@ private function doParse(string $value, int $flags): mixed return empty($data) ? null : $data; } - private function parseBlock(int $offset, string $yaml, int $flags): mixed + private function parseBlock(int $offset, string $yaml, int $flags) { $skippedLineNumbers = $this->skippedLineNumbers; @@ -703,7 +701,7 @@ private function moveToPreviousLine(): bool */ private function parseValue(string $value, int $flags, string $context): mixed { - if (str_starts_with($value, '*')) { + if (0 === strpos($value, '*')) { if (false !== $pos = strpos($value, '#')) { $value = substr($value, 1, $pos - 2); } else { @@ -790,7 +788,7 @@ private function parseValue(string $value, int $flags, string $context): mixed $parsedValue = Inline::parse($value, $flags, $this->refs); - if ('mapping' === $context && \is_string($parsedValue) && '"' !== $value[0] && "'" !== $value[0] && '[' !== $value[0] && '{' !== $value[0] && '!' !== $value[0] && str_contains($parsedValue, ': ')) { + if ('mapping' === $context && \is_string($parsedValue) && '"' !== $value[0] && "'" !== $value[0] && '[' !== $value[0] && '{' !== $value[0] && '!' !== $value[0] && false !== strpos($parsedValue, ': ')) { throw new ParseException('A colon cannot be used in an unquoted mapping value.', $this->getRealCurrentLineNb() + 1, $value, $this->filename); } @@ -844,8 +842,8 @@ private function parseBlockScalar(string $style, string $chomping = '', int $ind while ( $notEOF && ( - $isCurrentLineBlank - || self::preg_match($pattern, $this->currentLine, $matches) + $isCurrentLineBlank || + self::preg_match($pattern, $this->currentLine, $matches) ) ) { if ($isCurrentLineBlank && \strlen($this->currentLine) > $indentation) { @@ -1026,7 +1024,7 @@ private function isNextLineUnIndentedCollection(): bool private function isStringUnIndentedCollectionItem(): bool { - return '-' === rtrim($this->currentLine) || str_starts_with($this->currentLine, '- '); + return '-' === rtrim($this->currentLine) || 0 === strpos($this->currentLine, '- '); } /** @@ -1038,12 +1036,34 @@ private function isStringUnIndentedCollectionItem(): bool * * @throws ParseException on a PCRE internal error * + * @see preg_last_error() + * * @internal */ public static function preg_match(string $pattern, string $subject, array &$matches = null, int $flags = 0, int $offset = 0): int { if (false === $ret = preg_match($pattern, $subject, $matches, $flags, $offset)) { - throw new ParseException(preg_last_error_msg()); + switch (preg_last_error()) { + case \PREG_INTERNAL_ERROR: + $error = 'Internal PCRE error.'; + break; + case \PREG_BACKTRACK_LIMIT_ERROR: + $error = 'pcre.backtrack_limit reached.'; + break; + case \PREG_RECURSION_LIMIT_ERROR: + $error = 'pcre.recursion_limit reached.'; + break; + case \PREG_BAD_UTF8_ERROR: + $error = 'Malformed UTF-8 data.'; + break; + case \PREG_BAD_UTF8_OFFSET_ERROR: + $error = 'Offset doesn\'t correspond to the begin of a valid UTF-8 code point.'; + break; + default: + $error = 'Error.'; + } + + throw new ParseException($error); } return $ret; diff --git a/vendor/symfony/yaml/Tag/TaggedValue.php b/vendor/symfony/yaml/Tag/TaggedValue.php index 3e09b93e..c7946c27 100644 --- a/vendor/symfony/yaml/Tag/TaggedValue.php +++ b/vendor/symfony/yaml/Tag/TaggedValue.php @@ -31,7 +31,7 @@ public function getTag(): string return $this->tag; } - public function getValue(): mixed + public function getValue() { return $this->value; } diff --git a/vendor/symfony/yaml/Unescaper.php b/vendor/symfony/yaml/Unescaper.php index 9e640ff2..d1ef0412 100644 --- a/vendor/symfony/yaml/Unescaper.php +++ b/vendor/symfony/yaml/Unescaper.php @@ -45,7 +45,9 @@ public function unescapeSingleQuotedString(string $value): string */ public function unescapeDoubleQuotedString(string $value): string { - $callback = fn ($match) => $this->unescapeCharacter($match[0]); + $callback = function ($match) { + return $this->unescapeCharacter($match[0]); + }; // evaluate the string return preg_replace_callback('/'.self::REGEX_ESCAPED_CHARACTER.'/u', $callback, $value); @@ -58,34 +60,56 @@ public function unescapeDoubleQuotedString(string $value): string */ private function unescapeCharacter(string $value): string { - return match ($value[1]) { - '0' => "\x0", - 'a' => "\x7", - 'b' => "\x8", - 't' => "\t", - "\t" => "\t", - 'n' => "\n", - 'v' => "\xB", - 'f' => "\xC", - 'r' => "\r", - 'e' => "\x1B", - ' ' => ' ', - '"' => '"', - '/' => '/', - '\\' => '\\', - // U+0085 NEXT LINE - 'N' => "\xC2\x85", - // U+00A0 NO-BREAK SPACE - '_' => "\xC2\xA0", - // U+2028 LINE SEPARATOR - 'L' => "\xE2\x80\xA8", - // U+2029 PARAGRAPH SEPARATOR - 'P' => "\xE2\x80\xA9", - 'x' => self::utf8chr(hexdec(substr($value, 2, 2))), - 'u' => self::utf8chr(hexdec(substr($value, 2, 4))), - 'U' => self::utf8chr(hexdec(substr($value, 2, 8))), - default => throw new ParseException(sprintf('Found unknown escape character "%s".', $value)), - }; + switch ($value[1]) { + case '0': + return "\x0"; + case 'a': + return "\x7"; + case 'b': + return "\x8"; + case 't': + return "\t"; + case "\t": + return "\t"; + case 'n': + return "\n"; + case 'v': + return "\xB"; + case 'f': + return "\xC"; + case 'r': + return "\r"; + case 'e': + return "\x1B"; + case ' ': + return ' '; + case '"': + return '"'; + case '/': + return '/'; + case '\\': + return '\\'; + case 'N': + // U+0085 NEXT LINE + return "\xC2\x85"; + case '_': + // U+00A0 NO-BREAK SPACE + return "\xC2\xA0"; + case 'L': + // U+2028 LINE SEPARATOR + return "\xE2\x80\xA8"; + case 'P': + // U+2029 PARAGRAPH SEPARATOR + return "\xE2\x80\xA9"; + case 'x': + return self::utf8chr(hexdec(substr($value, 2, 2))); + case 'u': + return self::utf8chr(hexdec(substr($value, 2, 4))); + case 'U': + return self::utf8chr(hexdec(substr($value, 2, 8))); + default: + throw new ParseException(sprintf('Found unknown escape character "%s".', $value)); + } } /** diff --git a/vendor/symfony/yaml/Yaml.php b/vendor/symfony/yaml/Yaml.php index e2d2af73..49784216 100644 --- a/vendor/symfony/yaml/Yaml.php +++ b/vendor/symfony/yaml/Yaml.php @@ -34,7 +34,6 @@ class Yaml public const PARSE_CUSTOM_TAGS = 512; public const DUMP_EMPTY_ARRAY_AS_SEQUENCE = 1024; public const DUMP_NULL_AS_TILDE = 2048; - public const DUMP_NUMERIC_KEY_AS_STRING = 4096; /** * Parses a YAML file into a PHP value. diff --git a/vendor/symfony/yaml/composer.json b/vendor/symfony/yaml/composer.json index 019776ce..356b9ac7 100644 --- a/vendor/symfony/yaml/composer.json +++ b/vendor/symfony/yaml/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": ">=8.1", + "php": ">=8.0.2", "symfony/polyfill-ctype": "^1.8" }, "require-dev": { @@ -25,6 +25,9 @@ "conflict": { "symfony/console": "<5.4" }, + "suggest": { + "symfony/console": "For validating YAML files using the lint command" + }, "autoload": { "psr-4": { "Symfony\\Component\\Yaml\\": "" }, "exclude-from-classmap": [ diff --git a/vendor/wp-coding-standards/wpcs/WordPress-Core/ruleset.xml b/vendor/wp-coding-standards/wpcs/WordPress-Core/ruleset.xml index 254a477c..03c23449 100644 --- a/vendor/wp-coding-standards/wpcs/WordPress-Core/ruleset.xml +++ b/vendor/wp-coding-standards/wpcs/WordPress-Core/ruleset.xml @@ -483,6 +483,35 @@ + + + + + + + + + + + + + 0 + + + + + 0 + + +