Skip to content

Commit

Permalink
fix: fix php 8.0 deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristoforo Cervino committed Aug 28, 2023
1 parent 692ca35 commit 6e544a8
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions src/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ public static function assertTargetCallableHasRightTypeHintedArguments(
throw new TargetCallableArgumentException(\sprintf('Callable for option "%s" must have first argument nullable', TargetCallbackExtension::NAME));
}

$targetParamClass = $targetParam->getType() && !$targetParam->getType()->isBuiltin() ? new \ReflectionClass($targetParam->getType()->getName()) : null;

Check failure on line 55 in src/Assert.php

View workflow job for this annotation

GitHub Actions / PHPStan

Call to an undefined method ReflectionType::getName().

Check failure on line 55 in src/Assert.php

View workflow job for this annotation

GitHub Actions / PHPStan

Call to an undefined method ReflectionType::isBuiltin().
if (
null !== $target &&
$targetParam->hasType() &&
(null !== $targetParam->getClass() ?
!\is_a($target, $targetParam->getClass()->getName(), true) :
// @phpstan-ignore-next-line
($targetParamType = $targetParam->getType()) !== null && \get_debug_type($target) !== $targetParamType->getName())) {
null !== $target
&& $targetParam->hasType()
&& (null !== $targetParamClass ?
!\is_a($target, $targetParamClass->getName(), true) :
// @phpstan-ignore-next-line
($targetParamType = $targetParam->getType()) !== null && \get_debug_type($target) !== $targetParamType->getName())) {
throw new TargetCallableArgumentException(\sprintf('Callable for option "%s" must have first argument type-hinted as "%s"', TargetCallbackExtension::NAME, \get_debug_type($target)));
}

Expand All @@ -67,23 +68,25 @@ public static function assertTargetCallableHasRightTypeHintedArguments(
throw new TargetCallableArgumentException(\sprintf('Callable for option "%s" must have second argument nullable', TargetCallbackExtension::NAME));
}

$formDataParamClass = $formDataParam->getType() && !$formDataParam->getType()->isBuiltin() ? new \ReflectionClass($formDataParam->getType()->getName()) : null;

Check failure on line 71 in src/Assert.php

View workflow job for this annotation

GitHub Actions / PHPStan

Call to an undefined method ReflectionType::getName().

Check failure on line 71 in src/Assert.php

View workflow job for this annotation

GitHub Actions / PHPStan

Call to an undefined method ReflectionType::isBuiltin().
if (
null !== $formData &&
$formDataParam->hasType() &&
(null !== $formDataParam->getClass() ?
!\is_a($formData, $formDataParam->getClass()->getName(), true) :
// @phpstan-ignore-next-line
($formDataParamType = $formDataParam->getType()) !== null && \get_debug_type($formData) !== $formDataParamType->getName())) {
null !== $formData
&& $formDataParam->hasType()
&& (null !== $formDataParamClass ?
!\is_a($formData, $formDataParamClass->getName(), true) :
// @phpstan-ignore-next-line
($formDataParamType = $formDataParam->getType()) !== null && \get_debug_type($formData) !== $formDataParamType->getName())) {
throw new TargetCallableArgumentException(\sprintf('Callable for option "%s" must have second argument type-hinted as "%s"', TargetCallbackExtension::NAME, \get_debug_type($formData)));
}

// Checking $form argument
if (null !== $formParam) {
$formParamClass = $formParam->getType() && !$formParam->getType()->isBuiltin() ? new \ReflectionClass($formParam->getType()->getName()) : null;

Check failure on line 84 in src/Assert.php

View workflow job for this annotation

GitHub Actions / PHPStan

Call to an undefined method ReflectionType::getName().

Check failure on line 84 in src/Assert.php

View workflow job for this annotation

GitHub Actions / PHPStan

Call to an undefined method ReflectionType::isBuiltin().
if (
$formParam->hasType() &&
(
null === $formParam->getClass() ||
!\is_a($formParam->getClass()->getName(), FormInterface::class, true)
$formParam->hasType()
&& (
null === $formParamClass
|| !\is_a($formParamClass->getName(), FormInterface::class, true)
)
) {
throw new TargetCallableArgumentException(\sprintf('Callable for option "%s" must have third argument type-hinted as "%s"', TargetCallbackExtension::NAME, FormInterface::class));
Expand Down

0 comments on commit 6e544a8

Please sign in to comment.