mihaeu / dephpend

Detect flaws in your architecture, before they drag you down into the depths of dependency hell ...

Home Page:https://dephpend.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uncaught TypeError: Argument 1 passed to Mihaeu\PhpDependencies\Dependencies\DependencyFactory::createClazzFromStringArray() must be of the type array, null given

sebastianbergmann opened this issue · comments

$ git clone git@github.com:mihaeu/dephpend.git
$ cd dephpend
$ composer update
$ cd ...
$ git clone git@github.com:symfony/symfony.git
$ cd symfony
$ composer update
$ ../dephpend/bin/dephpend text .
PHP Notice:  Undefined property: PhpParser\Node\Stmt\Class_::$namespacedName in /usr/local/src/dephpend/src/Analyser/DependencyInspectionVisitor.php on line 188
PHP Notice:  Trying to get property of non-object in /usr/local/src/dephpend/src/Analyser/DependencyInspectionVisitor.php on line 188
PHP Fatal error:  Uncaught TypeError: Argument 1 passed to Mihaeu\PhpDependencies\Dependencies\DependencyFactory::createClazzFromStringArray() must be of the type array, null given, called in /usr/local/src/dephpend/src/Analyser/DependencyInspectionVisitor.php on line 188 and defined in /usr/local/src/dephpend/src/Dependencies/DependencyFactory.php:14
Stack trace:
#0 /usr/local/src/dephpend/src/Analyser/DependencyInspectionVisitor.php(188): Mihaeu\PhpDependencies\Dependencies\DependencyFactory->createClazzFromStringArray(NULL)
#1 /usr/local/src/dephpend/src/Analyser/DependencyInspectionVisitor.php(59): Mihaeu\PhpDependencies\Analyser\DependencyInspectionVisitor->setCurrentClass(Object(PhpParser\Node\Stmt\Class_))
#2 /usr/local/src/dephpend/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(92): Mihaeu\PhpDependencies\Analyser\DependencyInspectionVisitor->enterNode(Object(PhpParser\Node\Stmt\Class_))
#3 /usr/local/src/dephpend/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(101): PhpParser\NodeTraverser->traverseNo in /usr/local/src/dephpend/src/Dependencies/DependencyFactory.php on line 14

Thanks for the report Sebastian. Interesting find.

If you change the last command to ../dephpend/bin/dephpend text src it would work. Something within the vendor directory is causing problems.

I'll investigate and let you know what it was.

P.S. new version with new features (and better error reporting) coming soon

Found it 😄 I didn't support inner classes using variable names (uargh!). I thought about that edge case once and then forgot to test it.

// \Doctrine\Tests\ORM\Decorator\EntityManagerDecoratorTest

/**
 * @dataProvider getMethodParameters
 */
public function testAllMethodCallsAreDelegatedToTheWrappedInstance($method, array $parameters)
{
    $return = !in_array($method, self::VOID_METHODS) ? 'INNER VALUE FROM ' . $method : null;

    $this->wrapped->expects($this->once())
        ->method($method)
        ->with(...$parameters)
        ->willReturn($return);

    $decorator = new class ($this->wrapped) extends EntityManagerDecorator {
    };

    $this->assertSame($return, $decorator->$method(...$parameters));
}

Fix is on develop. Will merge and tag tomorrow or Friday.

Fixed a while ago, my issue management sucks 🙈