Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 148 Revision 150
Zeile 17... Zeile 17...
17
 */
17
 */
18
final class Reflection
18
final class Reflection
19
{
19
{
20
	use Nette\StaticClass;
20
	use Nette\StaticClass;
Zeile 21... Zeile -...
21
 
-
 
22
	private const BuiltinTypes = [
-
 
23
		'string' => 1, 'int' => 1, 'float' => 1, 'bool' => 1, 'array' => 1, 'object' => 1,
-
 
24
		'callable' => 1, 'iterable' => 1, 'void' => 1, 'null' => 1, 'mixed' => 1, 'false' => 1,
-
 
25
		'never' => 1,
-
 
26
	];
-
 
27
 
-
 
28
	private const ClassKeywords = [
-
 
29
		'self' => 1, 'parent' => 1, 'static' => 1,
-
 
30
	];
-
 
31
 
-
 
32
 
21
 
33
	/**
22
	/**
34
	 * Determines if type is PHP built-in type. Otherwise, it is the class name.
23
	 * Determines if type is PHP built-in type. Otherwise, it is the class name.
35
	 */
24
	 */
36
	public static function isBuiltinType(string $type): bool
25
	public static function isBuiltinType(string $type): bool
37
	{
26
	{
38
		return isset(self::BuiltinTypes[strtolower($type)]);
27
		return Validators::isBuiltinType($type);
Zeile 39... Zeile 28...
39
	}
28
	}
40
 
29
 
41
 
30
 
42
	/**
31
	/**
43
	 * Determines if type is special class name self/parent/static.
32
	 * Determines if type is special class name self/parent/static.
44
	 */
33
	 */
45
	public static function isClassKeyword(string $name): bool
34
	public static function isClassKeyword(string $name): bool
Zeile 46... Zeile 35...
46
	{
35
	{
47
		return isset(self::ClassKeywords[strtolower($name)]);
36
		return Validators::isClassKeyword($name);
Zeile 259... Zeile 248...
259
	{
248
	{
260
		$lower = strtolower($name);
249
		$lower = strtolower($name);
261
		if (empty($name)) {
250
		if (empty($name)) {
262
			throw new Nette\InvalidArgumentException('Class name must not be empty.');
251
			throw new Nette\InvalidArgumentException('Class name must not be empty.');
Zeile 263... Zeile 252...
263
 
252
 
264
		} elseif (isset(self::BuiltinTypes[$lower])) {
253
		} elseif (Validators::isBuiltinType($lower)) {
Zeile 265... Zeile 254...
265
			return $lower;
254
			return $lower;
266
 
255