From daf9d9f8be22c84eb040a49550ade0f012136567 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 15 Jan 2024 22:20:23 +0700 Subject: [PATCH] fix various return type --- src/ReflectionClassConstant.php | 6 +++--- src/ReflectionFunction.php | 2 +- src/ReflectionMethod.php | 18 +++++++++--------- src/ReflectionNamedType.php | 8 ++++---- src/ReflectionParameter.php | 16 ++++++++-------- src/ReflectionProperty.php | 16 ++++++++-------- src/ReflectionType.php | 2 +- src/Traits/ReflectionClassLikeTrait.php | 14 +++++++------- 8 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/ReflectionClassConstant.php b/src/ReflectionClassConstant.php index 6bc07a7c..0ea30812 100644 --- a/src/ReflectionClassConstant.php +++ b/src/ReflectionClassConstant.php @@ -166,7 +166,7 @@ public function getValue() /** * @inheritDoc */ - public function isPrivate() + public function isPrivate(): bool { return $this->classConstantNode->isPrivate(); } @@ -174,7 +174,7 @@ public function isPrivate() /** * @inheritDoc */ - public function isProtected() + public function isProtected(): bool { return $this->classConstantNode->isProtected(); } @@ -182,7 +182,7 @@ public function isProtected() /** * @inheritDoc */ - public function isPublic() + public function isPublic(): bool { return $this->classConstantNode->isPublic(); } diff --git a/src/ReflectionFunction.php b/src/ReflectionFunction.php index 7a3d74c3..fece905a 100644 --- a/src/ReflectionFunction.php +++ b/src/ReflectionFunction.php @@ -100,7 +100,7 @@ public function invokeArgs(array $args) * Only internal functions can be disabled using disable_functions directive. * User-defined functions are unaffected. */ - public function isDisabled() + public function isDisabled(): bool { return false; } diff --git a/src/ReflectionMethod.php b/src/ReflectionMethod.php index b5f5d1a2..f22fd555 100644 --- a/src/ReflectionMethod.php +++ b/src/ReflectionMethod.php @@ -222,7 +222,7 @@ public function invokeArgs(?object $object, array $args): mixed /** * {@inheritDoc} */ - public function isAbstract() + public function isAbstract(): bool { return $this->getDeclaringClass()->isInterface() || $this->getClassMethodNode()->isAbstract(); } @@ -230,7 +230,7 @@ public function isAbstract() /** * {@inheritDoc} */ - public function isConstructor() + public function isConstructor(): bool { return $this->getClassMethodNode()->name->toLowerString() === '__construct'; } @@ -238,7 +238,7 @@ public function isConstructor() /** * {@inheritDoc} */ - public function isDestructor() + public function isDestructor(): bool { return $this->getClassMethodNode()->name->toLowerString() === '__destruct'; } @@ -246,7 +246,7 @@ public function isDestructor() /** * {@inheritDoc} */ - public function isFinal() + public function isFinal(): bool { return $this->getClassMethodNode()->isFinal(); } @@ -254,7 +254,7 @@ public function isFinal() /** * {@inheritDoc} */ - public function isPrivate() + public function isPrivate(): bool { return $this->getClassMethodNode()->isPrivate(); } @@ -262,7 +262,7 @@ public function isPrivate() /** * {@inheritDoc} */ - public function isProtected() + public function isProtected(): bool { return $this->getClassMethodNode()->isProtected(); } @@ -270,7 +270,7 @@ public function isProtected() /** * {@inheritDoc} */ - public function isPublic() + public function isPublic(): bool { return $this->getClassMethodNode()->isPublic(); } @@ -278,7 +278,7 @@ public function isPublic() /** * {@inheritDoc} */ - public function isStatic() + public function isStatic(): bool { return $this->getClassMethodNode()->isStatic(); } @@ -286,7 +286,7 @@ public function isStatic() /** * {@inheritDoc} */ - public function setAccessible($accessible) + public function setAccessible($accessible): void { $this->initializeInternalReflection(); diff --git a/src/ReflectionNamedType.php b/src/ReflectionNamedType.php index 569be319..9098825e 100644 --- a/src/ReflectionNamedType.php +++ b/src/ReflectionNamedType.php @@ -51,7 +51,7 @@ public function __construct($type, $allowsNull, $isBuiltin) /** * @inheritDoc */ - public function allowsNull() + public function allowsNull(): bool { return $this->allowsNull; } @@ -59,7 +59,7 @@ public function allowsNull() /** * @inheritDoc */ - public function isBuiltin() + public function isBuiltin(): bool { return $this->isBuiltin; } @@ -67,7 +67,7 @@ public function isBuiltin() /** * @inheritDoc */ - public function __toString() + public function __toString(): string { return $this->type; } @@ -75,7 +75,7 @@ public function __toString() /** * @inheritDoc */ - public function getName() + public function getName(): string { return $this->type; } diff --git a/src/ReflectionParameter.php b/src/ReflectionParameter.php index a9711cde..9e35ba20 100644 --- a/src/ReflectionParameter.php +++ b/src/ReflectionParameter.php @@ -260,7 +260,7 @@ public function getDefaultValueConstantName() /** * @inheritDoc */ - public function getName() + public function getName(): string { return (string)$this->parameterNode->var->name; } @@ -312,7 +312,7 @@ public function hasType() /** * @inheritDoc */ - public function isArray() + public function isArray(): bool { $type = $this->parameterNode->type; @@ -322,7 +322,7 @@ public function isArray() /** * @inheritDoc */ - public function isCallable() + public function isCallable(): bool { $type = $this->parameterNode->type; @@ -332,7 +332,7 @@ public function isCallable() /** * @inheritDoc */ - public function isDefaultValueAvailable() + public function isDefaultValueAvailable(): bool { return isset($this->parameterNode->default); } @@ -340,7 +340,7 @@ public function isDefaultValueAvailable() /** * {@inheritDoc} */ - public function isDefaultValueConstant() + public function isDefaultValueConstant(): bool { return $this->isDefaultValueConstant; } @@ -348,7 +348,7 @@ public function isDefaultValueConstant() /** * {@inheritDoc} */ - public function isOptional() + public function isOptional(): bool { return $this->isVariadic() || ($this->isDefaultValueAvailable() && $this->haveSiblingsDefaultValues()); } @@ -356,7 +356,7 @@ public function isOptional() /** * @inheritDoc */ - public function isPassedByReference() + public function isPassedByReference(): bool { return (bool) $this->parameterNode->byRef; } @@ -364,7 +364,7 @@ public function isPassedByReference() /** * @inheritDoc */ - public function isVariadic() + public function isVariadic(): bool { return (bool) $this->parameterNode->variadic; } diff --git a/src/ReflectionProperty.php b/src/ReflectionProperty.php index f5ad7a9c..6f823916 100644 --- a/src/ReflectionProperty.php +++ b/src/ReflectionProperty.php @@ -174,7 +174,7 @@ public function getModifiers(): int /** * @inheritDoc */ - public function getName() + public function getName(): string { return $this->propertyNode->name->toString(); } @@ -202,7 +202,7 @@ public function getValue($object = null) /** * @inheritDoc */ - public function isDefault() + public function isDefault(): bool { // TRUE if the property was declared at compile-time @@ -212,7 +212,7 @@ public function isDefault() /** * {@inheritDoc} */ - public function isPrivate() + public function isPrivate(): bool { return $this->propertyTypeNode->isPrivate(); } @@ -220,7 +220,7 @@ public function isPrivate() /** * {@inheritDoc} */ - public function isProtected() + public function isProtected(): bool { return $this->propertyTypeNode->isProtected(); } @@ -228,7 +228,7 @@ public function isProtected() /** * {@inheritDoc} */ - public function isPublic() + public function isPublic(): bool { return $this->propertyTypeNode->isPublic(); } @@ -236,7 +236,7 @@ public function isPublic() /** * {@inheritDoc} */ - public function isStatic() + public function isStatic(): bool { return $this->propertyTypeNode->isStatic(); } @@ -244,7 +244,7 @@ public function isStatic() /** * {@inheritDoc} */ - public function setAccessible($accessible) + public function setAccessible($accessible): void { $this->initializeInternalReflection(); @@ -254,7 +254,7 @@ public function setAccessible($accessible) /** * @inheritDoc */ - public function setValue($object, $value = null) + public function setValue($object, $value = null): void { $this->initializeInternalReflection(); diff --git a/src/ReflectionType.php b/src/ReflectionType.php index fd4572de..31f34fee 100644 --- a/src/ReflectionType.php +++ b/src/ReflectionType.php @@ -61,7 +61,7 @@ public function allowsNull() /** * @inheritDoc */ - public function isBuiltin() + public function isBuiltin(): bool { return $this->isBuiltin; } diff --git a/src/Traits/ReflectionClassLikeTrait.php b/src/Traits/ReflectionClassLikeTrait.php index ee92b577..a90bb063 100644 --- a/src/Traits/ReflectionClassLikeTrait.php +++ b/src/Traits/ReflectionClassLikeTrait.php @@ -435,7 +435,7 @@ public function getModifiers(): int /** * {@inheritDoc} */ - public function getName() + public function getName(): string { $namespaceName = $this->namespaceName ? $this->namespaceName . '\\' : ''; @@ -445,7 +445,7 @@ public function getName() /** * {@inheritDoc} */ - public function getNamespaceName() + public function getNamespaceName(): string { return $this->namespaceName; } @@ -705,7 +705,7 @@ public function implementsInterface($interfaceName) /** * {@inheritDoc} */ - public function inNamespace() + public function inNamespace(): bool { return !empty($this->namespaceName); } @@ -713,7 +713,7 @@ public function inNamespace() /** * {@inheritDoc} */ - public function isAbstract() + public function isAbstract(): bool { if ($this->classLikeNode instanceof Class_ && $this->classLikeNode->isAbstract()) { return true; @@ -729,7 +729,7 @@ public function isAbstract() /** * Currently, anonymous classes aren't supported for parsed reflection */ - public function isAnonymous() + public function isAnonymous(): bool { return false; } @@ -737,7 +737,7 @@ public function isAnonymous() /** * {@inheritDoc} */ - public function isCloneable() + public function isCloneable(): bool { if ($this->isInterface() || $this->isTrait() || $this->isAbstract()) { return false; @@ -755,7 +755,7 @@ public function isCloneable() /** * {@inheritDoc} */ - public function isFinal() + public function isFinal(): bool { $isFinal = $this->classLikeNode instanceof Class_ && $this->classLikeNode->isFinal();