Add documentation for WordPress.PHP.RestrictedPHPFunctions#2491
Add documentation for WordPress.PHP.RestrictedPHPFunctions#2491gogdzl wants to merge 2 commits intoWordPress:developfrom
Conversation
| add_action( 'init', function() { | ||
| return foo( 'bar' ); | ||
| } ); |
There was a problem hiding this comment.
| add_action( 'init', function() { | |
| return foo( 'bar' ); | |
| } ); | |
| add_action( 'init', <em>function() { | |
| return foo( 'bar' ); | |
| }</em> ); |
We can highlight the good bit of this snippet to focus on.
rodrigoprimo
left a comment
There was a problem hiding this comment.
Thanks for another PR adding user documentation for a sniff, @gogdzl! I left some comments with suggestions for us to discuss.
| > | ||
| <standard> | ||
| <![CDATA[ | ||
| The restricted function create_function() should not be used. |
There was a problem hiding this comment.
| The restricted function create_function() should not be used. | |
| The function create_function() should not be used. |
| <code_comparison> | ||
| <code title="Valid: Using anonymous function (closure)."> | ||
| <![CDATA[ | ||
| add_action( 'init', function() { |
There was a problem hiding this comment.
I wonder if it is a good idea to include an example with a declared named function as well (and then also update the title attribute)? Maybe it is just me, but it took me a second to properly read the sentence Please use declared named or anonymous functions instead. and to realize that functions applies to both declared named and anonymous. My first thought was "what is a declared named"?
There was a problem hiding this comment.
Looks like this phrase is also used in the error message thrown by the sniff.
While the phrase is no longer used in the docs per #2693, we may still want to consider updating the phrasing in the actual sniff.
@rodrigoprimo Want to add that to your list ?
There was a problem hiding this comment.
Never mind. Figured I might as well fix it straight away: #2702
| ]]> | ||
| </standard> | ||
| <code_comparison> | ||
| <code title="Valid: Using anonymous function (closure)."> |
There was a problem hiding this comment.
I'm not against mentioning here that anonymous functions are also known as closure. But if it is important to provide this information, I believe it should also be present in the description of the <standard> block.
| <code_comparison> | ||
| <code title="Valid: Using anonymous function (closure)."> | ||
| <![CDATA[ | ||
| add_action( 'init', function() { |
There was a problem hiding this comment.
I'm unsure if including a call to add_action() here helps understand what the sniff does or if it just adds noise. Usually, the examples are minimalistic, and just calling calling create_function() or calling it and assigning the returned value to a variable is enough?
|
@gogdzl, I was just wondering if you'll have a chance to finish this off in the near future. It would be great if this PR could be included in the next WPCS release. If you haven't got time or lost interest, please let us know and we'll see if we can find someone to take over. Thanks! |
|
@gogdzl, please let us know within a week if you are still interested in finishing this PR. If we don't hear back from you, we will presume you don't have time, and we will see if we can find someone else to take over and finish it. Thanks for your work so far! |
Follow up on the conversation about this phrasing in #2491 (comment) and #2693 (comment)
Follow up on the conversation about this phrasing in #2491 (comment) and #2693 (comment)
Follow up on the conversation about this phrasing in #2491 (comment) and #2693 (comment) Also related to: WordPress/wpcs-docs#158
Related to #1722