diff --git a/CHANGELOG-6.x.md b/CHANGELOG-6.x.md index c88ba87c7212..0a43e37ec935 100644 --- a/CHANGELOG-6.x.md +++ b/CHANGELOG-6.x.md @@ -1,6 +1,12 @@ # Release Notes for 6.x -## [Unreleased](https://github.com/laravel/framework/compare/v6.20.22...6.x) +## [Unreleased](https://github.com/laravel/framework/compare/v6.20.23...6.x) + + +## [v6.20.23 (2021-04-13)](https://github.com/laravel/framework/compare/v6.20.22...v6.20.23) + +### Added +- Added strings to the `DetectsLostConnections.php` ([4210258](https://github.com/laravel/framework/commit/42102589bc7f7b8533ee1b815ef0cc18017d4e45)) ## [v6.20.22 (2021-03-31)](https://github.com/laravel/framework/compare/v6.20.21...v6.20.22) diff --git a/CHANGELOG-8.x.md b/CHANGELOG-8.x.md index 5656104410a4..7b9707cef486 100644 --- a/CHANGELOG-8.x.md +++ b/CHANGELOG-8.x.md @@ -1,6 +1,43 @@ # Release Notes for 8.x -## [Unreleased](https://github.com/laravel/framework/compare/v8.36.0...8.x) +## [Unreleased](https://github.com/laravel/framework/compare/v8.37.0...8.x) + + +## [v8.37.0 (2021-04-13)](https://github.com/laravel/framework/compare/v8.36.2...v8.37.0) + +### Added +- Allow to retry jobs by queue name ([#36898](https://github.com/laravel/framework/pull/36898), [f2d9b59](https://github.com/laravel/framework/commit/f2d9b595e51d564c5e1390eb42438c632e0daf36), [c351a30](https://github.com/laravel/framework/commit/c351a309f1a02098f9a7ee24a8a402e9ce06fead)) +- Added strings to the `DetectsLostConnections.php` ([4210258](https://github.com/laravel/framework/commit/42102589bc7f7b8533ee1b815ef0cc18017d4e45)) +- Allow testing of Blade components that return closures ([#36919](https://github.com/laravel/framework/pull/36919)) +- Added anonymous migrations ([#36906](https://github.com/laravel/framework/pull/36906)) +- Added `Session\Store::missing()` method ([#36937](https://github.com/laravel/framework/pull/36937)) +- Handle concurrent asynchronous requests in the HTTP client ([#36948](https://github.com/laravel/framework/pull/36948), [245a712](https://github.com/laravel/framework/commit/245a7125076e52da7ce55b494c1c01f0f28df55d)) +- Added tinyText data type to Blueprint and to available database grammars ([#36949](https://github.com/laravel/framework/pull/36949)) +- Added a method to remove a resolved view engine ([#36955](https://github.com/laravel/framework/pull/36955)) +- Added `Illuminate\Database\Eloquent\Model::getAttributesForInsert()` protected method ([9a9f59f](https://github.com/laravel/framework/commit/9a9f59fcc6e7b93465ce9848b52a473477dff64a), [314bf87](https://github.com/laravel/framework/commit/314bf875ba5d37c056ccea5148181fcb0517f596)) + +### Fixed +- Fixed clone() on EloquentBuilder ([#36924](https://github.com/laravel/framework/pull/36924)) + +### Changed +- `Model::delete()` throw LogicException not Exception ([#36914](https://github.com/laravel/framework/pull/36914)) +- Make pagination linkCollection() method public ([#36959](https://github.com/laravel/framework/pull/36959)) + + +## [v8.36.2 (2021-04-07)](https://github.com/laravel/framework/compare/v8.36.1...v8.36.2) + +### Revert +- Revert blade changes ([#36902](https://github.com/laravel/framework/pull/36902)) + + +## [v8.36.1 (2021-04-07)](https://github.com/laravel/framework/compare/v8.36.0...v8.36.1) + +### Fixed +- Fixed escaping within quoted strings in blade ([#36893](https://github.com/laravel/framework/pull/36893)) + +### Changed +- Call transaction callbacks after updating the transaction level ([#36890](https://github.com/laravel/framework/pull/36890), [#36892](https://github.com/laravel/framework/pull/36892)) +- Support maxExceptions option on queued listeners ([#36891](https://github.com/laravel/framework/pull/36891)) ## [v8.36.0 (2021-04-06)](https://github.com/laravel/framework/compare/v8.35.1...v8.36.0) diff --git a/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php b/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php index 15695e114e6f..2b486becd363 100644 --- a/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php +++ b/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php @@ -160,4 +160,15 @@ public function getPusher() { return $this->pusher; } + + /** + * Set the Pusher SDK instance. + * + * @param \Pusher\Pusher $pusher + * @return void + */ + public function setPusher($pusher) + { + $this->pusher = $pusher; + } } diff --git a/src/Illuminate/Bus/Batch.php b/src/Illuminate/Bus/Batch.php index cac16e1e9f51..58c453d872da 100644 --- a/src/Illuminate/Bus/Batch.php +++ b/src/Illuminate/Bus/Batch.php @@ -368,7 +368,7 @@ public function hasCatchCallbacks() } /** - * Determine if the batch has "then" callbacks. + * Determine if the batch has "finally" callbacks. * * @return bool */ diff --git a/src/Illuminate/Collections/Traits/EnumeratesValues.php b/src/Illuminate/Collections/Traits/EnumeratesValues.php index 865d0047cdd5..bdeb7fde8a48 100644 --- a/src/Illuminate/Collections/Traits/EnumeratesValues.php +++ b/src/Illuminate/Collections/Traits/EnumeratesValues.php @@ -730,7 +730,7 @@ public function tap(callable $callback) * Reduce the collection to a single value. * * @param callable $callback - * @param mixed $initial + * @param mixed $initial * @return mixed */ public function reduce(callable $callback, $initial = null) @@ -748,7 +748,7 @@ public function reduce(callable $callback, $initial = null) * Reduce an associative collection to a single value. * * @param callable $callback - * @param mixed $initial + * @param mixed $initial * @return mixed */ public function reduceWithKeys(callable $callback, $initial = null) diff --git a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php index 7d660905e393..af89e47e0a28 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php +++ b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php @@ -695,7 +695,7 @@ public function setAttribute($key, $value) { // First we will check for the presence of a mutator for the set operation // which simply lets the developers tweak the attribute as it is set on - // the model, such as "json_encoding" an listing of data for storage. + // this model, such as "json_encoding" a listing of data for storage. if ($this->hasSetMutator($key)) { return $this->setMutatedAttributeValue($key, $value); } diff --git a/src/Illuminate/Database/Eloquent/Concerns/HidesAttributes.php b/src/Illuminate/Database/Eloquent/Concerns/HidesAttributes.php index 7f6ebfdbc55f..065d48a8d0ff 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/HidesAttributes.php +++ b/src/Illuminate/Database/Eloquent/Concerns/HidesAttributes.php @@ -94,9 +94,7 @@ public function makeVisible($attributes) */ public function makeVisibleIf($condition, $attributes) { - $condition = $condition instanceof Closure ? $condition($this) : $condition; - - return $condition ? $this->makeVisible($attributes) : $this; + return value($condition, $this) ? $this->makeVisible($attributes) : $this; } /** @@ -123,8 +121,6 @@ public function makeHidden($attributes) */ public function makeHiddenIf($condition, $attributes) { - $condition = $condition instanceof Closure ? $condition($this) : $condition; - - return value($condition) ? $this->makeHidden($attributes) : $this; + return value($condition, $this) ? $this->makeHidden($attributes) : $this; } } diff --git a/src/Illuminate/Database/Eloquent/SoftDeletes.php b/src/Illuminate/Database/Eloquent/SoftDeletes.php index 3f7a00e0090d..f9739698000a 100644 --- a/src/Illuminate/Database/Eloquent/SoftDeletes.php +++ b/src/Illuminate/Database/Eloquent/SoftDeletes.php @@ -3,9 +3,10 @@ namespace Illuminate\Database\Eloquent; /** - * @method static static|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder withTrashed() + * @method static static|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder withTrashed(bool $withTrashed = true) * @method static static|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder onlyTrashed() * @method static static|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder withoutTrashed() + * @method static static|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder restore() */ trait SoftDeletes { diff --git a/src/Illuminate/Database/Events/MigrationEvent.php b/src/Illuminate/Database/Events/MigrationEvent.php index 53b91a56b372..157303d2e2b5 100644 --- a/src/Illuminate/Database/Events/MigrationEvent.php +++ b/src/Illuminate/Database/Events/MigrationEvent.php @@ -8,7 +8,7 @@ abstract class MigrationEvent implements MigrationEventContract { /** - * An migration instance. + * A migration instance. * * @var \Illuminate\Database\Migrations\Migration */ diff --git a/src/Illuminate/Database/Migrations/Migrator.php b/src/Illuminate/Database/Migrations/Migrator.php index 35b4bb92e92a..c204e1764314 100755 --- a/src/Illuminate/Database/Migrations/Migrator.php +++ b/src/Illuminate/Database/Migrations/Migrator.php @@ -470,7 +470,7 @@ protected function resolvePath(string $path) { $class = $this->getMigrationClass($this->getMigrationName($path)); - if (class_exists($class)) { + if (class_exists($class) && realpath($path) == (new ReflectionClass($class))->getFileName()) { return new $class; } diff --git a/src/Illuminate/Database/Schema/Grammars/Grammar.php b/src/Illuminate/Database/Schema/Grammars/Grammar.php index 18071b2fbb12..2ca54eecf504 100755 --- a/src/Illuminate/Database/Schema/Grammars/Grammar.php +++ b/src/Illuminate/Database/Schema/Grammars/Grammar.php @@ -31,7 +31,7 @@ abstract class Grammar extends BaseGrammar /** * Compile a create database command. * - * @param string $name + * @param string $name * @param \Illuminate\Database\Connection $connection * @return string */ @@ -43,7 +43,7 @@ public function compileCreateDatabase($name, $connection) /** * Compile a drop database if exists command. * - * @param string $name + * @param string $name * @return string */ public function compileDropDatabaseIfExists($name) diff --git a/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php b/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php index 37df3337b040..b6e4e3568d8e 100755 --- a/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php +++ b/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php @@ -29,7 +29,7 @@ class MySqlGrammar extends Grammar /** * Compile a create database command. * - * @param string $name + * @param string $name * @param \Illuminate\Database\Connection $connection * @return string */ @@ -46,7 +46,7 @@ public function compileCreateDatabase($name, $connection) /** * Compile a drop database if exists command. * - * @param string $name + * @param string $name * @return string */ public function compileDropDatabaseIfExists($name) diff --git a/src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php b/src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php index fb7005b09df3..133da288f19d 100755 --- a/src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php +++ b/src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php @@ -38,7 +38,7 @@ class PostgresGrammar extends Grammar /** * Compile a create database command. * - * @param string $name + * @param string $name * @param \Illuminate\Database\Connection $connection * @return string */ @@ -54,7 +54,7 @@ public function compileCreateDatabase($name, $connection) /** * Compile a drop database if exists command. * - * @param string $name + * @param string $name * @return string */ public function compileDropDatabaseIfExists($name) diff --git a/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php b/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php index b147628ec2f3..bc6d6d43102e 100755 --- a/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php +++ b/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php @@ -31,7 +31,7 @@ class SqlServerGrammar extends Grammar /** * Compile a create database command. * - * @param string $name + * @param string $name * @param \Illuminate\Database\Connection $connection * @return string */ @@ -46,7 +46,7 @@ public function compileCreateDatabase($name, $connection) /** * Compile a drop database if exists command. * - * @param string $name + * @param string $name * @return string */ public function compileDropDatabaseIfExists($name) diff --git a/src/Illuminate/Database/Schema/MySqlBuilder.php b/src/Illuminate/Database/Schema/MySqlBuilder.php index b7cff5568d1b..699b41d5f227 100755 --- a/src/Illuminate/Database/Schema/MySqlBuilder.php +++ b/src/Illuminate/Database/Schema/MySqlBuilder.php @@ -7,7 +7,7 @@ class MySqlBuilder extends Builder /** * Create a database in the schema. * - * @param string $name + * @param string $name * @return bool */ public function createDatabase($name) @@ -20,7 +20,7 @@ public function createDatabase($name) /** * Drop a database from the schema if the database exists. * - * @param string $name + * @param string $name * @return bool */ public function dropDatabaseIfExists($name) diff --git a/src/Illuminate/Database/Schema/PostgresBuilder.php b/src/Illuminate/Database/Schema/PostgresBuilder.php index 82702a802691..ce1b5770ad5a 100755 --- a/src/Illuminate/Database/Schema/PostgresBuilder.php +++ b/src/Illuminate/Database/Schema/PostgresBuilder.php @@ -7,7 +7,7 @@ class PostgresBuilder extends Builder /** * Create a database in the schema. * - * @param string $name + * @param string $name * @return bool */ public function createDatabase($name) @@ -20,7 +20,7 @@ public function createDatabase($name) /** * Drop a database from the schema if the database exists. * - * @param string $name + * @param string $name * @return bool */ public function dropDatabaseIfExists($name) diff --git a/src/Illuminate/Database/Schema/SQLiteBuilder.php b/src/Illuminate/Database/Schema/SQLiteBuilder.php index 6a1dbae23ec6..3bc1275c6e04 100644 --- a/src/Illuminate/Database/Schema/SQLiteBuilder.php +++ b/src/Illuminate/Database/Schema/SQLiteBuilder.php @@ -9,7 +9,7 @@ class SQLiteBuilder extends Builder /** * Create a database in the schema. * - * @param string $name + * @param string $name * @return bool */ public function createDatabase($name) @@ -20,7 +20,7 @@ public function createDatabase($name) /** * Drop a database from the schema if the database exists. * - * @param string $name + * @param string $name * @return bool */ public function dropDatabaseIfExists($name) diff --git a/src/Illuminate/Database/Schema/SqlServerBuilder.php b/src/Illuminate/Database/Schema/SqlServerBuilder.php index 223abd44ed1c..93da1cb86fad 100644 --- a/src/Illuminate/Database/Schema/SqlServerBuilder.php +++ b/src/Illuminate/Database/Schema/SqlServerBuilder.php @@ -7,7 +7,7 @@ class SqlServerBuilder extends Builder /** * Create a database in the schema. * - * @param string $name + * @param string $name * @return bool */ public function createDatabase($name) @@ -20,7 +20,7 @@ public function createDatabase($name) /** * Drop a database from the schema if the database exists. * - * @param string $name + * @param string $name * @return bool */ public function dropDatabaseIfExists($name) diff --git a/src/Illuminate/Foundation/Application.php b/src/Illuminate/Foundation/Application.php index b9a9eecbbca9..c8df0b9d3236 100755 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -33,7 +33,7 @@ class Application extends Container implements ApplicationContract, CachesConfig * * @var string */ - const VERSION = '8.37.0'; + const VERSION = '8.38.0'; /** * The base path for the Laravel installation. diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithAuthentication.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithAuthentication.php index 404a8bfb628d..9e8c0f5870b6 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithAuthentication.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithAuthentication.php @@ -10,30 +10,30 @@ trait InteractsWithAuthentication * Set the currently logged in user for the application. * * @param \Illuminate\Contracts\Auth\Authenticatable $user - * @param string|null $driver + * @param string|null $guard * @return $this */ - public function actingAs(UserContract $user, $driver = null) + public function actingAs(UserContract $user, $guard = null) { - return $this->be($user, $driver); + return $this->be($user, $guard); } /** * Set the currently logged in user for the application. * * @param \Illuminate\Contracts\Auth\Authenticatable $user - * @param string|null $driver + * @param string|null $guard * @return $this */ - public function be(UserContract $user, $driver = null) + public function be(UserContract $user, $guard = null) { if (isset($user->wasRecentlyCreated) && $user->wasRecentlyCreated) { $user->wasRecentlyCreated = false; } - $this->app['auth']->guard($driver)->setUser($user); + $this->app['auth']->guard($guard)->setUser($user); - $this->app['auth']->shouldUse($driver); + $this->app['auth']->shouldUse($guard); return $this; } diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithViews.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithViews.php index faa6c64a367e..574effe21260 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithViews.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithViews.php @@ -2,10 +2,8 @@ namespace Illuminate\Foundation\Testing\Concerns; -use Closure; use Illuminate\Support\Facades\View as ViewFacade; use Illuminate\Support\MessageBag; -use Illuminate\Support\Str; use Illuminate\Support\ViewErrorBag; use Illuminate\Testing\TestView; use Illuminate\View\View; @@ -39,11 +37,13 @@ protected function blade(string $template, array $data = []) ViewFacade::addLocation(sys_get_temp_dir()); } - $tempFile = tempnam($tempDirectory, 'laravel-blade').'.blade.php'; + $tempFileInfo = pathinfo(tempnam($tempDirectory, 'laravel-blade')); + + $tempFile = $tempFileInfo['dirname'].'/'.$tempFileInfo['filename'].'.blade.php'; file_put_contents($tempFile, $template); - return new TestView(view(Str::before(basename($tempFile), '.blade.php'), $data)); + return new TestView(view($tempFileInfo['filename'], $data)); } /** @@ -57,11 +57,7 @@ protected function component(string $componentClass, array $data = []) { $component = $this->app->make($componentClass, $data); - $view = $component->resolveView(); - - if ($view instanceof Closure) { - $view = $view($data); - } + $view = value($component->resolveView(), $data); return $view instanceof View ? new TestView($view->with($component->data())) diff --git a/src/Illuminate/Foundation/helpers.php b/src/Illuminate/Foundation/helpers.php index 7aa2228e187c..5f5a71168701 100644 --- a/src/Illuminate/Foundation/helpers.php +++ b/src/Illuminate/Foundation/helpers.php @@ -659,7 +659,7 @@ function rescue(callable $callback, $rescue = null, $report = true) report($e); } - return $rescue instanceof Closure ? $rescue($e) : $rescue; + return value($rescue, $e); } } } diff --git a/src/Illuminate/Http/Client/Factory.php b/src/Illuminate/Http/Client/Factory.php index 6fc069d390b7..200f7f5e7a90 100644 --- a/src/Illuminate/Http/Client/Factory.php +++ b/src/Illuminate/Http/Client/Factory.php @@ -35,7 +35,7 @@ * @method \Illuminate\Http\Client\PendingRequest dump() * @method \Illuminate\Http\Client\PendingRequest dd() * @method \Illuminate\Http\Client\PendingRequest async() - * @method \Illuminate\Http\Client\Pool pool() + * @method \Illuminate\Http\Client\Pool pool(callable $callback) * @method \Illuminate\Http\Client\Response delete(string $url, array $data = []) * @method \Illuminate\Http\Client\Response get(string $url, array $query = []) * @method \Illuminate\Http\Client\Response head(string $url, array $query = []) diff --git a/src/Illuminate/Http/Client/PendingRequest.php b/src/Illuminate/Http/Client/PendingRequest.php index f0790c5a54a3..f7723243e917 100644 --- a/src/Illuminate/Http/Client/PendingRequest.php +++ b/src/Illuminate/Http/Client/PendingRequest.php @@ -642,6 +642,8 @@ public function send(string $method, string $url, array $options = []) $options[$this->bodyFormat], $this->pendingFiles ); } + } else { + $options[$this->bodyFormat] = $this->pendingBody; } [$this->pendingBody, $this->pendingFiles] = [null, []]; diff --git a/src/Illuminate/Http/Client/Pool.php b/src/Illuminate/Http/Client/Pool.php index 15002b28e92e..23ae75e9b158 100644 --- a/src/Illuminate/Http/Client/Pool.php +++ b/src/Illuminate/Http/Client/Pool.php @@ -2,6 +2,9 @@ namespace Illuminate\Http\Client; +/** + * @mixin \Illuminate\Http\Client\Factory + */ class Pool { /** diff --git a/src/Illuminate/Http/Concerns/InteractsWithFlashData.php b/src/Illuminate/Http/Concerns/InteractsWithFlashData.php index 25e11a95438f..6682e5427273 100644 --- a/src/Illuminate/Http/Concerns/InteractsWithFlashData.php +++ b/src/Illuminate/Http/Concerns/InteractsWithFlashData.php @@ -9,7 +9,7 @@ trait InteractsWithFlashData * * @param string|null $key * @param string|array|null $default - * @return string|array + * @return string|array|null */ public function old($key = null, $default = null) { diff --git a/src/Illuminate/Notifications/Messages/SimpleMessage.php b/src/Illuminate/Notifications/Messages/SimpleMessage.php index f90b26e9986b..e532aa4bf4ae 100644 --- a/src/Illuminate/Notifications/Messages/SimpleMessage.php +++ b/src/Illuminate/Notifications/Messages/SimpleMessage.php @@ -192,7 +192,7 @@ protected function formatLine($line) return implode(' ', array_map('trim', $line)); } - return trim(implode(' ', array_map('trim', preg_split('/\\r\\n|\\r|\\n/', $line)))); + return trim(implode(' ', array_map('trim', preg_split('/\\r\\n|\\r|\\n/', $line ?? '')))); } /** @@ -239,7 +239,7 @@ public function toArray() 'outroLines' => $this->outroLines, 'actionText' => $this->actionText, 'actionUrl' => $this->actionUrl, - 'displayableActionUrl' => str_replace(['mailto:', 'tel:'], '', $this->actionUrl), + 'displayableActionUrl' => str_replace(['mailto:', 'tel:'], '', $this->actionUrl ?? ''), ]; } } diff --git a/src/Illuminate/Queue/Queue.php b/src/Illuminate/Queue/Queue.php index 52bd32e924e8..e6285008fc98 100755 --- a/src/Illuminate/Queue/Queue.php +++ b/src/Illuminate/Queue/Queue.php @@ -157,10 +157,10 @@ protected function createObjectPayload($job, $queue) : serialize(clone $job); return array_merge($payload, [ - 'data' => [ + 'data' => array_merge($payload['data'], [ 'commandName' => get_class($job), 'command' => $command, - ], + ]), ]); } diff --git a/src/Illuminate/Support/Facades/Http.php b/src/Illuminate/Support/Facades/Http.php index 51763b6caef0..8d48496c03f7 100644 --- a/src/Illuminate/Support/Facades/Http.php +++ b/src/Illuminate/Support/Facades/Http.php @@ -33,7 +33,7 @@ * @method static \Illuminate\Http\Client\PendingRequest dump() * @method static \Illuminate\Http\Client\PendingRequest dd() * @method static \Illuminate\Http\Client\PendingRequest async() - * @method static \Illuminate\Http\Client\Pool pool() + * @method static \Illuminate\Http\Client\Pool pool(callable $callback) * @method static \Illuminate\Http\Client\Response delete(string $url, array $data = []) * @method static \Illuminate\Http\Client\Response get(string $url, array $query = []) * @method static \Illuminate\Http\Client\Response head(string $url, array $query = []) diff --git a/src/Illuminate/Support/Facades/Schema.php b/src/Illuminate/Support/Facades/Schema.php index 8c5b32c21ead..896e1764cd83 100755 --- a/src/Illuminate/Support/Facades/Schema.php +++ b/src/Illuminate/Support/Facades/Schema.php @@ -18,6 +18,7 @@ * @method static bool hasTable(string $table) * @method static void defaultStringLength(int $length) * @method static void registerCustomDoctrineType(string $class, string $name, string $type) + * @method static array getColumnListing(string $table) * * @see \Illuminate\Database\Schema\Builder */ diff --git a/src/Illuminate/Support/Str.php b/src/Illuminate/Support/Str.php index db2656483e70..37e3fd082956 100644 --- a/src/Illuminate/Support/Str.php +++ b/src/Illuminate/Support/Str.php @@ -573,9 +573,9 @@ public static function replaceLast($search, $replace, $subject) /** * Remove any occurrence of the given string in the subject. * - * @param string|array $search - * @param string $subject - * @param bool $caseSensitive + * @param string|array $search + * @param string $subject + * @param bool $caseSensitive * @return string */ public static function remove($search, $subject, $caseSensitive = true) @@ -766,6 +766,17 @@ public static function ucfirst($string) return static::upper(static::substr($string, 0, 1)).static::substr($string, 1); } + /** + * Get the number of words a string contains. + * + * @param string $string + * @return int + */ + public static function wordCount($string) + { + return str_word_count($string); + } + /** * Generate a UUID (version 4). * diff --git a/src/Illuminate/Support/Stringable.php b/src/Illuminate/Support/Stringable.php index 5085a3b876c1..290914bc32a1 100644 --- a/src/Illuminate/Support/Stringable.php +++ b/src/Illuminate/Support/Stringable.php @@ -426,7 +426,7 @@ public function parseCallback($default = null) /** * Call the given callback and return a new string. * - * @param callable $callback + * @param callable $callback * @return static */ public function pipe(callable $callback) @@ -470,8 +470,8 @@ public function prepend(...$values) /** * Remove any occurrence of the given string in the subject. * - * @param string|array $search - * @param bool $caseSensitive + * @param string|array $search + * @param bool $caseSensitive * @return static */ public function remove($search, $caseSensitive = true) @@ -756,6 +756,16 @@ public function words($words = 100, $end = '...') return new static(Str::words($this->value, $words, $end)); } + /** + * Get the number of words a string contains. + * + * @return int + */ + public function wordCount() + { + return str_word_count($this->value); + } + /** * Dump the string. * diff --git a/src/Illuminate/Support/helpers.php b/src/Illuminate/Support/helpers.php index 85486f6bbc55..f54c233ab561 100755 --- a/src/Illuminate/Support/helpers.php +++ b/src/Illuminate/Support/helpers.php @@ -272,7 +272,7 @@ function tap($value, $callback = null) * * @param mixed $condition * @param \Throwable|string $exception - * @param array ...$parameters + * @param mixed ...$parameters * @return mixed * * @throws \Throwable @@ -297,20 +297,14 @@ function throw_if($condition, $exception = 'RuntimeException', ...$parameters) * * @param mixed $condition * @param \Throwable|string $exception - * @param array ...$parameters + * @param mixed ...$parameters * @return mixed * * @throws \Throwable */ function throw_unless($condition, $exception = 'RuntimeException', ...$parameters) { - if (! $condition) { - if (is_string($exception) && class_exists($exception)) { - $exception = new $exception(...$parameters); - } - - throw is_string($exception) ? new RuntimeException($exception) : $exception; - } + throw_if(! $condition, $exception, ...$parameters); return $condition; } diff --git a/src/Illuminate/Testing/Concerns/TestDatabases.php b/src/Illuminate/Testing/Concerns/TestDatabases.php index 9e3198a0f166..f554f6d26be4 100644 --- a/src/Illuminate/Testing/Concerns/TestDatabases.php +++ b/src/Illuminate/Testing/Concerns/TestDatabases.php @@ -107,8 +107,8 @@ protected function ensureSchemaIsUpToDate() /** * Runs the given callable using the given database. * - * @param string $database - * @param callable $callable + * @param string $database + * @param callable $callable * @return void */ protected function usingDatabase($database, $callable) @@ -126,7 +126,7 @@ protected function usingDatabase($database, $callable) /** * Apply the given callback when tests are not using in memory database. * - * @param callable $callback + * @param callable $callback * @return void */ protected function whenNotUsingInMemoryDatabase($callback) @@ -141,7 +141,7 @@ protected function whenNotUsingInMemoryDatabase($callback) /** * Switch to the given database. * - * @param string $database + * @param string $database * @return void */ protected function switchToDatabase($database) diff --git a/src/Illuminate/Testing/ParallelRunner.php b/src/Illuminate/Testing/ParallelRunner.php index 802fe22ca30d..4d226a5643b7 100644 --- a/src/Illuminate/Testing/ParallelRunner.php +++ b/src/Illuminate/Testing/ParallelRunner.php @@ -106,7 +106,7 @@ public function getExitCode(): int /** * Apply the given callback for each process. * - * @param callable $callback + * @param callable $callback * @return void */ protected function forEachProcess($callback) diff --git a/src/Illuminate/Testing/ParallelTesting.php b/src/Illuminate/Testing/ParallelTesting.php index 11ebcfa89ed6..a3f7fc7e203a 100644 --- a/src/Illuminate/Testing/ParallelTesting.php +++ b/src/Illuminate/Testing/ParallelTesting.php @@ -238,7 +238,7 @@ public function callTearDownTestCaseCallbacks($testCase) } /** - * Get an parallel testing option. + * Get a parallel testing option. * * @param string $option * @return mixed @@ -269,7 +269,7 @@ public function token() /** * Apply the callback if tests are running in parallel. * - * @param callable $callback + * @param callable $callback * @return void */ protected function whenRunningInParallel($callback) diff --git a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php index 8f88aa2cd8df..454ddb70f1db 100644 --- a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php @@ -1554,7 +1554,7 @@ public function parseDependentRuleParameters($parameters) $values = array_slice($parameters, 1); - if (is_bool($other)) { + if ($this->shouldConvertToBoolean($parameters[0]) || is_bool($other)) { $values = $this->convertValuesToBoolean($values); } elseif (is_null($other)) { $values = $this->convertValuesToNull($values); @@ -1563,6 +1563,17 @@ public function parseDependentRuleParameters($parameters) return [$values, $other]; } + /** + * Check if parameter should be converted to boolean. + * + * @param string $parameter + * @return bool + */ + protected function shouldConvertToBoolean($parameter) + { + return in_array('boolean', Arr::get($this->rules, $parameter, [])); + } + /** * Convert the given values to boolean if they are string "true" / "false". * diff --git a/src/Illuminate/Validation/Validator.php b/src/Illuminate/Validation/Validator.php index 2311b7357718..70b8c17a6f3d 100755 --- a/src/Illuminate/Validation/Validator.php +++ b/src/Illuminate/Validation/Validator.php @@ -13,6 +13,7 @@ use Illuminate\Support\MessageBag; use Illuminate\Support\Str; use RuntimeException; +use stdClass; use Symfony\Component\HttpFoundation\File\UploadedFile; class Validator implements ValidatorContract @@ -503,7 +504,7 @@ public function validated() $results = []; - $missingValue = Str::random(10); + $missingValue = new stdClass; foreach (array_keys($this->getRules()) as $key) { $value = data_get($this->getData(), $key, $missingValue); diff --git a/src/Illuminate/View/Concerns/ManagesComponents.php b/src/Illuminate/View/Concerns/ManagesComponents.php index 81b2bdf6cbaf..273e8b496328 100644 --- a/src/Illuminate/View/Concerns/ManagesComponents.php +++ b/src/Illuminate/View/Concerns/ManagesComponents.php @@ -2,7 +2,6 @@ namespace Illuminate\View\Concerns; -use Closure; use Illuminate\Contracts\Support\Htmlable; use Illuminate\Contracts\View\View; use Illuminate\Support\Arr; @@ -84,9 +83,7 @@ public function renderComponent() $data = $this->componentData(); - if ($view instanceof Closure) { - $view = $view($data); - } + $view = value($view, $data); if ($view instanceof View) { return $view->with($data)->render(); @@ -151,8 +148,7 @@ public function endSlot() $this->slotStack[$this->currentComponent()] ); - $this->slots[$this->currentComponent()] - [$currentSlot] = new HtmlString(trim(ob_get_clean())); + $this->slots[$this->currentComponent()][$currentSlot] = new HtmlString(trim(ob_get_clean())); } /** diff --git a/tests/Foundation/Testing/Concerns/InteractsWithViewsTest.php b/tests/Foundation/Testing/Concerns/InteractsWithViewsTest.php new file mode 100644 index 000000000000..42bc6c2ec28d --- /dev/null +++ b/tests/Foundation/Testing/Concerns/InteractsWithViewsTest.php @@ -0,0 +1,18 @@ +blade('@if(true)test @endif'); + + $this->assertEquals('test ', $string); + } +} diff --git a/tests/Http/HttpClientTest.php b/tests/Http/HttpClientTest.php index 84709fa3ba66..a6637134708a 100644 --- a/tests/Http/HttpClientTest.php +++ b/tests/Http/HttpClientTest.php @@ -76,6 +76,21 @@ public function testResponseCanBeReturnedAsCollection() $this->assertEquals(collect(), $response->collect('missing_key')); } + public function testSendRequestBody() + { + $body = '{"test":"phpunit"}'; + + $fakeRequest = function (Request $request) use ($body) { + self::assertSame($body, $request->body()); + + return ['my' => 'response']; + }; + + $this->factory->fake($fakeRequest); + + $this->factory->withBody($body, 'application/json')->send('get', 'http://foo.com/api'); + } + public function testUrlsCanBeStubbedByPath() { $this->factory->fake([ diff --git a/tests/Integration/Migration/MigratorTest.php b/tests/Integration/Migration/MigratorTest.php index 08dd9c97862f..e21a884e4152 100644 --- a/tests/Integration/Migration/MigratorTest.php +++ b/tests/Integration/Migration/MigratorTest.php @@ -76,7 +76,7 @@ public function testPretendMigrate() { $this->expectOutput('CreatePeopleTable: create table "people" ("id" integer not null primary key autoincrement, "name" varchar not null, "email" varchar not null, "password" varchar not null, "remember_token" varchar, "created_at" datetime, "updated_at" datetime)'); $this->expectOutput('CreatePeopleTable: create unique index "people_email_unique" on "people" ("email")'); - $this->expectOutput('2015_10_04_000000_modify_people_table: alter table "people" add column "first_name" varchar'); + $this->expectOutput('ModifyPeopleTable: alter table "people" add column "first_name" varchar'); $this->expectOutput('2016_10_04_000000_modify_people_table: alter table "people" add column "last_name" varchar'); $this->subject->run([__DIR__.'/fixtures'], ['pretend' => true]); diff --git a/tests/Integration/Migration/fixtures/2015_10_04_000000_modify_people_table.php b/tests/Integration/Migration/fixtures/2015_10_04_000000_modify_people_table.php index 88ac706cd12a..c6a827583761 100644 --- a/tests/Integration/Migration/fixtures/2015_10_04_000000_modify_people_table.php +++ b/tests/Integration/Migration/fixtures/2015_10_04_000000_modify_people_table.php @@ -4,7 +4,8 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class extends Migration { +class ModifyPeopleTable extends Migration +{ /** * Run the migrations. * @@ -28,4 +29,4 @@ public function down() $table->dropColumn('first_name'); }); } -}; +} diff --git a/tests/Queue/QueueBeanstalkdQueueTest.php b/tests/Queue/QueueBeanstalkdQueueTest.php index 534a16141381..87a779f638ef 100755 --- a/tests/Queue/QueueBeanstalkdQueueTest.php +++ b/tests/Queue/QueueBeanstalkdQueueTest.php @@ -112,9 +112,9 @@ public function testDeleteProperlyRemoveJobsOffBeanstalkd() } /** - * @param string $default - * @param int $timeToRun - * @param int $blockFor + * @param string $default + * @param int $timeToRun + * @param int $blockFor */ private function setQueue($default, $timeToRun, $blockFor = 0) { diff --git a/tests/Queue/QueueSyncQueueTest.php b/tests/Queue/QueueSyncQueueTest.php index 2064add943a8..d4d07bbb2d6a 100755 --- a/tests/Queue/QueueSyncQueueTest.php +++ b/tests/Queue/QueueSyncQueueTest.php @@ -6,8 +6,11 @@ use Illuminate\Container\Container; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Queue\QueueableEntity; +use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\Jobs\SyncJob; use Illuminate\Queue\SyncQueue; +use LogicException; use Mockery as m; use PHPUnit\Framework\TestCase; @@ -54,6 +57,26 @@ public function testFailedJobGetsHandledWhenAnExceptionIsThrown() Container::setInstance(); } + + public function testCreatesPayloadObject() + { + $sync = new SyncQueue; + $container = new Container; + $container->bind(\Illuminate\Contracts\Events\Dispatcher::class, \Illuminate\Events\Dispatcher::class); + $container->bind(\Illuminate\Contracts\Bus\Dispatcher::class, \Illuminate\Bus\Dispatcher::class); + $container->bind(\Illuminate\Contracts\Container\Container::class, \Illuminate\Container\Container::class); + $sync->setContainer($container); + + SyncQueue::createPayloadUsing(function ($connection, $queue, $payload) { + return ['data' => ['extra' => 'extraValue']]; + }); + + try { + $sync->push(new SyncQueueJob()); + } catch (LogicException $e) { + $this->assertEquals('extraValue', $e->getMessage()); + } + } } class SyncQueueTestEntity implements QueueableEntity @@ -94,3 +117,20 @@ public function failed() $_SERVER['__sync.failed'] = true; } } + +class SyncQueueJob implements ShouldQueue +{ + use InteractsWithQueue; + + public function handle() + { + throw new LogicException($this->getValueFromJob('extra')); + } + + public function getValueFromJob($key) + { + $payload = $this->job->payload(); + + return $payload['data'][$key] ?? null; + } +} diff --git a/tests/Support/SupportStrTest.php b/tests/Support/SupportStrTest.php index f120708968dc..d8c744b37c70 100755 --- a/tests/Support/SupportStrTest.php +++ b/tests/Support/SupportStrTest.php @@ -494,6 +494,12 @@ public function testPadRight() $this->assertSame('Alien ', Str::padRight('Alien', 10)); } + public function testWordCount() + { + $this->assertEquals(2, Str::wordCount('Hello, world!')); + $this->assertEquals(10, Str::wordCount('Hi, this is my first contribution to the Laravel framework.')); + } + public function validUuidList() { return [ diff --git a/tests/Support/SupportStringableTest.php b/tests/Support/SupportStringableTest.php index be88413d750a..70916a0458b9 100644 --- a/tests/Support/SupportStringableTest.php +++ b/tests/Support/SupportStringableTest.php @@ -608,4 +608,10 @@ public function testRepeat() $this->assertSame('aaaaa', (string) $this->stringable('a')->repeat(5)); $this->assertSame('', (string) $this->stringable('')->repeat(5)); } + + public function testWordCount() + { + $this->assertEquals(2, $this->stringable('Hello, world!')->wordCount()); + $this->assertEquals(10, $this->stringable('Hi, this is my first contribution to the Laravel framework.')->wordCount()); + } } diff --git a/tests/Validation/ValidationValidatorTest.php b/tests/Validation/ValidationValidatorTest.php index d1d3d424dd59..7d592324e47c 100755 --- a/tests/Validation/ValidationValidatorTest.php +++ b/tests/Validation/ValidationValidatorTest.php @@ -1130,6 +1130,17 @@ public function testRequiredIf() $v = new Validator($trans, ['first' => 'dayle', 'last' => ''], ['last' => 'RequiredIf:first,taylor,dayle']); $this->assertFalse($v->passes()); $this->assertSame('The last field is required when first is dayle.', $v->messages()->first('last')); + + $trans = $this->getIlluminateArrayTranslator(); + $trans->addLines(['validation.required_if' => 'The :attribute field is required when :other is :value.'], 'en'); + $v = new Validator($trans, ['foo' => 0], [ + 'foo' => 'required|boolean', + 'bar' => 'required_if:foo,true', + 'baz' => 'required_if:foo,false', + ]); + $this->assertTrue($v->fails()); + $this->assertCount(1, $v->messages()); + $this->assertSame('The baz field is required when foo is 0.', $v->messages()->first('baz')); } public function testRequiredUnless() @@ -1998,9 +2009,9 @@ public function testValidateMax() } /** - * @param mixed $input - * @param mixed $allowed - * @param bool $passes + * @param mixed $input + * @param mixed $allowed + * @param bool $passes * * @dataProvider multipleOfDataProvider */ pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy