Skip to content

Instantly share code, notes, and snippets.

"inspect" keyword in PHP

The new inspect keyword is supposed to create bridge between generic type and variable inspection versus full-fledged reflection introspection. Hopefully this keyword can provide a replacement for a bunch of functions from https://www.php.net/manual/en/ref.var.php and https://www.php.net/manual/en/ref.classobj.php, while also making it fairly simple to get Reflection information of the variable.

I'm not sure at all if this is feasible or performance wise doable or even faster than the current implementations, it's merely an idea that popped up after a discussion on slack.

Examples for basic type usage

$foo = 1;