diff --git a/src/Common/Reflected.php~ b/src/Common/Reflected.php~ deleted file mode 100644 index 9002648..0000000 --- a/src/Common/Reflected.php~ +++ /dev/null @@ -1,82 +0,0 @@ -attributes, fn($e) => $e->object instanceof Ignore); - } - - public function allowsNull() : bool - { - # dump($this); - return empty($this->type) || $this->expectType("null"); - } - - public function expectType(string $type) : bool - { - $type = strtolower($type); - - foreach($this->getTypes() as $item) { - if ($type === "null") { - if ($item->type === "null" || $item->nullable) { - return true; - } - } - elseif ($type === $item->type) { - return true; - } - } - - return false; - } - - public function getTypes() : array - { - return is_array($this->type) ? $this->type : [ $this->type ]; - } - - public function typeFromReflection(\ReflectionProperty|\ReflectionParameter $property) : void - { - if ( $property->hasType() ) { - $type = $property->getType(); - - if ($type instanceof \ReflectionUnionType ) { - foreach($type->getTypes() as $item) { - $this->type[] = new ReflectedPropertyType($item->getName(), $item->isBuiltIn(), $item->allowsNull()); - } - } - else { - $this->type = new ReflectedPropertyType($type->getName(), $type->isBuiltIn(), $type->allowsNull()); - } - } - } - - public function getAttributes(null|string|array $attributeType = null): array - { - if ($attributeType) { - $list = []; - - foreach($this->attributes as $attribute) { - foreach((array) $attributeType as $type) { - if ($attribute->object instanceof $type) { - $list[] = $attribute; - } - } - } - - return array_reverse($list); - } - - return array_reverse($this->attributes); - } - - public function getAttribute(string|array $attributeType): ?object - { - return $this->getAttributes($attributeType)[0] ?? null; - } -} \ No newline at end of file diff --git a/src/Security/SecurityHandler.php b/src/Security/SecurityHandler.php index 5b07a46..eaa3048 100644 --- a/src/Security/SecurityHandler.php +++ b/src/Security/SecurityHandler.php @@ -66,12 +66,11 @@ class SecurityHandler { $fromObject = $this->findAttributes(Attribute\Taxus::class, $className); $fromMethod = $this->findAttributes(Attribute\Taxus::class, $className, $methodName); - if ($fromMethod || $fromObject) { - if ( $this->taxusGrantPermission($fromMethod, ... $arguments) || $this->taxusGrantPermission($fromObject, ... $arguments) ) { - return true; - } - - return false; + if ($fromMethod) { + return $this->taxusGrantPermission($fromMethod, ... $arguments); + } + elseif ($fromObject) { + return $this->taxusGrantPermission($fromObject, ... $arguments); } return true;