Skip to content

Commit e2f5dab

Browse files
committed
Rework XML documentation for WordPress.PHP.RestrictedPHPFunctions
Some of these changes were suggested during the review of PR 2491, and others were decided while working on the new PR: - Make the standard description generic instead of mentioning create_function() specifically, following the pattern used by other docs like DeprecatedFunctionsStandard.xml. - Use "must not" instead of "should not" since the sniff produces an error. - Simplify the code examples by removing the add_action() wrapper. - Add <em> tags to the valid code example.
1 parent 5d7ccce commit e2f5dab

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

WordPress/Docs/PHP/RestrictedPHPFunctionsStandard.xml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,23 @@
55
>
66
<standard>
77
<![CDATA[
8-
The restricted function create_function() should not be used.
9-
10-
create_function() is deprecated as of PHP 7.2 and removed in PHP 8.0. Please use declared named or anonymous functions instead.
8+
Certain PHP functions must not be used. Use the recommended alternatives instead.
119
]]>
1210
</standard>
1311
<code_comparison>
14-
<code title="Valid: Using anonymous function (closure).">
12+
<code title="Valid: Using an anonymous function.">
1513
<![CDATA[
16-
add_action( 'init', function() {
14+
$function = <em>function ()</em> {
1715
return foo( 'bar' );
18-
} );
16+
};
1917
]]>
2018
</code>
2119
<code title="Invalid: Using create_function().">
2220
<![CDATA[
23-
add_action( 'init', <em>create_function( '',
21+
$function = <em>create_function</em>(
22+
'',
2423
'return foo( "bar" );'
25-
)</em> );
24+
);
2625
]]>
2726
</code>
2827
</code_comparison>

0 commit comments

Comments
 (0)