File tree Expand file tree Collapse file tree
rules/TypeDeclaration/PHPStan
tests/Issues/NamespacedUseAutoImport/Fixture Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,14 +51,16 @@ public function narrowToFullyQualifiedOrAliasedObjectType(
5151
5252 $ uses = $ this ->useImportsResolver ->resolve ();
5353
54- $ aliasedObjectType = $ this ->matchAliasedObjectType ($ objectType , $ uses );
55- if ($ aliasedObjectType instanceof AliasedObjectType) {
56- return $ aliasedObjectType ;
57- }
54+ if (! $ withPreslash ) {
55+ $ aliasedObjectType = $ this ->matchAliasedObjectType ($ objectType , $ uses );
56+ if ($ aliasedObjectType instanceof AliasedObjectType) {
57+ return $ aliasedObjectType ;
58+ }
5859
59- $ shortenedObjectType = $ this ->matchShortenedObjectType ($ objectType , $ uses );
60- if ($ shortenedObjectType !== null ) {
61- return $ shortenedObjectType ;
60+ $ shortenedObjectType = $ this ->matchShortenedObjectType ($ objectType , $ uses );
61+ if ($ shortenedObjectType !== null ) {
62+ return $ shortenedObjectType ;
63+ }
6264 }
6365
6466 if ($ this ->reflectionProvider ->hasClass ($ className )) {
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Carbon ;
4+
5+ if (interface_exists ('Carbon\CarbonInterface ' )) {
6+ return ;
7+ }
8+
9+ interface CarbonInterface
10+ {
11+
12+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Rector \Tests \Issues \NamespacedUseAutoImport \Fixture ;
6+
7+ use Carbon \Carbon ;
8+ use Carbon \CarbonInterface ;
9+
10+ /**
11+ * @property \Carbon\CarbonInterface|null $deleted_at
12+ */
13+ class InUseFqcnDocblock
14+ {
15+ /**
16+ * @return CarbonInterface[]
17+ */
18+ public function demoFunction (): array
19+ {
20+ return [Carbon::parse ('2026-01-01 11:16:01 ' )];
21+ }
22+ }
23+
24+ ?>
25+ -----
26+ <?php
27+
28+ declare (strict_types=1 );
29+
30+ namespace Rector \Tests \Issues \NamespacedUseAutoImport \Fixture ;
31+
32+ use Carbon \Carbon ;
33+ use Carbon \CarbonInterface ;
34+
35+ /**
36+ * @property CarbonInterface|null $deleted_at
37+ */
38+ class InUseFqcnDocblock
39+ {
40+ /**
41+ * @return CarbonInterface[]
42+ */
43+ public function demoFunction (): array
44+ {
45+ return [Carbon::parse ('2026-01-01 11:16:01 ' )];
46+ }
47+ }
48+
49+ ?>
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ use Carbon\CarbonInterface;
1010/**
1111 * @property \Carbon\CarbonInterface|null $deleted_at
1212 */
13- class MergedImportErrorOtherVariety
13+ class NotInUseFqcnDocblock
1414{
1515 public function demoFunction (): array
1616 {
@@ -32,7 +32,7 @@ use Carbon\CarbonInterface;
3232/**
3333 * @property CarbonInterface|null $deleted_at
3434 */
35- class MergedImportErrorOtherVariety
35+ class NotInUseFqcnDocblock
3636{
3737 public function demoFunction (): array
3838 {
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ use Carbon\CarbonInterface;
1010/**
1111 * @property \Carbon\CarbonInterface|null $deleted_at
1212 */
13- class MergedImportError
13+ class NotInUseFqcnDocblock2
1414{
1515 public function demoFunction (): array
1616 {
@@ -27,12 +27,11 @@ declare(strict_types=1);
2727namespace Rector \Tests \Issues \NamespacedUseAutoImport \Fixture ;
2828
2929use Carbon \Carbon ;
30- use Carbon \CarbonInterface ;
3130
3231/**
3332 * @property CarbonInterface|null $deleted_at
3433 */
35- class MergedImportError
34+ class NotInUseFqcnDocblock2
3635{
3736 public function demoFunction (): array
3837 {
You can’t perform that action at this time.
0 commit comments