summaryrefslogtreecommitdiff
path: root/Zend/tests/object_types/type_hint_reflection.phpt
blob: c5059e0b680b40128a6b40e1c1526b746da6cd89 (plain)
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
--TEST--
Reflecting object type hint
--FILE--
<?php

interface One {
    public function a(object $obj);
}

class Two implements One {
    public function a(object $obj) {}
}

function a(object $obj) {}

$typeHintOne = (new ReflectionClass(One::class))->getMethod('a')->getParameters()[0]->getType();
var_dump($typeHintOne->isBuiltin(), (string)$typeHintOne);

$typeHintTwo = (new ReflectionClass(Two::class))->getMethod('a')->getParameters()[0]->getType();
var_dump($typeHintTwo->isBuiltin(), (string)$typeHintTwo);

$typeHinta = (new ReflectionFunction('a'))->getParameters()[0]->getType();
var_dump($typeHinta->isBuiltin(), (string)$typeHinta);
--EXPECTF--
bool(true)
string(6) "object"
bool(true)
string(6) "object"
bool(true)
string(6) "object"