Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
/language-phpPublic archive

Attributes#405

Merged
sadick254 merged 5 commits intoatom:masterfromKapitanOczywisty:attributes
Dec 7, 2020
Merged

Attributes#405

sadick254 merged 5 commits intoatom:masterfromKapitanOczywisty:attributes
Dec 7, 2020

Conversation

KapitanOczywisty
Copy link
Contributor

@KapitanOczywistyKapitanOczywisty commentedNov 27, 2020
edited
Loading

This is implementation of Attributes added in PHP 8.0. However documentation for this feature is rather bad, so I'd advice you to use sth likehttps://3v4l.org/ to determinate how this feature really works.

Implemented:

  • argument-less attribute#[MyAttribute]
  • attribute with arguments#[MyAttribute(true)]
  • attribute with named arguments#[MyAttribute(name:'Bob')]
  • namespaced attributes#[\Ye\Old\Attribute]
  • multiple attributes#[A,B,C]
  • multilined attributes
#[A,B(true)]
  • anonymous class attributes (single-line only)new #[MyAttribute] class {}, also it's valid to writenew#[MyAttribute]class{}
  • Attribute as class name, for use as argument#[Attribute(Attribute::TARGET_CLASS)]
  • test spec

Scopes

  • meta.attribute.php for whole#[....]
  • support.attribute.php for attribute name, w/ namespace scopes like in classes
  • support.attribute.builtin.php forAttribute and future builtins
  • arguments are the same as in function call

Not implemented

  • multilined attributes for anonymous classes - I'm not sure if I should implement this, since it would need some trickery to add with TM grammar (feedback is welcome)

@KapitanOczywistyKapitanOczywisty mentioned this pull requestNov 27, 2020
12 tasks
'begin':'''(?ix)
(?:
(?:^|(?<=}))\\s*(?:(abstract|final)\\s+)?(class)\\s+([a-z_\\x{7f}-\\x{7fffffff}][a-z0-9_\\x{7f}-\\x{7fffffff}]*)
\\b(?:(abstract|final)\\s+)?(class)\\s+([a-z_\\x{7f}-\\x{7fffffff}][a-z0-9_\\x{7f}-\\x{7fffffff}]*)
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I've removed complicated look-behind. As far I'm concerned, there is no case where this could backfire, but I could be wrong.

@KapitanOczywisty
Copy link
ContributorAuthor

@sadick254 ready for review 😃

Copy link
Contributor

@sadick254sadick254 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Looks great 👍

@sadick254sadick254 merged commit2a12e89 intoatom:masterDec 7, 2020
@KapitanOczywistyKapitanOczywisty deleted the attributes branchDecember 14, 2022 22:39
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers
1 more reviewer

@sadick254sadick254sadick254 approved these changes

Reviewers whose approvals may not affect merge requirements
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@KapitanOczywisty@sadick254

[8]ページ先頭

©2009-2025 Movatter.jp