Skip to content

Commit b197663

Browse files
authored
Merge pull request #190 from magento-commerce/develop
Version 25 master update
2 parents ab5a8ca + 7be8305 commit b197663

File tree

7 files changed

+60
-10
lines changed

7 files changed

+60
-10
lines changed

Magento2/Sniffs/CodeAnalysis/EmptyBlockSniff.php

+11
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ public function process(File $phpcsFile, $stackPtr)
3737
return;
3838
}
3939

40+
// Ignore empty constructor function blocks when using property promotion
41+
if ($tokens[$stackPtr]['code'] === T_FUNCTION &&
42+
strpos($phpcsFile->getDeclarationName($stackPtr), '__construct') === 0 &&
43+
count($phpcsFile->getMethodParameters($stackPtr)) > 0 &&
44+
array_reduce($phpcsFile->getMethodParameters($stackPtr), static function ($result, $methodParam) {
45+
return $result && isset($methodParam['property_visibility']);
46+
}, true)) {
47+
48+
return;
49+
}
50+
4051
parent::process($phpcsFile, $stackPtr);
4152
}//end process()
4253
}

Magento2/Sniffs/Less/ColonSpacingSniff.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,13 @@ private function needValidateSpaces(File $phpcsFile, $stackPtr, $tokens)
6060
return false;
6161
}
6262

63-
$prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
64-
if ($tokens[$prev]['code'] !== T_STYLE) {
65-
// The colon is not part of a style definition.
63+
// Avoid false positives when parsing pseudo-classes
64+
$next = $phpcsFile->findNext([T_SEMICOLON, T_OPEN_CURLY_BRACKET], $stackPtr + 1);
65+
if ($tokens[$next]['code'] === T_OPEN_CURLY_BRACKET) {
6666
return false;
6767
}
6868

69+
$prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
6970
if ($tokens[$prev]['content'] === 'progid') {
7071
// Special case for IE filters.
7172
return false;

Magento2/Tests/CodeAnalysis/EmptyBlockUnitTest.inc

+12
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,15 @@ function emptyFunction () { /*Empty function block*/ }
7676
function nonEmptyFunction () { return true; }
7777

7878
function aroundEmptyFunction ($foo, $bar) { }
79+
80+
class Foo {
81+
public function __construct(private $bar) {}
82+
}
83+
84+
class Foo2 {
85+
public function __construct() {}
86+
}
87+
88+
class Foo3 {
89+
public function __construct(private $bar, $baz) {}
90+
}

Magento2/Tests/CodeAnalysis/EmptyBlockUnitTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public function getErrorList()
2929
68 => 1,
3030
72 => 2,
3131
74 => 1,
32+
85 => 1,
33+
89 => 1
3234
];
3335
}
3436

Magento2/Tests/Less/ColonSpacingUnitTest.less

+29-5
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,46 @@
55

66

77
div#foo {
8-
blah:'abc';
8+
blah:'abc';
99
}
1010

1111
.my #foo .blah {
12-
some: 'stuff';
12+
some: 'stuff';
1313
}
1414

1515
.blah {
16-
foo :'jkl';
16+
foo :'jkl';
1717
}
1818

1919
.foo {
20-
bar:
20+
bar:
2121
'xyz';
2222
}
2323

2424
.right {
25-
way: 'good'
25+
way: 'good';
26+
}
27+
28+
a:active {
29+
color: #000;
30+
}
31+
32+
@abs-action-button-as-link: {
33+
&:not(:focus) {
34+
box-shadow: none;
35+
}
36+
}
37+
38+
.actions-toolbar {
39+
&:not(:first-child) {
40+
&:extend(.abs-add-clearfix all);
41+
> .secondary {
42+
.action {
43+
&.add {
44+
margin-top: @indent__l;
45+
}
46+
}
47+
float: left;
48+
}
49+
}
2650
}

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"AFL-3.0"
77
],
88
"type": "phpcodesniffer-standard",
9-
"version": "24",
9+
"version": "25",
1010
"require": {
1111
"php": ">=7.3",
1212
"webonyx/graphql-php": "^14.9",

composer.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)