@@ -283,4 +283,19 @@ public function testClassesInAFile(): void {
283283 $ this ->assertSame ('Price ' , $ data ->getClassType ()->getName (), '3rd class type name. ' );
284284 $ this ->assertSame (['hoge ' , 'fuga ' , 'product ' ], $ data ->getClassType ()->getNamespace (), '3rd namespace name. ' );
285285 }
286+ public function testTrait (): void {
287+ $ options = new Options ([]);
288+ $ directory = sprintf ('%s/trait ' , $ this ->fixtureDir );
289+ $ filename = sprintf ('%s/trait/TestTrait.php ' , $ this ->fixtureDir );
290+ $ parsed = PhpReader::parseFile ($ directory , $ filename , $ options );
291+
292+ $ data = $ parsed [0 ]->getInfo ();
293+ $ this ->assertSame ('TestTrait ' , $ data ->getClassType ()->getName (), '1st class type name. ' );
294+ $ this ->assertSame (['Foo ' , 'Traits ' ], $ data ->getClassType ()->getNamespace (), '1st namespace name. ' );
295+ $ this ->assertSame ([], $ data ->getMethods ()[0 ]->getType ()->getTypes ()[0 ]->getNamespace (), 'return type namespace. ' );
296+ $ this ->assertSame ('bool ' , $ data ->getMethods ()[0 ]->getType ()->getTypes ()[0 ]->getName (), 'return type name. ' );
297+ $ this ->assertSame ('name ' , $ data ->getMethods ()[0 ]->getParams ()[0 ]->getName (), 'parameter name. ' );
298+ $ this ->assertSame ('string ' , $ data ->getMethods ()[0 ]->getParams ()[0 ]->getType ()->getName (), 'parameter type. ' );
299+ $ this ->assertSame ([], $ data ->getMethods ()[0 ]->getParams ()[0 ]->getType ()->getTypes ()[0 ]->getNamespace (), 'parameter type namespace. ' );
300+ }
286301}
0 commit comments