composer update
This commit is contained in:
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
install:
|
||||
@docker run -it -w /data -v ${PWD}:/data:delegated -v ~/.composer:/root/.composer:delegated --entrypoint composer --rm registry.gitlab.com/grahamcampbell/php:7.4-base update
|
||||
@docker run -it -w /data -v ${PWD}:/data:delegated -v ~/.composer:/root/.composer:delegated --entrypoint composer --rm registry.gitlab.com/grahamcampbell/php:7.4-base bin all update
|
||||
|
||||
phpunit:
|
||||
@rm -f bootstrap/cache/*.php && docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit --rm registry.gitlab.com/grahamcampbell/php:7.4-cli
|
||||
|
||||
phpstan-analyze-src:
|
||||
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpstan --rm registry.gitlab.com/grahamcampbell/php:7.4-cli analyze src -c phpstan.src.neon.dist
|
||||
|
||||
phpstan-analyze-tests:
|
||||
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpstan --rm registry.gitlab.com/grahamcampbell/php:7.4-cli analyze tests -c phpstan.tests.neon.dist
|
||||
|
||||
psalm-analyze:
|
||||
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/psalm --rm registry.gitlab.com/grahamcampbell/php:7.4-cli
|
||||
|
||||
psalm-show-info:
|
||||
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/psalm --rm registry.gitlab.com/grahamcampbell/php:7.4-cli --show-info=true
|
||||
|
||||
test: phpunit phpstan-analyze-src phpstan-analyze-tests psalm-analyze
|
||||
|
||||
clean:
|
||||
@rm -rf .phpunit.result.cache composer.lock vendor vendor-bin/*/composer.lock vendor-bin/*/vendor
|
||||
+8
-3
@@ -17,8 +17,8 @@
|
||||
"php": "^5.5.9 || ^7.0 || ^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8.35 || ^5.0 || ^6.0 || ^7.0",
|
||||
"bamarni/composer-bin-plugin": "^1.3"
|
||||
"bamarni/composer-bin-plugin": "^1.4.1",
|
||||
"phpunit/phpunit": "^4.8.35 || ^5.7.27 || ^6.5.6 || ^7.0 || ^8.0 || ^9.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -30,9 +30,14 @@
|
||||
"PhpOption\\Tests\\": "tests/PhpOption/Tests/"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"preferred-install": "dist"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.7-dev"
|
||||
}
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
}
|
||||
|
||||
+7
-6
@@ -97,7 +97,7 @@ final class LazyOption extends Option
|
||||
|
||||
public function ifDefined($callable)
|
||||
{
|
||||
$this->option()->ifDefined($callable);
|
||||
$this->option()->forAll($callable);
|
||||
}
|
||||
|
||||
public function forAll($callable)
|
||||
@@ -156,11 +156,12 @@ final class LazyOption extends Option
|
||||
private function option()
|
||||
{
|
||||
if (null === $this->option) {
|
||||
$this->option = call_user_func_array($this->callback, $this->arguments);
|
||||
if (!$this->option instanceof Option) {
|
||||
$this->option = null;
|
||||
|
||||
throw new \RuntimeException(sprintf('Expected instance of \%s', Option::class));
|
||||
/** @var mixed */
|
||||
$option = call_user_func_array($this->callback, $this->arguments);
|
||||
if ($option instanceof Option) {
|
||||
$this->option = $option;
|
||||
} else {
|
||||
throw new \RuntimeException(sprintf('Expected instance of %s', Option::class));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -61,8 +61,8 @@ abstract class Option implements IteratorAggregate
|
||||
*
|
||||
* @template S
|
||||
*
|
||||
* @param array<string,S>|ArrayAccess<string,S>|null $array A potential array or \ArrayAccess value.
|
||||
* @param string $key The key to check.
|
||||
* @param array<string|int,S>|ArrayAccess<string|int,S>|null $array A potential array or \ArrayAccess value.
|
||||
* @param string $key The key to check.
|
||||
*
|
||||
* @return Option<S>
|
||||
*/
|
||||
@@ -93,7 +93,7 @@ abstract class Option implements IteratorAggregate
|
||||
*/
|
||||
public static function fromReturn($callback, array $arguments = [], $noneValue = null)
|
||||
{
|
||||
return new LazyOption(function () use ($callback, $arguments, $noneValue) {
|
||||
return new LazyOption(static function () use ($callback, $arguments, $noneValue) {
|
||||
/** @var mixed */
|
||||
$return = call_user_func_array($callback, $arguments);
|
||||
|
||||
@@ -126,7 +126,7 @@ abstract class Option implements IteratorAggregate
|
||||
if ($value instanceof self) {
|
||||
return $value;
|
||||
} elseif (is_callable($value)) {
|
||||
return new LazyOption(function () use ($value, $noneValue) {
|
||||
return new LazyOption(static function () use ($value, $noneValue) {
|
||||
/** @var mixed */
|
||||
$return = $value();
|
||||
|
||||
@@ -159,14 +159,14 @@ abstract class Option implements IteratorAggregate
|
||||
*/
|
||||
public static function lift($callback, $noneValue = null)
|
||||
{
|
||||
return function () use ($callback, $noneValue) {
|
||||
return static function () use ($callback, $noneValue) {
|
||||
/** @var array<int, mixed> */
|
||||
$args = func_get_args();
|
||||
|
||||
$reduced_args = array_reduce(
|
||||
$args,
|
||||
/** @param bool $status */
|
||||
function ($status, self $o) {
|
||||
static function ($status, self $o) {
|
||||
return $o->isEmpty() ? true : $status;
|
||||
},
|
||||
false
|
||||
@@ -178,7 +178,7 @@ abstract class Option implements IteratorAggregate
|
||||
|
||||
$args = array_map(
|
||||
/** @return T */
|
||||
function (self $o) {
|
||||
static function (self $o) {
|
||||
// it is safe to do so because the fold above checked
|
||||
// that all arguments are of type Some
|
||||
/** @var T */
|
||||
|
||||
+2
-1
@@ -87,7 +87,7 @@ final class Some extends Option
|
||||
|
||||
public function ifDefined($callable)
|
||||
{
|
||||
$callable($this->value);
|
||||
$this->forAll($callable);
|
||||
}
|
||||
|
||||
public function forAll($callable)
|
||||
@@ -104,6 +104,7 @@ final class Some extends Option
|
||||
|
||||
public function flatMap($callable)
|
||||
{
|
||||
/** @var mixed */
|
||||
$rs = $callable($this->value);
|
||||
if (!$rs instanceof Option) {
|
||||
throw new \RuntimeException('Callables passed to flatMap() must return an Option. Maybe you should use map() instead?');
|
||||
|
||||
Reference in New Issue
Block a user