Introspection

Introspection in PHP is the ability to examine the properties and behavior of objects, classes, and functions at runtime. It allows code to discover and inspect its own structure.

PHP provides many native introspection functions: get_class(), get_object_vars(), get_class_vars(), get_class_methods(), method_exists(), property_exists(), function_exists(), is_a(), instanceof, and others.

For deeper introspection, the Reflection API provides programmatic access to class hierarchies, method signatures, parameter types, and attributes.

<?php

class Dog {
    public string $name = 'Rex';
    public function bark(): void {}
}

$dog = new Dog();

var_dump(get_class($dog));             // string(3) "Dog"
var_dump(get_object_vars($dog));       // Array ( [name] => Rex )
var_dump(get_class_methods($dog));     // Array ( [0] => bark )
var_dump(method_exists($dog, 'bark')); // bool(true)

?>

Documentation

Related : Reflection, get_class(), get_class_vars(), get_object_vars(), class_implements(), Reflector