Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try new stubs #374

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
101 changes: 47 additions & 54 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 23 additions & 25 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -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\.$#'
2 changes: 2 additions & 0 deletions phpstan/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/composer.lock
/vendor/
1 change: 1 addition & 0 deletions phpstan/class-app-context.stub
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

namespace WPGraphQL;

/**
* @property mixed $gfForm
* @property mixed $gfEntry
Expand Down
13 changes: 6 additions & 7 deletions phpstan/class-gf-quiz.stub
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<?php

class GFAddon{}
class GF_Field{}
class GFQuiz extends GFAddon{
class GFAddon {}

class GF_Field {}

class GFQuiz extends GFAddon
{
/**
* If the field is a Poll type radio, select or checkbox then replace the choice value with the choice text.
*
* @param string|array<mixed> $value The field value.
* @param GF_Field|null $field The field object being processed or null.
*
* @return string|array<mixed>
*/
public function maybe_format_field_values( $value, $field ) {}
public function maybe_format_field_values( $value, $field );
}
13 changes: 13 additions & 0 deletions phpstan/composer.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
4 changes: 2 additions & 2 deletions phpstan/constants.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
/**
* Constants defined in this file are to help phpstan analyze code where constants outside the plugin (WordPress core constants, etc) are being used.
* Define constants PHPStan is not able to discover.
*/

define( 'WPGRAPHQL_GF_AUTOLOAD', true );
define( 'CRGEARY_JAMSTACK_DEPLOYMENTS_OPTIONS_KEY', 'wp-jamstack-deployments' );
define( 'WPGRAPHQL_GF_PLUGIN_FILE', 'wp-graphql-gravity-forms.php' );
define( 'WPGRAPHQL_GF_VERSION', '0.12.2' );
define( 'WPGRAPHQL_GF_VERSION', '0.0.0' );
2 changes: 1 addition & 1 deletion src/Extensions/WPGatsby/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Settings {
/**
* An instance of the Settings API.
*
* @var ?\WPGraphQL_Settings_API
* @var \WPGraphQL_Settings_API|null
*/
private static $settings_api;

Expand Down
12 changes: 8 additions & 4 deletions vendor/composer/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,8 @@ public function unregister()
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
(self::$includeFile)($file);
$includeFile = self::$includeFile;
$includeFile($file);

return true;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
}
17 changes: 12 additions & 5 deletions vendor/composer/InstalledVersions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand All @@ -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);
Expand Down Expand Up @@ -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<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $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];
}
Expand All @@ -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<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $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;
}
Expand Down
6 changes: 3 additions & 3 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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(),
Expand Down