File tree Expand file tree Collapse file tree
packages/NodeTypeResolver
rules-tests/TypeDeclaration/Rector/ClassMethod/AddMethodCallBasedStrictParamTypeRector Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -224,7 +224,8 @@ public function getNativeType(Expr $expr): Type
224224 return new MixedType ();
225225 }
226226
227- return $ scope ->getNativeType ($ expr );
227+ $ type = $ scope ->getNativeType ($ expr );
228+ return $ this ->accessoryNonEmptyStringTypeCorrector ->correct ($ type );
228229 }
229230
230231 public function isNumberType (Node $ node ): bool
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Tests \TypeDeclaration \Rector \ClassMethod \AddMethodCallBasedStrictParamTypeRector \FixtureIntersection ;
4+
5+ final class StringIntersection
6+ {
7+ public function execute ()
8+ {
9+ $ value = sys_get_temp_dir () . DIRECTORY_SEPARATOR . basename (__FILE__ );
10+ $ this ->run ($ value );
11+ }
12+
13+ private function run ($ value )
14+ {
15+ }
16+ }
17+
18+ ?>
19+ -----
20+ <?php
21+
22+ namespace Rector \Tests \TypeDeclaration \Rector \ClassMethod \AddMethodCallBasedStrictParamTypeRector \FixtureIntersection ;
23+
24+ final class StringIntersection
25+ {
26+ public function execute ()
27+ {
28+ $ value = sys_get_temp_dir () . DIRECTORY_SEPARATOR . basename (__FILE__ );
29+ $ this ->run ($ value );
30+ }
31+
32+ private function run (string $ value )
33+ {
34+ }
35+ }
36+
37+ ?>
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Rector \Tests \TypeDeclaration \Rector \ClassMethod \AddMethodCallBasedStrictParamTypeRector ;
6+
7+ use Iterator ;
8+ use Rector \Testing \PHPUnit \AbstractRectorTestCase ;
9+ use Symplify \SmartFileSystem \SmartFileInfo ;
10+
11+ final class IntersectionTest extends AbstractRectorTestCase
12+ {
13+ /**
14+ * @dataProvider provideData()
15+ */
16+ public function test (SmartFileInfo $ fileInfo ): void
17+ {
18+ $ this ->doTestFileInfo ($ fileInfo );
19+ }
20+
21+ /**
22+ * @return Iterator<SmartFileInfo>
23+ */
24+ public function provideData (): Iterator
25+ {
26+ return $ this ->yieldFilesFromDirectory (__DIR__ . '/FixtureIntersection ' );
27+ }
28+
29+ public function provideConfigFilePath (): string
30+ {
31+ return __DIR__ . '/config/intersection_config.php ' ;
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ use Rector \Core \Configuration \Option ;
6+ use Rector \Core \ValueObject \PhpVersionFeature ;
7+ use Rector \TypeDeclaration \Rector \ClassMethod \AddMethodCallBasedStrictParamTypeRector ;
8+ use Symfony \Component \DependencyInjection \Loader \Configurator \ContainerConfigurator ;
9+
10+ return static function (ContainerConfigurator $ containerConfigurator ): void {
11+ $ parameters = $ containerConfigurator ->parameters ();
12+ $ parameters ->set (Option::PHP_VERSION_FEATURES , PhpVersionFeature::INTERSECTION_TYPES );
13+
14+ $ services = $ containerConfigurator ->services ();
15+ $ services ->set (AddMethodCallBasedStrictParamTypeRector::class);
16+ };
You can’t perform that action at this time.
0 commit comments