-
-
Notifications
You must be signed in to change notification settings - Fork 52
Closed
Description
In version 5.0.0, in contrast with 4.0.1, Class_::$usedTraits
is never initialized when using ProjectFactory
.
How to reproduce
index.php
use phpDocumentor\Reflection\File\LocalFile;
use phpDocumentor\Reflection\Php\ProjectFactory;
use phpDocumentor\Reflection\Php\Project;
require __DIR__ . "/vendor/autoload.php";
// Get project files
$files = [
new LocalFile(__DIR__ . '/TestClass.php'),
new LocalFile(__DIR__ . '/TestTrait.php')
];
/** @var Project */
$project = ProjectFactory::createInstance()->create('Project', $files);
// Validate output
$expectedClass = $project->getFiles()[__DIR__ . '/TestClass.php']->getClasses()['\App\TestClass'];
$expectedTrait = $expectedClass->getUsedTraits()['\App\TestTrait'] ?? null;
var_dump($expectedTrait);
TestClass.php
namespace App;
class TestClass {
use TestTrait;
public function sayBye() {
echo "Bye!";
}
}
TestTrait.php
namespace App;
trait TestTrait {
public function sayHi() {
echo "Hi!";
}
}
Output
When using v4.0.1:
object(phpDocumentor\Reflection\Fqsen)#1218 (2) {
["fqsen":"phpDocumentor\Reflection\Fqsen":private]=>
string(14) "\App\TestTrait"
["name":"phpDocumentor\Reflection\Fqsen":private]=>
string(9) "TestTrait"
}
When using v5.0.0:
NULL
Metadata
Metadata
Assignees
Labels
No labels