Skip to content

Commit

Permalink
fix cs and staticanalysis
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer committed Aug 15, 2024
1 parent 22d0bde commit a6ddff4
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 26 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
25 changes: 7 additions & 18 deletions src/Fixers/ClientUpgradeFixer/ClientUpgradeFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -34,19 +32,10 @@ public function isCandidate(Tokens $tokens): bool
return true;
}

/**
* @param array<string, mixed> $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'))
Expand Down Expand Up @@ -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));
Expand Down
1 change: 0 additions & 1 deletion src/Fixers/ClientUpgradeFixer/RequestClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Google\Cloud\Fixers\ClientUpgradeFixer;

use PhpCsFixer\Tokenizer\Token;
use PhpCsFixer\Tokenizer\Tokens;
use ReflectionClass;

class RequestClass
Expand Down
2 changes: 0 additions & 2 deletions src/Fixers/ClientUpgradeFixer/RequestVariableCounter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Google\Cloud\Fixers\ClientUpgradeFixer;

use PhpCsFixer\Tokenizer\Tokens;

class RequestVariableCounter
{
private array $varCounts = [];
Expand Down
1 change: 0 additions & 1 deletion src/Fixers/ClientUpgradeFixer/RpcMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use PhpCsFixer\Tokenizer\Token;
use PhpCsFixer\Tokenizer\Tokens;
use ReflectionMethod;
use ReflectionParameter;

class RpcMethod
{
Expand Down
1 change: 1 addition & 0 deletions src/TestUtils/GcloudWrapper/AppEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,5 @@ public function getBaseUrl($service = 'default')
}
}

// @phpstan-ignore-next-line
class_alias(AppEngine::class, \Google\Cloud\TestUtils\GcloudWrapper::class);
2 changes: 1 addition & 1 deletion src/TestUtils/GcloudWrapper/CloudFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static function fromArray(array $arr)
$args[] = $arr[$key] ?? '';
}

return new static(...$args);
return new self(...$args);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Utils/ContainerExec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/Flex/FlexExecCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions src/Utils/WordPress/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a6ddff4

Please sign in to comment.