language
stringclasses
1 value
owner
stringlengths
2
15
repo
stringlengths
2
21
sha
stringlengths
45
45
message
stringlengths
7
36.3k
path
stringlengths
1
199
patch
stringlengths
15
102k
is_multipart
bool
2 classes
Other
laravel
framework
0dd1a50f041f227e21c42f0bd92f91af9121eab8.json
add missing docblocks (#30898)
src/Illuminate/Cache/DynamoDbStore.php
@@ -443,6 +443,8 @@ public function forget($key) * Remove all items from the cache. * * @return bool + * + * @throws \RuntimeException */ public function flush() {
true
Other
laravel
framework
0dd1a50f041f227e21c42f0bd92f91af9121eab8.json
add missing docblocks (#30898)
src/Illuminate/Database/Connectors/ConnectionFactory.php
@@ -194,6 +194,8 @@ protected function createPdoResolverWithHosts(array $config) * * @param array $config * @return array + * + * @throws \InvalidArgumentException */ protected function parseHosts(array $config) {
true
Other
laravel
framework
0dd1a50f041f227e21c42f0bd92f91af9121eab8.json
add missing docblocks (#30898)
src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php
@@ -22,6 +22,8 @@ trait QueriesRelationships * @param string $boolean * @param \Closure|null $callback * @return \Illuminate\Database\Eloquent\Builder|static + * + * @throws \RuntimeException */ public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', Closure $callback = null) {
true
Other
laravel
framework
0dd1a50f041f227e21c42f0bd92f91af9121eab8.json
add missing docblocks (#30898)
src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php
@@ -393,6 +393,8 @@ public function orWherePivot($column, $operator = null, $value = null) * @param string|array $column * @param mixed $value * @return $this + * + * @throws \InvalidArgumentException */ public function withPivotValue($column, $value = null) {
true
Other
laravel
framework
0dd1a50f041f227e21c42f0bd92f91af9121eab8.json
add missing docblocks (#30898)
src/Illuminate/Database/Query/Builder.php
@@ -1472,6 +1472,8 @@ public function addWhereExistsQuery(self $query, $boolean = 'and', $not = false) * @param array $values * @param string $boolean * @return $this + * + * @throws \InvalidArgumentException */ public function whereRowValues($columns, $operator, $values, $boolean = 'and') { @@ -2729,6 +2731,8 @@ public function updateOrInsert(array $attributes, array $values = []) * @param float|int $amount * @param array $extra * @return int + * + * @throws \InvalidArgumentException */ public function increment($column, $amount = 1, array $extra = []) { @@ -2750,6 +2754,8 @@ public function increment($column, $amount = 1, array $extra = []) * @param float|int $amount * @param array $extra * @return int + * + * @throws \InvalidArgumentException */ public function decrement($column, $amount = 1, array $extra = []) {
true
Other
laravel
framework
0dd1a50f041f227e21c42f0bd92f91af9121eab8.json
add missing docblocks (#30898)
src/Illuminate/Database/Query/Grammars/Grammar.php
@@ -878,6 +878,8 @@ public function compileInsert(Builder $query, array $values) * @param \Illuminate\Database\Query\Builder $query * @param array $values * @return string + * + * @throws \RuntimeException */ public function compileInsertOrIgnore(Builder $query, array $values) { @@ -1144,6 +1146,8 @@ public function wrap($value, $prefixAlias = false) * * @param string $value * @return string + * + * @throws \RuntimeException */ protected function wrapJsonSelector($value) {
true
Other
laravel
framework
0dd1a50f041f227e21c42f0bd92f91af9121eab8.json
add missing docblocks (#30898)
src/Illuminate/Database/Schema/Builder.php
@@ -319,6 +319,7 @@ protected function createBlueprint($table, Closure $callback = null) * @return void * * @throws \Doctrine\DBAL\DBALException + * @throws \RuntimeException */ public function registerCustomDoctrineType($class, $name, $type) {
true
Other
laravel
framework
0dd1a50f041f227e21c42f0bd92f91af9121eab8.json
add missing docblocks (#30898)
src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php
@@ -340,6 +340,8 @@ public function compileRename(Blueprint $blueprint, Fluent $command) * @param \Illuminate\Support\Fluent $command * @param \Illuminate\Database\Connection $connection * @return array + * + * @throws \RuntimeException */ public function compileRenameIndex(Blueprint $blueprint, Fluent $command, Connection $connection) {
true
Other
laravel
framework
0dd1a50f041f227e21c42f0bd92f91af9121eab8.json
add missing docblocks (#30898)
src/Illuminate/Foundation/Application.php
@@ -1005,6 +1005,7 @@ public function isDownForMaintenance() * @return void * * @throws \Symfony\Component\HttpKernel\Exception\HttpException + * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException */ public function abort($code, $message = '', array $headers = []) {
true
Other
laravel
framework
0dd1a50f041f227e21c42f0bd92f91af9121eab8.json
add missing docblocks (#30898)
src/Illuminate/Foundation/Http/Kernel.php
@@ -293,6 +293,8 @@ public function pushMiddleware($middleware) * @param string $group * @param string $middleware * @return $this + * + * @throws \InvalidArgumentException */ public function prependMiddlewareToGroup($group, $middleware) { @@ -315,6 +317,8 @@ public function prependMiddlewareToGroup($group, $middleware) * @param string $group * @param string $middleware * @return $this + * + * @throws \InvalidArgumentException */ public function appendMiddlewareToGroup($group, $middleware) {
true
Other
laravel
framework
0dd1a50f041f227e21c42f0bd92f91af9121eab8.json
add missing docblocks (#30898)
src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php
@@ -42,6 +42,7 @@ public function __construct(Application $app) * @return mixed * * @throws \Symfony\Component\HttpKernel\Exception\HttpException + * @throws \Illuminate\Foundation\Http\Exceptions\MaintenanceModeException */ public function handle($request, Closure $next) {
true
Other
laravel
framework
0dd1a50f041f227e21c42f0bd92f91af9121eab8.json
add missing docblocks (#30898)
src/Illuminate/Foundation/Testing/Concerns/InteractsWithExceptionHandling.php
@@ -110,7 +110,8 @@ public function shouldReport(Exception $e) * @param \Exception $e * @return mixed * - * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException|\Exception + * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * @throws \Exception */ public function render($request, Exception $e) {
true
Other
laravel
framework
0dd1a50f041f227e21c42f0bd92f91af9121eab8.json
add missing docblocks (#30898)
src/Illuminate/Foundation/Testing/TestResponse.php
@@ -1240,6 +1240,8 @@ public function offsetGet($offset) * @param string $offset * @param mixed $value * @return void + * + * @throws \LogicException */ public function offsetSet($offset, $value) { @@ -1251,6 +1253,8 @@ public function offsetSet($offset, $value) * * @param string $offset * @return void + * + * @throws \LogicException */ public function offsetUnset($offset) {
true
Other
laravel
framework
0dd1a50f041f227e21c42f0bd92f91af9121eab8.json
add missing docblocks (#30898)
src/Illuminate/Hashing/Argon2IdHasher.php
@@ -13,6 +13,8 @@ class Argon2IdHasher extends ArgonHasher * @param string $hashedValue * @param array $options * @return bool + * + * @throws \RuntimeException */ public function check($value, $hashedValue, array $options = []) {
true
Other
laravel
framework
0dd1a50f041f227e21c42f0bd92f91af9121eab8.json
add missing docblocks (#30898)
src/Illuminate/Hashing/ArgonHasher.php
@@ -90,6 +90,8 @@ protected function algorithm() * @param string $hashedValue * @param array $options * @return bool + * + * @throws \RuntimeException */ public function check($value, $hashedValue, array $options = []) {
true
Other
laravel
framework
0dd1a50f041f227e21c42f0bd92f91af9121eab8.json
add missing docblocks (#30898)
src/Illuminate/Queue/Failed/DynamoDbFailedJobProvider.php
@@ -165,6 +165,8 @@ public function forget($id) * Flush all of the failed jobs from storage. * * @return void + * + * @throws \Exception */ public function flush() {
true
Other
laravel
framework
0dd1a50f041f227e21c42f0bd92f91af9121eab8.json
add missing docblocks (#30898)
src/Illuminate/Routing/RouteAction.php
@@ -54,6 +54,8 @@ public static function parse($uri, $action) * * @param string $uri * @return array + * + * @throws \LogicException */ protected static function missingAction($uri) {
true
Other
laravel
framework
0dd1a50f041f227e21c42f0bd92f91af9121eab8.json
add missing docblocks (#30898)
src/Illuminate/Support/ConfigurationUrlParser.php
@@ -124,6 +124,8 @@ protected function getQueryOptions($url) * * @param string $url * @return array + * + * @throws \InvalidArgumentException */ protected function parseUrl($url) {
true
Other
laravel
framework
0dd1a50f041f227e21c42f0bd92f91af9121eab8.json
add missing docblocks (#30898)
src/Illuminate/Support/Testing/Fakes/QueueFake.php
@@ -367,6 +367,8 @@ public function setConnectionName($name) * @param string $method * @param array $parameters * @return mixed + * + * @throws \BadMethodCallException */ public function __call($method, $parameters) {
true
Other
laravel
framework
0dd1a50f041f227e21c42f0bd92f91af9121eab8.json
add missing docblocks (#30898)
src/Illuminate/View/Compilers/BladeCompiler.php
@@ -510,6 +510,8 @@ public function include($path, $alias = null) * @param string $name * @param callable $handler * @return void + * + * @throws \InvalidArgumentException */ public function directive($name, callable $handler) {
true
Other
laravel
framework
f32662a0f6bce153c8c714a155ae2ea3504a4c59.json
Add withoutMix and withMix test helpers (#30900)
src/Illuminate/Foundation/Testing/Concerns/InteractsWithContainer.php
@@ -3,10 +3,18 @@ namespace Illuminate\Foundation\Testing\Concerns; use Closure; +use Illuminate\Foundation\Mix; use Mockery; trait InteractsWithContainer { + /** + * The original Laravel Mix handler. + * + * @var \Illuminate\Foundation\Mix|null + */ + protected $originalMix; + /** * Register an instance of an object in the container. * @@ -68,4 +76,36 @@ protected function spy($abstract, Closure $mock = null) { return $this->instance($abstract, Mockery::spy(...array_filter(func_get_args()))); } + + /** + * Register an empty handler for Laravel Mix in the container. + * + * @return $this + */ + protected function withoutMix() + { + if ($this->originalMix == null) { + $this->originalMix = app(Mix::class); + } + + $this->swap(Mix::class, function () { + return ''; + }); + + return $this; + } + + /** + * Register an empty handler for Laravel Mix in the container. + * + * @return $this + */ + protected function withMix() + { + if ($this->originalMix) { + $this->app->instance(Mix::class, $this->originalMix); + } + + return $this; + } }
true
Other
laravel
framework
f32662a0f6bce153c8c714a155ae2ea3504a4c59.json
Add withoutMix and withMix test helpers (#30900)
tests/Foundation/Testing/Concerns/InteractsWithContainerTest.php
@@ -0,0 +1,29 @@ +<?php + +namespace Illuminate\Tests\Foundation\Testing\Concerns; + +use Illuminate\Foundation\Mix; +use Orchestra\Testbench\TestCase; + +class InteractsWithContainerTest extends TestCase +{ + public function testWithoutMixBindsEmptyHandlerAndReturnsInstance() + { + $instance = $this->withoutMix(); + + $this->assertSame('', mix('path/to/asset.png')); + $this->assertSame($this, $instance); + } + + public function testWithMixRestoresOriginalHandlerAndReturnsInstance() + { + $handler = new \stdClass(); + $this->app->instance(Mix::class, $handler); + + $this->withoutMix(); + $instance = $this->withMix(); + + $this->assertSame($handler, resolve(Mix::class)); + $this->assertSame($this, $instance); + } +}
true
Other
laravel
framework
b0dfbdf78ac7178c13384e91e650697e0d6f3397.json
Apply fixes from StyleCI (#30888)
src/Illuminate/Foundation/Http/Kernel.php
@@ -10,7 +10,6 @@ use Illuminate\Routing\Router; use Illuminate\Support\Facades\Facade; use InvalidArgumentException; -use Symfony\Component\Debug\Exception\FatalThrowableError; use Throwable; class Kernel implements KernelContract
false
Other
laravel
framework
a7523c5bcfaa0c48dbca0d16e8134de7d89c61c3.json
add marker interface for authentication middleware
src/Illuminate/Auth/Middleware/Authenticate.php
@@ -5,8 +5,9 @@ use Closure; use Illuminate\Auth\AuthenticationException; use Illuminate\Contracts\Auth\Factory as Auth; +use Illuminate\Contracts\Auth\Middleware\AuthenticatesRequests; -class Authenticate +class Authenticate implements AuthenticatesRequests { /** * The authentication factory instance.
true
Other
laravel
framework
a7523c5bcfaa0c48dbca0d16e8134de7d89c61c3.json
add marker interface for authentication middleware
src/Illuminate/Contracts/Auth/Middleware/AuthenticatesRequests.php
@@ -0,0 +1,8 @@ +<?php + +namespace Illuminate\Contracts\Auth\Middleware; + +interface AuthenticatesRequests +{ + // +}
true
Other
laravel
framework
a7523c5bcfaa0c48dbca0d16e8134de7d89c61c3.json
add marker interface for authentication middleware
src/Illuminate/Foundation/Http/Kernel.php
@@ -72,7 +72,8 @@ class Kernel implements KernelContract protected $middlewarePriority = [ \Illuminate\Session\Middleware\StartSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, - \Illuminate\Auth\Middleware\Authenticate::class, + \Illuminate\Contracts\Auth\Middleware\AuthenticatesRequests::class, + \Illuminate\Routing\Middleware\ThrottleRequests::class, \Illuminate\Session\Middleware\AuthenticateSession::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, \Illuminate\Auth\Middleware\Authorize::class,
true
Other
laravel
framework
6f33feba124d4a7ff2af4f3ed18583d67fb68f7c.json
add some methods for manipulating middleware
src/Illuminate/Foundation/Http/Kernel.php
@@ -10,6 +10,7 @@ use Illuminate\Routing\Pipeline; use Illuminate\Routing\Router; use Illuminate\Support\Facades\Facade; +use InvalidArgumentException; use Symfony\Component\Debug\Exception\FatalThrowableError; use Throwable; @@ -294,6 +295,76 @@ public function pushMiddleware($middleware) return $this; } + /** + * Prepend the given middleware to the given middleware group. + * + * @param string $group + * @param string $middleware + * @return $this + */ + public function prependMiddlewareToGroup($group, $middleware) + { + if (! isset($this->middlewareGroups[$group])) { + throw new InvalidArgumentException("The [{$group}] middleware group has not been defined."); + } + + if (array_search($middleware, $this->middlewareGroups[$group]) === false) { + array_unshift($this->middlewareGroups[$group], $middleware); + } + + return $this; + } + + /** + * Append the given middleware to the given middleware group. + * + * @param string $group + * @param string $middleware + * @return $this + */ + public function appendMiddlewareToGroup($group, $middleware) + { + if (! isset($this->middlewareGroups[$group])) { + throw new InvalidArgumentException("The [{$group}] middleware group has not been defined."); + } + + if (array_search($middleware, $this->middlewareGroups[$group]) === false) { + $this->middlewareGroups[$group][] = $middleware; + } + + return $this; + } + + /** + * Prepend the given middleware to the middleware priority list. + * + * @param string $middleware + * @return $this + */ + public function prependToMiddlewarePriority($middleware) + { + if (! in_array($middleware, $this->middlewarePriority)) { + array_unshift($this->middlewarePriority, $middleware); + } + + return $this; + } + + /** + * Append the given middleware to the middleware priority list. + * + * @param string $middleware + * @return $this + */ + public function appendToMiddlewarePriority($middleware) + { + if (! in_array($middleware, $this->middlewarePriority)) { + $this->middlewarePriority[] = $middleware; + } + + return $this; + } + /** * Get the bootstrap classes for the application. *
false
Other
laravel
framework
67b814b8350dbe0ca1682ca185f2ecef7dd67656.json
remove factory "types" (#30867) - simplify the global helper `factory()`. since the signature is no longer dynamic, we can be a little more explicit in our parameters - remove `defineAs`, `createAs`, `makeAs`, and `rawOf` which were methods specific to factory "types" - update the `FactoryBuilder` to remove references to the "name". we do keep one reference to the name "default" because that is how the callbacks are registered.
src/Illuminate/Database/Eloquent/Factory.php
@@ -68,30 +68,16 @@ public static function construct(Faker $faker, $pathToFactories = null) return (new static($faker))->load($pathToFactories); } - /** - * Define a class with a given short-name. - * - * @param string $class - * @param string $name - * @param callable $attributes - * @return $this - */ - public function defineAs($class, $name, callable $attributes) - { - return $this->define($class, $attributes, $name); - } - /** * Define a class with a given set of attributes. * * @param string $class * @param callable $attributes - * @param string $name * @return $this */ - public function define($class, callable $attributes, $name = 'default') + public function define($class, callable $attributes) { - $this->definitions[$class][$name] = $attributes; + $this->definitions[$class] = $attributes; return $this; } @@ -179,19 +165,6 @@ public function create($class, array $attributes = []) return $this->of($class)->create($attributes); } - /** - * Create an instance of the given model and type and persist it to the database. - * - * @param string $class - * @param string $name - * @param array $attributes - * @return mixed - */ - public function createAs($class, $name, array $attributes = []) - { - return $this->of($class, $name)->create($attributes); - } - /** * Create an instance of the given model. * @@ -204,58 +177,30 @@ public function make($class, array $attributes = []) return $this->of($class)->make($attributes); } - /** - * Create an instance of the given model and type. - * - * @param string $class - * @param string $name - * @param array $attributes - * @return mixed - */ - public function makeAs($class, $name, array $attributes = []) - { - return $this->of($class, $name)->make($attributes); - } - - /** - * Get the raw attribute array for a given named model. - * - * @param string $class - * @param string $name - * @param array $attributes - * @return array - */ - public function rawOf($class, $name, array $attributes = []) - { - return $this->raw($class, $attributes, $name); - } - /** * Get the raw attribute array for a given model. * * @param string $class * @param array $attributes - * @param string $name * @return array */ - public function raw($class, array $attributes = [], $name = 'default') + public function raw($class, array $attributes = []) { return array_merge( - call_user_func($this->definitions[$class][$name], $this->faker), $attributes + call_user_func($this->definitions[$class], $this->faker), $attributes ); } /** * Create a builder for the given model. * * @param string $class - * @param string $name * @return \Illuminate\Database\Eloquent\FactoryBuilder */ - public function of($class, $name = 'default') + public function of($class) { return new FactoryBuilder( - $class, $name, $this->definitions, $this->states, + $class, $this->definitions, $this->states, $this->afterMaking, $this->afterCreating, $this->faker ); }
true
Other
laravel
framework
67b814b8350dbe0ca1682ca185f2ecef7dd67656.json
remove factory "types" (#30867) - simplify the global helper `factory()`. since the signature is no longer dynamic, we can be a little more explicit in our parameters - remove `defineAs`, `createAs`, `makeAs`, and `rawOf` which were methods specific to factory "types" - update the `FactoryBuilder` to remove references to the "name". we do keep one reference to the name "default" because that is how the callbacks are registered.
src/Illuminate/Database/Eloquent/FactoryBuilder.php
@@ -24,13 +24,6 @@ class FactoryBuilder */ protected $class; - /** - * The name of the model being built. - * - * @var string - */ - protected $name = 'default'; - /** * The database connection on which the model instance should be persisted. * @@ -84,18 +77,16 @@ class FactoryBuilder * Create an new builder instance. * * @param string $class - * @param string $name * @param array $definitions * @param array $states * @param array $afterMaking * @param array $afterCreating * @param \Faker\Generator $faker * @return void */ - public function __construct($class, $name, array $definitions, array $states, + public function __construct($class, array $definitions, array $states, array $afterMaking, array $afterCreating, Faker $faker) { - $this->name = $name; $this->class = $class; $this->faker = $faker; $this->states = $states; @@ -265,12 +256,12 @@ public function raw(array $attributes = []) */ protected function getRawAttributes(array $attributes = []) { - if (! isset($this->definitions[$this->class][$this->name])) { - throw new InvalidArgumentException("Unable to locate factory with name [{$this->name}] [{$this->class}]."); + if (! isset($this->definitions[$this->class])) { + throw new InvalidArgumentException("Unable to locate factory for [{$this->class}]."); } $definition = call_user_func( - $this->definitions[$this->class][$this->name], + $this->definitions[$this->class], $this->faker, $attributes ); @@ -403,7 +394,7 @@ public function callAfterCreating($models) */ protected function callAfter(array $afterCallbacks, $models) { - $states = array_merge([$this->name], $this->activeStates); + $states = array_merge(['default'], $this->activeStates); $models->each(function ($model) use ($states, $afterCallbacks) { foreach ($states as $state) {
true
Other
laravel
framework
67b814b8350dbe0ca1682ca185f2ecef7dd67656.json
remove factory "types" (#30867) - simplify the global helper `factory()`. since the signature is no longer dynamic, we can be a little more explicit in our parameters - remove `defineAs`, `createAs`, `makeAs`, and `rawOf` which were methods specific to factory "types" - update the `FactoryBuilder` to remove references to the "name". we do keep one reference to the name "default" because that is how the callbacks are registered.
src/Illuminate/Foundation/helpers.php
@@ -484,24 +484,21 @@ function event(...$args) if (! function_exists('factory')) { /** - * Create a model factory builder for a given class, name, and amount. + * Create a model factory builder for a given class and amount. * - * @param dynamic class|class,name|class,amount|class,name,amount + * @param string $class + * @param int $amount * @return \Illuminate\Database\Eloquent\FactoryBuilder */ - function factory() + function factory($class, $amount = null) { $factory = app(EloquentFactory::class); - $arguments = func_get_args(); - - if (isset($arguments[1]) && is_string($arguments[1])) { - return $factory->of($arguments[0], $arguments[1])->times($arguments[2] ?? null); - } elseif (isset($arguments[1])) { - return $factory->of($arguments[0])->times($arguments[1]); + if (isset($amount) && is_int($amount)) { + return $factory->of($class)->times($amount); } - return $factory->of($arguments[0]); + return $factory->of($class); } }
true
Other
laravel
framework
4c30d2c1119576773e8864d5cb9bd4a2c23a267a.json
Enable seed to all option (#30874)
src/Illuminate/Foundation/Console/ModelMakeCommand.php
@@ -42,6 +42,7 @@ public function handle() if ($this->option('all')) { $this->input->setOption('factory', true); + $this->input->setOption('seed', true); $this->input->setOption('migration', true); $this->input->setOption('controller', true); $this->input->setOption('resource', true);
false
Other
laravel
framework
3c8ccc2fb4ec03572076e6df71608f6bbb7d71e1.json
Prevent duplicate attachments This will prevent users from adding duplicate attachments. This bug surfaced when rendering a mailable for logging or storage before sending.
src/Illuminate/Mail/Mailable.php
@@ -747,7 +747,10 @@ public function with($key, $value = null) */ public function attach($file, array $options = []) { - $this->attachments[] = compact('file', 'options'); + $this->attachments = collect($this->attachments) + ->push(compact('file', 'options')) + ->unique('file') + ->all(); return $this; } @@ -776,12 +779,14 @@ public function attachFromStorage($path, $name = null, array $options = []) */ public function attachFromStorageDisk($disk, $path, $name = null, array $options = []) { - $this->diskAttachments[] = [ + $this->diskAttachments = collect($this->diskAttachments)->push([ 'disk' => $disk, 'path' => $path, 'name' => $name ?? basename($path), 'options' => $options, - ]; + ])->unique(function ($file) { + return $file['disk'].$file['path']; + })->all(); return $this; } @@ -796,7 +801,10 @@ public function attachFromStorageDisk($disk, $path, $name = null, array $options */ public function attachData($data, $name, array $options = []) { - $this->rawAttachments[] = compact('data', 'name', 'options'); + $this->rawAttachments = collect($this->rawAttachments) + ->push(compact('data', 'name', 'options')) + ->unique('data') + ->all(); return $this; }
false
Other
laravel
framework
db794ceea6734cc90286e04a8a2a48e5b4cd4130.json
Update helpers.php (#30838)
src/Illuminate/Foundation/helpers.php
@@ -715,7 +715,7 @@ function rescue(callable $callback, $rescue = null, $report = true) report($e); } - return value($rescue); + return $rescue instanceof Closure ? $rescue($e) : $rescue; } } }
false
Other
laravel
framework
fa4a36788d0f34b22a67a65589e22c34deb3fae1.json
fix non-eloquent model validation
src/Illuminate/Validation/Concerns/ValidatesAttributes.php
@@ -818,12 +818,9 @@ public function parseTable($table) { [$connection, $table] = Str::contains($table, '.') ? explode('.', $table, 2) : [null, $table]; - if (Str::contains($table, '\\') && class_exists($table)) { + if (Str::contains($table, '\\') && class_exists($table) && is_a($table, Model::class, true)) { $model = new $table; - - if ($model instanceof Model) { - $table = $model->getTable(); - } + $table = $model->getTable(); } return [$connection, $table];
true
Other
laravel
framework
fa4a36788d0f34b22a67a65589e22c34deb3fae1.json
fix non-eloquent model validation
tests/Validation/ValidationValidatorTest.php
@@ -4307,6 +4307,10 @@ public function testParsingTablesFromModels() $this->assertEquals(null, $explicit_no_connection[0]); $this->assertEquals('explicits', $explicit_no_connection[1]); + $noneloquent_no_connection = $v->parseTable(NonEloquentModel::class); + $this->assertEquals(null, $noneloquent_no_connection[0]); + $this->assertEquals(NonEloquentModel::class, $noneloquent_no_connection[1]); + $raw_no_connection = $v->parseTable('table'); $this->assertEquals(null, $raw_no_connection[0]); $this->assertEquals('table', $raw_no_connection[1]); @@ -4319,6 +4323,10 @@ public function testParsingTablesFromModels() $this->assertEquals('connection', $explicit_connection[0]); $this->assertEquals('explicits', $explicit_connection[1]); + $noneloquent_connection = $v->parseTable('connection.'.NonEloquentModel::class); + $this->assertEquals('connection', $noneloquent_connection[0]); + $this->assertEquals(NonEloquentModel::class, $noneloquent_connection[1]); + $raw_connection = $v->parseTable('connection.table'); $this->assertEquals('connection', $raw_connection[0]); $this->assertEquals('table', $raw_connection[1]); @@ -4799,3 +4807,6 @@ class ExplicitTableModel extends Model protected $guarded = []; public $timestamps = false; } + +class NonEloquentModel +{}
true
Other
laravel
framework
9693cedbfc1fb0e38a8e688375e5b2ce5273b75f.json
add more quotes
src/Illuminate/Foundation/Inspiring.php
@@ -40,6 +40,10 @@ public static function quote() 'I begin to speak only when I am certain what I will say is not better left unsaid - Cato the Younger', 'Order your soul. Reduce your wants. - Augustine', 'Be present above all else. - Naval Ravikant', + 'Let all your things have their places; let each part of your business have its time. - Benjamin Franklin', + 'If you do not have a consistent goal in life, you can not live it in a consistent way. - Marcus Aurelius', + 'No surplus words or unnecessary actions. - Marcus Aurelius', + 'People find pleasure in different ways. I find it in keeping my mind clear. - Marcus Aurelius', ])->random(); } }
false
Other
laravel
framework
f5c3c60d52eccd77274e586fc4c775374e826b0f.json
Implement ArrayAccess on TestResponse (#30817) When building / testing and JSON API, I like to sometimes interact with the raw JSON payload returned in the response. Normally you would have to access this via $response->original['foo']; however, with this change I implement ArrayAccess on both JsonResponse and TestResponse in order to be able to proxy directly into the response JSON without going through the original property.
src/Illuminate/Foundation/Testing/TestResponse.php
@@ -2,6 +2,7 @@ namespace Illuminate\Foundation\Testing; +use ArrayAccess; use Closure; use Illuminate\Contracts\View\View; use Illuminate\Database\Eloquent\Model; @@ -12,12 +13,13 @@ use Illuminate\Support\Str; use Illuminate\Support\Traits\Macroable; use Illuminate\Support\Traits\Tappable; +use LogicException; use Symfony\Component\HttpFoundation\StreamedResponse; /** * @mixin \Illuminate\Http\Response */ -class TestResponse +class TestResponse implements ArrayAccess { use Tappable, Macroable { __call as macroCall; @@ -1210,6 +1212,51 @@ public function __isset($key) return isset($this->baseResponse->{$key}); } + /** + * Determine if the given offset exists. + * + * @param string $offset + * @return bool + */ + public function offsetExists($offset) + { + return isset($this->json()[$offset]); + } + + /** + * Get the value for a given offset. + * + * @param string $offset + * @return mixed + */ + public function offsetGet($offset) + { + return $this->json()[$offset]; + } + + /** + * Set the value at the given offset. + * + * @param string $offset + * @param mixed $value + * @return void + */ + public function offsetSet($offset, $value) + { + throw new LogicException('Response data may not be mutated using array access.'); + } + + /** + * Unset the value at the given offset. + * + * @param string $offset + * @return void + */ + public function offsetUnset($offset) + { + throw new LogicException('Response data may not be mutated using array access.'); + } + /** * Handle dynamic calls into macros or pass missing methods to the base response. *
false
Other
laravel
framework
454c2b341a2662fb88bfc42cb030d422783e4bab.json
Apply fixes from StyleCI (#30803)
tests/Integration/Broadcasting/BroadcastManagerTest.php
@@ -7,9 +7,7 @@ use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow; use Illuminate\Support\Facades\Broadcast; use Illuminate\Support\Facades\Bus; -use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Queue; -use Illuminate\Support\Str; use Orchestra\Testbench\TestCase; /**
false
Other
laravel
framework
f4b4b8108bb0f5e81e0856697c74aa03cd35b214.json
Handle toJson properly on json resources (#30801) At the moment when you call toJson on a Json resource it skips the `toArray` method and directly calls toJson on the Eloquent model because of the ForwardsCalls trait. This seems unwanted because if you're formatting the resource in a specific way through the toArray method you'd expect it to be honered when calling toJson I believe. toJson isn't documented on the Json Resources documentation but I still believe that this should be honered. This is technically a breaking change so I'm targeting the next release.
src/Illuminate/Database/Eloquent/JsonEncodingException.php
@@ -18,6 +18,20 @@ public static function forModel($model, $message) return new static('Error encoding model ['.get_class($model).'] with ID ['.$model->getKey().'] to JSON: '.$message); } + /** + * Create a new JSON encoding exception for the resource. + * + * @param \Illuminate\Http\Resources\Json\JsonResource $resource + * @param string $message + * @return static + */ + public static function forResource($resource, $message) + { + $model = $resource->resource; + + return new static('Error encoding resource ['.get_class($resource).'] with model ['.get_class($model).'] with ID ['.$model->getKey().'] to JSON: '.$message); + } + /** * Create a new JSON encoding exception for an attribute. *
true
Other
laravel
framework
f4b4b8108bb0f5e81e0856697c74aa03cd35b214.json
Handle toJson properly on json resources (#30801) At the moment when you call toJson on a Json resource it skips the `toArray` method and directly calls toJson on the Eloquent model because of the ForwardsCalls trait. This seems unwanted because if you're formatting the resource in a specific way through the toArray method you'd expect it to be honered when calling toJson I believe. toJson isn't documented on the Json Resources documentation but I still believe that this should be honered. This is technically a breaking change so I'm targeting the next release.
src/Illuminate/Http/Resources/Json/JsonResource.php
@@ -7,6 +7,7 @@ use Illuminate\Contracts\Routing\UrlRoutable; use Illuminate\Contracts\Support\Arrayable; use Illuminate\Contracts\Support\Responsable; +use Illuminate\Database\Eloquent\JsonEncodingException; use Illuminate\Http\Resources\ConditionallyLoadsAttributes; use Illuminate\Http\Resources\DelegatesToResource; use JsonSerializable; @@ -120,6 +121,25 @@ public function toArray($request) : $this->resource->toArray(); } + /** + * Convert the model instance to JSON. + * + * @param int $options + * @return string + * + * @throws \Illuminate\Database\Eloquent\JsonEncodingException + */ + public function toJson($options = 0) + { + $json = json_encode($this->jsonSerialize(), $options); + + if (JSON_ERROR_NONE !== json_last_error()) { + throw JsonEncodingException::forResource($this, json_last_error_msg()); + } + + return $json; + } + /** * Get any additional data that should be returned with the resource array. *
true
Other
laravel
framework
f4b4b8108bb0f5e81e0856697c74aa03cd35b214.json
Handle toJson properly on json resources (#30801) At the moment when you call toJson on a Json resource it skips the `toArray` method and directly calls toJson on the Eloquent model because of the ForwardsCalls trait. This seems unwanted because if you're formatting the resource in a specific way through the toArray method you'd expect it to be honered when calling toJson I believe. toJson isn't documented on the Json Resources documentation but I still believe that this should be honered. This is technically a breaking change so I'm targeting the next release.
tests/Integration/Http/ResourceTest.php
@@ -38,6 +38,7 @@ public function testResourcesMayBeConvertedToJson() return new PostResource(new Post([ 'id' => 5, 'title' => 'Test Title', + 'abstract' => 'Test abstract', ])); }); @@ -55,6 +56,17 @@ public function testResourcesMayBeConvertedToJson() ]); } + public function testResourcesMayBeConvertedToJsonWithToJsonMethod() + { + $resource = new PostResource(new Post([ + 'id' => 5, + 'title' => 'Test Title', + 'abstract' => 'Test abstract', + ])); + + $this->assertEquals('{"id":5,"title":"Test Title","custom":true}', $resource->toJson()); + } + public function testResourcesMayHaveNoWrap() { Route::get('/', function () {
true
Other
laravel
framework
c5c5b75a07af4442c437d8730ad0ecec8a5b97cc.json
Improve ShouldBroadcastNow performance
src/Illuminate/Broadcasting/BroadcastManager.php
@@ -9,6 +9,7 @@ use Illuminate\Broadcasting\Broadcasters\RedisBroadcaster; use Illuminate\Contracts\Broadcasting\Factory as FactoryContract; use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow; +use Illuminate\Contracts\Bus\Dispatcher as BusDispatcherContract; use InvalidArgumentException; use Psr\Log\LoggerInterface; use Pusher\Pusher; @@ -108,10 +109,8 @@ public function event($event = null) */ public function queue($event) { - $connection = $event instanceof ShouldBroadcastNow ? 'sync' : null; - - if (is_null($connection) && isset($event->connection)) { - $connection = $event->connection; + if ($event instanceof ShouldBroadcastNow) { + return $this->app->make(BusDispatcherContract::class)->dispatchNow(new BroadcastEvent(clone $event)); } $queue = null; @@ -124,7 +123,7 @@ public function queue($event) $queue = $event->queue; } - $this->app->make('queue')->connection($connection)->pushOn( + $this->app->make('queue')->connection($event->connection ?? null)->pushOn( $queue, new BroadcastEvent(clone $event) ); }
false
Other
laravel
framework
58d5f788dc47b63bc861417fbf9f7bdfff1b0428.json
Update travis file
.travis.yml
@@ -39,4 +39,5 @@ install: - if [[ $SETUP = 'stable' ]]; then travis_retry composer update --prefer-dist --no-interaction --prefer-stable --no-suggest; fi - if [[ $SETUP = 'lowest' ]]; then travis_retry composer update --prefer-dist --no-interaction --prefer-lowest --prefer-stable --no-suggest; fi -script: vendor/bin/phpunit +script: + - vendor/bin/phpunit
false
Other
laravel
framework
11f410a3439f47efb60f19cf100e719e461fd75b.json
add doc block return
src/Illuminate/Http/Resources/Json/ResourceCollection.php
@@ -54,6 +54,8 @@ public function __construct($resource) /** * Indicate that all current query parameters should be appended to pagination links. + * + * @return $this */ public function preserveQuery() {
false
Other
laravel
framework
7b074c1ac506c1895f85ec77481b55228a122a05.json
Add missing imports. (#30764)
src/Illuminate/Auth/MustVerifyEmail.php
@@ -2,6 +2,8 @@ namespace Illuminate\Auth; +use Illuminate\Auth\Notifications\VerifyEmail; + trait MustVerifyEmail { /** @@ -33,7 +35,7 @@ public function markEmailAsVerified() */ public function sendEmailVerificationNotification() { - $this->notify(new Notifications\VerifyEmail); + $this->notify(new VerifyEmail); } /**
true
Other
laravel
framework
7b074c1ac506c1895f85ec77481b55228a122a05.json
Add missing imports. (#30764)
src/Illuminate/Auth/SessionGuard.php
@@ -2,6 +2,13 @@ namespace Illuminate\Auth; +use Illuminate\Auth\Events\Attempting; +use Illuminate\Auth\Events\Authenticated; +use Illuminate\Auth\Events\CurrentDeviceLogout; +use Illuminate\Auth\Events\Failed; +use Illuminate\Auth\Events\Login; +use Illuminate\Auth\Events\Logout; +use Illuminate\Auth\Events\OtherDeviceLogout; use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; use Illuminate\Contracts\Auth\StatefulGuard; use Illuminate\Contracts\Auth\SupportsBasicAuth; @@ -492,7 +499,7 @@ public function logout() // so any further processing can be done. This allows the developer to be // listening for anytime a user signs out of this application manually. if (isset($this->events)) { - $this->events->dispatch(new Events\Logout($this->name, $user)); + $this->events->dispatch(new Logout($this->name, $user)); } // Once we have fired the logout event we will clear the users out of memory @@ -546,7 +553,7 @@ public function logoutCurrentDevice() // so any further processing can be done. This allows the developer to be // listening for anytime a user signs out of this application manually. if (isset($this->events)) { - $this->events->dispatch(new Events\CurrentDeviceLogout($this->name, $user)); + $this->events->dispatch(new CurrentDeviceLogout($this->name, $user)); } // Once we have fired the logout event we will clear the users out of memory @@ -609,7 +616,7 @@ public function attempting($callback) protected function fireAttemptEvent(array $credentials, $remember = false) { if (isset($this->events)) { - $this->events->dispatch(new Events\Attempting( + $this->events->dispatch(new Attempting( $this->name, $credentials, $remember )); } @@ -625,7 +632,7 @@ protected function fireAttemptEvent(array $credentials, $remember = false) protected function fireLoginEvent($user, $remember = false) { if (isset($this->events)) { - $this->events->dispatch(new Events\Login( + $this->events->dispatch(new Login( $this->name, $user, $remember )); } @@ -640,7 +647,7 @@ protected function fireLoginEvent($user, $remember = false) protected function fireAuthenticatedEvent($user) { if (isset($this->events)) { - $this->events->dispatch(new Events\Authenticated( + $this->events->dispatch(new Authenticated( $this->name, $user )); } @@ -655,7 +662,7 @@ protected function fireAuthenticatedEvent($user) protected function fireOtherDeviceLogoutEvent($user) { if (isset($this->events)) { - $this->events->dispatch(new Events\OtherDeviceLogout( + $this->events->dispatch(new OtherDeviceLogout( $this->name, $user )); } @@ -671,7 +678,7 @@ protected function fireOtherDeviceLogoutEvent($user) protected function fireFailedEvent($user, array $credentials) { if (isset($this->events)) { - $this->events->dispatch(new Events\Failed( + $this->events->dispatch(new Failed( $this->name, $user, $credentials )); }
true
Other
laravel
framework
7b074c1ac506c1895f85ec77481b55228a122a05.json
Add missing imports. (#30764)
src/Illuminate/Console/Application.php
@@ -3,6 +3,9 @@ namespace Illuminate\Console; use Closure; +use Illuminate\Console\Events\ArtisanStarting; +use Illuminate\Console\Events\CommandFinished; +use Illuminate\Console\Events\CommandStarting; use Illuminate\Contracts\Console\Application as ApplicationContract; use Illuminate\Contracts\Container\Container; use Illuminate\Contracts\Events\Dispatcher; @@ -67,7 +70,7 @@ public function __construct(Container $laravel, Dispatcher $events, $version) $this->setAutoExit(false); $this->setCatchExceptions(false); - $this->events->dispatch(new Events\ArtisanStarting($this)); + $this->events->dispatch(new ArtisanStarting($this)); $this->bootstrap(); } @@ -82,15 +85,15 @@ public function run(InputInterface $input = null, OutputInterface $output = null ); $this->events->dispatch( - new Events\CommandStarting( + new CommandStarting( $commandName, $input, $output = $output ?: new ConsoleOutput ) ); $exitCode = parent::run($input, $output); $this->events->dispatch( - new Events\CommandFinished($commandName, $input, $output, $exitCode) + new CommandFinished($commandName, $input, $output, $exitCode) ); return $exitCode;
true
Other
laravel
framework
7b074c1ac506c1895f85ec77481b55228a122a05.json
Add missing imports. (#30764)
src/Illuminate/Container/Util.php
@@ -2,6 +2,8 @@ namespace Illuminate\Container; +use Closure; + class Util { /** @@ -31,6 +33,6 @@ public static function arrayWrap($value) */ public static function unwrapIfClosure($value) { - return $value instanceof \Closure ? $value() : $value; + return $value instanceof Closure ? $value() : $value; } }
true
Other
laravel
framework
7b074c1ac506c1895f85ec77481b55228a122a05.json
Add missing imports. (#30764)
src/Illuminate/Database/Connection.php
@@ -8,6 +8,10 @@ use Exception; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Database\Events\QueryExecuted; +use Illuminate\Database\Events\StatementPrepared; +use Illuminate\Database\Events\TransactionBeginning; +use Illuminate\Database\Events\TransactionCommitted; +use Illuminate\Database\Events\TransactionRolledBack; use Illuminate\Database\Query\Builder as QueryBuilder; use Illuminate\Database\Query\Expression; use Illuminate\Database\Query\Grammars\Grammar as QueryGrammar; @@ -382,7 +386,7 @@ protected function prepared(PDOStatement $statement) { $statement->setFetchMode($this->fetchMode); - $this->event(new Events\StatementPrepared( + $this->event(new StatementPrepared( $this, $statement )); @@ -809,11 +813,11 @@ protected function fireConnectionEvent($event) switch ($event) { case 'beganTransaction': - return $this->events->dispatch(new Events\TransactionBeginning($this)); + return $this->events->dispatch(new TransactionBeginning($this)); case 'committed': - return $this->events->dispatch(new Events\TransactionCommitted($this)); + return $this->events->dispatch(new TransactionCommitted($this)); case 'rollingBack': - return $this->events->dispatch(new Events\TransactionRolledBack($this)); + return $this->events->dispatch(new TransactionRolledBack($this)); } }
true
Other
laravel
framework
7b074c1ac506c1895f85ec77481b55228a122a05.json
Add missing imports. (#30764)
src/Illuminate/Foundation/Application.php
@@ -9,6 +9,7 @@ use Illuminate\Events\EventServiceProvider; use Illuminate\Filesystem\Filesystem; use Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables; +use Illuminate\Foundation\Events\LocaleUpdated; use Illuminate\Http\Request; use Illuminate\Log\LogServiceProvider; use Illuminate\Routing\RoutingServiceProvider; @@ -1125,7 +1126,7 @@ public function setLocale($locale) $this['translator']->setLocale($locale); - $this['events']->dispatch(new Events\LocaleUpdated($locale)); + $this['events']->dispatch(new LocaleUpdated($locale)); } /**
true
Other
laravel
framework
7b074c1ac506c1895f85ec77481b55228a122a05.json
Add missing imports. (#30764)
src/Illuminate/Foundation/Http/Kernel.php
@@ -6,6 +6,7 @@ use Illuminate\Contracts\Debug\ExceptionHandler; use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\Http\Kernel as KernelContract; +use Illuminate\Foundation\Http\Events\RequestHandled; use Illuminate\Routing\Pipeline; use Illuminate\Routing\Router; use Illuminate\Support\Facades\Facade; @@ -125,7 +126,7 @@ public function handle($request) } $this->app['events']->dispatch( - new Events\RequestHandled($request, $response) + new RequestHandled($request, $response) ); return $response;
true
Other
laravel
framework
7b074c1ac506c1895f85ec77481b55228a122a05.json
Add missing imports. (#30764)
src/Illuminate/Http/UploadedFile.php
@@ -5,6 +5,7 @@ use Illuminate\Container\Container; use Illuminate\Contracts\Filesystem\Factory as FilesystemFactory; use Illuminate\Contracts\Filesystem\FileNotFoundException; +use Illuminate\Http\Testing\FileFactory; use Illuminate\Support\Arr; use Illuminate\Support\Traits\Macroable; use Symfony\Component\HttpFoundation\File\UploadedFile as SymfonyUploadedFile; @@ -20,7 +21,7 @@ class UploadedFile extends SymfonyUploadedFile */ public static function fake() { - return new Testing\FileFactory; + return new FileFactory; } /**
true
Other
laravel
framework
7b074c1ac506c1895f85ec77481b55228a122a05.json
Add missing imports. (#30764)
src/Illuminate/Mail/Mailer.php
@@ -10,6 +10,8 @@ use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Support\Htmlable; use Illuminate\Contracts\View\Factory; +use Illuminate\Mail\Events\MessageSending; +use Illuminate\Mail\Events\MessageSent; use Illuminate\Support\HtmlString; use Illuminate\Support\Traits\Macroable; use InvalidArgumentException; @@ -501,7 +503,7 @@ protected function shouldSendMessage($message, $data = []) } return $this->events->until( - new Events\MessageSending($message, $data) + new MessageSending($message, $data) ) !== false; } @@ -516,7 +518,7 @@ protected function dispatchSentEvent($message, $data = []) { if ($this->events) { $this->events->dispatch( - new Events\MessageSent($message->getSwiftMessage(), $data) + new MessageSent($message->getSwiftMessage(), $data) ); } }
true
Other
laravel
framework
7b074c1ac506c1895f85ec77481b55228a122a05.json
Add missing imports. (#30764)
src/Illuminate/Notifications/NotificationSender.php
@@ -6,6 +6,8 @@ use Illuminate\Contracts\Translation\HasLocalePreference; use Illuminate\Database\Eloquent\Collection as ModelCollection; use Illuminate\Database\Eloquent\Model; +use Illuminate\Notifications\Events\NotificationSending; +use Illuminate\Notifications\Events\NotificationSent; use Illuminate\Support\Collection; use Illuminate\Support\Str; use Illuminate\Support\Traits\Localizable; @@ -144,7 +146,7 @@ protected function sendToNotifiable($notifiable, $id, $notification, $channel) $response = $this->manager->driver($channel)->send($notifiable, $notification); $this->events->dispatch( - new Events\NotificationSent($notifiable, $notification, $channel, $response) + new NotificationSent($notifiable, $notification, $channel, $response) ); } @@ -159,7 +161,7 @@ protected function sendToNotifiable($notifiable, $id, $notification, $channel) protected function shouldSendNotification($notifiable, $notification, $channel) { return $this->events->until( - new Events\NotificationSending($notifiable, $notification, $channel) + new NotificationSending($notifiable, $notification, $channel) ) !== false; }
true
Other
laravel
framework
7b074c1ac506c1895f85ec77481b55228a122a05.json
Add missing imports. (#30764)
src/Illuminate/Queue/SyncQueue.php
@@ -5,6 +5,9 @@ use Exception; use Illuminate\Contracts\Queue\Job; use Illuminate\Contracts\Queue\Queue as QueueContract; +use Illuminate\Queue\Events\JobExceptionOccurred; +use Illuminate\Queue\Events\JobProcessed; +use Illuminate\Queue\Events\JobProcessing; use Illuminate\Queue\Jobs\SyncJob; use Symfony\Component\Debug\Exception\FatalThrowableError; use Throwable; @@ -72,7 +75,7 @@ protected function resolveJob($payload, $queue) protected function raiseBeforeJobEvent(Job $job) { if ($this->container->bound('events')) { - $this->container['events']->dispatch(new Events\JobProcessing($this->connectionName, $job)); + $this->container['events']->dispatch(new JobProcessing($this->connectionName, $job)); } } @@ -85,7 +88,7 @@ protected function raiseBeforeJobEvent(Job $job) protected function raiseAfterJobEvent(Job $job) { if ($this->container->bound('events')) { - $this->container['events']->dispatch(new Events\JobProcessed($this->connectionName, $job)); + $this->container['events']->dispatch(new JobProcessed($this->connectionName, $job)); } } @@ -99,7 +102,7 @@ protected function raiseAfterJobEvent(Job $job) protected function raiseExceptionOccurredJobEvent(Job $job, $e) { if ($this->container->bound('events')) { - $this->container['events']->dispatch(new Events\JobExceptionOccurred($this->connectionName, $job, $e)); + $this->container['events']->dispatch(new JobExceptionOccurred($this->connectionName, $job, $e)); } }
true
Other
laravel
framework
7b074c1ac506c1895f85ec77481b55228a122a05.json
Add missing imports. (#30764)
src/Illuminate/Queue/Worker.php
@@ -8,6 +8,11 @@ use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Queue\Factory as QueueManager; use Illuminate\Database\DetectsLostConnections; +use Illuminate\Queue\Events\JobExceptionOccurred; +use Illuminate\Queue\Events\JobProcessed; +use Illuminate\Queue\Events\JobProcessing; +use Illuminate\Queue\Events\Looping; +use Illuminate\Queue\Events\WorkerStopping; use Illuminate\Support\Carbon; use Symfony\Component\Debug\Exception\FatalThrowableError; use Throwable; @@ -189,7 +194,7 @@ protected function daemonShouldRun(WorkerOptions $options, $connectionName, $que { return ! ((($this->isDownForMaintenance)() && ! $options->force) || $this->paused || - $this->events->until(new Events\Looping($connectionName, $queue)) === false); + $this->events->until(new Looping($connectionName, $queue)) === false); } /** @@ -471,7 +476,7 @@ protected function failJob($job, $e) */ protected function raiseBeforeJobEvent($connectionName, $job) { - $this->events->dispatch(new Events\JobProcessing( + $this->events->dispatch(new JobProcessing( $connectionName, $job )); } @@ -485,7 +490,7 @@ protected function raiseBeforeJobEvent($connectionName, $job) */ protected function raiseAfterJobEvent($connectionName, $job) { - $this->events->dispatch(new Events\JobProcessed( + $this->events->dispatch(new JobProcessed( $connectionName, $job )); } @@ -500,7 +505,7 @@ protected function raiseAfterJobEvent($connectionName, $job) */ protected function raiseExceptionOccurredJobEvent($connectionName, $job, $e) { - $this->events->dispatch(new Events\JobExceptionOccurred( + $this->events->dispatch(new JobExceptionOccurred( $connectionName, $job, $e )); } @@ -579,7 +584,7 @@ public function memoryExceeded($memoryLimit) */ public function stop($status = 0) { - $this->events->dispatch(new Events\WorkerStopping($status)); + $this->events->dispatch(new WorkerStopping($status)); exit($status); } @@ -592,7 +597,7 @@ public function stop($status = 0) */ public function kill($status = 0) { - $this->events->dispatch(new Events\WorkerStopping($status)); + $this->events->dispatch(new WorkerStopping($status)); if (extension_loaded('posix')) { posix_kill(getmypid(), SIGKILL);
true
Other
laravel
framework
7b074c1ac506c1895f85ec77481b55228a122a05.json
Add missing imports. (#30764)
src/Illuminate/Redis/RedisManager.php
@@ -5,6 +5,8 @@ use Closure; use Illuminate\Contracts\Redis\Factory; use Illuminate\Redis\Connections\Connection; +use Illuminate\Redis\Connectors\PhpRedisConnector; +use Illuminate\Redis\Connectors\PredisConnector; use Illuminate\Support\ConfigurationUrlParser; use InvalidArgumentException; @@ -167,9 +169,9 @@ protected function connector() switch ($this->driver) { case 'predis': - return new Connectors\PredisConnector; + return new PredisConnector; case 'phpredis': - return new Connectors\PhpRedisConnector; + return new PhpRedisConnector; } }
true
Other
laravel
framework
7b074c1ac506c1895f85ec77481b55228a122a05.json
Add missing imports. (#30764)
src/Illuminate/Routing/Router.php
@@ -15,6 +15,7 @@ use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Http\Response; +use Illuminate\Routing\Events\RouteMatched; use Illuminate\Support\Collection; use Illuminate\Support\Str; use Illuminate\Support\Traits\Macroable; @@ -651,7 +652,7 @@ protected function runRoute(Request $request, Route $route) return $route; }); - $this->events->dispatch(new Events\RouteMatched($route, $request)); + $this->events->dispatch(new RouteMatched($route, $request)); return $this->prepareResponse($request, $this->runRouteWithinStack($route, $request)
true
Other
laravel
framework
7b074c1ac506c1895f85ec77481b55228a122a05.json
Add missing imports. (#30764)
src/Illuminate/Validation/Rule.php
@@ -4,6 +4,12 @@ use Illuminate\Contracts\Support\Arrayable; use Illuminate\Support\Traits\Macroable; +use Illuminate\Validation\Rules\Dimensions; +use Illuminate\Validation\Rules\Exists; +use Illuminate\Validation\Rules\In; +use Illuminate\Validation\Rules\NotIn; +use Illuminate\Validation\Rules\RequiredIf; +use Illuminate\Validation\Rules\Unique; class Rule { @@ -17,7 +23,7 @@ class Rule */ public static function dimensions(array $constraints = []) { - return new Rules\Dimensions($constraints); + return new Dimensions($constraints); } /** @@ -29,7 +35,7 @@ public static function dimensions(array $constraints = []) */ public static function exists($table, $column = 'NULL') { - return new Rules\Exists($table, $column); + return new Exists($table, $column); } /** @@ -44,7 +50,7 @@ public static function in($values) $values = $values->toArray(); } - return new Rules\In(is_array($values) ? $values : func_get_args()); + return new In(is_array($values) ? $values : func_get_args()); } /** @@ -59,7 +65,7 @@ public static function notIn($values) $values = $values->toArray(); } - return new Rules\NotIn(is_array($values) ? $values : func_get_args()); + return new NotIn(is_array($values) ? $values : func_get_args()); } /** @@ -70,7 +76,7 @@ public static function notIn($values) */ public static function requiredIf($callback) { - return new Rules\RequiredIf($callback); + return new RequiredIf($callback); } /** @@ -82,6 +88,6 @@ public static function requiredIf($callback) */ public static function unique($table, $column = 'NULL') { - return new Rules\Unique($table, $column); + return new Unique($table, $column); } }
true
Other
laravel
framework
7b074c1ac506c1895f85ec77481b55228a122a05.json
Add missing imports. (#30764)
tests/Container/UtilTest.php
@@ -4,6 +4,7 @@ use Illuminate\Container\Util; use PHPUnit\Framework\TestCase; +use stdClass; class UtilTest extends TestCase { @@ -19,7 +20,7 @@ public function testArrayWrap() { $string = 'a'; $array = ['a']; - $object = new \stdClass; + $object = new stdClass; $object->value = 'a'; $this->assertEquals(['a'], Util::arrayWrap($string)); $this->assertEquals($array, Util::arrayWrap($array)); @@ -33,7 +34,7 @@ public function testArrayWrap() $this->assertEquals([false], Util::arrayWrap([false])); $this->assertEquals([0], Util::arrayWrap(0)); - $obj = new \stdClass; + $obj = new stdClass; $obj->value = 'a'; $obj = unserialize(serialize($obj)); $this->assertEquals([$obj], Util::arrayWrap($obj));
true
Other
laravel
framework
7b074c1ac506c1895f85ec77481b55228a122a05.json
Add missing imports. (#30764)
tests/Cookie/CookieTest.php
@@ -5,6 +5,7 @@ use Illuminate\Cookie\CookieJar; use Mockery as m; use PHPUnit\Framework\TestCase; +use ReflectionObject; use Symfony\Component\HttpFoundation\Cookie; class CookieTest extends TestCase @@ -194,7 +195,7 @@ public function getCreator() private function getQueuedPropertyValue(CookieJar $cookieJar) { - $property = (new \ReflectionObject($cookieJar))->getProperty('queued'); + $property = (new ReflectionObject($cookieJar))->getProperty('queued'); $property->setAccessible(true); return $property->getValue($cookieJar);
true
Other
laravel
framework
7b074c1ac506c1895f85ec77481b55228a122a05.json
Add missing imports. (#30764)
tests/Queue/QueueWorkerTest.php
@@ -2,6 +2,7 @@ namespace Illuminate\Tests\Queue; +use Exception; use Illuminate\Container\Container; use Illuminate\Contracts\Debug\ExceptionHandler; use Illuminate\Contracts\Events\Dispatcher; @@ -249,7 +250,7 @@ public function testJobBasedMaxRetries() public function testJobBasedFailedDelay() { $job = new WorkerFakeJob(function ($job) { - throw new \Exception('Something went wrong.'); + throw new Exception('Something went wrong.'); }); $job->attempts = 1;
true
Other
laravel
framework
910cc7473c0772032a8ac4fedb27e695ee69f9f0.json
Fix zero parameter for routes (#30768) Routes should be allowed to accept a 0 as a route parameter.
src/Illuminate/Routing/RouteUrlGenerator.php
@@ -218,7 +218,7 @@ protected function replaceRouteParameters($path, array &$parameters) protected function replaceNamedParameters($path, &$parameters) { return preg_replace_callback('/\{(.*?)(\?)?\}/', function ($m) use (&$parameters) { - if (isset($parameters[$m[1]]) && $parameters[$m[1]] != '') { + if (isset($parameters[$m[1]]) && $parameters[$m[1]] !== '') { return Arr::pull($parameters, $m[1]); } elseif (isset($this->defaultParameters[$m[1]])) { return $this->defaultParameters[$m[1]];
true
Other
laravel
framework
910cc7473c0772032a8ac4fedb27e695ee69f9f0.json
Fix zero parameter for routes (#30768) Routes should be allowed to accept a 0 as a route parameter.
tests/Routing/RoutingUrlGeneratorTest.php
@@ -249,6 +249,7 @@ public function testBasicRouteGeneration() $this->assertSame('/foo/bar?foo=bar', $url->route('foo', ['foo' => 'bar'], false)); $this->assertSame('http://www.foo.com/foo/bar/taylor/breeze/otwell?fly=wall', $url->route('bar', ['taylor', 'otwell', 'fly' => 'wall'])); $this->assertSame('http://www.foo.com/foo/bar/otwell/breeze/taylor?fly=wall', $url->route('bar', ['boom' => 'taylor', 'baz' => 'otwell', 'fly' => 'wall'])); + $this->assertSame('http://www.foo.com/foo/bar/0', $url->route('foobar', 0)); $this->assertSame('http://www.foo.com/foo/bar/2', $url->route('foobar', 2)); $this->assertSame('http://www.foo.com/foo/bar/taylor', $url->route('foobar', 'taylor')); $this->assertSame('/foo/bar/taylor/breeze/otwell?fly=wall', $url->route('bar', ['taylor', 'otwell', 'fly' => 'wall'], false)); @@ -261,6 +262,7 @@ public function testBasicRouteGeneration() $this->assertSame('http://www.foo.com/foo/bar', $url->route('optional')); $this->assertSame('http://www.foo.com/foo/bar', $url->route('optional', ['baz' => null])); $this->assertSame('http://www.foo.com/foo/bar', $url->route('optional', ['baz' => ''])); + $this->assertSame('http://www.foo.com/foo/bar/0', $url->route('optional', ['baz' => 0])); $this->assertSame('http://www.foo.com/foo/bar/taylor', $url->route('optional', 'taylor')); $this->assertSame('http://www.foo.com/foo/bar/taylor', $url->route('optional', ['taylor'])); $this->assertSame('http://www.foo.com/foo/bar/taylor?breeze', $url->route('optional', ['taylor', 'breeze']));
true
Other
laravel
framework
79ac996b4474c95d55885049bbd8981afc7c6148.json
remove empty line
tests/Integration/Events/EventFakeTest.php
@@ -14,7 +14,6 @@ class EventFakeTest extends TestCase * Define environment setup. * * @param \Illuminate\Contracts\Foundation\Application $app - * * @return void */ protected function getEnvironmentSetUp($app)
false
Other
laravel
framework
679eb00c6852034fee125709decdc1628f4b996b.json
fix single spaces for params in docs
src/Illuminate/Database/Console/WipeCommand.php
@@ -83,7 +83,7 @@ protected function dropAllViews($database) /** * Drop all of the database types. * - * @param string $database + * @param string $database * @return void */ protected function dropAllTypes($database)
true
Other
laravel
framework
679eb00c6852034fee125709decdc1628f4b996b.json
fix single spaces for params in docs
src/Illuminate/Database/Eloquent/HigherOrderBuilderProxy.php
@@ -25,7 +25,7 @@ class HigherOrderBuilderProxy * Create a new proxy instance. * * @param \Illuminate\Database\Eloquent\Builder $builder - * @param string $method + * @param string $method */ public function __construct(Builder $builder, $method) {
true
Other
laravel
framework
679eb00c6852034fee125709decdc1628f4b996b.json
fix single spaces for params in docs
src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php
@@ -222,7 +222,7 @@ public function compileDropAllViews($views) /** * Compile the SQL needed to drop all types. * - * @param array $types + * @param array $types * @return string */ public function compileDropAllTypes($types)
true
Other
laravel
framework
679eb00c6852034fee125709decdc1628f4b996b.json
fix single spaces for params in docs
src/Illuminate/Filesystem/Cache.php
@@ -31,9 +31,10 @@ class Cache extends AbstractCache /** * Create a new cache instance. * - * @param \Illuminate\Contracts\Cache\Repository $repository - * @param string $key - * @param int|null $expire + * @param \Illuminate\Contracts\Cache\Repository $repository + * @param string $key + * @param int|null $expire + * @return void */ public function __construct(Repository $repository, $key = 'flysystem', $expire = null) {
true
Other
laravel
framework
a07bd96a101034a6944e3a58dc50d9936a20e2f9.json
accept a string or array of views (#30746) this goes along with PR #30651 . I'm not sure what our practice is for changes like this on an interface.... I'm not technically changing any of the code, just a docblock, so is it safe to send to 6.x?
src/Illuminate/Contracts/Routing/ResponseFactory.php
@@ -26,7 +26,7 @@ public function noContent($status = 204, array $headers = []); /** * Create a new response for a given view. * - * @param string $view + * @param string|array $view * @param array $data * @param int $status * @param array $headers
false
Other
laravel
framework
3673354d70b860078d0c88e1d89439e65db9af70.json
Change method visibility
src/Illuminate/Http/Resources/Json/ResourceCollection.php
@@ -99,7 +99,7 @@ public function toResponse($request) * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\JsonResponse */ - private function preparePaginatedResponse($request) + protected function preparePaginatedResponse($request) { if ($this->queryParameters) { $this->resource->appends($request->query());
false
Other
laravel
framework
6690c2c0f1887475712569cbe902e93be12ccb1a.json
Allow string in some Builder param types (#30744)
src/Illuminate/Database/Concerns/BuildsQueries.php
@@ -135,7 +135,7 @@ public function eachById(callable $callback, $count = 1000, $column = null, $ali /** * Execute the query and get the first result. * - * @param array $columns + * @param array|string $columns * @return \Illuminate\Database\Eloquent\Model|object|static|null */ public function first($columns = ['*'])
true
Other
laravel
framework
6690c2c0f1887475712569cbe902e93be12ccb1a.json
Allow string in some Builder param types (#30744)
src/Illuminate/Database/Eloquent/Builder.php
@@ -492,7 +492,7 @@ public function value($column) /** * Execute the query as a "select" statement. * - * @param array $columns + * @param array|string $columns * @return \Illuminate\Database\Eloquent\Collection|static[] */ public function get($columns = ['*']) @@ -512,7 +512,7 @@ public function get($columns = ['*']) /** * Get the hydrated models without eager loading. * - * @param array $columns + * @param array|string $columns * @return \Illuminate\Database\Eloquent\Model[]|static[] */ public function getModels($columns = ['*'])
true
Other
laravel
framework
72deea318efb2886ee589654b584be8500977eb1.json
Remove unnecessary variable (#30735)
src/Illuminate/Auth/GenericUser.php
@@ -41,9 +41,7 @@ public function getAuthIdentifierName() */ public function getAuthIdentifier() { - $name = $this->getAuthIdentifierName(); - - return $this->attributes[$name]; + return $this->attributes[$this->getAuthIdentifierName()]; } /**
false
Other
laravel
framework
663a30fa808072093d2525c068eb36425b4a21e2.json
Fix return type
src/Illuminate/Mail/Mailable.php
@@ -202,7 +202,7 @@ public function later($delay, Queue $queue) /** * Render the mailable into a view. * - * @return \Illuminate\View\View + * @return string * * @throws \ReflectionException */
false
Other
laravel
framework
93b5068214ddd1c1aa33bb09aea645fc916aed86.json
force usage getting timestamps columns
src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php
@@ -866,7 +866,10 @@ protected function serializeDate(DateTimeInterface $date) */ public function getDates() { - $defaults = [static::CREATED_AT, static::UPDATED_AT]; + $defaults = [ + $this->getCreatedAtColumn(), + $this->getUpdatedAtColumn(), + ]; return $this->usesTimestamps() ? array_unique(array_merge($this->dates, $defaults))
true
Other
laravel
framework
93b5068214ddd1c1aa33bb09aea645fc916aed86.json
force usage getting timestamps columns
src/Illuminate/Database/Eloquent/Concerns/HasTimestamps.php
@@ -38,12 +38,13 @@ protected function updateTimestamps() { $time = $this->freshTimestamp(); - if (! is_null(static::UPDATED_AT) && ! $this->isDirty(static::UPDATED_AT)) { + $updatedAtColumn = $this->getUpdatedAtColumn(); + if (! is_null($updatedAtColumn) && ! $this->isDirty($updatedAtColumn)) { $this->setUpdatedAt($time); } - if (! $this->exists && ! is_null(static::CREATED_AT) && - ! $this->isDirty(static::CREATED_AT)) { + $createdAtColumn = $this->getCreatedAtColumn(); + if (! $this->exists && ! is_null($createdAtColumn) && ! $this->isDirty($createdAtColumn)) { $this->setCreatedAt($time); } } @@ -56,7 +57,7 @@ protected function updateTimestamps() */ public function setCreatedAt($value) { - $this->{static::CREATED_AT} = $value; + $this->{$this->getCreatedAtColumn()} = $value; return $this; } @@ -69,7 +70,7 @@ public function setCreatedAt($value) */ public function setUpdatedAt($value) { - $this->{static::UPDATED_AT} = $value; + $this->{$this->getUpdatedAtColumn()} = $value; return $this; }
true
Other
laravel
framework
e1f8eef2a413642aeab6df1a08602a58da58739f.json
accept field for Route binding (#30471) when resolving the binding for a Route, allow passing an override parameter for the queries field name, instead of the default one on the Model.
src/Illuminate/Contracts/Routing/UrlRoutable.php
@@ -21,8 +21,9 @@ public function getRouteKeyName(); /** * Retrieve the model for a bound value. * - * @param mixed $value + * @param mixed $value + * @param string $field * @return \Illuminate\Database\Eloquent\Model|null */ - public function resolveRouteBinding($value); + public function resolveRouteBinding($value, $field = null); }
true
Other
laravel
framework
e1f8eef2a413642aeab6df1a08602a58da58739f.json
accept field for Route binding (#30471) when resolving the binding for a Route, allow passing an override parameter for the queries field name, instead of the default one on the Model.
src/Illuminate/Database/Eloquent/Model.php
@@ -1493,12 +1493,13 @@ public function getRouteKeyName() /** * Retrieve the model for a bound value. * - * @param mixed $value + * @param mixed $value + * @param string $field * @return \Illuminate\Database\Eloquent\Model|null */ - public function resolveRouteBinding($value) + public function resolveRouteBinding($value, $field = null) { - return $this->where($this->getRouteKeyName(), $value)->first(); + return $this->where($field ?? $this->getRouteKeyName(), $value)->first(); } /**
true
Other
laravel
framework
e1f8eef2a413642aeab6df1a08602a58da58739f.json
accept field for Route binding (#30471) when resolving the binding for a Route, allow passing an override parameter for the queries field name, instead of the default one on the Model.
src/Illuminate/Http/Resources/DelegatesToResource.php
@@ -32,12 +32,13 @@ public function getRouteKeyName() /** * Retrieve the model for a bound value. * - * @param mixed $value + * @param mixed $value + * @param string $field * @return void * * @throws \Exception */ - public function resolveRouteBinding($value) + public function resolveRouteBinding($value, $field = null) { throw new Exception('Resources may not be implicitly resolved from route bindings.'); }
true
Other
laravel
framework
e1f8eef2a413642aeab6df1a08602a58da58739f.json
accept field for Route binding (#30471) when resolving the binding for a Route, allow passing an override parameter for the queries field name, instead of the default one on the Model.
tests/Integration/Routing/UrlSigningTest.php
@@ -101,7 +101,7 @@ public function getRouteKeyName() return 'routable'; } - public function resolveRouteBinding($routeKey) + public function resolveRouteBinding($routeKey, $field = null) { // }
true
Other
laravel
framework
e1f8eef2a413642aeab6df1a08602a58da58739f.json
accept field for Route binding (#30471) when resolving the binding for a Route, allow passing an override parameter for the queries field name, instead of the default one on the Model.
tests/Routing/RoutingUrlGeneratorTest.php
@@ -665,7 +665,7 @@ public function getRouteKeyName() return 'key'; } - public function resolveRouteBinding($routeKey) + public function resolveRouteBinding($routeKey, $field = null) { // }
true
Other
laravel
framework
074cc3cc5df1062fa6ae7e274ad0c73721e6d897.json
Remove Resource class (#30619) This class is never used and doesn't provide any value over using JsonResource instead.
src/Illuminate/Http/Resources/Json/Resource.php
@@ -1,8 +0,0 @@ -<?php - -namespace Illuminate\Http\Resources\Json; - -class Resource extends JsonResource -{ - // -}
false
Other
laravel
framework
08f8ef951e3f54e43bb9829c47393e9975b0a9ff.json
Apply fixes from StyleCI (#30657)
src/Illuminate/Routing/Router.php
@@ -142,7 +142,7 @@ public function __construct(Dispatcher $events, Container $container = null) public function head($uri, $action = null) { return $this->addRoute('HEAD', $uri, $action); - } + } /** * Register a new GET route with the router.
false
Other
laravel
framework
c0eff91020f5cbf014f97d39a4b47df3f8ec3d26.json
Add Route::fallback() PHPDoc (#30647)
src/Illuminate/Support/Facades/Route.php
@@ -3,6 +3,7 @@ namespace Illuminate\Support\Facades; /** + * @method static \Illuminate\Routing\Route fallback(\Closure|array|string|callable|null $action = null) * @method static \Illuminate\Routing\Route get(string $uri, \Closure|array|string|callable|null $action = null) * @method static \Illuminate\Routing\Route post(string $uri, \Closure|array|string|callable|null $action = null) * @method static \Illuminate\Routing\Route put(string $uri, \Closure|array|string|callable|null $action = null)
false
Other
laravel
framework
57306b716362331b6a95bf05336fcdb52057cca7.json
Allow explicit model definitions in database rules
src/Illuminate/Validation/Rules/DatabaseRule.php
@@ -3,6 +3,8 @@ namespace Illuminate\Validation\Rules; use Closure; +use Illuminate\Support\Str; +use Illuminate\Database\Eloquent\Model; trait DatabaseRule { @@ -43,10 +45,30 @@ trait DatabaseRule */ public function __construct($table, $column = 'NULL') { - $this->table = $table; + $this->table = $this->resolveTableName($table); $this->column = $column; } + /** + * Resolves the name of the table from the given string. + * + * @param string $table + * @return string + */ + public function resolveTableName($table) { + if (! Str::contains($table, '\\') || ! class_exists($table)) { + return $table; + } + + $model = new $table; + + if (! $model instanceof Model) { + return $table; + } + + return $model->getTable(); + } + /** * Set a "where" constraint on the query. *
true
Other
laravel
framework
57306b716362331b6a95bf05336fcdb52057cca7.json
Allow explicit model definitions in database rules
tests/Validation/ValidationExistsRuleTest.php
@@ -42,17 +42,29 @@ public function testItCorrectlyFormatsAStringVersionOfTheRule() $rule = new Exists('table', 'column'); $rule->where('foo', 'bar'); $this->assertSame('exists:table,column,foo,"bar"', (string) $rule); + + $rule = new Exists(User::class, 'column'); + $rule->where('foo', 'bar'); + $this->assertSame('exists:users,column,foo,"bar"', (string) $rule); + + $rule = new Exists('Illuminate\Tests\Validation\User', 'column'); + $rule->where('foo', 'bar'); + $this->assertSame('exists:users,column,foo,"bar"', (string) $rule); + + $rule = new Exists(NoTableNameModel::class, 'column'); + $rule->where('foo', 'bar'); + $this->assertSame('exists:no_table_name_models,column,foo,"bar"', (string) $rule); } public function testItChoosesValidRecordsUsingWhereInRule() { $rule = new Exists('users', 'id'); $rule->whereIn('type', ['foo', 'bar']); - EloquentTestUser::create(['id' => '1', 'type' => 'foo']); - EloquentTestUser::create(['id' => '2', 'type' => 'bar']); - EloquentTestUser::create(['id' => '3', 'type' => 'baz']); - EloquentTestUser::create(['id' => '4', 'type' => 'other']); + User::create(['id' => '1', 'type' => 'foo']); + User::create(['id' => '2', 'type' => 'bar']); + User::create(['id' => '3', 'type' => 'baz']); + User::create(['id' => '4', 'type' => 'other']); $trans = $this->getIlluminateArrayTranslator(); $v = new Validator($trans, [], ['id' => $rule]); @@ -73,10 +85,10 @@ public function testItChoosesValidRecordsUsingWhereNotInRule() $rule = new Exists('users', 'id'); $rule->whereNotIn('type', ['foo', 'bar']); - EloquentTestUser::create(['id' => '1', 'type' => 'foo']); - EloquentTestUser::create(['id' => '2', 'type' => 'bar']); - EloquentTestUser::create(['id' => '3', 'type' => 'baz']); - EloquentTestUser::create(['id' => '4', 'type' => 'other']); + User::create(['id' => '1', 'type' => 'foo']); + User::create(['id' => '2', 'type' => 'bar']); + User::create(['id' => '3', 'type' => 'baz']); + User::create(['id' => '4', 'type' => 'other']); $trans = $this->getIlluminateArrayTranslator(); $v = new Validator($trans, [], ['id' => $rule]); @@ -97,10 +109,10 @@ public function testItChoosesValidRecordsUsingWhereNotInAndWhereNotInRulesTogeth $rule = new Exists('users', 'id'); $rule->whereIn('type', ['foo', 'bar', 'baz'])->whereNotIn('type', ['foo', 'bar']); - EloquentTestUser::create(['id' => '1', 'type' => 'foo']); - EloquentTestUser::create(['id' => '2', 'type' => 'bar']); - EloquentTestUser::create(['id' => '3', 'type' => 'baz']); - EloquentTestUser::create(['id' => '4', 'type' => 'other']); + User::create(['id' => '1', 'type' => 'foo']); + User::create(['id' => '2', 'type' => 'bar']); + User::create(['id' => '3', 'type' => 'baz']); + User::create(['id' => '4', 'type' => 'other']); $trans = $this->getIlluminateArrayTranslator(); $v = new Validator($trans, [], ['id' => $rule]); @@ -175,9 +187,18 @@ public function getIlluminateArrayTranslator() /** * Eloquent Models. */ -class EloquentTestUser extends Eloquent +class User extends Eloquent { protected $table = 'users'; protected $guarded = []; public $timestamps = false; } + +/** + * Eloquent Models. + */ +class NoTableNameModel extends Eloquent +{ + protected $guarded = []; + public $timestamps = false; +}
true
Other
laravel
framework
c23b0b8b11ec65cdb857044a0c2e917ed62ce8a2.json
Fix QueueFake docblocks on Queue facade (#30629) The `@method` docblocks on the Queue facade introduced in #30300 are a bit different than the method signatures on the QueueFake.
src/Illuminate/Support/Facades/Queue.php
@@ -16,10 +16,10 @@ * @method static string getConnectionName() * @method static \Illuminate\Contracts\Queue\Queue setConnectionName(string $name) * @method static void assertNothingPushed() - * @method static void assertNotPushed(string $job, \Closure $callback = null) - * @method static void assertPushed(string $job, \Closure|int $callback = null) - * @method static void assertPushedOn(string $job, int $times = 1) - * @method static void assertPushedWithChain(string $queue, string $job, \Closure $callback = null) + * @method static void assertNotPushed(string $job, callable $callback = null) + * @method static void assertPushed(string $job, callable|int $callback = null) + * @method static void assertPushedOn(string $queue, string $job, callable|int $callback = null) + * @method static void assertPushedWithChain(string $job, array $expectedChain = [], callable $callback = null) * * @see \Illuminate\Queue\QueueManager * @see \Illuminate\Queue\Queue
false
Other
laravel
framework
181db51595d546cbd24b3fac0cb276255e147286.json
allow string content on fake file creation
src/Illuminate/Http/Testing/File.php
@@ -49,7 +49,7 @@ public function __construct($name, $tempFile) * Create a new fake file. * * @param string $name - * @param int $kilobytes + * @param string|int $kilobytes * @return \Illuminate\Http\Testing\File */ public static function create($name, $kilobytes = 0)
true
Other
laravel
framework
181db51595d546cbd24b3fac0cb276255e147286.json
allow string content on fake file creation
src/Illuminate/Http/Testing/FileFactory.php
@@ -10,13 +10,19 @@ class FileFactory * Create a new fake file. * * @param string $name - * @param int $kilobytes + * @param string|int $kilobytes * @return \Illuminate\Http\Testing\File */ public function create($name, $kilobytes = 0) { - return tap(new File($name, tmpfile()), function ($file) use ($kilobytes) { - $file->sizeToReport = $kilobytes * 1024; + $tmp = tmpfile(); + + if (is_string($kilobytes)) { + file_put_contents($tmp, $kilobytes); + } + + return tap(new File($name, $tmp), function ($file) use ($kilobytes) { + $file->sizeToReport = is_string($kilobytes) ? fstat($tmp)['size'] : ($kilobytes * 1024); }); }
true
Other
laravel
framework
b204042056458faefee1be04c0e4b2fb59424cbe.json
Remove prefix before normalizing the channel name.
src/Illuminate/Broadcasting/Broadcasters/RedisBroadcaster.php
@@ -47,15 +47,14 @@ public function __construct(Redis $redis, $connection = null) */ public function auth($request) { - $channelName = $this->normalizeChannelName($request->channel_name); + $channelName = str_replace(config('database.redis.options.prefix', ''), '', $request->channel_name); + $channelName = $this->normalizeChannelName($channelName); if ($this->isGuardedChannel($request->channel_name) && ! $this->retrieveUser($request, $channelName)) { throw new AccessDeniedHttpException; } - $channelName = str_replace(config('redis.options.prefix', ''), '', $channelName); - return parent::verifyUserCanAccessChannel( $request, $channelName );
false
Other
laravel
framework
174c234b2d7e5108db1395ad5b681e50e0a7794d.json
add conditional methods to dispatchable traits
src/Illuminate/Foundation/Bus/Dispatchable.php
@@ -16,6 +16,32 @@ public static function dispatch() return new PendingDispatch(new static(...func_get_args())); } + /** + * Dispatch the job with the given arguments if the given truth test passes. + * + * @param bool $boolean + * @return \Illuminate\Foundation\Bus\PendingDispatch|\Illuminate\Support\Fluent + */ + public static function dispatchIf($boolean, ...$arguments) + { + return $boolean + ? new PendingDispatch(new static(...$arguments)) + : new Fluent; + } + + /** + * Dispatch the job with the given arguments unless the given truth test passes. + * + * @param bool $boolean + * @return \Illuminate\Foundation\Bus\PendingDispatch|\Illuminate\Support\Fluent + */ + public static function dispatchUnless($boolean, ...$arguments) + { + return ! $boolean + ? new PendingDispatch(new static(...$arguments)) + : new Fluent; + } + /** * Dispatch a command to its appropriate handler in the current process. *
true
Other
laravel
framework
174c234b2d7e5108db1395ad5b681e50e0a7794d.json
add conditional methods to dispatchable traits
src/Illuminate/Foundation/Events/Dispatchable.php
@@ -14,6 +14,32 @@ public static function dispatch() return event(new static(...func_get_args())); } + /** + * Dispatch the event with the given arguments if the given truth test passes. + * + * @param bool $boolean + * @return void + */ + public static function dispatchIf($boolean, ...$arguments) + { + if ($boolean) { + return event(new static(...$arguments)); + } + } + + /** + * Dispatch the event with the given arguments unless the given truth test passes. + * + * @param bool $boolean + * @return void + */ + public static function dispatchUnless($boolean, ...$arguments) + { + if (! $boolean) { + return event(new static(...$arguments)); + } + } + /** * Broadcast the event with the given arguments. *
true
Other
laravel
framework
2385358edd9652ce115632002027ac71bf2633db.json
Fix typos (#30581)
CHANGELOG-6.x.md
@@ -11,7 +11,7 @@ ### Fixed - Fixed default value for $count in `PhpRedisConnection::spop()` method ([#30546](https://github.com/laravel/framework/pull/30546)) - Fixed breaking compatibility with multi-schema postgres ([#30562](https://github.com/laravel/framework/pull/30562), [6460d2b](https://github.com/laravel/framework/commit/6460d2b1bd89f470a76f5c2c3bddd390fe430e0f)) -- Fixed `Model::isDirty()` with `colelction` \ `object` casts ([#30565](https://github.com/laravel/framework/pull/30565)) +- Fixed `Model::isDirty()` with `collection` / `object` casts ([#30565](https://github.com/laravel/framework/pull/30565)) - Fixed `bcc` in `MailgunTransport::send()` ([#30569](https://github.com/laravel/framework/pull/30569)) ### Changed @@ -79,7 +79,7 @@ ### Added - Added ability to override `setUserPassword` on password reset ([#30218](https://github.com/laravel/framework/pull/30218)) -- Added firing `deleting` \ `deleted` events in `MorphPivot` ([#30229](https://github.com/laravel/framework/pull/30229)) +- Added firing `deleting` / `deleted` events in `MorphPivot` ([#30229](https://github.com/laravel/framework/pull/30229)) - Added locking mechanism for the array cache driver ([#30253](https://github.com/laravel/framework/pull/30253)) - Added `dropAllViews` functionality to the SQL Server builder ([#30222](https://github.com/laravel/framework/pull/30222)) @@ -149,10 +149,10 @@ ### Added - Added `TestResponse::assertJsonPath()` method ([#29957](https://github.com/laravel/framework/pull/29957)) -- Added `hasMacro` \ `getGlobalMacro` \ `hasGlobalMacro` methods to `Eloquent Builder` ([#30008](https://github.com/laravel/framework/pull/30008)) +- Added `hasMacro` / `getGlobalMacro` / `hasGlobalMacro` methods to `Eloquent Builder` ([#30008](https://github.com/laravel/framework/pull/30008)) - Added `Illuminate\Database\Eloquent\Relations\BelongsToMany::getPivotColumns()` method ([#30049](https://github.com/laravel/framework/pull/30049)) -- Added `ScheduledTaskFinished` \ `ScheduledTaskStarting` events to signal when scheduled task runs ([#29888](https://github.com/laravel/framework/pull/29888)) -- Allowing adding command arguments and options with `InputArgument` \ `InputOption` objects ([#29987](https://github.com/laravel/framework/pull/29987)) +- Added `ScheduledTaskFinished` / `ScheduledTaskStarting` events to signal when scheduled task runs ([#29888](https://github.com/laravel/framework/pull/29888)) +- Allowing adding command arguments and options with `InputArgument` / `InputOption` objects ([#29987](https://github.com/laravel/framework/pull/29987)) ### Fixed - Fixed `__()` with `null` parameter ([#29967](https://github.com/laravel/framework/pull/29967)) @@ -164,7 +164,7 @@ - Fixed adding `NotFoundHttpException` to "allowed" exceptions in tests ([#29975](https://github.com/laravel/framework/pull/29975)) ### Changed -- Make it possible to disable encryption via `0`/`false` ([#29985](https://github.com/laravel/framework/pull/29985)) +- Make it possible to disable encryption via `0` / `false` ([#29985](https://github.com/laravel/framework/pull/29985)) - Allowed a symfony file instance in validate dimensions ([#30009](https://github.com/laravel/framework/pull/30009)) - Create storage fakes with custom configuration ([#29999](https://github.com/laravel/framework/pull/29999)) - Set locale in `PendingMail` only if locale present conditionally ([dd1e0a6](https://github.com/laravel/framework/commit/dd1e0a604713ddae21e6a893e4f605a6777300e8))
false
Other
laravel
framework
f1cfa859e3826b2d996ffc8af30848bc537f06f9.json
update Model dirty check (#30565) for attributes that are cast to any type of Object, the strict equivalency (`===`) will never return `true`, because even though the values may be equal, the Object there reference will be different. this changes checks if the cast type is either `object` or `collection`, both with return Objects, and uses loose equivalency to compare them. even though date casting also returns an Object, we don't need to handle that since it's handled in the previous conditional. the test represents a scenario that occurs when using JSON fields in MySQL. MySQL returns the value with spaces between the elements, but `json_encode` returns a string **without** spaces between the elements.
src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php
@@ -1172,6 +1172,9 @@ public function originalIsEquivalent($key, $current) } elseif ($this->isDateAttribute($key)) { return $this->fromDateTime($current) === $this->fromDateTime($original); + } elseif ($this->hasCast($key, ['object', 'collection'])) { + return $this->castAttribute($key, $current) == + $this->castAttribute($key, $original); } elseif ($this->hasCast($key)) { return $this->castAttribute($key, $current) === $this->castAttribute($key, $original);
true
Other
laravel
framework
f1cfa859e3826b2d996ffc8af30848bc537f06f9.json
update Model dirty check (#30565) for attributes that are cast to any type of Object, the strict equivalency (`===`) will never return `true`, because even though the values may be equal, the Object there reference will be different. this changes checks if the cast type is either `object` or `collection`, both with return Objects, and uses loose equivalency to compare them. even though date casting also returns an Object, we don't need to handle that since it's handled in the previous conditional. the test represents a scenario that occurs when using JSON fields in MySQL. MySQL returns the value with spaces between the elements, but `json_encode` returns a string **without** spaces between the elements.
tests/Database/DatabaseEloquentModelTest.php
@@ -116,6 +116,23 @@ public function testDirtyOnCastOrDateAttributes() $this->assertTrue($model->isDirty('datetimeAttribute')); } + public function testDirtyOnCastedObjects() + { + $model = new EloquentModelCastingStub; + $model->setRawAttributes([ + 'objectAttribute' => '["one", "two", "three"]', + 'collectionAttribute' => '["one", "two", "three"]', + ]); + $model->syncOriginal(); + + $model->objectAttribute = ['one', 'two', 'three']; + $model->collectionAttribute = ['one', 'two', 'three']; + + $this->assertFalse($model->isDirty()); + $this->assertFalse($model->isDirty('objectAttribute')); + $this->assertFalse($model->isDirty('collectionAttribute')); + } + public function testCleanAttributes() { $model = new EloquentModelStub(['foo' => '1', 'bar' => 2, 'baz' => 3]);
true
Other
laravel
framework
60a688ae5f5342874cafdcc3603667539e0e9c19.json
Add includeUnless directive (#30538)
src/Illuminate/View/Compilers/Concerns/CompilesIncludes.php
@@ -54,6 +54,19 @@ protected function compileIncludeWhen($expression) return "<?php echo \$__env->renderWhen($expression, \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path'])); ?>"; } + /** + * Compile the include-unless statements into valid PHP. + * + * @param string $expression + * @return string + */ + protected function compileIncludeUnless($expression) + { + $expression = $this->stripParentheses($expression); + + return "<?php echo \$__env->renderWhen(! $expression, \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path'])); ?>"; + } + /** * Compile the include-first statements into valid PHP. *
false
Other
laravel
framework
3745d9a97a74185c90d76db921b6daba6d6e24f2.json
Apply fixes from StyleCI (#30527)
src/Illuminate/Database/Schema/Blueprint.php
@@ -5,9 +5,8 @@ use BadMethodCallException; use Closure; use Illuminate\Database\Connection; -use Illuminate\Database\SQLiteConnection; -use Illuminate\Database\Schema\ForeignKeyDefinition; use Illuminate\Database\Schema\Grammars\Grammar; +use Illuminate\Database\SQLiteConnection; use Illuminate\Support\Fluent; use Illuminate\Support\Traits\Macroable;
true
Other
laravel
framework
3745d9a97a74185c90d76db921b6daba6d6e24f2.json
Apply fixes from StyleCI (#30527)
tests/Database/DatabaseMySqlSchemaGrammarTest.php
@@ -372,7 +372,6 @@ public function testAddingForeignKey() $this->assertCount(1, $statements); $this->assertSame('alter table `users` add constraint `users_foo_id_foreign` foreign key (`foo_id`) references `orders` (`id`)', $statements[0]); - $blueprint = new Blueprint('users'); $blueprint->foreign('foo_id')->references('id')->on('orders')->cascadeOnDelete(); $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
true
Other
laravel
framework
ec966c21c4062c8ded5d8add4db91cab61a591dc.json
add helper for on delete cascade
src/Illuminate/Database/Schema/Blueprint.php
@@ -5,8 +5,9 @@ use BadMethodCallException; use Closure; use Illuminate\Database\Connection; -use Illuminate\Database\Schema\Grammars\Grammar; use Illuminate\Database\SQLiteConnection; +use Illuminate\Database\Schema\ForeignKeyDefinition; +use Illuminate\Database\Schema\Grammars\Grammar; use Illuminate\Support\Fluent; use Illuminate\Support\Traits\Macroable; @@ -520,11 +521,17 @@ public function spatialIndex($columns, $name = null) * * @param string|array $columns * @param string|null $name - * @return \Illuminate\Support\Fluent|\Illuminate\Database\Schema\ForeignKeyDefinition + * @return \Illuminate\Database\Schema\ForeignKeyDefinition */ public function foreign($columns, $name = null) { - return $this->indexCommand('foreign', $columns, $name); + $command = new ForeignKeyDefinition( + $this->indexCommand('foreign', $columns, $name)->getAttributes() + ); + + $this->commands[count($this->commands) - 1] = $command; + + return $command; } /**
true