coding-standard icon indicating copy to clipboard operation
coding-standard copied to clipboard

Allow ignoring JumpStatementsSpacing after T_OPEN_TAG

Open MatzeKitt opened this issue 1 year ago • 0 comments

I use the following configuration:

<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
	<properties>
		<property name="linesCountAfter" value="0"/>
		<property name="linesCountAfterLast" value="0"/>
		<property name="linesCountAfterWhenLastInCaseOrDefault" value="0"/>
		<property name="linesCountAfterWhenLastInLastCaseOrDefault" value="0"/>
		<property name="linesCountBefore" value="1"/>
		<property name="linesCountBeforeFirst" value="0"/>
		<property name="linesCountBeforeWhenFirstInCaseOrDefault" value="0"/>
		<property name="jumpStatements" type="array">
			<element value="continue"/>
			<element value="return"/>
		</property>
	</properties>
</rule>

So it means that after each return there must be an empty space. That’s good for the most part, but unfortunately I sometimes have code like this:

function foo() {
	ob_start();
	?>
	<div>Some HTML</div>
	<?php
	return ob_get_clean();
}

Now the settings above require an empty line before the return, which would make no sense to me here. Thus it would be great to add such a functionality to allow T_OPEN_TAG to be excluded from such a check and allow it preceeding without an empty line.

Or is this already possible and I couldn’t find it?

MatzeKitt avatar May 07 '24 11:05 MatzeKitt