Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
core\attribute_helper Class Reference

Static Public Member Functions

static from (array|string|object $reference, ?string $attributename=null, int $attributeflags=ReflectionAttribute::IS_INSTANCEOF,)
 Get the attribute from a reference.
 
static instance (array|string|object $reference, ?string $attributename=null, int $attributeflags=ReflectionAttribute::IS_INSTANCEOF,)
 Get an instance of an attribute from a reference.
 
static instances (array|string|object $reference, ?string $attributename=null, int $attributeflags=ReflectionAttribute::IS_INSTANCEOF,)
 Get all instance of an attribute from a reference.
 
static one_from (array|string|object $reference, ?string $attributename=null, int $attributeflags=ReflectionAttribute::IS_INSTANCEOF,)
 Get one attribute from a reference.
 

Static Protected Member Functions

static from_reflected_object (ReflectionClass $rc, ?string $referenceproperty, ?string $attributename=null, int $flags=0,)
 Fetch an attribute from a reflected object.
 

Member Function Documentation

◆ from()

static core\attribute_helper::from ( array|string|object $reference,
?string $attributename = null,
int $attributeflags = ReflectionAttribute::IS_INSTANCEOF )
static

Get the attribute from a reference.

The reference can be:

  • a string, in which case it will be checked for a function, class, method, property, constant, or enum.
  • an array
  • an instantiated object, in which case the object will be checked for a class, method, property, or constant.
Parameters
array | string | object$referenceA reference of where to find the attribute
null | string$attributenameThe name of the attribute to find
int$attributeflagsThe flags to use when finding the attribute
Return values
ReflectionAttribute[]|null

◆ from_reflected_object()

static core\attribute_helper::from_reflected_object ( ReflectionClass $rc,
?string $referenceproperty,
?string $attributename = null,
int $flags = 0 )
staticprotected

Fetch an attribute from a reflected object.

Parameters
ReflectionClass$rcThe reflected object
null | string$referencepropertyThe name of the thing to find attributes on
null | string$attributenameThe name of the attribute to find
int$attributeflagsThe flags to use when finding the attribute
Return values
ReflectionAttribute[]|null

◆ instance()

static core\attribute_helper::instance ( array|string|object $reference,
?string $attributename = null,
int $attributeflags = ReflectionAttribute::IS_INSTANCEOF )
static

Get an instance of an attribute from a reference.

The reference can be:

  • a string, in which case it will be checked for a function, class, method, property, constant, or enum.
  • an array
  • an instantiated object, in which case the object will be checked for a class, method, property, or constant.
Parameters
array | string | object$referenceA reference of where to find the attribute
null | string$attributenameThe name of the attribute to find
int$attributeflagsThe flags to use when finding the attribute
Return values
?object

◆ instances()

static core\attribute_helper::instances ( array|string|object $reference,
?string $attributename = null,
int $attributeflags = ReflectionAttribute::IS_INSTANCEOF )
static

Get all instance of an attribute from a reference.

The reference can be:

  • a string, in which case it will be checked for a function, class, method, property, constant, or enum.
  • an array
  • an instantiated object, in which case the object will be checked for a class, method, property, or constant.
Parameters
array | string | object$referenceA reference of where to find the attribute
null | string$attributenameThe name of the attribute to find
int$attributeflagsThe flags to use when finding the attribute
Return values
?object[]

◆ one_from()

static core\attribute_helper::one_from ( array|string|object $reference,
?string $attributename = null,
int $attributeflags = ReflectionAttribute::IS_INSTANCEOF )
static

Get one attribute from a reference.

The reference can be:

  • a string, in which case it will be checked for a function, class, method, property, constant, or enum.
  • an array
  • an instantiated object, in which case the object will be checked for a class, method, property, or constant.
Parameters
array | string | object$referenceA reference of where to find the attribute
null | string$attributenameThe name of the attribute to find
int$attributeflagsThe flags to use when finding the attribute
Return values
ReflectionAttribute|null

The documentation for this class was generated from the following file: