ReflectionClass::isAnonymous

(PHP 7)
Checks if class is anonymous
public bool ReflectionClass::isAnonymous ( void )

Checks if a class is an anonymous class.

Returns:

Returns TRUE on success or FALSE on failure.

Examples:
ReflectionClass::isAnonymous() example
1
2
3
4
5
6
7
8
9
10
11
<?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:

ReflectionClass::isFinal() -

doc_php
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.