Edit report at https://bugs.php.net/bug.php?id=54441&edit=1

 ID:                 54441
 Comment by:         me at mikestowe dot com
 Reported by:        php-svn at helio dot arq dot br
 Summary:            Traits - Visibility on alias names
 Status:             Assigned
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Linux
 PHP Version:        trunk-SVN-2011-04-01 (snap)
 Assigned To:        gron
 Block user comment: N
 Private report:     N

 New Comment:

class Boo {
  use Foo {
    Foo::lol as dontKnow; 
    dontKnow as protected;
  }
}

To me this would do the following:
Use "Foo", set "Foo:lol" as "dontKnow", and then set "dontKnow" as "protected"

Meaning that I should be able to call $boo->lol, $boo->dontKnow, or 
$boo->protected to accomplish the same thing.

Otherwise it should throw a method does not exist error if the "as" is supposed 
to rename the function.


Previous Comments:
------------------------------------------------------------------------
[2011-04-03 15:30:16] php at stefan-marr dot de

Interesting question.

I suppose it could be legal (but obviously it is currently not implemented).
It looks kind of ugly to me, since it is less concise.
But well, all the traits use definitions should be declarative and orderless, 
so 
if it is possible to do something with two separate declarations then people 
might expect that it works.

Not sure whether we want that... 
But anyway, a good catch, thanks.
Stefan

------------------------------------------------------------------------
[2011-04-02 18:14:36] fel...@php.net

According to the actual grammar and implementation, the right way to do this is 
using:

Foo::lol as protected dontKnow;


Stefan Marr, is supposed to work the code as the bug reporter tried it?

------------------------------------------------------------------------
[2011-04-01 12:47:43] php-svn at helio dot arq dot br

Description:
------------
I'm trying Traits in php-trunk version.
In a give moment, I tried to change visibility in a alias trait's method.

Test script:
---------------
trait Foo {
  public static function lol() {
    echo 'Foo!';                                                            
  }
}

class Boo {
  use Foo {
    Foo::lol as dontKnow; 
    dontKnow as protected;
  }
}
$boo = new Boo();
$boo->dontKnow();

Expected result:
----------------
Fatal error: Call to protected method Boo::dontKnow() from context '' in %s on 
line %d

Actual result:
--------------
Foo!


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=54441&edit=1

Reply via email to