Skip to content

Commit

Permalink
Bump php-cs-fixer to version 3.60 (#1743)
Browse files Browse the repository at this point in the history
  • Loading branch information
jderusse authored Jul 30, 2024
1 parent 3bf9996 commit 44581d5
Show file tree
Hide file tree
Showing 600 changed files with 1,599 additions and 1,428 deletions.
3 changes: 2 additions & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
;

return (new PhpCsFixer\Config())
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
->setCacheFile(__DIR__.'/.cache/php-cs-fixer/.php-cs-fixer.cache')
->setRiskyAllowed(true)
->setRules([
Expand All @@ -28,7 +29,7 @@
'no_alias_functions' => true,
'no_extra_blank_lines' => ['tokens' => [
'attribute',
'break',
'break',
'case',
'continue',
'curly_brace_block',
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"symfony/service-contracts": "^1.0 || ^2.0 || ^3.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "~3.54.0",
"friendsofphp/php-cs-fixer": "~3.60.0",
"illuminate/cache": "^6.18.13 || ^7.10 || ^8.0 || ^9.0 || ^10.0 || ^11.0",
"illuminate/queue": "^6.18.11 || ^7.10 || ^8.0 || ^9.0 || ^10.0 || ^11.0",
"illuminate/support": "^6.18.13 || ^7.10 || ^8.0 || ^9.0 || ^10.0 || ^11.0",
Expand Down
4 changes: 2 additions & 2 deletions psalm.baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,12 @@
</file>
<file src="src/Service/StepFunctions/src/Result/StartExecutionOutput.php">
<PossiblyFalsePropertyAssignmentValue>
<code><![CDATA[$d = \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', $data['startDate']))]]></code>
<code><![CDATA[$d = \DateTimeImmutable::createFromFormat('U.u', \sprintf('%.6F', $data['startDate']))]]></code>
</PossiblyFalsePropertyAssignmentValue>
</file>
<file src="src/Service/StepFunctions/src/Result/StopExecutionOutput.php">
<PossiblyFalsePropertyAssignmentValue>
<code><![CDATA[$d = \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', $data['stopDate']))]]></code>
<code><![CDATA[$d = \DateTimeImmutable::createFromFormat('U.u', \sprintf('%.6F', $data['stopDate']))]]></code>
</PossiblyFalsePropertyAssignmentValue>
</file>
<file src="src/Service/Sqs/src/Result/GetQueueAttributesResult.php">
Expand Down
2 changes: 1 addition & 1 deletion src/CodeGenerator/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"ext-SimpleXML": "*",
"ext-dom": "*",
"ext-json": "*",
"friendsofphp/php-cs-fixer": "~3.52.0",
"friendsofphp/php-cs-fixer": "~3.60.0",
"nette/php-generator": "^3.6 || ^4.1",
"nette/utils": "^3.0 || ^4.0",
"nikic/php-parser": "^4.0",
Expand Down
22 changes: 11 additions & 11 deletions src/CodeGenerator/src/Command/GenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private function extractEndpointsForService(array $endpoints, string $prefix, st

if (empty($config)) {
if (!isset($serviceEndpoints['_default'][$partition['partition']])) {
$endpoint = strtr(sprintf('http%s://%s', \in_array('https', $protocols) ? 's' : '', $hostname), [
$endpoint = strtr(\sprintf('http%s://%s', \in_array('https', $protocols) ? 's' : '', $hostname), [
'{service}' => $prefix,
'{region}' => '%region%',
'{dnsSuffix}' => $suffix,
Expand All @@ -232,7 +232,7 @@ private function extractEndpointsForService(array $endpoints, string $prefix, st
$serviceEndpoints['_default'][$partition['partition']]['regions'][] = $region;
}
} else {
$endpoint = strtr(sprintf('http%s://%s', \in_array('https', $protocols) ? 's' : '', $hostname), [
$endpoint = strtr(\sprintf('http%s://%s', \in_array('https', $protocols) ? 's' : '', $hostname), [
'{service}' => $prefix,
'{region}' => $region,
'{dnsSuffix}' => $suffix,
Expand Down Expand Up @@ -303,7 +303,7 @@ private function generateService(SymfonyStyle $io, InputInterface $input, array

$managedOperations = array_unique(array_merge($manifest['services'][$serviceName]['methods'], $operationNames));
$definition = new ServiceDefinition($serviceName, $endpoints, $definitionArray, $documentationArray, $paginationArray, $waiterArray, $exampleArray, $manifest['services'][$serviceName]['hooks'] ?? [], $manifest['services'][$serviceName]['api-reference'] ?? null);
$serviceGenerator = $this->generator->service($namespace = $manifest['services'][$serviceName]['namespace'] ?? sprintf('AsyncAws\\%s', $serviceName), $managedOperations);
$serviceGenerator = $this->generator->service($namespace = $manifest['services'][$serviceName]['namespace'] ?? \sprintf('AsyncAws\\%s', $serviceName), $managedOperations);

$clientClass = $serviceGenerator->client()->generate($definition, $customErrorFactory);

Expand All @@ -313,7 +313,7 @@ private function generateService(SymfonyStyle $io, InputInterface $input, array
} elseif (null !== $waiter = $definition->getWaiter($operationName)) {
$serviceGenerator->waiter()->generate($waiter);
} else {
$io->error(sprintf('Could not find service or waiter named "%s".', $operationName));
$io->error(\sprintf('Could not find service or waiter named "%s".', $operationName));

return 1;
}
Expand Down Expand Up @@ -351,7 +351,7 @@ private function getServiceNames(?string $inputServiceName, bool $returnAll, Sym
{
if ($inputServiceName) {
if (!isset($manifest[$inputServiceName])) {
$io->error(sprintf('Could not find service named "%s".', $inputServiceName));
$io->error(\sprintf('Could not find service named "%s".', $inputServiceName));

return 1;
}
Expand Down Expand Up @@ -384,19 +384,19 @@ private function getOperationNames(?string $inputOperationName, bool $returnAll,
{
if ($inputOperationName) {
if ($returnAll) {
$io->error(sprintf('Cannot use "--all" together with an operation. You passed "%s" as operation.', $inputOperationName));
$io->error(\sprintf('Cannot use "--all" together with an operation. You passed "%s" as operation.', $inputOperationName));

return 1;
}

if (!isset($definition['operations'][$inputOperationName]) && !isset($waiter['waiters'][$inputOperationName])) {
$io->error(sprintf('Could not find operation or waiter named "%s".', $inputOperationName));
$io->error(\sprintf('Could not find operation or waiter named "%s".', $inputOperationName));

return 1;
}

if (!\in_array($inputOperationName, $manifest['methods'])) {
$io->warning(sprintf('Operation named "%s" has never been generated.', $inputOperationName));
$io->warning(\sprintf('Operation named "%s" has never been generated.', $inputOperationName));
if (!$io->confirm('Do you want adding it?', true)) {
return 1;
}
Expand Down Expand Up @@ -434,10 +434,10 @@ private function fixCs(ClassName $clientClass, SymfonyStyle $io): void
$testPath = substr($srcPath, 0, strrpos($srcPath, '/src')) . '/tests';

if (!is_dir($srcPath)) {
throw new \InvalidArgumentException(sprintf('The src dir "%s" does not exists', $srcPath));
throw new \InvalidArgumentException(\sprintf('The src dir "%s" does not exists', $srcPath));
}
if (!is_dir($testPath)) {
throw new \InvalidArgumentException(sprintf('The test dir "%s" does not exists', $testPath));
throw new \InvalidArgumentException(\sprintf('The test dir "%s" does not exists', $testPath));
}

// assert this
Expand Down Expand Up @@ -480,7 +480,7 @@ private function fixCs(ClassName $clientClass, SymfonyStyle $io): void
);
$runner->fix();
foreach ($e->getInvalidErrors() as $error) {
$io->error(sprintf('The generated file "%s" is invalid: %s', $error->getFilePath(), $error->getSource() ? $error->getSource()->getMessage() : 'unknown'));
$io->error(\sprintf('The generated file "%s" is invalid: %s', $error->getFilePath(), $error->getSource() ? $error->getSource()->getMessage() : 'unknown'));
}
if (empty($e->getInvalidErrors())) {
$runner->fix();
Expand Down
2 changes: 1 addition & 1 deletion src/CodeGenerator/src/Definition/ErrorWaiterAcceptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function getError(): ExceptionShape
$shape = ($this->shapeLocator)($this->data['expected']);

if (!$shape instanceof ExceptionShape) {
throw new \InvalidArgumentException(sprintf('The error "%s" of the waiter acceptor should have an Exception shape.', $this->data['expected']));
throw new \InvalidArgumentException(\sprintf('The error "%s" of the waiter acceptor should have an Exception shape.', $this->data['expected']));
}

return $shape;
Expand Down
10 changes: 5 additions & 5 deletions src/CodeGenerator/src/Definition/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function getOutput(): ?StructureShape
$shape = ($this->shapeLocator)($this->data['output']['shape'], null, ['resultWrapper' => $this->data['output']['resultWrapper'] ?? null]);

if (!$shape instanceof StructureShape) {
throw new \InvalidArgumentException(sprintf('The operation "%s" should have an Structure output.', $this->getName()));
throw new \InvalidArgumentException(\sprintf('The operation "%s" should have an Structure output.', $this->getName()));
}

return $shape;
Expand All @@ -124,7 +124,7 @@ public function getErrors(): array
}
$shape = ($this->shapeLocator)($error['shape']);
if (!$shape instanceof ExceptionShape) {
throw new \InvalidArgumentException(sprintf('The error "%s" of the operation "%s" should have an Exception shape.', $error['shape'], $this->getName()));
throw new \InvalidArgumentException(\sprintf('The error "%s" of the operation "%s" should have an Exception shape.', $error['shape'], $this->getName()));
}

$errors[$error['shape']] = $shape;
Expand All @@ -138,7 +138,7 @@ public function getInput(): StructureShape
$shape = $this->getInputShape();

if (!$shape instanceof StructureShape) {
throw new \InvalidArgumentException(sprintf('The operation "%s" should have an Structure Input.', $this->getName()));
throw new \InvalidArgumentException(\sprintf('The operation "%s" should have an Structure Input.', $this->getName()));
}

return $shape;
Expand Down Expand Up @@ -172,7 +172,7 @@ public function getHttpRequestUri(): ?string
public function getHttpMethod(): string
{
if (isset($this->data['input']['method'])) {
throw new \InvalidArgumentException(sprintf('The operation "%s" should have an HTTP Method.', $this->getName()));
throw new \InvalidArgumentException(\sprintf('The operation "%s" should have an HTTP Method.', $this->getName()));
}

return $this->data['http']['method'];
Expand Down Expand Up @@ -215,7 +215,7 @@ private function getInputShape(): Shape
}

return Shape::create(
sprintf('%sRequest', $this->getName()),
\sprintf('%sRequest', $this->getName()),
['type' => 'structure', 'required' => [], 'members' => []],
$this->shapeLocator,
function () {
Expand Down
4 changes: 2 additions & 2 deletions src/CodeGenerator/src/Definition/ServiceDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ private function getShape(string $name, ?Member $member, array $extra): Shape
return Shape::create($name, $this->definition['shapes'][$name] + ['_documentation_main' => $documentationMain, '_documentation_member' => $documentationMember] + $extra, $this->createClosureToFindShape(), $this->createClosureToService());
}

throw new \InvalidArgumentException(sprintf('The shape "%s" does not exist.', $name));
throw new \InvalidArgumentException(\sprintf('The shape "%s" does not exist.', $name));
}

/**
Expand Down Expand Up @@ -240,7 +240,7 @@ private function createClosureToFindOperation(): \Closure
$operation = $definition->getOperation($name);

if (null === $operation) {
throw new \InvalidArgumentException(sprintf('The operation "%s" is not defined.', $name));
throw new \InvalidArgumentException(\sprintf('The operation "%s" is not defined.', $name));
}

return $operation;
Expand Down
2 changes: 1 addition & 1 deletion src/CodeGenerator/src/Definition/StructureShape.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function getMembers(): array
public function getMember(string $name): StructureMember
{
if (!isset($this->data['members'][$name])) {
throw new \InvalidArgumentException(sprintf('The member "%s" does not exists.', $name));
throw new \InvalidArgumentException(\sprintf('The member "%s" does not exists.', $name));
}

return new StructureMember(
Expand Down
4 changes: 2 additions & 2 deletions src/CodeGenerator/src/File/ClassWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function write(ClassBuilder $classBuilder): void
$className = $className->getName();
$directory = $this->resolveDirectory($namespace);

$filename = sprintf('%s/%s.php', $directory, $className);
$filename = \sprintf('%s/%s.php', $directory, $className);

$this->fileDumper->dump($filename, $content);
}
Expand All @@ -58,7 +58,7 @@ private function resolveDirectory(string $namespace): string
$directory = $this->directoryResolver->resolveDirectory($namespace);
if (!is_dir($directory)) {
if (false === mkdir($directory, 0777, true)) {
throw new \RuntimeException(sprintf('Could not create directory "%s"', $directory));
throw new \RuntimeException(\sprintf('Could not create directory "%s"', $directory));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/CodeGenerator/src/File/FileDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private function verifyFileSyntax(string $filename): void
return;
}

throw new RuntimeException(sprintf('Could not generate file "%s" due invalid syntax.' . "\n\n%s", $filename, $process->getErrorOutput()));
throw new RuntimeException(\sprintf('Could not generate file "%s" due invalid syntax.' . "\n\n%s", $filename, $process->getErrorOutput()));
}

private function moveFile(string $from, string $to): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ public function resolveDirectory(string $namespace): string
array_unshift($parts, 'Service');
}

return sprintf('%s/%s', $this->srcDirectory, implode('/', $parts));
return \sprintf('%s/%s', $this->srcDirectory, implode('/', $parts));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ public function resolveDirectory(string $namespace): string
array_unshift($parts, 'src');
}

return sprintf('%s/%s', $this->rootDirectory, implode('/', $parts));
return \sprintf('%s/%s', $this->rootDirectory, implode('/', $parts));
}
}
6 changes: 3 additions & 3 deletions src/CodeGenerator/src/Generator/ClientGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function generate(ServiceDefinition $definition, ?string $customErrorFact
}
$classBuilder = $this->classRegistry->register($className->getFqdn(), true);

$supportedVersions = eval(sprintf('class A%s extends %s {
$supportedVersions = eval(\sprintf('class A%s extends %s {
public function __construct() {}
public function getVersion() {
return array_keys($this->getSignerFactories());
Expand Down Expand Up @@ -232,7 +232,7 @@ public function getVersion() {
$code = $regionConfig['code'];
$regions = $regionConfig['regions'];
foreach ($regions as $region) {
$body .= sprintf(" case %s:\n", var_export($region, true));
$body .= \sprintf(" case %s:\n", var_export($region, true));
}
$body .= $code;
}
Expand Down Expand Up @@ -277,7 +277,7 @@ public function getVersion() {

break;
default:
throw new \LogicException(sprintf('Parser for "%s" is not implemented yet', $definition->getProtocol()));
throw new \LogicException(\sprintf('Parser for "%s" is not implemented yet', $definition->getProtocol()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ private function generatePopulator(Operation $operation, StructureShape $shape,

break;
default:
throw new \RuntimeException(sprintf('Type %s is not yet implemented', $memberShape->getType()));
throw new \RuntimeException(\sprintf('Type %s is not yet implemented', $memberShape->getType()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ public function generateDocblock(StructureShape $shape, ClassName $shapeClassNam
}

if ($nullable) {
$body[] = sprintf(' %s?: %s,', $phpdocMemberName, 'null|' . $param);
$body[] = \sprintf(' %s?: %s,', $phpdocMemberName, 'null|' . $param);
} elseif ($allNullable) {
// For input objects, the constructor allows to omit all members to set them later. But when provided,
// they should respect the nullability of the member.
$body[] = sprintf(' %s?: %s,', $phpdocMemberName, $param);
$body[] = \sprintf(' %s?: %s,', $phpdocMemberName, $param);
} else {
$body[] = sprintf(' %s: %s,', $phpdocMemberName, $param);
$body[] = \sprintf(' %s: %s,', $phpdocMemberName, $param);
}
}
$body = array_merge($body, $extra);
Expand Down Expand Up @@ -199,7 +199,7 @@ private function getNativePhpType(string $parameterType): string
case 'timestamp':
return '\DateTimeImmutable';
default:
throw new \RuntimeException(sprintf('Type %s is not yet implemented', $parameterType));
throw new \RuntimeException(\sprintf('Type %s is not yet implemented', $parameterType));
}
}
}
2 changes: 1 addition & 1 deletion src/CodeGenerator/src/Generator/GeneratorHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static function normalizeName(string $propertyName): string
if (preg_match('/[A-Z]{2,}/', $propertyName)) {
$propertyName = strtr($propertyName, $ignored);
if (preg_match('/[A-Z]{2,}/', $propertyName)) {
throw new \RuntimeException(sprintf('No camel case property "%s" is not yet implemented', $originalPropertyName));
throw new \RuntimeException(\sprintf('No camel case property "%s" is not yet implemented', $originalPropertyName));
}
}

Expand Down
Loading

0 comments on commit 44581d5

Please sign in to comment.