Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Reflection/Reflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Reflection
*
* @link https://php.net/manual/en/reflection.getmodifiernames.php
* @param int $modifiers Bitfield of the modifiers to get.
* @return string[] An array of modifier names.
* @return list<non-empty-string> An array of modifier names.
*/
#[TentativeType]
public static function getModifierNames(#[LanguageLevelTypeAware(['8.0' => 'int'], default: '')] $modifiers): array {}
Expand Down
11 changes: 7 additions & 4 deletions Reflection/ReflectionAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
/**
* @since 8.0
*
* @template T of object
* @template TAttributeClass of Attribute
*/
class ReflectionAttribute implements Reflector
{
/**
* @var class-string<TAttributeClass>
*/
public string $name;

/**
Expand All @@ -30,7 +33,7 @@ private function __construct() {}
/**
* Gets attribute name
*
* @return string The name of the attribute parameter.
* @return class-string<TAttributeClass> The name of the attribute parameter.
* @since 8.0
*/
#[Pure]
Expand All @@ -57,7 +60,7 @@ public function isRepeated(): bool {}
/**
* Gets list of passed attribute's arguments.
*
* @return array
* @return list<mixed>
* @since 8.0
*/
#[Pure]
Expand All @@ -66,7 +69,7 @@ public function getArguments(): array {}
/**
* Creates a new instance of the attribute with passed arguments
*
* @return T
* @return TAttributeClass
* @since 8.0
*/
public function newInstance(): object {}
Expand Down
66 changes: 33 additions & 33 deletions Reflection/ReflectionClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
use JetBrains\PhpStorm\Pure;

/**
* @template T of object
* The <b>ReflectionClass</b> class reports information about a class.
*
* @link https://php.net/manual/en/class.reflectionclass.php
* @template TReflectedClass of object
*/
class ReflectionClass implements Reflector
{
/**
* @var class-string<T> Name of the class, same as calling the {@see ReflectionClass::getName()} method
* @var class-string<TReflectedClass> Name of the class, same as calling the {@see ReflectionClass::getName()} method
*/
#[Immutable]
#[LanguageLevelTypeAware(['8.1' => 'string'], default: '')]
Expand Down Expand Up @@ -62,7 +62,7 @@ class ReflectionClass implements Reflector
* Constructs a ReflectionClass
*
* @link https://php.net/manual/en/reflectionclass.construct.php
* @param class-string<T>|T $objectOrClass Either a string containing the name of
* @param class-string<TReflectedClass>|TReflectedClass $objectOrClass Either a string containing the name of
* the class to reflect, or an object.
* @throws ReflectionException if the class does not exist.
*/
Expand Down Expand Up @@ -95,7 +95,7 @@ public function __toString(): string {}
* Gets class name
*
* @link https://php.net/manual/en/reflectionclass.getname.php
* @return string The class name.
* @return class-string<TReflectedClass> The class name.
*/
#[Pure]
#[TentativeType]
Expand Down Expand Up @@ -189,7 +189,7 @@ public function getDocComment(): string|false {}
* Gets the constructor of the class
*
* @link https://php.net/manual/en/reflectionclass.getconstructor.php
* @return ReflectionMethod|null A {@see ReflectionMethod} object reflecting
* @return ReflectionMethod<TReflectedClass>|null A {@see ReflectionMethod} object reflecting
* the class' constructor, or {@see null} if the class has no constructor.
*/
#[Pure]
Expand All @@ -210,8 +210,8 @@ public function hasMethod(#[LanguageLevelTypeAware(['8.0' => 'string'], default:
* Gets a <b>ReflectionMethod</b> for a class method.
*
* @link https://php.net/manual/en/reflectionclass.getmethod.php
* @param string $name The method name to reflect.
* @return ReflectionMethod A {@see ReflectionMethod}
* @param non-empty-string $name The method name to reflect.
* @return ReflectionMethod<TReflectedClass> A {@see ReflectionMethod}
* @throws ReflectionException if the method does not exist.
*/
#[Pure]
Expand All @@ -224,7 +224,7 @@ public function getMethod(#[LanguageLevelTypeAware(['8.0' => 'string'], default:
* @link https://php.net/manual/en/reflectionclass.getmethods.php
* @param int|null $filter Filter the results to include only methods
* with certain attributes. Defaults to no filtering.
* @return ReflectionMethod[] An array of {@see ReflectionMethod} objects
* @return list<ReflectionMethod<TReflectedClass>> An array of {@see ReflectionMethod} objects
* reflecting each method.
*/
#[Pure]
Expand All @@ -245,8 +245,8 @@ public function hasProperty(#[LanguageLevelTypeAware(['8.0' => 'string'], defaul
* Gets a <b>ReflectionProperty</b> for a class's property
*
* @link https://php.net/manual/en/reflectionclass.getproperty.php
* @param string $name The property name.
* @return ReflectionProperty A {@see ReflectionProperty}
* @param non-empty-string $name The property name.
* @return ReflectionProperty<TReflectedClass> A {@see ReflectionProperty}
* @throws ReflectionException If no property exists by that name.
*/
#[Pure]
Expand All @@ -260,7 +260,7 @@ public function getProperty(#[LanguageLevelTypeAware(['8.0' => 'string'], defaul
* @param int|null $filter The optional filter, for filtering desired
* property types. It's configured using the {@see ReflectionProperty} constants,
* and defaults to all property types.
* @return ReflectionProperty[]
* @return list<ReflectionProperty<TReflectedClass>>
*/
#[Pure]
#[TentativeType]
Expand All @@ -270,8 +270,8 @@ public function getProperties(#[LanguageLevelTypeAware(['8.0' => 'int|null'], de
* Gets a ReflectionClassConstant for a class's property
*
* @link https://php.net/manual/en/reflectionclass.getreflectionconstant.php
* @param string $name The class constant name.
* @return ReflectionClassConstant|false A {@see ReflectionClassConstant}.
* @param non-empty-string $name The class constant name.
* @return ReflectionClassConstant<TReflectedClass>|false A {@see ReflectionClassConstant}.
* @since 7.1
*/
#[Pure]
Expand All @@ -283,7 +283,7 @@ public function getReflectionConstant(string $name): ReflectionClassConstant|fal
*
* @link https://php.net/manual/en/reflectionclass.getreflectionconstants.php
* @param int|null $filter [optional] allows the filtering of constants defined in a class by their visibility. Since 8.0.
* @return ReflectionClassConstant[] An array of ReflectionClassConstant objects.
* @return list<ReflectionClassConstant<TReflectedClass>> An array of ReflectionClassConstant objects.
* @since 7.1
*/
#[Pure]
Expand All @@ -305,7 +305,7 @@ public function hasConstant(#[LanguageLevelTypeAware(['8.0' => 'string'], defaul
*
* @link https://php.net/manual/en/reflectionclass.getconstants.php
* @param int|null $filter [optional] allows the filtering of constants defined in a class by their visibility. Since 8.0.
* @return array An array of constants, where the keys hold the name and
* @return array<non-empty-string, mixed> An array of constants, where the keys hold the name and
* the values the value of the constants.
*/
#[Pure]
Expand All @@ -316,7 +316,7 @@ public function getConstants(#[PhpStormStubsElementAvailable(from: '8.0')] ?int
* Gets defined constant
*
* @link https://php.net/manual/en/reflectionclass.getconstant.php
* @param string $name Name of the constant.
* @param non-empty-string $name Name of the constant.
* @return mixed|false Value of the constant with the name name.
* Returns {@see false} if the constant was not found in the class.
*/
Expand All @@ -328,7 +328,7 @@ public function getConstant(#[LanguageLevelTypeAware(['8.0' => 'string'], defaul
* Gets the interfaces
*
* @link https://php.net/manual/en/reflectionclass.getinterfaces.php
* @return ReflectionClass[] An associative array of interfaces, with keys as interface
* @return list<ReflectionClass> An associative array of interfaces, with keys as interface
* names and the array values as {@see ReflectionClass} objects.
*/
#[Pure]
Expand All @@ -339,7 +339,7 @@ public function getInterfaces(): array {}
* Gets the interface names
*
* @link https://php.net/manual/en/reflectionclass.getinterfacenames.php
* @return string[] A numerical array with interface names as the values.
* @return list<class-string> A numerical array with interface names as the values.
*/
#[Pure]
#[TentativeType]
Expand Down Expand Up @@ -370,7 +370,7 @@ public function isInterface(): bool {}
* Returns an array of traits used by this class
*
* @link https://php.net/manual/en/reflectionclass.gettraits.php
* @return ReflectionClass[] an array with trait names in keys and
* @return list<ReflectionClass> an array with trait names in keys and
* instances of trait's {@see ReflectionClass} in values.
* @since 5.4
*/
Expand All @@ -382,7 +382,7 @@ public function getTraits(): array {}
* Returns an array of names of traits used by this class
*
* @link https://php.net/manual/en/reflectionclass.gettraitnames.php
* @return string[] An array with trait names in values.
* @return list<class-string> An array with trait names in values.
* Returns {@see null} in case of an error.
* @since 5.4
*/
Expand All @@ -394,7 +394,7 @@ public function getTraitNames(): array {}
* Returns an array of trait aliases
*
* @link https://php.net/manual/en/reflectionclass.gettraitaliases.php
* @return string[] an array with new method names in keys and original
* @return array<non-empty-string, non-empty-string> an array with new method names in keys and original
* names (in the format "TraitName::original") in values.
* Returns {@see null} in case of an error.
* @since 5.4
Expand Down Expand Up @@ -469,7 +469,7 @@ public function isInstance(#[LanguageLevelTypeAware(['8.0' => 'object'], default
* @link https://php.net/manual/en/reflectionclass.newinstance.php
* @param mixed ...$args Accepts a variable number of arguments which are
* passed to the class constructor, much like {@see call_user_func}
* @return T a new instance of the class.
* @return TReflectedClass a new instance of the class.
* @throws ReflectionException if the class constructor is not public or if
* the class does not have a constructor and the $args parameter contains
* one or more parameters.
Expand All @@ -480,7 +480,7 @@ public function newInstance(...$args) {}
* Creates a new class instance without invoking the constructor.
*
* @link https://php.net/manual/en/reflectionclass.newinstancewithoutconstructor.php
* @return T a new instance of the class.
* @return TReflectedClass a new instance of the class.
* @throws ReflectionException if the class is an internal class that
* cannot be instantiated without invoking the constructor. In PHP 5.6.0
* onwards, this exception is limited only to internal classes that are final.
Expand All @@ -494,7 +494,7 @@ public function newInstanceWithoutConstructor(): object {}
*
* @link https://php.net/manual/en/reflectionclass.newinstanceargs.php
* @param array $args The parameters to be passed to the class constructor as an array.
* @return T|null a new instance of the class.
* @return TReflectedClass|null a new instance of the class.
* @throws ReflectionException if the class constructor is not public or if
* the class does not have a constructor and the $args parameter contains
* one or more parameters.
Expand Down Expand Up @@ -530,7 +530,7 @@ public function isSubclassOf(#[LanguageLevelTypeAware(['8.0' => 'ReflectionClass
* Gets static properties
*
* @link https://php.net/manual/en/reflectionclass.getstaticproperties.php
* @return array|null The static properties, as an array where the keys hold
* @return array<non-empty-string, mixed>|null The static properties, as an array where the keys hold
* the name and the values the value of the properties.
*/
#[Pure]
Expand All @@ -542,7 +542,7 @@ public function getStaticProperties() {}
* Gets static property value
*
* @link https://php.net/manual/en/reflectionclass.getstaticpropertyvalue.php
* @param string $name The name of the static property for which to return a value.
* @param non-empty-string $name The name of the static property for which to return a value.
* @param mixed $default [optional] A default value to return in case the class does
* not declare a static property with the given name. If the property does
* not exist and this argument is omitted, a {@see ReflectionException} is thrown.
Expand All @@ -559,7 +559,7 @@ public function getStaticPropertyValue(
* Sets static property value
*
* @link https://php.net/manual/en/reflectionclass.setstaticpropertyvalue.php
* @param string $name Property name.
* @param non-empty-string $name Property name.
* @param mixed $value New property value.
* @return void No value is returned.
*/
Expand All @@ -573,7 +573,7 @@ public function setStaticPropertyValue(
* Gets default properties
*
* @link https://php.net/manual/en/reflectionclass.getdefaultproperties.php
* @return mixed[] An array of default properties, with the key being the name
* @return array<non-empty-string, mixed> An array of default properties, with the key being the name
* of the property and the value being the default value of the property
* or {@see null} if the property doesn't have a default value. The function
* does not distinguish between static and non static properties and does
Expand Down Expand Up @@ -659,20 +659,20 @@ public function getNamespaceName(): string {}
* Gets short name
*
* @link https://php.net/manual/en/reflectionclass.getshortname.php
* @return string The class short name.
* @return non-empty-string The class short name.
*/
#[Pure]
#[TentativeType]
public function getShortName(): string {}

/**
* @template T
* @template TAttributeClass of Attribute
*
* Returns an array of class attributes.
*
* @param class-string<T>|null $name Name of an attribute class
* @param class-string<TAttributeClass>|null $name Name of an attribute class
* @param int $flags Сriteria by which the attribute is searched.
* @return ReflectionAttribute<T>[]
* @return list<ReflectionAttribute<TAttributeClass>>
* @since 8.0
*/
#[Pure]
Expand Down Expand Up @@ -705,7 +705,7 @@ public function isEnum(): bool {}
public function newLazyGhost(callable $initializer, int $options = 0): object {}

/**
* @return T
* @return TReflectedClass
* @since 8.4
*/
public function newLazyProxy(callable $factory, int $options = 0): object {}
Expand Down
17 changes: 9 additions & 8 deletions Reflection/ReflectionClassConstant.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@
*
* @link https://www.php.net/manual/en/class.reflectionclassconstant.php
* @since 7.1
* @template TReflectedClass of object
*/
class ReflectionClassConstant implements Reflector
{
/**
* @var string Constant name, same as calling the {@see ReflectionClassConstant::getName()} method
* @var non-empty-string Constant name, same as calling the {@see ReflectionClassConstant::getName()} method
*/
#[Immutable]
#[LanguageLevelTypeAware(['8.1' => 'string'], default: '')]
public $name;

/**
* @var class-string Fully qualified class name where this constant was defined
* @var class-string<TReflectedClass> Fully qualified class name where this constant was defined
*/
#[Immutable]
#[LanguageLevelTypeAware(['8.1' => 'string'], default: '')]
Expand Down Expand Up @@ -65,8 +66,8 @@ class ReflectionClassConstant implements Reflector
/**
* ReflectionClassConstant constructor.
*
* @param class-string|object $class Either a string containing the name of the class to reflect, or an object.
* @param string $constant The name of the class constant.
* @param class-string<TReflectedClass>|TReflectedClass $class Either a string containing the name of the class to reflect, or an object.
* @param non-empty-string $constant The name of the class constant.
* @since 7.1
* @link https://php.net/manual/en/reflectionclassconstant.construct.php
*/
Expand Down Expand Up @@ -123,7 +124,7 @@ public function getModifiers(): int {}
* Get name of the constant
*
* @link https://php.net/manual/en/reflectionclassconstant.getname.php
* @return string Returns the constant's name.
* @return non-empty-string Returns the constant's name.
* @since 7.1
*/
#[Pure]
Expand Down Expand Up @@ -184,13 +185,13 @@ public function isPublic(): bool {}
public function __toString(): string {}

/**
* @template T
* @template TAttributeClass of Attribute
*
* Returns an array of constant attributes.
*
* @param class-string<T>|null $name Name of an attribute class
* @param class-string<TAttributeClass>|null $name Name of an attribute class
* @param int $flags Сriteria by which the attribute is searched.
* @return ReflectionAttribute<T>[]
* @return list<ReflectionAttribute<TAttributeClass>>
* @since 8.0
*/
#[Pure]
Expand Down
7 changes: 7 additions & 0 deletions Reflection/ReflectionConstant.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ public function getExtension(): ?ReflectionExtension {}
public function getExtensionName(): string|false {}

/**
* @template TAttributeClass of Attribute
*
* Returns an array of extension attributes.
*
* @param class-string<TAttributeClass>|null $name Name of an attribute class
* @param int $flags Сriteria by which the attribute is searched.
* @return list<ReflectionAttribute<TAttributeClass>>
* @since 8.5
*/
public function getAttributes(?string $name = null, int $flags = 0): array {}
Expand Down
Loading
Loading