Skip to content

Commit 6669768

Browse files
committed
Reproduce autoloader bug
1 parent ea816fc commit 6669768

File tree

8 files changed

+54
-1
lines changed

8 files changed

+54
-1
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,10 @@ jobs:
390390
cd e2e/composer-version-config
391391
composer install
392392
../../bin/phpstan analyze test.php --level=0
393-
393+
- script: |
394+
cd e2e/bug-12972b
395+
composer install
396+
../../bin/phpstan analyze
394397
steps:
395398
- name: "Checkout"
396399
uses: actions/checkout@v4

e2e/bug-12972b/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/vendor/
2+
composer.lock

e2e/bug-12972b/autoloader.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
require_once __DIR__ . '/vendor/autoload.php';
4+
5+
spl_autoload_register(function($class) {
6+
if ($class === \other12972\MyClass::class) {
7+
throw new LogicException('this should not happen');
8+
}
9+
});

e2e/bug-12972b/composer.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"autoload": {
3+
"classmap": [
4+
"src/"
5+
]
6+
}
7+
}

e2e/bug-12972b/phpstan.dist.neon

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
parameters:
2+
level: 9
3+
4+
paths:
5+
- src
6+
7+
bootstrapFiles:
8+
- autoloader.php

e2e/bug-12972b/real-world.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
require 'autoloader.php';
4+
5+
new \Foo12972\MyRoot();

e2e/bug-12972b/src/folder/file2.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace Foo12972;
4+
5+
use other12972\MyClass;
6+
7+
class MyRoot {
8+
function doBar(MyClass $myClass):void {}
9+
}

e2e/bug-12972b/src/other/file.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace other12972;
4+
5+
class MyClass {
6+
public function doSomething(): int
7+
{
8+
return 1;
9+
}
10+
}

0 commit comments

Comments
 (0)