-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add compatibility/arrow-functions-feature lint #42
base: main
Are you sure you want to change the base?
Conversation
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.
Thank you for your contribution 😄 could you please rebase?
impl Rule for ArrowFunctionsFeatureRule { | ||
fn get_definition(&self) -> RuleDefinition { | ||
RuleDefinition::enabled("Arrow Functions Feature", Level::Error) | ||
.with_maximum_supported_php_version(PHPVersion::PHP73) |
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.
.with_maximum_supported_php_version(PHPVersion::PHP73) | |
.with_maximum_supported_php_version(PHPVersion::PHP74) |
.with_description(indoc! {" | ||
Flags any usage of the `fn` keyword for arrow functions, which was introduced in PHP 7.4. | ||
|
||
In environments running older versions of PHP, you can use the `use` keyword to import variables instead. |
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.
In environments running older versions of PHP, you can use the `use` keyword to import variables instead. | |
In environments running older versions of PHP, you can use an anonymous function | |
with `use` keyword anonymous functions combined with the `use` keyword to import variables instead. |
In environments running older versions of PHP, you can use the `use` keyword to import variables instead. | ||
"}) | ||
.with_example(RuleUsageExample::valid( | ||
"Using the `use` keyword for arrow functions", |
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.
"Using the `use` keyword for arrow functions", | |
"Using an anonymous function with `use` keyword", |
This is my first attempt at writing a lint!
In order to test it out properly, the
MINIMUM_PHP_VERSION
needs to be lowered toPHP73
since arrow functions are available on PHP 7.4+. (note: there is currently an issue with "Null Coalesce Assignment Feature" that warns forphp_version = "7.4"
see more info here: 95a84ce#r151496707)mago/src/consts.rs
Line 52 in dc32663
I have done that locally, and the lint seems to be working! 🎉