Skip to content

Commit b4e1eab

Browse files
committed
style: run cs fix for all codes
1 parent c4e56cd commit b4e1eab

17 files changed

+106
-33
lines changed

.php_cs renamed to .php-cs-fixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
'void_return' => true, // add :void for method
3737
];
3838

39-
return PhpCsFixer\Config::create()
39+
return (new PhpCsFixer\Config)
4040
->setRiskyAllowed(true)
4141
->setRules($rules)
4242
->setFinder(

src/Arr/ArrayHelper.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -718,14 +718,14 @@ public static function toString(
718718

719719
if (is_array($value)) {
720720
$string .= $keyStr . 'Array(' . self::toString(
721-
$value,
722-
$length,
723-
$cycles,
724-
$showKey,
725-
$addMark,
726-
$separator,
727-
$string
728-
) . ')' . $separator;
721+
$value,
722+
$length,
723+
$cycles,
724+
$showKey,
725+
$addMark,
726+
$separator,
727+
$string
728+
) . ')' . $separator;
729729
} elseif (is_object($value)) {
730730
$string .= $keyStr . 'Object(' . get_class($value) . ')' . $separator;
731731
} elseif (is_resource($value)) {

src/Arr/Traits/ArrayValueGetSetTrait.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
*/
3030
trait ArrayValueGetSetTrait
3131
{
32-
3332
/**
3433
* Add an element to an array using "dot" notation if it doesn't exist.
3534
*
@@ -266,5 +265,4 @@ public static function setByPath(&$data, string $path, $value, string $separator
266265
// Now, path go to the end, means we get latest node, set value to this node.
267266
$dataTmp = $value;
268267
}
269-
270268
}

src/Helper/DataHelper.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<?php declare(strict_types=1);
2+
/**
3+
* This file is part of toolkit/stdlib.
4+
*
5+
* @author https://github.com/inhere
6+
* @link https://github.com/php-toolkit/stdlib
7+
* @license MIT
8+
*/
29

310
namespace Toolkit\Stdlib\Helper;
411

src/Math.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<?php declare(strict_types=1);
2+
/**
3+
* This file is part of toolkit/stdlib.
4+
*
5+
* @author https://github.com/inhere
6+
* @link https://github.com/php-toolkit/stdlib
7+
* @license MIT
8+
*/
29

310
namespace Toolkit\Stdlib;
411

src/Obj/Traits/CreateSingletonTrait.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<?php declare(strict_types=1);
2+
/**
3+
* This file is part of toolkit/stdlib.
4+
*
5+
* @author https://github.com/inhere
6+
* @link https://github.com/php-toolkit/stdlib
7+
* @license MIT
8+
*/
29

310
namespace Toolkit\Stdlib\Obj\Traits;
411

src/Str/StrHelper.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<?php declare(strict_types=1);
2+
/**
3+
* This file is part of toolkit/stdlib.
4+
*
5+
* @author https://github.com/inhere
6+
* @link https://github.com/php-toolkit/stdlib
7+
* @license MIT
8+
*/
29

310
namespace Toolkit\Stdlib\Str;
411

@@ -9,5 +16,4 @@
916
*/
1017
class StrHelper extends StringHelper
1118
{
12-
1319
}

src/Str/StrObject.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<?php declare(strict_types=1);
2+
/**
3+
* This file is part of toolkit/stdlib.
4+
*
5+
* @author https://github.com/inhere
6+
* @link https://github.com/php-toolkit/stdlib
7+
* @license MIT
8+
*/
29

310
namespace Toolkit\Stdlib\Str;
411

@@ -265,5 +272,4 @@ public function __toString(): string
265272
{
266273
return $this->string;
267274
}
268-
269275
}

src/Str/Traits/StringCheckHelperTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public static function strrpos(string $str, string $find, int $offset = 0, strin
197197
*/
198198
public static function hasPrefix(string $str, string $prefix): bool
199199
{
200-
return self::strpos($str,$prefix) === 0;
200+
return self::strpos($str, $prefix) === 0;
201201
}
202202

203203
/**

src/Str/Traits/StringConvertTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,6 @@ public static function splitUnicode(string $str, int $length = 1): array
212212
return $ret;
213213
}
214214

215-
return preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY);
215+
return preg_split('//u', $str, -1, PREG_SPLIT_NO_EMPTY);
216216
}
217217
}

src/Str/Traits/StringTruncateHelperTrait.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<?php declare(strict_types=1);
2-
2+
/**
3+
* This file is part of toolkit/stdlib.
4+
*
5+
* @author https://github.com/inhere
6+
* @link https://github.com/php-toolkit/stdlib
7+
* @license MIT
8+
*/
39

410
namespace Toolkit\Stdlib\Str\Traits;
511

@@ -204,7 +210,7 @@ public static function truncate3(string $text, int $length = 120, array $options
204210
* @var bool $html
205211
*/
206212
if ($html) {
207-
if (self::strlen(\preg_replace('/<.*?>/', '', $text)) <= $length) {
213+
if (self::strlen(preg_replace('/<.*?>/', '', $text)) <= $length) {
208214
return $text;
209215
}
210216

@@ -318,5 +324,4 @@ public static function truncate3(string $text, int $length = 120, array $options
318324

319325
return $truncate;
320326
}
321-
322-
}
327+
}

src/func.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
<?php
1+
<?php declare(strict_types=1);
2+
/**
3+
* This file is part of toolkit/stdlib.
4+
*
5+
* @author https://github.com/inhere
6+
* @link https://github.com/php-toolkit/stdlib
7+
* @license MIT
8+
*/
29

310
if (!function_exists('vdump')) {
411
/**
512
* Dump data like var_dump
613
*
714
* @param mixed ...$vars
815
*/
9-
function vdump(...$vars)
16+
function vdump(...$vars): void
1017
{
1118
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
1219

@@ -27,7 +34,7 @@ function vdump(...$vars)
2734
*
2835
* @param mixed ...$vars
2936
*/
30-
function edump(...$vars)
37+
function edump(...$vars): void
3138
{
3239
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
3340

@@ -49,7 +56,7 @@ function edump(...$vars)
4956
*
5057
* @param mixed ...$vars
5158
*/
52-
function ddump(...$vars)
59+
function ddump(...$vars): void
5360
{
5461
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
5562

@@ -71,7 +78,7 @@ function ddump(...$vars)
7178
*
7279
* @param mixed ...$vars
7380
*/
74-
function pprint(...$vars)
81+
function pprint(...$vars): void
7582
{
7683
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
7784

@@ -92,7 +99,7 @@ function pprint(...$vars)
9299
*
93100
* @param mixed ...$vars
94101
*/
95-
function eprints(...$vars)
102+
function eprints(...$vars): void
96103
{
97104
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
98105

test/Helper/DataHelperTest.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
<?php declare(strict_types=1);
2+
/**
3+
* This file is part of toolkit/stdlib.
4+
*
5+
* @author https://github.com/inhere
6+
* @link https://github.com/php-toolkit/stdlib
7+
* @license MIT
8+
*/
29

310
namespace Toolkit\StdlibTest\Str;
411

512
use PHPUnit\Framework\TestCase;
613
use Toolkit\Stdlib\Helper\DataHelper;
14+
use Toolkit\Stdlib\Str;
715

816
/**
917
* Class DataHelperTest
@@ -33,13 +41,7 @@ public function testToString(): void
3341
self::assertEquals('<NULL>', DataHelper::toString(null));
3442
self::assertEquals('["ab",23]', DataHelper::toString(['ab', 23]));
3543

36-
$objStr = <<<OBJ
37-
object(stdClass)#73 (2) {
38-
["0"]=> string(2) "ab"
39-
["1"]=> int(23)
40-
}
41-
42-
OBJ;
43-
self::assertEquals($objStr, DataHelper::toString((object)['ab', 23]));
44+
$str = DataHelper::toString((object)['ab', 23]);
45+
self::assertTrue(Str::contains($str, 'object(stdClass)'));
4446
}
4547
}

test/OSTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<?php declare(strict_types=1);
2+
/**
3+
* This file is part of toolkit/stdlib.
4+
*
5+
* @author https://github.com/inhere
6+
* @link https://github.com/php-toolkit/stdlib
7+
* @license MIT
8+
*/
29

310
namespace Toolkit\StdlibTest;
411

test/Str/StrBufferTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<?php declare(strict_types=1);
2+
/**
3+
* This file is part of toolkit/stdlib.
4+
*
5+
* @author https://github.com/inhere
6+
* @link https://github.com/php-toolkit/stdlib
7+
* @license MIT
8+
*/
29

310
namespace Toolkit\StdlibTest\Str;
411

test/Str/StrObjectTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<?php declare(strict_types=1);
2+
/**
3+
* This file is part of toolkit/stdlib.
4+
*
5+
* @author https://github.com/inhere
6+
* @link https://github.com/php-toolkit/stdlib
7+
* @license MIT
8+
*/
29

310
namespace Toolkit\StdlibTest\Str;
411

test/Str/StringHelperTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<?php declare(strict_types=1);
2+
/**
3+
* This file is part of toolkit/stdlib.
4+
*
5+
* @author https://github.com/inhere
6+
* @link https://github.com/php-toolkit/stdlib
7+
* @license MIT
8+
*/
29

310
namespace Toolkit\StdlibTest\Str;
411

0 commit comments

Comments
 (0)