Skip to content

Commit 4a35832

Browse files
committed
Test against target version, not runtime version
1 parent 28403bd commit 4a35832

File tree

6 files changed

+15
-3
lines changed

6 files changed

+15
-3
lines changed

src/main/php/lang/ast/emit/PHP74.class.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class PHP74 extends PHP {
2828
RewriteThrowableExpressions
2929
;
3030

31+
public $targetVersion= 70400;
32+
3133
/** Sets up type => literal mappings */
3234
public function __construct() {
3335
$this->literals= [

src/main/php/lang/ast/emit/PHP80.class.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class PHP80 extends PHP {
3131
RewriteStaticVariableInitializations
3232
;
3333

34+
public $targetVersion= 80000;
35+
3436
/** Sets up type => literal mappings */
3537
public function __construct() {
3638
$this->literals= [

src/main/php/lang/ast/emit/PHP81.class.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class PHP81 extends PHP {
2828
OmitConstantTypes
2929
;
3030

31+
public $targetVersion= 80100;
32+
3133
/** Sets up type => literal mappings */
3234
public function __construct() {
3335
$this->literals= [

src/main/php/lang/ast/emit/PHP82.class.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class PHP82 extends PHP {
2828
OmitConstantTypes
2929
;
3030

31+
public $targetVersion= 80200;
32+
3133
/** Sets up type => literal mappings */
3234
public function __construct() {
3335
$this->literals= [

src/main/php/lang/ast/emit/PHP83.class.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
class PHP83 extends PHP {
2121
use RewriteBlockLambdaExpressions, RewriteProperties, ReadonlyClasses;
2222

23+
public $targetVersion= 80300;
24+
2325
/** Sets up type => literal mappings */
2426
public function __construct() {
2527
$this->literals= [

src/main/php/lang/ast/emit/RewriteProperties.class.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ trait RewriteProperties {
1010
}
1111

1212
protected function emitProperty($result, $property) {
13-
static $asymmetric= null;
1413
if ($property->hooks) {
1514
return $this->emitPropertyHooks($result, $property);
1615
} else if (
17-
!($asymmetric ?? $asymmetric= method_exists(ReflectionProperty::class, 'isPrivateSet')) &&
16+
$this->targetVersion < 80400 &&
1817
array_intersect($property->modifiers, ['private(set)', 'protected(set)', 'public(set)'])
1918
) {
2019
return $this->emitAsymmetricVisibility($result, $property);
21-
} else if (PHP_VERSION_ID <= 80100 && in_array('readonly', $property->modifiers)) {
20+
} else if (
21+
$this->targetVersion < 80100 &&
22+
in_array('readonly', $property->modifiers)
23+
) {
2224
return $this->emitReadonlyProperties($result, $property);
2325
}
2426
parent::emitProperty($result, $property);

0 commit comments

Comments
 (0)