-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
206 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?php | ||
/* | ||
/** | ||
* Copyright 2017, 2018 Alexey Kopytko <[email protected]> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
|
@@ -36,40 +36,27 @@ EOF; | |
return PhpCsFixer\Config::create() | ||
->setRiskyAllowed(true) | ||
->setRules([ | ||
'header_comment' => ['commentType' => 'PHPDoc', 'header' => $header, 'separate' => 'bottom', 'location' => 'after_open'], | ||
|
||
'@Symfony' => true, | ||
'@Symfony:risky' => true, | ||
'@PHP70Migration:risky' => true, | ||
'@PHP71Migration' => true, | ||
'@PHP71Migration:risky' => true, | ||
'array_syntax' => ['syntax' => 'short'], | ||
'declare_strict_types' => true, | ||
'explicit_indirect_variable' => true, | ||
'no_superfluous_elseif' => true, | ||
'no_unreachable_default_argument_value' => true, | ||
'no_useless_else' => true, | ||
'no_useless_return' => true, | ||
'@PHPUnit60Migration:risky' => true, | ||
'@PHPUnit75Migration:risky' => true, | ||
'@PhpCsFixer' => true, | ||
'@PhpCsFixer:risky' => true, | ||
|
||
'ordered_class_elements' => false, | ||
'non_printable_character' => true, | ||
'ordered_imports' => true, | ||
'php_unit_test_class_requires_covers' => true, | ||
'php_unit_strict' => true, | ||
'phpdoc_add_missing_param_annotation' => true, | ||
'phpdoc_order' => true, | ||
'visibility_required' => true, | ||
'header_comment' => ['header' => $header, 'separate' => 'bottom', 'location' => 'after_open'], | ||
'ternary_to_null_coalescing' => true, | ||
'yoda_style' => true, | ||
'phpdoc_to_comment' => false, | ||
'strict_comparison' => true, | ||
'is_null' => true, | ||
'function_to_constant' => true, | ||
'void_return' => false, | ||
'return_assignment' => true, | ||
'array_syntax' => ['syntax' => 'short'], | ||
'array_indentation' => true, | ||
'native_function_invocation' => null, | ||
'comment_to_phpdoc' => true, | ||
'native_function_invocation' => true, | ||
'php_unit_test_case_static_method_calls' => false, | ||
]) | ||
->setFinder( | ||
PhpCsFixer\Finder::create() | ||
->in(__DIR__) | ||
->in(__DIR__) | ||
->append([__FILE__]) | ||
) | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?php | ||
/* | ||
/** | ||
* Copyright 2017, 2018 Alexey Kopytko <[email protected]> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
|
@@ -24,7 +24,7 @@ | |
|
||
// wrap an initial generator with a pipeline | ||
$pipeline = map(function () { | ||
foreach (range(1, 3) as $value) { | ||
foreach (\range(1, 3) as $value) { | ||
yield $value; | ||
} | ||
}); | ||
|
@@ -69,11 +69,11 @@ | |
return $carry + $valuetem; | ||
}, 0); | ||
|
||
var_dump($value); | ||
\var_dump($value); | ||
// int(104) | ||
|
||
$sum = take([1, 2, 3])->reduce(); | ||
var_dump($sum); | ||
\var_dump($sum); | ||
// int(6) | ||
|
||
// now with League\Pipeline | ||
|
@@ -86,8 +86,8 @@ | |
$pipeline = new \Pipeline\Standard(new \ArrayIterator([10, 20, 30])); | ||
$pipeline->map($leaguePipeline); | ||
|
||
$result = iterator_to_array($pipeline); | ||
var_dump($result); | ||
$result = \iterator_to_array($pipeline); | ||
\var_dump($result); | ||
// array(3) { | ||
// [0] => | ||
// int(22) | ||
|
@@ -111,7 +111,7 @@ | |
}); | ||
|
||
$arrayResult = $pipeline->toArray(); | ||
var_dump($arrayResult); | ||
\var_dump($arrayResult); | ||
// Since keys are discarded we get: | ||
// array(4) { | ||
// [0] => | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?php | ||
/* | ||
/** | ||
* Copyright 2017, 2018 Alexey Kopytko <[email protected]> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?php | ||
/* | ||
/** | ||
* Copyright 2017, 2018 Alexey Kopytko <[email protected]> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
|
@@ -63,7 +63,7 @@ public function filter(callable $func = null); | |
* @param ?callable $func {@inheritdoc} | ||
* @param ?mixed $initial {@inheritdoc} | ||
* | ||
* @return mixed|null | ||
* @return null|mixed | ||
*/ | ||
public function reduce(callable $func = null, $initial = null); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?php | ||
/* | ||
/** | ||
* Copyright 2017, 2018 Alexey Kopytko <[email protected]> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
|
@@ -82,6 +82,7 @@ private static function apply(iterable $previous, callable $func): \Generator | |
$result = $func($value); | ||
if ($result instanceof \Generator) { | ||
yield from $result; | ||
|
||
continue; | ||
} | ||
|
||
|
@@ -163,7 +164,7 @@ public function toArray(): array | |
* @param callable $func {@inheritdoc} | ||
* @param mixed $initial {@inheritdoc} | ||
* | ||
* @return mixed|null | ||
* @return null|mixed | ||
*/ | ||
public function reduce(callable $func, $initial) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?php | ||
/* | ||
/** | ||
* Copyright 2017, 2018 Alexey Kopytko <[email protected]> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?php | ||
/* | ||
/** | ||
* Copyright 2017, 2018 Alexey Kopytko <[email protected]> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?php | ||
/* | ||
/** | ||
* Copyright 2017, 2018 Alexey Kopytko <[email protected]> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
|
@@ -23,22 +23,24 @@ | |
use Pipeline\Standard; | ||
|
||
/** | ||
* @covers \Pipeline\Standard | ||
* @covers \Pipeline\Principal | ||
* @covers \Pipeline\Standard | ||
* | ||
* @internal | ||
*/ | ||
class ArraysTest extends TestCase | ||
final class ArraysTest extends TestCase | ||
{ | ||
public function testInitialCallbackNotGenerator() | ||
public function testInitialCallbackNotGenerator(): void | ||
{ | ||
$pipeline = new Standard(); | ||
$pipeline->map(function () { | ||
return PHP_INT_MAX; | ||
}); | ||
|
||
$this->assertSame([PHP_INT_MAX], iterator_to_array($pipeline)); | ||
$this->assertSame([PHP_INT_MAX], \iterator_to_array($pipeline)); | ||
} | ||
|
||
public function testArrayToArray() | ||
public function testArrayToArray(): void | ||
{ | ||
$pipeline = new Standard(); | ||
$pipeline->map(function () { | ||
|
@@ -48,7 +50,7 @@ public function testArrayToArray() | |
$this->assertSame([42], $pipeline->toArray()); | ||
} | ||
|
||
public function testArrayFilter() | ||
public function testArrayFilter(): void | ||
{ | ||
$pipeline = new Standard(); | ||
$pipeline->map(function () { | ||
|
@@ -58,7 +60,7 @@ public function testArrayFilter() | |
$this->assertSame([], $pipeline->toArray()); | ||
} | ||
|
||
public function testArrayReduce() | ||
public function testArrayReduce(): void | ||
{ | ||
$pipeline = new Standard(); | ||
$pipeline->map(function () { | ||
|
@@ -68,7 +70,7 @@ public function testArrayReduce() | |
$this->assertSame(3, $pipeline->reduce()); | ||
} | ||
|
||
public function testArrayValues() | ||
public function testArrayValues(): void | ||
{ | ||
$pipeline = new Standard(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?php | ||
/* | ||
/** | ||
* Copyright 2017, 2018 Alexey Kopytko <[email protected]> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
|
@@ -27,8 +27,10 @@ | |
|
||
/** | ||
* @covers \Pipeline\Principal | ||
* | ||
* @internal | ||
*/ | ||
class EagerWithArraysTest extends TestCase | ||
final class EagerWithArraysTest extends TestCase | ||
{ | ||
public static function specimens(): \Generator | ||
{ | ||
|
@@ -39,7 +41,7 @@ public static function specimens(): \Generator | |
/** | ||
* @dataProvider specimens | ||
*/ | ||
public function testEagerArrayFilter(Standard $pipeline) | ||
public function testEagerArrayFilter(Standard $pipeline): void | ||
{ | ||
$reflectionClass = new \ReflectionClass(Principal::class); | ||
$reflectionProperty = $reflectionClass->getProperty('pipeline'); | ||
|
@@ -59,7 +61,7 @@ public function testEagerArrayFilter(Standard $pipeline) | |
/** | ||
* @dataProvider specimens | ||
*/ | ||
public function testEagerArrayReduce(Standard $pipeline) | ||
public function testEagerArrayReduce(Standard $pipeline): void | ||
{ | ||
$this->assertSame(6, $pipeline->reduce()); | ||
|
||
|
@@ -71,7 +73,7 @@ public function testEagerArrayReduce(Standard $pipeline) | |
/** | ||
* @dataProvider specimens | ||
*/ | ||
public function testEagerArrayFilterAndReduce(Standard $pipeline) | ||
public function testEagerArrayFilterAndReduce(Standard $pipeline): void | ||
{ | ||
$this->assertSame(6, $pipeline->filter()->reduce()); | ||
// This should be possible with an array | ||
|
@@ -81,7 +83,7 @@ public function testEagerArrayFilterAndReduce(Standard $pipeline) | |
/** | ||
* @dataProvider specimens | ||
*/ | ||
public function testNonEagerArrayMap(Standard $pipeline) | ||
public function testNonEagerArrayMap(Standard $pipeline): void | ||
{ | ||
$this->assertSame([1, 1, 1, 1, 1], $pipeline->map(function ($value) { | ||
return 1; | ||
|
Oops, something went wrong.