Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to list all PHP classes and their methods and properties?

Tags:

oop

php

I'm making the leap to OOP with my PHP. Is there a way to list all active classes and their methods and properties?

like image 470
Cyrcle Avatar asked Mar 03 '10 10:03

Cyrcle


People also ask

How can I see all class methods in PHP?

PHP | get_class_methods() Function The get_class_methods() function is an inbuilt function in PHP which is used to get the class method names. Parameters: This function accepts a single parameter $class_name which holds the class name or an object instance.

How can we access properties and methods of a class in PHP?

Once you have an object, you can use the -> notation to access methods and properties of the object: $object -> propertyname $object -> methodname ([ arg, ... ] ) Methods are functions, so they can take arguments and return a value: $clan = $rasmus->family('extended');

What are the properties of PHP?

In PHP, a property is qualified by one of the access specifier keywords, public, private or protected. Name of property could be any valid label in PHP. Value of property can be different for each instance of class. That's why it is sometimes referred as instance variable.


2 Answers

Complete list of similar functions :)

Quick Look:

get_declared_classes() // gives you all declared classes
get_class_methods() // gives you all methods of class
get_class_vars() // gives you properties of the class
get_object_vars() // gives you propertis of an object
get_parent_class()  // gives you parent class of the current class
like image 59
Sarfraz Avatar answered Oct 02 '22 16:10

Sarfraz


Also, you might be interested in the Reflection API offered by PHP.

As they claim in their introduction:

PHP 5 comes with a complete reflection API that adds the ability to reverse-engineer classes, interfaces, functions, methods and extensions. Additionally, the reflection API offers ways to retrieve doc comments for functions, classes and methods.

like image 42
Roberto Aloi Avatar answered Oct 02 '22 17:10

Roberto Aloi