Merge branch 'v2.0.0b' of https://git.mcnd.ca/mcndave/notes into v2.0.0b

This commit is contained in:
Dave Mc Nicoll 2024-10-29 16:00:36 +00:00
commit 08c0ffacab
3 changed files with 20 additions and 12 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

@ -25,8 +25,8 @@ class ObjectReflection {
$this->cache = $cache; $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->classReflection = $class instanceof ReflectionClass ? $class : new ReflectionClass($class);
# } # }
} }
public static function fromClass(ReflectionClass|string $class, ? CacheInterface $cache = null) : self public static function fromClass(ReflectionClass|string $class, ? CacheInterface $cache = null) : self
@ -53,11 +53,11 @@ class ObjectReflection {
traits: array_map(fn($trait) => static::fromClass($trait)->reflectClass(), array_keys($this->classReflection->getTraits())), traits: array_map(fn($trait) => static::fromClass($trait)->reflectClass(), array_keys($this->classReflection->getTraits())),
); );
} }
public function reflectProperties(int $filter = public function reflectProperties(int $filter =
ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_PUBLIC |
ReflectionProperty::IS_PROTECTED | ReflectionProperty::IS_PROTECTED |
ReflectionProperty::IS_PRIVATE ReflectionProperty::IS_PRIVATE
) : array ) : array
{ {
$defaultValues = $this->classReflection->getDefaultProperties(); $defaultValues = $this->classReflection->getDefaultProperties();
@ -87,11 +87,11 @@ class ObjectReflection {
} }
public function reflectMethods(int $filter = public function reflectMethods(int $filter =
ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PUBLIC |
ReflectionMethod::IS_PROTECTED | ReflectionMethod::IS_PROTECTED |
ReflectionMethod::IS_PRIVATE | ReflectionMethod::IS_PRIVATE |
ReflectionMethod::IS_STATIC | ReflectionMethod::IS_STATIC |
ReflectionMethod::IS_FINAL ReflectionMethod::IS_FINAL
) : array ) : array
{ {
$list = []; $list = [];