Skip to content
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

Prefer PHP 8 attributes over xp::$meta #28

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

thekid
Copy link
Member

@thekid thekid commented Jan 29, 2023

This PR always uses the native syntax instead of using the information available in xp::$meta in PHP 8.

Runtime version Source
PHP 7.* Meta information if available, syntax tree otherwise
PHP 8.* (before) Meta information if available, PHP 8 attributes reflection otherwise
PHP 8.* (after this PR is merged) PHP 8 attributes reflection only 🆕

Changes to the compiler

Here's what we could do in XP Compiler:

diff --git a/src/main/php/lang/ast/emit/php/XpMeta.class.php b/src/main/php/lang/ast/emit/php/XpMeta.class.php
index 0da5bcc..444e052 100755
--- a/src/main/php/lang/ast/emit/php/XpMeta.class.php
+++ b/src/main/php/lang/ast/emit/php/XpMeta.class.php
@@ -96,12 +96,4 @@ trait XpMeta {
   protected function emitComment($result, $comment) {
     // Omit from generated code
   }
-
-  protected function emitAnnotation($result, $annotation) {
-    // Omit from generated code
-  }
-
-  protected function emitAnnotations($result, $annotations) {
-    // Omit from generated code
-  }
 }

However, this would require changes to XP Core to parse annotations from the source code even if meta information is available - thus we'll have to wait for xp-framework/rfc#338

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant