Skip to content

Commit 20d16c4

Browse files
committed
coding style: fixes in code
1 parent 434084b commit 20d16c4

34 files changed

+106
-105
lines changed

src/Utils/DateTime.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static function from($time)
6666
*/
6767
public static function fromParts(int $year, int $month, int $day, int $hour = 0, int $minute = 0, float $second = 0)
6868
{
69-
$s = sprintf("%04d-%02d-%02d %02d:%02d:%02.5f", $year, $month, $day, $hour, $minute, $second);
69+
$s = sprintf('%04d-%02d-%02d %02d:%02d:%02.5f', $year, $month, $day, $hour, $minute, $second);
7070
if (!checkdate($month, $day, $year) || $hour < 0 || $hour > 23 || $minute < 0 || $minute > 59 || $second < 0 || $second >= 60) {
7171
throw new Nette\InvalidArgumentException("Invalid date '$s'");
7272
}

src/Utils/Html.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,9 @@ class Html implements \ArrayAccess, \Countable, \IteratorAggregate, IHtmlString
2828
{
2929
use Nette\SmartObject;
3030

31-
/** @var string element's name */
32-
private $name;
33-
34-
/** @var bool is element empty? */
35-
private $isEmpty;
36-
3731
/** @var array element's attributes */
3832
public $attrs = [];
3933

40-
/** @var array of Html | string nodes */
41-
protected $children = [];
42-
4334
/** @var bool use XHTML syntax? */
4435
public static $xhtml = false;
4536

@@ -50,6 +41,15 @@ class Html implements \ArrayAccess, \Countable, \IteratorAggregate, IHtmlString
5041
'isindex' => 1, 'wbr' => 1, 'command' => 1, 'track' => 1,
5142
];
5243

44+
/** @var array of Html | string nodes */
45+
protected $children = [];
46+
47+
/** @var string element's name */
48+
private $name;
49+
50+
/** @var bool is element empty? */
51+
private $isEmpty;
52+
5353

5454
/**
5555
* Static factory.
@@ -511,7 +511,7 @@ final public function __toString(): string
511511
try {
512512
return $this->render();
513513
} catch (\Throwable $e) {
514-
trigger_error("Exception in " . __METHOD__ . "(): {$e->getMessage()} in {$e->getFile()}:{$e->getLine()}", E_USER_ERROR);
514+
trigger_error('Exception in ' . __METHOD__ . "(): {$e->getMessage()} in {$e->getFile()}:{$e->getLine()}", E_USER_ERROR);
515515
}
516516
}
517517

src/Utils/Image.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ public function __toString(): string
549549
if (func_num_args()) {
550550
throw $e;
551551
}
552-
trigger_error("Exception in " . __METHOD__ . "(): {$e->getMessage()} in {$e->getFile()}:{$e->getLine()}", E_USER_ERROR);
552+
trigger_error('Exception in ' . __METHOD__ . "(): {$e->getMessage()} in {$e->getFile()}:{$e->getLine()}", E_USER_ERROR);
553553
}
554554
}
555555

src/Utils/Reflection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ final class Reflection
2121

2222
private static $builtinTypes = [
2323
'string' => 1, 'int' => 1, 'float' => 1, 'bool' => 1, 'array' => 1,
24-
'callable' => 1, 'iterable' => 1, 'void' => 1
24+
'callable' => 1, 'iterable' => 1, 'void' => 1,
2525
];
2626

2727

src/Utils/Strings.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public static function truncate(string $s, int $maxLen, string $append = "\u{202
192192
if ($maxLen < 1) {
193193
return $append;
194194

195-
} elseif ($matches = self::match($s, '#^.{1,'.$maxLen.'}(?=[\s\x00-/:-@\[-`{-~])#us')) {
195+
} elseif ($matches = self::match($s, '#^.{1,' . $maxLen . '}(?=[\s\x00-/:-@\[-`{-~])#us')) {
196196
return $matches[0] . $append;
197197

198198
} else {
@@ -316,7 +316,7 @@ public static function length(string $s): int
316316
public static function trim(string $s, string $charlist = self::TRIM_CHARACTERS): string
317317
{
318318
$charlist = preg_quote($charlist, '#');
319-
return self::replace($s, '#^['.$charlist.']+|['.$charlist.']+\z#u', '');
319+
return self::replace($s, '#^[' . $charlist . ']+|[' . $charlist . ']+\z#u', '');
320320
}
321321

322322

@@ -403,7 +403,7 @@ private static function pos(string $haystack, string $needle, int $nth = 1)
403403
return 0;
404404
}
405405
$pos = 0;
406-
while (false !== ($pos = strpos($haystack, $needle, $pos)) && --$nth) {
406+
while (($pos = strpos($haystack, $needle, $pos)) !== false && --$nth) {
407407
$pos++;
408408
}
409409
} else {
@@ -412,7 +412,7 @@ private static function pos(string $haystack, string $needle, int $nth = 1)
412412
return $len;
413413
}
414414
$pos = $len - 1;
415-
while (false !== ($pos = strrpos($haystack, $needle, $pos - $len)) && ++$nth) {
415+
while (($pos = strrpos($haystack, $needle, $pos - $len)) !== false && ++$nth) {
416416
$pos--;
417417
}
418418
}
@@ -501,7 +501,7 @@ public static function pcre(string $func, array $args)
501501
});
502502

503503
if (($code = preg_last_error()) // run-time error, but preg_last_error & return code are liars
504-
&& ($res === null || !in_array($func, ['preg_filter', 'preg_replace_callback', 'preg_replace']))
504+
&& ($res === null || !in_array($func, ['preg_filter', 'preg_replace_callback', 'preg_replace'], true))
505505
) {
506506
throw new RegexpException(($messages[$code] ?? 'Unknown error')
507507
. ' (pattern: ' . implode(' or ', (array) $args[0]) . ')', $code);

tests/Utils/Callback.closure.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require __DIR__ . '/../bootstrap.php';
1515

1616
class Test
1717
{
18-
function __invoke($a)
18+
public function __invoke($a)
1919
{
2020
return __METHOD__ . $a;
2121
}

tests/Utils/Html.data.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ test(function () { // special values
4949
test(function () { // setter
5050
$el = Html::el('div');
5151
$el->setAttribute('data-x', 'x');
52-
$el->setAttribute('data-list', [1,2,3]);
52+
$el->setAttribute('data-list', [1, 2, 3]);
5353
$el->setAttribute('data-arr', ['a' => 1]);
5454
$el->setAttribute('top', null);
5555
$el->setAttribute('active', false);

tests/Utils/Object.closureProperty.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class TestClass extends Nette\Object
1919
private $private;
2020

2121

22-
function __construct($func)
22+
public function __construct($func)
2323
{
2424
$this->public = $this->onPublic = $this->protected = $this->private = $func;
2525
}

tests/Utils/Object.events.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function handler($obj)
3131

3232
class Handler
3333
{
34-
function __invoke($obj)
34+
public function __invoke($obj)
3535
{
3636
$obj->counter++;
3737
}

tests/Utils/Object.extensionMethod.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ require __DIR__ . '/../bootstrap.php';
1313

1414
class TestClass extends Nette\Object
1515
{
16-
public $foo = 'Hello', $bar = 'World';
16+
public $foo = 'Hello';
17+
public $bar = 'World';
1718
}
1819

1920

0 commit comments

Comments
 (0)