Skip to content

Commit 3244faa

Browse files
CS fixes
1 parent 94d18e5 commit 3244faa

File tree

10 files changed

+22
-20
lines changed

10 files changed

+22
-20
lines changed

Extractor/PhpDocExtractor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class PhpDocExtractor implements PropertyDescriptionExtractorInterface, Property
6060
public function __construct(?DocBlockFactoryInterface $docBlockFactory = null, ?array $mutatorPrefixes = null, ?array $accessorPrefixes = null, ?array $arrayMutatorPrefixes = null)
6161
{
6262
if (!class_exists(DocBlockFactory::class)) {
63-
throw new \LogicException(sprintf('Unable to use the "%s" class as the "phpdocumentor/reflection-docblock" package is not installed. Try running composer require "phpdocumentor/reflection-docblock".', __CLASS__));
63+
throw new \LogicException(\sprintf('Unable to use the "%s" class as the "phpdocumentor/reflection-docblock" package is not installed. Try running composer require "phpdocumentor/reflection-docblock".', __CLASS__));
6464
}
6565

6666
$this->docBlockFactory = $docBlockFactory ?: DocBlockFactory::createInstance();
@@ -221,7 +221,7 @@ private function filterDocBlockParams(DocBlock $docBlock, string $allowedParam):
221221
*/
222222
private function getDocBlock(string $class, string $property): array
223223
{
224-
$propertyHash = sprintf('%s::%s', $class, $property);
224+
$propertyHash = \sprintf('%s::%s', $class, $property);
225225

226226
if (isset($this->docBlocks[$propertyHash])) {
227227
return $this->docBlocks[$propertyHash];

Extractor/PhpStanExtractor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ final class PhpStanExtractor implements PropertyTypeExtractorInterface, Construc
5757
public function __construct(?array $mutatorPrefixes = null, ?array $accessorPrefixes = null, ?array $arrayMutatorPrefixes = null)
5858
{
5959
if (!class_exists(ContextFactory::class)) {
60-
throw new \LogicException(sprintf('Unable to use the "%s" class as the "phpdocumentor/type-resolver" package is not installed. Try running composer require "phpdocumentor/type-resolver".', __CLASS__));
60+
throw new \LogicException(\sprintf('Unable to use the "%s" class as the "phpdocumentor/type-resolver" package is not installed. Try running composer require "phpdocumentor/type-resolver".', __CLASS__));
6161
}
6262

6363
if (!class_exists(PhpDocParser::class)) {
64-
throw new \LogicException(sprintf('Unable to use the "%s" class as the "phpstan/phpdoc-parser" package is not installed. Try running composer require "phpstan/phpdoc-parser".', __CLASS__));
64+
throw new \LogicException(\sprintf('Unable to use the "%s" class as the "phpstan/phpdoc-parser" package is not installed. Try running composer require "phpstan/phpdoc-parser".', __CLASS__));
6565
}
6666

6767
$this->phpStanTypeHelper = new PhpStanTypeHelper();

Extractor/ReflectionExtractor.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ public function getWriteInfo(string $class, string $property, array $context = [
366366
return new PropertyWriteInfo(PropertyWriteInfo::TYPE_PROPERTY, $property, $this->getWriteVisiblityForProperty($reflProperty), $reflProperty->isStatic());
367367
}
368368

369-
$errors[] = [sprintf('The property "%s" in class "%s" is a promoted readonly property.', $property, $reflClass->getName())];
369+
$errors[] = [\sprintf('The property "%s" in class "%s" is a promoted readonly property.', $property, $reflClass->getName())];
370370
$allowMagicSet = $allowMagicCall = false;
371371
}
372372

@@ -389,7 +389,7 @@ public function getWriteInfo(string $class, string $property, array $context = [
389389
}
390390

391391
if (!$allowAdderRemover && null !== $adderAccessName && null !== $removerAccessName) {
392-
$errors[] = [sprintf(
392+
$errors[] = [\sprintf(
393393
'The property "%s" in class "%s" can be defined with the methods "%s()" but '.
394394
'the new value must be an array or an instance of \Traversable',
395395
$property,
@@ -589,7 +589,7 @@ private function isAllowedProperty(string $class, string $property, bool $writeA
589589
return (bool) ($this->propertyReflectionFlags & \ReflectionProperty::IS_PRIVATE);
590590
}
591591

592-
if (\PHP_VERSION_ID >= 80400 &&$reflectionProperty->isVirtual() && !$reflectionProperty->hasHook(\PropertyHookType::Set)) {
592+
if (\PHP_VERSION_ID >= 80400 && $reflectionProperty->isVirtual() && !$reflectionProperty->hasHook(\PropertyHookType::Set)) {
593593
return false;
594594
}
595595
}
@@ -721,9 +721,9 @@ private function findAdderAndRemover(\ReflectionClass $reflClass, array $singula
721721
}
722722

723723
if ($addMethodFound && !$removeMethodFound) {
724-
$errors[] = [sprintf('The add method "%s" in class "%s" was found, but the corresponding remove method "%s" was not found', $addMethod, $reflClass->getName(), $removeMethod)];
724+
$errors[] = [\sprintf('The add method "%s" in class "%s" was found, but the corresponding remove method "%s" was not found', $addMethod, $reflClass->getName(), $removeMethod)];
725725
} elseif (!$addMethodFound && $removeMethodFound) {
726-
$errors[] = [sprintf('The remove method "%s" in class "%s" was found, but the corresponding add method "%s" was not found', $removeMethod, $reflClass->getName(), $addMethod)];
726+
$errors[] = [\sprintf('The remove method "%s" in class "%s" was found, but the corresponding add method "%s" was not found', $removeMethod, $reflClass->getName(), $addMethod)];
727727
}
728728
}
729729

@@ -741,9 +741,9 @@ private function isMethodAccessible(\ReflectionClass $class, string $methodName,
741741
$method = $class->getMethod($methodName);
742742

743743
if (\ReflectionMethod::IS_PUBLIC === $this->methodReflectionFlags && !$method->isPublic()) {
744-
$errors[] = sprintf('The method "%s" in class "%s" was found but does not have public access.', $methodName, $class->getName());
744+
$errors[] = \sprintf('The method "%s" in class "%s" was found but does not have public access.', $methodName, $class->getName());
745745
} elseif ($method->getNumberOfRequiredParameters() > $parameters || $method->getNumberOfParameters() < $parameters) {
746-
$errors[] = sprintf('The method "%s" in class "%s" requires %d arguments, but should accept only %d.', $methodName, $class->getName(), $method->getNumberOfRequiredParameters(), $parameters);
746+
$errors[] = \sprintf('The method "%s" in class "%s" requires %d arguments, but should accept only %d.', $methodName, $class->getName(), $method->getNumberOfRequiredParameters(), $parameters);
747747
} else {
748748
return [true, $errors];
749749
}
@@ -843,7 +843,7 @@ private function getWriteVisiblityForProperty(\ReflectionProperty $reflectionPro
843843

844844
if ($reflectionProperty->isProtectedSet()) {
845845
return PropertyWriteInfo::VISIBILITY_PROTECTED;
846-
}
846+
}
847847
}
848848

849849
if ($reflectionProperty->isPrivate()) {

PhpStan/NameScope.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ public function resolveStringName(string $name): string
4848
}
4949
array_shift($nameParts);
5050

51-
return sprintf('%s\\%s', $this->uses[$firstNamePart], implode('\\', $nameParts));
51+
return \sprintf('%s\\%s', $this->uses[$firstNamePart], implode('\\', $nameParts));
5252
}
5353

5454
if (null !== $this->namespace) {
55-
return sprintf('%s\\%s', $this->namespace, $name);
55+
return \sprintf('%s\\%s', $this->namespace, $name);
5656
}
5757

5858
return $name;

PhpStan/NameScopeFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private function extractFromFullClassName(\ReflectionClass $reflection): array
5656

5757
if (\is_string($fileName) && is_file($fileName)) {
5858
if (false === $contents = file_get_contents($fileName)) {
59-
throw new \RuntimeException(sprintf('Unable to read file "%s".', $fileName));
59+
throw new \RuntimeException(\sprintf('Unable to read file "%s".', $fileName));
6060
}
6161

6262
$factory = new ContextFactory();

Tests/Extractor/ReflectionExtractorTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,7 @@ public function testVirtualProperties()
743743

744744
/**
745745
* @dataProvider provideAsymmetricVisibilityMutator
746+
*
746747
* @requires PHP 8.4
747748
*/
748749
public function testAsymmetricVisibilityMutator(string $property, string $readVisibility, string $writeVisibility)
@@ -768,6 +769,7 @@ public static function provideAsymmetricVisibilityMutator(): iterable
768769

769770
/**
770771
* @dataProvider provideVirtualPropertiesMutator
772+
*
771773
* @requires PHP 8.4
772774
*/
773775
public function testVirtualPropertiesMutator(string $property, string $readVisibility, string $writeVisibility)

Tests/Extractor/SerializerExtractorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ public function testGetPropertiesWithAnyGroup()
5858

5959
public function testGetPropertiesWithNonExistentClassReturnsNull()
6060
{
61-
$this->assertSame(null, $this->extractor->getProperties('NonExistent'));
61+
$this->assertNull($this->extractor->getProperties('NonExistent'));
6262
}
6363
}

Type.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class Type
7979
public function __construct(string $builtinType, bool $nullable = false, ?string $class = null, bool $collection = false, array|self|null $collectionKeyType = null, array|self|null $collectionValueType = null)
8080
{
8181
if (!\in_array($builtinType, self::$builtinTypes)) {
82-
throw new \InvalidArgumentException(sprintf('"%s" is not a valid PHP type.', $builtinType));
82+
throw new \InvalidArgumentException(\sprintf('"%s" is not a valid PHP type.', $builtinType));
8383
}
8484

8585
$this->builtinType = $builtinType;
@@ -99,7 +99,7 @@ private function validateCollectionArgument(array|self|null $collectionArgument,
9999
if (\is_array($collectionArgument)) {
100100
foreach ($collectionArgument as $type) {
101101
if (!$type instanceof self) {
102-
throw new \TypeError(sprintf('"%s()": Argument #%d (%s) must be of type "%s[]", "%s" or "null", array value "%s" given.', __METHOD__, $argumentIndex, $argumentName, self::class, self::class, get_debug_type($collectionArgument)));
102+
throw new \TypeError(\sprintf('"%s()": Argument #%d (%s) must be of type "%s[]", "%s" or "null", array value "%s" given.', __METHOD__, $argumentIndex, $argumentName, self::class, self::class, get_debug_type($collectionArgument)));
103103
}
104104
}
105105

Util/PhpDocTypeHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private function createType(DocType $type, bool $nullable): ?Type
118118

119119
[$phpType, $class] = $this->getPhpTypeAndClass((string) $fqsen);
120120

121-
$collection = \is_a($class, \Traversable::class, true) || \is_a($class, \ArrayAccess::class, true);
121+
$collection = is_a($class, \Traversable::class, true) || is_a($class, \ArrayAccess::class, true);
122122

123123
// it's safer to fall back to other extractors if the generic type is too abstract
124124
if (!$collection && !class_exists($class)) {

Util/PhpStanTypeHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private function extractTypes(TypeNode $node, NameScope $nameScope): array
125125
return [$mainType];
126126
}
127127

128-
$collection = $mainType->isCollection() || \is_a($mainType->getClassName(), \Traversable::class, true) || \is_a($mainType->getClassName(), \ArrayAccess::class, true);
128+
$collection = $mainType->isCollection() || is_a($mainType->getClassName(), \Traversable::class, true) || is_a($mainType->getClassName(), \ArrayAccess::class, true);
129129

130130
// it's safer to fall back to other extractors if the generic type is too abstract
131131
if (!$collection && !class_exists($mainType->getClassName()) && !interface_exists($mainType->getClassName(), false)) {

0 commit comments

Comments
 (0)