diff --git a/tests/Fixer/Preload/ExplicitlyLoadClassTest.php b/tests/Fixer/Preload/ExplicitlyLoadClassTest.php index 361925f3f14..d642075579c 100644 --- a/tests/Fixer/Preload/ExplicitlyLoadClassTest.php +++ b/tests/Fixer/Preload/ExplicitlyLoadClassTest.php @@ -44,16 +44,18 @@ public function provideFixCases() /** @var SplFileInfo $file */ foreach ($finder as $file) { - $path = $file->getRealPath(); - $output = file_get_contents($path); + $output = file_get_contents($file->getRealPath()); - $input = null; - $inputFile = substr($path, 0, -7).'In.php'; - if (is_file($inputFile)) { - $input = file_get_contents($inputFile); + $inputFilePattern = substr($file->getFilename(), 0, -7).'In*.php'; + $inputFinder = new Finder(); + $inputFinder->in($testDir)->name($inputFilePattern); + + /** @var SplFileInfo $file */ + foreach ($inputFinder as $input) { + yield sprintf('%s => %s', $input->getFilename(), $file->getFilename()) => [$output, file_get_contents($input->getRealPath())]; } - yield $file->getFilename() => [$output, $input]; + yield $file->getFilename() => [$output, null]; } } } diff --git a/tests/Fixtures/Preload/Case003_In.php b/tests/Fixtures/Preload/Case003_In.php new file mode 100644 index 00000000000..240dc39b8ea --- /dev/null +++ b/tests/Fixtures/Preload/Case003_In.php @@ -0,0 +1,15 @@ +foo = new Foo(); + } +} diff --git a/tests/Fixtures/Preload/Case003_Out.php b/tests/Fixtures/Preload/Case003_Out.php new file mode 100644 index 00000000000..dc71d812022 --- /dev/null +++ b/tests/Fixtures/Preload/Case003_Out.php @@ -0,0 +1,16 @@ +foo = new Foo(); + } +} diff --git a/tests/Fixtures/Preload/Case004_In.php b/tests/Fixtures/Preload/Case004_In.php new file mode 100644 index 00000000000..828e6ae9894 --- /dev/null +++ b/tests/Fixtures/Preload/Case004_In.php @@ -0,0 +1,15 @@ +foo = Foo::class; + } +} diff --git a/tests/Fixtures/Preload/Case004_Out.php b/tests/Fixtures/Preload/Case004_Out.php new file mode 100644 index 00000000000..7543f9570fc --- /dev/null +++ b/tests/Fixtures/Preload/Case004_Out.php @@ -0,0 +1,16 @@ +foo = Foo::class; + } +} diff --git a/tests/Fixtures/Preload/Case005_In.php b/tests/Fixtures/Preload/Case005_In.php new file mode 100644 index 00000000000..7ee7df2ca77 --- /dev/null +++ b/tests/Fixtures/Preload/Case005_In.php @@ -0,0 +1,21 @@ +bar = new Foo\Bar(); + $this->barClass = Foo\BarClass::class; + $this->baz = new \Biz\Baz(); + $this->bazClass = \Biz\BazClass::class; + } +} diff --git a/tests/Fixtures/Preload/Case005_Out.php b/tests/Fixtures/Preload/Case005_Out.php new file mode 100644 index 00000000000..166bcd74f88 --- /dev/null +++ b/tests/Fixtures/Preload/Case005_Out.php @@ -0,0 +1,25 @@ +bar = new Foo\Bar(); + $this->barClass = Foo\BarClass::class; + $this->baz = new \Biz\Baz(); + $this->bazClass = \Biz\BazClass::class; + } +} diff --git a/tests/Fixtures/Preload/Case006_In.php b/tests/Fixtures/Preload/Case006_In.php new file mode 100644 index 00000000000..0547a87c2b1 --- /dev/null +++ b/tests/Fixtures/Preload/Case006_In.php @@ -0,0 +1,22 @@ +bar = 2; + $this->init(); + } + + private function init() + { + $this->foo = new Foo(); + } +} diff --git a/tests/Fixtures/Preload/Case006_Out.php b/tests/Fixtures/Preload/Case006_Out.php new file mode 100644 index 00000000000..9be2fdb5aa9 --- /dev/null +++ b/tests/Fixtures/Preload/Case006_Out.php @@ -0,0 +1,23 @@ +bar = 2; + $this->init(); + } + + private function init() + { + $this->foo = new Foo(); + } +} diff --git a/tests/Fixtures/Preload/Case007_In.php b/tests/Fixtures/Preload/Case007_In.php new file mode 100644 index 00000000000..5b71b5c3d07 --- /dev/null +++ b/tests/Fixtures/Preload/Case007_In.php @@ -0,0 +1,22 @@ +bar = 2; + $this->init(); + } + + public function init() + { + $this->foo = new Foo(); + } +} diff --git a/tests/Fixtures/Preload/Case007_Out.php b/tests/Fixtures/Preload/Case007_Out.php new file mode 100644 index 00000000000..83e464b2ba6 --- /dev/null +++ b/tests/Fixtures/Preload/Case007_Out.php @@ -0,0 +1,23 @@ +bar = 2; + $this->init(); + } + + public function init() + { + $this->foo = new Foo(); + } +} diff --git a/tests/Fixtures/Preload/Case008_In.php b/tests/Fixtures/Preload/Case008_In.php new file mode 100644 index 00000000000..487bcec9f46 --- /dev/null +++ b/tests/Fixtures/Preload/Case008_In.php @@ -0,0 +1,23 @@ +bar = 2; + $var = new Foo(); + $this->init($var); + } + + private function init(Foo $foo) + { + $this->foo = $foo; + } +} diff --git a/tests/Fixtures/Preload/Case008_Out.php b/tests/Fixtures/Preload/Case008_Out.php new file mode 100644 index 00000000000..e6a165a62cf --- /dev/null +++ b/tests/Fixtures/Preload/Case008_Out.php @@ -0,0 +1,24 @@ +bar = 2; + $var = new Foo(); + $this->init($var); + } + + private function init(Foo $foo) + { + $this->foo = $foo; + } +} diff --git a/tests/Fixtures/Preload/Case009_Out.php b/tests/Fixtures/Preload/Case009_Out.php new file mode 100644 index 00000000000..a55bb8d00eb --- /dev/null +++ b/tests/Fixtures/Preload/Case009_Out.php @@ -0,0 +1,23 @@ +bar = 2; + $var = new Foo(); + $this->init($var); + } + + public function init(Foo $foo) + { + $this->foo = $foo; + } +} diff --git a/tests/Fixtures/Preload/Case010_In.php b/tests/Fixtures/Preload/Case010_In.php new file mode 100644 index 00000000000..a46b39dc5cb --- /dev/null +++ b/tests/Fixtures/Preload/Case010_In.php @@ -0,0 +1,26 @@ +init(); + } + + private function init() + { + $this->bar = new Foo\Bar(); + $this->barClass = Foo\BarClass::class; + $this->baz = new \Biz\Baz(); + $this->bazClass = \Biz\BazClass::class; + } +} diff --git a/tests/Fixtures/Preload/Case010_Out.php b/tests/Fixtures/Preload/Case010_Out.php new file mode 100644 index 00000000000..9bcb93b0381 --- /dev/null +++ b/tests/Fixtures/Preload/Case010_Out.php @@ -0,0 +1,30 @@ +init(); + } + + private function init() + { + $this->bar = new Foo\Bar(); + $this->barClass = Foo\BarClass::class; + $this->baz = new \Biz\Baz(); + $this->bazClass = \Biz\BazClass::class; + } +} diff --git a/tests/Fixtures/Preload/Case011_In.php b/tests/Fixtures/Preload/Case011_In.php new file mode 100644 index 00000000000..b9719023c2c --- /dev/null +++ b/tests/Fixtures/Preload/Case011_In.php @@ -0,0 +1,19 @@ +init(); + } + + public function init(): Foo + { + $bar = new Bar(); + return $bar->createFoo(); + } +} diff --git a/tests/Fixtures/Preload/Case011_Out.php b/tests/Fixtures/Preload/Case011_Out.php new file mode 100644 index 00000000000..f9e17dca753 --- /dev/null +++ b/tests/Fixtures/Preload/Case011_Out.php @@ -0,0 +1,20 @@ +init(); + } + + public function init(): Foo + { + $bar = new Bar(); + return $bar->createFoo(); + } +} diff --git a/tests/Fixtures/Preload/Case012_In.php b/tests/Fixtures/Preload/Case012_In.php new file mode 100644 index 00000000000..5b05c314c56 --- /dev/null +++ b/tests/Fixtures/Preload/Case012_In.php @@ -0,0 +1,19 @@ +init(); + } + + private function init(): Foo + { + $bar = new Bar(); + return $bar->createFoo(); + } +} diff --git a/tests/Fixtures/Preload/Case012_Out.php b/tests/Fixtures/Preload/Case012_Out.php new file mode 100644 index 00000000000..d78f4fab57f --- /dev/null +++ b/tests/Fixtures/Preload/Case012_Out.php @@ -0,0 +1,21 @@ +init(); + } + + private function init(): Foo + { + $bar = new Bar(); + return $bar->createFoo(); + } +} diff --git a/tests/Fixtures/Preload/Case013_In.php b/tests/Fixtures/Preload/Case013_In.php new file mode 100644 index 00000000000..8986ffc3aa6 --- /dev/null +++ b/tests/Fixtures/Preload/Case013_In.php @@ -0,0 +1,19 @@ +init(); + } + + protected function init(): Foo + { + $bar = new Bar(); + return $bar->createFoo(); + } +} diff --git a/tests/Fixtures/Preload/Case013_Out.php b/tests/Fixtures/Preload/Case013_Out.php new file mode 100644 index 00000000000..20199aab3a2 --- /dev/null +++ b/tests/Fixtures/Preload/Case013_Out.php @@ -0,0 +1,21 @@ +init(); + } + + protected function init(): Foo + { + $bar = new Bar(); + return $bar->createFoo(); + } +} diff --git a/tests/Fixtures/Preload/Case014_In.php b/tests/Fixtures/Preload/Case014_In.php new file mode 100644 index 00000000000..27ae7f8253b --- /dev/null +++ b/tests/Fixtures/Preload/Case014_In.php @@ -0,0 +1,19 @@ +init(); + } + + protected function init(): self + { + $bar = new Bar(); + return $bar->createFoo(); + } +} diff --git a/tests/Fixtures/Preload/Case014_Out.php b/tests/Fixtures/Preload/Case014_Out.php new file mode 100644 index 00000000000..366e62ec644 --- /dev/null +++ b/tests/Fixtures/Preload/Case014_Out.php @@ -0,0 +1,20 @@ +init(); + } + + protected function init(): self + { + $bar = new Bar(); + return $bar->createFoo(); + } +} diff --git a/tests/Fixtures/Preload/Case015_In.php b/tests/Fixtures/Preload/Case015_In.php new file mode 100644 index 00000000000..daeb00272b3 --- /dev/null +++ b/tests/Fixtures/Preload/Case015_In.php @@ -0,0 +1,19 @@ +init(); + } + + protected function init(): string + { + $bar = new Bar(); + return $bar->createFoo(); + } +} diff --git a/tests/Fixtures/Preload/Case015_Out.php b/tests/Fixtures/Preload/Case015_Out.php new file mode 100644 index 00000000000..483641e8765 --- /dev/null +++ b/tests/Fixtures/Preload/Case015_Out.php @@ -0,0 +1,20 @@ +init(); + } + + protected function init(): string + { + $bar = new Bar(); + return $bar->createFoo(); + } +} diff --git a/tests/Fixtures/Preload/Case016_In.php b/tests/Fixtures/Preload/Case016_In.php new file mode 100644 index 00000000000..bae0817c23e --- /dev/null +++ b/tests/Fixtures/Preload/Case016_In.php @@ -0,0 +1,19 @@ +init(); + } + + protected function init(): ?Foo + { + $bar = new Bar(); + return $bar->createFoo(); + } +} diff --git a/tests/Fixtures/Preload/Case016_Out.php b/tests/Fixtures/Preload/Case016_Out.php new file mode 100644 index 00000000000..56a78451385 --- /dev/null +++ b/tests/Fixtures/Preload/Case016_Out.php @@ -0,0 +1,21 @@ +init(); + } + + protected function init(): ?Foo + { + $bar = new Bar(); + return $bar->createFoo(); + } +} diff --git a/tests/Fixtures/Preload/Case017_In.php b/tests/Fixtures/Preload/Case017_In.php new file mode 100644 index 00000000000..0c5eaddcbc6 --- /dev/null +++ b/tests/Fixtures/Preload/Case017_In.php @@ -0,0 +1,25 @@ +init(); + } + + protected function init(): Foo + { + $bar = new Bar(); + return $bar->createFoo(); + } + + public function other(Foo $input) + { + // Nothing + } +} diff --git a/tests/Fixtures/Preload/Case017_Out.php b/tests/Fixtures/Preload/Case017_Out.php new file mode 100644 index 00000000000..76618a854eb --- /dev/null +++ b/tests/Fixtures/Preload/Case017_Out.php @@ -0,0 +1,26 @@ +init(); + } + + protected function init(): Foo + { + $bar = new Bar(); + return $bar->createFoo(); + } + + public function other(Foo $input) + { + // Nothing + } +} diff --git a/tests/Fixtures/Preload/Case018_In.php b/tests/Fixtures/Preload/Case018_In.php new file mode 100644 index 00000000000..e5e1b918840 --- /dev/null +++ b/tests/Fixtures/Preload/Case018_In.php @@ -0,0 +1,25 @@ +init(); + } + + protected function init(): Foo + { + $bar = new Bar(); + return $bar->createFoo(); + } + + protected function other(Foo $input) + { + // Nothing + } +} diff --git a/tests/Fixtures/Preload/Case018_Out.php b/tests/Fixtures/Preload/Case018_Out.php new file mode 100644 index 00000000000..57a76498ba6 --- /dev/null +++ b/tests/Fixtures/Preload/Case018_Out.php @@ -0,0 +1,27 @@ +init(); + } + + protected function init(): Foo + { + $bar = new Bar(); + return $bar->createFoo(); + } + + protected function other(Foo $input) + { + // Nothing + } +} diff --git a/tests/Fixtures/Preload/Case019_In.php b/tests/Fixtures/Preload/Case019_In.php new file mode 100644 index 00000000000..871201e3580 --- /dev/null +++ b/tests/Fixtures/Preload/Case019_In.php @@ -0,0 +1,25 @@ +init(); + } + + protected function init(): Foo + { + $bar = new Bar(); + return $bar->createFoo(); + } + + private function other(Foo $input) + { + // Nothing + } +} diff --git a/tests/Fixtures/Preload/Case019_Out.php b/tests/Fixtures/Preload/Case019_Out.php new file mode 100644 index 00000000000..27954ef16ec --- /dev/null +++ b/tests/Fixtures/Preload/Case019_Out.php @@ -0,0 +1,27 @@ +init(); + } + + protected function init(): Foo + { + $bar = new Bar(); + return $bar->createFoo(); + } + + private function other(Foo $input) + { + // Nothing + } +}