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

PHP8: Attributes Support #625

Closed
2 tasks done
zonuexe opened this issue May 3, 2020 · 4 comments · Fixed by #647
Closed
2 tasks done

PHP8: Attributes Support #625

zonuexe opened this issue May 3, 2020 · 4 comments · Fixed by #647
Assignees

Comments

@zonuexe
Copy link
Member

zonuexe commented May 3, 2020

Specification

Example

<<WithoutArgument>>
<<SingleArgument(0)>>
<<FewArguments('Hello', 'World')>>
function foo() {}

<<WithoutArgument>><<SingleArgument(0)>><<FewArguments('Hello', 'World')>>
function bar() {}

PHP Mode implementation

  • Face and font-lock
  • Indentation (vsemi)
@zonuexe
Copy link
Member Author

zonuexe commented May 3, 2020

This is valid syntax, but not attribute.

<?php

const Attribute = 0;

1 <<Attribute>> 2;

if (1 <<Attribute>> 2) Attribute;

@zonuexe
Copy link
Member Author

zonuexe commented May 3, 2020

This is also valid, of course, but since it is not a general description, coloring as an attribute is allowed.

<?php

const Attribute = 0;

if (1 
<<Attribute>>
2) Attribute;

@zonuexe
Copy link
Member Author

zonuexe commented May 4, 2020

https://github.com/php/php-src/pull/5394/files

$ref = new \ReflectionFunction(<<A1>> <<A2>> <<A5>> function () { });
$attr = $ref->getAttributes(\stdClass::class, \ReflectionAttribute::IS_INSTANCEOF);
var_dump(count($attr));
print_r(array_map(fn ($a) => $a->getName(), $attr));

@zonuexe
Copy link
Member Author

zonuexe commented Jun 18, 2020

Since two competing RFCs have been voted recently, the decision is about to be overturned.

We have to carefully review the logic for font-locking and indentation, especially if #[ ... ] were accepted.

image

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 a pull request may close this issue.

1 participant