diff --git a/src/AnnotationReader.php b/src/AnnotationReader.php index 5d30232..5fdb920 100644 --- a/src/AnnotationReader.php +++ b/src/AnnotationReader.php @@ -99,6 +99,8 @@ class AnnotationReader case $reflect instanceof ReflectionClass : return $reflect->name; } + + return "#UNKNOWN#"; } protected function getObjectNamespace(Reflector $reflect) : string diff --git a/src/Breadcrumb/Breadcrumb.php b/src/Breadcrumb/Breadcrumb.php index d2011d5..ceb27fb 100644 --- a/src/Breadcrumb/Breadcrumb.php +++ b/src/Breadcrumb/Breadcrumb.php @@ -10,6 +10,8 @@ use RuntimeException, DirectoryIterator, Generator; class Breadcrumb extends RouteFetcher { + public bool $ignoreSoleRoute = true; + public function getRouteTree(\Notes\Route\Attribute\Method\Route $route) : array { $tree = []; @@ -36,7 +38,11 @@ class Breadcrumb extends RouteFetcher { else { $route = null; } - }; + } + + if ($this->ignoreSoleRoute && count($tree) === 1) { + return []; + } return array_reverse($tree); } diff --git a/src/ObjectReflection.php b/src/ObjectReflection.php index b773b43..9f28125 100644 --- a/src/ObjectReflection.php +++ b/src/ObjectReflection.php @@ -20,10 +20,10 @@ class ObjectReflection { $this->classname = ltrim($class, '\\'); $this->cache = $cache; - #if ( ! $this->cache || ! $this->cache->has($class) ) { + # if ( ! $this->cache || ! $this->cache->has($class) ) { $this->classReflection = $class instanceof ReflectionClass ? $class : new ReflectionClass($class); $this->annotationReader = $annotationReader ?: AnnotationReader::fromClass($class); - # } + # } } public static function fromClass($class, ? CacheInterface $cache = null) : self @@ -81,11 +81,11 @@ class ObjectReflection { } return array_merge_recursive($class ?? [], $traitTags ?? [], $interfaceTags ?? [], [ - 'tags' => $this->annotationReader->getClass($this->classReflection) - ] + ( ! $full ? [] : [ - 'traits' => array_map($itemName, $traits), - 'interfaces' => array_map($itemName, $interfaces), - ] )); + 'tags' => $this->annotationReader->getClass($this->classReflection) + ] + ( ! $full ? [] : [ + 'traits' => array_map($itemName, $traits), + 'interfaces' => array_map($itemName, $interfaces), + ] )); } public function gatherProperties(bool $full = true, int $filter = @@ -109,28 +109,32 @@ class ObjectReflection { '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 if ( array_key_exists($current['name'], $defaultValues) ) { $current['value'] = $defaultValues[ $current['name'] ]; } - if ( $property->hasType() ) { $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['builtin'] = $type->isBuiltIn(); $current['nullable'] = $type->allowsNull(); } } - $current['tags'] = $this->annotationReader->getProperty($property); - - if ( $this->ignoreElementAnnotation($current['tags']) ) { - continue; - } - $list[ $current['name'] ] = $current; } @@ -220,6 +224,8 @@ class ObjectReflection { protected function getUsesStatements() : array { + return []; + $uses = []; $tokens = token_get_all( $c = $this->readCode() );