Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 77d0290

Browse filesBrowse files
committed
No longer require a space before a colon for control structures using the alternative syntax
1 parent f14d045 commit 77d0290
Copy full SHA for 77d0290

File tree

Expand file treeCollapse file tree

3 files changed

+82
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+82
-0
lines changed
Open diff view settings
Collapse file
+45Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
$something = true;
3+
$array = [1];
4+
?>
5+
6+
<!-- THIS IS WRONG -->
7+
<?php if ($something) : ?>
8+
<!-- do something -->
9+
<?php else : ?>
10+
<!-- do something else -->
11+
<?php endif; ?>
12+
13+
<?php foreach($array as $a) : ?>
14+
<!-- foreach -->
15+
<?php endforeach; ?>
16+
17+
<?php switch ($something) : ?>
18+
<?php case true : ?>
19+
<!-- case is true -->
20+
<?php endswitch; ?>
21+
22+
<?php while(!$something) : ?>
23+
<!-- I'm not being outputted -->
24+
<?php endwhile; ?>
25+
26+
27+
<!-- THIS IS CORRECT -->
28+
<?php if ($something): ?>
29+
<!-- do something -->
30+
<?php else: ?>
31+
<!-- do something else -->
32+
<?php endif; ?>
33+
34+
<?php foreach($array as $a): ?>
35+
<!-- foreach -->
36+
<?php endforeach; ?>
37+
38+
<?php switch ($something): ?>
39+
<?php case true: ?>
40+
<!-- case is true -->
41+
<?php endswitch; ?>
42+
43+
<?php while(!$something): ?>
44+
<!-- I'm not being outputted -->
45+
<?php endwhile; ?>
Collapse file
+34Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* Copyright © Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento2\Tests\Templates;
7+
8+
use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
9+
10+
class AlternativeControlStructuresSyntaxUnitTest extends AbstractSniffUnitTest
11+
{
12+
/**
13+
* @inheritdoc
14+
*/
15+
public function getErrorList()
16+
{
17+
return [];
18+
}
19+
20+
/**
21+
* @inheritdoc
22+
*/
23+
public function getWarningList()
24+
{
25+
return [
26+
7 => 1,
27+
9 => 1,
28+
13 => 1,
29+
17 => 1,
30+
18 => 1,
31+
22 => 1,
32+
];
33+
}
34+
}
Collapse file

‎Magento2/ruleset.xml‎

Copy file name to clipboardExpand all lines: Magento2/ruleset.xml
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,9 @@
431431
<rule ref="Squiz.ControlStructures.ControlSignature">
432432
<severity>6</severity>
433433
<type>warning</type>
434+
<properties>
435+
<property name="requiredSpacesBeforeColon" value="0"/>
436+
</properties>
434437
</rule>
435438
<rule ref="Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace">
436439
<exclude-pattern>*.phtml</exclude-pattern>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.