-
Notifications
You must be signed in to change notification settings - Fork 868
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
PHP 8.4 Support: Property hooks #8227
base: master
Are you sure you want to change the base?
Conversation
- apache#8035 - https://wiki.php.net/rfc#php_84 - https://wiki.php.net/rfc/property-hooks - Fix the lexer and parser(grammar) - Add `PropertyHookDeclaration` as an `ASTNode` - Fix `PHP5ErrorHandlerImpl` (handle missing tokens) - Fix/Add unit tests for the lexer and parser - Remove `ArrayDimensionSyntaxSuggestionHint` because this no longer works. Example: ```php class PropertyHooksClass { public int $backed = 100 { get { return $this->backed; } set { $this->backed = $value; } } public $doubleArrow { // virtual get => $this->test(); set => $this->test() . $value; } public $attributes { #[Attr1] get {} #[Attr2] set ($value) { $this->attributes = $value; } } public $reference { &get => $this->reference; } public $final { final get => $this->final; } // constructor property promotion public function __construct( public $prop { get { return $this->prop; } set { $this->prop = $value; } } ) {} } class Child extends PropertyHooksClass { public $prop { get => parent::$prop::get(); set { parent::$prop::set($value); } } } interface PropertyHooksInterface { public string $prop1 { get; } final public int $prop2 { set; } public $prop3 { get; set; } public $ref { &get; } } ``` Note: Curly braces array access (`{}` e.g. `$array{1}`, `$array{'key'}`) can use no longer. Because a conflict occurs in the following case: ```php "string"{1}; public string $prop = "string" { get => $this->prop; set {} } ```
php/php.editor/src/org/netbeans/modules/php/editor/model/impl/ClassScopeImpl.java
Show resolved
Hide resolved
...tor/src/org/netbeans/modules/php/editor/verification/ArrayDimensionSyntaxSuggestionHint.java
Outdated
Show resolved
Hide resolved
@tmysik This is not done yet. I'm slowly going to add more commits to this PR. Could you please have a look at each commit when you have time? |
php/php.editor/src/org/netbeans/modules/php/editor/csl/NavigatorScanner.java
Show resolved
Hide resolved
Time out occurs in Windows tests. I'll try adding commits one by one.
|
e1d3267
to
5e2fad5
Compare
@tmysik Please ignore this. I'll try to investigate this later... |
3bf0406
to
33472a7
Compare
php/php.editor/src/org/netbeans/modules/php/editor/model/impl/PropertyHookSignatureItem.java
Show resolved
Hide resolved
@tmysik It should be OK now. Probably, the cause is "Jackson". Instead, I used "JSON simple". |
&& ((HookedFieldElemnt) field).isHooked(); | ||
} | ||
|
||
public interface HookedFieldElemnt extends FieldElement { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public interface HookedFieldElemnt extends FieldElement { | |
public interface HookedFieldElement extends FieldElement { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, Thank you for catching it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @return property hook elements | ||
*/ | ||
public static List<PropertyHookElement> fromSignatureItems(final List<PropertyHookSignatureItem> signatureItems, final String field, final String filenameUrl, final ElementQuery elementQuery) { | ||
List<PropertyHookElement> elements = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick:
List<PropertyHookElement> elements = new ArrayList<>(); | |
List<PropertyHookElement> elements = new ArrayList<>(signatureItems.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a very quick review, and it looks good to me. Thanks for changing the code to the modern one, e.g. the switches :) |
33472a7
to
b7eb3b4
Compare
Fix folding feature: 8cff930 |
- apache#8035 - https://wiki.php.net/rfc#php_84 - https://wiki.php.net/rfc/property-hooks - Fix the indexer and the model - Use JSON format as a signature for property hooks - Current format is semicolon separated but it's hard to add hooks to a field signature without JSON format - Use the "JSON simple". If we use "Jackson", problems(timeout, java.lang.NoClassDefFoundError) occurs in CI for Windows ```json [ { "name":"set", "start":3651, "end":3690, "mod":1, "isRef":false, "isAttr":false, "hasBody":true, "paramSig":"$value::0::1:1:0:0:0:0::" } ] ``` - Add interface methods - `FieldElemnt.isHooked()` - `FieldElement.HookedFieldElemnt.isHooked()` - `FieldElement.HookedFieldElemnt.getPropertyHooks()` - `IndexScope.PHP84IndexScope.findFields()` - `TypeScope.FieldDeclarable.getDeclaredFields()` - `TypeScope.FieldDeclarable.getInheritedFields()` - `PropertyHookScope.isReference()` - `PropertyHookScope.hasBody()` - `PropertyHookScope.isAttributed()` - `PropertyHookScope.getParameterNames()` - `PropertyHookScope.getParameters()` - `PropertyHookScope.getOffsetRange()` - `PropertyHookElement.isReference()` - `PropertyHookElement.hasBody()` - `PropertyHookElement.isAttributed()` - `PropertyHookElement.getParameters()` - `PropertyHookElement.getOffsetRange()` - Add/Fix unit tests for the index and the model Log: ``` FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: getSignatureFromScopes() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: getSignatureFromScopes() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: getSignatureFromScopes() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: getSignatureFromScopes() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: getSignatureFromScopes() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: getSignatureFromScopes() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: getSignatureFromScopes() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: getSignatureFromScopes() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: getSignatureFromScopes() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: getSignatureFromScopes() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: getSignatureFromScopes() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: getSignatureFromScopes() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: getSignatureFromScopes() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: getSignatureFromScopes() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: getSignatureFromScopes() took: 0 ms INFO [org.netbeans.ui.indexing]: Indexing finished, indexing took 14 ms. FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: fromSignature() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: fromSignature() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: fromSignature() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: fromSignature() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: fromSignature() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: fromSignature() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: fromSignature() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: fromSignature() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: fromSignature() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: fromSignature() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: fromSignature() took: 1 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: fromSignature() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: fromSignature() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: fromSignature() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: fromSignature() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: fromSignature() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: fromSignature() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: fromSignature() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: fromSignature() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: fromSignature() took: 0 ms FINE [org.netbeans.modules.php.editor.model.impl.PropertyHookSignatureItem]: fromSignature() took: 0 ms ```
- apache#8035 - https://wiki.php.net/rfc#php_84 - https://wiki.php.net/rfc/property-hooks - Fix the navigator - Fix/Add unit tests - Add SVG icons for a property hook, a trait, and an enum case
- apache#8035 - https://wiki.php.net/rfc#php_84 - https://wiki.php.net/rfc/property-hooks - Fix the folding feature - Add unit tests
3b51984
to
8cff930
Compare
PHP 8.4 Support: Property hooks (Part 1)
PropertyHookDeclaration
as anASTNode
PHP5ErrorHandlerImpl
(handle missing tokens)ArrayDimensionSyntaxSuggestionHint
because this no longer works.Example:
Note: Curly braces array access (
{}
e.g.$array{1}
,$array{'key'}
) can use no longer.Because a conflict occurs in the following case:
PHP 8.4
PHP 8.3
PHP 8.4 Support: Property hooks (Part 2)
Add interface methods
FieldElemnt.isHooked()
FieldElement.HookedFieldElemnt.isHooked()
FieldElement.HookedFieldElemnt.getPropertyHooks()
IndexScope.PHP84IndexScope.findFields()
TypeScope.FieldDeclarable.getDeclaredFields()
TypeScope.FieldDeclarable.getInheritedFields()
PropertyHookScope.isReference()
PropertyHookScope.hasBody()
PropertyHookScope.isAttributed()
PropertyHookScope.getParameterNames()
PropertyHookScope.getParameters()
PropertyHookScope.getOffsetRange()
PropertyHookElement.isReference()
PropertyHookElement.hasBody()
PropertyHookElement.isAttributed()
PropertyHookElement.getParameters()
PropertyHookElement.getOffsetRange()
Add/Fix unit tests for the index and the model
PHP 8.4 Support: Property hooks (Part 3)
PHP 8.4 Support: Property hooks (Part 4)
Expanded:
Collapsed: