Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP8 - Utilize "get_debug_type" #6303

Merged
merged 1 commit into from Feb 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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