PHP | ReflectionExtension getClasses() Function

The ReflectionExtension::getClasses() function is an inbuilt function in PHP which is used to return a list of classes from specified extension. If no classes are specified, an empty array is returned.

Syntax:

array ReflectionExtension::getClasses( void )

Parameters: This function does not accept any parameter.



Return Value: This function returns a list of classes from specified extension.

Below programs illustrate the ReflectionExtension::getClasses() function in PHP:

Program_1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Defining an extension
$A = 'DOM';
  
// Using ReflectionExtension() over the 
// specified extension
$extension = new ReflectionExtension($A);
  
// Calling the getClasses() function
$B = $extension->getClasses();
  
// Getting the list of classes
var_dump($B);
?>

chevron_right


Output:

array(31) {
  ["DOMException"]=>
  object(ReflectionClass)#2 (1) {
    ["name"]=>
    string(12) "DOMException"
  }
  ["DOMStringList"]=>
  object(ReflectionClass)#3 (1) {
    ["name"]=>
    string(13) "DOMStringList"
  }
  ["DOMNameList"]=>
  object(ReflectionClass)#4 (1) {
    ["name"]=>
    string(11) "DOMNameList"
  }
  ["DOMImplementationList"]=>
  object(ReflectionClass)#5 (1) {
    ["name"]=>
    string(21) "DOMImplementationList"
  }
  ["DOMImplementationSource"]=>
  object(ReflectionClass)#6 (1) {
    ["name"]=>
    string(23) "DOMImplementationSource"
  }
  ["DOMImplementation"]=>
  object(ReflectionClass)#7 (1) {
    ["name"]=>
    string(17) "DOMImplementation"
  }
  ["DOMNode"]=>
  object(ReflectionClass)#8 (1) {
    ["name"]=>
    string(7) "DOMNode"
  }
  ["DOMNameSpaceNode"]=>
  object(ReflectionClass)#9 (1) {
    ["name"]=>
    string(16) "DOMNameSpaceNode"
  }
  ["DOMDocumentFragment"]=>
  object(ReflectionClass)#10 (1) {
    ["name"]=>
    string(19) "DOMDocumentFragment"
  }
  ["DOMDocument"]=>
  object(ReflectionClass)#11 (1) {
    ["name"]=>
    string(11) "DOMDocument"
  }
  ["DOMNodeList"]=>
  object(ReflectionClass)#12 (1) {
    ["name"]=>
    string(11) "DOMNodeList"
  }
  ["DOMNamedNodeMap"]=>
  object(ReflectionClass)#13 (1) {
    ["name"]=>
    string(15) "DOMNamedNodeMap"
  }
  ["DOMCharacterData"]=>
  object(ReflectionClass)#14 (1) {
    ["name"]=>
    string(16) "DOMCharacterData"
  }
  ["DOMAttr"]=>
  object(ReflectionClass)#15 (1) {
    ["name"]=>
    string(7) "DOMAttr"
  }
  ["DOMElement"]=>
  object(ReflectionClass)#16 (1) {
    ["name"]=>
    string(10) "DOMElement"
  }
  ["DOMText"]=>
  object(ReflectionClass)#17 (1) {
    ["name"]=>
    string(7) "DOMText"
  }
  ["DOMComment"]=>
  object(ReflectionClass)#18 (1) {
    ["name"]=>
    string(10) "DOMComment"
  }
  ["DOMTypeinfo"]=>
  object(ReflectionClass)#19 (1) {
    ["name"]=>
    string(11) "DOMTypeinfo"
  }
  ["DOMUserDataHandler"]=>
  object(ReflectionClass)#20 (1) {
    ["name"]=>
    string(18) "DOMUserDataHandler"
  }
  ["DOMDomError"]=>
  object(ReflectionClass)#21 (1) {
    ["name"]=>
    string(11) "DOMDomError"
  }
  ["DOMErrorHandler"]=>
  object(ReflectionClass)#22 (1) {
    ["name"]=>
    string(15) "DOMErrorHandler"
  }
  ["DOMLocator"]=>
  object(ReflectionClass)#23 (1) {
    ["name"]=>
    string(10) "DOMLocator"
  }
  ["DOMConfiguration"]=>
  object(ReflectionClass)#24 (1) {
    ["name"]=>
    string(16) "DOMConfiguration"
  }
  ["DOMCdataSection"]=>
  object(ReflectionClass)#25 (1) {
    ["name"]=>
    string(15) "DOMCdataSection"
  }
  ["DOMDocumentType"]=>
  object(ReflectionClass)#26 (1) {
    ["name"]=>
    string(15) "DOMDocumentType"
  }
  ["DOMNotation"]=>
  object(ReflectionClass)#27 (1) {
    ["name"]=>
    string(11) "DOMNotation"
  }
  ["DOMEntity"]=>
  object(ReflectionClass)#28 (1) {
    ["name"]=>
    string(9) "DOMEntity"
  }
  ["DOMEntityReference"]=>
  object(ReflectionClass)#29 (1) {
    ["name"]=>
    string(18) "DOMEntityReference"
  }
  ["DOMProcessingInstruction"]=>
  object(ReflectionClass)#30 (1) {
    ["name"]=>
    string(24) "DOMProcessingInstruction"
  }
  ["DOMStringExtend"]=>
  object(ReflectionClass)#31 (1) {
    ["name"]=>
    string(15) "DOMStringExtend"
  }
  ["DOMXPath"]=>
  object(ReflectionClass)#32 (1) {
    ["name"]=>
    string(8) "DOMXPath"
  }
}

Program_2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Using ReflectionExtension() over 
// a extension xml
$extension = new ReflectionExtension('xml');
  
// Calling the getClasses() function and
// Getting the list of classes
var_dump($extension->getClasses());
?>

chevron_right


Output:

array(0) {
}

Reference: https://www.php.net/manual/en/reflectionextension.getclasses.php



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.