Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CS] Fixes based on added php-cs-fixer config
Browse files Browse the repository at this point in the history
veewee committed Oct 15, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 1f8cc1f commit bf86fef
Showing 314 changed files with 1,552 additions and 1,567 deletions.
4 changes: 3 additions & 1 deletion src/Psl/Arr/contains_key.php
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@

namespace Psl\Arr;

use function array_key_exists;

/**
* Returns true if the given array contains the key.
*
@@ -17,5 +19,5 @@
*/
function contains_key(array $array, $key): bool
{
return \array_key_exists($key, $array);
return array_key_exists($key, $array);
}
1 change: 0 additions & 1 deletion src/Psl/Arr/drop.php
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@

namespace Psl\Arr;

use Generator;
use Psl;

/**
4 changes: 3 additions & 1 deletion src/Psl/Arr/first_key.php
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@

namespace Psl\Arr;

use function array_key_first;

/**
* Get the first key of an array, if the array is empty, null will be returned.
*
@@ -17,5 +19,5 @@
*/
function first_key(array $array)
{
return \array_key_first($array);
return array_key_first($array);
}
1 change: 0 additions & 1 deletion src/Psl/Arr/group_by.php
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@
namespace Psl\Arr;

use Psl;
use Psl\Str;
use Psl\Type;

/**
4 changes: 3 additions & 1 deletion src/Psl/Arr/keys.php
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@

namespace Psl\Arr;

use function array_keys;

/**
* Return all the keys of an array.
*
@@ -18,5 +20,5 @@
*/
function keys(array $arr): array
{
return \array_keys($arr);
return array_keys($arr);
}
1 change: 0 additions & 1 deletion src/Psl/Arr/sort.php
Original file line number Diff line number Diff line change
@@ -19,7 +19,6 @@
* @psalm-param array<Tk, Tv> $array
* @psalm-param (callable(Tv, Tv): int)|null $comparator
*
* @return array
*
* @psalm-return list<Tv>
*/
7 changes: 5 additions & 2 deletions src/Psl/Arr/sort_by.php
Original file line number Diff line number Diff line change
@@ -4,6 +4,9 @@

namespace Psl\Arr;

use function asort;
use function uasort;

/**
* Returns a new array sorted by some scalar property of each value of the given
* iterable, which is computed by the given function.
@@ -33,9 +36,9 @@ function sort_by(iterable $iterable, callable $scalar_func, ?callable $comparato
}

if (null !== $comparator) {
\uasort($order_by, $comparator);
uasort($order_by, $comparator);
} else {
\asort($order_by);
asort($order_by);
}

$result = [];
7 changes: 5 additions & 2 deletions src/Psl/Arr/sort_by_key.php
Original file line number Diff line number Diff line change
@@ -4,6 +4,9 @@

namespace Psl\Arr;

use function ksort;
use function uksort;

/**
* Returns a new array sorted by the keys of the given array. If the
* optional comparator function isn't provided, the keys will be sorted in
@@ -20,9 +23,9 @@
function sort_by_key(array $array, ?callable $comparator = null): array
{
if ($comparator) {
\uksort($array, $comparator);
uksort($array, $comparator);
} else {
\ksort($array);
ksort($array);
}

return $array;
7 changes: 5 additions & 2 deletions src/Psl/Arr/sort_with_keys.php
Original file line number Diff line number Diff line change
@@ -4,6 +4,9 @@

namespace Psl\Arr;

use function asort;
use function uasort;

/**
* Returns a new array sorted by the values of the given array. If the
* optional comparator function isn't provided, the values will be sorted in
@@ -20,9 +23,9 @@
function sort_with_keys(array $array, ?callable $comparator = null): array
{
if (null !== $comparator) {
\uasort($array, $comparator);
uasort($array, $comparator);
} else {
\asort($array);
asort($array);
}

return $array;
2 changes: 1 addition & 1 deletion src/Psl/Arr/sort_with_keys_by.php
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ function sort_with_keys_by(iterable $iterable, callable $scalar_func, ?callable
* @psalm-param array{0: Ts, 1: Tv} $a
* @psalm-param array{0: Ts, 1: Tv} $b
*/
fn ($a, $b): int => $comparator($a[0], $b[0]);
static fn ($a, $b): int => $comparator($a[0], $b[0]);

/**
* @psalm-var array<Tk, array{0: Ts, 1: Tv}> $tuples
2 changes: 0 additions & 2 deletions src/Psl/Arr/unique_by.php
Original file line number Diff line number Diff line change
@@ -4,8 +4,6 @@

namespace Psl\Arr;

use Psl;

/**
* Returns a new array in which each value appears exactly once, where the
* value's uniqueness is determined by transforming it to a scalar via the
2 changes: 1 addition & 1 deletion src/Psl/Collection/MutableVectorInterface.php
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
* @extends VectorInterface<T>
* @extends MutableAccessibleCollectionInterface<int, T>
*/
interface MutableVectorInterface extends VectorInterface, MutableAccessibleCollectionInterface
interface MutableVectorInterface extends MutableAccessibleCollectionInterface, VectorInterface
{
/**
* Get an array copy of the current vector.
3 changes: 0 additions & 3 deletions src/Psl/DataStructure/PriorityQueueInterface.php
Original file line number Diff line number Diff line change
@@ -4,9 +4,6 @@

namespace Psl\DataStructure;

use Psl;
use Countable;

/**
* @template T
*
2 changes: 1 addition & 1 deletion src/Psl/DataStructure/QueueInterface.php
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@

namespace Psl\DataStructure;

use Psl;
use Countable;
use Psl;

/**
* An interface representing a queue data structure ( FIFO ).
2 changes: 1 addition & 1 deletion src/Psl/DataStructure/StackInterface.php
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@

namespace Psl\DataStructure;

use Psl;
use Countable;
use Psl;

/**
* An interface representing a stack data structure ( LIFO ).
2 changes: 0 additions & 2 deletions src/Psl/Env/get_vars.php
Original file line number Diff line number Diff line change
@@ -4,8 +4,6 @@

namespace Psl\Env;

use Psl;

use function getenv;

/**
1 change: 0 additions & 1 deletion src/Psl/Env/set_current_dir.php
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@
/**
* Changes the current working directory to the specified path.
*
* @param string $directory
*
* @throws Psl\Exception\InvariantViolationException If the operation fails.
*/
2 changes: 0 additions & 2 deletions src/Psl/Env/temp_dir.php
Original file line number Diff line number Diff line change
@@ -4,8 +4,6 @@

namespace Psl\Env;

use Psl;

use function sys_get_temp_dir;

/**
4 changes: 3 additions & 1 deletion src/Psl/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
@@ -4,9 +4,11 @@

namespace Psl\Exception;

use Throwable;

/**
* @internal
*/
interface ExceptionInterface extends \Throwable
interface ExceptionInterface extends Throwable
{
}
2 changes: 1 addition & 1 deletion src/Psl/Exception/InvariantViolationException.php
Original file line number Diff line number Diff line change
@@ -4,6 +4,6 @@

namespace Psl\Exception;

final class InvariantViolationException extends RuntimeException
class InvariantViolationException extends RuntimeException
{
}
4 changes: 1 addition & 3 deletions src/Psl/Internal/internal_encoding.php
Original file line number Diff line number Diff line change
@@ -5,12 +5,10 @@
namespace Psl\Internal;

use Psl;
use Psl\Type;
use Psl\Exception;
use Psl\Type;

use function in_array;
use function mb_internal_encoding;
use function mb_list_encodings;

/**
* @psalm-pure
5 changes: 0 additions & 5 deletions src/Psl/Internal/is_encoding_valid.php
Original file line number Diff line number Diff line change
@@ -4,12 +4,7 @@

namespace Psl\Internal;

use Psl;
use Psl\Type;
use Psl\Exception;

use function in_array;
use function mb_internal_encoding;
use function mb_list_encodings;

/**
2 changes: 0 additions & 2 deletions src/Psl/Internal/type.php
Original file line number Diff line number Diff line change
@@ -11,8 +11,6 @@
/**
* @param mixed $value
*
* @return string
*
* @psalm-pure
*
* @codeCoverageIgnore
2 changes: 1 addition & 1 deletion src/Psl/Iter/Iterator.php
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
*
* @implements SeekableIterator<Tk, Tv>
*/
final class Iterator implements SeekableIterator, Countable
final class Iterator implements Countable, SeekableIterator
{
/**
* @psalm-var Generator<Tk, Tv, mixed, mixed>
2 changes: 0 additions & 2 deletions src/Psl/Iter/contains_key.php
Original file line number Diff line number Diff line change
@@ -4,8 +4,6 @@

namespace Psl\Iter;

use Psl\Arr;

/**
* Returns true if the given iterable contains the key.
*
4 changes: 3 additions & 1 deletion src/Psl/Iter/count.php
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@

namespace Psl\Iter;

use function is_countable;

/**
* Returns the number of elements an iterable contains.
*
@@ -26,7 +28,7 @@
*/
function count(iterable $iterable): int
{
if (\is_countable($iterable)) {
if (is_countable($iterable)) {
return \count($iterable);
}

4 changes: 2 additions & 2 deletions src/Psl/Iter/diff_by_key.php
Original file line number Diff line number Diff line change
@@ -23,13 +23,13 @@ function diff_by_key(iterable $first, iterable $second, iterable ...$rest): Iter
return;
}

if (is_empty($second) && all($rest, fn (iterable $iter): bool => is_empty($iter))) {
if (is_empty($second) && all($rest, static fn (iterable $iter): bool => is_empty($iter))) {
yield from $first;
}

// We don't use arrays here to ensure we allow the usage of non-arraykey indexes.
/** @psalm-var Generator<Tk, mixed, mixed, void> $second */
$second = ((fn (iterable $iterable): Generator => yield from $iterable)($second));
$second = ((static fn (iterable $iterable): Generator => yield from $iterable)($second));
/** @psalm-var Generator<iterable<Tk, mixed>, mixed, mixed, void> $generator */
$generator = ((static function (Generator $second, iterable ...$rest): Generator {
yield from $second;
1 change: 0 additions & 1 deletion src/Psl/Iter/drop.php
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@

namespace Psl\Iter;

use Generator;
use Psl;

/**
2 changes: 1 addition & 1 deletion src/Psl/Iter/filter_with_key.php
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ function filter_with_key(iterable $iterable, ?callable $predicate = null): Itera
*
* @return bool
*/
fn ($k, $v) => Psl\Internal\boolean($v);
static fn ($k, $v) => Psl\Internal\boolean($v);

foreach ($iterable as $k => $v) {
if ($predicate($k, $v)) {
2 changes: 0 additions & 2 deletions src/Psl/Iter/first_key.php
Original file line number Diff line number Diff line change
@@ -4,8 +4,6 @@

namespace Psl\Iter;

use Psl\Arr;

/**
* Gets the first key of an iterable.
*
2 changes: 1 addition & 1 deletion src/Psl/Iter/product.php
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ function product(iterable ...$iterables): Iterator
/** @psalm-var list<Iterator<Tk, Tv>> $iterators */
$iterators = to_array(map(
$iterables,
fn (iterable $iterable) => Iterator::create($iterable)
static fn (iterable $iterable) => Iterator::create($iterable)
));

$numIterators = count($iterators);
2 changes: 1 addition & 1 deletion src/Psl/Iter/reduce_keys.php
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@
* Iter\range(1, 5),
* static fn(int $accumulator, int $key): int => $accumulator + $key,
* 0,
* )
* )
* => 10
*
* @psalm-template Tk
2 changes: 1 addition & 1 deletion src/Psl/Iter/reduce_with_keys.php
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@
* Iter\range(1, 5),
* static fn(int $accumulator, int $key, int $value): int => $accumulator + $value,
* 0,
* )
* )
* => 15
*
* Iter\reduce_with_keys(
1 change: 0 additions & 1 deletion src/Psl/Iter/repeat.php
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@

use Generator;
use Psl;
use Psl\Internal;
use Psl\Math;

/**
Loading

0 comments on commit bf86fef

Please sign in to comment.