file cleanup

This commit is contained in:
2019-12-25 06:39:54 +00:00
parent dbfdc41029
commit d4b64055d0
48 changed files with 706 additions and 136 deletions

View File

@@ -20,7 +20,6 @@ return array(
'App\\Console\\Commands\\UpdateMoonRental' => $baseDir . '/app/Console/Commands/Moons/UpdateMoonRental.php',
'App\\Console\\Kernel' => $baseDir . '/app/Console/Kernel.php',
'App\\Exceptions\\Handler' => $baseDir . '/app/Exceptions/Handler.php',
'App\\Http\\Controllers\\Ajax\\LiveSearch' => $baseDir . '/app/Http/Controllers/Ajax/LiveSearch.php',
'App\\Http\\Controllers\\Auth\\EsiScopeController' => $baseDir . '/app/Http/Controllers/Auth/EsiScopeController.php',
'App\\Http\\Controllers\\Auth\\LoginController' => $baseDir . '/app/Http/Controllers/Auth/LoginController.php',
'App\\Http\\Controllers\\Blacklist\\BlacklistController' => $baseDir . '/app/Http/Controllers/Blacklist/BlacklistController.php',
@@ -74,6 +73,7 @@ return array(
'App\\Library\\SRP\\SRPHelper' => $baseDir . '/app/Library/SRP/SRPHelper.php',
'App\\Library\\Structures\\StructureHelper' => $baseDir . '/app/Library/Structures/StructureHelper.php',
'App\\Library\\Taxes\\TaxesHelper' => $baseDir . '/app/Library/Taxes/TaxesHelper.php',
'App\\Library\\Wiki\\WikiHelper' => $baseDir . '/app/Library/Wiki/WikiHelper.php',
'App\\Models\\Admin\\AllowedLogin' => $baseDir . '/app/Models/Admin/AllowedLogin.php',
'App\\Models\\Blacklist\\BlacklistUser' => $baseDir . '/app/Models/Blacklist/BlacklistUser.php',
'App\\Models\\Config' => $baseDir . '/app/Models/Moon/Config.php',

View File

@@ -484,7 +484,6 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
'App\\Console\\Commands\\UpdateMoonRental' => __DIR__ . '/../..' . '/app/Console/Commands/Moons/UpdateMoonRental.php',
'App\\Console\\Kernel' => __DIR__ . '/../..' . '/app/Console/Kernel.php',
'App\\Exceptions\\Handler' => __DIR__ . '/../..' . '/app/Exceptions/Handler.php',
'App\\Http\\Controllers\\Ajax\\LiveSearch' => __DIR__ . '/../..' . '/app/Http/Controllers/Ajax/LiveSearch.php',
'App\\Http\\Controllers\\Auth\\EsiScopeController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/EsiScopeController.php',
'App\\Http\\Controllers\\Auth\\LoginController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/LoginController.php',
'App\\Http\\Controllers\\Blacklist\\BlacklistController' => __DIR__ . '/../..' . '/app/Http/Controllers/Blacklist/BlacklistController.php',
@@ -538,6 +537,7 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
'App\\Library\\SRP\\SRPHelper' => __DIR__ . '/../..' . '/app/Library/SRP/SRPHelper.php',
'App\\Library\\Structures\\StructureHelper' => __DIR__ . '/../..' . '/app/Library/Structures/StructureHelper.php',
'App\\Library\\Taxes\\TaxesHelper' => __DIR__ . '/../..' . '/app/Library/Taxes/TaxesHelper.php',
'App\\Library\\Wiki\\WikiHelper' => __DIR__ . '/../..' . '/app/Library/Wiki/WikiHelper.php',
'App\\Models\\Admin\\AllowedLogin' => __DIR__ . '/../..' . '/app/Models/Admin/AllowedLogin.php',
'App\\Models\\Blacklist\\BlacklistUser' => __DIR__ . '/../..' . '/app/Models/Blacklist/BlacklistUser.php',
'App\\Models\\Config' => __DIR__ . '/../..' . '/app/Models/Moon/Config.php',

View File

@@ -777,17 +777,17 @@
},
{
"name": "fzaninotto/faker",
"version": "v1.9.0",
"version_normalized": "1.9.0.0",
"version": "v1.9.1",
"version_normalized": "1.9.1.0",
"source": {
"type": "git",
"url": "https://github.com/fzaninotto/Faker.git",
"reference": "27a216cbe72327b2d6369fab721a5843be71e57d"
"reference": "fc10d778e4b84d5bd315dad194661e091d307c6f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fzaninotto/Faker/zipball/27a216cbe72327b2d6369fab721a5843be71e57d",
"reference": "27a216cbe72327b2d6369fab721a5843be71e57d",
"url": "https://api.github.com/repos/fzaninotto/Faker/zipball/fc10d778e4b84d5bd315dad194661e091d307c6f",
"reference": "fc10d778e4b84d5bd315dad194661e091d307c6f",
"shasum": ""
},
"require": {
@@ -798,10 +798,12 @@
"phpunit/phpunit": "^4.8.35 || ^5.7",
"squizlabs/php_codesniffer": "^2.9.2"
},
"time": "2019-11-14T13:13:06+00:00",
"time": "2019-12-12T13:22:17+00:00",
"type": "library",
"extra": {
"branch-alias": []
"branch-alias": {
"dev-master": "1.9-dev"
}
},
"installation-source": "dist",
"autoload": {
@@ -1382,17 +1384,17 @@
},
{
"name": "laravel/horizon",
"version": "v3.4.3",
"version_normalized": "3.4.3.0",
"version": "v3.4.4",
"version_normalized": "3.4.4.0",
"source": {
"type": "git",
"url": "https://github.com/laravel/horizon.git",
"reference": "37226dd66318014fac20351b4cc7ca209dd4ccb6"
"reference": "7c36d24b200b60a059ab20f5b53f5bb6f4d2da40"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/horizon/zipball/37226dd66318014fac20351b4cc7ca209dd4ccb6",
"reference": "37226dd66318014fac20351b4cc7ca209dd4ccb6",
"url": "https://api.github.com/repos/laravel/horizon/zipball/7c36d24b200b60a059ab20f5b53f5bb6f4d2da40",
"reference": "7c36d24b200b60a059ab20f5b53f5bb6f4d2da40",
"shasum": ""
},
"require": {
@@ -1400,9 +1402,9 @@
"ext-json": "*",
"ext-pcntl": "*",
"ext-posix": "*",
"illuminate/contracts": "~5.7.0|~5.8.0|^6.0|^7.0",
"illuminate/queue": "~5.7.0|~5.8.0|^6.0|^7.0",
"illuminate/support": "~5.7.0|~5.8.0|^6.0|^7.0",
"illuminate/contracts": "~5.7.0|~5.8.0|^6.0",
"illuminate/queue": "~5.7.0|~5.8.0|^6.0",
"illuminate/support": "~5.7.0|~5.8.0|^6.0",
"php": ">=7.1.0",
"predis/predis": "^1.1",
"ramsey/uuid": "^3.5",
@@ -1411,10 +1413,10 @@
},
"require-dev": {
"mockery/mockery": "^1.0",
"orchestra/testbench": "^3.7|^4.0|^5.0",
"orchestra/testbench": "^3.7|^4.0",
"phpunit/phpunit": "^7.0|^8.0"
},
"time": "2019-11-19T16:23:21+00:00",
"time": "2019-12-10T16:50:59+00:00",
"type": "library",
"extra": {
"branch-alias": {
@@ -2566,30 +2568,31 @@
},
{
"name": "phpoption/phpoption",
"version": "1.6.0",
"version_normalized": "1.6.0.0",
"version": "1.7.1",
"version_normalized": "1.7.1.0",
"source": {
"type": "git",
"url": "https://github.com/schmittjoh/php-option.git",
"reference": "f4e7a6a1382183412246f0d361078c29fb85089e"
"reference": "100a25207566930efd926cf205542946aa692e01"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/schmittjoh/php-option/zipball/f4e7a6a1382183412246f0d361078c29fb85089e",
"reference": "f4e7a6a1382183412246f0d361078c29fb85089e",
"url": "https://api.github.com/repos/schmittjoh/php-option/zipball/100a25207566930efd926cf205542946aa692e01",
"reference": "100a25207566930efd926cf205542946aa692e01",
"shasum": ""
},
"require": {
"php": "^5.5.9 || ^7.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.3",
"phpunit/phpunit": "^4.8.35 || ^5.0 || ^6.0 || ^7.0"
},
"time": "2019-11-30T20:20:49+00:00",
"time": "2019-12-14T13:46:39+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.6-dev"
"dev-master": "1.7-dev"
}
},
"installation-source": "dist",

View File

@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# The problem is that we do not want to remove the configuration file, just disable it for a few tasks, then enable it
#
# For reference, see
#
# - https://docs.travis-ci.com/user/languages/php#Disabling-preinstalled-PHP-extensions
# - https://docs.travis-ci.com/user/languages/php#Custom-PHP-configuration
config="/home/travis/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini"
function xdebug-disable() {
if [[ -f $config ]]; then
mv $config "$config.bak"
fi
}
function xdebug-enable() {
if [[ -f "$config.bak" ]]; then
mv "$config.bak" $config
fi
}

View File

@@ -1,5 +1,15 @@
# CHANGELOG
## 2019-12-03, v1.9.1
- Add link to PHPStan extension to readme [\#1834](https://github.com/fzaninotto/Faker/pull/1834) ([finwe](https://github.com/finwe))
- Enhancement: Collect code coverage [\#1824](https://github.com/fzaninotto/Faker/pull/1824) ([localheinz](https://github.com/localheinz))
- Enhancement: Use all columns when running tests [\#1823](https://github.com/fzaninotto/Faker/pull/1823) ([localheinz](https://github.com/localheinz))
- Enhancement: Configure verbose output via phpunit.xml.dist [\#1822](https://github.com/fzaninotto/Faker/pull/1822) ([localheinz](https://github.com/localheinz))
- Curly braces for arrays is deprecated in PHP 7.4 [\#1843](https://github.com/fzaninotto/Faker/pull/1843) ([wimg](https://github.com/wimg))
- Fix: Reduce visibility of setUp\(\) and tearDown\(\) [\#1821](https://github.com/fzaninotto/Faker/pull/1821) ([localheinz](https://github.com/localheinz))
- Fix: Mark test classes as final [\#1820](https://github.com/fzaninotto/Faker/pull/1820) ([localheinz](https://github.com/localheinz))
- Fix: Remove unnecessary class-level DocBlocks [\#1819](https://github.com/fzaninotto/Faker/pull/1819) ([localheinz](https://github.com/localheinz))
## 2019-11-10, v1.9.0

View File

@@ -33,7 +33,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.9"
"dev-master": "1.9-dev"
}
},
"config": {

View File

@@ -1,5 +1,7 @@
# Faker
[![Code Coverage](https://codecov.io/gh/fzaninotto/Faker/branch/master/graph/badge.svg)](https://codecov.io/gh/fzaninotto/Faker)
Faker is a PHP library that generates fake data for you. Whether you need to bootstrap your database, create good-looking XML documents, fill-in your persistence to stress test it, or anonymize data taken from a production service, Faker is for you.
Faker is heavily inspired by Perl's [Data::Faker](http://search.cpan.org/~jasonk/Data-Faker-0.07/), and by ruby's [Faker](https://rubygems.org/gems/faker).
@@ -53,7 +55,7 @@ composer require fzaninotto/faker
### Autoloading
Faker supports both `PSR-0` as `PSR-4` autoloaders.
Faker supports both `PSR-0` as `PSR-4` autoloaders.
```php
<?php
# When installed via composer
@@ -1789,6 +1791,7 @@ echo $faker->VAT; //23456789
* [`drupol/belgian-national-number-faker`](https://github.com/drupol/belgian-national-number-faker): Generate fake Belgian national numbers
* [`elgentos/masquerade`](https://github.com/elgentos/masquerade): Configuration-based, platform-agnostic, locale-compatible data faker tool (out-of-the-box support for Magento 2)
* [`ottaviano/faker-gravatar`](https://github.com/ottaviano/faker-gravatar): Generate avatars using [Gravatar](https://en.gravatar.com/site/implement/images/)
* [`finwe/phpstan-faker`](https://github.com/finwe/phpstan-faker): PHPStan extension for Faker methods
## License

View File

@@ -24,10 +24,10 @@ class Luhn
$length = strlen($number);
$sum = 0;
for ($i = $length - 1; $i >= 0; $i -= 2) {
$sum += $number{$i};
$sum += $number[$i];
}
for ($i = $length - 2; $i >= 0; $i -= 2) {
$sum += array_sum(str_split($number{$i} * 2));
$sum += array_sum(str_split($number[$i] * 2));
}
return $sum % 10;

View File

@@ -1,7 +1,5 @@
<?php
// data source
namespace Faker\Provider\en_NG;
class Person extends \Faker\Provider\Person

View File

@@ -15,9 +15,9 @@
"ext-pcntl": "*",
"ext-posix": "*",
"cakephp/chronos": "^1.0",
"illuminate/contracts": "~5.7.0|~5.8.0|^6.0|^7.0",
"illuminate/queue": "~5.7.0|~5.8.0|^6.0|^7.0",
"illuminate/support": "~5.7.0|~5.8.0|^6.0|^7.0",
"illuminate/contracts": "~5.7.0|~5.8.0|^6.0",
"illuminate/queue": "~5.7.0|~5.8.0|^6.0",
"illuminate/support": "~5.7.0|~5.8.0|^6.0",
"predis/predis": "^1.1",
"ramsey/uuid": "^3.5",
"symfony/process": "^4.2",
@@ -25,7 +25,7 @@
},
"require-dev": {
"mockery/mockery": "^1.0",
"orchestra/testbench": "^3.7|^4.0|^5.0",
"orchestra/testbench": "^3.7|^4.0",
"phpunit/phpunit": "^7.0|^8.0"
},
"autoload": {

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,5 @@
{
"/app.js": "/app.js?id=f41217b645f8cd9ffacc",
"/app.js": "/app.js?id=dbc6b1d1957be6dae833",
"/app.css": "/app.css?id=b95d548aba488172f4b4",
"/app-dark.css": "/app-dark.css?id=b5b064c2f5a4b673a1c5"
}

View File

@@ -108,7 +108,8 @@
* @returns {string}
*/
prettyPrintJob(data) {
return data.command ? phpunserialize(data.command) : data;
return data.command && !data.command.includes('CallQueuedClosure')
? phpunserialize(data.command) : data;
}
}
}

View File

@@ -79,7 +79,10 @@ class AutoScaler
return $pools->mapWithKeys(function ($pool, $queue) use ($supervisor) {
$size = $this->queue->connection($supervisor->options->connection)->readyNow($queue);
return [$queue => ($size * $this->metrics->runtimeForQueue($queue))];
return [$queue => [
'size' => $size,
'time' => ($size * $this->metrics->runtimeForQueue($queue)),
]];
});
}
@@ -87,20 +90,24 @@ class AutoScaler
* Get the number of workers needed per queue for proper balance.
*
* @param \Laravel\Horizon\Supervisor $supervisor
* @param \Illuminate\Support\Collection $timeToClear
* @param \Illuminate\Support\Collection $queues
* @return \Illuminate\Support\Collection
*/
protected function numberOfWorkersPerQueue(Supervisor $supervisor, Collection $timeToClear)
protected function numberOfWorkersPerQueue(Supervisor $supervisor, Collection $queues)
{
$timeToClearAll = $timeToClear->sum();
$timeToClearAll = $queues->sum('time');
return $timeToClear->mapWithKeys(function ($timeToClear, $queue) use ($supervisor, $timeToClearAll) {
return $queues->mapWithKeys(function ($timeToClear, $queue) use ($supervisor, $timeToClearAll) {
if ($timeToClearAll > 0 &&
$supervisor->options->autoScaling()) {
return [$queue => (($timeToClear / $timeToClearAll) * $supervisor->options->maxProcesses)];
return [$queue => (($timeToClear['time'] / $timeToClearAll) * $supervisor->options->maxProcesses)];
} elseif ($timeToClearAll == 0 &&
$supervisor->options->autoScaling()) {
return [$queue => $supervisor->options->minProcesses];
return [
$queue => $timeToClear['size']
? $supervisor->options->maxProcesses
: $supervisor->options->minProcesses,
];
}
return [$queue => $supervisor->options->maxProcesses / count($supervisor->processPools)];

View File

@@ -259,18 +259,16 @@ class RedisJobRepository implements JobRepository
$time = str_replace(',', '.', microtime(true));
$pipe->hmset(
$payload->id(), [
'id' => $payload->id(),
'connection' => $connection,
'queue' => $queue,
'name' => $payload->decoded['displayName'],
'status' => 'pending',
'payload' => $payload->value,
'created_at' => $time,
'updated_at' => $time,
]
);
$pipe->hmset($payload->id(), [
'id' => $payload->id(),
'connection' => $connection,
'queue' => $queue,
'name' => $payload->decoded['displayName'],
'status' => 'pending',
'payload' => $payload->value,
'created_at' => $time,
'updated_at' => $time,
]);
$pipe->expireat(
$payload->id(), Chronos::now()->addMinutes($this->recentJobExpires)->getTimestamp()

View File

@@ -17,16 +17,22 @@
"php": "^5.5.9 || ^7.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35 || ^5.0 || ^6.0 || ^7.0"
"phpunit/phpunit": "^4.8.35 || ^5.0 || ^6.0 || ^7.0",
"bamarni/composer-bin-plugin": "^1.3"
},
"autoload": {
"psr-4": {
"PhpOption\\": "src/PhpOption/"
}
},
"autoload-dev": {
"psr-4": {
"PhpOption\\Tests\\": "tests/PhpOption/Tests/"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.6-dev"
"dev-master": "1.7-dev"
}
}
}

View File

@@ -18,6 +18,11 @@
namespace PhpOption;
/**
* @template T
*
* @extends Option<T>
*/
final class LazyOption extends Option
{
/** @var callable */
@@ -26,14 +31,16 @@ final class LazyOption extends Option
/** @var array */
private $arguments;
/** @var Option|null */
/** @var Option<T>|null */
private $option;
/**
* @template S
*
* @param callable $callback
* @param array $arguments
*
* @return LazyOption
* @return LazyOption<S>
*/
public static function create($callback, array $arguments = [])
{
@@ -89,9 +96,6 @@ final class LazyOption extends Option
return $this->option()->orElse($else);
}
/**
* @deprecated Use forAll() instead.
*/
public function ifDefined($callable)
{
$this->option()->ifDefined($callable);
@@ -148,7 +152,7 @@ final class LazyOption extends Option
}
/**
* @return Option
* @return Option<T>
*/
private function option()
{

View File

@@ -20,10 +20,19 @@ namespace PhpOption;
use EmptyIterator;
/**
* @template T
*
* @extends Option<T>
*/
final class None extends Option
{
/** @var None<T> */
private static $instance;
/**
* @return None<T>
*/
public static function create()
{
if (null === self::$instance) {
@@ -68,9 +77,6 @@ final class None extends Option
return $else;
}
/**
* @deprecated Use forAll() instead.
*/
public function ifDefined($callable)
{
// Just do nothing in that case.

View File

@@ -18,12 +18,13 @@
namespace PhpOption;
use ArrayAccess;
use IteratorAggregate;
/**
* Base Option Class.
* @template T
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
* @implements IteratorAggregate<T>
*/
abstract class Option implements IteratorAggregate
{
@@ -34,11 +35,13 @@ abstract class Option implements IteratorAggregate
* convert them to an option. By default, we treat ``null`` as the None
* case, and everything else as Some.
*
* @param mixed $value The actual return value.
* @param mixed $noneValue The value which should be considered "None";
* null by default.
* @template S
*
* @return Option
* @param S $value The actual return value.
* @param S $noneValue The value which should be considered "None"; null by
* default.
*
* @return Option<S>
*/
public static function fromValue($value, $noneValue = null)
{
@@ -56,14 +59,16 @@ abstract class Option implements IteratorAggregate
* array, or the array's value at the given key is null, None is returned.
* Otherwise, Some is returned wrapping the value at the given key.
*
* @param mixed $array A potential array value.
* @param string $key The key to check.
* @template S
*
* @return Option
* @param array<string,S>|ArrayAccess<string,S>|null $array A potential array or \ArrayAccess value.
* @param string $key The key to check.
*
* @return Option<S>
*/
public static function fromArraysValue($array, $key)
{
if (!is_array($array) || !isset($array[$key])) {
if (!(is_array($array) || $array instanceof ArrayAccess) || !isset($array[$key])) {
return None::create();
}
@@ -77,12 +82,14 @@ abstract class Option implements IteratorAggregate
* the return value is not yet an option. By default, we treat ``null`` as
* None case, and everything else as Some.
*
* @template S
*
* @param callable $callback The callback to evaluate.
* @param array $arguments The arguments for the callback.
* @param mixed $noneValue The value which should be considered "None"; null
* by default.
* @param S $noneValue The value which should be considered "None";
* null by default.
*
* @return Option
* @return LazyOption<S>
*/
public static function fromReturn($callback, array $arguments = [], $noneValue = null)
{
@@ -105,11 +112,13 @@ abstract class Option implements IteratorAggregate
* returned from callback, it returns directly. On other case value passed
* to Option::fromValue() method.
*
* @param Option|callable|mixed $value
* @param mixed $noneValue Used when $value is mixed or
* callable, for None-check.
* @template S
*
* @return Option
* @param Option<S>|callable|S $value
* @param S $noneValue Used when $value is mixed or
* callable, for None-check.
*
* @return Option<S>|LazyOption<S>
*/
public static function ensure($value, $noneValue = null)
{
@@ -139,6 +148,8 @@ abstract class Option implements IteratorAggregate
* original callback and return the value inside a new Option, unless an
* Option is returned from the function, in which case, we use that.
*
* @template S
*
* @param callable $callback
* @param mixed $noneValue
*
@@ -171,16 +182,18 @@ abstract class Option implements IteratorAggregate
*
* @throws \RuntimeException If value is not available.
*
* @return mixed
* @return T
*/
abstract public function get();
/**
* Returns the value if available, or the default value if not.
*
* @param mixed $default
* @template S
*
* @return mixed
* @param S $default
*
* @return T|S
*/
abstract public function getOrElse($default);
@@ -190,9 +203,11 @@ abstract class Option implements IteratorAggregate
* This is preferable over ``getOrElse`` if the computation of the default
* value is expensive.
*
* @param callable $callable
* @template S
*
* @return mixed
* @param callable(): S $callable
*
* @return T|S
*/
abstract public function getOrCall($callable);
@@ -201,7 +216,7 @@ abstract class Option implements IteratorAggregate
*
* @param \Exception $ex
*
* @return mixed
* @return T
*/
abstract public function getOrThrow(\Exception $ex);
@@ -231,9 +246,9 @@ abstract class Option implements IteratorAggregate
* ->orElse(new LazyOption(array($repo, 'createSomething')));
* ```
*
* @param Option $else
* @param Option<T> $else
*
* @return Option
* @return Option<T>
*/
abstract public function orElse(self $else);
@@ -268,9 +283,9 @@ abstract class Option implements IteratorAggregate
* option is empty. This method is preferred for callables with side-effects, while map()
* is intended for callables without side-effects.
*
* @param callable $callable
* @param callable(T): void $callable
*
* @return Option
* @return Option<T>
*/
abstract public function forAll($callable);
@@ -284,9 +299,11 @@ abstract class Option implements IteratorAggregate
* (new Some("foo"))->map('strtoupper')->get(); // "FOO"
* ```
*
* @param callable $callable
* @template S
*
* @return Option
* @param callable(T): S $callable
*
* @return Option<S>
*/
abstract public function map($callable);
@@ -297,9 +314,11 @@ abstract class Option implements IteratorAggregate
* In contrast to ``map``, the return value of the callable is expected to
* be an Option itself; it is not automatically wrapped in Some().
*
* @param callable $callable must return an Option
* @template S
*
* @return Option
* @param callable(T): Option<S> $callable must return an Option
*
* @return Option<S>
*/
abstract public function flatMap($callable);
@@ -309,9 +328,9 @@ abstract class Option implements IteratorAggregate
* If the option is non-empty, the callable is applied, and if it returns true,
* the option itself is returned; otherwise, None is returned.
*
* @param callable $callable
* @param callable(T): bool $callable
*
* @return Option
* @return Option<T>
*/
abstract public function filter($callable);
@@ -321,9 +340,9 @@ abstract class Option implements IteratorAggregate
* If the option is non-empty, the callable is applied, and if it returns false,
* the option itself is returned; otherwise, None is returned.
*
* @param callable $callable
* @param callable(T): bool $callable
*
* @return Option
* @return Option<T>
*/
abstract public function filterNot($callable);
@@ -336,9 +355,9 @@ abstract class Option implements IteratorAggregate
*
* In other words, this will filter all but the passed value.
*
* @param mixed $value
* @param T $value
*
* @return Option
* @return Option<T>
*/
abstract public function select($value);
@@ -351,9 +370,9 @@ abstract class Option implements IteratorAggregate
*
* In other words, this will let all values through except the passed value.
*
* @param mixed $value
* @param T $value
*
* @return Option
* @return Option<T>
*/
abstract public function reject($value);
@@ -378,20 +397,24 @@ abstract class Option implements IteratorAggregate
* }
* ```
*
* @param mixed $initialValue
* @template S
*
* @param S $initialValue
* @param callable $callable function(initialValue, callable): result
*
* @return mixed
* @return S
*/
abstract public function foldLeft($initialValue, $callable);
/**
* foldLeft() but with reversed arguments for the callable.
*
* @param mixed $initialValue
* @template S
*
* @param S $initialValue
* @param callable $callable function(callable, initialValue): result
*
* @return mixed
* @return S
*/
abstract public function foldRight($initialValue, $callable);
}

View File

@@ -20,15 +20,29 @@ namespace PhpOption;
use ArrayIterator;
/**
* @template T
*
* @extends Option<T>
*/
final class Some extends Option
{
/** @var T */
private $value;
/**
* @param T $value
*/
public function __construct($value)
{
$this->value = $value;
}
/**
* @param T $value
*
* @return Some<T>
*/
public static function create($value)
{
return new self($value);
@@ -69,9 +83,6 @@ final class Some extends Option
return $this;
}
/**
* @deprecated Use forAll() instead.
*/
public function ifDefined($callable)
{
$callable($this->value);