-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support asymmetric visibility #182
Comments
The reflection library has support for this now, see https://github.com/xp-framework/reflection/releases/tag/v3.2.0 and https://github.com/xp-framework/reflection/releases/tag/v2.15.0 |
Implemented in https://github.com/xp-framework/compiler/releases/tag/v9.2.0 |
Once the PR is merged and built into GitHub Actions's 8.4 build, we can remove the featzre availability checks from the PHP 8.4 emitter using the following patch: diff --git a/src/main/php/lang/ast/emit/PHP84.class.php b/src/main/php/lang/ast/emit/PHP84.class.php
index a23910d..71379f3 100755
--- a/src/main/php/lang/ast/emit/PHP84.class.php
+++ b/src/main/php/lang/ast/emit/PHP84.class.php
@@ -1,6 +1,5 @@
<?php namespace lang\ast\emit;
-use ReflectionProperty;
use lang\ast\types\{
IsArray,
IsFunction,
@@ -20,10 +19,6 @@ use lang\ast\types\{
*/
class PHP84 extends PHP {
use RewriteBlockLambdaExpressions;
- use PropertyHooks, AsymmetricVisibility {
- PropertyHooks::emitProperty as emitPropertyHooks;
- AsymmetricVisibility::emitProperty as emitAsymmetricVisibility;
- }
public $targetVersion= 80400;
@@ -58,25 +53,4 @@ class PHP84 extends PHP {
IsGeneric::class => function($t) { return null; }
];
}
-
- protected function emitProperty($result, $property) {
- static $asymmetric= null;
- static $hooks= null;
-
- // TODO Remove once https://github.com/php/php-src/pull/15063 and
- // https://github.com/php/php-src/pull/13455 are merged
- if (
- !($asymmetric ?? $asymmetric= method_exists(ReflectionProperty::class, 'isPrivateSet')) &&
- array_intersect($property->modifiers, ['private(set)', 'protected(set)', 'public(set)'])
- ) {
- return $this->emitAsymmetricVisibility($result, $property);
- } else if (
- !($hooks ?? $hooks= method_exists(ReflectionProperty::class, 'getHooks')) &&
- $property->hooks
- ) {
- return $this->emitPropertyHooks($result, $property);
- }
-
- parent::emitProperty($result, $property);
- }
}
\ No newline at end of file |
Merged in php/php-src@8df557a |
PHP 8.4 on Ubuntu is not yet up-to-date with current GIT, see https://github.com/xp-framework/compiler/actions/runs/10643910513/job/29508056545. |
PHP 8.4 emitter released in https://github.com/xp-framework/compiler/releases/tag/v9.3.0 |
See thekid/dialog#61 |
Add support for https://wiki.php.net/rfc/asymmetric-visibility-v2
Example
In a nutshell:
RFC status: Accepted
Quoting https://externals.io/message/124622#124838:
Rewriting
To support this in lower PHP versions, we will need to rewrite this to virtual properties, much like readonly support was implemented in #124, along the lines of the following:
See also
The text was updated successfully, but these errors were encountered: