pestphp / pest

Pest is an elegant PHP testing Framework with a focus on simplicity, meticulously designed to bring back the joy of testing in PHP.
https://pestphp.com
MIT License
9.06k stars 313 forks source link

[Bug]: method directoriesByNamespace replacing prefix multiple times resulting in false positive because the directory is not found #1164

Open mateusdeitos-tiny opened 1 month ago

mateusdeitos-tiny commented 1 month ago

What Happened

when running


arch('App\Application\Exception')
    ->expect('App\Application\Exception')
    ->toExtend(RequestException::class);

the method ObjectsRepository@directoriesByNamespace remove the prefix twice if the prefix is also present in another part of the namespace.

Example:

image

How to Reproduce

arch('App\Application\Exception') ->expect('App\Application\Exception') ->toExtend(RequestException::class);



### Sample Repository

_No response_

### Pest Version

2.34.7

### PHP Version

8.3.7

### Operation System

Linux

### Notes

_No response_