-
-
Notifications
You must be signed in to change notification settings - Fork 488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding documentation to WordPress.WP.DiscouragedConstants #2493
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,49 @@ | ||||||
<?xml version="1.0"?> | ||||||
<documentation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||||
xsi:noNamespaceSchemaLocation="https://phpcsstandards.github.io/PHPCSDevTools/phpcsdocs.xsd" | ||||||
title="Discouraged Constants" | ||||||
> | ||||||
<standard> | ||||||
<![CDATA[ | ||||||
The usage of WordPress Constants is discouraged. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if it makes sense to list here and in the other There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On a second thought, maybe providing the whole list is too much, we could simply say something like |
||||||
]]> | ||||||
</standard> | ||||||
<code_comparison> | ||||||
<code title="Valid: A function is used in the code to retrieve the theme directory."> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not explicitly mentioned in #1722, but my understanding, based on checking the documentation from other sniffs, is that the description of the valid and invalid examples should be generic and describe what constitutes a valid example for this particular check that the sniff performs instead of describing the code sample provided. Maybe here, the valid description should mention that the code does not use one of the discouraged WP constants or something like that? |
||||||
<![CDATA[ | ||||||
<img src=" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAIK, it is not common to indent an HTML tag like it is done here. Maybe instead of fixing the indentation, we can simplify the example and make it easier to understand what this sniff is about? I believe the code sample could be trimmed down to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually just $subdir = TEMPLATEPATH . '/subdir/'; And something similar for the example with |
||||||
<?php echo <em>get_template_directory_uri()</em>; ?> | ||||||
/img/logo.svg" /> | ||||||
]]> | ||||||
</code> | ||||||
<code title="Invalid: The TEMPLATEPATH constant is used in the code."> | ||||||
<![CDATA[ | ||||||
<img src=" | ||||||
<?php echo <em>TEMPLATEPATH</em>;?> | ||||||
/img/logo.svg" /> | ||||||
]]> | ||||||
</code> | ||||||
</code_comparison> | ||||||
<standard> | ||||||
<![CDATA[ | ||||||
Defining WordPress Constants is discouraged. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
]]> | ||||||
</standard> | ||||||
<code_comparison> | ||||||
<code title="Valid: A function is used in the code to retrieve the theme directory."> | ||||||
<![CDATA[ | ||||||
<img src=" | ||||||
<?php echo <em>get_template_directory_uri()</em>; ?> | ||||||
/img/logo.svg" /> | ||||||
]]> | ||||||
</code> | ||||||
<code title="Invalid: The TEMPLATEPATH constant is set by a theme."> | ||||||
<![CDATA[ | ||||||
<em>define("TEMPLATEPATH", "foo");</em> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it is better to highlight just the constant name instead of the whole line as it is not any call to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest using a different discouraged constant here, so that we have two examples of constants that trigger this sniff. And possibly wrapping it with a if defined check to illustrate that the sniff is triggered even in this case. |
||||||
<img src=" | ||||||
<?php echo <em>$foo</em>; ?> | ||||||
/img/logo.svg" /> | ||||||
Comment on lines
+42
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it is necessary to include the |
||||||
]]> | ||||||
</code> | ||||||
</code_comparison> | ||||||
</documentation> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.