Skip to content

[FR] ObjectDeclarations: add getTraitImportUse() method #689

@jrfnl

Description

@jrfnl

... to get the pointers to the trait import use statements in an OO construct.

Needs a new uses array entry in the analyzeOOStructure() method to track the use tokens.

Array format for the getTraitImportUse() method will be different compared to the other get*() methods as it would just be pointers to the use tokens, no names.

Or alternatively, the trait import use would need to be analysed and an entry be added to each imported trait name, but then, what should the token pointer be ? Still the use token, even for multi-imports ?

Some code samples:

class MyHelloWorld
{
    use TraitA;
    use TraitB, TraitC; // Multi-import.
}

class Talker {
    use A, B {
        B::smallTalk insteadof A;
        A::bigTalk insteadof B;
    }
}

class Aliased_Talker {
    use A, B {
        B::smallTalk insteadof A;
        A::bigTalk insteadof B;
        B::bigTalk as talk;
    }
}

class MyClass1 {
    use HelloWorld { sayHello as protected; }
}

class MyClass2 {
    use HelloWorld { sayHello as private myPrivateHello; }
}

Ref: https://www.php.net/manual/en/language.oop5.traits.php

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions