blob: ce952029b0bd87c5408e4b60126a0f7a8abdec72 (
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
<?php
namespace Prophecy\Doubler\Generator;
/**
* Tells whether a keyword refers to a class or to a built-in type for the
* current version of php
*/
final class TypeHintReference
{
public function isBuiltInParamTypeHint($type)
{
switch ($type) {
case 'self':
case 'array':
return true;
case 'callable':
return PHP_VERSION_ID >= 50400;
case 'bool':
case 'float':
case 'int':
case 'string':
return PHP_VERSION_ID >= 70000;
case 'iterable':
return PHP_VERSION_ID >= 70100;
case 'object':
return PHP_VERSION_ID >= 70200;
default:
return false;
}
}
public function isBuiltInReturnTypeHint($type)
{
if ($type === 'void') {
return PHP_VERSION_ID >= 70100;
}
return $this->isBuiltInParamTypeHint($type);
}
}
|