Skip to content

Commit

Permalink
up: cs fix for the stdlib package
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed May 7, 2021
1 parent 82be8fc commit 1c469f7
Show file tree
Hide file tree
Showing 41 changed files with 393 additions and 64 deletions.
20 changes: 14 additions & 6 deletions src/stdlib/src/Collection.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact group@swoft.org
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Stdlib;

Expand Down Expand Up @@ -159,8 +167,8 @@ public function average($callback = null)
public function median($key = null)
{
$values = (isset($key) ? $this->pluck($key) : $this)->filter(function ($item) {
return $item !== null;
})->sort()->values();
return $item !== null;
})->sort()->values();

$count = $values->count();

Expand Down Expand Up @@ -197,7 +205,7 @@ public function mode($key = null): ?array

$counts = new self;

$collection->each(function ($value) use ($counts) {
$collection->each(function ($value) use ($counts): void {
$counts[$value] = isset($counts[$value]) ? $counts[$value] + 1 : 1;
});

Expand Down Expand Up @@ -310,9 +318,9 @@ public function dd(...$args): void
*/
public function dump(): self
{
(new static(func_get_args()))->push($this)->each(function ($item) {
var_dump($item);
});
(new static(func_get_args()))->push($this)->each(function ($item): void {
var_dump($item);
});

return $this;
}
Expand Down
8 changes: 8 additions & 0 deletions src/stdlib/src/Concern/ArrayPropertyTrait.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Stdlib\Concern;

Expand Down
8 changes: 8 additions & 0 deletions src/stdlib/src/Concern/DataPropertyTrait.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Stdlib\Concern;

Expand Down
8 changes: 8 additions & 0 deletions src/stdlib/src/Concern/RandomStringTrait.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Stdlib\Concern;

Expand Down
8 changes: 8 additions & 0 deletions src/stdlib/src/Contract/Arrayable.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Stdlib\Contract;

Expand Down
8 changes: 8 additions & 0 deletions src/stdlib/src/Contract/Jsonable.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact group@swoft.org
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Stdlib\Contract;

Expand Down
15 changes: 10 additions & 5 deletions src/stdlib/src/Fluent.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
<?php declare(strict_types=1);

/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact group@swoft.org
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Stdlib;


use ArrayAccess;
use JsonSerializable;
use Swoft\Stdlib\Contract\Arrayable;
Expand All @@ -19,7 +25,6 @@
*/
class Fluent implements ArrayAccess, Arrayable, Jsonable, JsonSerializable
{

/**
* All of the attributes set on the fluent instance.
*
Expand Down Expand Up @@ -184,7 +189,7 @@ public function __get($key)
*
* @return void
*/
public function __set($key, $value)
public function __set($key, $value): void
{
$this->offsetSet($key, $value);
}
Expand All @@ -208,7 +213,7 @@ public function __isset($key)
*
* @return void
*/
public function __unset($key)
public function __unset($key): void
{
$this->offsetUnset($key);
}
Expand Down
8 changes: 8 additions & 0 deletions src/stdlib/src/Helper/Arr.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Stdlib\Helper;

Expand Down
14 changes: 12 additions & 2 deletions src/stdlib/src/Helper/ArrayHelper.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact group@swoft.org
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Stdlib\Helper;

Expand Down Expand Up @@ -957,8 +965,10 @@ public static function has($array, $key): bool
}

foreach (explode('.', $key) as $segment) {
if ((is_array($array) && array_key_exists($segment,
$array)) || ($array instanceof ArrayAccess && $array->offsetExists($segment))
if ((is_array($array) && array_key_exists(
$segment,
$array
)) || ($array instanceof ArrayAccess && $array->offsetExists($segment))
) {
$array = $array[$segment];
} else {
Expand Down
8 changes: 8 additions & 0 deletions src/stdlib/src/Helper/ComposerHelper.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Stdlib\Helper;

Expand Down
9 changes: 8 additions & 1 deletion src/stdlib/src/Helper/Dir.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact group@swoft.org
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Stdlib\Helper;

Expand All @@ -9,5 +17,4 @@
*/
final class Dir extends DirectoryHelper
{

}
9 changes: 8 additions & 1 deletion src/stdlib/src/Helper/DirHelper.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact group@swoft.org
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Stdlib\Helper;

Expand All @@ -9,5 +17,4 @@
*/
final class DirHelper extends DirectoryHelper
{

}
9 changes: 8 additions & 1 deletion src/stdlib/src/Helper/DirectoryHelper.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Stdlib\Helper;

Expand Down Expand Up @@ -81,7 +89,6 @@ public static function iterator(string $path): IteratorIterator
return new IteratorIterator($directoryIterator);
}


/**
* Find all php files in the dir-path.
*
Expand Down
15 changes: 12 additions & 3 deletions src/stdlib/src/Helper/DocBlock.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?php declare(strict_types=1);

/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact group@swoft.org
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Stdlib\Helper;

Expand Down Expand Up @@ -43,7 +50,9 @@ public static function getTags(string $comment, array $options = [], array $defa

$comment = str_replace("\r\n", "\n", $comment);
$comment = "@{$default} \n" .
str_replace("\r", '',
str_replace(
"\r",
'',
trim(preg_replace('/^\s*\**( |\t)?/m', '', $comment))
);

Expand Down Expand Up @@ -135,4 +144,4 @@ public static function getPropertyDescription(string $className, string $propert

return $description;
}
}
}
8 changes: 8 additions & 0 deletions src/stdlib/src/Helper/EnvHelper.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Stdlib\Helper;

Expand Down
10 changes: 9 additions & 1 deletion src/stdlib/src/Helper/FSHelper.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Stdlib\Helper;

Expand Down
8 changes: 8 additions & 0 deletions src/stdlib/src/Helper/FileHelper.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Stdlib\Helper;

Expand Down
13 changes: 11 additions & 2 deletions src/stdlib/src/Helper/Functions.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact group@swoft.org
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

if (!function_exists('value')) {
/**
* Return the callback value
Expand Down Expand Up @@ -53,7 +62,7 @@ function tap($value, Closure $callback = null)
*
* @param mixed ...$vars
*/
function printr(...$vars)
function printr(...$vars): void
{
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);

Expand All @@ -78,7 +87,7 @@ function printr(...$vars)
*
* @param mixed ...$vars
*/
function vdump(...$vars)
function vdump(...$vars): void
{
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);

Expand Down
8 changes: 8 additions & 0 deletions src/stdlib/src/Helper/JsonHelper.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Stdlib\Helper;

Expand Down
8 changes: 8 additions & 0 deletions src/stdlib/src/Helper/ObjectHelper.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Stdlib\Helper;

Expand Down
Loading

0 comments on commit 1c469f7

Please sign in to comment.