diff --git a/composer.json b/composer.json index eefcb4d..5b494b5 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,7 @@ "paragonie/random_compat": ">=2", "phpunit/phpunit": "^9", "phpspec/prophecy-phpunit": "^2.0", - "friendsofphp/php-cs-fixer": "^3.21", + "friendsofphp/php-cs-fixer": "^3.62", "google/cloud-dlp": "^1.10", "google/cloud-storage": "^1.33", "google/cloud-secret-manager": "^1.12" diff --git a/src/Fixers/ClientUpgradeFixer/ClientUpgradeFixer.php b/src/Fixers/ClientUpgradeFixer/ClientUpgradeFixer.php index 7adf779..d86cf7d 100644 --- a/src/Fixers/ClientUpgradeFixer/ClientUpgradeFixer.php +++ b/src/Fixers/ClientUpgradeFixer/ClientUpgradeFixer.php @@ -3,23 +3,21 @@ namespace Google\Cloud\Fixers\ClientUpgradeFixer; use PhpCsFixer\AbstractFixer; -use PhpCsFixer\Fixer\FixerInterface; use PhpCsFixer\Fixer\Import\OrderedImportsFixer; use PhpCsFixer\FixerDefinition\FixerDefinitionInterface; -use PhpCsFixer\Tokenizer\Analyzer\NamespaceUsesAnalyzer; -use PhpCsFixer\Tokenizer\Analyzer\Analysis\NamespaceUseAnalysis; -use PhpCsFixer\Tokenizer\CT; +use PhpCsFixer\FixerDefinition\FixerDefinition; use PhpCsFixer\Tokenizer\Token; use PhpCsFixer\Tokenizer\Tokens; -use ReflectionClass; -use ReflectionMethod; use PhpCsFixer\Fixer\ConfigurableFixerInterface; +use PhpCsFixer\Fixer\ConfigurableFixerTrait; use PhpCsFixer\FixerConfiguration\FixerConfigurationResolver; use PhpCsFixer\FixerConfiguration\FixerOptionBuilder; use PhpCsFixer\FixerConfiguration\FixerConfigurationResolverInterface; class ClientUpgradeFixer extends AbstractFixer implements ConfigurableFixerInterface { + use ConfigurableFixerTrait; + /** * Check if the fixer is a candidate for given Tokens collection. * @@ -34,19 +32,10 @@ public function isCandidate(Tokens $tokens): bool return true; } - /** - * @param array $configuration - */ - public function configure(array $configuration): void - { - // no configuration assumes true - $this->configuration = $configuration; - } - /** * Defines the available configuration options of the fixer. */ - public function getConfigurationDefinition(): FixerConfigurationResolverInterface + protected function createConfigurationDefinition(): FixerConfigurationResolverInterface { return new FixerConfigurationResolver([ (new FixerOptionBuilder('clientVars', 'A map of client variables to their new class names')) @@ -199,10 +188,10 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void $importedClasses = array_map(fn ($useDeclaration) => $useDeclaration->getFullName(), $useDeclarations); $classesToImport = array_filter( $classesToImport, - fn($requestClass) => !isset($importedClasses[$requestClass->getName()]) + fn ($requestClass) => !isset($importedClasses[$requestClass->getName()]) ); $requestClassImportTokens = array_map( - fn($requestClass) => $requestClass->getImportTokens(), + fn ($requestClass) => $requestClass->getImportTokens(), array_values($classesToImport) ); $tokens->insertAt($importStart, array_merge(...$requestClassImportTokens)); diff --git a/src/Fixers/ClientUpgradeFixer/RequestClass.php b/src/Fixers/ClientUpgradeFixer/RequestClass.php index 78ca769..89c78a2 100644 --- a/src/Fixers/ClientUpgradeFixer/RequestClass.php +++ b/src/Fixers/ClientUpgradeFixer/RequestClass.php @@ -3,7 +3,6 @@ namespace Google\Cloud\Fixers\ClientUpgradeFixer; use PhpCsFixer\Tokenizer\Token; -use PhpCsFixer\Tokenizer\Tokens; use ReflectionClass; class RequestClass diff --git a/src/Fixers/ClientUpgradeFixer/RequestVariableCounter.php b/src/Fixers/ClientUpgradeFixer/RequestVariableCounter.php index 6f7dcc5..07fbf8e 100644 --- a/src/Fixers/ClientUpgradeFixer/RequestVariableCounter.php +++ b/src/Fixers/ClientUpgradeFixer/RequestVariableCounter.php @@ -2,8 +2,6 @@ namespace Google\Cloud\Fixers\ClientUpgradeFixer; -use PhpCsFixer\Tokenizer\Tokens; - class RequestVariableCounter { private array $varCounts = []; diff --git a/src/Fixers/ClientUpgradeFixer/RpcMethod.php b/src/Fixers/ClientUpgradeFixer/RpcMethod.php index 9f3b109..6dca677 100644 --- a/src/Fixers/ClientUpgradeFixer/RpcMethod.php +++ b/src/Fixers/ClientUpgradeFixer/RpcMethod.php @@ -6,7 +6,6 @@ use PhpCsFixer\Tokenizer\Token; use PhpCsFixer\Tokenizer\Tokens; use ReflectionMethod; -use ReflectionParameter; class RpcMethod { diff --git a/src/TestUtils/GcloudWrapper/AppEngine.php b/src/TestUtils/GcloudWrapper/AppEngine.php index 333ecde..1d3702f 100644 --- a/src/TestUtils/GcloudWrapper/AppEngine.php +++ b/src/TestUtils/GcloudWrapper/AppEngine.php @@ -237,4 +237,5 @@ public function getBaseUrl($service = 'default') } } +// @phpstan-ignore-next-line class_alias(AppEngine::class, \Google\Cloud\TestUtils\GcloudWrapper::class); diff --git a/src/TestUtils/GcloudWrapper/CloudFunction.php b/src/TestUtils/GcloudWrapper/CloudFunction.php index a6ca92e..07b05d3 100644 --- a/src/TestUtils/GcloudWrapper/CloudFunction.php +++ b/src/TestUtils/GcloudWrapper/CloudFunction.php @@ -108,7 +108,7 @@ public static function fromArray(array $arr) $args[] = $arr[$key] ?? ''; } - return new static(...$args); + return new self(...$args); } /** diff --git a/src/Utils/ContainerExec.php b/src/Utils/ContainerExec.php index 9e6b95c..72f3875 100644 --- a/src/Utils/ContainerExec.php +++ b/src/Utils/ContainerExec.php @@ -62,7 +62,8 @@ public function __construct( throw new \InvalidArgumentException("$workdir is not a directory"); } $this->gcloud = ($gcloud == null) ? new Gcloud() : $gcloud; - if (class_exists(\Twig_Loader_Filesystem::class)) { + if (class_exists(\Twig_Loader_Filesystem::class) + && class_exists(\Twig_Environment::class)) { $loader = new \Twig_Loader_Filesystem(__DIR__ . '/templates'); $this->twig = new \Twig_Environment($loader); } else { diff --git a/src/Utils/Flex/FlexExecCommand.php b/src/Utils/Flex/FlexExecCommand.php index d60a60e..ea354c4 100644 --- a/src/Utils/Flex/FlexExecCommand.php +++ b/src/Utils/Flex/FlexExecCommand.php @@ -244,7 +244,7 @@ protected function resolveImage( * @param string $service * @param InputInterface $input * @param OutputInterface $output - * @return string The version for the latest deployment for the given + * @return ?string The version for the latest deployment for the given * service. */ protected function detectLatestDeployedVersion( diff --git a/src/Utils/WordPress/Project.php b/src/Utils/WordPress/Project.php index 4c418e5..2004c21 100644 --- a/src/Utils/WordPress/Project.php +++ b/src/Utils/WordPress/Project.php @@ -41,6 +41,7 @@ class Project extends BaseProject private $input; private $output; private $helper; + private $filesystem; private $wordPressDir; public function __construct(InputInterface $input, OutputInterface $output, QuestionHelper $helper = null)