- WIP on Breadcrumb, AnnotationReader now return #UNKNOWN# if reflection fail

This commit is contained in:
Dave Mc Nicoll 2024-10-07 15:44:00 -04:00
parent 996c8fa14a
commit 133672b347
3 changed files with 30 additions and 16 deletions

View File

@ -99,6 +99,8 @@ class AnnotationReader
case $reflect instanceof ReflectionClass : case $reflect instanceof ReflectionClass :
return $reflect->name; return $reflect->name;
} }
return "#UNKNOWN#";
} }
protected function getObjectNamespace(Reflector $reflect) : string protected function getObjectNamespace(Reflector $reflect) : string

View File

@ -10,6 +10,8 @@ use RuntimeException, DirectoryIterator, Generator;
class Breadcrumb extends RouteFetcher { class Breadcrumb extends RouteFetcher {
public bool $ignoreSoleRoute = true;
public function getRouteTree(\Notes\Route\Attribute\Method\Route $route) : array public function getRouteTree(\Notes\Route\Attribute\Method\Route $route) : array
{ {
$tree = []; $tree = [];
@ -36,7 +38,11 @@ class Breadcrumb extends RouteFetcher {
else { else {
$route = null; $route = null;
} }
}; }
if ($this->ignoreSoleRoute && count($tree) === 1) {
return [];
}
return array_reverse($tree); return array_reverse($tree);
} }

View File

@ -109,28 +109,32 @@ class ObjectReflection {
'name' => $property->getName() 'name' => $property->getName()
]; ];
$current['tags'] = $this->annotationReader->getProperty($property);
if ( $this->ignoreElementAnnotation($current['tags']) ) {
continue;
}
# Default value can be 'null', so isset() it not suitable here # Default value can be 'null', so isset() it not suitable here
if ( array_key_exists($current['name'], $defaultValues) ) { if ( array_key_exists($current['name'], $defaultValues) ) {
$current['value'] = $defaultValues[ $current['name'] ]; $current['value'] = $defaultValues[ $current['name'] ];
} }
if ( $property->hasType() ) { if ( $property->hasType() ) {
$type = $property->getType(); $type = $property->getType();
if (! $type instanceof \ReflectionUnionType ) { if ($type instanceof \ReflectionUnionType ) {
foreach($type->getTypes() as $type) {
# dump($type->getName(), $type->isBuiltin(), $type->allowsNull());
}
}
else {
$current['type'] = $type->getName(); $current['type'] = $type->getName();
$current['builtin'] = $type->isBuiltIn(); $current['builtin'] = $type->isBuiltIn();
$current['nullable'] = $type->allowsNull(); $current['nullable'] = $type->allowsNull();
} }
} }
$current['tags'] = $this->annotationReader->getProperty($property);
if ( $this->ignoreElementAnnotation($current['tags']) ) {
continue;
}
$list[ $current['name'] ] = $current; $list[ $current['name'] ] = $current;
} }
@ -220,6 +224,8 @@ class ObjectReflection {
protected function getUsesStatements() : array protected function getUsesStatements() : array
{ {
return [];
$uses = []; $uses = [];
$tokens = token_get_all( $c = $this->readCode() ); $tokens = token_get_all( $c = $this->readCode() );