Skip to content
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

Bug in ArrayIndentation / multi-line strings #1064

Closed
jrfnl opened this issue Jul 25, 2017 · 0 comments
Closed

Bug in ArrayIndentation / multi-line strings #1064

jrfnl opened this issue Jul 25, 2017 · 0 comments
Assignees
Milestone

Comments

@jrfnl
Copy link
Member

jrfnl commented Jul 25, 2017

Found yet another edge case for the ArrayIndentation sniff:

$array  = array(
	'notes'         => array(
		'<p><strong>Please note:</strong> <code>min() / max()</code> will evaluate a non-numeric string as 0 if compared to integer, but still return the string if it\'s seen as the numerically lowest/highest value.</p>',
		'<p><code>max()</code> returns the numerically highest of the parameter values. If multiple values can be considered of the same size, the one that is listed first will be returned.<br />
		If <code>max()</code> is given multiple arrays, the longest array is returned. If all the arrays have the same length, <code>max()</code> will use lexicographic ordering to find the return value.</p>',
	),
);

will throw a Multi-line array item not aligned correctly; expected 8 spaces, but found 0 (WordPress.Arrays.ArrayIndentation.MultiLineArrayItemNotAligned) error.

This is caused by multi-line strings (the second <p> + subsequent line) being tokenized as T_CONSTANT_ENCAPSED_STRING, T_WHITESPACE (new line), T_CONSTANT_ENCAPSED_STRING where the second T_CONSTANT_ENCAPSED_STRING contains the indentation for the next line.

I haven't tested this, but I believe this will also cause a fixer loop as the additional whitespace would be added before the second T_CONSTANT_ENCAPSED_STRING, but in the next round of the fixer would be tokenized as part of the string - similar to what was happening in another sniff (#1017).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant