Skip to content

Commit

Permalink
minor #6303 PHP8 - Utilize "get_debug_type" (SpacePossum)
Browse files Browse the repository at this point in the history
This PR was merged into the master branch.

Discussion
----------

PHP8 - Utilize "get_debug_type"

Commits
-------

7e82a42 PHP8 - Utilize "get_debug_type"
  • Loading branch information
SpacePossum committed Feb 20, 2022
2 parents b780ffb + 7e82a42 commit ae5701a
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/Fixer/Alias/RandomApiMigrationFixer.php
Expand Up @@ -149,7 +149,7 @@ protected function createConfigurationDefinition(): FixerConfigurationResolverIn
throw new InvalidOptionsException(sprintf(
'Replacement for function "%s" must be a string, "%s" given.',
$functionName,
\is_object($replacement) ? \get_class($replacement) : \gettype($replacement)
get_debug_type($replacement)
));
}
}
Expand Down
Expand Up @@ -206,7 +206,7 @@ protected function createConfigurationDefinition(): FixerConfigurationResolverIn
if (!\is_string($constantName) || '' === trim($constantName) || trim($constantName) !== $constantName) {
throw new InvalidOptionsException(sprintf(
'Each element must be a non-empty, trimmed string, got "%s" instead.',
\is_object($constantName) ? \get_class($constantName) : \gettype($constantName)
get_debug_type($constantName)
));
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/FunctionNotation/NativeFunctionInvocationFixer.php
Expand Up @@ -223,7 +223,7 @@ protected function createConfigurationDefinition(): FixerConfigurationResolverIn
if (!\is_string($functionName) || '' === trim($functionName) || trim($functionName) !== $functionName) {
throw new InvalidOptionsException(sprintf(
'Each element must be a non-empty, trimmed string, got "%s" instead.',
\is_object($functionName) ? \get_class($functionName) : \gettype($functionName)
get_debug_type($functionName)
));
}
}
Expand All @@ -239,7 +239,7 @@ protected function createConfigurationDefinition(): FixerConfigurationResolverIn
if (!\is_string($functionName) || '' === trim($functionName) || trim($functionName) !== $functionName) {
throw new InvalidOptionsException(sprintf(
'Each element must be a non-empty, trimmed string, got "%s" instead.',
\is_object($functionName) ? \get_class($functionName) : \gettype($functionName)
get_debug_type($functionName)
));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Runner/FileFilterIterator.php
Expand Up @@ -61,7 +61,7 @@ public function accept(): bool
throw new \RuntimeException(
sprintf(
'Expected instance of "\SplFileInfo", got "%s".',
\is_object($file) ? \get_class($file) : \gettype($file)
get_debug_type($file)
)
);
}
Expand Down
10 changes: 3 additions & 7 deletions src/Tokenizer/Token.php
Expand Up @@ -55,14 +55,14 @@ public function __construct($token)
if (!\is_int($token[0])) {
throw new \InvalidArgumentException(sprintf(
'Id must be an int, got "%s".',
\is_object($token[0]) ? \get_class($token[0]) : \gettype($token[0])
get_debug_type($token[0])
));
}

if (!\is_string($token[1])) {
throw new \InvalidArgumentException(sprintf(
'Content must be a string, got "%s".',
\is_object($token[1]) ? \get_class($token[1]) : \gettype($token[1])
get_debug_type($token[1])
));
}

Expand All @@ -77,11 +77,7 @@ public function __construct($token)
$this->isArray = false;
$this->content = $token;
} else {
throw new \InvalidArgumentException(sprintf(
'Cannot recognize input value as valid Token prototype, got "%s".',
// @phpstan-ignore-next-line due to lack of strong typing of method parameter
\is_object($token) ? \get_class($token) : \gettype($token)
));
throw new \InvalidArgumentException(sprintf('Cannot recognize input value as valid Token prototype, got "%s".', get_debug_type($token)));
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/Alias/RandomApiMigrationFixerTest.php
Expand Up @@ -38,7 +38,7 @@ public function testConfigureCheckSearchFunction(): void
public function testConfigureCheckReplacementType(): void
{
$this->expectException(InvalidFixerConfigurationException::class);
$this->expectExceptionMessageMatches('#^\[random_api_migration\] Invalid configuration: Replacement for function "rand" must be a string, "NULL" given\.$#');
$this->expectExceptionMessageMatches('#^\[random_api_migration\] Invalid configuration: Replacement for function "rand" must be a string, "null" given\.$#');

$this->fixer->configure(['replacements' => ['rand' => null]]);
}
Expand Down
Expand Up @@ -48,7 +48,7 @@ public function testConfigureRejectsInvalidExcludeConfigurationElement($element)
$this->expectException(InvalidConfigurationException::class);
$this->expectExceptionMessage(sprintf(
'Each element must be a non-empty, trimmed string, got "%s" instead.',
\is_object($element) ? \get_class($element) : \gettype($element)
get_debug_type($element)
));

$this->fixer->configure([
Expand All @@ -68,7 +68,7 @@ public function testConfigureRejectsInvalidIncludeConfigurationElement($element)
$this->expectException(InvalidConfigurationException::class);
$this->expectExceptionMessage(sprintf(
'Each element must be a non-empty, trimmed string, got "%s" instead.',
\is_object($element) ? \get_class($element) : \gettype($element)
get_debug_type($element)
));

$this->fixer->configure([
Expand Down
Expand Up @@ -53,7 +53,7 @@ public function testConfigureRejectsInvalidConfigurationElement($element): void
$this->expectException(InvalidConfigurationException::class);
$this->expectExceptionMessage(sprintf(
'Each element must be a non-empty, trimmed string, got "%s" instead.',
\is_object($element) ? \get_class($element) : \gettype($element)
get_debug_type($element)
));

$this->fixer->configure([
Expand Down

0 comments on commit ae5701a

Please sign in to comment.