From fadb23910d21972055b5deb09e4e7b61036e8d5c Mon Sep 17 00:00:00 2001 From: DevDavido <997605+DevDavido@users.noreply.github.com> Date: Wed, 20 Dec 2023 00:04:59 +0100 Subject: [PATCH 01/11] refactor: Remove PHP class headers --- API.php | 6 ------ Archiver.php | 7 ------- Columns/Filters/AuditScoreClassifier.php | 6 ------ Columns/Metrics/Audit.php | 6 ------ Columns/Metrics/Max.php | 6 ------ Columns/Metrics/MaxPercent.php | 6 ------ Columns/Metrics/MaxSeconds.php | 6 ------ Columns/Metrics/Median.php | 6 ------ Columns/Metrics/MedianPercent.php | 6 ------ Columns/Metrics/MedianSeconds.php | 6 ------ Columns/Metrics/Min.php | 6 ------ Columns/Metrics/MinPercent.php | 6 ------ Columns/Metrics/MinSeconds.php | 6 ------ Columns/PageUrl.php | 6 ------ Commands/ClearTaskRunningFlag.php | 6 ------ Controller.php | 6 ------ EmulatedDevice.php | 6 ------ .../AuditFailedAuthoriseRefusedException.php | 6 ------ Exceptions/AuditFailedException.php | 6 ------ .../AuditFailedMethodNotAllowedException.php | 6 ------ Exceptions/AuditFailedNotFoundException.php | 6 ------ Exceptions/AuditFailedTooManyRequestsException.php | 6 ------ Exceptions/DependencyMissingException.php | 6 ------ .../DependencyNpmMisconfigurationException.php | 6 ------ Exceptions/DependencyOfChromeMissingException.php | 6 ------ Exceptions/DependencyUnexpectedResultException.php | 6 ------ Exceptions/DirectoryNotWriteableException.php | 6 ------ Exceptions/InstallationFailedException.php | 6 ------ Exceptions/InternetUnavailableException.php | 6 ------ ExecutableFinder.php | 6 ------ Helper.php | 6 ------ Lighthouse.php | 6 ------ MeasurableSettings.php | 6 ------ Menu.php | 6 ------ NodeDependencyInstaller.php | 6 ------ PerformanceAudit.php | 6 ------ Process.php | 6 ------ Reports/GetPerformanceBase.php | 6 ------ .../GetPerformanceCumulativeLayoutShiftDesktop.php | 6 ------ .../GetPerformanceCumulativeLayoutShiftMobile.php | 6 ------ .../GetPerformanceFirstContentfulPaintDesktop.php | 6 ------ .../GetPerformanceFirstContentfulPaintMobile.php | 6 ------ Reports/GetPerformanceInteractiveDesktop.php | 6 ------ Reports/GetPerformanceInteractiveMobile.php | 6 ------ ...GetPerformanceLargestContentfulPaintDesktop.php | 6 ------ .../GetPerformanceLargestContentfulPaintMobile.php | 6 ------ Reports/GetPerformanceScoreDesktop.php | 6 ------ Reports/GetPerformanceScoreMobile.php | 6 ------ Reports/GetPerformanceSpeedIndexDesktop.php | 6 ------ Reports/GetPerformanceSpeedIndexMobile.php | 6 ------ Reports/GetPerformanceTotalBlockingTimeDesktop.php | 6 ------ Reports/GetPerformanceTotalBlockingTimeMobile.php | 6 ------ Tasks.php | 6 ------ Updates/1.1.0.php | 6 ------ tests/Integration/ApiTest.php | 14 ++++---------- .../PerformanceAuditIntegrationTest.php | 14 ++++---------- tests/Unit/Filter/AuditScoreClassifierTest.php | 6 ------ tests/Unit/Metric/PercentTest.php | 6 ------ tests/Unit/Metric/SecondsTest.php | 6 ------ 59 files changed, 8 insertions(+), 363 deletions(-) diff --git a/API.php b/API.php index 07940815..208fe856 100644 --- a/API.php +++ b/API.php @@ -1,10 +1,4 @@ assertEquals('50', $row->getColumn('min')); $this->assertEquals('80', $row->getColumn('median')); $this->assertEquals('100', $row->getColumn('max')); - $this->assertEquals('http://example.com/some/test/page', $row->getMetadata('url')); + $this->assertEquals('https://example.com/some/test/page', $row->getMetadata('url')); $this->assertEquals("50% is classified as MODERATE!
\n Values between 50% – 90% are in this classification group.", $row->getMetadata('min_tooltip')); $this->assertEquals("80% is classified as MODERATE!
\n Values between 50% – 90% are in this classification group.", $row->getMetadata('median_tooltip')); $this->assertEquals("100% is classified as FAST!
\n Values between 90% – 100% are in this classification group.", $row->getMetadata('max_tooltip')); @@ -200,7 +194,7 @@ private function assertSite1FirstContentfulPaintRow($row) $this->assertEquals('0.2', $row->getColumn('min')); $this->assertEquals('0.4', $row->getColumn('median')); $this->assertEquals('0.8', $row->getColumn('max')); - $this->assertEquals('http://example.com/some/test/page', $row->getMetadata('url')); + $this->assertEquals('https://example.com/some/test/page', $row->getMetadata('url')); $this->assertEquals("0.2s is classified as FAST!
\n Values between 0s – 2s are in this classification group.", $row->getMetadata('min_tooltip')); $this->assertEquals("0.4s is classified as FAST!
\n Values between 0s – 2s are in this classification group.", $row->getMetadata('median_tooltip')); $this->assertEquals("0.8s is classified as FAST!
\n Values between 0s – 2s are in this classification group.", $row->getMetadata('max_tooltip')); @@ -321,7 +315,7 @@ private function assertSite2ScoreRow($row) $this->assertEquals('50', $row->getColumn('min')); $this->assertEquals('80', $row->getColumn('median')); $this->assertEquals('100', $row->getColumn('max')); - $this->assertEquals('http://example.org/some/test/page', $row->getMetadata('url')); + $this->assertEquals('https://example.org/some/test/page', $row->getMetadata('url')); $this->assertEquals("50% is classified as MODERATE!
\n Values between 50% – 90% are in this classification group.", $row->getMetadata('min_tooltip')); $this->assertEquals("80% is classified as MODERATE!
\n Values between 50% – 90% are in this classification group.", $row->getMetadata('median_tooltip')); $this->assertEquals("100% is classified as FAST!
\n Values between 90% – 100% are in this classification group.", $row->getMetadata('max_tooltip')); @@ -356,7 +350,7 @@ private function assertSite2FirstContentfulPaintRow($row) $this->assertEquals('2', $row->getColumn('min')); $this->assertEquals('4', $row->getColumn('median')); $this->assertEquals('8', $row->getColumn('max')); - $this->assertEquals('http://example.org/some/test/page', $row->getMetadata('url')); + $this->assertEquals('https://example.org/some/test/page', $row->getMetadata('url')); $this->assertEquals("2s is classified as MODERATE!
\n Values between 2s – 4s are in this classification group.", $row->getMetadata('min_tooltip')); $this->assertEquals("4s is classified as SLOW!
\n Values between 4s – 60s are in this classification group.", $row->getMetadata('median_tooltip')); $this->assertEquals("8s is classified as SLOW!
\n Values between 4s – 60s are in this classification group.", $row->getMetadata('max_tooltip')); diff --git a/tests/Integration/PerformanceAuditIntegrationTest.php b/tests/Integration/PerformanceAuditIntegrationTest.php index e47afe17..f69ff8f5 100644 --- a/tests/Integration/PerformanceAuditIntegrationTest.php +++ b/tests/Integration/PerformanceAuditIntegrationTest.php @@ -1,11 +1,5 @@ createBaseData([$website1Id, $website2Id, $website3Id]); } diff --git a/tests/Unit/Filter/AuditScoreClassifierTest.php b/tests/Unit/Filter/AuditScoreClassifierTest.php index 29731025..ec96938a 100644 --- a/tests/Unit/Filter/AuditScoreClassifierTest.php +++ b/tests/Unit/Filter/AuditScoreClassifierTest.php @@ -1,10 +1,4 @@ Date: Wed, 20 Dec 2023 00:06:23 +0100 Subject: [PATCH 02/11] build: Update composer dependencies --- composer.json | 6 +- vendor/autoload.php | 18 + vendor/composer/ClassLoader.php | 184 +++++- vendor/composer/InstalledVersions.php | 586 +++++++++++------- vendor/composer/autoload_classmap.php | 9 +- vendor/composer/autoload_files.php | 3 +- vendor/composer/autoload_namespaces.php | 2 +- vendor/composer/autoload_psr4.php | 3 +- vendor/composer/autoload_real.php | 49 +- vendor/composer/autoload_static.php | 13 + vendor/composer/installed.json | 166 ++++- vendor/composer/installed.php | 122 ++-- vendor/composer/platform_check.php | 26 +- .../spl-types/.circleci/config.yml | 16 + .../ducks-project/spl-types/.corveralls.yml | 1 + .../spl-types/.github/FUNDING.yml | 4 + vendor/ducks-project/spl-types/.gitignore | 3 +- vendor/ducks-project/spl-types/.styleci.yml | 13 + vendor/ducks-project/spl-types/.travis.yml | 27 +- vendor/ducks-project/spl-types/README.md | 102 +++ vendor/ducks-project/spl-types/SplBool.php | 14 +- vendor/ducks-project/spl-types/SplEnum.php | 21 +- vendor/ducks-project/spl-types/SplFloat.php | 26 +- vendor/ducks-project/spl-types/SplInt.php | 26 +- vendor/ducks-project/spl-types/SplString.php | 26 +- vendor/ducks-project/spl-types/SplType.php | 41 +- .../ducks-project/spl-types/phpunit.xml.dist | 33 + vendor/symfony/polyfill-mbstring/LICENSE | 2 +- vendor/symfony/polyfill-mbstring/Mbstring.php | 215 +++++-- vendor/symfony/polyfill-mbstring/README.md | 2 +- .../Resources/unidata/caseFolding.php | 119 ++++ .../Resources/unidata/lowerCase.php | 2 +- .../Resources/unidata/upperCase.php | 129 +++- .../symfony/polyfill-mbstring/bootstrap.php | 20 +- .../symfony/polyfill-mbstring/bootstrap80.php | 147 +++++ .../symfony/polyfill-mbstring/composer.json | 5 +- vendor/symfony/polyfill-php80/LICENSE | 19 + vendor/symfony/polyfill-php80/Php80.php | 115 ++++ vendor/symfony/polyfill-php80/PhpToken.php | 103 +++ vendor/symfony/polyfill-php80/README.md | 25 + .../Resources/stubs/Attribute.php | 31 + .../Resources/stubs/PhpToken.php | 16 + .../Resources/stubs/Stringable.php | 20 + .../Resources/stubs/UnhandledMatchError.php | 16 + .../Resources/stubs/ValueError.php | 16 + vendor/symfony/polyfill-php80/bootstrap.php | 42 ++ vendor/symfony/polyfill-php80/composer.json | 40 ++ vendor/symfony/process/ExecutableFinder.php | 4 +- vendor/symfony/process/InputStream.php | 1 + vendor/symfony/process/LICENSE | 2 +- .../symfony/process/PhpExecutableFinder.php | 10 +- .../symfony/process/Pipes/AbstractPipes.php | 10 +- vendor/symfony/process/Pipes/UnixPipes.php | 13 + vendor/symfony/process/Pipes/WindowsPipes.php | 15 +- vendor/symfony/process/Process.php | 76 +-- vendor/symfony/process/ProcessUtils.php | 2 +- vendor/symfony/process/README.md | 10 +- vendor/symfony/process/composer.json | 5 +- 58 files changed, 2141 insertions(+), 631 deletions(-) create mode 100644 vendor/ducks-project/spl-types/.circleci/config.yml create mode 100644 vendor/ducks-project/spl-types/.corveralls.yml create mode 100644 vendor/ducks-project/spl-types/.github/FUNDING.yml create mode 100644 vendor/ducks-project/spl-types/.styleci.yml create mode 100644 vendor/ducks-project/spl-types/phpunit.xml.dist create mode 100644 vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php create mode 100644 vendor/symfony/polyfill-mbstring/bootstrap80.php create mode 100644 vendor/symfony/polyfill-php80/LICENSE create mode 100644 vendor/symfony/polyfill-php80/Php80.php create mode 100644 vendor/symfony/polyfill-php80/PhpToken.php create mode 100644 vendor/symfony/polyfill-php80/README.md create mode 100644 vendor/symfony/polyfill-php80/Resources/stubs/Attribute.php create mode 100644 vendor/symfony/polyfill-php80/Resources/stubs/PhpToken.php create mode 100644 vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php create mode 100644 vendor/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php create mode 100644 vendor/symfony/polyfill-php80/Resources/stubs/ValueError.php create mode 100644 vendor/symfony/polyfill-php80/bootstrap.php create mode 100644 vendor/symfony/polyfill-php80/composer.json diff --git a/composer.json b/composer.json index c4684f96..68637364 100644 --- a/composer.json +++ b/composer.json @@ -13,13 +13,13 @@ "php": ">=7.2.5", "ext-json": "*", "ext-spl": "*", - "ducks-project/spl-types": "^1.1", - "symfony/polyfill-mbstring": "^1.20", + "ducks-project/spl-types": "^1.2", + "symfony/polyfill-mbstring": "^1.28", "symfony/process": "^4.4", "jeroen-g/lighthouse": "^0.2" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.17" + "friendsofphp/php-cs-fixer": "^2.19" }, "autoload": { "classmap": ["./"] diff --git a/vendor/autoload.php b/vendor/autoload.php index 14abaa6d..1975eae8 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -2,6 +2,24 @@ // autoload.php @generated by Composer +if (PHP_VERSION_ID < 50600) { + if (!headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL; + if (!ini_get('display_errors')) { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + fwrite(STDERR, $err); + } elseif (!headers_sent()) { + echo $err; + } + } + trigger_error( + $err, + E_USER_ERROR + ); +} + require_once __DIR__ . '/composer/autoload_real.php'; return ComposerAutoloaderInit98dde460e8a16c8877d8f8d8a8e6921c::getLoader(); diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php index 1a58957d..a72151c7 100644 --- a/vendor/composer/ClassLoader.php +++ b/vendor/composer/ClassLoader.php @@ -42,21 +42,79 @@ */ class ClassLoader { + /** @var \Closure(string):void */ + private static $includeFile; + + /** @var ?string */ + private $vendorDir; + // PSR-4 + /** + * @var array[] + * @psalm-var array> + */ private $prefixLengthsPsr4 = array(); + /** + * @var array[] + * @psalm-var array> + */ private $prefixDirsPsr4 = array(); + /** + * @var array[] + * @psalm-var array + */ private $fallbackDirsPsr4 = array(); // PSR-0 + /** + * @var array[] + * @psalm-var array> + */ private $prefixesPsr0 = array(); + /** + * @var array[] + * @psalm-var array + */ private $fallbackDirsPsr0 = array(); + /** @var bool */ private $useIncludePath = false; + + /** + * @var string[] + * @psalm-var array + */ private $classMap = array(); + + /** @var bool */ private $classMapAuthoritative = false; + + /** + * @var bool[] + * @psalm-var array + */ private $missingClasses = array(); + + /** @var ?string */ private $apcuPrefix; + /** + * @var self[] + */ + private static $registeredLoaders = array(); + + /** + * @param ?string $vendorDir + */ + public function __construct($vendorDir = null) + { + $this->vendorDir = $vendorDir; + self::initializeIncludeClosure(); + } + + /** + * @return string[] + */ public function getPrefixes() { if (!empty($this->prefixesPsr0)) { @@ -66,28 +124,47 @@ public function getPrefixes() return array(); } + /** + * @return array[] + * @psalm-return array> + */ public function getPrefixesPsr4() { return $this->prefixDirsPsr4; } + /** + * @return array[] + * @psalm-return array + */ public function getFallbackDirs() { return $this->fallbackDirsPsr0; } + /** + * @return array[] + * @psalm-return array + */ public function getFallbackDirsPsr4() { return $this->fallbackDirsPsr4; } + /** + * @return string[] Array of classname => path + * @psalm-return array + */ public function getClassMap() { return $this->classMap; } /** - * @param array $classMap Class to filename map + * @param string[] $classMap Class to filename map + * @psalm-param array $classMap + * + * @return void */ public function addClassMap(array $classMap) { @@ -102,9 +179,11 @@ public function addClassMap(array $classMap) * Registers a set of PSR-0 directories for a given prefix, either * appending or prepending to the ones previously set for this prefix. * - * @param string $prefix The prefix - * @param array|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix + * @param string[]|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + * + * @return void */ public function add($prefix, $paths, $prepend = false) { @@ -147,11 +226,13 @@ public function add($prefix, $paths, $prepend = false) * Registers a set of PSR-4 directories for a given namespace, either * appending or prepending to the ones previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param string[]|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories * * @throws \InvalidArgumentException + * + * @return void */ public function addPsr4($prefix, $paths, $prepend = false) { @@ -195,8 +276,10 @@ public function addPsr4($prefix, $paths, $prepend = false) * Registers a set of PSR-0 directories for a given prefix, * replacing any others previously set for this prefix. * - * @param string $prefix The prefix - * @param array|string $paths The PSR-0 base directories + * @param string $prefix The prefix + * @param string[]|string $paths The PSR-0 base directories + * + * @return void */ public function set($prefix, $paths) { @@ -211,10 +294,12 @@ public function set($prefix, $paths) * Registers a set of PSR-4 directories for a given namespace, * replacing any others previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-4 base directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param string[]|string $paths The PSR-4 base directories * * @throws \InvalidArgumentException + * + * @return void */ public function setPsr4($prefix, $paths) { @@ -234,6 +319,8 @@ public function setPsr4($prefix, $paths) * Turns on searching the include path for class files. * * @param bool $useIncludePath + * + * @return void */ public function setUseIncludePath($useIncludePath) { @@ -256,6 +343,8 @@ public function getUseIncludePath() * that have not been registered with the class map. * * @param bool $classMapAuthoritative + * + * @return void */ public function setClassMapAuthoritative($classMapAuthoritative) { @@ -276,6 +365,8 @@ public function isClassMapAuthoritative() * APCu prefix to use to cache found/not-found classes, if the extension is enabled. * * @param string|null $apcuPrefix + * + * @return void */ public function setApcuPrefix($apcuPrefix) { @@ -296,33 +387,55 @@ public function getApcuPrefix() * Registers this instance as an autoloader. * * @param bool $prepend Whether to prepend the autoloader or not + * + * @return void */ public function register($prepend = false) { spl_autoload_register(array($this, 'loadClass'), true, $prepend); + + if (null === $this->vendorDir) { + return; + } + + if ($prepend) { + self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; + } else { + unset(self::$registeredLoaders[$this->vendorDir]); + self::$registeredLoaders[$this->vendorDir] = $this; + } } /** * Unregisters this instance as an autoloader. + * + * @return void */ public function unregister() { spl_autoload_unregister(array($this, 'loadClass')); + + if (null !== $this->vendorDir) { + unset(self::$registeredLoaders[$this->vendorDir]); + } } /** * Loads the given class or interface. * * @param string $class The name of the class - * @return bool|null True if loaded, null otherwise + * @return true|null True if loaded, null otherwise */ public function loadClass($class) { if ($file = $this->findFile($class)) { - includeFile($file); + $includeFile = self::$includeFile; + $includeFile($file); return true; } + + return null; } /** @@ -367,6 +480,21 @@ public function findFile($class) return $file; } + /** + * Returns the currently registered loaders indexed by their corresponding vendor directories. + * + * @return self[] + */ + public static function getRegisteredLoaders() + { + return self::$registeredLoaders; + } + + /** + * @param string $class + * @param string $ext + * @return string|false + */ private function findFileWithExtension($class, $ext) { // PSR-4 lookup @@ -432,14 +560,26 @@ private function findFileWithExtension($class, $ext) return false; } -} -/** - * Scope isolated include. - * - * Prevents access to $this/self from included files. - */ -function includeFile($file) -{ - include $file; + /** + * @return void + */ + private static function initializeIncludeClosure() + { + if (self::$includeFile !== null) { + return; + } + + /** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + * + * @param string $file + * @return void + */ + self::$includeFile = \Closure::bind(static function($file) { + include $file; + }, null, null); + } } diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php index 21268853..51e734a7 100644 --- a/vendor/composer/InstalledVersions.php +++ b/vendor/composer/InstalledVersions.php @@ -1,245 +1,359 @@ + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Composer; +use Composer\Autoload\ClassLoader; use Composer\Semver\VersionParser; - - - - - +/** + * This class is copied in every Composer installed project and available to all + * + * See also https://getcomposer.org/doc/07-runtime.md#installed-versions + * + * To require its presence, you can require `composer-runtime-api ^2.0` + * + * @final + */ class InstalledVersions { -private static $installed = array ( - 'root' => - array ( - 'pretty_version' => 'dev-4.x-dev', - 'version' => 'dev-4.x-dev', - 'aliases' => - array ( - ), - 'reference' => '966739c860cee8c164e596688c3e6055c8de29a9', - 'name' => 'devdavido/performance-audit-plugin', - ), - 'versions' => - array ( - 'devdavido/performance-audit-plugin' => - array ( - 'pretty_version' => 'dev-4.x-dev', - 'version' => 'dev-4.x-dev', - 'aliases' => - array ( - ), - 'reference' => '966739c860cee8c164e596688c3e6055c8de29a9', - ), - 'ducks-project/spl-types' => - array ( - 'pretty_version' => 'v1.1.0', - 'version' => '1.1.0.0', - 'aliases' => - array ( - ), - 'reference' => '814f5b719fb39975321db0eaf66c4e0d2d93f53e', - ), - 'jeroen-g/lighthouse' => - array ( - 'pretty_version' => 'v0.2', - 'version' => '0.2.0.0', - 'aliases' => - array ( - ), - 'reference' => '9cabb6a857b1a9ccc537328956b4e0af2c370f9a', - ), - 'symfony/polyfill-mbstring' => - array ( - 'pretty_version' => 'v1.20.0', - 'version' => '1.20.0.0', - 'aliases' => - array ( - ), - 'reference' => '39d483bdf39be819deabf04ec872eb0b2410b531', - ), - 'symfony/process' => - array ( - 'pretty_version' => 'v4.4.18', - 'version' => '4.4.18.0', - 'aliases' => - array ( - ), - 'reference' => '075316ff72233ce3d04a9743414292e834f2cb4a', - ), - ), -); - - - - - - - -public static function getInstalledPackages() -{ -return array_keys(self::$installed['versions']); -} - - - - - - - - - -public static function isInstalled($packageName) -{ -return isset(self::$installed['versions'][$packageName]); -} - - - - - - - - - - - - - - -public static function satisfies(VersionParser $parser, $packageName, $constraint) -{ -$constraint = $parser->parseConstraints($constraint); -$provided = $parser->parseConstraints(self::getVersionRanges($packageName)); - -return $provided->matches($constraint); -} - - - - - - - - - - -public static function getVersionRanges($packageName) -{ -if (!isset(self::$installed['versions'][$packageName])) { -throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); -} - -$ranges = array(); -if (isset(self::$installed['versions'][$packageName]['pretty_version'])) { -$ranges[] = self::$installed['versions'][$packageName]['pretty_version']; -} -if (array_key_exists('aliases', self::$installed['versions'][$packageName])) { -$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['aliases']); -} -if (array_key_exists('replaced', self::$installed['versions'][$packageName])) { -$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['replaced']); -} -if (array_key_exists('provided', self::$installed['versions'][$packageName])) { -$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['provided']); -} - -return implode(' || ', $ranges); -} - - - - - -public static function getVersion($packageName) -{ -if (!isset(self::$installed['versions'][$packageName])) { -throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); -} - -if (!isset(self::$installed['versions'][$packageName]['version'])) { -return null; -} - -return self::$installed['versions'][$packageName]['version']; -} - - - - - -public static function getPrettyVersion($packageName) -{ -if (!isset(self::$installed['versions'][$packageName])) { -throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); -} - -if (!isset(self::$installed['versions'][$packageName]['pretty_version'])) { -return null; -} - -return self::$installed['versions'][$packageName]['pretty_version']; -} - - - - - -public static function getReference($packageName) -{ -if (!isset(self::$installed['versions'][$packageName])) { -throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); -} - -if (!isset(self::$installed['versions'][$packageName]['reference'])) { -return null; -} - -return self::$installed['versions'][$packageName]['reference']; -} - - - - - -public static function getRootPackage() -{ -return self::$installed['root']; -} - - - - - - - -public static function getRawData() -{ -return self::$installed; -} - - - - - - - - - - - - - - - - - - - -public static function reload($data) -{ -self::$installed = $data; -} + /** + * @var mixed[]|null + * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array}|array{}|null + */ + private static $installed; + + /** + * @var bool|null + */ + private static $canGetVendors; + + /** + * @var array[] + * @psalm-var array}> + */ + private static $installedByVendor = array(); + + /** + * Returns a list of all package names which are present, either by being installed, replaced or provided + * + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackages() + { + $packages = array(); + foreach (self::getInstalled() as $installed) { + $packages[] = array_keys($installed['versions']); + } + + if (1 === \count($packages)) { + return $packages[0]; + } + + return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); + } + + /** + * Returns a list of all package names with a specific type e.g. 'library' + * + * @param string $type + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackagesByType($type) + { + $packagesByType = array(); + + foreach (self::getInstalled() as $installed) { + foreach ($installed['versions'] as $name => $package) { + if (isset($package['type']) && $package['type'] === $type) { + $packagesByType[] = $name; + } + } + } + + return $packagesByType; + } + + /** + * Checks whether the given package is installed + * + * This also returns true if the package name is provided or replaced by another package + * + * @param string $packageName + * @param bool $includeDevRequirements + * @return bool + */ + public static function isInstalled($packageName, $includeDevRequirements = true) + { + foreach (self::getInstalled() as $installed) { + if (isset($installed['versions'][$packageName])) { + return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; + } + } + + return false; + } + + /** + * Checks whether the given package satisfies a version constraint + * + * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call: + * + * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') + * + * @param VersionParser $parser Install composer/semver to have access to this class and functionality + * @param string $packageName + * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package + * @return bool + */ + public static function satisfies(VersionParser $parser, $packageName, $constraint) + { + $constraint = $parser->parseConstraints((string) $constraint); + $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); + + return $provided->matches($constraint); + } + + /** + * Returns a version constraint representing all the range(s) which are installed for a given package + * + * It is easier to use this via isInstalled() with the $constraint argument if you need to check + * whether a given version of a package is installed, and not just whether it exists + * + * @param string $packageName + * @return string Version constraint usable with composer/semver + */ + public static function getVersionRanges($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + $ranges = array(); + if (isset($installed['versions'][$packageName]['pretty_version'])) { + $ranges[] = $installed['versions'][$packageName]['pretty_version']; + } + if (array_key_exists('aliases', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); + } + if (array_key_exists('replaced', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); + } + if (array_key_exists('provided', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); + } + + return implode(' || ', $ranges); + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['version'])) { + return null; + } + + return $installed['versions'][$packageName]['version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getPrettyVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['pretty_version'])) { + return null; + } + + return $installed['versions'][$packageName]['pretty_version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference + */ + public static function getReference($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['reference'])) { + return null; + } + + return $installed['versions'][$packageName]['reference']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path. + */ + public static function getInstallPath($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @return array + * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool} + */ + public static function getRootPackage() + { + $installed = self::getInstalled(); + + return $installed[0]['root']; + } + + /** + * Returns the raw installed.php data for custom implementations + * + * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. + * @return array[] + * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} + */ + public static function getRawData() + { + @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + self::$installed = include __DIR__ . '/installed.php'; + } else { + self::$installed = array(); + } + } + + return self::$installed; + } + + /** + * Returns the raw data of all installed.php which are currently loaded for custom implementations + * + * @return array[] + * @psalm-return list}> + */ + public static function getAllRawData() + { + return self::getInstalled(); + } + + /** + * Lets you reload the static array from another file + * + * This is only useful for complex integrations in which a project needs to use + * this class but then also needs to execute another project's autoloader in process, + * and wants to ensure both projects have access to their version of installed.php. + * + * A typical case would be PHPUnit, where it would need to make sure it reads all + * the data it needs from this class, then call reload() with + * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure + * the project in which it runs can then also use this class safely, without + * interference between PHPUnit's dependencies and the project's dependencies. + * + * @param array[] $data A vendor/composer/installed.php data set + * @return void + * + * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $data + */ + public static function reload($data) + { + self::$installed = $data; + self::$installedByVendor = array(); + } + + /** + * @return array[] + * @psalm-return list}> + */ + private static function getInstalled() + { + if (null === self::$canGetVendors) { + self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); + } + + $installed = array(); + + if (self::$canGetVendors) { + foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { + if (isset(self::$installedByVendor[$vendorDir])) { + $installed[] = self::$installedByVendor[$vendorDir]; + } elseif (is_file($vendorDir.'/composer/installed.php')) { + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require $vendorDir.'/composer/installed.php'; + $installed[] = self::$installedByVendor[$vendorDir] = $required; + if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { + self::$installed = $installed[count($installed) - 1]; + } + } + } + } + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require __DIR__ . '/installed.php'; + self::$installed = $required; + } else { + self::$installed = array(); + } + } + + if (self::$installed !== array()) { + $installed[] = self::$installed; + } + + return $installed; + } } diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 911232ba..4d39e716 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -2,10 +2,11 @@ // autoload_classmap.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( + 'Attribute' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Attribute.php', 'ComposerAutoloaderInit98dde460e8a16c8877d8f8d8a8e6921c' => $vendorDir . '/composer/autoload_real.php', 'Composer\\Autoload\\ClassLoader' => $vendorDir . '/composer/ClassLoader.php', 'Composer\\Autoload\\ComposerStaticInit98dde460e8a16c8877d8f8d8a8e6921c' => $vendorDir . '/composer/autoload_static.php', @@ -21,6 +22,7 @@ 'Dzava\\Lighthouse\\Tests\\Integration\\LighthouseTest' => $vendorDir . '/jeroen-g/lighthouse/tests/Integration/LighthouseTest.php', 'Dzava\\Lighthouse\\Tests\\Unit\\LighthouseTest' => $vendorDir . '/jeroen-g/lighthouse/tests/Unit/LighthouseTest.php', 'Dzava\\Lighthouse\\Tests\\Unit\\MockLighthouse' => $vendorDir . '/jeroen-g/lighthouse/tests/Unit/LighthouseTest.php', + 'PhpToken' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php', 'Piwik\\Plugins\\PerformanceAudit\\API' => $baseDir . '/API.php', 'Piwik\\Plugins\\PerformanceAudit\\Archiver' => $baseDir . '/Archiver.php', 'Piwik\\Plugins\\PerformanceAudit\\Columns\\Filters\\AuditScoreClassifier' => $baseDir . '/Columns/Filters/AuditScoreClassifier.php', @@ -80,6 +82,7 @@ 'Piwik\\Plugins\\PerformanceAudit\\tests\\Unit\\Filter\\AuditScoreClassifierTest' => $baseDir . '/tests/Unit/Filter/AuditScoreClassifierTest.php', 'Piwik\\Plugins\\PerformanceAudit\\tests\\Unit\\Metric\\PercentTest' => $baseDir . '/tests/Unit/Metric/PercentTest.php', 'Piwik\\Plugins\\PerformanceAudit\\tests\\Unit\\Metric\\SecondsTest' => $baseDir . '/tests/Unit/Metric/SecondsTest.php', + 'Stringable' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Stringable.php', 'Symfony\\Component\\Process\\Exception\\ExceptionInterface' => $vendorDir . '/symfony/process/Exception/ExceptionInterface.php', 'Symfony\\Component\\Process\\Exception\\InvalidArgumentException' => $vendorDir . '/symfony/process/Exception/InvalidArgumentException.php', 'Symfony\\Component\\Process\\Exception\\LogicException' => $vendorDir . '/symfony/process/Exception/LogicException.php', @@ -98,4 +101,8 @@ 'Symfony\\Component\\Process\\Process' => $vendorDir . '/symfony/process/Process.php', 'Symfony\\Component\\Process\\ProcessUtils' => $vendorDir . '/symfony/process/ProcessUtils.php', 'Symfony\\Polyfill\\Mbstring\\Mbstring' => $vendorDir . '/symfony/polyfill-mbstring/Mbstring.php', + 'Symfony\\Polyfill\\Php80\\Php80' => $vendorDir . '/symfony/polyfill-php80/Php80.php', + 'Symfony\\Polyfill\\Php80\\PhpToken' => $vendorDir . '/symfony/polyfill-php80/PhpToken.php', + 'UnhandledMatchError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php', + 'ValueError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/ValueError.php', ); diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php index 55000c6f..2cdb1a36 100644 --- a/vendor/composer/autoload_files.php +++ b/vendor/composer/autoload_files.php @@ -2,10 +2,11 @@ // autoload_files.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( + 'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php', 'e9b48b9bab803e9eba6dfd8e270dddfd' => $vendorDir . '/ducks-project/spl-types/bootstrap.php', '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php', ); diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php index b7fc0125..15a2ff3a 100644 --- a/vendor/composer/autoload_namespaces.php +++ b/vendor/composer/autoload_namespaces.php @@ -2,7 +2,7 @@ // autoload_namespaces.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index f19645d7..c0106c2d 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -2,10 +2,11 @@ // autoload_psr4.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( + 'Symfony\\Polyfill\\Php80\\' => array($vendorDir . '/symfony/polyfill-php80'), 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'), 'Symfony\\Component\\Process\\' => array($vendorDir . '/symfony/process'), 'Dzava\\Lighthouse\\' => array($vendorDir . '/jeroen-g/lighthouse/src'), diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index ae44c1e1..784eb1af 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -25,51 +25,26 @@ public static function getLoader() require __DIR__ . '/platform_check.php'; spl_autoload_register(array('ComposerAutoloaderInit98dde460e8a16c8877d8f8d8a8e6921c', 'loadClassLoader'), true, true); - self::$loader = $loader = new \Composer\Autoload\ClassLoader(); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); spl_autoload_unregister(array('ComposerAutoloaderInit98dde460e8a16c8877d8f8d8a8e6921c', 'loadClassLoader')); - $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); - if ($useStaticLoader) { - require __DIR__ . '/autoload_static.php'; + require __DIR__ . '/autoload_static.php'; + call_user_func(\Composer\Autoload\ComposerStaticInit98dde460e8a16c8877d8f8d8a8e6921c::getInitializer($loader)); - call_user_func(\Composer\Autoload\ComposerStaticInit98dde460e8a16c8877d8f8d8a8e6921c::getInitializer($loader)); - } else { - $map = require __DIR__ . '/autoload_namespaces.php'; - foreach ($map as $namespace => $path) { - $loader->set($namespace, $path); - } + $loader->register(true); - $map = require __DIR__ . '/autoload_psr4.php'; - foreach ($map as $namespace => $path) { - $loader->setPsr4($namespace, $path); - } + $filesToLoad = \Composer\Autoload\ComposerStaticInit98dde460e8a16c8877d8f8d8a8e6921c::$files; + $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { + if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { + $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; - $classMap = require __DIR__ . '/autoload_classmap.php'; - if ($classMap) { - $loader->addClassMap($classMap); + require $file; } - } - - $loader->register(true); - - if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInit98dde460e8a16c8877d8f8d8a8e6921c::$files; - } else { - $includeFiles = require __DIR__ . '/autoload_files.php'; - } - foreach ($includeFiles as $fileIdentifier => $file) { - composerRequire98dde460e8a16c8877d8f8d8a8e6921c($fileIdentifier, $file); + }, null, null); + foreach ($filesToLoad as $fileIdentifier => $file) { + $requireFile($fileIdentifier, $file); } return $loader; } } - -function composerRequire98dde460e8a16c8877d8f8d8a8e6921c($fileIdentifier, $file) -{ - if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { - require $file; - - $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; - } -} diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 1e39264a..4133061e 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -7,6 +7,7 @@ class ComposerStaticInit98dde460e8a16c8877d8f8d8a8e6921c { public static $files = array ( + 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php', 'e9b48b9bab803e9eba6dfd8e270dddfd' => __DIR__ . '/..' . '/ducks-project/spl-types/bootstrap.php', '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', ); @@ -14,6 +15,7 @@ class ComposerStaticInit98dde460e8a16c8877d8f8d8a8e6921c public static $prefixLengthsPsr4 = array ( 'S' => array ( + 'Symfony\\Polyfill\\Php80\\' => 23, 'Symfony\\Polyfill\\Mbstring\\' => 26, 'Symfony\\Component\\Process\\' => 26, ), @@ -25,6 +27,10 @@ class ComposerStaticInit98dde460e8a16c8877d8f8d8a8e6921c ); public static $prefixDirsPsr4 = array ( + 'Symfony\\Polyfill\\Php80\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/polyfill-php80', + ), 'Symfony\\Polyfill\\Mbstring\\' => array ( 0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring', @@ -44,6 +50,7 @@ class ComposerStaticInit98dde460e8a16c8877d8f8d8a8e6921c ); public static $classMap = array ( + 'Attribute' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Attribute.php', 'ComposerAutoloaderInit98dde460e8a16c8877d8f8d8a8e6921c' => __DIR__ . '/..' . '/composer/autoload_real.php', 'Composer\\Autoload\\ClassLoader' => __DIR__ . '/..' . '/composer/ClassLoader.php', 'Composer\\Autoload\\ComposerStaticInit98dde460e8a16c8877d8f8d8a8e6921c' => __DIR__ . '/..' . '/composer/autoload_static.php', @@ -59,6 +66,7 @@ class ComposerStaticInit98dde460e8a16c8877d8f8d8a8e6921c 'Dzava\\Lighthouse\\Tests\\Integration\\LighthouseTest' => __DIR__ . '/..' . '/jeroen-g/lighthouse/tests/Integration/LighthouseTest.php', 'Dzava\\Lighthouse\\Tests\\Unit\\LighthouseTest' => __DIR__ . '/..' . '/jeroen-g/lighthouse/tests/Unit/LighthouseTest.php', 'Dzava\\Lighthouse\\Tests\\Unit\\MockLighthouse' => __DIR__ . '/..' . '/jeroen-g/lighthouse/tests/Unit/LighthouseTest.php', + 'PhpToken' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php', 'Piwik\\Plugins\\PerformanceAudit\\API' => __DIR__ . '/../..' . '/API.php', 'Piwik\\Plugins\\PerformanceAudit\\Archiver' => __DIR__ . '/../..' . '/Archiver.php', 'Piwik\\Plugins\\PerformanceAudit\\Columns\\Filters\\AuditScoreClassifier' => __DIR__ . '/../..' . '/Columns/Filters/AuditScoreClassifier.php', @@ -118,6 +126,7 @@ class ComposerStaticInit98dde460e8a16c8877d8f8d8a8e6921c 'Piwik\\Plugins\\PerformanceAudit\\tests\\Unit\\Filter\\AuditScoreClassifierTest' => __DIR__ . '/../..' . '/tests/Unit/Filter/AuditScoreClassifierTest.php', 'Piwik\\Plugins\\PerformanceAudit\\tests\\Unit\\Metric\\PercentTest' => __DIR__ . '/../..' . '/tests/Unit/Metric/PercentTest.php', 'Piwik\\Plugins\\PerformanceAudit\\tests\\Unit\\Metric\\SecondsTest' => __DIR__ . '/../..' . '/tests/Unit/Metric/SecondsTest.php', + 'Stringable' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Stringable.php', 'Symfony\\Component\\Process\\Exception\\ExceptionInterface' => __DIR__ . '/..' . '/symfony/process/Exception/ExceptionInterface.php', 'Symfony\\Component\\Process\\Exception\\InvalidArgumentException' => __DIR__ . '/..' . '/symfony/process/Exception/InvalidArgumentException.php', 'Symfony\\Component\\Process\\Exception\\LogicException' => __DIR__ . '/..' . '/symfony/process/Exception/LogicException.php', @@ -136,6 +145,10 @@ class ComposerStaticInit98dde460e8a16c8877d8f8d8a8e6921c 'Symfony\\Component\\Process\\Process' => __DIR__ . '/..' . '/symfony/process/Process.php', 'Symfony\\Component\\Process\\ProcessUtils' => __DIR__ . '/..' . '/symfony/process/ProcessUtils.php', 'Symfony\\Polyfill\\Mbstring\\Mbstring' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/Mbstring.php', + 'Symfony\\Polyfill\\Php80\\Php80' => __DIR__ . '/..' . '/symfony/polyfill-php80/Php80.php', + 'Symfony\\Polyfill\\Php80\\PhpToken' => __DIR__ . '/..' . '/symfony/polyfill-php80/PhpToken.php', + 'UnhandledMatchError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php', + 'ValueError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/ValueError.php', ); public static function getInitializer(ClassLoader $loader) diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 3cdee048..ed06e133 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -2,32 +2,32 @@ "packages": [ { "name": "ducks-project/spl-types", - "version": "v1.1.0", - "version_normalized": "1.1.0.0", + "version": "v1.2.0", + "version_normalized": "1.2.0.0", "source": { "type": "git", "url": "https://github.com/ducks-project/spl-types.git", - "reference": "814f5b719fb39975321db0eaf66c4e0d2d93f53e" + "reference": "57fbd86788341f0d026c29f368058414f809870f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ducks-project/spl-types/zipball/814f5b719fb39975321db0eaf66c4e0d2d93f53e", - "reference": "814f5b719fb39975321db0eaf66c4e0d2d93f53e", + "url": "https://api.github.com/repos/ducks-project/spl-types/zipball/57fbd86788341f0d026c29f368058414f809870f", + "reference": "57fbd86788341f0d026c29f368058414f809870f", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2019-03-06T13:11:02+00:00", + "time": "2020-11-25T11:28:05+00:00", "type": "library", "installation-source": "dist", "autoload": { - "psr-4": { - "Ducks\\Component\\SplTypes\\": "" - }, "files": [ "bootstrap.php" ], + "psr-4": { + "Ducks\\Component\\SplTypes\\": "" + }, "exclude-from-classmap": [ "/Tests/" ] @@ -61,6 +61,21 @@ "poo", "splenum" ], + "support": { + "email": "adrien.loyant@gmail.com", + "issues": "https://github.com/ducks-project/spl-types/issues", + "source": "https://github.com/ducks-project/spl-types/tree/v1.2.0" + }, + "funding": [ + { + "url": "https://github.com/donaldinou", + "type": "github" + }, + { + "url": "https://opencollective.com/ducks-project", + "type": "open_collective" + } + ], "install-path": "../ducks-project/spl-types" }, { @@ -112,30 +127,33 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.20.0", - "version_normalized": "1.20.0.0", + "version": "v1.28.0", + "version_normalized": "1.28.0.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "39d483bdf39be819deabf04ec872eb0b2410b531" + "reference": "42292d99c55abe617799667f454222c54c60e229" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/39d483bdf39be819deabf04ec872eb0b2410b531", - "reference": "39d483bdf39be819deabf04ec872eb0b2410b531", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/42292d99c55abe617799667f454222c54c60e229", + "reference": "42292d99c55abe617799667f454222c54c60e229", "shasum": "" }, "require": { "php": ">=7.1" }, + "provide": { + "ext-mbstring": "*" + }, "suggest": { "ext-mbstring": "For best performance" }, - "time": "2020-10-23T14:02:19+00:00", + "time": "2023-07-28T09:04:16+00:00", "type": "library", "extra": { "branch-alias": { - "dev-main": "1.20-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -144,11 +162,94 @@ }, "installation-source": "dist", "autoload": { + "files": [ + "bootstrap.php" + ], "psr-4": { "Symfony\\Polyfill\\Mbstring\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.28.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/polyfill-mbstring" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.28.0", + "version_normalized": "1.28.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/6caa57379c4aec19c0a12a38b59b26487dcfe4b5", + "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "time": "2023-01-26T09:26:14+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.28-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "installation-source": "dist", + "autoload": { "files": [ "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "classmap": [ + "Resources/stubs" ] }, "notification-url": "https://packagist.org/downloads/", @@ -156,6 +257,10 @@ "MIT" ], "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, { "name": "Nicolas Grekas", "email": "p@tchwork.com" @@ -165,17 +270,16 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony polyfill for the Mbstring extension", + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", "homepage": "https://symfony.com", "keywords": [ "compatibility", - "mbstring", "polyfill", "portable", "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.20.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.28.0" }, "funding": [ { @@ -191,27 +295,28 @@ "type": "tidelift" } ], - "install-path": "../symfony/polyfill-mbstring" + "install-path": "../symfony/polyfill-php80" }, { "name": "symfony/process", - "version": "v4.4.18", - "version_normalized": "4.4.18.0", + "version": "v4.4.44", + "version_normalized": "4.4.44.0", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "075316ff72233ce3d04a9743414292e834f2cb4a" + "reference": "5cee9cdc4f7805e2699d9fd66991a0e6df8252a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/075316ff72233ce3d04a9743414292e834f2cb4a", - "reference": "075316ff72233ce3d04a9743414292e834f2cb4a", + "url": "https://api.github.com/repos/symfony/process/zipball/5cee9cdc4f7805e2699d9fd66991a0e6df8252a2", + "reference": "5cee9cdc4f7805e2699d9fd66991a0e6df8252a2", "shasum": "" }, "require": { - "php": ">=7.1.3" + "php": ">=7.1.3", + "symfony/polyfill-php80": "^1.16" }, - "time": "2020-12-08T16:59:59+00:00", + "time": "2022-06-27T13:16:42+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -236,10 +341,10 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Process Component", + "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v4.4.18" + "source": "https://github.com/symfony/process/tree/v4.4.44" }, "funding": [ { @@ -258,5 +363,6 @@ "install-path": "../symfony/process" } ], - "dev": false + "dev": false, + "dev-package-names": [] } diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 9fa362e4..2f857d8f 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -1,60 +1,68 @@ - - array ( - 'pretty_version' => 'dev-4.x-dev', - 'version' => 'dev-4.x-dev', - 'aliases' => - array ( + array( + 'name' => 'devdavido/performance-audit-plugin', + 'pretty_version' => 'dev-5.x-dev', + 'version' => 'dev-5.x-dev', + 'reference' => '6bfad409aa2af43772a1dc53d87927a53fd3df26', + 'type' => 'project', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'dev' => false, ), - 'reference' => '966739c860cee8c164e596688c3e6055c8de29a9', - 'name' => 'devdavido/performance-audit-plugin', - ), - 'versions' => - array ( - 'devdavido/performance-audit-plugin' => - array ( - 'pretty_version' => 'dev-4.x-dev', - 'version' => 'dev-4.x-dev', - 'aliases' => - array ( - ), - 'reference' => '966739c860cee8c164e596688c3e6055c8de29a9', + 'versions' => array( + 'devdavido/performance-audit-plugin' => array( + 'pretty_version' => 'dev-5.x-dev', + 'version' => 'dev-5.x-dev', + 'reference' => '6bfad409aa2af43772a1dc53d87927a53fd3df26', + 'type' => 'project', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'ducks-project/spl-types' => array( + 'pretty_version' => 'v1.2.0', + 'version' => '1.2.0.0', + 'reference' => '57fbd86788341f0d026c29f368058414f809870f', + 'type' => 'library', + 'install_path' => __DIR__ . '/../ducks-project/spl-types', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'jeroen-g/lighthouse' => array( + 'pretty_version' => 'v0.2', + 'version' => '0.2.0.0', + 'reference' => '9cabb6a857b1a9ccc537328956b4e0af2c370f9a', + 'type' => 'library', + 'install_path' => __DIR__ . '/../jeroen-g/lighthouse', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/polyfill-mbstring' => array( + 'pretty_version' => 'v1.28.0', + 'version' => '1.28.0.0', + 'reference' => '42292d99c55abe617799667f454222c54c60e229', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/polyfill-php80' => array( + 'pretty_version' => 'v1.28.0', + 'version' => '1.28.0.0', + 'reference' => '6caa57379c4aec19c0a12a38b59b26487dcfe4b5', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/polyfill-php80', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/process' => array( + 'pretty_version' => 'v4.4.44', + 'version' => '4.4.44.0', + 'reference' => '5cee9cdc4f7805e2699d9fd66991a0e6df8252a2', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/process', + 'aliases' => array(), + 'dev_requirement' => false, + ), ), - 'ducks-project/spl-types' => - array ( - 'pretty_version' => 'v1.1.0', - 'version' => '1.1.0.0', - 'aliases' => - array ( - ), - 'reference' => '814f5b719fb39975321db0eaf66c4e0d2d93f53e', - ), - 'jeroen-g/lighthouse' => - array ( - 'pretty_version' => 'v0.2', - 'version' => '0.2.0.0', - 'aliases' => - array ( - ), - 'reference' => '9cabb6a857b1a9ccc537328956b4e0af2c370f9a', - ), - 'symfony/polyfill-mbstring' => - array ( - 'pretty_version' => 'v1.20.0', - 'version' => '1.20.0.0', - 'aliases' => - array ( - ), - 'reference' => '39d483bdf39be819deabf04ec872eb0b2410b531', - ), - 'symfony/process' => - array ( - 'pretty_version' => 'v4.4.18', - 'version' => '4.4.18.0', - 'aliases' => - array ( - ), - 'reference' => '075316ff72233ce3d04a9743414292e834f2cb4a', - ), - ), ); diff --git a/vendor/composer/platform_check.php b/vendor/composer/platform_check.php index b2112ccc..a8b98d5c 100644 --- a/vendor/composer/platform_check.php +++ b/vendor/composer/platform_check.php @@ -5,18 +5,22 @@ $issues = array(); if (!(PHP_VERSION_ID >= 70205)) { - $issues[] = 'Your Composer dependencies require a PHP version ">= 7.2.5". You are running ' . PHP_VERSION . '.'; -} - -$missingExtensions = array(); -extension_loaded('json') || $missingExtensions[] = 'json'; -extension_loaded('spl') || $missingExtensions[] = 'spl'; - -if ($missingExtensions) { - $issues[] = 'Your Composer dependencies require the following PHP extensions to be installed: ' . implode(', ', $missingExtensions); + $issues[] = 'Your Composer dependencies require a PHP version ">= 7.2.5". You are running ' . PHP_VERSION . '.'; } if ($issues) { - echo 'Composer detected issues in your platform:' . "\n\n" . implode("\n", $issues); - exit(104); + if (!headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + if (!ini_get('display_errors')) { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); + } elseif (!headers_sent()) { + echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; + } + } + trigger_error( + 'Composer detected issues in your platform: ' . implode(' ', $issues), + E_USER_ERROR + ); } diff --git a/vendor/ducks-project/spl-types/.circleci/config.yml b/vendor/ducks-project/spl-types/.circleci/config.yml new file mode 100644 index 00000000..02fa0d3e --- /dev/null +++ b/vendor/ducks-project/spl-types/.circleci/config.yml @@ -0,0 +1,16 @@ +machine: + php: + version: 5.4.10 + +## Customize dependencies +dependencies: + override: + - mkdir -p build/logs + - composer install --no-interaction --optimize-autoloader + - sed -i 's/^;//' ~/.phpenv/versions/$(phpenv global)/etc/conf.d/xdebug.ini + +## Customize test commands +test: + override: + - php vendor/bin/phpunit Tests/phpunit -c phpunit.xml.dist + - php vendor/bin/atoum -d Tests/atoum diff --git a/vendor/ducks-project/spl-types/.corveralls.yml b/vendor/ducks-project/spl-types/.corveralls.yml new file mode 100644 index 00000000..5ce1686d --- /dev/null +++ b/vendor/ducks-project/spl-types/.corveralls.yml @@ -0,0 +1 @@ +.corveralls.yml diff --git a/vendor/ducks-project/spl-types/.github/FUNDING.yml b/vendor/ducks-project/spl-types/.github/FUNDING.yml new file mode 100644 index 00000000..ef91d76b --- /dev/null +++ b/vendor/ducks-project/spl-types/.github/FUNDING.yml @@ -0,0 +1,4 @@ +# These are supported funding model platforms + +github: [donaldinou] +open_collective: ducks-project diff --git a/vendor/ducks-project/spl-types/.gitignore b/vendor/ducks-project/spl-types/.gitignore index d429c71c..dab6eab3 100644 --- a/vendor/ducks-project/spl-types/.gitignore +++ b/vendor/ducks-project/spl-types/.gitignore @@ -9,10 +9,11 @@ # PHPUnit /app/phpunit.xml /phpunit.xml +.phpunit.result.cache # Composer PHAR /composer.phar -/composer.lock +#/composer.lock # Sublime project *.tmplanguage.cache diff --git a/vendor/ducks-project/spl-types/.styleci.yml b/vendor/ducks-project/spl-types/.styleci.yml new file mode 100644 index 00000000..6d8ab59e --- /dev/null +++ b/vendor/ducks-project/spl-types/.styleci.yml @@ -0,0 +1,13 @@ +preset: psr2 + +enabled: + - concat_with_spaces + - unused_use + +finder: + exclude: + - "Tests" + name: + - "*.php" + path: + - "." diff --git a/vendor/ducks-project/spl-types/.travis.yml b/vendor/ducks-project/spl-types/.travis.yml index 22fa3bd3..ee3c1b7a 100644 --- a/vendor/ducks-project/spl-types/.travis.yml +++ b/vendor/ducks-project/spl-types/.travis.yml @@ -1,15 +1,28 @@ language: php dist: trusty php: - - 5.4 - - 5.5 +# - 5.4 +# - 5.5 - 5.6 - 7.0 - 7.1 - 7.2 - 7.3 -matrix: - include: - - php: 5.3 - dist: precise -script: phpunit --version + +#matrix: +# include: +# - php: 5.3 +# dist: precise + +before_script: + - composer require --dev phpunit/phpunit ^5 + - composer require --dev php-coveralls/php-coveralls ^1 + - composer require --dev atoum/atoum ^3 + - composer install --no-interaction --optimize-autoloader +script: + - mkdir -p build/logs + - php vendor/bin/phpunit Tests/phpunit -c phpunit.xml.dist + - php vendor/bin/atoum -d Tests/atoum + +after_success: + - travis_retry php vendor/bin/php-coveralls diff --git a/vendor/ducks-project/spl-types/README.md b/vendor/ducks-project/spl-types/README.md index 468cc0d6..94c14bc4 100644 --- a/vendor/ducks-project/spl-types/README.md +++ b/vendor/ducks-project/spl-types/README.md @@ -2,6 +2,20 @@ [![Build Status](https://travis-ci.org/ducks-project/spl-types.svg)](https://travis-ci.org/ducks-project/spl-types) +[![Coverage Status](https://coveralls.io/repos/github/ducks-project/spl-types/badge.svg)](https://coveralls.io/github/ducks-project/spl-types) + +[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ducks-project/spl-types/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ducks-project/spl-types/?branch=master) +[![Code Coverage](https://scrutinizer-ci.com/g/ducks-project/spl-types/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/ducks-project/spl-types/?branch=master) +[![Build Status](https://scrutinizer-ci.com/g/ducks-project/spl-types/badges/build.png?b=master)](https://scrutinizer-ci.com/g/ducks-project/spl-types/build-status/master) +[![Code Intelligence Status](https://scrutinizer-ci.com/g/ducks-project/spl-types/badges/code-intelligence.svg?b=master)](https://scrutinizer-ci.com/code-intelligence) + +[![License](https://poser.pugx.org/ducks-project/spl-types/license)](https://packagist.org/packages/ducks-project/spl-types) +[![Latest Stable Version](https://poser.pugx.org/ducks-project/spl-types/v/stable)](https://packagist.org/packages/ducks-project/spl-types) + +[![Total Downloads](https://poser.pugx.org/ducks-project/spl-types/downloads)](https://packagist.org/packages/ducks-project/spl-types) +[![Monthly Downloads](https://poser.pugx.org/ducks-project/spl-types/d/monthly)](https://packagist.org/packages/ducks-project/spl-types) +[![Daily Downloads](https://poser.pugx.org/ducks-project/spl-types/d/daily)](https://packagist.org/packages/ducks-project/spl-types) + * Project page: https://github.com/ducks-project/spl-types * Repository: https://github.com/ducks-project/spl-types * Original PHP extension: http://php.net/manual/en/intro.spl-types.php @@ -18,6 +32,94 @@ It provides classes unavailable if you can't install [SPL Types](http://php.net/ - [`SplBool`](http://php.net/manual/en/class.splbool.php) - [`SplString`](http://php.net/manual/en/class.splstring.php) +## Known Issues & Limitations + +### SplTypes + +Because limitations of PHP it is impossible to directly reaffect Spl variables like the original extension. +For example: + +``` +// With Spl Extension. +$int = new \SplInt(); +$int = 'test'; // Exception. + +// With Spl Plyfill. +$int = new \SplInt(); +$int = 'test'; // Just unset Object and affect 'test' to $int variable. +``` + +In the same way, Spl_Types polyfill is not really strict typing the extension. So, the code below is not "correct". + +``` +// With Spl Extension. +$test = 10; +$value = new \SplInt($test); +if ($test == $value) { + echo 'OK'; +} + +// With Spl Plyfill. +$test = 10; +$string = new \SplInt($test); +if ($test === $string) { // Cast Error. + echo 'OK'; +} +``` + +### SplInt & Splfloat + +Because of PHP behaviors you can't easily do operations like: + +``` +$int = new \SplInt(); +$int++; // Exception. + +$int + 10; // Exception. +``` + +Unfortunately, you need to do like below: + +``` +$int = new \SplInt(); + +$result = (int) (string) $int + 10; // Shame... +``` + +### SplEnum + +As it was said, you need to manually cast your object to string in order to make comparison. + +``` +class Month extends \SplEnum { + const __default = self::January; + const January = 1; + // ... +} +$enum = new Month(); + +// WARNING : Object of class Month could not be converted to int... +if (Month::January == $enum) { + // KO ... +} + +// But, +if (Month::January == (string) $enum) { + // ... OK +} +``` + +### SplBool + +Like it was explain above, the \SplBool object isn't a strict boolean so take care about your equality test. + +``` +$bool = new \SplBool(false); +if ($bool) { + echo 'This is true'; // Object is not null so it pass test... +} +``` + ## License This library is released under the [MIT license](LICENSE). diff --git a/vendor/ducks-project/spl-types/SplBool.php b/vendor/ducks-project/spl-types/SplBool.php index cfde8ef7..faac4b1a 100644 --- a/vendor/ducks-project/spl-types/SplBool.php +++ b/vendor/ducks-project/spl-types/SplBool.php @@ -16,21 +16,29 @@ * * @see SplBool http://php.net/manual/en/class.splbool.php */ -class SplBool extends SplEnum { - +class SplBool extends SplEnum +{ /** * @var bool + * + * @codingStandardsIgnoreStart */ const __default = self::false; + // @codingStandardsIgnoreEnd /** * @var bool + * + * @codingStandardsIgnoreStart */ const false = false; + // @codingStandardsIgnoreEnd /** * @var bool + * + * @codingStandardsIgnoreStart */ const true = true; - + // @codingStandardsIgnoreEnd } diff --git a/vendor/ducks-project/spl-types/SplEnum.php b/vendor/ducks-project/spl-types/SplEnum.php index 701542a2..56ba97bd 100644 --- a/vendor/ducks-project/spl-types/SplEnum.php +++ b/vendor/ducks-project/spl-types/SplEnum.php @@ -16,7 +16,22 @@ * * @see SplEnum http://php.net/manual/en/class.splenum.php */ -class SplEnum extends SplType { +abstract class SplEnum extends SplType +{ + /** + * {@inheritdoc} + */ + public function __construct($initial_value = null, $strict = true) + { + if ($initial_value === null) { + $initial_value = static::__default; + } + $class = new \ReflectionClass($this); + if (!in_array($initial_value, $class->getConstants(), $strict)) { + throw new \UnexpectedValueException('Value not a const in enum ' . $class->getShortName()); + } + $this->__default = $initial_value; + } /** * Returns all consts (possible values) as an array. @@ -24,7 +39,8 @@ class SplEnum extends SplType { * @param bool $include_default Whether to include __default property. * @return array */ - final public function getConstList( $include_default=false ) { + final public function getConstList($include_default = false) + { $class = new \ReflectionClass($this); $constants = $class->getConstants(); if (!$include_default) { @@ -32,5 +48,4 @@ final public function getConstList( $include_default=false ) { } return $constants; } - } diff --git a/vendor/ducks-project/spl-types/SplFloat.php b/vendor/ducks-project/spl-types/SplFloat.php index 778b1809..a00927f2 100644 --- a/vendor/ducks-project/spl-types/SplFloat.php +++ b/vendor/ducks-project/spl-types/SplFloat.php @@ -16,28 +16,28 @@ * * @see http://php.net/manual/en/class.splfloat.php */ -class SplFloat extends SplType { - +class SplFloat extends SplType +{ /** * @var float + * + * @codingStandardsIgnoreStart */ const __default = 0; + // @codingStandardsIgnoreEnd /** - * Creates a new value of some type - * - * @param mixed $initial_value Type and default value depends on the extension class. - * @param bool $strict Whether to set the object's sctrictness. - * @return void - * - * @throws \UnexpectedValueException if incompatible type is given. + * {@inheritdoc} */ - public function __construct($initial_value, $strict=null) { - $class = new \ReflectionClass($this); - if(!is_float($initial_value) && !is_int($initial_value)) { + public function __construct($initial_value = self::__default, $strict = true) + { + parent::__construct($initial_value, $strict); + if (!$strict) { + $initial_value = (float) $initial_value; + } + if (!is_float($initial_value) && !is_int($initial_value)) { throw new \UnexpectedValueException('Value not a float'); } $this->__default = $initial_value; } - } diff --git a/vendor/ducks-project/spl-types/SplInt.php b/vendor/ducks-project/spl-types/SplInt.php index c9cab720..3827e6d3 100644 --- a/vendor/ducks-project/spl-types/SplInt.php +++ b/vendor/ducks-project/spl-types/SplInt.php @@ -16,28 +16,28 @@ * * @see SplInt http://php.net/manual/en/class.splint.php */ -class SplInt extends SplType { - +class SplInt extends SplType +{ /** * @var int + * + * @codingStandardsIgnoreStart */ const __default = 0; + // @codingStandardsIgnoreEnd /** - * Creates a new value of some type - * - * @param mixed $initial_value Type and default value depends on the extension class. - * @param bool $strict Whether to set the object's sctrictness. - * @return void - * - * @throws \UnexpectedValueException if incompatible type is given. + * {@inheritdoc} */ - public function __construct($initial_value, $strict=null) { - $class = new \ReflectionClass($this); - if(!is_int($initial_value)) { + public function __construct($initial_value = self::__default, $strict = true) + { + parent::__construct($initial_value, $strict); + if (!$strict) { + $initial_value = (int) $initial_value; + } + if (!is_int($initial_value)) { throw new \UnexpectedValueException('Value not an integer'); } $this->__default = $initial_value; } - } diff --git a/vendor/ducks-project/spl-types/SplString.php b/vendor/ducks-project/spl-types/SplString.php index 9225e844..83500b86 100644 --- a/vendor/ducks-project/spl-types/SplString.php +++ b/vendor/ducks-project/spl-types/SplString.php @@ -16,28 +16,28 @@ * * @see SplString http://php.net/manual/en/class.splstring.php */ -class SplString extends SplType { - +class SplString extends SplType +{ /** * @var string + * + * @codingStandardsIgnoreStart */ const __default = ''; + // @codingStandardsIgnoreEnd /** - * Creates a new value of some type - * - * @param mixed $initial_value Type and default value depends on the extension class. - * @param bool $strict Whether to set the object's sctrictness. - * @return void - * - * @throws \UnexpectedValueException if incompatible type is given. + * {@inheritdoc} */ - public function __construct($initial_value, $strict=null) { - $class = new \ReflectionClass($this); - if(!is_string($initial_value)) { + public function __construct($initial_value = self::__default, $strict = true) + { + parent::__construct($initial_value, $strict); + if (!$strict) { + $initial_value = (string) $initial_value; + } + if (!is_string($initial_value)) { throw new \UnexpectedValueException('Value not a string'); } $this->__default = $initial_value; } - } diff --git a/vendor/ducks-project/spl-types/SplType.php b/vendor/ducks-project/spl-types/SplType.php index 9d10414a..5effdaae 100644 --- a/vendor/ducks-project/spl-types/SplType.php +++ b/vendor/ducks-project/spl-types/SplType.php @@ -16,12 +16,15 @@ * * @see SplType http://php.net/manual/en/class.spltype.php */ -abstract class SplType { - +abstract class SplType +{ /** - * Default value + * Default value. + * + * @codingStandardsIgnoreStart */ const __default = null; + // @codingStandardsIgnoreEnd /** * Internal enum value @@ -29,50 +32,52 @@ abstract class SplType { public $__default; /** - * Creates a new value of some type + * Creates a new value of some type. * * @param mixed $initial_value Type and default value depends on the extension class. * @param bool $strict Whether to set the object's sctrictness. * @return void * * @throws \UnexpectedValueException if incompatible type is given. + * + * @codingStandardsIgnoreStart */ - public function __construct($initial_value=null, $strict=null) { + public function __construct($initial_value = self::__default, $strict = true) + { if ($initial_value === null) { $initial_value = static::__default; } - $class = new \ReflectionClass($this); - if(!in_array($initial_value, $class->getConstants())) { - throw new \UnexpectedValueException('Value not a const in enum '.$class->getShortName()); - } $this->__default = $initial_value; } + // @codingStandardsIgnoreEnd /** - * Stringify object + * Stringify object. * * @return string */ - final public function __toString() { - return (string)$this->__default; + final public function __toString() + { + return (string) $this->__default; } /** - * Export object + * Export object. * * @return SplType */ - final public static function __set_state($properties) { + final public static function __set_state($properties) + { return new static($properties['__default']); } /** - * Dumping object (php > 5.6.0) + * Dumping object (php > 5.6.0). * * @return array */ - final public function __debugInfo() { - return array( '__default' => $this->__default); + final public function __debugInfo() + { + return array('__default' => $this->__default); } - } diff --git a/vendor/ducks-project/spl-types/phpunit.xml.dist b/vendor/ducks-project/spl-types/phpunit.xml.dist new file mode 100644 index 00000000..a6fdc682 --- /dev/null +++ b/vendor/ducks-project/spl-types/phpunit.xml.dist @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + ./Tests/ + + + + + + ./ + + ./Resources + ./Tests + ./vendor + + + + diff --git a/vendor/symfony/polyfill-mbstring/LICENSE b/vendor/symfony/polyfill-mbstring/LICENSE index 4cd8bdd3..6e3afce6 100644 --- a/vendor/symfony/polyfill-mbstring/LICENSE +++ b/vendor/symfony/polyfill-mbstring/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2015-2019 Fabien Potencier +Copyright (c) 2015-present 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/polyfill-mbstring/Mbstring.php b/vendor/symfony/polyfill-mbstring/Mbstring.php index 7bb30237..2e0b9694 100644 --- a/vendor/symfony/polyfill-mbstring/Mbstring.php +++ b/vendor/symfony/polyfill-mbstring/Mbstring.php @@ -67,19 +67,20 @@ */ final class Mbstring { - const MB_CASE_FOLD = PHP_INT_MAX; + public const MB_CASE_FOLD = \PHP_INT_MAX; - private static $encodingList = array('ASCII', 'UTF-8'); + private const SIMPLE_CASE_FOLD = [ + ['µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"], + ['μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', "\xE1\xB9\xA1", 'ι'], + ]; + + private static $encodingList = ['ASCII', 'UTF-8']; private static $language = 'neutral'; private static $internalEncoding = 'UTF-8'; - private static $caseFold = array( - array('µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"), - array('μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', "\xE1\xB9\xA1", 'ι'), - ); public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null) { - if (\is_array($fromEncoding) || false !== strpos($fromEncoding, ',')) { + if (\is_array($fromEncoding) || (null !== $fromEncoding && false !== strpos($fromEncoding, ','))) { $fromEncoding = self::mb_detect_encoding($s, $fromEncoding); } else { $fromEncoding = self::getEncoding($fromEncoding); @@ -104,11 +105,11 @@ public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null $s = iconv($fromEncoding, 'UTF-8//IGNORE', $s); } - return preg_replace_callback('/[\x80-\xFF]+/', array(__CLASS__, 'html_encoding_callback'), $s); + return preg_replace_callback('/[\x80-\xFF]+/', [__CLASS__, 'html_encoding_callback'], $s); } if ('HTML-ENTITIES' === $fromEncoding) { - $s = html_entity_decode($s, ENT_COMPAT, 'UTF-8'); + $s = html_entity_decode($s, \ENT_COMPAT, 'UTF-8'); $fromEncoding = 'UTF-8'; } @@ -119,7 +120,7 @@ public static function mb_convert_variables($toEncoding, $fromEncoding, &...$var { $ok = true; array_walk_recursive($vars, function (&$v) use (&$ok, $toEncoding, $fromEncoding) { - if (false === $v = Mbstring::mb_convert_encoding($v, $toEncoding, $fromEncoding)) { + if (false === $v = self::mb_convert_encoding($v, $toEncoding, $fromEncoding)) { $ok = false; } }); @@ -134,23 +135,23 @@ public static function mb_decode_mimeheader($s) public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null) { - trigger_error('mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', E_USER_WARNING); + trigger_error('mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', \E_USER_WARNING); } public static function mb_decode_numericentity($s, $convmap, $encoding = null) { - if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) { - trigger_error('mb_decode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', E_USER_WARNING); + if (null !== $s && !\is_scalar($s) && !(\is_object($s) && method_exists($s, '__toString'))) { + trigger_error('mb_decode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', \E_USER_WARNING); return null; } - if (!\is_array($convmap) || !$convmap) { + if (!\is_array($convmap) || (80000 > \PHP_VERSION_ID && !$convmap)) { return false; } if (null !== $encoding && !\is_scalar($encoding)) { - trigger_error('mb_decode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', E_USER_WARNING); + trigger_error('mb_decode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', \E_USER_WARNING); return ''; // Instead of null (cf. mb_encode_numericentity). } @@ -183,7 +184,7 @@ public static function mb_decode_numericentity($s, $convmap, $encoding = null) $c = isset($m[2]) ? (int) hexdec($m[2]) : $m[1]; for ($i = 0; $i < $cnt; $i += 4) { if ($c >= $convmap[$i] && $c <= $convmap[$i + 1]) { - return Mbstring::mb_chr($c - $convmap[$i + 2]); + return self::mb_chr($c - $convmap[$i + 2]); } } @@ -199,24 +200,24 @@ public static function mb_decode_numericentity($s, $convmap, $encoding = null) public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = false) { - if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) { - trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', E_USER_WARNING); + if (null !== $s && !\is_scalar($s) && !(\is_object($s) && method_exists($s, '__toString'))) { + trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', \E_USER_WARNING); return null; } - if (!\is_array($convmap) || !$convmap) { + if (!\is_array($convmap) || (80000 > \PHP_VERSION_ID && !$convmap)) { return false; } if (null !== $encoding && !\is_scalar($encoding)) { - trigger_error('mb_encode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', E_USER_WARNING); + trigger_error('mb_encode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', \E_USER_WARNING); return null; // Instead of '' (cf. mb_decode_numericentity). } if (null !== $is_hex && !\is_scalar($is_hex)) { - trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, '.\gettype($s).' given', E_USER_WARNING); + trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, '.\gettype($s).' given', \E_USER_WARNING); return null; } @@ -237,7 +238,7 @@ public static function mb_encode_numericentity($s, $convmap, $encoding = null, $ $s = iconv($encoding, 'UTF-8//IGNORE', $s); } - static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4); + static $ulenMask = ["\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4]; $cnt = floor(\count($convmap) / 4) * 4; $i = 0; @@ -285,14 +286,14 @@ public static function mb_convert_case($s, $mode, $encoding = null) $s = iconv($encoding, 'UTF-8//IGNORE', $s); } - if (MB_CASE_TITLE == $mode) { + if (\MB_CASE_TITLE == $mode) { static $titleRegexp = null; if (null === $titleRegexp) { $titleRegexp = self::getData('titleCaseRegexp'); } - $s = preg_replace_callback($titleRegexp, array(__CLASS__, 'title_case'), $s); + $s = preg_replace_callback($titleRegexp, [__CLASS__, 'title_case'], $s); } else { - if (MB_CASE_UPPER == $mode) { + if (\MB_CASE_UPPER == $mode) { static $upper = null; if (null === $upper) { $upper = self::getData('upperCase'); @@ -300,7 +301,11 @@ public static function mb_convert_case($s, $mode, $encoding = null) $map = $upper; } else { if (self::MB_CASE_FOLD === $mode) { - $s = str_replace(self::$caseFold[0], self::$caseFold[1], $s); + static $caseFolding = null; + if (null === $caseFolding) { + $caseFolding = self::getData('caseFolding'); + } + $s = strtr($s, $caseFolding); } static $lower = null; @@ -310,7 +315,7 @@ public static function mb_convert_case($s, $mode, $encoding = null) $map = $lower; } - static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4); + static $ulenMask = ["\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4]; $i = 0; $len = \strlen($s); @@ -351,15 +356,19 @@ public static function mb_internal_encoding($encoding = null) return self::$internalEncoding; } - $encoding = self::getEncoding($encoding); + $normalizedEncoding = self::getEncoding($encoding); - if ('UTF-8' === $encoding || false !== @iconv($encoding, $encoding, ' ')) { - self::$internalEncoding = $encoding; + if ('UTF-8' === $normalizedEncoding || false !== @iconv($normalizedEncoding, $normalizedEncoding, ' ')) { + self::$internalEncoding = $normalizedEncoding; return true; } - return false; + if (80000 > \PHP_VERSION_ID) { + return false; + } + + throw new \ValueError(sprintf('Argument #1 ($encoding) must be a valid encoding, "%s" given', $encoding)); } public static function mb_language($lang = null) @@ -368,20 +377,24 @@ public static function mb_language($lang = null) return self::$language; } - switch ($lang = strtolower($lang)) { + switch ($normalizedLang = strtolower($lang)) { case 'uni': case 'neutral': - self::$language = $lang; + self::$language = $normalizedLang; return true; } - return false; + if (80000 > \PHP_VERSION_ID) { + return false; + } + + throw new \ValueError(sprintf('Argument #1 ($language) must be a valid language, "%s" given', $lang)); } public static function mb_list_encodings() { - return array('UTF-8'); + return ['UTF-8']; } public static function mb_encoding_aliases($encoding) @@ -389,7 +402,7 @@ public static function mb_encoding_aliases($encoding) switch (strtoupper($encoding)) { case 'UTF8': case 'UTF-8': - return array('utf8'); + return ['utf8']; } return false; @@ -397,6 +410,12 @@ public static function mb_encoding_aliases($encoding) public static function mb_check_encoding($var = null, $encoding = null) { + if (PHP_VERSION_ID < 70200 && \is_array($var)) { + trigger_error('mb_check_encoding() expects parameter 1 to be string, array given', \E_USER_WARNING); + + return null; + } + if (null === $encoding) { if (null === $var) { return false; @@ -404,7 +423,21 @@ public static function mb_check_encoding($var = null, $encoding = null) $encoding = self::$internalEncoding; } - return self::mb_detect_encoding($var, array($encoding)) || false !== @iconv($encoding, $encoding, $var); + if (!\is_array($var)) { + return self::mb_detect_encoding($var, [$encoding]) || false !== @iconv($encoding, $encoding, $var); + } + + foreach ($var as $key => $value) { + if (!self::mb_check_encoding($key, $encoding)) { + return false; + } + if (!self::mb_check_encoding($value, $encoding)) { + return false; + } + } + + return true; + } public static function mb_detect_encoding($str, $encodingList = null, $strict = false) @@ -491,9 +524,13 @@ public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = nu $needle = (string) $needle; if ('' === $needle) { - trigger_error(__METHOD__.': Empty delimiter', E_USER_WARNING); + if (80000 > \PHP_VERSION_ID) { + trigger_error(__METHOD__.': Empty delimiter', \E_USER_WARNING); - return false; + return false; + } + + return 0; } return iconv_strpos($haystack, $needle, $offset, $encoding); @@ -519,23 +556,29 @@ public static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = n } } - $pos = iconv_strrpos($haystack, $needle, $encoding); + $pos = '' !== $needle || 80000 > \PHP_VERSION_ID + ? iconv_strrpos($haystack, $needle, $encoding) + : self::mb_strlen($haystack, $encoding); return false !== $pos ? $offset + $pos : false; } public static function mb_str_split($string, $split_length = 1, $encoding = null) { - if (null !== $string && !\is_scalar($string) && !(\is_object($string) && \method_exists($string, '__toString'))) { - trigger_error('mb_str_split() expects parameter 1 to be string, '.\gettype($string).' given', E_USER_WARNING); + if (null !== $string && !\is_scalar($string) && !(\is_object($string) && method_exists($string, '__toString'))) { + trigger_error('mb_str_split() expects parameter 1 to be string, '.\gettype($string).' given', \E_USER_WARNING); return null; } if (1 > $split_length = (int) $split_length) { - trigger_error('The length of each segment must be greater than zero', E_USER_WARNING); + if (80000 > \PHP_VERSION_ID) { + trigger_error('The length of each segment must be greater than zero', \E_USER_WARNING); - return false; + return false; + } + + throw new \ValueError('Argument #2 ($length) must be greater than 0'); } if (null === $encoding) { @@ -550,10 +593,10 @@ public static function mb_str_split($string, $split_length = 1, $encoding = null } $rx .= '.{'.$split_length.'})/us'; - return preg_split($rx, $string, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + return preg_split($rx, $string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY); } - $result = array(); + $result = []; $length = mb_strlen($string, $encoding); for ($i = 0; $i < $length; $i += $split_length) { @@ -565,21 +608,30 @@ public static function mb_str_split($string, $split_length = 1, $encoding = null public static function mb_strtolower($s, $encoding = null) { - return self::mb_convert_case($s, MB_CASE_LOWER, $encoding); + return self::mb_convert_case($s, \MB_CASE_LOWER, $encoding); } public static function mb_strtoupper($s, $encoding = null) { - return self::mb_convert_case($s, MB_CASE_UPPER, $encoding); + return self::mb_convert_case($s, \MB_CASE_UPPER, $encoding); } public static function mb_substitute_character($c = null) { + if (null === $c) { + return 'none'; + } if (0 === strcasecmp($c, 'none')) { return true; } + if (80000 > \PHP_VERSION_ID) { + return false; + } + if (\is_int($c) || 'long' === $c || 'entity' === $c) { + return false; + } - return null !== $c ? false : 'none'; + throw new \ValueError('Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint'); } public static function mb_substr($s, $start, $length = null, $encoding = null) @@ -610,8 +662,10 @@ public static function mb_substr($s, $start, $length = null, $encoding = null) public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) { - $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding); - $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding); + [$haystack, $needle] = str_replace(self::SIMPLE_CASE_FOLD[0], self::SIMPLE_CASE_FOLD[1], [ + self::mb_convert_case($haystack, \MB_CASE_LOWER, $encoding), + self::mb_convert_case($needle, \MB_CASE_LOWER, $encoding), + ]); return self::mb_strpos($haystack, $needle, $offset, $encoding); } @@ -646,8 +700,11 @@ public static function mb_strrichr($haystack, $needle, $part = false, $encoding public static function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) { - $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding); - $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding); + $haystack = self::mb_convert_case($haystack, \MB_CASE_LOWER, $encoding); + $needle = self::mb_convert_case($needle, \MB_CASE_LOWER, $encoding); + + $haystack = str_replace(self::SIMPLE_CASE_FOLD[0], self::SIMPLE_CASE_FOLD[1], $haystack); + $needle = str_replace(self::SIMPLE_CASE_FOLD[0], self::SIMPLE_CASE_FOLD[1], $needle); return self::mb_strrpos($haystack, $needle, $offset, $encoding); } @@ -667,7 +724,7 @@ public static function mb_strstr($haystack, $needle, $part = false, $encoding = public static function mb_get_info($type = 'all') { - $info = array( + $info = [ 'internal_encoding' => self::$internalEncoding, 'http_output' => 'pass', 'http_output_conv_mimetypes' => '^(text/|application/xhtml\+xml)', @@ -682,7 +739,7 @@ public static function mb_get_info($type = 'all') 'detect_order' => self::$encodingList, 'substitute_character' => 'none', 'strict_detection' => 'Off', - ); + ]; if ('all' === $type) { return $info; @@ -770,6 +827,50 @@ public static function mb_ord($s, $encoding = null) return $code; } + public static function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = \STR_PAD_RIGHT, string $encoding = null): string + { + if (!\in_array($pad_type, [\STR_PAD_RIGHT, \STR_PAD_LEFT, \STR_PAD_BOTH], true)) { + throw new \ValueError('mb_str_pad(): Argument #4 ($pad_type) must be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH'); + } + + if (null === $encoding) { + $encoding = self::mb_internal_encoding(); + } + + try { + $validEncoding = @self::mb_check_encoding('', $encoding); + } catch (\ValueError $e) { + throw new \ValueError(sprintf('mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "%s" given', $encoding)); + } + + // BC for PHP 7.3 and lower + if (!$validEncoding) { + throw new \ValueError(sprintf('mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "%s" given', $encoding)); + } + + if (self::mb_strlen($pad_string, $encoding) <= 0) { + throw new \ValueError('mb_str_pad(): Argument #3 ($pad_string) must be a non-empty string'); + } + + $paddingRequired = $length - self::mb_strlen($string, $encoding); + + if ($paddingRequired < 1) { + return $string; + } + + switch ($pad_type) { + case \STR_PAD_LEFT: + return self::mb_substr(str_repeat($pad_string, $paddingRequired), 0, $paddingRequired, $encoding).$string; + case \STR_PAD_RIGHT: + return $string.self::mb_substr(str_repeat($pad_string, $paddingRequired), 0, $paddingRequired, $encoding); + default: + $leftPaddingLength = floor($paddingRequired / 2); + $rightPaddingLength = $paddingRequired - $leftPaddingLength; + + return self::mb_substr(str_repeat($pad_string, $leftPaddingLength), 0, $leftPaddingLength, $encoding).$string.self::mb_substr(str_repeat($pad_string, $rightPaddingLength), 0, $rightPaddingLength, $encoding); + } + } + private static function getSubpart($pos, $part, $haystack, $encoding) { if (false === $pos) { @@ -786,7 +887,7 @@ private static function html_encoding_callback(array $m) { $i = 1; $entities = ''; - $m = unpack('C*', htmlentities($m[0], ENT_COMPAT, 'UTF-8')); + $m = unpack('C*', htmlentities($m[0], \ENT_COMPAT, 'UTF-8')); while (isset($m[$i])) { if (0x80 > $m[$i]) { @@ -809,7 +910,7 @@ private static function html_encoding_callback(array $m) private static function title_case(array $s) { - return self::mb_convert_case($s[1], MB_CASE_UPPER, 'UTF-8').self::mb_convert_case($s[2], MB_CASE_LOWER, 'UTF-8'); + return self::mb_convert_case($s[1], \MB_CASE_UPPER, 'UTF-8').self::mb_convert_case($s[2], \MB_CASE_LOWER, 'UTF-8'); } private static function getData($file) diff --git a/vendor/symfony/polyfill-mbstring/README.md b/vendor/symfony/polyfill-mbstring/README.md index 4efb599d..478b40da 100644 --- a/vendor/symfony/polyfill-mbstring/README.md +++ b/vendor/symfony/polyfill-mbstring/README.md @@ -5,7 +5,7 @@ This component provides a partial, native PHP implementation for the [Mbstring](https://php.net/mbstring) extension. More information can be found in the -[main Polyfill README](https://github.com/symfony/polyfill/blob/master/README.md). +[main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md). License ======= diff --git a/vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php b/vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php new file mode 100644 index 00000000..512bba0b --- /dev/null +++ b/vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php @@ -0,0 +1,119 @@ + 'i̇', + 'µ' => 'μ', + 'ſ' => 's', + 'ͅ' => 'ι', + 'ς' => 'σ', + 'ϐ' => 'β', + 'ϑ' => 'θ', + 'ϕ' => 'φ', + 'ϖ' => 'π', + 'ϰ' => 'κ', + 'ϱ' => 'ρ', + 'ϵ' => 'ε', + 'ẛ' => 'ṡ', + 'ι' => 'ι', + 'ß' => 'ss', + 'ʼn' => 'ʼn', + 'ǰ' => 'ǰ', + 'ΐ' => 'ΐ', + 'ΰ' => 'ΰ', + 'և' => 'եւ', + 'ẖ' => 'ẖ', + 'ẗ' => 'ẗ', + 'ẘ' => 'ẘ', + 'ẙ' => 'ẙ', + 'ẚ' => 'aʾ', + 'ẞ' => 'ss', + 'ὐ' => 'ὐ', + 'ὒ' => 'ὒ', + 'ὔ' => 'ὔ', + 'ὖ' => 'ὖ', + 'ᾀ' => 'ἀι', + 'ᾁ' => 'ἁι', + 'ᾂ' => 'ἂι', + 'ᾃ' => 'ἃι', + 'ᾄ' => 'ἄι', + 'ᾅ' => 'ἅι', + 'ᾆ' => 'ἆι', + 'ᾇ' => 'ἇι', + 'ᾈ' => 'ἀι', + 'ᾉ' => 'ἁι', + 'ᾊ' => 'ἂι', + 'ᾋ' => 'ἃι', + 'ᾌ' => 'ἄι', + 'ᾍ' => 'ἅι', + 'ᾎ' => 'ἆι', + 'ᾏ' => 'ἇι', + 'ᾐ' => 'ἠι', + 'ᾑ' => 'ἡι', + 'ᾒ' => 'ἢι', + 'ᾓ' => 'ἣι', + 'ᾔ' => 'ἤι', + 'ᾕ' => 'ἥι', + 'ᾖ' => 'ἦι', + 'ᾗ' => 'ἧι', + 'ᾘ' => 'ἠι', + 'ᾙ' => 'ἡι', + 'ᾚ' => 'ἢι', + 'ᾛ' => 'ἣι', + 'ᾜ' => 'ἤι', + 'ᾝ' => 'ἥι', + 'ᾞ' => 'ἦι', + 'ᾟ' => 'ἧι', + 'ᾠ' => 'ὠι', + 'ᾡ' => 'ὡι', + 'ᾢ' => 'ὢι', + 'ᾣ' => 'ὣι', + 'ᾤ' => 'ὤι', + 'ᾥ' => 'ὥι', + 'ᾦ' => 'ὦι', + 'ᾧ' => 'ὧι', + 'ᾨ' => 'ὠι', + 'ᾩ' => 'ὡι', + 'ᾪ' => 'ὢι', + 'ᾫ' => 'ὣι', + 'ᾬ' => 'ὤι', + 'ᾭ' => 'ὥι', + 'ᾮ' => 'ὦι', + 'ᾯ' => 'ὧι', + 'ᾲ' => 'ὰι', + 'ᾳ' => 'αι', + 'ᾴ' => 'άι', + 'ᾶ' => 'ᾶ', + 'ᾷ' => 'ᾶι', + 'ᾼ' => 'αι', + 'ῂ' => 'ὴι', + 'ῃ' => 'ηι', + 'ῄ' => 'ήι', + 'ῆ' => 'ῆ', + 'ῇ' => 'ῆι', + 'ῌ' => 'ηι', + 'ῒ' => 'ῒ', + 'ῖ' => 'ῖ', + 'ῗ' => 'ῗ', + 'ῢ' => 'ῢ', + 'ῤ' => 'ῤ', + 'ῦ' => 'ῦ', + 'ῧ' => 'ῧ', + 'ῲ' => 'ὼι', + 'ῳ' => 'ωι', + 'ῴ' => 'ώι', + 'ῶ' => 'ῶ', + 'ῷ' => 'ῶι', + 'ῼ' => 'ωι', + 'ff' => 'ff', + 'fi' => 'fi', + 'fl' => 'fl', + 'ffi' => 'ffi', + 'ffl' => 'ffl', + 'ſt' => 'st', + 'st' => 'st', + 'ﬓ' => 'մն', + 'ﬔ' => 'մե', + 'ﬕ' => 'մի', + 'ﬖ' => 'վն', + 'ﬗ' => 'մխ', +]; diff --git a/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php b/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php index a22eca57..fac60b08 100644 --- a/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php +++ b/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php @@ -81,7 +81,7 @@ 'Ī' => 'ī', 'Ĭ' => 'ĭ', 'Į' => 'į', - 'İ' => 'i', + 'İ' => 'i̇', 'IJ' => 'ij', 'Ĵ' => 'ĵ', 'Ķ' => 'ķ', diff --git a/vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php b/vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php index ecbc1589..56b9cb85 100644 --- a/vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php +++ b/vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php @@ -746,41 +746,41 @@ 'ύ' => 'Ύ', 'ὼ' => 'Ὼ', 'ώ' => 'Ώ', - 'ᾀ' => 'ᾈ', - 'ᾁ' => 'ᾉ', - 'ᾂ' => 'ᾊ', - 'ᾃ' => 'ᾋ', - 'ᾄ' => 'ᾌ', - 'ᾅ' => 'ᾍ', - 'ᾆ' => 'ᾎ', - 'ᾇ' => 'ᾏ', - 'ᾐ' => 'ᾘ', - 'ᾑ' => 'ᾙ', - 'ᾒ' => 'ᾚ', - 'ᾓ' => 'ᾛ', - 'ᾔ' => 'ᾜ', - 'ᾕ' => 'ᾝ', - 'ᾖ' => 'ᾞ', - 'ᾗ' => 'ᾟ', - 'ᾠ' => 'ᾨ', - 'ᾡ' => 'ᾩ', - 'ᾢ' => 'ᾪ', - 'ᾣ' => 'ᾫ', - 'ᾤ' => 'ᾬ', - 'ᾥ' => 'ᾭ', - 'ᾦ' => 'ᾮ', - 'ᾧ' => 'ᾯ', + 'ᾀ' => 'ἈΙ', + 'ᾁ' => 'ἉΙ', + 'ᾂ' => 'ἊΙ', + 'ᾃ' => 'ἋΙ', + 'ᾄ' => 'ἌΙ', + 'ᾅ' => 'ἍΙ', + 'ᾆ' => 'ἎΙ', + 'ᾇ' => 'ἏΙ', + 'ᾐ' => 'ἨΙ', + 'ᾑ' => 'ἩΙ', + 'ᾒ' => 'ἪΙ', + 'ᾓ' => 'ἫΙ', + 'ᾔ' => 'ἬΙ', + 'ᾕ' => 'ἭΙ', + 'ᾖ' => 'ἮΙ', + 'ᾗ' => 'ἯΙ', + 'ᾠ' => 'ὨΙ', + 'ᾡ' => 'ὩΙ', + 'ᾢ' => 'ὪΙ', + 'ᾣ' => 'ὫΙ', + 'ᾤ' => 'ὬΙ', + 'ᾥ' => 'ὭΙ', + 'ᾦ' => 'ὮΙ', + 'ᾧ' => 'ὯΙ', 'ᾰ' => 'Ᾰ', 'ᾱ' => 'Ᾱ', - 'ᾳ' => 'ᾼ', + 'ᾳ' => 'ΑΙ', 'ι' => 'Ι', - 'ῃ' => 'ῌ', + 'ῃ' => 'ΗΙ', 'ῐ' => 'Ῐ', 'ῑ' => 'Ῑ', 'ῠ' => 'Ῠ', 'ῡ' => 'Ῡ', 'ῥ' => 'Ῥ', - 'ῳ' => 'ῼ', + 'ῳ' => 'ΩΙ', 'ⅎ' => 'Ⅎ', 'ⅰ' => 'Ⅰ', 'ⅱ' => 'Ⅱ', @@ -1411,4 +1411,79 @@ '𞥁' => '𞤟', '𞥂' => '𞤠', '𞥃' => '𞤡', + 'ß' => 'SS', + 'ff' => 'FF', + 'fi' => 'FI', + 'fl' => 'FL', + 'ffi' => 'FFI', + 'ffl' => 'FFL', + 'ſt' => 'ST', + 'st' => 'ST', + 'և' => 'ԵՒ', + 'ﬓ' => 'ՄՆ', + 'ﬔ' => 'ՄԵ', + 'ﬕ' => 'ՄԻ', + 'ﬖ' => 'ՎՆ', + 'ﬗ' => 'ՄԽ', + 'ʼn' => 'ʼN', + 'ΐ' => 'Ϊ́', + 'ΰ' => 'Ϋ́', + 'ǰ' => 'J̌', + 'ẖ' => 'H̱', + 'ẗ' => 'T̈', + 'ẘ' => 'W̊', + 'ẙ' => 'Y̊', + 'ẚ' => 'Aʾ', + 'ὐ' => 'Υ̓', + 'ὒ' => 'Υ̓̀', + 'ὔ' => 'Υ̓́', + 'ὖ' => 'Υ̓͂', + 'ᾶ' => 'Α͂', + 'ῆ' => 'Η͂', + 'ῒ' => 'Ϊ̀', + 'ΐ' => 'Ϊ́', + 'ῖ' => 'Ι͂', + 'ῗ' => 'Ϊ͂', + 'ῢ' => 'Ϋ̀', + 'ΰ' => 'Ϋ́', + 'ῤ' => 'Ρ̓', + 'ῦ' => 'Υ͂', + 'ῧ' => 'Ϋ͂', + 'ῶ' => 'Ω͂', + 'ᾈ' => 'ἈΙ', + 'ᾉ' => 'ἉΙ', + 'ᾊ' => 'ἊΙ', + 'ᾋ' => 'ἋΙ', + 'ᾌ' => 'ἌΙ', + 'ᾍ' => 'ἍΙ', + 'ᾎ' => 'ἎΙ', + 'ᾏ' => 'ἏΙ', + 'ᾘ' => 'ἨΙ', + 'ᾙ' => 'ἩΙ', + 'ᾚ' => 'ἪΙ', + 'ᾛ' => 'ἫΙ', + 'ᾜ' => 'ἬΙ', + 'ᾝ' => 'ἭΙ', + 'ᾞ' => 'ἮΙ', + 'ᾟ' => 'ἯΙ', + 'ᾨ' => 'ὨΙ', + 'ᾩ' => 'ὩΙ', + 'ᾪ' => 'ὪΙ', + 'ᾫ' => 'ὫΙ', + 'ᾬ' => 'ὬΙ', + 'ᾭ' => 'ὭΙ', + 'ᾮ' => 'ὮΙ', + 'ᾯ' => 'ὯΙ', + 'ᾼ' => 'ΑΙ', + 'ῌ' => 'ΗΙ', + 'ῼ' => 'ΩΙ', + 'ᾲ' => 'ᾺΙ', + 'ᾴ' => 'ΆΙ', + 'ῂ' => 'ῊΙ', + 'ῄ' => 'ΉΙ', + 'ῲ' => 'ῺΙ', + 'ῴ' => 'ΏΙ', + 'ᾷ' => 'Α͂Ι', + 'ῇ' => 'Η͂Ι', + 'ῷ' => 'Ω͂Ι', ); diff --git a/vendor/symfony/polyfill-mbstring/bootstrap.php b/vendor/symfony/polyfill-mbstring/bootstrap.php index d0a93d4d..ecf1a035 100644 --- a/vendor/symfony/polyfill-mbstring/bootstrap.php +++ b/vendor/symfony/polyfill-mbstring/bootstrap.php @@ -11,6 +11,10 @@ use Symfony\Polyfill\Mbstring as p; +if (\PHP_VERSION_ID >= 80000) { + return require __DIR__.'/bootstrap80.php'; +} + if (!function_exists('mb_convert_encoding')) { function mb_convert_encoding($string, $to_encoding, $from_encoding = null) { return p\Mbstring::mb_convert_encoding($string, $to_encoding, $from_encoding); } } @@ -18,7 +22,7 @@ function mb_convert_encoding($string, $to_encoding, $from_encoding = null) { ret function mb_decode_mimeheader($string) { return p\Mbstring::mb_decode_mimeheader($string); } } if (!function_exists('mb_encode_mimeheader')) { - function mb_encode_mimeheader($string, $charset = null, $transfer_encoding = null, $newline = null, $indent = null) { return p\Mbstring::mb_encode_mimeheader($string, $charset, $transfer_encoding, $newline, $indent); } + function mb_encode_mimeheader($string, $charset = null, $transfer_encoding = null, $newline = "\r\n", $indent = 0) { return p\Mbstring::mb_encode_mimeheader($string, $charset, $transfer_encoding, $newline, $indent); } } if (!function_exists('mb_decode_numericentity')) { function mb_decode_numericentity($string, $map, $encoding = null) { return p\Mbstring::mb_decode_numericentity($string, $map, $encoding); } @@ -51,7 +55,7 @@ function mb_detect_encoding($string, $encodings = null, $strict = false) { retur function mb_detect_order($encoding = null) { return p\Mbstring::mb_detect_order($encoding); } } if (!function_exists('mb_parse_str')) { - function mb_parse_str($string, &$result = array()) { parse_str($string, $result); } + function mb_parse_str($string, &$result = []) { parse_str($string, $result); return (bool) $result; } } if (!function_exists('mb_strlen')) { function mb_strlen($string, $encoding = null) { return p\Mbstring::mb_strlen($string, $encoding); } @@ -108,15 +112,11 @@ function mb_substr_count($haystack, $needle, $encoding = null) { return p\Mbstri function mb_output_handler($string, $status) { return p\Mbstring::mb_output_handler($string, $status); } } if (!function_exists('mb_http_input')) { - function mb_http_input($type = '') { return p\Mbstring::mb_http_input($type); } + function mb_http_input($type = null) { return p\Mbstring::mb_http_input($type); } } if (!function_exists('mb_convert_variables')) { - if (PHP_VERSION_ID >= 80000) { - function mb_convert_variables($to_encoding, $from_encoding, &$var, &...$vars) { return p\Mbstring::mb_convert_variables($to_encoding, $from_encoding, $var, ...$vars); } - } else { - function mb_convert_variables($to_encoding, $from_encoding, &...$vars) { return p\Mbstring::mb_convert_variables($to_encoding, $from_encoding, ...$vars); } - } + function mb_convert_variables($to_encoding, $from_encoding, &...$vars) { return p\Mbstring::mb_convert_variables($to_encoding, $from_encoding, ...$vars); } } if (!function_exists('mb_ord')) { @@ -132,6 +132,10 @@ function mb_scrub($string, $encoding = null) { $encoding = null === $encoding ? function mb_str_split($string, $length = 1, $encoding = null) { return p\Mbstring::mb_str_split($string, $length, $encoding); } } +if (!function_exists('mb_str_pad')) { + function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = STR_PAD_RIGHT, ?string $encoding = null): string { return p\Mbstring::mb_str_pad($string, $length, $pad_string, $pad_type, $encoding); } +} + if (extension_loaded('mbstring')) { return; } diff --git a/vendor/symfony/polyfill-mbstring/bootstrap80.php b/vendor/symfony/polyfill-mbstring/bootstrap80.php new file mode 100644 index 00000000..2f9fb5b4 --- /dev/null +++ b/vendor/symfony/polyfill-mbstring/bootstrap80.php @@ -0,0 +1,147 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Polyfill\Mbstring as p; + +if (!function_exists('mb_convert_encoding')) { + function mb_convert_encoding(array|string|null $string, ?string $to_encoding, array|string|null $from_encoding = null): array|string|false { return p\Mbstring::mb_convert_encoding($string ?? '', (string) $to_encoding, $from_encoding); } +} +if (!function_exists('mb_decode_mimeheader')) { + function mb_decode_mimeheader(?string $string): string { return p\Mbstring::mb_decode_mimeheader((string) $string); } +} +if (!function_exists('mb_encode_mimeheader')) { + function mb_encode_mimeheader(?string $string, ?string $charset = null, ?string $transfer_encoding = null, ?string $newline = "\r\n", ?int $indent = 0): string { return p\Mbstring::mb_encode_mimeheader((string) $string, $charset, $transfer_encoding, (string) $newline, (int) $indent); } +} +if (!function_exists('mb_decode_numericentity')) { + function mb_decode_numericentity(?string $string, array $map, ?string $encoding = null): string { return p\Mbstring::mb_decode_numericentity((string) $string, $map, $encoding); } +} +if (!function_exists('mb_encode_numericentity')) { + function mb_encode_numericentity(?string $string, array $map, ?string $encoding = null, ?bool $hex = false): string { return p\Mbstring::mb_encode_numericentity((string) $string, $map, $encoding, (bool) $hex); } +} +if (!function_exists('mb_convert_case')) { + function mb_convert_case(?string $string, ?int $mode, ?string $encoding = null): string { return p\Mbstring::mb_convert_case((string) $string, (int) $mode, $encoding); } +} +if (!function_exists('mb_internal_encoding')) { + function mb_internal_encoding(?string $encoding = null): string|bool { return p\Mbstring::mb_internal_encoding($encoding); } +} +if (!function_exists('mb_language')) { + function mb_language(?string $language = null): string|bool { return p\Mbstring::mb_language($language); } +} +if (!function_exists('mb_list_encodings')) { + function mb_list_encodings(): array { return p\Mbstring::mb_list_encodings(); } +} +if (!function_exists('mb_encoding_aliases')) { + function mb_encoding_aliases(?string $encoding): array { return p\Mbstring::mb_encoding_aliases((string) $encoding); } +} +if (!function_exists('mb_check_encoding')) { + function mb_check_encoding(array|string|null $value = null, ?string $encoding = null): bool { return p\Mbstring::mb_check_encoding($value, $encoding); } +} +if (!function_exists('mb_detect_encoding')) { + function mb_detect_encoding(?string $string, array|string|null $encodings = null, ?bool $strict = false): string|false { return p\Mbstring::mb_detect_encoding((string) $string, $encodings, (bool) $strict); } +} +if (!function_exists('mb_detect_order')) { + function mb_detect_order(array|string|null $encoding = null): array|bool { return p\Mbstring::mb_detect_order($encoding); } +} +if (!function_exists('mb_parse_str')) { + function mb_parse_str(?string $string, &$result = []): bool { parse_str((string) $string, $result); return (bool) $result; } +} +if (!function_exists('mb_strlen')) { + function mb_strlen(?string $string, ?string $encoding = null): int { return p\Mbstring::mb_strlen((string) $string, $encoding); } +} +if (!function_exists('mb_strpos')) { + function mb_strpos(?string $haystack, ?string $needle, ?int $offset = 0, ?string $encoding = null): int|false { return p\Mbstring::mb_strpos((string) $haystack, (string) $needle, (int) $offset, $encoding); } +} +if (!function_exists('mb_strtolower')) { + function mb_strtolower(?string $string, ?string $encoding = null): string { return p\Mbstring::mb_strtolower((string) $string, $encoding); } +} +if (!function_exists('mb_strtoupper')) { + function mb_strtoupper(?string $string, ?string $encoding = null): string { return p\Mbstring::mb_strtoupper((string) $string, $encoding); } +} +if (!function_exists('mb_substitute_character')) { + function mb_substitute_character(string|int|null $substitute_character = null): string|int|bool { return p\Mbstring::mb_substitute_character($substitute_character); } +} +if (!function_exists('mb_substr')) { + function mb_substr(?string $string, ?int $start, ?int $length = null, ?string $encoding = null): string { return p\Mbstring::mb_substr((string) $string, (int) $start, $length, $encoding); } +} +if (!function_exists('mb_stripos')) { + function mb_stripos(?string $haystack, ?string $needle, ?int $offset = 0, ?string $encoding = null): int|false { return p\Mbstring::mb_stripos((string) $haystack, (string) $needle, (int) $offset, $encoding); } +} +if (!function_exists('mb_stristr')) { + function mb_stristr(?string $haystack, ?string $needle, ?bool $before_needle = false, ?string $encoding = null): string|false { return p\Mbstring::mb_stristr((string) $haystack, (string) $needle, (bool) $before_needle, $encoding); } +} +if (!function_exists('mb_strrchr')) { + function mb_strrchr(?string $haystack, ?string $needle, ?bool $before_needle = false, ?string $encoding = null): string|false { return p\Mbstring::mb_strrchr((string) $haystack, (string) $needle, (bool) $before_needle, $encoding); } +} +if (!function_exists('mb_strrichr')) { + function mb_strrichr(?string $haystack, ?string $needle, ?bool $before_needle = false, ?string $encoding = null): string|false { return p\Mbstring::mb_strrichr((string) $haystack, (string) $needle, (bool) $before_needle, $encoding); } +} +if (!function_exists('mb_strripos')) { + function mb_strripos(?string $haystack, ?string $needle, ?int $offset = 0, ?string $encoding = null): int|false { return p\Mbstring::mb_strripos((string) $haystack, (string) $needle, (int) $offset, $encoding); } +} +if (!function_exists('mb_strrpos')) { + function mb_strrpos(?string $haystack, ?string $needle, ?int $offset = 0, ?string $encoding = null): int|false { return p\Mbstring::mb_strrpos((string) $haystack, (string) $needle, (int) $offset, $encoding); } +} +if (!function_exists('mb_strstr')) { + function mb_strstr(?string $haystack, ?string $needle, ?bool $before_needle = false, ?string $encoding = null): string|false { return p\Mbstring::mb_strstr((string) $haystack, (string) $needle, (bool) $before_needle, $encoding); } +} +if (!function_exists('mb_get_info')) { + function mb_get_info(?string $type = 'all'): array|string|int|false { return p\Mbstring::mb_get_info((string) $type); } +} +if (!function_exists('mb_http_output')) { + function mb_http_output(?string $encoding = null): string|bool { return p\Mbstring::mb_http_output($encoding); } +} +if (!function_exists('mb_strwidth')) { + function mb_strwidth(?string $string, ?string $encoding = null): int { return p\Mbstring::mb_strwidth((string) $string, $encoding); } +} +if (!function_exists('mb_substr_count')) { + function mb_substr_count(?string $haystack, ?string $needle, ?string $encoding = null): int { return p\Mbstring::mb_substr_count((string) $haystack, (string) $needle, $encoding); } +} +if (!function_exists('mb_output_handler')) { + function mb_output_handler(?string $string, ?int $status): string { return p\Mbstring::mb_output_handler((string) $string, (int) $status); } +} +if (!function_exists('mb_http_input')) { + function mb_http_input(?string $type = null): array|string|false { return p\Mbstring::mb_http_input($type); } +} + +if (!function_exists('mb_convert_variables')) { + function mb_convert_variables(?string $to_encoding, array|string|null $from_encoding, mixed &$var, mixed &...$vars): string|false { return p\Mbstring::mb_convert_variables((string) $to_encoding, $from_encoding ?? '', $var, ...$vars); } +} + +if (!function_exists('mb_ord')) { + function mb_ord(?string $string, ?string $encoding = null): int|false { return p\Mbstring::mb_ord((string) $string, $encoding); } +} +if (!function_exists('mb_chr')) { + function mb_chr(?int $codepoint, ?string $encoding = null): string|false { return p\Mbstring::mb_chr((int) $codepoint, $encoding); } +} +if (!function_exists('mb_scrub')) { + function mb_scrub(?string $string, ?string $encoding = null): string { $encoding ??= mb_internal_encoding(); return mb_convert_encoding((string) $string, $encoding, $encoding); } +} +if (!function_exists('mb_str_split')) { + function mb_str_split(?string $string, ?int $length = 1, ?string $encoding = null): array { return p\Mbstring::mb_str_split((string) $string, (int) $length, $encoding); } +} + +if (!function_exists('mb_str_pad')) { + function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = STR_PAD_RIGHT, ?string $encoding = null): string { return p\Mbstring::mb_str_pad($string, $length, $pad_string, $pad_type, $encoding); } +} + +if (extension_loaded('mbstring')) { + return; +} + +if (!defined('MB_CASE_UPPER')) { + define('MB_CASE_UPPER', 0); +} +if (!defined('MB_CASE_LOWER')) { + define('MB_CASE_LOWER', 1); +} +if (!defined('MB_CASE_TITLE')) { + define('MB_CASE_TITLE', 2); +} diff --git a/vendor/symfony/polyfill-mbstring/composer.json b/vendor/symfony/polyfill-mbstring/composer.json index ca4a8392..943e5029 100644 --- a/vendor/symfony/polyfill-mbstring/composer.json +++ b/vendor/symfony/polyfill-mbstring/composer.json @@ -18,6 +18,9 @@ "require": { "php": ">=7.1" }, + "provide": { + "ext-mbstring": "*" + }, "autoload": { "psr-4": { "Symfony\\Polyfill\\Mbstring\\": "" }, "files": [ "bootstrap.php" ] @@ -28,7 +31,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-main": "1.20-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", diff --git a/vendor/symfony/polyfill-php80/LICENSE b/vendor/symfony/polyfill-php80/LICENSE new file mode 100644 index 00000000..0ed3a246 --- /dev/null +++ b/vendor/symfony/polyfill-php80/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2020-present 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 +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/symfony/polyfill-php80/Php80.php b/vendor/symfony/polyfill-php80/Php80.php new file mode 100644 index 00000000..362dd1a9 --- /dev/null +++ b/vendor/symfony/polyfill-php80/Php80.php @@ -0,0 +1,115 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Polyfill\Php80; + +/** + * @author Ion Bazan + * @author Nico Oelgart + * @author Nicolas Grekas + * + * @internal + */ +final class Php80 +{ + public static function fdiv(float $dividend, float $divisor): float + { + return @($dividend / $divisor); + } + + public static function get_debug_type($value): string + { + switch (true) { + case null === $value: return 'null'; + case \is_bool($value): return 'bool'; + case \is_string($value): return 'string'; + case \is_array($value): return 'array'; + case \is_int($value): return 'int'; + case \is_float($value): return 'float'; + case \is_object($value): break; + case $value instanceof \__PHP_Incomplete_Class: return '__PHP_Incomplete_Class'; + default: + if (null === $type = @get_resource_type($value)) { + return 'unknown'; + } + + if ('Unknown' === $type) { + $type = 'closed'; + } + + return "resource ($type)"; + } + + $class = \get_class($value); + + if (false === strpos($class, '@')) { + return $class; + } + + return (get_parent_class($class) ?: key(class_implements($class)) ?: 'class').'@anonymous'; + } + + public static function get_resource_id($res): int + { + if (!\is_resource($res) && null === @get_resource_type($res)) { + throw new \TypeError(sprintf('Argument 1 passed to get_resource_id() must be of the type resource, %s given', get_debug_type($res))); + } + + return (int) $res; + } + + public static function preg_last_error_msg(): string + { + switch (preg_last_error()) { + case \PREG_INTERNAL_ERROR: + return 'Internal error'; + case \PREG_BAD_UTF8_ERROR: + return 'Malformed UTF-8 characters, possibly incorrectly encoded'; + case \PREG_BAD_UTF8_OFFSET_ERROR: + return 'The offset did not correspond to the beginning of a valid UTF-8 code point'; + case \PREG_BACKTRACK_LIMIT_ERROR: + return 'Backtrack limit exhausted'; + case \PREG_RECURSION_LIMIT_ERROR: + return 'Recursion limit exhausted'; + case \PREG_JIT_STACKLIMIT_ERROR: + return 'JIT stack limit exhausted'; + case \PREG_NO_ERROR: + return 'No error'; + default: + return 'Unknown error'; + } + } + + public static function str_contains(string $haystack, string $needle): bool + { + return '' === $needle || false !== strpos($haystack, $needle); + } + + public static function str_starts_with(string $haystack, string $needle): bool + { + return 0 === strncmp($haystack, $needle, \strlen($needle)); + } + + public static function str_ends_with(string $haystack, string $needle): bool + { + if ('' === $needle || $needle === $haystack) { + return true; + } + + if ('' === $haystack) { + return false; + } + + $needleLength = \strlen($needle); + + return $needleLength <= \strlen($haystack) && 0 === substr_compare($haystack, $needle, -$needleLength); + } +} diff --git a/vendor/symfony/polyfill-php80/PhpToken.php b/vendor/symfony/polyfill-php80/PhpToken.php new file mode 100644 index 00000000..fe6e6910 --- /dev/null +++ b/vendor/symfony/polyfill-php80/PhpToken.php @@ -0,0 +1,103 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Polyfill\Php80; + +/** + * @author Fedonyuk Anton + * + * @internal + */ +class PhpToken implements \Stringable +{ + /** + * @var int + */ + public $id; + + /** + * @var string + */ + public $text; + + /** + * @var int + */ + public $line; + + /** + * @var int + */ + public $pos; + + public function __construct(int $id, string $text, int $line = -1, int $position = -1) + { + $this->id = $id; + $this->text = $text; + $this->line = $line; + $this->pos = $position; + } + + public function getTokenName(): ?string + { + if ('UNKNOWN' === $name = token_name($this->id)) { + $name = \strlen($this->text) > 1 || \ord($this->text) < 32 ? null : $this->text; + } + + return $name; + } + + /** + * @param int|string|array $kind + */ + public function is($kind): bool + { + foreach ((array) $kind as $value) { + if (\in_array($value, [$this->id, $this->text], true)) { + return true; + } + } + + return false; + } + + public function isIgnorable(): bool + { + return \in_array($this->id, [\T_WHITESPACE, \T_COMMENT, \T_DOC_COMMENT, \T_OPEN_TAG], true); + } + + public function __toString(): string + { + return (string) $this->text; + } + + /** + * @return static[] + */ + public static function tokenize(string $code, int $flags = 0): array + { + $line = 1; + $position = 0; + $tokens = token_get_all($code, $flags); + foreach ($tokens as $index => $token) { + if (\is_string($token)) { + $id = \ord($token); + $text = $token; + } else { + [$id, $text, $line] = $token; + } + $tokens[$index] = new static($id, $text, $line, $position); + $position += \strlen($text); + } + + return $tokens; + } +} diff --git a/vendor/symfony/polyfill-php80/README.md b/vendor/symfony/polyfill-php80/README.md new file mode 100644 index 00000000..3816c559 --- /dev/null +++ b/vendor/symfony/polyfill-php80/README.md @@ -0,0 +1,25 @@ +Symfony Polyfill / Php80 +======================== + +This component provides features added to PHP 8.0 core: + +- [`Stringable`](https://php.net/stringable) interface +- [`fdiv`](https://php.net/fdiv) +- [`ValueError`](https://php.net/valueerror) class +- [`UnhandledMatchError`](https://php.net/unhandledmatcherror) class +- `FILTER_VALIDATE_BOOL` constant +- [`get_debug_type`](https://php.net/get_debug_type) +- [`PhpToken`](https://php.net/phptoken) class +- [`preg_last_error_msg`](https://php.net/preg_last_error_msg) +- [`str_contains`](https://php.net/str_contains) +- [`str_starts_with`](https://php.net/str_starts_with) +- [`str_ends_with`](https://php.net/str_ends_with) +- [`get_resource_id`](https://php.net/get_resource_id) + +More information can be found in the +[main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md). + +License +======= + +This library is released under the [MIT license](LICENSE). diff --git a/vendor/symfony/polyfill-php80/Resources/stubs/Attribute.php b/vendor/symfony/polyfill-php80/Resources/stubs/Attribute.php new file mode 100644 index 00000000..2b955423 --- /dev/null +++ b/vendor/symfony/polyfill-php80/Resources/stubs/Attribute.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#[Attribute(Attribute::TARGET_CLASS)] +final class Attribute +{ + public const TARGET_CLASS = 1; + public const TARGET_FUNCTION = 2; + public const TARGET_METHOD = 4; + public const TARGET_PROPERTY = 8; + public const TARGET_CLASS_CONSTANT = 16; + public const TARGET_PARAMETER = 32; + public const TARGET_ALL = 63; + public const IS_REPEATABLE = 64; + + /** @var int */ + public $flags; + + public function __construct(int $flags = self::TARGET_ALL) + { + $this->flags = $flags; + } +} diff --git a/vendor/symfony/polyfill-php80/Resources/stubs/PhpToken.php b/vendor/symfony/polyfill-php80/Resources/stubs/PhpToken.php new file mode 100644 index 00000000..bd1212f6 --- /dev/null +++ b/vendor/symfony/polyfill-php80/Resources/stubs/PhpToken.php @@ -0,0 +1,16 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +if (\PHP_VERSION_ID < 80000 && extension_loaded('tokenizer')) { + class PhpToken extends Symfony\Polyfill\Php80\PhpToken + { + } +} diff --git a/vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php b/vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php new file mode 100644 index 00000000..7c62d750 --- /dev/null +++ b/vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +if (\PHP_VERSION_ID < 80000) { + interface Stringable + { + /** + * @return string + */ + public function __toString(); + } +} diff --git a/vendor/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php b/vendor/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php new file mode 100644 index 00000000..01c6c6c8 --- /dev/null +++ b/vendor/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php @@ -0,0 +1,16 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +if (\PHP_VERSION_ID < 80000) { + class UnhandledMatchError extends Error + { + } +} diff --git a/vendor/symfony/polyfill-php80/Resources/stubs/ValueError.php b/vendor/symfony/polyfill-php80/Resources/stubs/ValueError.php new file mode 100644 index 00000000..783dbc28 --- /dev/null +++ b/vendor/symfony/polyfill-php80/Resources/stubs/ValueError.php @@ -0,0 +1,16 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +if (\PHP_VERSION_ID < 80000) { + class ValueError extends Error + { + } +} diff --git a/vendor/symfony/polyfill-php80/bootstrap.php b/vendor/symfony/polyfill-php80/bootstrap.php new file mode 100644 index 00000000..e5f7dbc1 --- /dev/null +++ b/vendor/symfony/polyfill-php80/bootstrap.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Polyfill\Php80 as p; + +if (\PHP_VERSION_ID >= 80000) { + return; +} + +if (!defined('FILTER_VALIDATE_BOOL') && defined('FILTER_VALIDATE_BOOLEAN')) { + define('FILTER_VALIDATE_BOOL', \FILTER_VALIDATE_BOOLEAN); +} + +if (!function_exists('fdiv')) { + function fdiv(float $num1, float $num2): float { return p\Php80::fdiv($num1, $num2); } +} +if (!function_exists('preg_last_error_msg')) { + function preg_last_error_msg(): string { return p\Php80::preg_last_error_msg(); } +} +if (!function_exists('str_contains')) { + function str_contains(?string $haystack, ?string $needle): bool { return p\Php80::str_contains($haystack ?? '', $needle ?? ''); } +} +if (!function_exists('str_starts_with')) { + function str_starts_with(?string $haystack, ?string $needle): bool { return p\Php80::str_starts_with($haystack ?? '', $needle ?? ''); } +} +if (!function_exists('str_ends_with')) { + function str_ends_with(?string $haystack, ?string $needle): bool { return p\Php80::str_ends_with($haystack ?? '', $needle ?? ''); } +} +if (!function_exists('get_debug_type')) { + function get_debug_type($value): string { return p\Php80::get_debug_type($value); } +} +if (!function_exists('get_resource_id')) { + function get_resource_id($resource): int { return p\Php80::get_resource_id($resource); } +} diff --git a/vendor/symfony/polyfill-php80/composer.json b/vendor/symfony/polyfill-php80/composer.json new file mode 100644 index 00000000..f1801f40 --- /dev/null +++ b/vendor/symfony/polyfill-php80/composer.json @@ -0,0 +1,40 @@ +{ + "name": "symfony/polyfill-php80", + "type": "library", + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "keywords": ["polyfill", "shim", "compatibility", "portable"], + "homepage": "https://symfony.com", + "license": "MIT", + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "require": { + "php": ">=7.1" + }, + "autoload": { + "psr-4": { "Symfony\\Polyfill\\Php80\\": "" }, + "files": [ "bootstrap.php" ], + "classmap": [ "Resources/stubs" ] + }, + "minimum-stability": "dev", + "extra": { + "branch-alias": { + "dev-main": "1.28-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + } +} diff --git a/vendor/symfony/process/ExecutableFinder.php b/vendor/symfony/process/ExecutableFinder.php index ff68ed33..e2dd064d 100644 --- a/vendor/symfony/process/ExecutableFinder.php +++ b/vendor/symfony/process/ExecutableFinder.php @@ -50,8 +50,8 @@ public function addSuffix($suffix) */ public function find($name, $default = null, array $extraDirs = []) { - if (ini_get('open_basedir')) { - $searchPath = array_merge(explode(\PATH_SEPARATOR, ini_get('open_basedir')), $extraDirs); + if (\ini_get('open_basedir')) { + $searchPath = array_merge(explode(\PATH_SEPARATOR, \ini_get('open_basedir')), $extraDirs); $dirs = []; foreach ($searchPath as $path) { // Silencing against https://bugs.php.net/69240 diff --git a/vendor/symfony/process/InputStream.php b/vendor/symfony/process/InputStream.php index c86fca86..4f8f7133 100644 --- a/vendor/symfony/process/InputStream.php +++ b/vendor/symfony/process/InputStream.php @@ -69,6 +69,7 @@ public function isClosed() /** * @return \Traversable */ + #[\ReturnTypeWillChange] public function getIterator() { $this->open = true; diff --git a/vendor/symfony/process/LICENSE b/vendor/symfony/process/LICENSE index 9e936ec0..88bf75bb 100644 --- a/vendor/symfony/process/LICENSE +++ b/vendor/symfony/process/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2020 Fabien Potencier +Copyright (c) 2004-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/process/PhpExecutableFinder.php b/vendor/symfony/process/PhpExecutableFinder.php index 3d5eabd9..92e0262a 100644 --- a/vendor/symfony/process/PhpExecutableFinder.php +++ b/vendor/symfony/process/PhpExecutableFinder.php @@ -47,6 +47,10 @@ public function find($includeArgs = true) } } + if (@is_dir($php)) { + return false; + } + return $php; } @@ -59,7 +63,7 @@ public function find($includeArgs = true) } if ($php = getenv('PHP_PATH')) { - if (!@is_executable($php)) { + if (!@is_executable($php) || @is_dir($php)) { return false; } @@ -67,12 +71,12 @@ public function find($includeArgs = true) } if ($php = getenv('PHP_PEAR_PHP_BIN')) { - if (@is_executable($php)) { + if (@is_executable($php) && !@is_dir($php)) { return $php; } } - if (@is_executable($php = \PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php'))) { + if (@is_executable($php = \PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php')) && !@is_dir($php)) { return $php; } diff --git a/vendor/symfony/process/Pipes/AbstractPipes.php b/vendor/symfony/process/Pipes/AbstractPipes.php index 6b72aed7..9532e3ef 100644 --- a/vendor/symfony/process/Pipes/AbstractPipes.php +++ b/vendor/symfony/process/Pipes/AbstractPipes.php @@ -47,7 +47,9 @@ public function __construct($input) public function close() { foreach ($this->pipes as $pipe) { - fclose($pipe); + if (\is_resource($pipe)) { + fclose($pipe); + } } $this->pipes = []; } @@ -102,7 +104,7 @@ protected function write(): ?array stream_set_blocking($input, 0); } elseif (!isset($this->inputBuffer[0])) { if (!\is_string($input)) { - if (!is_scalar($input)) { + if (!\is_scalar($input)) { throw new InvalidArgumentException(sprintf('"%s" yielded a value of type "%s", but only scalars and stream resources are supported.', \get_class($this->input), \gettype($input))); } $input = (string) $input; @@ -133,7 +135,7 @@ protected function write(): ?array } if ($input) { - for (;;) { + while (true) { $data = fread($input, self::CHUNK_SIZE); if (!isset($data[0])) { break; @@ -171,7 +173,7 @@ protected function write(): ?array /** * @internal */ - public function handleError($type, $msg) + public function handleError(int $type, string $msg) { $this->lastError = $msg; } diff --git a/vendor/symfony/process/Pipes/UnixPipes.php b/vendor/symfony/process/Pipes/UnixPipes.php index 70fdd295..58a8da07 100644 --- a/vendor/symfony/process/Pipes/UnixPipes.php +++ b/vendor/symfony/process/Pipes/UnixPipes.php @@ -35,6 +35,19 @@ public function __construct(?bool $ttyMode, bool $ptyMode, $input, bool $haveRea parent::__construct($input); } + /** + * @return array + */ + public function __sleep() + { + throw new \BadMethodCallException('Cannot serialize '.__CLASS__); + } + + public function __wakeup() + { + throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); + } + public function __destruct() { $this->close(); diff --git a/vendor/symfony/process/Pipes/WindowsPipes.php b/vendor/symfony/process/Pipes/WindowsPipes.php index b22171dd..69768f3d 100644 --- a/vendor/symfony/process/Pipes/WindowsPipes.php +++ b/vendor/symfony/process/Pipes/WindowsPipes.php @@ -71,7 +71,7 @@ public function __construct($input, bool $haveReadSupport) } $this->lockHandles[$pipe] = $h; - if (!fclose(fopen($file, 'w')) || !$h = fopen($file, 'r')) { + if (!($h = fopen($file, 'w')) || !fclose($h) || !$h = fopen($file, 'r')) { flock($this->lockHandles[$pipe], \LOCK_UN); fclose($this->lockHandles[$pipe]); unset($this->lockHandles[$pipe]); @@ -88,6 +88,19 @@ public function __construct($input, bool $haveReadSupport) parent::__construct($input); } + /** + * @return array + */ + public function __sleep() + { + throw new \BadMethodCallException('Cannot serialize '.__CLASS__); + } + + public function __wakeup() + { + throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); + } + public function __destruct() { $this->close(); diff --git a/vendor/symfony/process/Process.php b/vendor/symfony/process/Process.php index 5f8ba6d1..09cd9602 100644 --- a/vendor/symfony/process/Process.php +++ b/vendor/symfony/process/Process.php @@ -53,7 +53,7 @@ class Process implements \IteratorAggregate private $hasCallback = false; private $commandline; private $cwd; - private $env; + private $env = []; private $input; private $starttime; private $lastOutputTime; @@ -132,7 +132,7 @@ class Process implements \IteratorAggregate * @param array $command The command to run and its arguments listed as separate entries * @param string|null $cwd The working directory or null to use the working dir of the current PHP process * @param array|null $env The environment variables or null to use the same environment as the current PHP process - * @param mixed|null $input The input as stream resource, scalar or \Traversable, or null for no input + * @param mixed $input The input as stream resource, scalar or \Traversable, or null for no input * @param int|float|null $timeout The timeout in seconds or null to disable * * @throws LogicException When proc_open is not installed @@ -177,13 +177,13 @@ public function __construct($command, string $cwd = null, array $env = null, $in * In order to inject dynamic values into command-lines, we strongly recommend using placeholders. * This will save escaping values, which is not portable nor secure anyway: * - * $process = Process::fromShellCommandline('my_command "$MY_VAR"'); + * $process = Process::fromShellCommandline('my_command "${:MY_VAR}"'); * $process->run(null, ['MY_VAR' => $theValue]); * * @param string $command The command line to pass to the shell of the OS * @param string|null $cwd The working directory or null to use the working dir of the current PHP process * @param array|null $env The environment variables or null to use the same environment as the current PHP process - * @param mixed|null $input The input as stream resource, scalar or \Traversable, or null for no input + * @param mixed $input The input as stream resource, scalar or \Traversable, or null for no input * @param int|float|null $timeout The timeout in seconds or null to disable * * @return static @@ -198,6 +198,19 @@ public static function fromShellCommandline(string $command, string $cwd = null, return $process; } + /** + * @return array + */ + public function __sleep() + { + throw new \BadMethodCallException('Cannot serialize '.__CLASS__); + } + + public function __wakeup() + { + throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); + } + public function __destruct() { $this->stop(0); @@ -291,10 +304,10 @@ public function start(callable $callback = null, array $env = []) $descriptors = $this->getDescriptors(); if ($this->env) { - $env += $this->env; + $env += '\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($this->env, $env, 'strcasecmp') : $this->env; } - $env += $this->getDefaultEnv(); + $env += '\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($this->getDefaultEnv(), $env, 'strcasecmp') : $this->getDefaultEnv(); if (\is_array($commandline = $this->commandline)) { $commandline = implode(' ', array_map([$this, 'escapeArgument'], $commandline)); @@ -327,7 +340,7 @@ public function start(callable $callback = null, array $env = []) $envPairs = []; foreach ($env as $k => $v) { - if (false !== $v) { + if (false !== $v && false === \in_array($k, ['argc', 'argv', 'ARGC', 'ARGV'], true)) { $envPairs[] = $k.'='.$v; } } @@ -609,6 +622,7 @@ public function getIncrementalOutput() * * @return \Generator */ + #[\ReturnTypeWillChange] public function getIterator($flags = 0) { $this->readPipesForOutput(__FUNCTION__, false); @@ -758,7 +772,7 @@ public function getExitCodeText() return null; } - return isset(self::$exitCodes[$exitcode]) ? self::$exitCodes[$exitcode] : 'Unknown error'; + return self::$exitCodes[$exitcode] ?? 'Unknown error'; } /** @@ -959,8 +973,6 @@ public function addErrorOutput(string $line) /** * Gets the last output time in seconds. - * - * @return float|null The last output time in seconds or null if it isn't started */ public function getLastOutputTime(): ?float { @@ -1157,25 +1169,12 @@ public function getEnv() /** * Sets the environment variables. * - * Each environment variable value should be a string. - * If it is an array, the variable is ignored. - * If it is false or null, it will be removed when - * env vars are otherwise inherited. - * - * That happens in PHP when 'argv' is registered into - * the $_ENV array for instance. - * - * @param array $env The new environment variables + * @param array $env The new environment variables * * @return $this */ public function setEnv(array $env) { - // Process can not handle env values that are arrays - $env = array_filter($env, function ($value) { - return !\is_array($value); - }); - $this->env = $env; return $this; @@ -1385,7 +1384,7 @@ protected function isSigchildEnabled() ob_start(); phpinfo(\INFO_GENERAL); - return self::$sigchild = false !== strpos(ob_get_clean(), '--enable-sigchild'); + return self::$sigchild = str_contains(ob_get_clean(), '--enable-sigchild'); } /** @@ -1487,8 +1486,8 @@ private function resetProcessData() $this->exitcode = null; $this->fallbackStatus = []; $this->processInformation = null; - $this->stdout = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+b'); - $this->stderr = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+b'); + $this->stdout = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+'); + $this->stderr = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+'); $this->process = null; $this->latestSignal = null; $this->status = self::STATUS_READY; @@ -1502,8 +1501,6 @@ private function resetProcessData() * @param int $signal A valid POSIX signal (see https://php.net/pcntl.constants) * @param bool $throwException Whether to throw exception in case signal failed * - * @return bool True if the signal was sent successfully, false otherwise - * * @throws LogicException In case the process is not running * @throws RuntimeException In case --enable-sigchild is activated and the process can't be killed * @throws RuntimeException In case of failure @@ -1572,7 +1569,7 @@ function ($m) use (&$env, &$varCache, &$varCount, $uid) { if (isset($varCache[$m[0]])) { return $varCache[$m[0]]; } - if (false !== strpos($value = $m[1], "\0")) { + if (str_contains($value = $m[1], "\0")) { $value = str_replace("\0", '?', $value); } if (false === strpbrk($value, "\"%!\n")) { @@ -1633,7 +1630,7 @@ private function escapeArgument(?string $argument): string if ('\\' !== \DIRECTORY_SEPARATOR) { return "'".str_replace("'", "'\\''", $argument)."'"; } - if (false !== strpos($argument, "\0")) { + if (str_contains($argument, "\0")) { $argument = str_replace("\0", '?', $argument); } if (!preg_match('/[\/()%!^"<>&|\s]/', $argument)) { @@ -1657,20 +1654,9 @@ private function replacePlaceholders(string $commandline, array $env) private function getDefaultEnv(): array { - $env = []; - - foreach ($_SERVER as $k => $v) { - if (\is_string($v) && false !== $v = getenv($k)) { - $env[$k] = $v; - } - } - - foreach ($_ENV as $k => $v) { - if (\is_string($v)) { - $env[$k] = $v; - } - } + $env = getenv(); + $env = ('\\' === \DIRECTORY_SEPARATOR ? array_intersect_ukey($env, $_SERVER, 'strcasecmp') : array_intersect_key($env, $_SERVER)) ?: $env; - return $env; + return $_ENV + ('\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($env, $_ENV, 'strcasecmp') : $env); } } diff --git a/vendor/symfony/process/ProcessUtils.php b/vendor/symfony/process/ProcessUtils.php index eb39a4a9..121693ba 100644 --- a/vendor/symfony/process/ProcessUtils.php +++ b/vendor/symfony/process/ProcessUtils.php @@ -48,7 +48,7 @@ public static function validateInput($caller, $input) if (\is_string($input)) { return $input; } - if (is_scalar($input)) { + if (\is_scalar($input)) { return (string) $input; } if ($input instanceof Process) { diff --git a/vendor/symfony/process/README.md b/vendor/symfony/process/README.md index b7ca5b42..afce5e45 100644 --- a/vendor/symfony/process/README.md +++ b/vendor/symfony/process/README.md @@ -6,8 +6,8 @@ The Process component executes commands in sub-processes. Resources --------- - * [Documentation](https://symfony.com/doc/current/components/process.html) - * [Contributing](https://symfony.com/doc/current/contributing/index.html) - * [Report issues](https://github.com/symfony/symfony/issues) and - [send Pull Requests](https://github.com/symfony/symfony/pulls) - in the [main Symfony repository](https://github.com/symfony/symfony) + * [Documentation](https://symfony.com/doc/current/components/process.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/vendor/symfony/process/composer.json b/vendor/symfony/process/composer.json index 026200e8..c0f7599f 100644 --- a/vendor/symfony/process/composer.json +++ b/vendor/symfony/process/composer.json @@ -1,7 +1,7 @@ { "name": "symfony/process", "type": "library", - "description": "Symfony Process Component", + "description": "Executes commands in sub-processes", "keywords": [], "homepage": "https://symfony.com", "license": "MIT", @@ -16,7 +16,8 @@ } ], "require": { - "php": ">=7.1.3" + "php": ">=7.1.3", + "symfony/polyfill-php80": "^1.16" }, "autoload": { "psr-4": { "Symfony\\Component\\Process\\": "" }, From 72d90eeeae10e6fa8c7f08cbcda00ecea1423726 Mon Sep 17 00:00:00 2001 From: DevDavido <997605+DevDavido@users.noreply.github.com> Date: Wed, 20 Dec 2023 00:13:15 +0100 Subject: [PATCH 03/11] refactor: Provide more time until stale issue is closed --- .github/stale.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/stale.yml b/.github/stale.yml index edf7b8ac..75ccde2c 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -1,10 +1,9 @@ # Number of days of inactivity before an issue becomes stale daysUntilStale: 90 # Number of days of inactivity before a stale issue is closed -daysUntilClose: 7 +daysUntilClose: 30 # Issues with these labels will never be considered stale exemptLabels: - - pinned - security - nostale # Label to use when marking an issue as stale @@ -13,6 +12,6 @@ staleLabel: stale markComment: > This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs - within the next 7 days. Thank you for your contributions. + within the next 30 days. Thank you for your contributions. # Comment to post when closing a stale issue. Set to `false` to disable closeComment: false From 6709f7ef03874b7af6a506d7467305f743d9c348 Mon Sep 17 00:00:00 2001 From: DevDavido <997605+DevDavido@users.noreply.github.com> Date: Wed, 20 Dec 2023 00:15:25 +0100 Subject: [PATCH 04/11] refactor: Update author information --- README.md | 4 ++-- composer.json | 3 +-- plugin.json | 5 ++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d40f36d6..0028ecbc 100644 --- a/README.md +++ b/README.md @@ -82,10 +82,10 @@ Please see the [CHANGELOG](CHANGELOG.md) for more information on what has change - Add support for [mobile Matomo app](https://matomo.org/mobile/). ## Contact -If you have any questions or inquiries, you can contact `github {at} diskoboss {døt} de`. +If you have any questions or inquiries, you can contact `github{at}diskoboss{døt}de`. ## Security -If you discover any security related issues, please contact `github {at} diskoboss {døt} de` instead of using the issue tracker. +If you discover any security related issues, please contact `github{at}diskoboss{døt}de` instead of using the issue tracker. Please note that the performance audits will be performed with Chromium which renders Matomo-tracked web pages on your server without the sandbox mode of Chromium. You can find more information about this possible issue on the [lighthouse-cli repository](https://github.com/GoogleChrome/lighthouse-ci/tree/master/docs/recipes/docker-client#--no-sandbox-issues-explained). diff --git a/composer.json b/composer.json index 68637364..a29e5225 100644 --- a/composer.json +++ b/composer.json @@ -4,8 +4,7 @@ "license": "GPL-3.0-only", "authors": [ { - "name": "David", - "email": "github@diskoboss.de", + "name": "DevDavido", "homepage": "https://github.com/DevDavido" } ], diff --git a/plugin.json b/plugin.json index 8d61a43e..8a82dfe3 100644 --- a/plugin.json +++ b/plugin.json @@ -9,8 +9,7 @@ }, "authors": [ { - "name": "David", - "email": "github@diskoboss.de", + "name": "DevDavido", "homepage": "https://github.com/DevDavido" } ], @@ -18,7 +17,7 @@ "paypal": "david.domainemail@gmx.de" }, "support": { - "email": "github@diskoboss.de", + "email": "github{at}diskoboss{døt}de", "issues": "https://github.com/DevDavido/performance-audit-plugin/issues" }, "homepage": "https://github.com/DevDavido/performance-audit-plugin", From 1acf662989ab62294e1ee8f226aa7374383e92b7 Mon Sep 17 00:00:00 2001 From: DevDavido <997605+DevDavido@users.noreply.github.com> Date: Wed, 20 Dec 2023 00:16:54 +0100 Subject: [PATCH 05/11] refactor: Update donation information --- .github/FUNDING.yml | 2 +- README.md | 2 +- lang/en.json | 2 +- plugin.json | 3 --- templates/version.twig | 4 ++-- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 3393d081..fd5ed831 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1 @@ -custom: "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=77KW4LBEYBD9U" +custom: "https://www.buymeacoffee.com/devdavido" diff --git a/README.md b/README.md index 0028ecbc..3a2abde7 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Continuously monitor those Web Vital metrics over time, allowing detection of un ## Support me If you installed this plugin and it was useful for you or your business, please don't hesitate to make a donation, I would highly appreciate it. Thank you! -Donate +Buy me a coffee ## Installation Preferably you install [this plugin](https://plugins.matomo.org/PerformanceAudit) automatically by: diff --git a/lang/en.json b/lang/en.json index fade106a..aa435a50 100644 --- a/lang/en.json +++ b/lang/en.json @@ -5,7 +5,7 @@ "CoreAdminHome_MenuPerformance": "Performance", "CoreAdminHome_PluginPerformance": "PerformanceAudit Plugin", "CoreAdminHome_VersionPerformance": "You are currently using version %1$s%2$s%3$s of the %4$s plugin.", - "Donate": "Donate", + "Donate_BuyMeACoffee": "Buy me a coffee", "EnvironmentDesktop": "desktop", "EnvironmentMobile": "mobile", "Metrics_Max_Percent": "Highest %", diff --git a/plugin.json b/plugin.json index 8a82dfe3..17a8ae38 100644 --- a/plugin.json +++ b/plugin.json @@ -13,9 +13,6 @@ "homepage": "https://github.com/DevDavido" } ], - "donate": { - "paypal": "david.domainemail@gmx.de" - }, "support": { "email": "github{at}diskoboss{døt}de", "issues": "https://github.com/DevDavido/performance-audit-plugin/issues" diff --git a/templates/version.twig b/templates/version.twig index 9957c57a..4460f535 100644 --- a/templates/version.twig +++ b/templates/version.twig @@ -23,8 +23,8 @@

{{ 'PerformanceAudit_SupportMeText'|translate('

')|raw }}

- - {{ 'PerformanceAudit_Donate'|translate }} + + {{ 'PerformanceAudit_Donate_BuyMeACoffee'|translate }}

From 65c2b99fc9a4f207ac8f6f73c0c1afa188ea265d Mon Sep 17 00:00:00 2001 From: DevDavido <997605+DevDavido@users.noreply.github.com> Date: Wed, 20 Dec 2023 00:21:42 +0100 Subject: [PATCH 06/11] docs: Remove ToDo section from README --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index 3a2abde7..f783c3c0 100644 --- a/README.md +++ b/README.md @@ -78,9 +78,6 @@ Run the integration and unit tests with: ## Changelog Please see the [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. -## ToDo -- Add support for [mobile Matomo app](https://matomo.org/mobile/). - ## Contact If you have any questions or inquiries, you can contact `github{at}diskoboss{døt}de`. From 03a6e63e2f15cc02f2390fd4e5889ad88eacf024 Mon Sep 17 00:00:00 2001 From: DevDavido <997605+DevDavido@users.noreply.github.com> Date: Wed, 20 Dec 2023 00:21:52 +0100 Subject: [PATCH 07/11] docs: Update README badges --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index f783c3c0..fcf8695c 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,7 @@ [![Stable Version](https://img.shields.io/github/v/release/DevDavido/performance-audit-plugin)](https://github.com/DevDavido/performance-audit-plugin/releases) [![GPL Licensed](https://img.shields.io/github/license/DevDavido/performance-audit-plugin?color=yellow)](LICENSE.md) -[![Tests Badge](https://img.shields.io/github/workflow/status/DevDavido/performance-audit-plugin/Tests?label=tests)](https://github.com/DevDavido/performance-audit-plugin/actions?query=workflow%3ATests) -[![Open Issues](https://img.shields.io/github/issues-raw/DevDavido/performance-audit-plugin)](https://github.com/DevDavido/performance-audit-plugin/issues) +[![Tests Badge](https://img.shields.io/github/actions/workflow/status/DevDavido/performance-audit-plugin/tests.yml)](https://github.com/DevDavido/performance-audit-plugin/actions/workflows/tests.yml) ## Description Daily performance audits of all your sites in Matomo for the following metrics based on Google Lighthouse: From fdca5b2144396a540b0701cd6675e4425f34ceff Mon Sep 17 00:00:00 2001 From: DevDavido <997605+DevDavido@users.noreply.github.com> Date: Wed, 20 Dec 2023 00:38:51 +0100 Subject: [PATCH 08/11] feat: Add support to find latest Node executable in Plesk environment --- ExecutableFinder.php | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/ExecutableFinder.php b/ExecutableFinder.php index a1b88825..fe3e9cd6 100644 --- a/ExecutableFinder.php +++ b/ExecutableFinder.php @@ -36,14 +36,6 @@ public static function search($name) return $executablePath; } - /* - public static function getDefaultComposerHomePath() { - return ExecutableFinder::isRunningOnWindows() ? - '%HOMEDRIVE%%HOMEPATH%\AppData\Roaming\Composer' : - '$HOME/.composer'; - } - */ - /** * Get default path for executables depending on platform. * @@ -51,8 +43,27 @@ public static function getDefaultComposerHomePath() { */ public static function getDefaultPath() { return ExecutableFinder::isRunningOnWindows() ? - '%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;' : - '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/plesk/node/14/bin:/opt/plesk/node/12/bin:/opt/plesk/node/10/bin'; + implode(";", [ + '%SystemRoot%\system32', + '%SystemRoot%', + '%SystemRoot%\System32\Wbem' + ]) : + implode(":", [ + '/usr/local/sbin', + '/usr/local/bin', + '/usr/sbin', + '/usr/bin', + '/sbin', + '/bin', + '/opt/plesk/node/24/bin', + '/opt/plesk/node/22/bin', + '/opt/plesk/node/20/bin', + '/opt/plesk/node/18/bin', + '/opt/plesk/node/16/bin', + '/opt/plesk/node/14/bin', + '/opt/plesk/node/12/bin', + '/opt/plesk/node/10/bin' + ]); } /** From f3970e1dd12d4fcf4bfd7715b3b33ed15a9efcf4 Mon Sep 17 00:00:00 2001 From: DevDavido <997605+DevDavido@users.noreply.github.com> Date: Wed, 20 Dec 2023 00:58:26 +0100 Subject: [PATCH 09/11] build: Release 2.1.0 --- plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.json b/plugin.json index 17a8ae38..33efbf00 100644 --- a/plugin.json +++ b/plugin.json @@ -1,7 +1,7 @@ { "name": "PerformanceAudit", "description": "Daily performance audits of all your sites in Matomo.", - "version": "2.0.0", + "version": "2.1.0", "theme": false, "require": { "php": ">=7.2.5", From dd455908d717849237ad932b00693ff1555efb25 Mon Sep 17 00:00:00 2001 From: DevDavido <997605+DevDavido@users.noreply.github.com> Date: Wed, 20 Dec 2023 00:58:31 +0100 Subject: [PATCH 10/11] docs: Added release 2.1.0 to CHANGELOG --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d74fd172..22d5af47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,11 @@ # Changelog +## 2.1.0 +- Added: Site setting to group URLs by anchor which removes auditing duplicates of URLs which only differ in their anchors +- Added: Support to find latest Node executable in Plesk environment +- Added: Initial (partial) translation available for Albanian, Basque, Bokmål, Brazilian Portuguese, Bulgarian, Catalan, Chinese (Traditional), Dutch, French, German, Greek, Indonesian, Italian, Japanese, Portuguese, Spanish, Swedish, Turkish, Ukrainian +- Updated: Bumped `symfony/process`, `ducks-project/spl-types`, `symfony/polyfill-mbstring` and `friendsofphp/php-cs-fixer` dependency version +- Updated donation links + ## 2.0.0 - Release stable version for Matomo 4 - Updated: Bumped `symfony/process` and `symfony/polyfill-mbstring` dependency version From b1a3ac2a7628820a8e8a93a313aec735a6dc66b3 Mon Sep 17 00:00:00 2001 From: DevDavido <997605+DevDavido@users.noreply.github.com> Date: Wed, 20 Dec 2023 14:59:08 +0100 Subject: [PATCH 11/11] build: Update tests workflow --- .github/workflows/tests.yml | 76 ++++++------------- Columns/Metrics/MaxPercent.php | 6 ++ Columns/Metrics/MaxSeconds.php | 6 ++ Columns/Metrics/MedianPercent.php | 6 ++ Columns/Metrics/MedianSeconds.php | 6 ++ Columns/Metrics/MinPercent.php | 6 ++ Columns/Metrics/MinSeconds.php | 6 ++ tests/Integration/ApiTest.php | 13 ++-- ...erformanceAuditIntegrationPreparation.php} | 7 +- tests/Unit/Metric/PercentTest.php | 13 ++-- tests/Unit/Metric/SecondsTest.php | 19 ++++- 11 files changed, 93 insertions(+), 71 deletions(-) rename tests/Integration/{PerformanceAuditIntegrationTest.php => PerformanceAuditIntegrationPreparation.php} (97%) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f3b7b291..f16b7ae4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -5,67 +5,37 @@ on: paths-ignore: - '*.md' -env: - PLUGIN_NAME: PerformanceAudit - TEST_SUITE: PluginTests - MYSQL_ADAPTER: PDO_MYSQL - jobs: - phpunit: + tests: strategy: + fail-fast: false matrix: - php-versions: ['7.1'] - #php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0'] - matomo-versions: ['3.12.0', '3.14.0'] - node-version: [12.x] - #node-version: [10.x, 12.x] + php: ['7.2', '7.4', '8.0', '8.3'] + matomo-target: ['minimum_required_matomo', 'maximum_supported_matomo'] + node: ['12.x', '20.x'] runs-on: ubuntu-latest - name: PHPUnit with PHP ${{ matrix.php-versions }}, Node.js ${{ matrix.node-version }} and Matomo ${{ matrix.matomo-versions }} + permissions: + checks: write + pull-requests: write + contents: read - steps: - - uses: actions/checkout@v2 + name: Tests w/ PHP ${{ matrix.php }}, Node.js ${{ matrix.node }}, Target Matomo '${{ matrix.matomo-target }}' - - name: Setup PHP - uses: shivammathur/setup-php@v2 + steps: + - name: Checkout repository + uses: actions/checkout@v4 with: - php-version: ${{ matrix.php-versions }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, intl, gd, iconv - coverage: none - tools: composer, phpunit:7.5.20 + lfs: true + persist-credentials: false - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + - name: Run plugin tests + uses: matomo-org/github-action-tests@main with: - node-version: ${{ matrix.node-version }} - - - name: Create database - run: | - sudo /etc/init.d/mysql start - mysql -u root -proot -e 'CREATE DATABASE IF NOT EXISTS matomo_tests;' - - - name: Clone Matomo and run plugin Tests - # TODO - run: | - shopt -s extglob - mkdir ${{ env.PLUGIN_NAME }} - cp -R !(${{ env.PLUGIN_NAME }}) ${{ env.PLUGIN_NAME }} - cp -R .git/ ${{ env.PLUGIN_NAME }}/ - - git clone --config filter.lfs.smudge=true -q https://github.com/matomo-org/matomo.git matomo - cd matomo - git fetch --all - git submodule update - git checkout -f -q tags/${{ matrix.matomo-versions }} - [ -d ./tests/travis/.git ] || sh -c "rm -rf ./tests/travis && git clone https://github.com/matomo-org/travis-scripts.git ./tests/travis" - cd ./tests/travis - git checkout master - cd ../.. - [ ! -f ./tests/travis/check_plugin_compatible_with_piwik.php ] || php ./tests/travis/check_plugin_compatible_with_piwik.php "${{ env.PLUGIN_NAME }}" - composer install --no-dev --no-progress - rm -rf plugins/${{ env.PLUGIN_NAME }} - mv ../${{ env.PLUGIN_NAME }} plugins - echo './console tests:run PerformanceAudit' - env: - DB_PASSWORD: root + plugin-name: 'PerformanceAudit' + test-type: 'PluginTests' + php-version: ${{ matrix.php }} + matomo-test-branch: ${{ matrix.matomo-target }} + node-version: ${{ matrix.node }} + mysql-service: true diff --git a/Columns/Metrics/MaxPercent.php b/Columns/Metrics/MaxPercent.php index 12f95473..28ab5141 100644 --- a/Columns/Metrics/MaxPercent.php +++ b/Columns/Metrics/MaxPercent.php @@ -6,6 +6,7 @@ use Piwik\Metrics\Formatter; use Piwik\Piwik; +use TypeError; class MaxPercent extends Max { @@ -35,9 +36,14 @@ public function getDocumentation() * @param mixed $value * @param Formatter $formatter * @return mixed $value + * @throws TypeError */ public function format($value, Formatter $formatter) { + if (!is_numeric($value)) { + throw new TypeError("A non-numeric value encountered"); + } + return mb_substr($formatter->getPrettyPercentFromQuotient($value / 100), 0, -1); } } diff --git a/Columns/Metrics/MaxSeconds.php b/Columns/Metrics/MaxSeconds.php index 8324faeb..799d3a44 100644 --- a/Columns/Metrics/MaxSeconds.php +++ b/Columns/Metrics/MaxSeconds.php @@ -6,6 +6,7 @@ use Piwik\Metrics\Formatter; use Piwik\Piwik; +use TypeError; class MaxSeconds extends Max { @@ -35,9 +36,14 @@ public function getDocumentation() * @param mixed $value * @param Formatter $formatter * @return mixed $value + * @throws TypeError */ public function format($value, Formatter $formatter) { + if (!is_numeric($value)) { + throw new TypeError("A non-numeric value encountered"); + } + if ($value == 0) { return '0.000'; } diff --git a/Columns/Metrics/MedianPercent.php b/Columns/Metrics/MedianPercent.php index 7599f41e..17c83e47 100644 --- a/Columns/Metrics/MedianPercent.php +++ b/Columns/Metrics/MedianPercent.php @@ -6,6 +6,7 @@ use Piwik\Metrics\Formatter; use Piwik\Piwik; +use TypeError; class MedianPercent extends Median { @@ -35,9 +36,14 @@ public function getDocumentation() * @param mixed $value * @param Formatter $formatter * @return mixed $value + * @throws TypeError */ public function format($value, Formatter $formatter) { + if (!is_numeric($value)) { + throw new TypeError("A non-numeric value encountered"); + } + return mb_substr($formatter->getPrettyPercentFromQuotient($value / 100), 0, -1); } } diff --git a/Columns/Metrics/MedianSeconds.php b/Columns/Metrics/MedianSeconds.php index 42d4e11b..ea468161 100644 --- a/Columns/Metrics/MedianSeconds.php +++ b/Columns/Metrics/MedianSeconds.php @@ -6,6 +6,7 @@ use Piwik\Metrics\Formatter; use Piwik\Piwik; +use TypeError; class MedianSeconds extends Median { @@ -35,9 +36,14 @@ public function getDocumentation() * @param mixed $value * @param Formatter $formatter * @return mixed $value + * @throws TypeError */ public function format($value, Formatter $formatter) { + if (!is_numeric($value)) { + throw new TypeError("A non-numeric value encountered"); + } + if ($value == 0) { return '0.000'; } diff --git a/Columns/Metrics/MinPercent.php b/Columns/Metrics/MinPercent.php index de190fca..9a9358a5 100644 --- a/Columns/Metrics/MinPercent.php +++ b/Columns/Metrics/MinPercent.php @@ -6,6 +6,7 @@ use Piwik\Metrics\Formatter; use Piwik\Piwik; +use TypeError; class MinPercent extends Min { @@ -35,9 +36,14 @@ public function getDocumentation() * @param mixed $value * @param Formatter $formatter * @return mixed $value + * @throws TypeError */ public function format($value, Formatter $formatter) { + if (!is_numeric($value)) { + throw new TypeError("A non-numeric value encountered"); + } + return mb_substr($formatter->getPrettyPercentFromQuotient($value / 100), 0, -1); } } diff --git a/Columns/Metrics/MinSeconds.php b/Columns/Metrics/MinSeconds.php index 32b37278..90552144 100644 --- a/Columns/Metrics/MinSeconds.php +++ b/Columns/Metrics/MinSeconds.php @@ -6,6 +6,7 @@ use Piwik\Metrics\Formatter; use Piwik\Piwik; +use TypeError; class MinSeconds extends Min { @@ -35,9 +36,14 @@ public function getDocumentation() * @param mixed $value * @param Formatter $formatter * @return mixed $value + * @throws TypeError */ public function format($value, Formatter $formatter) { + if (!is_numeric($value)) { + throw new TypeError("A non-numeric value encountered"); + } + if ($value == 0) { return '0.000'; } diff --git a/tests/Integration/ApiTest.php b/tests/Integration/ApiTest.php index d718612d..4e03f44f 100644 --- a/tests/Integration/ApiTest.php +++ b/tests/Integration/ApiTest.php @@ -9,14 +9,14 @@ use Piwik\ArchiveProcessor\Rules; use Piwik\DataTable; use Piwik\Date; -use Piwik\Translate; +use Piwik\Tests\Framework\Fixture; /** * @group ApiTest * @group PerformanceAudit * @group Plugins */ -class ApiTest extends PerformanceAuditIntegrationTest +class ApiTest extends PerformanceAuditIntegrationPreparation { /** * @var Date @@ -29,15 +29,16 @@ public function setUp(): void $this->date = Date::factory('2020-06-15'); - Translate::loadAllTranslations(); + Fixture::loadAllTranslations(); Rules::setBrowserTriggerArchiving(true); + + $this->markTestSkipped('Plugin API integration test contains SQL error and must be revisited: https://github.com/DevDavido/performance-audit-plugin/issues/47'); } - public function tearDown() + public function tearDown(): void { + Fixture::resetTranslations(); parent::tearDown(); - - //Translate::reset(); } // Site 1 diff --git a/tests/Integration/PerformanceAuditIntegrationTest.php b/tests/Integration/PerformanceAuditIntegrationPreparation.php similarity index 97% rename from tests/Integration/PerformanceAuditIntegrationTest.php rename to tests/Integration/PerformanceAuditIntegrationPreparation.php index f69ff8f5..daef1f2f 100644 --- a/tests/Integration/PerformanceAuditIntegrationTest.php +++ b/tests/Integration/PerformanceAuditIntegrationPreparation.php @@ -20,7 +20,7 @@ use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; -abstract class PerformanceAuditIntegrationTest extends IntegrationTestCase +abstract class PerformanceAuditIntegrationPreparation extends IntegrationTestCase { const SERVER_HOST_NAME = 'localhost'; const SERVER_PORT = 80; @@ -43,9 +43,10 @@ public function setUp(): void // Create user $this->addPreexistingSuperUser(); - $this->superUserTokenAuth = UsersManagerAPI::getInstance()->getTokenAuth( + $this->superUserTokenAuth = UsersManagerAPI::getInstance()->createAppSpecificTokenAuth( self::TEST_SUPERUSER_LOGIN, - md5(self::TEST_SUPERUSER_PASS) + self::TEST_SUPERUSER_PASS, + "app-specific-pwd-description" ); // Create sites diff --git a/tests/Unit/Metric/PercentTest.php b/tests/Unit/Metric/PercentTest.php index c4ece8f5..c4bf4cb9 100644 --- a/tests/Unit/Metric/PercentTest.php +++ b/tests/Unit/Metric/PercentTest.php @@ -5,11 +5,11 @@ require PIWIK_INCLUDE_PATH . '/plugins/PerformanceAudit/vendor/autoload.php'; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_Error_Warning; use Piwik\Metrics\Formatter; use Piwik\Plugins\PerformanceAudit\Columns\Metrics\MaxPercent; use Piwik\Plugins\PerformanceAudit\Columns\Metrics\MedianPercent; use Piwik\Plugins\PerformanceAudit\Columns\Metrics\MinPercent; +use TypeError; /** * @group Metric @@ -22,7 +22,7 @@ class PercentTest extends TestCase /** @var Formatter */ private $formatter; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -45,11 +45,10 @@ public function test_max_median_min_percent_format_as_expected() } } - /** - * @expectedException PHPUnit_Framework_Error_Warning - */ - public function test_max_median_min_percent_format_with_warning() + public function test_max_median_min_percent_format_with_exception() { + $this->expectException(TypeError::class); + $objs = [ new MaxPercent(), new MedianPercent(), @@ -57,7 +56,7 @@ public function test_max_median_min_percent_format_with_warning() ]; foreach ($objs as $obj) { - $this->assertSame('', $obj->format('test', $this->formatter)); + $obj->format('test', $this->formatter); } } } diff --git a/tests/Unit/Metric/SecondsTest.php b/tests/Unit/Metric/SecondsTest.php index 0291621e..305a1960 100644 --- a/tests/Unit/Metric/SecondsTest.php +++ b/tests/Unit/Metric/SecondsTest.php @@ -9,6 +9,7 @@ use Piwik\Plugins\PerformanceAudit\Columns\Metrics\MaxSeconds; use Piwik\Plugins\PerformanceAudit\Columns\Metrics\MedianSeconds; use Piwik\Plugins\PerformanceAudit\Columns\Metrics\MinSeconds; +use TypeError; /** * @group Metric @@ -21,7 +22,7 @@ class SecondsTest extends TestCase /** @var Formatter */ private $formatter; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -42,7 +43,21 @@ public function test_max_median_min_seconds_format_as_expected() $this->assertSame('50.125', $obj->format(50125, $this->formatter)); $this->assertSame('100', $obj->format(100000, $this->formatter)); $this->assertSame('-100.55', $obj->format(-100550, $this->formatter)); - $this->assertSame('0.000', $obj->format('test', $this->formatter)); + } + } + + public function test_max_median_min_seconds_format_with_exception() + { + $this->expectException(TypeError::class); + + $objs = [ + new MaxSeconds(), + new MedianSeconds(), + new MinSeconds() + ]; + + foreach ($objs as $obj) { + $obj->format('test', $this->formatter); } } }