Skip to content

Commit 8c2bb03

Browse files
committed
📦 Introduce runtime deprecation for deprecated functionality to hint about upgrade path
1 parent 834f54f commit 8c2bb03

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/AnnotationReader.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
use function get_class;
3535
use function is_a;
3636
use function reset;
37+
use function trigger_error;
38+
39+
use const E_USER_DEPRECATED;
3740

3841
class AnnotationReader
3942
{
@@ -261,6 +264,14 @@ public function getParameterAnnotationsPerParameter(array $refParameters): array
261264

262265
$parameterAnnotations = $this->getMethodAnnotations($method, ParameterAnnotationInterface::class);
263266
foreach ($parameterAnnotations as $parameterAnnotation) {
267+
trigger_error(
268+
"Using '" . ParameterAnnotationInterface::class . "' over methods is deprecated. " .
269+
"Found attribute '" . $parameterAnnotation::class .
270+
"' over '" . $method->getDeclaringClass()->getName() . ':' . $method->getName() . "'. " .
271+
"Please target annotation to the parameter '$" . $parameterAnnotation->getTarget() . "' instead",
272+
E_USER_DEPRECATED,
273+
);
274+
264275
$parameterAnnotationsPerParameter[$parameterAnnotation->getTarget()][] = $parameterAnnotation;
265276
}
266277

0 commit comments

Comments
 (0)