Mercurial > hg > cmmr2012-drupal-site
comparison vendor/psy/psysh/src/ParserFactory.php @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:11:55 +0000 |
parents | c75dbcec494b |
children |
comparison
equal
deleted
inserted
replaced
3:307d7a7fd348 | 4:a9cd425dd02b |
---|---|
42 * | 42 * |
43 * @return bool | 43 * @return bool |
44 */ | 44 */ |
45 public function hasKindsSupport() | 45 public function hasKindsSupport() |
46 { | 46 { |
47 return class_exists('PhpParser\ParserFactory'); | 47 return \class_exists('PhpParser\ParserFactory'); |
48 } | 48 } |
49 | 49 |
50 /** | 50 /** |
51 * Default kind (if supported, based on current interpreter's version). | 51 * Default kind (if supported, based on current interpreter's version). |
52 * | 52 * |
53 * @return string|null | 53 * @return string|null |
54 */ | 54 */ |
55 public function getDefaultKind() | 55 public function getDefaultKind() |
56 { | 56 { |
57 if ($this->hasKindsSupport()) { | 57 if ($this->hasKindsSupport()) { |
58 return version_compare(PHP_VERSION, '7.0', '>=') ? static::ONLY_PHP7 : static::ONLY_PHP5; | 58 return \version_compare(PHP_VERSION, '7.0', '>=') ? static::ONLY_PHP7 : static::ONLY_PHP5; |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 /** | 62 /** |
63 * New parser instance with given kind. | 63 * New parser instance with given kind. |
71 if ($this->hasKindsSupport()) { | 71 if ($this->hasKindsSupport()) { |
72 $originalFactory = new OriginalParserFactory(); | 72 $originalFactory = new OriginalParserFactory(); |
73 | 73 |
74 $kind = $kind ?: $this->getDefaultKind(); | 74 $kind = $kind ?: $this->getDefaultKind(); |
75 | 75 |
76 if (!in_array($kind, static::getPossibleKinds())) { | 76 if (!\in_array($kind, static::getPossibleKinds())) { |
77 throw new \InvalidArgumentException('Unknown parser kind'); | 77 throw new \InvalidArgumentException('Unknown parser kind'); |
78 } | 78 } |
79 | 79 |
80 $parser = $originalFactory->create(constant('PhpParser\ParserFactory::' . $kind)); | 80 $parser = $originalFactory->create(\constant('PhpParser\ParserFactory::' . $kind)); |
81 } else { | 81 } else { |
82 if ($kind !== null) { | 82 if ($kind !== null) { |
83 throw new \InvalidArgumentException('Install PHP Parser v2.x to specify parser kind'); | 83 throw new \InvalidArgumentException('Install PHP Parser v2.x to specify parser kind'); |
84 } | 84 } |
85 | 85 |