Skip to content

Commit e05a39c

Browse files
committed
used attribute Deprecated
1 parent 2de10f5 commit e05a39c

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
@@ -120,7 +120,7 @@ public static function getInjectProperties(string $class): array
120120
foreach ((new \ReflectionClass($class))->getProperties() as $rp) {
121121
if (
122122
$rp->getAttributes(DI\Attributes\Inject::class)
123-
|| DI\Helpers::parseAnnotation($rp, 'inject') !== null
123+
|| @DI\Helpers::parseAnnotation($rp, 'inject') !== null // @deprecated
124124
) {
125125
if (!$rp->getAttributes(DI\Attributes\Inject::class)) {
126126
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
@@ -202,9 +202,7 @@ public static function prefixServiceName(mixed $config, string $namespace): mixe
202202
}
203203

204204

205-
/**
206-
* Returns an annotation value.
207-
*/
205+
#[\Deprecated]
208206
public static function parseAnnotation(\Reflector $ref, string $name): ?string
209207
{
210208
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)