Skip to content

Commit 6c040ea

Browse files
rodrigoprimogogdzl
andauthored
PHP/RestrictedPHPFunctions: add XML documentation (#2693)
* Add documentation for WordPress.PHP.RestrictedPHPFunctions * 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. * Explain why in the standard description Following the suggestion in PR 2687, this commit improves the standard description to explain why these functions must not be used. The phrasing is kept generic instead of mentioning create_function() specifically, since the sniff name suggests it could be extended with more functions in the future. Co-authored-by: gogdzl <diego.rodrigues@automattic.com>
1 parent c580c6c commit 6c040ea

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0"?>
2+
<documentation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://phpcsstandards.github.io/PHPCSDevTools/phpcsdocs.xsd"
4+
title="Restricted PHP Functions"
5+
>
6+
<standard>
7+
<![CDATA[
8+
Certain PHP functions must not be used. Use the recommended alternatives instead.
9+
]]>
10+
</standard>
11+
<code_comparison>
12+
<code title="Valid: Using an anonymous function (closure).">
13+
<![CDATA[
14+
add_action(
15+
'init',
16+
<em>function () {
17+
return foo( 'bar' );
18+
}</em>
19+
);
20+
]]>
21+
</code>
22+
<code title="Invalid: Using create_function().">
23+
<![CDATA[
24+
add_action(
25+
'init',
26+
<em>create_function(
27+
'',
28+
'return foo( "bar" );'
29+
)</em>
30+
);
31+
]]>
32+
</code>
33+
</code_comparison>
34+
</documentation>

0 commit comments

Comments
 (0)