Skip to content

Commit bcaa672

Browse files
authored
[TASK] Switch to the PER2 coding standard (MyIntervals#467)
Fixes MyIntervals#442
1 parent c00e588 commit bcaa672

File tree

8 files changed

+28
-30
lines changed

8 files changed

+28
-30
lines changed

config/php-cs-fixer.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,27 @@
88
->setRiskyAllowed(true)
99
->setRules(
1010
[
11-
'@PSR12' => true,
12-
// Disable constant visibility from the PSR12 rule set as this would break compatibility with PHP < 7.1.
13-
'visibility_required' => ['elements' => ['property', 'method']],
11+
'@PER-CS2.0' => true,
12+
'@PER-CS2.0:risky' => true,
1413

1514
'@PHPUnit50Migration:risky' => true,
1615
'@PHPUnit52Migration:risky' => true,
1716
'@PHPUnit54Migration:risky' => true,
1817
'@PHPUnit55Migration:risky' => true,
1918
'@PHPUnit56Migration:risky' => true,
2019
'@PHPUnit57Migration:risky' => true,
20+
'@PHPUnit60Migration:risky' => true,
21+
'@PHPUnit75Migration:risky' => true,
22+
'@PHPUnit84Migration:risky' => true,
2123

2224
'php_unit_construct' => true,
23-
'php_unit_dedicate_assert' => ['target' => '5.6'],
24-
'php_unit_expectation' => ['target' => '5.6'],
25+
'php_unit_dedicate_assert' => ['target' => 'newest'],
26+
'php_unit_expectation' => ['target' => 'newest'],
2527
'php_unit_fqcn_annotation' => true,
2628
'php_unit_method_casing' => true,
27-
'php_unit_mock' => ['target' => '5.5'],
29+
'php_unit_mock' => ['target' => 'newest'],
2830
'php_unit_mock_short_will_return' => true,
29-
'php_unit_namespaced' => ['target' => '5.7'],
31+
'php_unit_namespaced' => ['target' => 'newest'],
3032
'php_unit_set_up_tear_down_visibility' => true,
3133
'php_unit_test_annotation' => ['style' => 'annotation'],
3234
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],

src/CSSList/CSSBlockList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ protected function allSelectors(array &$aResult, $sSpecificitySearch = null)
113113
$sComparator = $aSpecificitySearch[0];
114114
$iTargetSpecificity = $aSpecificitySearch[1];
115115
}
116-
$iTargetSpecificity = (int)$iTargetSpecificity;
116+
$iTargetSpecificity = (int) $iTargetSpecificity;
117117
$iSelectorSpecificity = $oSelector->getSpecificity();
118118
$bMatches = false;
119119
switch ($sComparator) {

src/OutputFormat.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,7 @@ class OutputFormat
165165
*/
166166
private $iIndentationLevel = 0;
167167

168-
public function __construct()
169-
{
170-
}
168+
public function __construct() {}
171169

172170
/**
173171
* @param string $sName

src/Parsing/UnexpectedEOFException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,4 @@
77
*
88
* Extends `UnexpectedTokenException` in order to preserve backwards compatibility.
99
*/
10-
class UnexpectedEOFException extends UnexpectedTokenException
11-
{
12-
}
10+
class UnexpectedEOFException extends UnexpectedTokenException {}

src/RuleSet/DeclarationBlock.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,9 +682,9 @@ public function createDimensionsShorthand()
682682
$aValues[$sPosition] = $aRuleValues;
683683
}
684684
$oNewRule = new Rule($sProperty, $oRule->getLineNo(), $oRule->getColNo());
685-
if ((string)$aValues['left'][0] == (string)$aValues['right'][0]) {
686-
if ((string)$aValues['top'][0] == (string)$aValues['bottom'][0]) {
687-
if ((string)$aValues['top'][0] == (string)$aValues['left'][0]) {
685+
if ((string) $aValues['left'][0] == (string) $aValues['right'][0]) {
686+
if ((string) $aValues['top'][0] == (string) $aValues['bottom'][0]) {
687+
if ((string) $aValues['top'][0] == (string) $aValues['left'][0]) {
688688
// All 4 sides are equal
689689
$oNewRule->addValue($aValues['top']);
690690
} else {

src/Value/Size.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class Size extends PrimitiveValue
5858
public function __construct($fSize, $sUnit = null, $bIsColorComponent = false, $iLineNo = 0)
5959
{
6060
parent::__construct($iLineNo);
61-
$this->fSize = (float)$fSize;
61+
$this->fSize = (float) $fSize;
6262
$this->sUnit = $sUnit;
6363
$this->bIsColorComponent = $bIsColorComponent;
6464
}
@@ -103,7 +103,7 @@ public static function parse(ParserState $oParserState, $bIsColorComponent = fal
103103
}
104104
}
105105
}
106-
return new Size((float)$sSize, $sUnit, $bIsColorComponent, $oParserState->currentLine());
106+
return new Size((float) $sSize, $sUnit, $bIsColorComponent, $oParserState->currentLine());
107107
}
108108

109109
/**
@@ -150,7 +150,7 @@ public function getUnit()
150150
*/
151151
public function setSize($fSize)
152152
{
153-
$this->fSize = (float)$fSize;
153+
$this->fSize = (float) $fSize;
154154
}
155155

156156
/**
@@ -211,7 +211,7 @@ public function render(OutputFormat $oOutputFormat)
211211
{
212212
$l = localeconv();
213213
$sPoint = preg_quote($l['decimal_point'], '/');
214-
$sSize = preg_match("/[\d\.]+e[+-]?\d+/i", (string)$this->fSize)
214+
$sSize = preg_match("/[\d\.]+e[+-]?\d+/i", (string) $this->fSize)
215215
? preg_replace("/$sPoint?0+$/", "", sprintf("%f", $this->fSize)) : $this->fSize;
216216
return preg_replace(["/$sPoint/", "/^(-?)0\./"], ['.', '$1.'], $sSize)
217217
. ($this->sUnit === null ? '' : $this->sUnit);

tests/Comment/CommentTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function toStringRendersCommentEnclosedInCommentDelimiters()
9191

9292
$subject->setComment($comment);
9393

94-
self::assertSame('/*' . $comment . '*/', (string)$subject);
94+
self::assertSame('/*' . $comment . '*/', (string) $subject);
9595
}
9696

9797
/**

tests/RuleSet/DeclarationBlockTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function expandBorderShorthand($sCss, $sExpected)
2727
foreach ($oDoc->getAllDeclarationBlocks() as $oDeclaration) {
2828
$oDeclaration->expandBorderShorthand();
2929
}
30-
self::assertSame(trim((string)$oDoc), $sExpected);
30+
self::assertSame(trim((string) $oDoc), $sExpected);
3131
}
3232

3333
/**
@@ -60,7 +60,7 @@ public function expandFontShorthand($sCss, $sExpected)
6060
foreach ($oDoc->getAllDeclarationBlocks() as $oDeclaration) {
6161
$oDeclaration->expandFontShorthand();
6262
}
63-
self::assertSame(trim((string)$oDoc), $sExpected);
63+
self::assertSame(trim((string) $oDoc), $sExpected);
6464
}
6565

6666
/**
@@ -116,7 +116,7 @@ public function expandBackgroundShorthand($sCss, $sExpected)
116116
foreach ($oDoc->getAllDeclarationBlocks() as $oDeclaration) {
117117
$oDeclaration->expandBackgroundShorthand();
118118
}
119-
self::assertSame(trim((string)$oDoc), $sExpected);
119+
self::assertSame(trim((string) $oDoc), $sExpected);
120120
}
121121

122122
/**
@@ -169,7 +169,7 @@ public function expandDimensionsShorthand($sCss, $sExpected)
169169
foreach ($oDoc->getAllDeclarationBlocks() as $oDeclaration) {
170170
$oDeclaration->expandDimensionsShorthand();
171171
}
172-
self::assertSame(trim((string)$oDoc), $sExpected);
172+
self::assertSame(trim((string) $oDoc), $sExpected);
173173
}
174174

175175
/**
@@ -207,7 +207,7 @@ public function createBorderShorthand($sCss, $sExpected)
207207
foreach ($oDoc->getAllDeclarationBlocks() as $oDeclaration) {
208208
$oDeclaration->createBorderShorthand();
209209
}
210-
self::assertSame(trim((string)$oDoc), $sExpected);
210+
self::assertSame(trim((string) $oDoc), $sExpected);
211211
}
212212

213213
/**
@@ -238,7 +238,7 @@ public function createFontShorthand($sCss, $sExpected)
238238
foreach ($oDoc->getAllDeclarationBlocks() as $oDeclaration) {
239239
$oDeclaration->createFontShorthand();
240240
}
241-
self::assertSame(trim((string)$oDoc), $sExpected);
241+
self::assertSame(trim((string) $oDoc), $sExpected);
242242
}
243243

244244
/**
@@ -281,7 +281,7 @@ public function createDimensionsShorthand($sCss, $sExpected)
281281
foreach ($oDoc->getAllDeclarationBlocks() as $oDeclaration) {
282282
$oDeclaration->createDimensionsShorthand();
283283
}
284-
self::assertSame(trim((string)$oDoc), $sExpected);
284+
self::assertSame(trim((string) $oDoc), $sExpected);
285285
}
286286

287287
/**
@@ -319,7 +319,7 @@ public function createBackgroundShorthand($sCss, $sExpected)
319319
foreach ($oDoc->getAllDeclarationBlocks() as $oDeclaration) {
320320
$oDeclaration->createBackgroundShorthand();
321321
}
322-
self::assertSame(trim((string)$oDoc), $sExpected);
322+
self::assertSame(trim((string) $oDoc), $sExpected);
323323
}
324324

325325
/**

0 commit comments

Comments
 (0)