-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
49 lines (39 loc) · 1.26 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
use ReflectionClass as GlobalReflectionClass;
class UserClass
{
public $name;
public $email;
protected $password;
public function show()
{
return [
'Name' => $this->name,
'Email' => $this->email,
'Password' => $this->password,
];
}
public function store()
{
$this->name = 'Mahmoud Mohamed Ramadan';
$this->email = '[email protected]';
$this->password = md5('admin');
}
public function update()
{
$this->name = 'Mahmoud Ramadan';
$this->email = '[email protected]';
$this->password = md5('developer');
}
}
$userObject = new UserClass();
$reflectionClassObject = new GlobalReflectionClass($userObject);
$reflectionMethodsObject = new ReflectionMethod($userObject, 'show');
echo '<pre>';
// This object allows you to get all info about passed method
// by passing a classObject in first param and methodName in string in second param
print_r($reflectionMethodsObject);
// `getMethods` method to get all methods inside object which you pass
print_r($reflectionClassObject->getMethods());
// `getProperties` method to get all properties inside object which you pass
print_r($reflectionClassObject->getProperties());