Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call to a member function toString() on null #90

Closed
fe3dback opened this issue Feb 13, 2020 · 2 comments
Closed

Call to a member function toString() on null #90

fe3dback opened this issue Feb 13, 2020 · 2 comments
Labels
bug Something isn't working ❔ question Further information is requested

Comments

@fe3dback
Copy link

Bug Description

/app/web/vendor/bin/phpat /app/phpat.yaml
Deprecated: Array and string offset access syntax with curly braces is deprecated in /app/web/vendor/sentry/sentry/lib/Raven/Client.php on line 331
Notice: Undefined property: PhpParser\Node\Stmt\Class_::$namespacedName in /app/web/vendor/carlosas/phpat/src/Parser/NameCollector.php on line 23


	An error occurred while running phpat :(
        Please consider opening an issue: http://github.com/carlosas/phpat/issues


Call to a member function toString() on null

#0 /app/web/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(153): PhpAT\Parser\NameCollector->leaveNode(Object(PhpParser\Node\Stmt\Class_))
#1 /app/web/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(146): PhpParser\NodeTraverser->traverseNode(Object(PhpParser\Node\Expr\New_))
#2 /app/web/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(223): PhpParser\NodeTraverser->traverseNode(Object(PhpParser\Node\Stmt\Return_))
#3 /app/web/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(114): PhpParser\NodeTraverser->traverseArray(Array)
#4 /app/web/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(223): PhpParser\NodeTraverser->traverseNode(Object(PhpParser\Node\Stmt\ClassMethod))
#5 /app/web/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(114): PhpParser\NodeTraverser->traverseArray(Array)
#6 /app/web/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(223): PhpParser\NodeTraverser->traverseNode(Object(PhpParser\Node\Stmt\Class_))
#7 /app/web/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(114): PhpParser\NodeTraverser->traverseArray(Array)
#8 /app/web/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(223): PhpParser\NodeTraverser->traverseNode(Object(PhpParser\Node\Stmt\Namespace_))
#9 /app/web/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(91): PhpParser\NodeTraverser->traverseArray(Array)
#10 /app/web/vendor/carlosas/phpat/src/Parser/MapBuilder.php(70): PhpParser\NodeTraverser->traverse(Array)
#11 /app/web/vendor/carlosas/phpat/src/App.php(63): PhpAT\Parser\MapBuilder->build()
#12 /app/web/vendor/carlosas/phpat/phpat(47): PhpAT\App->execute()

Additional context
My config

src:
  path: web/src/
tests:
  path: tests/architecture/

My test:

<?php

use PhpAT\Selector\Selector;

class OnlyRepositoriesDependOnModelsTest extends \PhpAT\Test\ArchitectureTest
{
    /**
     * @return \PhpAT\Rule\Rule
     */
    public function testNobodyExceptRepositoriesDependOnModels(): \PhpAT\Rule\Rule
    {
        return $this->newRule
            ->classesThat(Selector::haveClassName('App\Domain\*'))
            ->canOnlyDependOn()
            ->classesThat(Selector::havePath('Domain/*'))
            ->andClassesThat(Selector::haveClassName('App\Application\Shared\Service\KnownBadApproach'))
            ->build();
    }
}
@fe3dback fe3dback added the bug Something isn't working label Feb 13, 2020
@carlosas
Copy link
Owner

carlosas commented Feb 14, 2020

Could you specify which version of phpat are you using? And PHP version?

Seems like the NameResolver is not able to transform a class into a namespaced ClassLike node.
Some extra information about the code, does it include anonymous classes or some other not-so-mainstream technique? In this case a piece of code would be appreciated.

@carlosas carlosas added the ❔ question Further information is requested label Feb 14, 2020
@carlosas
Copy link
Owner

I assume this is due to the usage of anonymous classes, I added a fix and released a new version.
https://github.com/carlosas/phpat/releases/tag/0.6.0

If you keep experiencing this error please, comment on this issue with more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ❔ question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants