carlosas / phpat

PHP Architecture Tester - Easy architecture testing for PHP :heavy_check_mark:
https://phpat.dev
MIT License
1.08k stars 41 forks source link

Parameter #1 ...$selectors of method PHPat\Test\Builder\SubjectStep::classes() expects PHPat\Selector\SelectorInterface, PHPat\Selector\Modifier\AndModifier given #291

Open erikvanderschaaf opened 4 weeks ago

erikvanderschaaf commented 4 weeks ago

Bug Description I'm not sure if this is a phpat bug or a phpstan bug. I've written the following test, but I'm getting an error, but IMHO this is not a valid error since AndModifier implements SelectorInterface

 Line   test/PHPat/Process.php
 ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
   7     Parameter #1 ...$selectors of method PHPat\Test\Builder\SubjectStep::classes() expects PHPat\Selector\SelectorInterface, PHPat\Selector\Modifier\AndModifier given.
final class Process
{
    public function testImplementsInterface(): Rule
    {
        return PHPat::rule()
            ->classes(
                Selector::AND(
                    Selector::inNamespace('Process'),
                    Selector::NOT(
                        Selector::isInterface()
                    )
                )
            )
            ->shouldImplement()
            ->classes(
                Selector::classname(ProcessInterface::class)
            )
            ->because('Each process should implement ProcessInterface');
    }
}
carlosas commented 1 week ago

Hi. Did you figure out what was happening? I just run your code and it works properly. Which PHPStan/PHPat version are you using?