You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2021/11/11 13:39:00 UTC

[jira] [Updated] (NETBEANS-6193) Can't use attributes with interface constants and methods

     [ https://issues.apache.org/jira/browse/NETBEANS-6193?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

ASF GitHub Bot updated NETBEANS-6193:
-------------------------------------
    Labels: pull-request-available  (was: )

> Can't use attributes with interface constants and methods
> ---------------------------------------------------------
>
>                 Key: NETBEANS-6193
>                 URL: https://issues.apache.org/jira/browse/NETBEANS-6193
>             Project: NetBeans
>          Issue Type: Bug
>          Components: php - Editor
>    Affects Versions: 12.5
>            Reporter: Junichi Yamamoto
>            Assignee: Junichi Yamamoto
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> The following code is valid. However, if we use attributes with interface constants and methods, syntax errors occur.
> Example code:
> {code:php}
> <?php
> #[I1]
> interface I {
>     #[I2(1)] // syntax error occurs
>     public const I_CONST = "interface";
>     #[I3] // syntax error occurs
>     public function method(#[I4] $param1, #[I5(), I6("test")] $param): void; // syntax error occurs
> }
> $refI = new \ReflectionClass(I::class);
> $sourcesI = [
>     $refI,
>     $refI->getReflectionConstant('I_CONST'),
>     $refI->getMethod('method'),
>     $refI->getMethod('method')->getParameters()[0],
>     $refI->getMethod('method')->getParameters()[1],
> ];
> foreach ($sourcesI as $r) {
> 	$attr = $r->getAttributes();
> 	var_dump(get_class($r), count($attr));
>     foreach ($attr as $a) {
>         var_dump($a->getName(), $a->getArguments());
>     }
>     echo "\n";
> }{code}
> Result:
> string(15) "ReflectionClass"
> int(1)
> string(2) "I1"
> array(0) {
> }
> string(23) "ReflectionClassConstant"
> int(1)
> string(2) "I2"
> array(1) {
>   [0]=>
>   int(1)
> }
> string(16) "ReflectionMethod"
> int(1)
> string(2) "I3"
> array(0) {
> }
> string(19) "ReflectionParameter"
> int(1)
> string(2) "I4"
> array(0) {
> }
> string(19) "ReflectionParameter"
> int(2)
> string(2) "I5"
> array(0) {
> }
> string(2) "I6"
> array(1) {
>   [0]=>
>   string(4) "test"
> }
> Steps to reproduce:
>  # Create a PHP project
>  # Create a new file
>  # Copy and paste the above example code



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists