Skip to content

Commit

Permalink
Docs / ParameterValues/RemovedPCREModifiers: various tweaks
Browse files Browse the repository at this point in the history
* Add proper XML header.
    Note: this is something which only recently became an option as there previously was no schema available.
* Style: have `CDATA` tags on their own lines.
    This makes the XML code style consistent with currently existing XML docs.
* Expand the issue description a little.
* Use `Cross-version compatible` and `PHP </> #.#` style prefixes in the code samples.
    This improves consistency with the other XML docs and makes the code samples more descriptive in the context of PHPCompatibility.
* Add `<em>` tags to the code samples to allow for highlighting the specific issue the sniff is looking for.
  • Loading branch information
jrfnl committed Mar 27, 2023
1 parent dfee66b commit 94244ed
Showing 1 changed file with 24 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
<documentation title="Removed PCRE Modifiers">
<standard><![CDATA[
The /e modifier is deprecated since PHP 5.5 and removed since PHP 7.0. Use preg_replace_callback or preg_replace_array_callback instead.
]]></standard>
<?xml version="1.0"?>
<documentation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://phpcsstandards.github.io/PHPCSDevTools/phpcsdocs.xsd"
title="Removed PCRE Modifiers"
>
<standard>
<![CDATA[
The /e modifier, as could be used in regexes passed to the PCRE `preg_replace()` and `preg_filter()` functions, is deprecated since PHP 5.5 and removed since PHP 7.0.
Use `preg_replace_callback()` or `preg_replace_array_callback()` instead.
]]>
</standard>
<code_comparison>
<code title="Valid"><![CDATA[
preg_replace_callback(
<code title="Cross-version compatible: using preg_replace_callback()">
<![CDATA[
<em>preg_replace_callback</em>(
'/^(.?)/',
function ($matches) {
<em>function ($matches) {
return strtoupper($matches[1]);
},
}</em>,
$input
);
]]></code>
<code title="Invalid"><![CDATA[
]]>
</code>
<code title="PHP &lt; 7.0: using the /e modifier">
<![CDATA[
preg_replace(
'/^(.?)/e',
"strtoupper('\\1')",
<em>'/^(.?)/e'</em>,
<em>"strtoupper('\\1')"</em>,
$input
);
]]></code>
]]>
</code>
</code_comparison>
</documentation>

0 comments on commit 94244ed

Please sign in to comment.