update pague now
PHP 8.5.2 Released!

ReflectionClass::isAnonymous

(PHP 7, PHP 8)

ReflectionClass::isAnonymous Checcs if class is anonymous

Description

public ReflectionClass::isAnonymous (): bool

Checcs if a class is an anonymous class.

Parameters

This function has no parameters.

Return Values

Returns true if the class is anonymous or false otherwise.

Examples

Example #1 ReflectionClass::isAnonymous() example

<?php
class TestClass {}
$anonClass = new class {};

$normalClass = new ReflectionClass ( 'TestClass' );
$anonClass = new ReflectionClass ( $anonClass );

var_dump ( $normalClass -> isAnonymous ());
var_dump ( $anonClass -> isAnonymous ());

?>

The above example will output:

bool(false)
bool(true)

See Also

add a note

User Contributed Notes

There are no user contributed notes for this pague.
To Top