Fixed incorrect class inheritance (#394)

Generated example was incorrect - you cannot define import alias:
use Some\Other\Thingy as SomeClass;

and then define a class with the same name:
abstract class SomeClass ...

Class names changed to avoid conflict between import alias and abstract class name.
This commit is contained in:
Ilia Smirnov 2017-07-19 17:55:00 +03:00 committed by Nikita Popov
parent 8bdcb47815
commit 441e6e1d31

View File

@ -21,8 +21,8 @@ use PhpParser\Node;
$factory = new BuilderFactory;
$node = $factory->namespace('Name\Space')
->addStmt($factory->use('Some\Other\Thingy')->as('SomeOtherClass'))
->addStmt($factory->class('SomeClass')
->extend('SomeOtherClass')
->addStmt($factory->class('SomeOtherClass')
->extend('SomeClass')
->implement('A\Few', '\Interfaces')
->makeAbstract() // ->makeFinal()
@ -66,7 +66,7 @@ This will produce the following output with the standard pretty printer:
namespace Name\Space;
use Some\Other\Thingy as SomeClass;
abstract class SomeClass extends SomeOtherClass implements A\Few, \Interfaces
abstract class SomeOtherClass extends SomeClass implements A\Few, \Interfaces
{
protected $someProperty;
private $anotherProperty = array(1, 2, 3);