Skip to content

Commit

Permalink
📦 Introduce runtime deprecation for deprecated functionality to hint …
Browse files Browse the repository at this point in the history
…about upgrade path
  • Loading branch information
andrew-demb committed Nov 26, 2024
1 parent 834f54f commit 8c2bb03
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/AnnotationReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
use function get_class;
use function is_a;
use function reset;
use function trigger_error;

use const E_USER_DEPRECATED;

class AnnotationReader
{
Expand Down Expand Up @@ -261,6 +264,14 @@ public function getParameterAnnotationsPerParameter(array $refParameters): array

$parameterAnnotations = $this->getMethodAnnotations($method, ParameterAnnotationInterface::class);
foreach ($parameterAnnotations as $parameterAnnotation) {
trigger_error(
"Using '" . ParameterAnnotationInterface::class . "' over methods is deprecated. " .
"Found attribute '" . $parameterAnnotation::class .
"' over '" . $method->getDeclaringClass()->getName() . ':' . $method->getName() . "'. " .
"Please target annotation to the parameter '$" . $parameterAnnotation->getTarget() . "' instead",
E_USER_DEPRECATED,
);

$parameterAnnotationsPerParameter[$parameterAnnotation->getTarget()][] = $parameterAnnotation;
}

Expand Down

0 comments on commit 8c2bb03

Please sign in to comment.