-
-
Notifications
You must be signed in to change notification settings - Fork 89
Add documentation for the SpaceBeforeCast sniff #159
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
Changes from 1 commit
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,31 @@ | ||
| <documentation title="Space Before Casts"> | ||
| <standard> | ||
| <![CDATA[ | ||
| Ensures there is exactly one space before a cast operator. | ||
rodrigoprimo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ]]> | ||
| </standard> | ||
| <code_comparison> | ||
| <code title="Valid: Single space before a cast operator."> | ||
| <![CDATA[ | ||
| $integer =<em> </em>(int) $string; | ||
| ]]> | ||
| </code> | ||
| <code title="Invalid: No space before a cast operator."> | ||
| <![CDATA[ | ||
| $integer =<em></em>(int) $string; | ||
| ]]> | ||
| </code> | ||
| </code_comparison> | ||
| <code_comparison> | ||
| <code title="Valid: Single space before a cast operator."> | ||
| <![CDATA[ | ||
| $c = $a +<em> </em>(int) $b; | ||
| ]]> | ||
| </code> | ||
| <code title="Invalid: Multiple spaces before a cast operator."> | ||
| <![CDATA[ | ||
| $c = $a +<em> </em>(int) $b; | ||
| ]]> | ||
| </code> | ||
|
Member
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. As the valid code is essentially the same for both cases, I think it might be better to use a single Might also be good to vary the type casts used in the code samples a little as people could get the impression this is only about
Contributor
Author
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. Even though the valid code is essentially the same for both cases, I opted for this approach as it was the only way that I could find to have titles for the two different invalid codes to highlight that this sniff acts when there is no space and also when there are multiple spaces.
I might be missing something, but I was not able to find a way to have more than two
👍 Maybe the second example could be: <code title="Valid: Single space before a cast operator.">
<![CDATA[
$c = $a . <em> </em>(string) $b;
]]>
</code>
<code title="Invalid: Multiple spaces before a cast operator.">
<![CDATA[
$c = $a .<em> </em>(string) $b;
]]>
</code>(I'm happy to adjust the example above and include it in the first
Member
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. There should only be two code blocks per code comparison, but a code block can contain multiple code samples. If it clarifies things, you can use inline comments in the code sample to add some additional info, like so: <code title="Invalid: Multiple spaces before a cast operator.">
<![CDATA[
// Too much space.
$c = $a +<em> </em>(int) $b;
]]>
</code>Having said that, I don't really think those comments are needed in this case as "no space" and "too much space" both translate to "not using a single space", so a good description for the "invalid" case can cover both.
Which other topic ?
Contributor
Author
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.
It's good to know that this is an option. Thanks.
I just pushed 1f90b17 in which I combined both code examples into a single
Our conversation on whether to use one or two |
||
| </code_comparison> | ||
| </documentation> | ||
Uh oh!
There was an error while loading. Please reload this page.