diff --git a/fixtures/set035-composer-files-autoload/index.php b/fixtures/set035-composer-files-autoload/index.php index 30c27de5..560c2a86 100644 --- a/fixtures/set035-composer-files-autoload/index.php +++ b/fixtures/set035-composer-files-autoload/index.php @@ -5,7 +5,7 @@ use Throwable; use const PHP_EOL; -// Autoload the scoped vendor guzzle. This is to mimick a scoped code that would +// Autoload the scoped vendor guzzle. This is to mimic a scoped code that would // load this code. // Triggering the autoloading will autoload the Guzzle `functions.php` file which // declares the _scoped_ functions. @@ -19,9 +19,9 @@ echo 'Autoload code.'.PHP_EOL; require __DIR__.'/vendor/autoload.php'; -// Will fail to find the function -try { - \GuzzleHttp\describe_type('hello'); -} catch (Throwable $throwable) { - echo $throwable->getMessage().PHP_EOL; -} +// This is the test: it should have autoloaded the function file from the regular autoload +// despite the scoped file having been loaded previously. +\GuzzleHttp\describe_type('hello'); + +// Mimic PHPStan that uses some autoloaded code + diff --git a/fixtures/set035-composer-files-autoload/test.php b/fixtures/set035-composer-files-autoload/test.php index 03c636ad..0db9bd6c 100644 --- a/fixtures/set035-composer-files-autoload/test.php +++ b/fixtures/set035-composer-files-autoload/test.php @@ -6,5 +6,11 @@ '#PHP Fatal error: Uncaught Error: Call to undefined function GuzzleHttp\\describe_type\(\)#', $output, ); +$expectedResult = false; -exit($functionAutoloadFailed ? 1 : 0); +if ($functionAutoloadFailed) { + echo $output; + echo PHP_EOL; +} + +exit($functionAutoloadFailed === $expectedResult ? 0 : 1);