laminas / laminas-code

Extensions to the PHP Reflection API, static code scanning, and code generation
https://docs.laminas.dev/laminas-code/
BSD 3-Clause "New" or "Revised" License
1.85k stars 80 forks source link

E_NOTICE with trait method aliases #15

Closed weierophinney closed 3 years ago

weierophinney commented 4 years ago

I'm getting Notice: Undefined offset: 1 in /path/to/vendor/zendframework/zend-code/src/Scanner/ClassScanner.php on line 596 using 3.1.0. It looks like this happens with aliased trait methods:

trait A 
{
    function a() {
        // does something
    }
}

class B 
{
    use A {
        a as b;
    }

    function a() {
        b();
        // do something more
    }
}

Stepping through the code it looks like $alias['original'] does not contain '::', causing the notice. I ran into this using zend-expressive-tooling on an existing project. It doesn't seem to cause anything other than annoyance, but I'm not sure if just adding a check for '::' would hide a deeper problem. Thoughts?


Originally posted by @kynx at https://github.com/zendframework/zend-code/issues/104

Ocramius commented 3 years ago

No longer needed as per #58

kynx commented 3 years ago

Heavens to Betsy! I used to alias trait methods? What was wrong with me?!

Nice cleanup you’re doing @Ocramius 🙂