Skip to content

Commit 199b05a

Browse files
committed
used attribute Deprecated
1 parent 1a056b4 commit 199b05a

File tree

3 files changed

+11
-17
lines changed

3 files changed

+11
-17
lines changed

src/DI/Extensions/InjectExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public static function getInjectProperties(string $class): array
119119
foreach ((new \ReflectionClass($class))->getProperties() as $rp) {
120120
if (
121121
$rp->getAttributes(DI\Attributes\Inject::class)
122-
|| DI\Helpers::parseAnnotation($rp, 'inject') !== null
122+
|| @DI\Helpers::parseAnnotation($rp, 'inject') !== null // @deprecated
123123
) {
124124
if (!$rp->getAttributes(DI\Attributes\Inject::class)) {
125125
trigger_error('Annotation @inject is deprecated, use #[Nette\\DI\\Attributes\\Inject] (used in ' . Reflection::toString($rp) . ')', E_USER_DEPRECATED);

src/DI/Helpers.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,7 @@ public static function prefixServiceName(mixed $config, string $namespace): mixe
200200
}
201201

202202

203-
/**
204-
* Returns an annotation value.
205-
*/
203+
#[\Deprecated]
206204
public static function parseAnnotation(\Reflector $ref, string $name): ?string
207205
{
208206
if (!Reflection::areCommentsAvailable()) {

tests/DI/Helpers.parseAnnotation().phpt

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<?php
22

3-
/**
4-
* Test: Nette\DI\Helpers::expand()
5-
*/
6-
73
declare(strict_types=1);
84

95
use Nette\DI\Helpers;
@@ -22,10 +18,10 @@ class TestClass
2218

2319
$rc = new ReflectionClass(TestClass::class);
2420

25-
Assert::same('', Helpers::parseAnnotation($rc, 'inject'));
26-
Assert::same(null, Helpers::parseAnnotation($rc, 'injec'));
27-
Assert::same('type', Helpers::parseAnnotation($rc, 'var'));
28-
Assert::same('bool|int', Helpers::parseAnnotation($rc, 'return'));
21+
Assert::same('', @Helpers::parseAnnotation($rc, 'inject'));
22+
Assert::same(null, @Helpers::parseAnnotation($rc, 'injec'));
23+
Assert::same('type', @Helpers::parseAnnotation($rc, 'var'));
24+
Assert::same('bool|int', @Helpers::parseAnnotation($rc, 'return'));
2925

3026

3127
/** @return*/
@@ -35,7 +31,7 @@ class TestClass2
3531

3632
$rc = new ReflectionClass(TestClass2::class);
3733

38-
Assert::same('', Helpers::parseAnnotation($rc, 'return'));
34+
Assert::same('', @Helpers::parseAnnotation($rc, 'return'));
3935

4036

4137
/** @return
@@ -47,7 +43,7 @@ class TestClass3
4743

4844
$rc = new ReflectionClass(TestClass3::class);
4945

50-
Assert::same('', Helpers::parseAnnotation($rc, 'return'));
46+
Assert::same('', @Helpers::parseAnnotation($rc, 'return'));
5147

5248

5349
/**
@@ -59,6 +55,6 @@ class TestClass4
5955

6056
$rc = new ReflectionClass(TestClass4::class);
6157

62-
Assert::same(null, Helpers::parseAnnotation($rc, 'inject'));
63-
Assert::same(null, Helpers::parseAnnotation($rc, 'injec'));
64-
Assert::same(null, Helpers::parseAnnotation($rc, 'var'));
58+
Assert::same(null, @Helpers::parseAnnotation($rc, 'inject'));
59+
Assert::same(null, @Helpers::parseAnnotation($rc, 'injec'));
60+
Assert::same(null, @Helpers::parseAnnotation($rc, 'var'));

0 commit comments

Comments
 (0)