From 8c2bb03983d4d77dcd6f8f761f41199110f1641e Mon Sep 17 00:00:00 2001 From: Andrii Date: Wed, 27 Nov 2024 00:31:08 +0200 Subject: [PATCH] :package: Introduce runtime deprecation for deprecated functionality to hint about upgrade path --- src/AnnotationReader.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/AnnotationReader.php b/src/AnnotationReader.php index 4053d885d..39ebb6706 100644 --- a/src/AnnotationReader.php +++ b/src/AnnotationReader.php @@ -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 { @@ -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; }