Giter Club home page Giter Club logo

Comments (4)

roblourens avatar roblourens commented on May 24, 2024

I don't know- I was just looking at the test cases and I'm not sure why you can use it on some code that references that name, but not in the use statement. If it makes sense, we could change that.

from tolerant-php-parser.

zobo avatar zobo commented on May 24, 2024

Hi, thanks for the feedback. Maybe it has something to do with the crazy things you can do with the insteadof and as keywords. See "Conflict resolution" in https://www.php.net/manual/en/language.oop5.traits.php .

from tolerant-php-parser.

zobo avatar zobo commented on May 24, 2024

But then again, I can't imagine this be the reason... I tried commenting out Node\TraitUseClause to see if any of the tests in php-intellisense break and there was no problem - if something, some things I missed got fixed.

    public function getResolvedName($namespaceDefinition = null) {
        // Name resolution not applicable to constructs that define symbol names or aliases.
        if (($this->parent instanceof Node\Statement\NamespaceDefinition && $this->parent->name->getStartPosition() === $this->getStartPosition()) ||
            $this->parent instanceof Node\Statement\NamespaceUseDeclaration ||
            $this->parent instanceof Node\NamespaceUseClause ||
            $this->parent instanceof Node\NamespaceUseGroupClause ||
            /*$this->parent->parent instanceof Node\TraitUseClause ||*/
            $this->parent instanceof Node\TraitSelectOrAliasClause
        ) {
            return null;
        }

I have not yet managed to wrap my head around TraitSelectOrAliasClause where in the parsers it's being used.

from tolerant-php-parser.

zobo avatar zobo commented on May 24, 2024

I cannot figure out why @mousetraps prohibited this. use Trait works much the same way as use Namespace - in the sense of resolving to FQN.

Even the other case of TraitSelectOrAliasClause is useless here because the following code

class TestClazz
{
	use TestTrait {
		TestTrait::test2 as testX;
	}

Gets constructed into: TraitUseClause -> TratSelectOrAliasClauseList -> TraitSelectOrAliasClause -> ScopedPropertyAccessExpression -> QualifiedName.

And such $this->parent instanceof Node\TraitSelectOrAliasClause should actually be $this->parent->parent instanceof Node\TraitSelectOrAliasClause to have any effect.

Then again it still does not make sense to have this as even here the QualifiedName can be resolved without any extra logic or context.

(unless I'm missing something)

Making a PR.

from tolerant-php-parser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.