Skip to content

Commit 004aab9

Browse files
committed
Fix issues reported by PHPCS and PHPUnit
1 parent cab8138 commit 004aab9

13 files changed

+47
-36
lines changed

phpcs.xml.dist

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<config name="show_progress" value="1" />
88
<config name="ignore_warnings_on_exit" value="1" />
9-
<config name="php_version" value="50630" />
9+
<config name="php_version" value="70300" />
1010

1111
<rule ref="PSR2" />
1212

@@ -38,8 +38,6 @@
3838

3939
<!-- Code Analysis Sniffs -->
4040

41-
<!-- Do not allow empty if, else or case -->
42-
<rule ref="Generic.CodeAnalysis.EmptyStatement" />
4341
<!-- Simple for loops (for(;true;){}) should be while -->
4442
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop" />
4543
<!-- Do not allow function in for(...) loops. Use a temporary variable to store the result instead -->
@@ -56,6 +54,10 @@
5654
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod" />
5755
<!-- This sniff class detects empty statement. -->
5856
<rule ref="Generic.CodeAnalysis.EmptyStatement" />
57+
<!-- Ignore empty CATCH statement -->
58+
<rule ref="Generic.CodeAnalysis.EmptyStatement.DetectedCatch">
59+
<severity>0</severity>
60+
</rule>
5961

6062
<!-- Commenting Sniffs -->
6163

@@ -82,10 +84,18 @@
8284
<!--<rule ref="Squiz.Commenting.FileComment" />-->
8385
<!-- Function comment blocks -->
8486
<rule ref="Squiz.Commenting.FunctionComment" />
87+
<!-- Ignore missing parameter comment -->
88+
<rule ref="Squiz.Commenting.FunctionComment.MissingParamComment">
89+
<severity>0</severity>
90+
</rule>
8591
<!-- Do not test scalar typehint (php-7 only feature) -->
8692
<rule ref="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing">
8793
<severity>0</severity>
8894
</rule>
95+
<!-- Do not test PHP-7 typehint (php-7 only feature) -->
96+
<rule ref="Squiz.Commenting.FunctionComment.TypeHintMissing">
97+
<type>warning</type>
98+
</rule>
8999
<!-- Verifies that a @throws tag exists for a function that throws exceptions -->
90100
<rule ref="Squiz.Commenting.FunctionCommentThrowTag" />
91101
<!-- Checks that there is adequate spacing between comments -->

src/Charcoal/Admin/Action/ElfinderConnectorAction.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -560,12 +560,12 @@ protected function resolveCallbacksForBindOption(array $toResolve)
560560
*
561561
* @todo Move this method to a dedicated plugin class.
562562
*
563-
* @param string $cmd The command name.
564-
* @param array $result The command result.
565-
* @param array $args The command arguments from the client.
566-
* @param object $elfinder The elFinder instance.
567-
* @param object $volume The current volume instance.
568-
* @return void|bool|array
563+
* @param string $cmd The command name.
564+
* @param mixed $result The command result.
565+
* @param mixed $args The command arguments from the client.
566+
* @param object $elfinder The elFinder instance.
567+
* @param object $volume The current volume instance.
568+
* @return void|boolean|array
569569
*/
570570
public function translateDirectoriesOnAnyCommand($cmd, &$result, $args, $elfinder, $volume)
571571
{
@@ -690,7 +690,7 @@ protected function translateFilesystemName(string $ident): ?string
690690
* @param string $src The temporary file name.
691691
* @param object $elfinder The elFinder instance.
692692
* @param object $volume The current volume instance.
693-
* @return void|bool|array
693+
* @return void|boolean|array
694694
*/
695695
public function sanitizeOnUploadPreSave(&$path, &$name, $src, $elfinder, $volume)
696696
{

src/Charcoal/Admin/Property/AbstractProperty.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ public function ident()
294294
* If a valid "function" option is not passed,
295295
* this method does nothing.
296296
*
297-
* @param string $val The value to escape.
298-
* @param array $options Optional escape options.
297+
* @param string $val The value to escape.
298+
* @param array $options Optional escape options.
299299
* @throws InvalidArgumentException If the value to escape is not a string.
300300
* @return string
301301
*/

src/Charcoal/Admin/Property/AbstractPropertyDisplay.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public function setDisplayEscape($escape)
258258
*/
259259
public function getDisplayEscape()
260260
{
261-
return $this->getDisplayEscapeOptions()['function'] ?? null;
261+
return ($this->getDisplayEscapeOptions()['function'] ?? null);
262262
}
263263

264264
/**
@@ -288,8 +288,8 @@ public function getDisplayEscapeOptions()
288288
/**
289289
* Escapes the given value according to display escape options.
290290
*
291-
* @param string $val The value to escape.
292-
* @param array $options Optional escape options.
291+
* @param string $val The value to escape.
292+
* @param array $options Optional escape options.
293293
* @throws InvalidArgumentException If the value to escape is not a string.
294294
* @return string
295295
*/
@@ -328,6 +328,7 @@ public function escapeVal($val, array $options = [])
328328
}
329329

330330
/**
331+
* @throws UnexpectedValueException If the value is not a scalar.
331332
* @return string
332333
*/
333334
public function displayVal()

src/Charcoal/Admin/Property/AbstractPropertyInput.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ public function setInputEscape($escape)
310310
*/
311311
public function getInputEscape()
312312
{
313-
return $this->getInputEscapeOptions()['function'] ?? null;
313+
return ($this->getInputEscapeOptions()['function'] ?? null);
314314
}
315315

316316
/**
@@ -340,8 +340,8 @@ public function getInputEscapeOptions()
340340
/**
341341
* Escapes the given value according to input escape options.
342342
*
343-
* @param string $val The value to escape.
344-
* @param array $options Optional escape options.
343+
* @param string $val The value to escape.
344+
* @param array $options Optional escape options.
345345
* @throws InvalidArgumentException If the value to escape is not a string.
346346
* @return string
347347
*/
@@ -508,7 +508,7 @@ public function inputPrefix()
508508
}
509509
}
510510

511-
return $this->inputPrefix ?? null;
511+
return ($this->inputPrefix ?? null);
512512
}
513513

514514
/**
@@ -559,7 +559,7 @@ public function inputSuffix()
559559
}
560560
}
561561

562-
return $this->inputSuffix ?? null;
562+
return ($this->inputSuffix ?? null);
563563
}
564564

565565
/**
@@ -655,7 +655,7 @@ public function setPlaceholder($placeholder)
655655
}
656656

657657
/**
658-
* @return bool
658+
* @return boolean
659659
*/
660660
public function hasPlaceholder()
661661
{
@@ -687,7 +687,7 @@ public function placeholder()
687687
}
688688
}
689689

690-
return $this->placeholder ?? null;
690+
return ($this->placeholder ?? null);
691691
}
692692

693693
/**

src/Charcoal/Admin/Property/Display/MessageDisplay.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function setMessage($message)
6060
}
6161

6262
/**
63-
* @return bool
63+
* @return boolean
6464
*/
6565
public function hasMessage()
6666
{

src/Charcoal/Admin/Property/Input/ReadonlyInput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public function maybeUnserializeValue($input)
224224
{
225225
if (!is_null($input) && $this->maybeInputIsSerialized()) {
226226
try {
227-
$output = json_decode($input, false, 512, JSON_THROW_ON_ERROR);
227+
$output = json_decode($input, false, 512, JSON_THROW_ON_ERROR);
228228
if (!is_scalar($output) && !is_null($output)) {
229229
return $output;
230230
}

src/Charcoal/Admin/Support/Sorter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Sorter
1010
/**
1111
* Compares the priority attribute of two array-accessible variables
1212
* to determine if the first variable is considered to be respectively
13-
* less than, equal to, or greater than the second.
13+
* less than, equal to, or greater than the second.
1414
*
1515
* To be called with {@see uasort()}.
1616
*

src/Charcoal/Admin/Ui/HasLanguageSwitcherTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function languages()
7070
/**
7171
* Resolves whether to display the language switcher or not.
7272
*
73-
* @var boolean
73+
* @return boolean
7474
*/
7575
abstract protected function resolveShowLanguageSwitch();
7676
}

src/Charcoal/Admin/Ui/LanguageSwitcherAwareInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface LanguageSwitcherAwareInterface
1313
/**
1414
* Whether a language switcher could be displayed.
1515
*
16-
* @return bool
16+
* @return boolean
1717
*/
1818
public function supportsLanguageSwitch(): bool;
1919
}

src/Charcoal/Admin/Widget/FormWidget.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ public function addSidebar($sidebarIdent, $sidebar)
392392
*/
393393
public function hasSidebars()
394394
{
395-
return (bool) $this->sidebars;
395+
return (bool)$this->sidebars;
396396
}
397397

398398
/**
@@ -617,7 +617,7 @@ public function hiddenProperties()
617617
/**
618618
* Whether a language switcher could be displayed.
619619
*
620-
* @return bool
620+
* @return boolean
621621
*/
622622
public function supportsLanguageSwitch(): bool
623623
{

src/Charcoal/Admin/Widget/ObjectFormWidget.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ protected function dataFromObject()
573573
/**
574574
* Whether a language switcher could be displayed.
575575
*
576-
* @return bool
576+
* @return boolean
577577
*/
578578
public function supportsLanguageSwitch(): bool
579579
{
@@ -624,7 +624,7 @@ public function hasL10nFormProperties()
624624
* Determine if the group has any multilingual properties.
625625
*
626626
* @param FormGroupInterface $group
627-
* @return bool
627+
* @return boolean
628628
*/
629629
protected function hasL10nGroupProperties(FormGroupInterface $group)
630630
{

tests/Charcoal/Admin/Widget/GraphWidgetTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ public function testSetData()
3232
{
3333
$obj = $this->obj;
3434
$ret = $obj->setData([
35-
'height'=>222,
36-
'colors'=>['#ff0000', '#0000ff']
35+
'height' => 222,
36+
'colors' => ['#ff0000', '#0000ff']
3737
]);
3838
$this->assertSame($obj, $ret);
39-
$this->assertEquals(222, $obj->height());
39+
$this->assertEquals('222px', $obj->height());
4040
$this->assertEquals(['#ff0000', '#0000ff'], $obj->colors());
4141
}
4242

@@ -46,11 +46,11 @@ public function testSetData()
4646
public function testSetHeight()
4747
{
4848
$obj = $this->obj;
49-
$this->assertEquals(400, $obj->height());
49+
$this->assertEquals('400px', $obj->height());
5050

5151
$ret = $obj->setHeight(333);
5252
$this->assertSame($obj, $ret);
53-
$this->assertEquals(333, $obj->height());
53+
$this->assertEquals('333px', $obj->height());
5454

5555
//$this->expectException('\InvalidArgumentException');
5656
//$obj->setHeight(false);

0 commit comments

Comments
 (0)