repl.it
@nguyenvanduocit/

reflectGetInterfaceNames

PHP (Legacy)

No description

fork
loading
main.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
interface Vehicle {
  
}

class Car implements Vehicle{
    private $people = array();
    private $capacity;

    public function __construct($capacity) {
      $this->capacity = $capacity;
    }

    public function addPerson($name) {
        if(count($this->people) >= $this->capacity) {
            throw new Exception("Car is already at capacity");
        } else {
            $this->people[] = $name;
        }
    }
    
    public function getPeople() {
      return $this->people; 
    }
    
    public function getCapacity() {
      return $this->capacity;
    }
}

$reflect = new ReflectionClass(new Car(12));
var_dump($reflect->getInterfaceNames());
PHP 7.0.8 (Legacy: use the following for new features: Command-line PHP: https://repl.it/languages/php_cli PHP Web Server: https://repl.it/languages/php7