2020use gossi \codegen \model \parts \QualifiedNameTrait ;
2121use gossi \codegen \model \parts \DocblockTrait ;
2222use gossi \codegen \model \parts \LongDescriptionTrait ;
23- use Doctrine \Common \Annotations \PhpParser ;
2423
2524/**
2625 * Represents an abstract php struct.
@@ -64,13 +63,6 @@ protected static function createMethod(\ReflectionMethod $method) {
6463 protected static function createProperty (\ReflectionProperty $ property ) {
6564 return PhpProperty::fromReflection ($ property );
6665 }
67-
68- protected static function getUseStatementsFromReflection (\ReflectionClass $ ref ) {
69- if (null === self ::$ phpParser ) {
70- self ::$ phpParser = new PhpParser ();
71- }
72- return self ::$ phpParser ->parseClass ($ ref );
73- }
7466
7567 public function __construct ($ name = null ) {
7668 $ this ->setQualifiedName ($ name );
@@ -94,7 +86,10 @@ public function addRequiredFile($file) {
9486 }
9587
9688 public function setUseStatements (array $ useStatements ) {
97- $ this ->useStatements = $ useStatements ;
89+ $ this ->useStatements = [];
90+ foreach ($ useStatements as $ alias => $ useStatement ) {
91+ $ this ->addUseStatement ($ useStatement , $ alias );
92+ }
9893
9994 return $ this ;
10095 }
@@ -106,7 +101,7 @@ public function setUseStatements(array $useStatements) {
106101 * @return $this
107102 */
108103 public function addUseStatement ($ qualifiedName , $ alias = null ) {
109- if (null === $ alias ) {
104+ if (! is_string ( $ alias) ) {
110105 if (false === strpos ($ qualifiedName , '\\' )) {
111106 $ alias = $ qualifiedName ;
112107 } else {
@@ -130,29 +125,6 @@ public function hasUseStatement($qualifiedName) {
130125 return isset ($ flipped [$ qualifiedName ]);
131126 }
132127
133- // public function declareUses()
134- // {
135- // foreach (func_get_args() as $name) {
136- // $this->declareUse($name);
137- // }
138- // }
139-
140- // /**
141- // * @param string $fullClassName
142- // * @param null|string $alias
143- // *
144- // * @return string
145- // */
146- // public function declareUse($fullClassName, $alias = null)
147- // {
148- // $fullClassName = trim($fullClassName, '\\');
149- // if (!$this->hasUseStatement($fullClassName)) {
150- // $this->addUseStatement($fullClassName, $alias);
151- // }
152-
153- // return $this->getUseAlias($fullClassName);
154- // }
155-
156128 /**
157129 * @param string $qualifiedName
158130 * @return string
@@ -253,7 +225,5 @@ public function generateDocblock() {
253225 foreach ($ this ->methods as $ method ) {
254226 $ method ->generateDocblock ();
255227 }
256-
257- // $this->setDocblock($docblock);
258228 }
259229}
0 commit comments