Skip to main content

reflect

Jump to function (11)

reflect/attributes#

(attributes obj-or-class)

Returns the class-level attribute maps for obj-or-class; an instance uses its class. Convenience alias of class-attributes.

Example:

(attributes my-controller)

reflect/class-attributes#

(class-attributes class-or-name)

Returns a vector of attribute maps for the class class-or-name (string FQN or object). Each map is {:name <attribute-fqcn> :args {...}}, where :args keys named arguments as keywords and positional arguments by index.

Example:

(class-attributes \App\Controller\ProductController)

reflect/class-info#

(class-info class-or-name)

Returns a map describing class-or-name with :name, :methods, :properties, :parents, and :interfaces keys.

Example:

(class-info \DateTime)

reflect/enum->keyword#

(enum->keyword enum-case)

Returns the keyword for a native PHP enum enum-case, using the case name verbatim (Status/Active => :Active). Round-trips with keyword->enum.

Example:

(enum->keyword Status/Active)

reflect/enum-values#

(enum-values enum-class)

Returns a vector of keywords, one per case of the native PHP enum enum-class (string FQN), in declaration order.

Example:

(enum-values \App\Status)

reflect/keyword->enum#

(keyword->enum enum-class kw)

Returns the case of the native PHP enum enum-class (string FQN) whose name matches keyword kw, or nil when no case matches. Inverse of enum->keyword.

Example:

(keyword->enum \App\Status :Active)

reflect/method-attributes#

(method-attributes class-or-name method-name)

Returns a vector of attribute maps for method method-name on class-or-name.

Example:

(method-attributes \App\Foo "handle")

reflect/methods#

(methods class-or-name)

Returns a vector of method maps for class-or-name. Each map contains :name, :params, :return-type, :static?, and :visibility.

Example:

(methods DateTime)

reflect/properties#

(properties class-or-name)

Returns a vector of property maps for class-or-name. Each map contains :name, :type, :static?, :readonly?, and :visibility.

Example:

(properties \DateInterval)

reflect/property-attributes#

(property-attributes class-or-name property-name)

Returns a vector of attribute maps for property property-name on class-or-name.

Example:

(property-attributes \App\Foo "id")

reflect/supers#

(supers class-or-name)

Returns a set of fully qualified parent classes and implemented interfaces for class-or-name.

Example:

(supers \RuntimeException)