From 074311c8e8dd5c5ec66805a021c1e87dd01e52dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Fri, 21 Jul 2023 23:02:33 +0000 Subject: [PATCH] Try new stubs --- composer.json | 4 +- composer.lock | 101 ++++++++++++-------------- phpstan.neon.dist | 48 ++++++------ phpstan/.gitignore | 2 + phpstan/class-app-context.stub | 1 + phpstan/class-gf-quiz.stub | 13 ++-- phpstan/composer.json | 13 ++++ phpstan/constants.php | 4 +- src/Extensions/WPGatsby/Settings.php | 2 +- vendor/composer/ClassLoader.php | 12 ++- vendor/composer/InstalledVersions.php | 17 +++-- vendor/composer/autoload_real.php | 6 +- vendor/composer/installed.php | 4 +- 13 files changed, 122 insertions(+), 105 deletions(-) create mode 100644 phpstan/.gitignore create mode 100644 phpstan/composer.json diff --git a/composer.json b/composer.json index d82d0734..f89f508e 100644 --- a/composer.json +++ b/composer.json @@ -38,10 +38,10 @@ "phpstan/phpstan": "^1.2", "phpstan/extension-installer": "^1.1", "szepeviktor/phpstan-wordpress": "^1.0", - "axepress/wp-graphql-stubs": "^1.11.1", "axepress/wp-graphql-cs": "^1.0.0-beta", "wp-cli/wp-cli-bundle": "^2.8.1", - "php-coveralls/php-coveralls": "^2.5" + "php-coveralls/php-coveralls": "^2.5", + "php-stubs/gravity-forms-stubs": "dev-master" }, "config": { "optimize-autoloader": true, diff --git a/composer.lock b/composer.lock index b91137b6..86653244 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": "1dbd8da85ae4ba5eadefd96015f946e1", + "content-hash": "93d1796be9935b146a13c947f3bca23e", "packages": [ { "name": "yahnis-elsts/plugin-update-checker", @@ -218,58 +218,6 @@ }, "time": "2023-06-05T09:07:08+00:00" }, - { - "name": "axepress/wp-graphql-stubs", - "version": "v1.14.3", - "source": { - "type": "git", - "url": "https://github.com/AxeWP/wp-graphql-stubs.git", - "reference": "84399dce808db09a876fd79013db56af5d8da4da" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/AxeWP/wp-graphql-stubs/zipball/84399dce808db09a876fd79013db56af5d8da4da", - "reference": "84399dce808db09a876fd79013db56af5d8da4da", - "shasum": "" - }, - "require": { - "php-stubs/wordpress-stubs": "^5.4 || ^6.0" - }, - "require-dev": { - "php": "~7.3 || ~8.0", - "php-stubs/generator": "^0.8.0", - "phpstan/phpstan": "^1.8" - }, - "suggest": { - "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan" - }, - "type": "library", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "WPGraphQL function and class declaration stubs for static analysis.", - "homepage": "https://github.com/axewp/wp-graphql-stubs", - "keywords": [ - "PHPStan", - "graphql", - "static analysis", - "wordpress", - "wp-graphql", - "wpgraphql" - ], - "support": { - "issues": "https://github.com/AxeWP/wp-graphql-stubs/issues", - "source": "https://github.com/AxeWP/wp-graphql-stubs/tree/v1.14.3" - }, - "funding": [ - { - "url": "https://github.com/AxeWp", - "type": "github" - } - ], - "time": "2023-04-28T12:31:19+00:00" - }, { "name": "behat/gherkin", "version": "v4.9.0", @@ -3520,6 +3468,50 @@ }, "time": "2022-09-12T20:47:09+00:00" }, + { + "name": "php-stubs/gravity-forms-stubs", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/php-stubs/gravity-forms-stubs.git", + "reference": "6229910064b9881d218cdc407eba5947147377ee" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-stubs/gravity-forms-stubs/zipball/6229910064b9881d218cdc407eba5947147377ee", + "reference": "6229910064b9881d218cdc407eba5947147377ee", + "shasum": "" + }, + "require": { + "php-stubs/wordpress-stubs": "^5.3 || ^6.0" + }, + "require-dev": { + "php": "~7.1 || ~8.0", + "php-stubs/generator": "^0.8.0" + }, + "suggest": { + "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan" + }, + "default-branch": true, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Gravity Forms function and class declaration stubs for static analysis.", + "homepage": "https://github.com/php-stubs/gravity-forms-stubs", + "keywords": [ + "PHPStan", + "gravity-forms", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/php-stubs/gravity-forms-stubs/issues", + "source": "https://github.com/php-stubs/gravity-forms-stubs/tree/master" + }, + "time": "2023-07-21T20:30:52+00:00" + }, { "name": "php-stubs/wordpress-stubs", "version": "v6.2.1", @@ -10565,7 +10557,8 @@ "aliases": [], "minimum-stability": "stable", "stability-flags": { - "axepress/wp-graphql-cs": 10 + "axepress/wp-graphql-cs": 10, + "php-stubs/gravity-forms-stubs": 20 }, "prefer-stable": false, "prefer-lowest": false, diff --git a/phpstan.neon.dist b/phpstan.neon.dist index e368f7ac..5b5205a2 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,26 +1,24 @@ parameters: - level: 8 - inferPrivatePropertyTypeFromConstructor: true - checkMissingIterableValueType: false - featureToggles: - disableRuntimeReflectionProvider: true - stubFiles: - # Simulate added properties - - phpstan/class-app-context.stub - - phpstan/class-gf-quiz.stub - bootstrapFiles: - - phpstan/constants.php - - wp-graphql-gravity-forms.php - paths: - - wp-graphql-gravity-forms.php - - src/ - scanDirectories: - - ../wp-graphql/ - - ../gravityforms/ - - ../gravityformssignature/ - - ../gravityformschainedselects/ - - ../gravityformsquiz/ - - ../wp-gatsby/ - - ../wp-jamstack-deployments/ - ignoreErrors: - - '#^Function gf_apply_filters(_ref_array)? invoked with ([1-9]|1[0-2]) parameters, 2 required\.$#' + paths: + - wp-graphql-gravity-forms.php + - src/ + bootstrapFiles: + - phpstan/vendor/autoload.php + - phpstan/constants.php + - vendor/php-stubs/gravity-forms-stubs/gravity-forms-stubs.php + scanDirectories: + #- ../gravityformssignature/ + #- ../gravityformschainedselects/ + #- ../gravityformsquiz/ + - phpstan/vendor/crgeary/wp-jamstack-deployments/src/ + - phpstan/vendor/gatsbyjs/wp-gatsby/lib/ + stubFiles: + - phpstan/class-app-context.stub + - phpstan/class-gf-quiz.stub + level: 8 + inferPrivatePropertyTypeFromConstructor: true + checkMissingIterableValueType: false + featureToggles: + disableRuntimeReflectionProvider: true + ignoreErrors: + - '#^Function gf_apply_filters(_ref_array)? invoked with ([1-9]|1[0-2]) parameters, 2 required\.$#' diff --git a/phpstan/.gitignore b/phpstan/.gitignore new file mode 100644 index 00000000..c8153b57 --- /dev/null +++ b/phpstan/.gitignore @@ -0,0 +1,2 @@ +/composer.lock +/vendor/ diff --git a/phpstan/class-app-context.stub b/phpstan/class-app-context.stub index 022ae0aa..2f98da95 100644 --- a/phpstan/class-app-context.stub +++ b/phpstan/class-app-context.stub @@ -1,6 +1,7 @@ $value The field value. * @param GF_Field|null $field The field object being processed or null. - * * @return string|array */ - public function maybe_format_field_values( $value, $field ) {} + public function maybe_format_field_values( $value, $field ); } diff --git a/phpstan/composer.json b/phpstan/composer.json new file mode 100644 index 00000000..6235a14d --- /dev/null +++ b/phpstan/composer.json @@ -0,0 +1,13 @@ +{ + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/crgeary/wp-jamstack-deployments.git" + } + ], + "require-dev": { + "crgeary/wp-jamstack-deployments": "dev-master", + "gatsbyjs/wp-gatsby": "^2.3", + "wp-graphql/wp-graphql": "^1.14" + } +} diff --git a/phpstan/constants.php b/phpstan/constants.php index 8c7862e2..816d99db 100644 --- a/phpstan/constants.php +++ b/phpstan/constants.php @@ -1,9 +1,9 @@ findFile($class)) { - (self::$includeFile)($file); + $includeFile = self::$includeFile; + $includeFile($file); return true; } @@ -560,7 +561,10 @@ private function findFileWithExtension($class, $ext) return false; } - private static function initializeIncludeClosure(): void + /** + * @return void + */ + private static function initializeIncludeClosure() { if (self::$includeFile !== null) { return; @@ -574,8 +578,8 @@ private static function initializeIncludeClosure(): void * @param string $file * @return void */ - self::$includeFile = static function($file) { + self::$includeFile = \Closure::bind(static function($file) { include $file; - }; + }, null, null); } } diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php index c6b54af7..51e734a7 100644 --- a/vendor/composer/InstalledVersions.php +++ b/vendor/composer/InstalledVersions.php @@ -98,7 +98,7 @@ 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 $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; } } @@ -119,7 +119,7 @@ public static function isInstalled($packageName, $includeDevRequirements = true) */ public static function satisfies(VersionParser $parser, $packageName, $constraint) { - $constraint = $parser->parseConstraints($constraint); + $constraint = $parser->parseConstraints((string) $constraint); $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); return $provided->matches($constraint); @@ -328,7 +328,9 @@ private static function getInstalled() 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'; + /** @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]; } @@ -340,12 +342,17 @@ private static function getInstalled() // 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'; + /** @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(); } } - $installed[] = self::$installed; + + if (self::$installed !== array()) { + $installed[] = self::$installed; + } return $installed; } diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 200d8cd4..c41254d8 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -34,15 +34,15 @@ public static function getLoader() $loader->register(true); $filesToLoad = \Composer\Autoload\ComposerStaticInitf35655797d6bdd77951f2274b8dc4a3f::$files; - $requireFile = static function ($fileIdentifier, $file) { + $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; require $file; } - }; + }, null, null); foreach ($filesToLoad as $fileIdentifier => $file) { - ($requireFile)($fileIdentifier, $file); + $requireFile($fileIdentifier, $file); } return $loader; diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index b793cb77..a196db74 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'harness-software/wp-graphql-gravity-forms', 'pretty_version' => 'dev-develop', 'version' => 'dev-develop', - 'reference' => 'aabf28139ef116405967dcd5eb4542929781aeda', + 'reference' => 'ddb40fd6731e54865397f76b3335a34ec7162321', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -13,7 +13,7 @@ 'harness-software/wp-graphql-gravity-forms' => array( 'pretty_version' => 'dev-develop', 'version' => 'dev-develop', - 'reference' => 'aabf28139ef116405967dcd5eb4542929781aeda', + 'reference' => 'ddb40fd6731e54865397f76b3335a34ec7162321', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(),