From 1584d008911dd911b219f1b72648881f66f238fd Mon Sep 17 00:00:00 2001 From: wn_ Date: Mon, 1 Nov 2021 15:36:56 +0000 Subject: Bump PHPStan to 1.0.0 --- composer.json | 2 +- composer.lock | 18 +- vendor/composer/ClassLoader.php | 117 +++++- vendor/composer/InstalledVersions.php | 689 +++++++++++++++----------------- vendor/composer/autoload_real.php | 2 - vendor/composer/installed.json | 16 +- vendor/composer/installed.php | 214 +++++----- vendor/composer/platform_check.php | 26 -- vendor/phpstan/phpstan/.gitattributes | 11 - vendor/phpstan/phpstan/.gitignore | 9 - vendor/phpstan/phpstan/README.md | 2 +- vendor/phpstan/phpstan/composer.json | 2 +- vendor/phpstan/phpstan/phpstan.phar | Bin 19102255 -> 19115160 bytes vendor/phpstan/phpstan/phpstan.phar.asc | 26 +- 14 files changed, 565 insertions(+), 569 deletions(-) delete mode 100644 vendor/composer/platform_check.php delete mode 100644 vendor/phpstan/phpstan/.gitattributes delete mode 100644 vendor/phpstan/phpstan/.gitignore diff --git a/composer.json b/composer.json index a1729917d..7d164b375 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,6 @@ "j4mie/idiorm": "^1.5" }, "require-dev": { - "phpstan/phpstan": "^0.12.99" + "phpstan/phpstan": "^1.0.0" } } diff --git a/composer.lock b/composer.lock index 616b75b74..ad9d5dd7a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "76e40cf59f811ee42d14ac41159c570a", + "content-hash": "7e359aa56ec6aad30f701009ced5590c", "packages": [ { "name": "beberlei/assert", @@ -595,16 +595,16 @@ "packages-dev": [ { "name": "phpstan/phpstan", - "version": "0.12.99", + "version": "1.0.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7" + "reference": "0d13a99513182e521271d46bde8f28caa4f84d97" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/b4d40f1d759942f523be267a1bab6884f46ca3f7", - "reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/0d13a99513182e521271d46bde8f28caa4f84d97", + "reference": "0d13a99513182e521271d46bde8f28caa4f84d97", "shasum": "" }, "require": { @@ -620,7 +620,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "0.12-dev" + "dev-master": "1.0-dev" } }, "autoload": { @@ -635,7 +635,7 @@ "description": "PHPStan - PHP Static Analysis Tool", "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/0.12.99" + "source": "https://github.com/phpstan/phpstan/tree/1.0.0" }, "funding": [ { @@ -655,7 +655,7 @@ "type": "tidelift" } ], - "time": "2021-09-12T20:09:55+00:00" + "time": "2021-11-01T06:38:20+00:00" } ], "aliases": [], @@ -665,5 +665,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.0.0" + "plugin-api-version": "2.1.0" } diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php index 247294d66..0cd6055d1 100644 --- a/vendor/composer/ClassLoader.php +++ b/vendor/composer/ClassLoader.php @@ -42,30 +42,75 @@ namespace Composer\Autoload; */ class ClassLoader { + /** @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; } + /** + * @return string[] + */ public function getPrefixes() { if (!empty($this->prefixesPsr0)) { @@ -75,28 +120,47 @@ class ClassLoader 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-var 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) { @@ -111,9 +175,11 @@ class ClassLoader * 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) { @@ -156,11 +222,13 @@ class ClassLoader * 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) { @@ -204,8 +272,10 @@ class ClassLoader * 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) { @@ -220,10 +290,12 @@ class ClassLoader * 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) { @@ -243,6 +315,8 @@ class ClassLoader * Turns on searching the include path for class files. * * @param bool $useIncludePath + * + * @return void */ public function setUseIncludePath($useIncludePath) { @@ -265,6 +339,8 @@ class ClassLoader * that have not been registered with the class map. * * @param bool $classMapAuthoritative + * + * @return void */ public function setClassMapAuthoritative($classMapAuthoritative) { @@ -285,6 +361,8 @@ class ClassLoader * 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) { @@ -305,6 +383,8 @@ class ClassLoader * Registers this instance as an autoloader. * * @param bool $prepend Whether to prepend the autoloader or not + * + * @return void */ public function register($prepend = false) { @@ -324,6 +404,8 @@ class ClassLoader /** * Unregisters this instance as an autoloader. + * + * @return void */ public function unregister() { @@ -338,7 +420,7 @@ class ClassLoader * 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) { @@ -347,6 +429,8 @@ class ClassLoader return true; } + + return null; } /** @@ -401,6 +485,11 @@ class ClassLoader return self::$registeredLoaders; } + /** + * @param string $class + * @param string $ext + * @return string|false + */ private function findFileWithExtension($class, $ext) { // PSR-4 lookup @@ -472,6 +561,10 @@ class ClassLoader * Scope isolated include. * * Prevents access to $this/self from included files. + * + * @param string $file + * @return void + * @private */ function includeFile($file) { diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php index 7aa64aca4..7c5502ca4 100644 --- a/vendor/composer/InstalledVersions.php +++ b/vendor/composer/InstalledVersions.php @@ -1,374 +1,337 @@ + * 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` + */ class InstalledVersions { -private static $installed = array ( - 'root' => - array ( - 'pretty_version' => 'dev-master', - 'version' => 'dev-master', - 'aliases' => - array ( - ), - 'reference' => '2a5c2be6cdd9ba9217a0661805b62aeec1de90c3', - 'dev-requirement' => true, - 'name' => '__root__', - ), - 'versions' => - array ( - '__root__' => - array ( - 'pretty_version' => 'dev-master', - 'version' => 'dev-master', - 'aliases' => - array ( - ), - 'reference' => '2a5c2be6cdd9ba9217a0661805b62aeec1de90c3', - 'dev-requirement' => false, - ), - 'beberlei/assert' => - array ( - 'pretty_version' => 'v3.2.7', - 'version' => '3.2.7.0', - 'aliases' => - array ( - ), - 'reference' => 'd63a6943fc4fd1a2aedb65994e3548715105abcf', - 'dev-requirement' => false, - ), - 'chillerlan/php-qrcode' => - array ( - 'pretty_version' => '3.4.0', - 'version' => '3.4.0.0', - 'aliases' => - array ( - ), - 'reference' => 'd8bf297e6843a53aeaa8f3285ce04fc349d133d6', - 'dev-requirement' => false, - ), - 'chillerlan/php-settings-container' => - array ( - 'pretty_version' => '1.2.1', - 'version' => '1.2.1.0', - 'aliases' => - array ( - ), - 'reference' => 'b9b0431dffd74102ee92348a63b4c33fc8ba639b', - 'dev-requirement' => false, - ), - 'j4mie/idiorm' => - array ( - 'pretty_version' => 'v1.5.7', - 'version' => '1.5.7.0', - 'aliases' => - array ( - ), - 'reference' => 'd23f97053ef5d0b988a02c6a71eb5c6118b2f5b4', - 'dev-requirement' => false, - ), - 'mervick/material-design-icons' => - array ( - 'pretty_version' => '2.2.0', - 'version' => '2.2.0.0', - 'aliases' => - array ( - ), - 'reference' => '635435c8d3df3a6da3241648caf8a65d1c07cc1a', - 'dev-requirement' => false, - ), - 'paragonie/constant_time_encoding' => - array ( - 'pretty_version' => 'v2.4.0', - 'version' => '2.4.0.0', - 'aliases' => - array ( - ), - 'reference' => 'f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c', - 'dev-requirement' => false, - ), - 'phpstan/phpstan' => - array ( - 'pretty_version' => '0.12.99', - 'version' => '0.12.99.0', - 'aliases' => - array ( - ), - 'reference' => 'b4d40f1d759942f523be267a1bab6884f46ca3f7', - 'dev-requirement' => true, - ), - 'spomky-labs/otphp' => - array ( - 'pretty_version' => 'v10.0.1', - 'version' => '10.0.1.0', - 'aliases' => - array ( - ), - 'reference' => 'f44cce5a9db4b8da410215d992110482c931232f', - 'dev-requirement' => false, - ), - 'thecodingmachine/safe' => - array ( - 'pretty_version' => 'v1.3.3', - 'version' => '1.3.3.0', - 'aliases' => - array ( - ), - 'reference' => 'a8ab0876305a4cdaef31b2350fcb9811b5608dbc', - 'dev-requirement' => false, - ), - ), -); -private static $canGetVendors; -private static $installedByVendor = array(); - - - - - - - -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))); -} - - - - - - - - - - -public static function isInstalled($packageName, $includeDevRequirements = true) -{ -foreach (self::getInstalled() as $installed) { -if (isset($installed['versions'][$packageName])) { -return $includeDevRequirements || empty($installed['versions'][$packageName]['dev-requirement']); -} -} - -return false; -} - - - - - - - - - - - - - -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) -{ -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'); -} - - - - - -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'); -} - - - - - -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'); -} - - - - - -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'); -} - - - - - -public static function getRootPackage() -{ -$installed = self::getInstalled(); - -return $installed[0]['root']; -} - - - - - - - -public static function getRawData() -{ -return self::$installed; -} - - - - - - - - - - - - - - - - - - - -public static function reload($data) -{ -self::$installed = $data; -self::$installedByVendor = array(); -} - - - - -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')) { -$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; -} -} -} - -$installed[] = self::$installed; - -return $installed; -} + private static $installed; + private static $canGetVendors; + 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 || empty($installed['versions'][$packageName]['dev_requirement']); + } + } + + 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($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, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string} + */ + 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, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, 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, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, 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')) { + $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; + 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') { + self::$installed = require __DIR__ . '/installed.php'; + } else { + self::$installed = array(); + } + } + $installed[] = self::$installed; + + return $installed; + } } diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 34b3b7ad0..51b54d2f0 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -22,8 +22,6 @@ class ComposerAutoloaderInit19fc2ff1c0f9a92279c7979386bb2056 return self::$loader; } - require __DIR__ . '/platform_check.php'; - spl_autoload_register(array('ComposerAutoloaderInit19fc2ff1c0f9a92279c7979386bb2056', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); spl_autoload_unregister(array('ComposerAutoloaderInit19fc2ff1c0f9a92279c7979386bb2056', 'loadClassLoader')); diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index e06a40433..e05582fec 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -391,17 +391,17 @@ }, { "name": "phpstan/phpstan", - "version": "0.12.99", - "version_normalized": "0.12.99.0", + "version": "1.0.0", + "version_normalized": "1.0.0.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7" + "reference": "0d13a99513182e521271d46bde8f28caa4f84d97" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/b4d40f1d759942f523be267a1bab6884f46ca3f7", - "reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/0d13a99513182e521271d46bde8f28caa4f84d97", + "reference": "0d13a99513182e521271d46bde8f28caa4f84d97", "shasum": "" }, "require": { @@ -410,7 +410,7 @@ "conflict": { "phpstan/phpstan-shim": "*" }, - "time": "2021-09-12T20:09:55+00:00", + "time": "2021-11-01T06:38:20+00:00", "bin": [ "phpstan", "phpstan.phar" @@ -418,7 +418,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "0.12-dev" + "dev-master": "1.0-dev" } }, "installation-source": "dist", @@ -434,7 +434,7 @@ "description": "PHPStan - PHP Static Analysis Tool", "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/0.12.99" + "source": "https://github.com/phpstan/phpstan/tree/1.0.0" }, "funding": [ { diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 17ae71708..28c605be1 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -1,116 +1,104 @@ - - array ( - 'pretty_version' => 'dev-master', - 'version' => 'dev-master', - 'aliases' => - array ( + array( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'type' => 'library', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'reference' => '9714c4fbcf76492d084ca5327cbab1ad1b662280', + 'name' => '__root__', + 'dev' => true, ), - 'reference' => '2a5c2be6cdd9ba9217a0661805b62aeec1de90c3', - 'dev-requirement' => true, - 'name' => '__root__', - ), - 'versions' => - array ( - '__root__' => - array ( - 'pretty_version' => 'dev-master', - 'version' => 'dev-master', - 'aliases' => - array ( - ), - 'reference' => '2a5c2be6cdd9ba9217a0661805b62aeec1de90c3', - 'dev-requirement' => false, + 'versions' => array( + '__root__' => array( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'type' => 'library', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'reference' => '9714c4fbcf76492d084ca5327cbab1ad1b662280', + 'dev_requirement' => false, + ), + 'beberlei/assert' => array( + 'pretty_version' => 'v3.2.7', + 'version' => '3.2.7.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../beberlei/assert', + 'aliases' => array(), + 'reference' => 'd63a6943fc4fd1a2aedb65994e3548715105abcf', + 'dev_requirement' => false, + ), + 'chillerlan/php-qrcode' => array( + 'pretty_version' => '3.4.0', + 'version' => '3.4.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../chillerlan/php-qrcode', + 'aliases' => array(), + 'reference' => 'd8bf297e6843a53aeaa8f3285ce04fc349d133d6', + 'dev_requirement' => false, + ), + 'chillerlan/php-settings-container' => array( + 'pretty_version' => '1.2.1', + 'version' => '1.2.1.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../chillerlan/php-settings-container', + 'aliases' => array(), + 'reference' => 'b9b0431dffd74102ee92348a63b4c33fc8ba639b', + 'dev_requirement' => false, + ), + 'j4mie/idiorm' => array( + 'pretty_version' => 'v1.5.7', + 'version' => '1.5.7.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../j4mie/idiorm', + 'aliases' => array(), + 'reference' => 'd23f97053ef5d0b988a02c6a71eb5c6118b2f5b4', + 'dev_requirement' => false, + ), + 'mervick/material-design-icons' => array( + 'pretty_version' => '2.2.0', + 'version' => '2.2.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../mervick/material-design-icons', + 'aliases' => array(), + 'reference' => '635435c8d3df3a6da3241648caf8a65d1c07cc1a', + 'dev_requirement' => false, + ), + 'paragonie/constant_time_encoding' => array( + 'pretty_version' => 'v2.4.0', + 'version' => '2.4.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../paragonie/constant_time_encoding', + 'aliases' => array(), + 'reference' => 'f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c', + 'dev_requirement' => false, + ), + 'phpstan/phpstan' => array( + 'pretty_version' => '1.0.0', + 'version' => '1.0.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../phpstan/phpstan', + 'aliases' => array(), + 'reference' => '0d13a99513182e521271d46bde8f28caa4f84d97', + 'dev_requirement' => true, + ), + 'spomky-labs/otphp' => array( + 'pretty_version' => 'v10.0.1', + 'version' => '10.0.1.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../spomky-labs/otphp', + 'aliases' => array(), + 'reference' => 'f44cce5a9db4b8da410215d992110482c931232f', + 'dev_requirement' => false, + ), + 'thecodingmachine/safe' => array( + 'pretty_version' => 'v1.3.3', + 'version' => '1.3.3.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../thecodingmachine/safe', + 'aliases' => array(), + 'reference' => 'a8ab0876305a4cdaef31b2350fcb9811b5608dbc', + 'dev_requirement' => false, + ), ), - 'beberlei/assert' => - array ( - 'pretty_version' => 'v3.2.7', - 'version' => '3.2.7.0', - 'aliases' => - array ( - ), - 'reference' => 'd63a6943fc4fd1a2aedb65994e3548715105abcf', - 'dev-requirement' => false, - ), - 'chillerlan/php-qrcode' => - array ( - 'pretty_version' => '3.4.0', - 'version' => '3.4.0.0', - 'aliases' => - array ( - ), - 'reference' => 'd8bf297e6843a53aeaa8f3285ce04fc349d133d6', - 'dev-requirement' => false, - ), - 'chillerlan/php-settings-container' => - array ( - 'pretty_version' => '1.2.1', - 'version' => '1.2.1.0', - 'aliases' => - array ( - ), - 'reference' => 'b9b0431dffd74102ee92348a63b4c33fc8ba639b', - 'dev-requirement' => false, - ), - 'j4mie/idiorm' => - array ( - 'pretty_version' => 'v1.5.7', - 'version' => '1.5.7.0', - 'aliases' => - array ( - ), - 'reference' => 'd23f97053ef5d0b988a02c6a71eb5c6118b2f5b4', - 'dev-requirement' => false, - ), - 'mervick/material-design-icons' => - array ( - 'pretty_version' => '2.2.0', - 'version' => '2.2.0.0', - 'aliases' => - array ( - ), - 'reference' => '635435c8d3df3a6da3241648caf8a65d1c07cc1a', - 'dev-requirement' => false, - ), - 'paragonie/constant_time_encoding' => - array ( - 'pretty_version' => 'v2.4.0', - 'version' => '2.4.0.0', - 'aliases' => - array ( - ), - 'reference' => 'f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c', - 'dev-requirement' => false, - ), - 'phpstan/phpstan' => - array ( - 'pretty_version' => '0.12.99', - 'version' => '0.12.99.0', - 'aliases' => - array ( - ), - 'reference' => 'b4d40f1d759942f523be267a1bab6884f46ca3f7', - 'dev-requirement' => true, - ), - 'spomky-labs/otphp' => - array ( - 'pretty_version' => 'v10.0.1', - 'version' => '10.0.1.0', - 'aliases' => - array ( - ), - 'reference' => 'f44cce5a9db4b8da410215d992110482c931232f', - 'dev-requirement' => false, - ), - 'thecodingmachine/safe' => - array ( - 'pretty_version' => 'v1.3.3', - 'version' => '1.3.3.0', - 'aliases' => - array ( - ), - 'reference' => 'a8ab0876305a4cdaef31b2350fcb9811b5608dbc', - 'dev-requirement' => false, - ), - ), ); diff --git a/vendor/composer/platform_check.php b/vendor/composer/platform_check.php deleted file mode 100644 index 589e9e770..000000000 --- a/vendor/composer/platform_check.php +++ /dev/null @@ -1,26 +0,0 @@ -= 70200)) { - $issues[] = 'Your Composer dependencies require a PHP version ">= 7.2.0". You are running ' . PHP_VERSION . '.'; -} - -if ($issues) { - 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/phpstan/phpstan/.gitattributes b/vendor/phpstan/phpstan/.gitattributes deleted file mode 100644 index 658b92eeb..000000000 --- a/vendor/phpstan/phpstan/.gitattributes +++ /dev/null @@ -1,11 +0,0 @@ -/.github export-ignore -/BACKERS.md export-ignore -/CODE_OF_CONDUCT.md export-ignore -/docker export-ignore -/e2e export-ignore -/issue-bot export-ignore -/playground-api export-ignore -/playground-runner export-ignore -/.travis.yml export-ignore -/website export-ignore -website/* linguist-vendored diff --git a/vendor/phpstan/phpstan/.gitignore b/vendor/phpstan/phpstan/.gitignore deleted file mode 100644 index 020e4b465..000000000 --- a/vendor/phpstan/phpstan/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -/build/phpstan-generated.neon -/composer.lock -/conf/config.local.yml -/e2e/composer.lock -/e2e/vendor -/vendor -/.idea -/tests/tmp -/tests/.phpunit.result.cache diff --git a/vendor/phpstan/phpstan/README.md b/vendor/phpstan/phpstan/README.md index b31560d28..b90c0d415 100644 --- a/vendor/phpstan/phpstan/README.md +++ b/vendor/phpstan/phpstan/README.md @@ -28,7 +28,7 @@ can be checked before you run the actual line.     Private Packagist
-Musement +Musement     Blackfire.io
diff --git a/vendor/phpstan/phpstan/composer.json b/vendor/phpstan/phpstan/composer.json index 2e1182949..2c9e27962 100644 --- a/vendor/phpstan/phpstan/composer.json +++ b/vendor/phpstan/phpstan/composer.json @@ -14,7 +14,7 @@ ], "extra": { "branch-alias": { - "dev-master": "0.12-dev" + "dev-master": "1.0-dev" } }, "autoload": { diff --git a/vendor/phpstan/phpstan/phpstan.phar b/vendor/phpstan/phpstan/phpstan.phar index 43ca4e4b5..69444cd4e 100644 Binary files a/vendor/phpstan/phpstan/phpstan.phar and b/vendor/phpstan/phpstan/phpstan.phar differ diff --git a/vendor/phpstan/phpstan/phpstan.phar.asc b/vendor/phpstan/phpstan/phpstan.phar.asc index f1191c8bb..47cafb9dc 100644 --- a/vendor/phpstan/phpstan/phpstan.phar.asc +++ b/vendor/phpstan/phpstan/phpstan.phar.asc @@ -1,16 +1,16 @@ -----BEGIN PGP SIGNATURE----- -iQIzBAABCgAdFiEE0yaA1ZV9xxFr4pwUzxoQjQ565yAFAmE+XpIACgkQzxoQjQ56 -5yDsLg/+Nv1uIaCuKfAlpBv+GmszF/jj7P91VYNpf5Zts9lj0tm91MRu+vVc46q7 -v68dIYZoOJE69n+Nvg0BuXA+ZuuMR0A/vMot3CqxqAPAslwaE6c9tg1OpktFoYQp -t7IqU/ftz4OlCEkeBigEtmYe585ppBkWwZNakl81xA5K+DqXEJqCFCdROVRJfa5K -36ck/iIAs2EOtQCwvIQttqev1fTVQAfTicH1B7wnqsg9zQ1a9l1/V2JlhxtzpCsc -1T27yoiUOewpfyVSu3kBUPsXtppFe9X2UjRaOIpUiguXxEsWRW/eUMWFOnUG2tv0 -m1S8Q3roY92eYq94LtHs5mj11YPIkRbzwTwoZv4F5g1pS5jSVhQklCTdrOb6XXfh -aiFe8aiwjFdOs4y5eDGpttDOMOtgDxogGphXiXpzAILn/4mfoP6Cgcd1sOReXaLV -V/eMQvZG3Np93lYf/ezR++Rk4ZM1UAz7fkYw5lTZN3epShpsdsrPGj5MdJoahTFr -+ITm4TVWpuiPIQqV/2TeIm3m0tdXaTGGgOv+qMdOFbEcMqSFg5WnfdWjSzj35R7n -wsjnhyN5MIkMWvWFO4wail3gUUpzKZGyd0Gbo3fVi67piUG38CcjxWUiYZ2EShwp -A88kgsC7m+Ye6Pcjs70VhqHbW+HyW5bwBOuVdVqpkeqgLDM7tuo= -=KGGY +iQIzBAABCgAdFiEE0yaA1ZV9xxFr4pwUzxoQjQ565yAFAmF/i1sACgkQzxoQjQ56 +5yDALhAAhsbjCJLAUrakUztJRtsze7ka9fdbE9tPzTcY79AauMrFp/YIW5v+FrlE +O7+uvxUcNLbBPB/+v4mOIRmwFvJFjttBEKNZRviX/M3GXx/eeKqccXbkmjn/eYhu +1l34QRdROk5cdB9KD0q47wbSWcZ4TN1JyiBxqCyE+vyBDS8EnNjSOoSf+PaVTVyt +01sDLXZdokPF7TyeHzy0T4ye9nPyPe6//yeZkmpy40+ucJI4Y3VlNCycu5JFXt6v +2fYSFawgkPqpm9Oy3gNSL7qm8xMYI9mi3MqXmu+RYjFl3hTsVTYXiEWGeSHZ9lKO +BtzQfH6vhfeziZKRR7/7hCrzqz2s3v0WLdatkYeG9m2qtMNf6M7I3f0MwdMdCgb8 +hZbKFUkHFWq2cFOtz+3ZKlvpbxnXkmnGapdyNVGn5eMkr4HdmrDic/IktHp+XWub +6xZMfHGz/fcuyLAE4XgPuVxx41wYYw2minmsgg2gsx2imTHM4r/ILezftxHIm0zG +Bl4PjxVrXa9WPTibdjd+5Vqat6/9mjCoMc131kDIwqjLmZT2jCXA4SoM8wi6VYkw +UdGumXXklSrN5qdxCpaEMpRMFIdVaiKyhB9MoQfeQ2hnPYA7blgE+htKT26E0vWC +dmtYQm47CKXCWPvrPKQnn0HYgOft655lde1zu2sFjQ5u+QzS9h8= +=PbiR -----END PGP SIGNATURE----- -- cgit v1.2.3 From 77a98134b83a9dfe44081641847ce2a842c05c24 Mon Sep 17 00:00:00 2001 From: wn_ Date: Mon, 1 Nov 2021 16:03:28 +0000 Subject: Address PHPStan warnings in 'classes/config.php'. ------ ----------------------------------------------------------------------- Line classes/config.php ------ ----------------------------------------------------------------------- 3 Constant Config::_ENVVAR_PREFIX is unused. 177 Constant Config::_DEFAULTS is unused. 237 Property Config::$schema_version is never read, only written. 352 Property Config::$migrations (Db_Migrations) in empty() is not falsy. ------ ----------------------------------------------------------------------- --- classes/config.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/classes/config.php b/classes/config.php index be4ecde36..53a31b61c 100644 --- a/classes/config.php +++ b/classes/config.php @@ -234,10 +234,9 @@ class Config { private static $instance; private $params = []; - private $schema_version = null; private $version = []; - /** @var Db_Migrations $migrations */ + /** @var Db_Migrations|null $migrations */ private $migrations; public static function get_instance() : Config { @@ -255,10 +254,10 @@ class Config { $ref = new ReflectionClass(get_class($this)); foreach ($ref->getConstants() as $const => $cvalue) { - if (isset($this::_DEFAULTS[$const])) { - $override = getenv($this::_ENVVAR_PREFIX . $const); + if (isset(self::_DEFAULTS[$const])) { + $override = getenv(self::_ENVVAR_PREFIX . $const); - list ($defval, $deftype) = $this::_DEFAULTS[$const]; + list ($defval, $deftype) = self::_DEFAULTS[$const]; $this->params[$cvalue] = [ self::cast_to($override !== false ? $override : $defval, $deftype), $deftype ]; } @@ -383,7 +382,7 @@ class Config { } private function _add(string $param, string $default, int $type_hint) { - $override = getenv($this::_ENVVAR_PREFIX . $param); + $override = getenv(self::_ENVVAR_PREFIX . $param); $this->params[$param] = [ self::cast_to($override !== false ? $override : $default, $type_hint), $type_hint ]; } -- cgit v1.2.3 From 7d8837ca17a34230e85b05c99f2fa16ef8bdc1d7 Mon Sep 17 00:00:00 2001 From: wn_ Date: Mon, 1 Nov 2021 20:28:00 +0000 Subject: Address PHPStan warnings in 'classes/db.php'. ------ -------------------------------------------------- Line classes/db.php ------ -------------------------------------------------- 7 Property Db::$link is unused. 86 Property Db::pdo (PDO) in empty() is not falsy. ------ -------------------------------------------------- --- classes/db.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/classes/db.php b/classes/db.php index a09c44628..7b669cf32 100755 --- a/classes/db.php +++ b/classes/db.php @@ -4,9 +4,7 @@ class Db /** @var Db $instance */ private static $instance; - private $link; - - /** @var PDO $pdo */ + /** @var PDO|null $pdo */ private $pdo; function __construct() { -- cgit v1.2.3 From 5b17c44e70689d4750e87da8801662baf21c5b6d Mon Sep 17 00:00:00 2001 From: wn_ Date: Mon, 1 Nov 2021 20:29:38 +0000 Subject: Address PHPStan warning in 'classes/feeditem/common.php'. ------ --------------------------------------------- Line classes/feeditem/common.php ------ --------------------------------------------- 194 No error to ignore is reported on line 194. ------ --------------------------------------------- --- classes/feeditem/common.php | 1 - 1 file changed, 1 deletion(-) diff --git a/classes/feeditem/common.php b/classes/feeditem/common.php index b4774941f..18afeaa94 100755 --- a/classes/feeditem/common.php +++ b/classes/feeditem/common.php @@ -190,7 +190,6 @@ abstract class FeedItem_Common extends FeedItem { }, $tmp); // remove empty values - // @phpstan-ignore-next-line $tmp = array_filter($tmp, 'strlen'); asort($tmp); -- cgit v1.2.3 From 72cf4f1f0de570b9944a8d5dca6aed80e1658780 Mon Sep 17 00:00:00 2001 From: wn_ Date: Mon, 1 Nov 2021 20:30:24 +0000 Subject: Address PHPStan warning in 'classes/feeds.php'. ------ ------------------------------------ Line classes/feeds.php ------ ------------------------------------ 8 Property Feeds::$params is unused. ------ ------------------------------------ --- classes/feeds.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/classes/feeds.php b/classes/feeds.php index ea9158949..987123a21 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -5,8 +5,6 @@ class Feeds extends Handler_Protected { const NEVER_GROUP_FEEDS = [ -6, 0 ]; const NEVER_GROUP_BY_DATE = [ -2, -1, -3 ]; - private $params; - private $viewfeed_timestamp; private $viewfeed_timestamp_last; -- cgit v1.2.3 From a7a59fe0e2402df03c383d16d3bfb1c28ecf93b5 Mon Sep 17 00:00:00 2001 From: wn_ Date: Mon, 1 Nov 2021 20:30:55 +0000 Subject: Address PHPStan warning in 'classes/logger/sql.php'. ------ -------------------------------------- Line classes/logger/sql.php ------ -------------------------------------- 4 Property Logger_SQL::$pdo is unused. ------ -------------------------------------- --- classes/logger/sql.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/classes/logger/sql.php b/classes/logger/sql.php index 784ebef31..0f6177a5b 100755 --- a/classes/logger/sql.php +++ b/classes/logger/sql.php @@ -1,8 +1,6 @@ Date: Mon, 1 Nov 2021 20:31:42 +0000 Subject: Address PHPStan warnings in 'classes/pluginhost.php'. ------ -------------------------------------------------------------------- Line classes/pluginhost.php ------ -------------------------------------------------------------------- 16 Property PluginHost::$last_registered is never read, only written. 386 If condition is always true. ------ -------------------------------------------------------------------- --- classes/pluginhost.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/classes/pluginhost.php b/classes/pluginhost.php index f067543bb..b506a957a 100755 --- a/classes/pluginhost.php +++ b/classes/pluginhost.php @@ -13,7 +13,6 @@ class PluginHost { private $api_methods = array(); private $plugin_actions = array(); private $owner_uid; - private $last_registered; private $data_loaded; private static $instance; @@ -383,7 +382,7 @@ class PluginHost { if (!isset($this->plugins[$class])) { try { - if (file_exists($file)) require_once $file; + require_once $file; } catch (Error $err) { user_error($err, E_USER_WARNING); continue; @@ -404,8 +403,6 @@ class PluginHost { _bind_textdomain_codeset($class, "UTF-8"); } - $this->last_registered = $class; - try { switch ($kind) { case $this::KIND_SYSTEM: -- cgit v1.2.3 From a38892d5d78a60e10e572e6473dbe75444462fb6 Mon Sep 17 00:00:00 2001 From: wn_ Date: Mon, 1 Nov 2021 20:32:43 +0000 Subject: Address PHPStan warning in 'classes/pref/prefs.php'. ------ ------------------------------------------------ Line classes/pref/prefs.php ------ ------------------------------------------------ 1328 Expression on left side of ?? is not nullable. ------ ------------------------------------------------ --- classes/pref/prefs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index cb666e945..c47a99469 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -1325,7 +1325,7 @@ class Pref_Prefs extends Handler_Protected { } function activateprofile() { - $id = (int) $_REQUEST['id'] ?? 0; + $id = (int) ($_REQUEST['id'] ?? 0); $profile = ORM::for_table('ttrss_settings_profiles') ->where('owner_uid', $_SESSION['uid']) -- cgit v1.2.3 From ac5a4f5937d2d763b6293d3db644c9f30aa704b6 Mon Sep 17 00:00:00 2001 From: wn_ Date: Mon, 1 Nov 2021 20:33:46 +0000 Subject: Address PHPStan warning in 'classes/pref/users.php'. ------ ------------------------------- Line classes/pref/users.php ------ ------------------------------- 170 If condition is always false. ------ ------------------------------- --- classes/pref/users.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/pref/users.php b/classes/pref/users.php index 76a879efd..aeba296b2 100644 --- a/classes/pref/users.php +++ b/classes/pref/users.php @@ -167,7 +167,7 @@ class Pref_Users extends Handler_Administrative { $user->created = Db::NOW(); $user->save(); - if ($new_uid = UserHelper::find_user_by_login($login)) { + if (!is_null(UserHelper::find_user_by_login($login))) { print T_sprintf("Added user %s with password %s", $login, $new_password); } else { -- cgit v1.2.3 From 9dac9c5a0db520697794c00d29424e617aca55bd Mon Sep 17 00:00:00 2001 From: wn_ Date: Mon, 1 Nov 2021 20:36:48 +0000 Subject: Address PHPStan warnings in 'classes/urlhelper.php'. Intentionally skipping the line 66 one for now; adding an 'is_array' check clears the warning, but there's a larger topic of how to handle an invalid '' that doesn't result in an array. ------ --------------------------------------------------------------------- Line classes/urlhelper.php ------ --------------------------------------------------------------------- 66 Offset 'path' on array{scheme: string} in isset() does not exist. 165 Parameter #2 $associative of function get_headers expects bool, int given. 167 Parameter #2 $associative of function get_headers expects bool, int given. 278 Negated boolean expression is always true. 309 Negated boolean expression is always true. ------ --------------------------------------------------------------------- --- classes/urlhelper.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/classes/urlhelper.php b/classes/urlhelper.php index 0e4834b72..4d11b5a4d 100644 --- a/classes/urlhelper.php +++ b/classes/urlhelper.php @@ -162,8 +162,12 @@ class UrlHelper { $context = stream_context_create($context_options); + // PHP 8 changed the second param from int to bool, but we still support PHP >= 7.1.0 + // @phpstan-ignore-next-line $headers = get_headers($url, 0, $context); } else { + // PHP 8 changed the second param from int to bool, but we still support PHP >= 7.1.0 + // @phpstan-ignore-next-line $headers = get_headers($url, 0); } @@ -275,7 +279,7 @@ class UrlHelper { curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout ? $timeout : Config::get(Config::FILE_FETCH_CONNECT_TIMEOUT)); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ? $timeout : Config::get(Config::FILE_FETCH_TIMEOUT)); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("open_basedir") && $followlocation); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $followlocation); curl_setopt($ch, CURLOPT_MAXREDIRS, 20); curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); @@ -283,6 +287,7 @@ class UrlHelper { curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($ch, CURLOPT_USERAGENT, $useragent ? $useragent : Config::get_user_agent()); curl_setopt($ch, CURLOPT_ENCODING, ""); + curl_setopt($ch, CURLOPT_COOKIEJAR, "/dev/null"); if ($http_referrer) curl_setopt($ch, CURLOPT_REFERER, $http_referrer); @@ -306,10 +311,6 @@ class UrlHelper { } - if (!ini_get("open_basedir")) { - curl_setopt($ch, CURLOPT_COOKIEJAR, "/dev/null"); - } - if (Config::get(Config::HTTP_PROXY)) { curl_setopt($ch, CURLOPT_PROXY, Config::get(Config::HTTP_PROXY)); } -- cgit v1.2.3 From 3cc60a02192eaf0f81065a40d5d781b60f371d15 Mon Sep 17 00:00:00 2001 From: wn_ Date: Mon, 1 Nov 2021 20:37:53 +0000 Subject: Address PHPStan warnings in 'include/colors.php'. ------ ------------------------------------------------------------------ Line include/colors.php ------ ------------------------------------------------------------------ 215 Variable $out might not be defined. 223 Parameter #3 $pad_string of function str_pad expects string, int given. 255 Variable $h might not be defined. 317 Variable $img might not be defined. ------ ------------------------------------------------------------------ --- include/colors.php | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/include/colors.php b/include/colors.php index 41158f96e..94bb82cd2 100644 --- a/include/colors.php +++ b/include/colors.php @@ -200,27 +200,31 @@ function _color_hue2rgb($m1, $m2, $h) { ### Convert a hex color into an RGB triplet. function _color_unpack($hex, $normalize = false) { + $hex = strpos($hex, '#') !== 0 ? _resolve_htmlcolor($hex) : substr($hex, 1); - if (strpos($hex, '#') !== 0) - $hex = _resolve_htmlcolor($hex); - else - $hex = substr($hex, 1); + if (strlen($hex) == 4) { + $hex = $hex[1] . $hex[1] . $hex[2] . $hex[2] . $hex[3] . $hex[3]; + } - if (strlen($hex) == 4) { - $hex = $hex[1] . $hex[1] . $hex[2] . $hex[2] . $hex[3] . $hex[3]; - } - $c = hexdec($hex); - for ($i = 16; $i >= 0; $i -= 8) { - $out[] = (($c >> $i) & 0xFF) / ($normalize ? 255 : 1); - } return $out; + $c = hexdec($hex); + $out = []; + + for ($i = 16; $i >= 0; $i -= 8) { + $out[] = (($c >> $i) & 0xFF) / ($normalize ? 255 : 1); + } + + return $out; } ### Convert an RGB triplet to a hex color. function _color_pack($rgb, $normalize = false) { $out = 0; - foreach ($rgb as $k => $v) { - $out |= (($v * ($normalize ? 255 : 1)) << (16 - $k * 8)); - }return '#'. str_pad(dechex($out), 6, 0, STR_PAD_LEFT); + + foreach ($rgb as $k => $v) { + $out |= (($v * ($normalize ? 255 : 1)) << (16 - $k * 8)); + } + + return '#'. str_pad(dechex($out), 6, '0', STR_PAD_LEFT); } function rgb2hsl($arr) { @@ -248,9 +252,14 @@ function rgb2hsl($arr) { $del_G = ((($var_Max - $var_G ) / 6 ) + ($del_Max / 2 ) ) / $del_Max; $del_B = ((($var_Max - $var_B ) / 6 ) + ($del_Max / 2 ) ) / $del_Max; - if ($var_R == $var_Max) $h = $del_B - $del_G; - else if ($var_G == $var_Max) $h = (1 / 3 ) + $del_R - $del_B; - else if ($var_B == $var_Max) $h = (2 / 3 ) + $del_G - $del_R; + if ($var_R == $var_Max) { + $h = $del_B - $del_G; + } else if ($var_G == $var_Max) { + $h = (1 / 3 ) + $del_R - $del_B; + } else { + // ($var_B == $var_Max) + $h = (2 / 3 ) + $del_G - $del_R; + } if ($h < 0) $h++; if ($h > 1) $h--; @@ -292,6 +301,7 @@ function hsl2rgb($arr) { $colors = array(); $size = @getimagesize($imageFile); + $img = null; // to enable .ico support place floIcon.php into lib/ if (strtolower($size['mime']) == 'image/vnd.microsoft.icon') { -- cgit v1.2.3 From 57436ee0c184c5fa362c66f8383a8a3b29f171cf Mon Sep 17 00:00:00 2001 From: wn_ Date: Mon, 1 Nov 2021 20:38:26 +0000 Subject: Address PHPStan warning in 'update.php'. ------ -------------------------------------- Line update.php ------ -------------------------------------- 213 While loop condition is always true. ------ -------------------------------------- --- update.php | 1 + 1 file changed, 1 insertion(+) diff --git a/update.php b/update.php index 2ad4c963c..b10dde400 100755 --- a/update.php +++ b/update.php @@ -210,6 +210,7 @@ } if (isset($options["daemon"])) { + // @phpstan-ignore-next-line while (true) { $quiet = (isset($options["quiet"])) ? "--quiet" : ""; $log = isset($options['log']) ? '--log '.$options['log'] : ''; -- cgit v1.2.3