Skip to content

Use keyword "static"#4436

Merged
Alkarex merged 1 commit intoFreshRSS:edgefrom
ColonelMoutarde:patch-2
Aug 21, 2022
Merged

Use keyword "static"#4436
Alkarex merged 1 commit intoFreshRSS:edgefrom
ColonelMoutarde:patch-2

Conversation

@ColonelMoutarde
Copy link
Copy Markdown
Contributor

@ColonelMoutarde ColonelMoutarde commented Jul 6, 2022

static closure
While methods may be static or not, function has no such alternative : they just can’t be static. Yet, there is one final type of method that may be static : static closures.
Closure are functions that may be stored in a variable : functions may have their name stored in a variable, though. Closure also have the ability to aggregate variables from the context of their creation, for future use. As such, $this is available in a closure that is created inside an object.
See more ... https://www.exakat.io/en/5-usages-of-static-keyword-in-php/

static closure
While methods may be static or not, function has no such alternative : they just can’t be static. Yet, there is one final type of method that may be static : static closures.
Closure are functions that may be stored in a variable : functions may have their name stored in a variable, though. Closure also have the ability to aggregate variables from the context of their creation, for future use. As such, $this is available in a closure that is created inside an object.
See more ... https://www.exakat.io/en/5-usages-of-static-keyword-in-php/
@Alkarex Alkarex added this to the 1.20.0 milestone Jul 6, 2022
@Alkarex
Copy link
Copy Markdown
Member

Alkarex commented Jul 6, 2022

Fine, and although I am not sure it makes much of a difference in practice, there are several other examples in our codebase with the same case, e.g.:

uasort($categories, function ($a, $b) {

@ColonelMoutarde
Copy link
Copy Markdown
Contributor Author

That's true, but every little improvement is a step forward

@Alkarex Alkarex merged commit 85991d1 into FreshRSS:edge Aug 21, 2022
@ColonelMoutarde ColonelMoutarde deleted the patch-2 branch April 5, 2023 17:04
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 this pull request may close these issues.

2 participants