parent
f56b209d5c
commit
8d745d89be
3 changed files with 83 additions and 2 deletions
@ -0,0 +1,49 @@ |
||||
--TEST-- |
||||
Nested trait uses retain import aliases through multiple composition levels |
||||
--FILE-- |
||||
<?php |
||||
namespace Issue38\Library { |
||||
trait Greeting { |
||||
public function hello(): string { |
||||
return 'imported'; |
||||
} |
||||
} |
||||
} |
||||
|
||||
namespace Issue38\Template { |
||||
use Issue38\Library\Greeting as ImportedGreeting; |
||||
|
||||
trait InnerWrapper { |
||||
use ImportedGreeting { |
||||
hello as protected importedHello; |
||||
} |
||||
|
||||
public function wrapped(): string { |
||||
return '[' . $this->importedHello() . ']'; |
||||
} |
||||
} |
||||
|
||||
trait OuterWrapper { |
||||
use InnerWrapper; |
||||
} |
||||
} |
||||
|
||||
namespace Issue38\Consumer { |
||||
use Issue38\Template\OuterWrapper as ImportedWrapper; |
||||
|
||||
class Example { |
||||
use ImportedWrapper; |
||||
} |
||||
} |
||||
|
||||
namespace { |
||||
function main(): void { |
||||
$example = new Issue38\Consumer\Example(); |
||||
echo $example->hello(), "\n"; |
||||
echo $example->wrapped(), "\n"; |
||||
} |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
imported |
||||
[imported] |
||||
@ -0,0 +1,28 @@ |
||||
--TEST-- |
||||
Nested trait uses resolve unqualified names in the declaring namespace |
||||
--FILE-- |
||||
<?php |
||||
namespace Issue38\SameNamespace { |
||||
trait Greeting { |
||||
public function hello(): string { |
||||
return 'hi'; |
||||
} |
||||
} |
||||
|
||||
trait GreetingWrapper { |
||||
use Greeting; |
||||
} |
||||
|
||||
class Example { |
||||
use GreetingWrapper; |
||||
} |
||||
} |
||||
|
||||
namespace { |
||||
function main(): void { |
||||
echo (new Issue38\SameNamespace\Example())->hello(), "\n"; |
||||
} |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
hi |
||||
Loading…
Reference in new issue