diff --git a/composer.json b/composer.json index 38674f54fd46..7ce8aa9e8aca 100644 --- a/composer.json +++ b/composer.json @@ -78,7 +78,7 @@ "illuminate/view": "self.version" }, "require-dev": { - "aws/aws-sdk-php": "^3.155", + "aws/aws-sdk-php": "^3.186.4", "doctrine/dbal": "^2.6|^3.0", "filp/whoops": "^2.8", "guzzlehttp/guzzle": "^6.5.5|^7.0.1", @@ -128,7 +128,7 @@ "ext-pcntl": "Required to use all features of the queue worker.", "ext-posix": "Required to use all features of the queue worker.", "ext-redis": "Required to use the Redis cache and queue drivers (^4.0|^5.0).", - "aws/aws-sdk-php": "Required to use the SQS queue driver, DynamoDb failed job storage and SES mail driver (^3.155).", + "aws/aws-sdk-php": "Required to use the SQS queue driver, DynamoDb failed job storage and SES mail driver (^3.186.4).", "brianium/paratest": "Required to run tests in parallel (^6.0).", "doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.6|^3.0).", "filp/whoops": "Required for friendly error pages in development (^2.8).", diff --git a/src/Illuminate/Bus/Batch.php b/src/Illuminate/Bus/Batch.php index 5766ff025ef9..aea6c0f641bc 100644 --- a/src/Illuminate/Bus/Batch.php +++ b/src/Illuminate/Bus/Batch.php @@ -11,7 +11,6 @@ use Illuminate\Support\Arr; use Illuminate\Support\Collection; use JsonSerializable; -use ReturnTypeWillChange; use Throwable; class Batch implements Arrayable, JsonSerializable @@ -460,7 +459,7 @@ public function toArray() * * @return array */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function jsonSerialize() { return $this->toArray(); diff --git a/src/Illuminate/Cache/Repository.php b/src/Illuminate/Cache/Repository.php index 00cd39b013a4..114b3ca9d85b 100755 --- a/src/Illuminate/Cache/Repository.php +++ b/src/Illuminate/Cache/Repository.php @@ -603,6 +603,7 @@ public function setEventDispatcher(Dispatcher $events) * @param string $key * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($key) { return $this->has($key); @@ -614,6 +615,7 @@ public function offsetExists($key) * @param string $key * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($key) { return $this->get($key); @@ -626,6 +628,7 @@ public function offsetGet($key) * @param mixed $value * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($key, $value) { $this->put($key, $value, $this->default); @@ -637,6 +640,7 @@ public function offsetSet($key, $value) * @param string $key * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($key) { $this->forget($key); diff --git a/src/Illuminate/Collections/Collection.php b/src/Illuminate/Collections/Collection.php index 39c611198d48..00ae3958c3d1 100644 --- a/src/Illuminate/Collections/Collection.php +++ b/src/Illuminate/Collections/Collection.php @@ -1423,6 +1423,7 @@ public function pad($size, $value) * * @return \ArrayIterator */ + #[\ReturnTypeWillChange] public function getIterator() { return new ArrayIterator($this->items); @@ -1433,6 +1434,7 @@ public function getIterator() * * @return int */ + #[\ReturnTypeWillChange] public function count() { return count($this->items); @@ -1478,6 +1480,7 @@ public function toBase() * @param mixed $key * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($key) { return isset($this->items[$key]); @@ -1489,6 +1492,7 @@ public function offsetExists($key) * @param mixed $key * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($key) { return $this->items[$key]; @@ -1501,6 +1505,7 @@ public function offsetGet($key) * @param mixed $value * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($key, $value) { if (is_null($key)) { @@ -1516,6 +1521,7 @@ public function offsetSet($key, $value) * @param string $key * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($key) { unset($this->items[$key]); diff --git a/src/Illuminate/Collections/LazyCollection.php b/src/Illuminate/Collections/LazyCollection.php index 6fb1f79db568..3ae549c154ac 100644 --- a/src/Illuminate/Collections/LazyCollection.php +++ b/src/Illuminate/Collections/LazyCollection.php @@ -1401,6 +1401,7 @@ public function pad($size, $value) * * @return \Traversable */ + #[\ReturnTypeWillChange] public function getIterator() { return $this->makeIterator($this->source); @@ -1411,6 +1412,7 @@ public function getIterator() * * @return int */ + #[\ReturnTypeWillChange] public function count() { if (is_array($this->source)) { diff --git a/src/Illuminate/Collections/Traits/EnumeratesValues.php b/src/Illuminate/Collections/Traits/EnumeratesValues.php index 7ced629bc4c4..19f32a322ee3 100644 --- a/src/Illuminate/Collections/Traits/EnumeratesValues.php +++ b/src/Illuminate/Collections/Traits/EnumeratesValues.php @@ -13,7 +13,6 @@ use Illuminate\Support\HigherOrderCollectionProxy; use Illuminate\Support\HigherOrderWhenProxy; use JsonSerializable; -use ReturnTypeWillChange; use Symfony\Component\VarDumper\VarDumper; use Traversable; @@ -834,7 +833,7 @@ public function toArray() * * @return array */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function jsonSerialize() { return array_map(function ($value) { diff --git a/src/Illuminate/Config/Repository.php b/src/Illuminate/Config/Repository.php index 5bcdcbf486c6..9f7af6d872e9 100644 --- a/src/Illuminate/Config/Repository.php +++ b/src/Illuminate/Config/Repository.php @@ -138,6 +138,7 @@ public function all() * @param string $key * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($key) { return $this->has($key); @@ -149,6 +150,7 @@ public function offsetExists($key) * @param string $key * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($key) { return $this->get($key); @@ -161,6 +163,7 @@ public function offsetGet($key) * @param mixed $value * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($key, $value) { $this->set($key, $value); @@ -172,6 +175,7 @@ public function offsetSet($key, $value) * @param string $key * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($key) { $this->set($key, null); diff --git a/src/Illuminate/Console/Scheduling/Event.php b/src/Illuminate/Console/Scheduling/Event.php index b3ab9b2db567..4ce5a7735d6c 100644 --- a/src/Illuminate/Console/Scheduling/Event.php +++ b/src/Illuminate/Console/Scheduling/Event.php @@ -10,7 +10,6 @@ use Illuminate\Contracts\Debug\ExceptionHandler; use Illuminate\Contracts\Mail\Mailer; use Illuminate\Support\Arr; -use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Date; use Illuminate\Support\Reflector; use Illuminate\Support\Stringable; @@ -322,7 +321,7 @@ public function runsInMaintenanceMode() */ protected function expressionPasses() { - $date = Carbon::now(); + $date = Date::now(); if ($this->timezone) { $date->setTimezone($this->timezone); diff --git a/src/Illuminate/Console/Scheduling/ManagesFrequencies.php b/src/Illuminate/Console/Scheduling/ManagesFrequencies.php index 7e1cdf17c0a8..d45bc0f8275b 100644 --- a/src/Illuminate/Console/Scheduling/ManagesFrequencies.php +++ b/src/Illuminate/Console/Scheduling/ManagesFrequencies.php @@ -262,10 +262,23 @@ public function dailyAt($time) * @return $this */ public function twiceDaily($first = 1, $second = 13) + { + return $this->twiceDailyAt($first, $second, 0); + } + + /** + * Schedule the event to run twice daily at a given offset. + * + * @param int $first + * @param int $second + * @param int $offset + * @return $this + */ + public function twiceDailyAt($first = 1, $second = 13, $offset = 0) { $hours = $first.','.$second; - return $this->spliceIntoPosition(1, 0) + return $this->spliceIntoPosition(1, $offset) ->spliceIntoPosition(2, $hours); } diff --git a/src/Illuminate/Container/Container.php b/src/Illuminate/Container/Container.php index b963b6b04924..9aa69ac0e7b6 100755 --- a/src/Illuminate/Container/Container.php +++ b/src/Illuminate/Container/Container.php @@ -1402,6 +1402,7 @@ public static function setInstance(ContainerContract $container = null) * @param string $key * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($key) { return $this->bound($key); @@ -1413,6 +1414,7 @@ public function offsetExists($key) * @param string $key * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($key) { return $this->make($key); @@ -1425,6 +1427,7 @@ public function offsetGet($key) * @param mixed $value * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($key, $value) { $this->bind($key, $value instanceof Closure ? $value : function () use ($value) { @@ -1438,6 +1441,7 @@ public function offsetSet($key, $value) * @param string $key * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($key) { unset($this->bindings[$key], $this->instances[$key], $this->resolved[$key]); diff --git a/src/Illuminate/Container/RewindableGenerator.php b/src/Illuminate/Container/RewindableGenerator.php index 675527d87eb4..4ee7bb20c667 100644 --- a/src/Illuminate/Container/RewindableGenerator.php +++ b/src/Illuminate/Container/RewindableGenerator.php @@ -39,6 +39,7 @@ public function __construct(callable $generator, $count) * * @return mixed */ + #[\ReturnTypeWillChange] public function getIterator() { return ($this->generator)(); @@ -49,6 +50,7 @@ public function getIterator() * * @return int */ + #[\ReturnTypeWillChange] public function count() { if (is_callable($count = $this->count)) { diff --git a/src/Illuminate/Contracts/Support/MessageBag.php b/src/Illuminate/Contracts/Support/MessageBag.php index 78bd8a00fc75..7f708aca533c 100644 --- a/src/Illuminate/Contracts/Support/MessageBag.php +++ b/src/Illuminate/Contracts/Support/MessageBag.php @@ -2,7 +2,9 @@ namespace Illuminate\Contracts\Support; -interface MessageBag extends Arrayable +use Countable; + +interface MessageBag extends Arrayable, Countable { /** * Get the keys present in the message bag. @@ -97,11 +99,4 @@ public function isEmpty(); * @return bool */ public function isNotEmpty(); - - /** - * Get the number of messages in the container. - * - * @return int - */ - public function count(); } diff --git a/src/Illuminate/Database/Concerns/BuildsQueries.php b/src/Illuminate/Database/Concerns/BuildsQueries.php index 64ce308406cf..184515ba21df 100644 --- a/src/Illuminate/Database/Concerns/BuildsQueries.php +++ b/src/Illuminate/Database/Concerns/BuildsQueries.php @@ -305,7 +305,11 @@ protected function paginateUsingCursor($perPage, $columns = ['*'], $cursorName = if (! is_null($cursor)) { $addCursorConditions = function (self $builder, $previousColumn, $i) use (&$addCursorConditions, $cursor, $orders) { if (! is_null($previousColumn)) { - $builder->where($previousColumn, '=', $cursor->parameter($previousColumn)); + $builder->where( + $this->getOriginalColumnNameForCursorPagination($this, $previousColumn), + '=', + $cursor->parameter($previousColumn) + ); } $builder->where(function (self $builder) use ($addCursorConditions, $cursor, $orders, $i) { diff --git a/src/Illuminate/Database/Eloquent/Casts/ArrayObject.php b/src/Illuminate/Database/Eloquent/Casts/ArrayObject.php index b1120c3f4a1d..6f1713c946ac 100644 --- a/src/Illuminate/Database/Eloquent/Casts/ArrayObject.php +++ b/src/Illuminate/Database/Eloquent/Casts/ArrayObject.php @@ -5,7 +5,6 @@ use ArrayObject as BaseArrayObject; use Illuminate\Contracts\Support\Arrayable; use JsonSerializable; -use ReturnTypeWillChange; class ArrayObject extends BaseArrayObject implements Arrayable, JsonSerializable { @@ -34,7 +33,7 @@ public function toArray() * * @return array */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function jsonSerialize() { return $this->getArrayCopy(); diff --git a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php index e70378c6b078..dabcb7209968 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php +++ b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php @@ -2,6 +2,7 @@ namespace Illuminate\Database\Eloquent\Concerns; +use Carbon\CarbonImmutable; use Carbon\CarbonInterface; use DateTimeInterface; use Illuminate\Contracts\Database\Eloquent\Castable; @@ -78,6 +79,9 @@ trait HasAttributes 'encrypted:json', 'encrypted:object', 'float', + 'immutable_date', + 'immutable_datetime', + 'immutable_custom_datetime', 'int', 'integer', 'json', @@ -241,11 +245,13 @@ protected function addCastAttributesToArray(array $attributes, array $mutatedAtt // a string. This allows the developers to customize how dates are serialized // into an array without affecting how they are persisted into the storage. if ($attributes[$key] && - ($value === 'date' || $value === 'datetime')) { + ($value === 'date' || $value === 'datetime' || + $value === 'immutable_date' || $value === 'immutable_datetime')) { $attributes[$key] = $this->serializeDate($attributes[$key]); } - if ($attributes[$key] && $this->isCustomDateTimeCast($value)) { + if ($attributes[$key] && ($this->isCustomDateTimeCast($value) || + $this->isImmutableCustomDateTimeCast($value))) { $attributes[$key] = $attributes[$key]->format(explode(':', $value, 2)[1]); } @@ -537,8 +543,8 @@ protected function mutateAttribute($key, $value) protected function mutateAttributeForArray($key, $value) { $value = $this->isClassCastable($key) - ? $this->getClassCastableAttributeValue($key, $value) - : $this->mutateAttribute($key, $value); + ? $this->getClassCastableAttributeValue($key, $value) + : $this->mutateAttribute($key, $value); return $value instanceof Arrayable ? $value->toArray() : $value; } @@ -607,6 +613,11 @@ protected function castAttribute($key, $value) case 'datetime': case 'custom_datetime': return $this->asDateTime($value); + case 'immutable_date': + return $this->asDate($value)->toImmutable(); + case 'immutable_custom_datetime': + case 'immutable_datetime': + return $this->asDateTime($value)->toImmutable(); case 'timestamp': return $this->asTimestamp($value); } @@ -633,8 +644,8 @@ protected function getClassCastableAttributeValue($key, $value) $caster = $this->resolveCasterClass($key); $value = $caster instanceof CastsInboundAttributes - ? $value - : $caster->get($this, $key, $value, $this->attributes); + ? $value + : $caster->get($this, $key, $value, $this->attributes); if ($caster instanceof CastsInboundAttributes || ! is_object($value)) { unset($this->classCastCache[$key]); @@ -658,6 +669,10 @@ protected function getCastType($key) return 'custom_datetime'; } + if ($this->isImmutableCustomDateTimeCast($this->getCasts()[$key])) { + return 'immutable_custom_datetime'; + } + if ($this->isDecimalCast($this->getCasts()[$key])) { return 'decimal'; } @@ -706,6 +721,18 @@ protected function isCustomDateTimeCast($cast) strncmp($cast, 'datetime:', 9) === 0; } + /** + * Determine if the cast type is an immutable custom date time cast. + * + * @param string $cast + * @return bool + */ + protected function isImmutableCustomDateTimeCast($cast) + { + return strncmp($cast, 'immutable_date:', 15) === 0 || + strncmp($cast, 'immutable_datetime:', 19) === 0; + } + /** * Determine if the cast type is a decimal cast. * @@ -798,7 +825,7 @@ protected function setMutatedAttributeValue($key, $value) protected function isDateAttribute($key) { return in_array($key, $this->getDates(), true) || - $this->isDateCastable($key); + $this->isDateCastable($key); } /** @@ -817,8 +844,8 @@ public function fillJsonAttribute($key, $value) )); $this->attributes[$key] = $this->isEncryptedCastable($key) - ? $this->castAttributeAsEncryptedString($key, $value) - : $value; + ? $this->castAttributeAsEncryptedString($key, $value) + : $value; return $this; } @@ -887,8 +914,8 @@ protected function getArrayAttributeByKey($key) return $this->fromJson( $this->isEncryptedCastable($key) - ? $this->fromEncryptedString($this->attributes[$key]) - : $this->attributes[$key] + ? $this->fromEncryptedString($this->attributes[$key]) + : $this->attributes[$key] ); } @@ -1107,7 +1134,9 @@ protected function asTimestamp($value) */ protected function serializeDate(DateTimeInterface $date) { - return Carbon::instance($date)->toJSON(); + return $date instanceof \DateTimeImmutable ? + CarbonImmutable::instance($date)->toJSON() : + Carbon::instance($date)->toJSON(); } /** @@ -1268,7 +1297,7 @@ protected function isClassDeviable($key) protected function isClassSerializable($key) { return $this->isClassCastable($key) && - method_exists($this->parseCasterClass($this->getCasts()[$key]), 'serialize'); + method_exists($this->parseCasterClass($this->getCasts()[$key]), 'serialize'); } /** @@ -1310,8 +1339,8 @@ protected function resolveCasterClass($key) protected function parseCasterClass($class) { return strpos($class, ':') === false - ? $class - : explode(':', $class, 2)[0]; + ? $class + : explode(':', $class, 2)[0]; } /** @@ -1327,8 +1356,8 @@ protected function mergeAttributesFromClassCasts() $this->attributes = array_merge( $this->attributes, $caster instanceof CastsInboundAttributes - ? [$key => $value] - : $this->normalizeCastClassResponse($key, $caster->set($this, $key, $value, $this->attributes)) + ? [$key => $value] + : $this->normalizeCastClassResponse($key, $caster->set($this, $key, $value, $this->attributes)) ); } } @@ -1618,7 +1647,7 @@ public function originalIsEquivalent($key) return false; } elseif ($this->isDateAttribute($key)) { return $this->fromDateTime($attribute) === - $this->fromDateTime($original); + $this->fromDateTime($original); } elseif ($this->hasCast($key, ['object', 'collection'])) { return $this->castAttribute($key, $attribute) == $this->castAttribute($key, $original); @@ -1630,11 +1659,11 @@ public function originalIsEquivalent($key) return abs($this->castAttribute($key, $attribute) - $this->castAttribute($key, $original)) < PHP_FLOAT_EPSILON * 4; } elseif ($this->hasCast($key, static::$primitiveCastTypes)) { return $this->castAttribute($key, $attribute) === - $this->castAttribute($key, $original); + $this->castAttribute($key, $original); } return is_numeric($attribute) && is_numeric($original) - && strcmp((string) $attribute, (string) $original) === 0; + && strcmp((string) $attribute, (string) $original) === 0; } /** diff --git a/src/Illuminate/Database/Eloquent/Model.php b/src/Illuminate/Database/Eloquent/Model.php index 0b95847a1112..1ee0829fe877 100644 --- a/src/Illuminate/Database/Eloquent/Model.php +++ b/src/Illuminate/Database/Eloquent/Model.php @@ -21,7 +21,6 @@ use Illuminate\Support\Traits\ForwardsCalls; use JsonSerializable; use LogicException; -use ReturnTypeWillChange; abstract class Model implements Arrayable, ArrayAccess, HasBroadcastChannel, Jsonable, JsonSerializable, QueueableEntity, UrlRoutable { @@ -1427,7 +1426,7 @@ public function toJson($options = 0) * * @return array */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function jsonSerialize() { return $this->toArray(); @@ -1912,6 +1911,7 @@ public function __set($key, $value) * @param mixed $offset * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return ! is_null($this->getAttribute($offset)); @@ -1923,6 +1923,7 @@ public function offsetExists($offset) * @param mixed $offset * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->getAttribute($offset); @@ -1935,6 +1936,7 @@ public function offsetGet($offset) * @param mixed $value * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { $this->setAttribute($offset, $value); @@ -1946,6 +1948,7 @@ public function offsetSet($offset, $value) * @param mixed $offset * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->attributes[$offset], $this->relations[$offset]); diff --git a/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php b/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php index f0896a35a3b2..85ff01214e97 100755 --- a/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php +++ b/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php @@ -369,7 +369,7 @@ protected function wrapJsonSelector($value) } /** - *Wrap the given JSON selector for boolean values. + * Wrap the given JSON selector for boolean values. * * @param string $value * @return string diff --git a/src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php b/src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php index e5c97c4183d1..0f5a27a66145 100755 --- a/src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php +++ b/src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php @@ -222,7 +222,7 @@ protected function queryOrderContainsSubquery($query) } /** - * Move the order bindings to be after the "select" statement to account for a order by subquery. + * Move the order bindings to be after the "select" statement to account for an order by subquery. * * @param \Illuminate\Database\Query\Builder $query * @return array diff --git a/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php b/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php index 9496dcea3730..810c730a73e7 100755 --- a/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php +++ b/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php @@ -68,6 +68,7 @@ use Illuminate\Queue\Console\ForgetFailedCommand as ForgetFailedQueueCommand; use Illuminate\Queue\Console\ListenCommand as QueueListenCommand; use Illuminate\Queue\Console\ListFailedCommand as ListFailedQueueCommand; +use Illuminate\Queue\Console\MonitorCommand as QueueMonitorCommand; use Illuminate\Queue\Console\PruneBatchesCommand as PruneBatchesQueueCommand; use Illuminate\Queue\Console\PruneFailedJobsCommand; use Illuminate\Queue\Console\RestartCommand as QueueRestartCommand; @@ -111,6 +112,7 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid 'QueueFlush' => 'command.queue.flush', 'QueueForget' => 'command.queue.forget', 'QueueListen' => 'command.queue.listen', + 'QueueMonitor' => 'command.queue.monitor', 'QueuePruneBatches' => 'command.queue.prune-batches', 'QueuePruneFailedJobs' => 'command.queue.prune-failed-jobs', 'QueueRestart' => 'command.queue.restart', @@ -702,6 +704,18 @@ protected function registerQueueListenCommand() }); } + /** + * Register the command. + * + * @return void + */ + protected function registerQueueMonitorCommand() + { + $this->app->singleton('command.queue.monitor', function ($app) { + return new QueueMonitorCommand($app['queue'], $app['events']); + }); + } + /** * Register the command. * diff --git a/src/Illuminate/Http/Client/Events/ConnectionFailed.php b/src/Illuminate/Http/Client/Events/ConnectionFailed.php index dbbb30c078cf..504006c80539 100644 --- a/src/Illuminate/Http/Client/Events/ConnectionFailed.php +++ b/src/Illuminate/Http/Client/Events/ConnectionFailed.php @@ -16,7 +16,7 @@ class ConnectionFailed /** * Create a new event instance. * - * @param \Illuminate\Http\Client\Request $request + * @param \Illuminate\Http\Client\Request $request * @return void */ public function __construct(Request $request) diff --git a/src/Illuminate/Http/Client/Events/ResponseReceived.php b/src/Illuminate/Http/Client/Events/ResponseReceived.php index 2202f1129d40..77be7aba7662 100644 --- a/src/Illuminate/Http/Client/Events/ResponseReceived.php +++ b/src/Illuminate/Http/Client/Events/ResponseReceived.php @@ -24,7 +24,7 @@ class ResponseReceived /** * Create a new event instance. * - * @param \Illuminate\Http\Client\Request $request + * @param \Illuminate\Http\Client\Request $request * @param \Illuminate\Http\Client\Response $response * @return void */ diff --git a/src/Illuminate/Http/Client/PendingRequest.php b/src/Illuminate/Http/Client/PendingRequest.php index 317e794b69b1..b0874c680ed4 100644 --- a/src/Illuminate/Http/Client/PendingRequest.php +++ b/src/Illuminate/Http/Client/PendingRequest.php @@ -181,7 +181,7 @@ public function baseUrl(string $url) /** * Attach a raw body to the request. * - * @param resource|string $content + * @param string $content * @param string $contentType * @return $this */ @@ -220,7 +220,7 @@ public function asForm() * Attach a file to the request. * * @param string|array $name - * @param string $contents + * @param string|resource $contents * @param string|null $filename * @param array $headers * @return $this diff --git a/src/Illuminate/Http/Client/Request.php b/src/Illuminate/Http/Client/Request.php index eb066dcc163d..f8699b5ac4aa 100644 --- a/src/Illuminate/Http/Client/Request.php +++ b/src/Illuminate/Http/Client/Request.php @@ -263,6 +263,7 @@ public function toPsrRequest() * @param string $offset * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->data()[$offset]); @@ -274,6 +275,7 @@ public function offsetExists($offset) * @param string $offset * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->data()[$offset]; @@ -288,6 +290,7 @@ public function offsetGet($offset) * * @throws \LogicException */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { throw new LogicException('Request data may not be mutated using array access.'); @@ -301,6 +304,7 @@ public function offsetSet($offset, $value) * * @throws \LogicException */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { throw new LogicException('Request data may not be mutated using array access.'); diff --git a/src/Illuminate/Http/Client/Response.php b/src/Illuminate/Http/Client/Response.php index 4326735f7dda..dc25cb830acc 100644 --- a/src/Illuminate/Http/Client/Response.php +++ b/src/Illuminate/Http/Client/Response.php @@ -290,6 +290,7 @@ public function throw() * @param string $offset * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->json()[$offset]); @@ -301,6 +302,7 @@ public function offsetExists($offset) * @param string $offset * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->json()[$offset]; @@ -315,6 +317,7 @@ public function offsetGet($offset) * * @throws \LogicException */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { throw new LogicException('Response data may not be mutated using array access.'); @@ -328,6 +331,7 @@ public function offsetSet($offset, $value) * * @throws \LogicException */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { throw new LogicException('Response data may not be mutated using array access.'); diff --git a/src/Illuminate/Http/Request.php b/src/Illuminate/Http/Request.php index 06f143c6020f..0dd1208778d6 100644 --- a/src/Illuminate/Http/Request.php +++ b/src/Illuminate/Http/Request.php @@ -634,6 +634,7 @@ public function toArray() * @param string $offset * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return Arr::has( @@ -648,6 +649,7 @@ public function offsetExists($offset) * @param string $offset * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->__get($offset); @@ -660,6 +662,7 @@ public function offsetGet($offset) * @param mixed $value * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { $this->getInputSource()->set($offset, $value); @@ -671,6 +674,7 @@ public function offsetSet($offset, $value) * @param string $offset * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { $this->getInputSource()->remove($offset); diff --git a/src/Illuminate/Http/Resources/CollectsResources.php b/src/Illuminate/Http/Resources/CollectsResources.php index 00209dfc170d..cd795df70fa0 100644 --- a/src/Illuminate/Http/Resources/CollectsResources.php +++ b/src/Illuminate/Http/Resources/CollectsResources.php @@ -59,6 +59,7 @@ class_exists($class = Str::replaceLast('Collection', 'Resource', get_class($this * * @return \ArrayIterator */ + #[\ReturnTypeWillChange] public function getIterator() { return $this->collection->getIterator(); diff --git a/src/Illuminate/Http/Resources/DelegatesToResource.php b/src/Illuminate/Http/Resources/DelegatesToResource.php index 495b7e3bf12a..48f455f97e02 100644 --- a/src/Illuminate/Http/Resources/DelegatesToResource.php +++ b/src/Illuminate/Http/Resources/DelegatesToResource.php @@ -64,6 +64,7 @@ public function resolveChildRouteBinding($childType, $value, $field = null) * @param mixed $offset * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->resource[$offset]); @@ -75,6 +76,7 @@ public function offsetExists($offset) * @param mixed $offset * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->resource[$offset]; @@ -87,6 +89,7 @@ public function offsetGet($offset) * @param mixed $value * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { $this->resource[$offset] = $value; @@ -98,6 +101,7 @@ public function offsetSet($offset, $value) * @param mixed $offset * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->resource[$offset]); diff --git a/src/Illuminate/Http/Resources/Json/JsonResource.php b/src/Illuminate/Http/Resources/Json/JsonResource.php index 130a0691ebef..7cbdb602997e 100644 --- a/src/Illuminate/Http/Resources/Json/JsonResource.php +++ b/src/Illuminate/Http/Resources/Json/JsonResource.php @@ -11,7 +11,6 @@ use Illuminate\Http\Resources\ConditionallyLoadsAttributes; use Illuminate\Http\Resources\DelegatesToResource; use JsonSerializable; -use ReturnTypeWillChange; class JsonResource implements ArrayAccess, JsonSerializable, Responsable, UrlRoutable { @@ -227,7 +226,7 @@ public function toResponse($request) * * @return array */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function jsonSerialize() { return $this->resolve(Container::getInstance()->make('request')); diff --git a/src/Illuminate/Http/Resources/Json/ResourceCollection.php b/src/Illuminate/Http/Resources/Json/ResourceCollection.php index ff090e9bea3a..65710aa32700 100644 --- a/src/Illuminate/Http/Resources/Json/ResourceCollection.php +++ b/src/Illuminate/Http/Resources/Json/ResourceCollection.php @@ -85,6 +85,7 @@ public function withQuery(array $query) * * @return int */ + #[\ReturnTypeWillChange] public function count() { return $this->collection->count(); diff --git a/src/Illuminate/Http/ResponseTrait.php b/src/Illuminate/Http/ResponseTrait.php index 6d568bb1d86d..cbe29dcc9902 100644 --- a/src/Illuminate/Http/ResponseTrait.php +++ b/src/Illuminate/Http/ResponseTrait.php @@ -130,8 +130,8 @@ public function withCookie($cookie) * Expire a cookie when sending the response. * * @param \Symfony\Component\HttpFoundation\Cookie|mixed $cookie - * @param string|null $path - * @param string|null $domain + * @param string|null $path + * @param string|null $domain * @return $this */ public function withoutCookie($cookie, $path = null, $domain = null) diff --git a/src/Illuminate/Mail/composer.json b/src/Illuminate/Mail/composer.json index 98dd9bc144bb..5e1610c83bbf 100755 --- a/src/Illuminate/Mail/composer.json +++ b/src/Illuminate/Mail/composer.json @@ -37,7 +37,7 @@ } }, "suggest": { - "aws/aws-sdk-php": "Required to use the SES mail driver (^3.155).", + "aws/aws-sdk-php": "Required to use the SES mail driver (^3.186.4).", "guzzlehttp/guzzle": "Required to use the Mailgun mail driver (^6.5.5|^7.0.1).", "wildbit/swiftmailer-postmark": "Required to use Postmark mail driver (^3.0)." }, diff --git a/src/Illuminate/Pagination/AbstractCursorPaginator.php b/src/Illuminate/Pagination/AbstractCursorPaginator.php index 9644f66036b0..1965588137e8 100644 --- a/src/Illuminate/Pagination/AbstractCursorPaginator.php +++ b/src/Illuminate/Pagination/AbstractCursorPaginator.php @@ -515,6 +515,7 @@ public static function viewFactory() * * @return \ArrayIterator */ + #[\ReturnTypeWillChange] public function getIterator() { return $this->items->getIterator(); @@ -545,6 +546,7 @@ public function isNotEmpty() * * @return int */ + #[\ReturnTypeWillChange] public function count() { return $this->items->count(); @@ -589,6 +591,7 @@ public function getOptions() * @param mixed $key * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($key) { return $this->items->has($key); @@ -600,6 +603,7 @@ public function offsetExists($key) * @param mixed $key * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($key) { return $this->items->get($key); @@ -612,6 +616,7 @@ public function offsetGet($key) * @param mixed $value * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($key, $value) { $this->items->put($key, $value); @@ -623,6 +628,7 @@ public function offsetSet($key, $value) * @param mixed $key * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($key) { $this->items->forget($key); diff --git a/src/Illuminate/Pagination/AbstractPaginator.php b/src/Illuminate/Pagination/AbstractPaginator.php index fd50ab2697b2..2e60b6eb797b 100644 --- a/src/Illuminate/Pagination/AbstractPaginator.php +++ b/src/Illuminate/Pagination/AbstractPaginator.php @@ -619,6 +619,7 @@ public static function useBootstrapThree() * * @return \ArrayIterator */ + #[\ReturnTypeWillChange] public function getIterator() { return $this->items->getIterator(); @@ -649,6 +650,7 @@ public function isNotEmpty() * * @return int */ + #[\ReturnTypeWillChange] public function count() { return $this->items->count(); @@ -693,6 +695,7 @@ public function getOptions() * @param mixed $key * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($key) { return $this->items->has($key); @@ -704,6 +707,7 @@ public function offsetExists($key) * @param mixed $key * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($key) { return $this->items->get($key); @@ -716,6 +720,7 @@ public function offsetGet($key) * @param mixed $value * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($key, $value) { $this->items->put($key, $value); @@ -727,6 +732,7 @@ public function offsetSet($key, $value) * @param mixed $key * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($key) { $this->items->forget($key); diff --git a/src/Illuminate/Pagination/CursorPaginator.php b/src/Illuminate/Pagination/CursorPaginator.php index f53c99678475..01039b7d1da0 100644 --- a/src/Illuminate/Pagination/CursorPaginator.php +++ b/src/Illuminate/Pagination/CursorPaginator.php @@ -10,7 +10,6 @@ use Illuminate\Support\Collection; use IteratorAggregate; use JsonSerializable; -use ReturnTypeWillChange; class CursorPaginator extends AbstractCursorPaginator implements Arrayable, ArrayAccess, Countable, IteratorAggregate, Jsonable, JsonSerializable, PaginatorContract { @@ -143,7 +142,7 @@ public function toArray() * * @return array */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function jsonSerialize() { return $this->toArray(); diff --git a/src/Illuminate/Pagination/LengthAwarePaginator.php b/src/Illuminate/Pagination/LengthAwarePaginator.php index f64e198ef054..81c0d78a515b 100644 --- a/src/Illuminate/Pagination/LengthAwarePaginator.php +++ b/src/Illuminate/Pagination/LengthAwarePaginator.php @@ -10,7 +10,6 @@ use Illuminate\Support\Collection; use IteratorAggregate; use JsonSerializable; -use ReturnTypeWillChange; class LengthAwarePaginator extends AbstractPaginator implements Arrayable, ArrayAccess, Countable, IteratorAggregate, Jsonable, JsonSerializable, LengthAwarePaginatorContract { @@ -214,7 +213,7 @@ public function toArray() * * @return array */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function jsonSerialize() { return $this->toArray(); diff --git a/src/Illuminate/Pagination/Paginator.php b/src/Illuminate/Pagination/Paginator.php index 822e7677e726..d295e669480f 100644 --- a/src/Illuminate/Pagination/Paginator.php +++ b/src/Illuminate/Pagination/Paginator.php @@ -10,7 +10,6 @@ use Illuminate\Support\Collection; use IteratorAggregate; use JsonSerializable; -use ReturnTypeWillChange; class Paginator extends AbstractPaginator implements Arrayable, ArrayAccess, Countable, IteratorAggregate, Jsonable, JsonSerializable, PaginatorContract { @@ -159,7 +158,7 @@ public function toArray() * * @return array */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function jsonSerialize() { return $this->toArray(); diff --git a/src/Illuminate/Queue/Console/MonitorCommand.php b/src/Illuminate/Queue/Console/MonitorCommand.php new file mode 100644 index 000000000000..1deb479ae698 --- /dev/null +++ b/src/Illuminate/Queue/Console/MonitorCommand.php @@ -0,0 +1,137 @@ +manager = $manager; + $this->events = $events; + } + + /** + * Execute the console command. + * + * @return void + */ + public function handle() + { + $queues = $this->parseQueues($this->argument('queues')); + + $this->displaySizes($queues); + + $this->dispatchEvents($queues); + } + + /** + * Parse the queues into an array of the connections and queues. + * + * @param string $queues + * @return \Illuminate\Support\Collection + */ + protected function parseQueues($queues) + { + return collect(explode(',', $queues))->map(function ($queue) { + [$connection, $queue] = array_pad(explode(':', $queue, 2), 2, null); + + if (! isset($queue)) { + $queue = $connection; + $connection = $this->laravel['config']['queue.default']; + } + + return [ + 'connection' => $connection, + 'queue' => $queue, + 'size' => $size = $this->manager->connection($connection)->size($queue), + 'status' => $size >= $this->option('max') ? 'ALERT' : 'OK', + ]; + }); + } + + /** + * Display the failed jobs in the console. + * + * @param \Illuminate\Support\Collection $queues + * @return void + */ + protected function displaySizes(Collection $queues) + { + $this->table($this->headers, $queues); + } + + /** + * Fire the monitoring events. + * + * @param \Illuminate\Support\Collection $queues + * @return void + */ + protected function dispatchEvents(Collection $queues) + { + foreach ($queues as $queue) { + if ($queue['status'] == 'OK') { + continue; + } + + $this->events->dispatch( + new QueueBusy( + $queue['connection'], + $queue['queue'], + $queue['size'], + ) + ); + } + } +} diff --git a/src/Illuminate/Queue/Events/QueueBusy.php b/src/Illuminate/Queue/Events/QueueBusy.php new file mode 100644 index 000000000000..684dec4ea08a --- /dev/null +++ b/src/Illuminate/Queue/Events/QueueBusy.php @@ -0,0 +1,42 @@ +connection = $connection; + $this->queue = $queue; + $this->size = $size; + } +} diff --git a/src/Illuminate/Queue/composer.json b/src/Illuminate/Queue/composer.json index 4ae4b55c693a..50a0fd0e5e52 100644 --- a/src/Illuminate/Queue/composer.json +++ b/src/Illuminate/Queue/composer.json @@ -41,7 +41,7 @@ "suggest": { "ext-pcntl": "Required to use all features of the queue worker.", "ext-posix": "Required to use all features of the queue worker.", - "aws/aws-sdk-php": "Required to use the SQS queue driver and DynamoDb failed job storage (^3.155).", + "aws/aws-sdk-php": "Required to use the SQS queue driver and DynamoDb failed job storage (^3.186.4).", "illuminate/redis": "Required to use the Redis queue driver (^8.0).", "pda/pheanstalk": "Required to use the Beanstalk queue driver (^4.0)." }, diff --git a/src/Illuminate/Routing/AbstractRouteCollection.php b/src/Illuminate/Routing/AbstractRouteCollection.php index 8b2a26e8d335..003566091550 100644 --- a/src/Illuminate/Routing/AbstractRouteCollection.php +++ b/src/Illuminate/Routing/AbstractRouteCollection.php @@ -237,6 +237,7 @@ protected function generateRouteName() * * @return \ArrayIterator */ + #[\ReturnTypeWillChange] public function getIterator() { return new ArrayIterator($this->getRoutes()); @@ -247,6 +248,7 @@ public function getIterator() * * @return int */ + #[\ReturnTypeWillChange] public function count() { return count($this->getRoutes()); diff --git a/src/Illuminate/Routing/UrlGenerator.php b/src/Illuminate/Routing/UrlGenerator.php index b2c694ab69da..5c754301ac46 100755 --- a/src/Illuminate/Routing/UrlGenerator.php +++ b/src/Illuminate/Routing/UrlGenerator.php @@ -318,13 +318,9 @@ public function formatScheme($secure = null) */ public function signedRoute($name, $parameters = [], $expiration = null, $absolute = true) { - $parameters = Arr::wrap($parameters); - - if (array_key_exists('signature', $parameters)) { - throw new InvalidArgumentException( - '"Signature" is a reserved parameter when generating signed routes. Please rename your route parameter.' - ); - } + $this->ensureSignedRouteParametersAreNotReserved( + $parameters = $this->formatParameters($parameters) + ); if ($expiration) { $parameters = $parameters + ['expires' => $this->availableAt($expiration)]; @@ -339,6 +335,27 @@ public function signedRoute($name, $parameters = [], $expiration = null, $absolu ], $absolute); } + /** + * Ensure the given signed route parameters are not reserved. + * + * @param mixed $parameters + * @return void + */ + protected function ensureSignedRouteParametersAreNotReserved($parameters) + { + if (array_key_exists('signature', $parameters)) { + throw new InvalidArgumentException( + '"Signature" is a reserved parameter when generating signed routes. Please rename your route parameter.' + ); + } + + if (array_key_exists('expires', $parameters)) { + throw new InvalidArgumentException( + '"Expires" is a reserved parameter when generating signed routes. Please rename your route parameter.' + ); + } + } + /** * Create a temporary signed route URL for a named route. * diff --git a/src/Illuminate/Session/ArraySessionHandler.php b/src/Illuminate/Session/ArraySessionHandler.php index 571210f637ef..1dcaa607feb4 100644 --- a/src/Illuminate/Session/ArraySessionHandler.php +++ b/src/Illuminate/Session/ArraySessionHandler.php @@ -3,7 +3,6 @@ namespace Illuminate\Session; use Illuminate\Support\InteractsWithTime; -use ReturnTypeWillChange; use SessionHandlerInterface; class ArraySessionHandler implements SessionHandlerInterface @@ -38,7 +37,7 @@ public function __construct($minutes) /** * {@inheritdoc} */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function open($savePath, $sessionName) { return true; @@ -47,7 +46,7 @@ public function open($savePath, $sessionName) /** * {@inheritdoc} */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function close() { return true; @@ -56,7 +55,7 @@ public function close() /** * {@inheritdoc} */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function read($sessionId) { if (! isset($this->storage[$sessionId])) { @@ -77,7 +76,7 @@ public function read($sessionId) /** * {@inheritdoc} */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function write($sessionId, $data) { $this->storage[$sessionId] = [ @@ -91,7 +90,7 @@ public function write($sessionId, $data) /** * {@inheritdoc} */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function destroy($sessionId) { if (isset($this->storage[$sessionId])) { @@ -104,7 +103,7 @@ public function destroy($sessionId) /** * {@inheritdoc} */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function gc($lifetime) { $expiration = $this->calculateExpiration($lifetime); diff --git a/src/Illuminate/Session/NullSessionHandler.php b/src/Illuminate/Session/NullSessionHandler.php index c34e47ef5848..778f48fa42e3 100644 --- a/src/Illuminate/Session/NullSessionHandler.php +++ b/src/Illuminate/Session/NullSessionHandler.php @@ -2,7 +2,6 @@ namespace Illuminate\Session; -use ReturnTypeWillChange; use SessionHandlerInterface; class NullSessionHandler implements SessionHandlerInterface @@ -10,7 +9,7 @@ class NullSessionHandler implements SessionHandlerInterface /** * {@inheritdoc} */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function open($savePath, $sessionName) { return true; @@ -19,7 +18,7 @@ public function open($savePath, $sessionName) /** * {@inheritdoc} */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function close() { return true; @@ -28,7 +27,7 @@ public function close() /** * {@inheritdoc} */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function read($sessionId) { return ''; @@ -37,7 +36,7 @@ public function read($sessionId) /** * {@inheritdoc} */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function write($sessionId, $data) { return true; @@ -46,7 +45,7 @@ public function write($sessionId, $data) /** * {@inheritdoc} */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function destroy($sessionId) { return true; @@ -55,7 +54,7 @@ public function destroy($sessionId) /** * {@inheritdoc} */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function gc($lifetime) { return true; diff --git a/src/Illuminate/Support/Fluent.php b/src/Illuminate/Support/Fluent.php index 411b83f8deb4..4660283b87e6 100755 --- a/src/Illuminate/Support/Fluent.php +++ b/src/Illuminate/Support/Fluent.php @@ -6,7 +6,6 @@ use Illuminate\Contracts\Support\Arrayable; use Illuminate\Contracts\Support\Jsonable; use JsonSerializable; -use ReturnTypeWillChange; class Fluent implements Arrayable, ArrayAccess, Jsonable, JsonSerializable { @@ -71,7 +70,7 @@ public function toArray() * * @return array */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function jsonSerialize() { return $this->toArray(); @@ -94,6 +93,7 @@ public function toJson($options = 0) * @param string $offset * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->attributes[$offset]); @@ -105,6 +105,7 @@ public function offsetExists($offset) * @param string $offset * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->get($offset); @@ -117,6 +118,7 @@ public function offsetGet($offset) * @param mixed $value * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { $this->attributes[$offset] = $value; @@ -128,6 +130,7 @@ public function offsetSet($offset, $value) * @param string $offset * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->attributes[$offset]); diff --git a/src/Illuminate/Support/MessageBag.php b/src/Illuminate/Support/MessageBag.php index 852bc5e3bb58..52f3b389ccf7 100755 --- a/src/Illuminate/Support/MessageBag.php +++ b/src/Illuminate/Support/MessageBag.php @@ -2,15 +2,12 @@ namespace Illuminate\Support; -use Countable; -use Illuminate\Contracts\Support\Arrayable; use Illuminate\Contracts\Support\Jsonable; use Illuminate\Contracts\Support\MessageBag as MessageBagContract; use Illuminate\Contracts\Support\MessageProvider; use JsonSerializable; -use ReturnTypeWillChange; -class MessageBag implements Arrayable, Countable, Jsonable, JsonSerializable, MessageBagContract, MessageProvider +class MessageBag implements Jsonable, JsonSerializable, MessageBagContract, MessageProvider { /** * All of the registered messages. @@ -370,6 +367,7 @@ public function any() * * @return int */ + #[\ReturnTypeWillChange] public function count() { return count($this->messages, COUNT_RECURSIVE) - count($this->messages); @@ -390,7 +388,7 @@ public function toArray() * * @return array */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function jsonSerialize() { return $this->toArray(); diff --git a/src/Illuminate/Support/Optional.php b/src/Illuminate/Support/Optional.php index b7ea039f949c..816190dd7a2e 100644 --- a/src/Illuminate/Support/Optional.php +++ b/src/Illuminate/Support/Optional.php @@ -68,6 +68,7 @@ public function __isset($name) * @param mixed $key * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($key) { return Arr::accessible($this->value) && Arr::exists($this->value, $key); @@ -79,6 +80,7 @@ public function offsetExists($key) * @param mixed $key * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($key) { return Arr::get($this->value, $key); @@ -91,6 +93,7 @@ public function offsetGet($key) * @param mixed $value * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($key, $value) { if (Arr::accessible($this->value)) { @@ -104,6 +107,7 @@ public function offsetSet($key, $value) * @param string $key * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($key) { if (Arr::accessible($this->value)) { diff --git a/src/Illuminate/Support/Stringable.php b/src/Illuminate/Support/Stringable.php index af181b1c1f0c..6e8328e3ab1f 100644 --- a/src/Illuminate/Support/Stringable.php +++ b/src/Illuminate/Support/Stringable.php @@ -7,7 +7,6 @@ use Illuminate\Support\Traits\Macroable; use Illuminate\Support\Traits\Tappable; use JsonSerializable; -use ReturnTypeWillChange; use Symfony\Component\VarDumper\VarDumper; class Stringable implements JsonSerializable @@ -783,7 +782,7 @@ public function dd() * * @return string */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function jsonSerialize() { return $this->__toString(); diff --git a/src/Illuminate/Support/ViewErrorBag.php b/src/Illuminate/Support/ViewErrorBag.php index 0f273b5b7573..d51bb534d84e 100644 --- a/src/Illuminate/Support/ViewErrorBag.php +++ b/src/Illuminate/Support/ViewErrorBag.php @@ -78,6 +78,7 @@ public function any() * * @return int */ + #[\ReturnTypeWillChange] public function count() { return $this->getBag('default')->count(); diff --git a/src/Illuminate/Testing/AssertableJsonString.php b/src/Illuminate/Testing/AssertableJsonString.php index e36c84aa300d..a5979865ea64 100644 --- a/src/Illuminate/Testing/AssertableJsonString.php +++ b/src/Illuminate/Testing/AssertableJsonString.php @@ -334,6 +334,7 @@ protected function jsonSearchStrings($key, $value) * * @return int */ + #[\ReturnTypeWillChange] public function count() { return count($this->decoded); @@ -345,6 +346,7 @@ public function count() * @param mixed $offset * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->decoded[$offset]); @@ -356,6 +358,7 @@ public function offsetExists($offset) * @param string $offset * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->decoded[$offset]; @@ -368,6 +371,7 @@ public function offsetGet($offset) * @param mixed $value * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { $this->decoded[$offset] = $value; @@ -379,6 +383,7 @@ public function offsetSet($offset, $value) * @param string $offset * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->decoded[$offset]); diff --git a/src/Illuminate/Testing/Fluent/Concerns/Has.php b/src/Illuminate/Testing/Fluent/Concerns/Has.php index 979b9afa3625..e1575d606cc6 100644 --- a/src/Illuminate/Testing/Fluent/Concerns/Has.php +++ b/src/Illuminate/Testing/Fluent/Concerns/Has.php @@ -85,7 +85,7 @@ public function has($key, $length = null, Closure $callback = null): self /** * Assert that all of the given props exist. * - * @param array|string $key + * @param array|string $key * @return $this */ public function hasAll($key): self @@ -106,7 +106,7 @@ public function hasAll($key): self /** * Assert that none of the given props exist. * - * @param array|string $key + * @param array|string $key * @return $this */ public function missingAll($key): self diff --git a/src/Illuminate/Testing/Fluent/Concerns/Matching.php b/src/Illuminate/Testing/Fluent/Concerns/Matching.php index a2d82c06f2a4..e1b3cb82a4cb 100644 --- a/src/Illuminate/Testing/Fluent/Concerns/Matching.php +++ b/src/Illuminate/Testing/Fluent/Concerns/Matching.php @@ -66,7 +66,7 @@ public function whereAll(array $bindings): self * Asserts that the property is of the expected type. * * @param string $key - * @param string|array $expected + * @param string|array $expected * @return $this */ public function whereType(string $key, $expected): self @@ -106,8 +106,8 @@ public function whereAllType(array $bindings): self /** * Asserts that the property contains the expected values. * - * @param string $key - * @param array|string $expected + * @param string $key + * @param array|string $expected * * @return $this */ diff --git a/src/Illuminate/Testing/TestResponse.php b/src/Illuminate/Testing/TestResponse.php index 2a0b909b2b58..b19f9e2c8577 100644 --- a/src/Illuminate/Testing/TestResponse.php +++ b/src/Illuminate/Testing/TestResponse.php @@ -192,10 +192,10 @@ protected function statusMessageWithDetails($expected, $actual) } if ($this->baseResponse->headers->get('Content-Type') === 'application/json') { - $json = $this->json(); + $testJson = new AssertableJsonString($this->getContent()); - if (isset($json['errors'])) { - return $this->statusMessageWithErrors($expected, $actual, $json); + if (isset($testJson['errors'])) { + return $this->statusMessageWithErrors($expected, $actual, $testJson->json()); } } @@ -228,7 +228,7 @@ protected function statusMessageWithException($expected, $actual, $exception) * * @param string|int $expected * @param string|int $actual - * @param array $errors; + * @param array $errors * @return string */ protected function statusMessageWithErrors($expected, $actual, $errors) @@ -1306,6 +1306,7 @@ public function __isset($key) * @param string $offset * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return $this->responseHasView() @@ -1319,6 +1320,7 @@ public function offsetExists($offset) * @param string $offset * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->responseHasView() @@ -1335,6 +1337,7 @@ public function offsetGet($offset) * * @throws \LogicException */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { throw new LogicException('Response data may not be mutated using array access.'); @@ -1348,6 +1351,7 @@ public function offsetSet($offset, $value) * * @throws \LogicException */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { throw new LogicException('Response data may not be mutated using array access.'); diff --git a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php index 8860dcbc97c6..a92a19835b6c 100644 --- a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php @@ -41,6 +41,29 @@ public function validateAccepted($attribute, $value) return $this->validateRequired($attribute, $value) && in_array($value, $acceptable, true); } + /** + * Validate that an attribute was "accepted" when another attribute has a given value. + * + * @param string $attribute + * @param mixed $value + * @param mixed $parameters + * @return bool + */ + public function validateAcceptedIf($attribute, $value, $parameters) + { + $acceptable = ['yes', 'on', '1', 1, true, 'true']; + + $this->requireParameterCount(2, $parameters, 'accepted_if'); + + [$values, $other] = $this->parseDependentRuleParameters($parameters); + + if (in_array($other, $values, is_bool($other) || is_null($other))) { + return $this->validateRequired($attribute, $value) && in_array($value, $acceptable, true); + } + + return true; + } + /** * Validate that an attribute is an active URL. * diff --git a/src/Illuminate/Validation/Rules/Password.php b/src/Illuminate/Validation/Rules/Password.php index bee75a1ad8a2..cf13e90a6a5c 100644 --- a/src/Illuminate/Validation/Rules/Password.php +++ b/src/Illuminate/Validation/Rules/Password.php @@ -162,7 +162,7 @@ public static function sometimes() /** * Set the performing validator. * - * @param \Illuminate\Contracts\Validation\Validator $validator + * @param \Illuminate\Contracts\Validation\Validator $validator * @return $this */ public function setValidator($validator) @@ -188,7 +188,7 @@ public function setData($data) /** * Sets the minimum size of the password. * - * @param int $size + * @param int $size * @return $this */ public static function min($size) diff --git a/src/Illuminate/Validation/Validator.php b/src/Illuminate/Validation/Validator.php index f5f1a8fbf8eb..6fe9a609b87f 100755 --- a/src/Illuminate/Validation/Validator.php +++ b/src/Illuminate/Validation/Validator.php @@ -201,6 +201,7 @@ class Validator implements ValidatorContract */ protected $implicitRules = [ 'Accepted', + 'AcceptedIf', 'Filled', 'Present', 'Required', @@ -231,6 +232,7 @@ class Validator implements ValidatorContract 'Gte', 'Lt', 'Lte', + 'AcceptedIf', 'RequiredIf', 'RequiredUnless', 'RequiredWith', diff --git a/src/Illuminate/View/Compilers/Concerns/CompilesEchos.php b/src/Illuminate/View/Compilers/Concerns/CompilesEchos.php index c8ed7aa59b4e..5924a0ac31fe 100644 --- a/src/Illuminate/View/Compilers/Concerns/CompilesEchos.php +++ b/src/Illuminate/View/Compilers/Concerns/CompilesEchos.php @@ -125,7 +125,7 @@ protected function compileEscapedEchos($value) /** * Add an instance of the blade echo handler to the start of the compiled string. * - * @param string $result + * @param string $result * @return string */ protected function addBladeCompilerVariable($result) @@ -153,7 +153,7 @@ protected function wrapInEchoHandler($value) /** * Apply the echo handler for the value if it exists. * - * @param $value string + * @param string $value * @return string */ public function applyEchoHandler($value) diff --git a/src/Illuminate/View/ComponentAttributeBag.php b/src/Illuminate/View/ComponentAttributeBag.php index 71666a34ac97..c7b1dd04d1b7 100644 --- a/src/Illuminate/View/ComponentAttributeBag.php +++ b/src/Illuminate/View/ComponentAttributeBag.php @@ -322,6 +322,7 @@ public function __invoke(array $attributeDefaults = []) * @param string $offset * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->attributes[$offset]); @@ -333,6 +334,7 @@ public function offsetExists($offset) * @param string $offset * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->get($offset); @@ -345,6 +347,7 @@ public function offsetGet($offset) * @param mixed $value * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { $this->attributes[$offset] = $value; @@ -356,6 +359,7 @@ public function offsetSet($offset, $value) * @param string $offset * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->attributes[$offset]); @@ -366,6 +370,7 @@ public function offsetUnset($offset) * * @return \ArrayIterator */ + #[\ReturnTypeWillChange] public function getIterator() { return new ArrayIterator($this->attributes); diff --git a/src/Illuminate/View/InvokableComponentVariable.php b/src/Illuminate/View/InvokableComponentVariable.php index c678a540c068..b9db6570be51 100644 --- a/src/Illuminate/View/InvokableComponentVariable.php +++ b/src/Illuminate/View/InvokableComponentVariable.php @@ -43,6 +43,7 @@ public function resolveDisplayableValue() * * @return \ArrayIterator */ + #[\ReturnTypeWillChange] public function getIterator() { $result = $this->__invoke(); diff --git a/src/Illuminate/View/View.php b/src/Illuminate/View/View.php index eff64ba87e89..4161494cae77 100755 --- a/src/Illuminate/View/View.php +++ b/src/Illuminate/View/View.php @@ -306,6 +306,7 @@ public function getEngine() * @param string $key * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($key) { return array_key_exists($key, $this->data); @@ -317,6 +318,7 @@ public function offsetExists($key) * @param string $key * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($key) { return $this->data[$key]; @@ -329,6 +331,7 @@ public function offsetGet($key) * @param mixed $value * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($key, $value) { $this->with($key, $value); @@ -340,6 +343,7 @@ public function offsetSet($key, $value) * @param string $key * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($key) { unset($this->data[$key]); diff --git a/tests/Console/Scheduling/FrequencyTest.php b/tests/Console/Scheduling/FrequencyTest.php index fb9a502aa7ca..5a14c37ce2e0 100644 --- a/tests/Console/Scheduling/FrequencyTest.php +++ b/tests/Console/Scheduling/FrequencyTest.php @@ -57,6 +57,11 @@ public function testTwiceDaily() $this->assertSame('0 3,15 * * *', $this->event->twiceDaily(3, 15)->getExpression()); } + public function testTwiceDailyAt() + { + $this->assertSame('5 3,15 * * *', $this->event->twiceDailyAt(3, 15, 5)->getExpression()); + } + public function testWeekly() { $this->assertSame('0 0 * * 0', $this->event->weekly()->getExpression()); diff --git a/tests/Database/DatabaseProcessorTest.php b/tests/Database/DatabaseProcessorTest.php index 2767523d7f7a..4e858cd59853 100755 --- a/tests/Database/DatabaseProcessorTest.php +++ b/tests/Database/DatabaseProcessorTest.php @@ -8,7 +8,6 @@ use Mockery as m; use PDO; use PHPUnit\Framework\TestCase; -use ReturnTypeWillChange; class DatabaseProcessorTest extends TestCase { @@ -39,7 +38,7 @@ public function __construct() // } - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function lastInsertId(string $sequence = null) { // diff --git a/tests/Integration/Database/EloquentModelImmutableDateCastingTest.php b/tests/Integration/Database/EloquentModelImmutableDateCastingTest.php new file mode 100644 index 000000000000..4568c043b473 --- /dev/null +++ b/tests/Integration/Database/EloquentModelImmutableDateCastingTest.php @@ -0,0 +1,76 @@ +increments('id'); + $table->date('date_field')->nullable(); + $table->datetime('datetime_field')->nullable(); + }); + } + + public function testDatesAreImmutableCastable() + { + $model = TestModelImmutable::create([ + 'date_field' => '2019-10-01', + 'datetime_field' => '2019-10-01 10:15:20', + ]); + + $this->assertSame('2019-10-01T00:00:00.000000Z', $model->toArray()['date_field']); + $this->assertSame('2019-10-01T10:15:20.000000Z', $model->toArray()['datetime_field']); + $this->assertInstanceOf(CarbonImmutable::class, $model->date_field); + $this->assertInstanceOf(CarbonImmutable::class, $model->datetime_field); + } + + public function testDatesAreImmutableAndCustomCastable() + { + $model = TestModelCustomImmutable::create([ + 'date_field' => '2019-10-01', + 'datetime_field' => '2019-10-01 10:15:20', + ]); + + $this->assertSame('2019-10', $model->toArray()['date_field']); + $this->assertSame('2019-10 10:15', $model->toArray()['datetime_field']); + $this->assertInstanceOf(CarbonImmutable::class, $model->date_field); + $this->assertInstanceOf(CarbonImmutable::class, $model->datetime_field); + } +} + +class TestModelImmutable extends Model +{ + public $table = 'test_model_immutable'; + public $timestamps = false; + protected $guarded = []; + + public $casts = [ + 'date_field' => 'immutable_date', + 'datetime_field' => 'immutable_datetime', + ]; +} + +class TestModelCustomImmutable extends Model +{ + public $table = 'test_model_immutable'; + public $timestamps = false; + protected $guarded = []; + + public $casts = [ + 'date_field' => 'immutable_date:Y-m', + 'datetime_field' => 'immutable_datetime:Y-m H:i', + ]; +} diff --git a/tests/Integration/Routing/UrlSigningTest.php b/tests/Integration/Routing/UrlSigningTest.php index ca8e7b19e9f0..b19f85dd3eed 100644 --- a/tests/Integration/Routing/UrlSigningTest.php +++ b/tests/Integration/Routing/UrlSigningTest.php @@ -8,6 +8,7 @@ use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\URL; +use InvalidArgumentException; use Orchestra\Testbench\TestCase; /** @@ -31,7 +32,10 @@ public function testSigningUrlWithCustomRouteSlug() return ['slug' => $slug, 'valid' => $request->hasValidSignature() ? 'valid' : 'invalid']; })->name('foo'); - $this->assertIsString($url = URL::signedRoute('foo', ['post' => new RoutableInterfaceStub])); + $model = new RoutableInterfaceStub; + $model->routable = 'routable-slug'; + + $this->assertIsString($url = URL::signedRoute('foo', ['post' => $model])); $this->assertSame('valid', $this->get($url)->original['valid']); $this->assertSame('routable-slug', $this->get($url)->original['slug']); } @@ -50,6 +54,18 @@ public function testTemporarySignedUrls() $this->assertSame('invalid', $this->get($url)->original); } + public function testTemporarySignedUrlsWithExpiresParameter() + { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('reserved'); + + Route::get('/foo/{id}', function (Request $request, $id) { + return $request->hasValidSignature() ? 'valid' : 'invalid'; + })->name('foo'); + + URL::temporarySignedRoute('foo', now()->addMinutes(5), ['id' => 1, 'expires' => 253402300799]); + } + public function testSignedUrlWithUrlWithoutSignatureParameter() { Route::get('/foo/{id}', function (Request $request, $id) { diff --git a/tests/Routing/RoutingUrlGeneratorTest.php b/tests/Routing/RoutingUrlGeneratorTest.php index 676f609b15fa..32b66b4971cf 100755 --- a/tests/Routing/RoutingUrlGeneratorTest.php +++ b/tests/Routing/RoutingUrlGeneratorTest.php @@ -736,6 +736,27 @@ public function testSignedUrlParameterCannotBeNamedSignature() Request::create($url->signedRoute('foo', ['signature' => 'bar'])); } + + public function testSignedUrlParameterCannotBeNamedExpires() + { + $url = new UrlGenerator( + $routes = new RouteCollection, + $request = Request::create('http://www.foo.com/') + ); + $url->setKeyResolver(function () { + return 'secret'; + }); + + $route = new Route(['GET'], 'foo/{expires}', ['as' => 'foo', function () { + // + }]); + $routes->add($route); + + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('reserved'); + + Request::create($url->signedRoute('foo', ['expires' => 253402300799])); + } } class RoutableInterfaceStub implements UrlRoutable diff --git a/tests/Testing/TestResponseTest.php b/tests/Testing/TestResponseTest.php index f22eeda2d21e..b0b9780bb658 100644 --- a/tests/Testing/TestResponseTest.php +++ b/tests/Testing/TestResponseTest.php @@ -599,6 +599,26 @@ public function testAssertStatusShowsJsonErrorsOnUnexpected422() $response->assertStatus($expectedStatusCode); } + public function testAssertStatusWhenJsonIsFalse() + { + $baseResponse = new Response('false', 200, ['Content-Type' => 'application/json']); + + $response = TestResponse::fromBaseResponse($baseResponse); + $response->assertStatus(200); + } + + public function testAssertStatusWhenJsonIsEncoded() + { + $baseResponse = tap(new Response, function ($response) { + $response->header('Content-Type', 'application/json'); + $response->header('Content-Encoding', 'gzip'); + $response->setContent('b"x£½V*.I,)-V▓R╩¤V¬\x05\x00+ü\x059"'); + }); + + $response = TestResponse::fromBaseResponse($baseResponse); + $response->assertStatus(200); + } + public function testAssertHeader() { $this->expectException(AssertionFailedError::class); diff --git a/tests/Validation/ValidationUniqueRuleTest.php b/tests/Validation/ValidationUniqueRuleTest.php index 2aa821c1f69a..cea86c7e11c6 100644 --- a/tests/Validation/ValidationUniqueRuleTest.php +++ b/tests/Validation/ValidationUniqueRuleTest.php @@ -81,6 +81,17 @@ public function testItCorrectlyFormatsAStringVersionOfTheRule() $rule->where('foo', '"bar"'); $this->assertSame('unique:table,NULL,NULL,id,foo,"""bar"""', (string) $rule); } + + public function testItIgnoresSoftDeletes() + { + $rule = new Unique('table'); + $rule->withoutTrashed(); + $this->assertSame('unique:table,NULL,NULL,id,deleted_at,"NULL"', (string) $rule); + + $rule = new Unique('table'); + $rule->withoutTrashed('softdeleted_at'); + $this->assertSame('unique:table,NULL,NULL,id,softdeleted_at,"NULL"', (string) $rule); + } } class EloquentModelStub extends Model diff --git a/tests/Validation/ValidationValidatorTest.php b/tests/Validation/ValidationValidatorTest.php index 876756d97c6c..57668851bc0f 100755 --- a/tests/Validation/ValidationValidatorTest.php +++ b/tests/Validation/ValidationValidatorTest.php @@ -1771,6 +1771,43 @@ public function testValidateAccepted() $this->assertTrue($v->passes()); } + public function testValidateAcceptedIf() + { + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, ['foo' => 'no', 'bar' => 'aaa'], ['foo' => 'accepted_if:bar,aaa']); + $this->assertFalse($v->passes()); + + $v = new Validator($trans, ['foo' => null, 'bar' => 'aaa'], ['foo' => 'accepted_if:bar,aaa']); + $this->assertFalse($v->passes()); + + $v = new Validator($trans, ['foo' => 0, 'bar' => 'aaa'], ['foo' => 'accepted_if:bar,aaa']); + $this->assertFalse($v->passes()); + + $v = new Validator($trans, ['foo' => false, 'bar' => 'aaa'], ['foo' => 'accepted_if:bar,aaa']); + $this->assertFalse($v->passes()); + + $v = new Validator($trans, ['foo' => 'false', 'bar' => 'aaa'], ['foo' => 'accepted_if:bar,aaa']); + $this->assertFalse($v->passes()); + + $v = new Validator($trans, ['foo' => 'yes', 'bar' => 'aaa'], ['foo' => 'accepted_if:bar,aaa']); + $this->assertTrue($v->passes()); + + $v = new Validator($trans, ['foo' => 'on', 'bar' => 'aaa'], ['foo' => 'accepted_if:bar,aaa']); + $this->assertTrue($v->passes()); + + $v = new Validator($trans, ['foo' => '1', 'bar' => 'aaa'], ['foo' => 'accepted_if:bar,aaa']); + $this->assertTrue($v->passes()); + + $v = new Validator($trans, ['foo' => 1, 'bar' => 'aaa'], ['foo' => 'accepted_if:bar,aaa']); + $this->assertTrue($v->passes()); + + $v = new Validator($trans, ['foo' => true, 'bar' => 'aaa'], ['foo' => 'accepted_if:bar,aaa']); + $this->assertTrue($v->passes()); + + $v = new Validator($trans, ['foo' => 'true', 'bar' => 'aaa'], ['foo' => 'accepted_if:bar,aaa']); + $this->assertTrue($v->passes()); + } + public function testValidateEndsWith() { $trans = $this->getIlluminateArrayTranslator();