Skip to content

Commit c48c309

Browse files
committed
Remove PHP 7.0 specific handling
1 parent b3f7473 commit c48c309

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

src/main/php/lang/meta/SyntaxTree.class.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php namespace lang\meta;
22

3+
use ReflectionClass;
34
use lang\IllegalAccessException;
45
use lang\ast\nodes\{Literal, Variable};
56
use lang\ast\{Visitor, Type};
@@ -76,7 +77,7 @@ public function array($self) {
7677
* @return var
7778
*/
7879
public function new($self) {
79-
$c= new \ReflectionClass($this->resolve($self->type));
80+
$c= new ReflectionClass($this->resolve($self->type));
8081
$arguments= [];
8182
foreach ($self->arguments as $key => $node) {
8283
$arguments[$key]= $node->visit($this);
@@ -93,16 +94,13 @@ public function new($self) {
9394
public function scope($self) {
9495
$c= $this->resolve($self->type);
9596

96-
// Use PHP reflection API to access members' runtime values. We cannot use
97-
// getStaticPropertyValue() as it cannot get non-public members in PHP 7.0
97+
// Use PHP reflection API to access members' runtime values
9898
if ($self->member instanceof Variable) {
99-
$p= (new \ReflectionClass($c))->getProperty($self->member->pointer ?? $self->member->name);
100-
$p->setAccessible(true);
101-
return $p->getValue();
99+
return (new ReflectionClass($c))->getStaticPropertyValue($self->member->pointer ?? $self->member->name);
102100
} else if ($self->member instanceof Literal) {
103101
return 'class' === $self->member->expression
104102
? substr($c, 1)
105-
: (new \ReflectionClass($c))->getConstant($self->member->expression)
103+
: (new ReflectionClass($c))->getConstant($self->member->expression)
106104
;
107105
} else {
108106
throw new IllegalAccessException('Cannot resolve '.$type->name.'::'.$self->member->kind);

src/main/php/lang/reflection/Type.class.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,8 @@ public function constants() { return new Constants($this->reflect); }
241241

242242
/** @return ?lang.reflection.Constant */
243243
public function constant($name) {
244-
245-
// Cannot use getReflectionConstant(), which does not exist in PHP 7.0.
246-
// Instantiate the polyfilled ReflectionClassConstant class directly in
247-
// order to make this compatible will all versions.
248244
return $this->reflect->hasConstant($name)
249-
? new Constant(new \ReflectionClassConstant($this->reflect->name, $name))
245+
? new Constant($this->reflect->getReflectionConstant($name))
250246
: null
251247
;
252248
}

0 commit comments

Comments
 (0)