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
8c16891c6e7a4738d63788f4447614056ab5136e.json
add isCallable helper
tests/Support/SupportReflectorTest.php
@@ -57,6 +57,16 @@ public function testUnionTypeName() $this->assertNull(Reflector::getParameterClassName($method->getParameters()[0])); } + + public function testIsCallable() + { + $this->assertTrue(Reflector::isCallable(function () {})); + $this->assertTrue(Reflector::isCallable([B::class, 'f'])); + $this->assertFalse(Reflector::isCallable([TestClassWithCall::class, 'f'])); + $this->assertTrue(Reflector::isCallable([new TestClassWithCall, 'f'])); + $this->assertTrue(Reflector::isCallable([TestClassWithCallStatic::class, 'f'])); + $this->assertFalse(Reflector::isCallable([new TestClassWithCallStatic, 'f'])); + } } class A @@ -82,3 +92,19 @@ public function f(A|Model $x) }' ); } + +class TestClassWithCall +{ + public function __call($method, $parameters) + { + + } +} + +class TestClassWithCallStatic +{ + public static function __callStatic($method, $parameters) + { + + } +}
true
Other
laravel
framework
826a90f660016bd66326ae823a077ae10a868b28.json
Remove throw in BoundMethod (#34970)
src/Illuminate/Container/BoundMethod.php
@@ -3,7 +3,6 @@ namespace Illuminate\Container; use Closure; -use Illuminate\Contracts\Container\BindingResolutionException; use InvalidArgumentException; use ReflectionFunction; use ReflectionMethod; @@ -174,10 +173,6 @@ protected static function addDependencyForCallParameter($container, $parameter, } } elseif ($parameter->isDefaultValueAvailable()) { $dependencies[] = $parameter->getDefaultValue(); - } elseif (! $parameter->isOptional() && ! array_key_exists($paramName, $parameters)) { - $message = "Unable to resolve dependency [{$parameter}] in class {$parameter->getDeclaringClass()->getName()}"; - - throw new BindingResolutionException($message); } }
true
Other
laravel
framework
826a90f660016bd66326ae823a077ae10a868b28.json
Remove throw in BoundMethod (#34970)
tests/Container/ContainerCallTest.php
@@ -91,6 +91,13 @@ public function testCallWithBoundMethod() $this->assertSame('taylor', $result[1]); } + public function testCallWithUnnamedParameters() + { + $container = new Container; + $result = $container->call([new ContainerTestCallStub, 'unresolvable'], ['foo', 'bar']); + $this->assertEquals(['foo', 'bar'], $result); + } + public function testBindMethodAcceptsAnArray() { $container = new Container;
true
Other
laravel
framework
3f0645cf38f51b235ec280b35922e3fe84f0be96.json
Add docblock for `Storage::extend()` (#34961)
src/Illuminate/Support/Facades/Storage.php
@@ -18,6 +18,7 @@ * @method static bool delete(string|array $paths) * @method static bool deleteDirectory(string $directory) * @method static bool exists(string $path) + * @method static \Illuminate\Filesystem\FilesystemManager extend(string $driver, \Closure $callback) * @method static bool makeDirectory(string $path) * @method static bool move(string $from, string $to) * @method static bool prepend(string $path, string $data)
false
Other
laravel
framework
d5172d47326714a564b786e61800f8083f9d3d20.json
Remove unused use statement
src/Illuminate/Database/Console/Migrations/FreshCommand.php
@@ -6,7 +6,6 @@ use Illuminate\Console\ConfirmableTrait; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Database\Events\DatabaseRefreshed; -use Illuminate\Database\Migrations\Migrator; use Symfony\Component\Console\Input\InputOption; class FreshCommand extends Command
false
Other
laravel
framework
1cf55138ac28989a4a8f0f2d6d63784a54dd1061.json
Add types for casting encrypted strings to objects
src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php
@@ -72,6 +72,10 @@ trait HasAttributes 'decimal', 'double', 'encrypted', + 'encrypted:array', + 'encrypted:collection', + 'encrypted:json', + 'encrypted:object', 'float', 'int', 'integer', @@ -525,6 +529,14 @@ protected function castAttribute($key, $value) return $value; } + // If the key is one of the encrypted castable types, we'll first decrypt + // the value and update the cast type so we may leverage the following + // logic for casting the value to any additionally specified type. + if ($this->isEncryptedCastable($key)) { + $value = $this->fromEncryptedString($value); + $castType = Str::after($castType, 'encrypted:'); + } + switch ($castType) { case 'int': case 'integer': @@ -554,8 +566,6 @@ protected function castAttribute($key, $value) return $this->asDateTime($value); case 'timestamp': return $this->asTimestamp($value); - case 'encrypted': - return $this->fromEncryptedString($value); } if ($this->isClassCastable($key)) { @@ -1112,7 +1122,7 @@ protected function isDateCastable($key) */ protected function isJsonCastable($key) { - return $this->hasCast($key, ['array', 'json', 'object', 'collection']); + return $this->hasCast($key, ['array', 'json', 'object', 'collection', 'encrypted:array', 'encrypted:collection', 'encrypted:json', 'encrypted:object']); } /** @@ -1123,7 +1133,7 @@ protected function isJsonCastable($key) */ protected function isEncryptedCastable($key) { - return $this->hasCast($key, ['encrypted']); + return $this->hasCast($key, ['encrypted', 'encrypted:array', 'encrypted:collection', 'encrypted:json', 'encrypted:object']); } /**
true
Other
laravel
framework
1cf55138ac28989a4a8f0f2d6d63784a54dd1061.json
Add types for casting encrypted strings to objects
tests/Integration/Database/EloquentModelEncryptedCastingTest.php
@@ -5,6 +5,7 @@ use Illuminate\Contracts\Encryption\Encrypter; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Collection; use Illuminate\Support\Facades\Crypt; use Illuminate\Support\Facades\Schema; @@ -25,6 +26,10 @@ protected function setUp(): void Schema::create('encrypted_casts', function (Blueprint $table) { $table->increments('id'); $table->string('secret', 1000)->nullable(); + $table->text('secret_array')->nullable(); + $table->text('secret_json')->nullable(); + $table->text('secret_object')->nullable(); + $table->text('secret_collection')->nullable(); }); } @@ -37,21 +42,116 @@ public function testStringsAreCastable() ->with('encrypted-secret-string') ->andReturn('this is a secret string'); + /** @var \Illuminate\Tests\Integration\Database\EncryptedCast $subject */ + $subject = EncryptedCast::create([ + 'secret' => 'this is a secret string', + ]); + + $this->assertSame('this is a secret string', $subject->secret); + $this->assertDatabaseHas('encrypted_casts', [ + 'id' => $subject->id, + 'secret' => 'encrypted-secret-string', + ]); + } + + public function testArraysAreCastable() + { + $this->encrypter->expects('encryptString') + ->with('{"key1":"value1"}') + ->andReturn('encrypted-secret-array-string'); + $this->encrypter->expects('decryptString') + ->with('encrypted-secret-array-string') + ->andReturn('{"key1":"value1"}'); + + /** @var \Illuminate\Tests\Integration\Database\EncryptedCast $subject */ + $subject = EncryptedCast::create([ + 'secret_array' => ['key1' => 'value1'], + ]); + + $this->assertSame(['key1' => 'value1'], $subject->secret_array); + $this->assertDatabaseHas('encrypted_casts', [ + 'id' => $subject->id, + 'secret_array' => 'encrypted-secret-array-string', + ]); + } + + public function testJsonIsCastable() + { + $this->encrypter->expects('encryptString') + ->with('{"key1":"value1"}') + ->andReturn('encrypted-secret-json-string'); + $this->encrypter->expects('decryptString') + ->with('encrypted-secret-json-string') + ->andReturn('{"key1":"value1"}'); + + /** @var \Illuminate\Tests\Integration\Database\EncryptedCast $subject */ + $subject = EncryptedCast::create([ + 'secret_json' => ['key1' => 'value1'], + ]); + + $this->assertSame(['key1' => 'value1'], $subject->secret_json); + $this->assertDatabaseHas('encrypted_casts', [ + 'id' => $subject->id, + 'secret_json' => 'encrypted-secret-json-string', + ]); + } + + public function testObjectIsCastable() + { + $object = new \stdClass(); + $object->key1 = 'value1'; + + $this->encrypter->expects('encryptString') + ->with('{"key1":"value1"}') + ->andReturn('encrypted-secret-object-string'); + $this->encrypter->expects('decryptString') + ->twice() + ->with('encrypted-secret-object-string') + ->andReturn('{"key1":"value1"}'); + /** @var \Illuminate\Tests\Integration\Database\EncryptedCast $object */ $object = EncryptedCast::create([ - 'secret' => 'this is a secret string', + 'secret_object' => $object, ]); - $this->assertSame('this is a secret string', $object->secret); + $this->assertInstanceOf(\stdClass::class, $object->secret_object); + $this->assertSame('value1', $object->secret_object->key1); $this->assertDatabaseHas('encrypted_casts', [ 'id' => $object->id, - 'secret' => 'encrypted-secret-string', + 'secret_object' => 'encrypted-secret-object-string', + ]); + } + + public function testCollectionIsCastable() + { + $this->encrypter->expects('encryptString') + ->with('{"key1":"value1"}') + ->andReturn('encrypted-secret-collection-string'); + $this->encrypter->expects('decryptString') + ->twice() + ->with('encrypted-secret-collection-string') + ->andReturn('{"key1":"value1"}'); + + /** @var \Illuminate\Tests\Integration\Database\EncryptedCast $subject */ + $subject = EncryptedCast::create([ + 'secret_collection' => new Collection(['key1' => 'value1']), + ]); + + $this->assertInstanceOf(Collection::class, $subject->secret_collection); + $this->assertSame('value1', $subject->secret_collection->get('key1')); + $this->assertDatabaseHas('encrypted_casts', [ + 'id' => $subject->id, + 'secret_collection' => 'encrypted-secret-collection-string', ]); } } /** * @property $secret + * @property $secret_array + * @property $secret_json + * @property $secret_object + * @property $secret_collection */ class EncryptedCast extends Model { @@ -60,5 +160,9 @@ class EncryptedCast extends Model public $casts = [ 'secret' => 'encrypted', + 'secret_array' => 'encrypted:array', + 'secret_json' => 'encrypted:json', + 'secret_object' => 'encrypted:object', + 'secret_collection' => 'encrypted:collection', ]; }
true
Other
laravel
framework
dae0cb962dbf6f48f9b5bd7dccd932b7833f41bc.json
add tests to dispatcher (#34940)
tests/Events/EventsDispatcherTest.php
@@ -26,6 +26,14 @@ public function testBasicEventExecution() $this->assertEquals([null], $response); $this->assertSame('bar', $_SERVER['__event.test']); + + // we can still add listeners after the event has fired + $d->listen('foo', function ($foo) { + $_SERVER['__event.test'] .= $foo; + }); + + $d->dispatch('foo', ['bar']); + $this->assertSame('barbar', $_SERVER['__event.test']); } public function testHaltingEventExecution() @@ -383,6 +391,26 @@ public function testBothClassesAndInterfacesWork() unset($_SERVER['__event.test1']); unset($_SERVER['__event.test2']); } + + public function testNestedEvent() + { + $_SERVER['__event.test'] = []; + $d = new Dispatcher; + + $d->listen('event', function () use ($d) { + $d->listen('event', function () { + $_SERVER['__event.test'][] = 'fired 1'; + }); + $d->listen('event', function () { + $_SERVER['__event.test'][] = 'fired 2'; + }); + }); + + $d->dispatch('event'); + $this->assertSame([], $_SERVER['__event.test']); + $d->dispatch('event'); + $this->assertEquals(['fired 1', 'fired 2'], $_SERVER['__event.test']); + } } class ExampleEvent
false
Other
laravel
framework
f22333a7c0bb550a9bc9463f26695c256cbfb10e.json
Remove trailing comma (#34945)
src/Illuminate/Bus/BusServiceProvider.php
@@ -47,7 +47,7 @@ protected function registerBatchServices() return new DatabaseBatchRepository( $app->make(BatchFactory::class), $app->make('db')->connection(config('queue.batching.database')), - config('queue.batching.table', 'job_batches'), + config('queue.batching.table', 'job_batches') ); }); }
false
Other
laravel
framework
b14367393e59e1d7f1a91cb889a988d5b684c54a.json
Fix higher order messaging annotations (#34929)
src/Illuminate/Collections/Traits/EnumeratesValues.php
@@ -35,7 +35,11 @@ * @property-read HigherOrderCollectionProxy $some * @property-read HigherOrderCollectionProxy $sortBy * @property-read HigherOrderCollectionProxy $sortByDesc + * @property-read HigherOrderCollectionProxy $skipUntil + * @property-read HigherOrderCollectionProxy $skipWhile * @property-read HigherOrderCollectionProxy $sum + * @property-read HigherOrderCollectionProxy $takeUntil + * @property-read HigherOrderCollectionProxy $takeWhile * @property-read HigherOrderCollectionProxy $unique * @property-read HigherOrderCollectionProxy $until */
false
Other
laravel
framework
0e33004fee1df5574bcc28ea95f2ada16f5ad8ae.json
Fix undefined variable error for id (#34878)
src/Illuminate/Queue/Console/RetryBatchCommand.php
@@ -28,7 +28,7 @@ class RetryBatchCommand extends Command */ public function handle() { - $batch = $this->laravel[BatchRepository::class]->find($this->argument('id')); + $batch = $this->laravel[BatchRepository::class]->find($id = $this->argument('id')); if (! $batch) { $this->error("Unable to find a batch with ID [{$id}].");
false
Other
laravel
framework
f857dd2248df3b909cb7dd0bd47c9117f8a38a39.json
Improve Bus::batch() doc block (#34888)
src/Illuminate/Bus/Dispatcher.php
@@ -146,7 +146,7 @@ public function findBatch(string $batchId) /** * Create a new batch of queueable jobs. * - * @param \Illuminate\Support\Collection|array $jobs + * @param \Illuminate\Support\Collection|array|mixed $jobs * @return \Illuminate\Bus\PendingBatch */ public function batch($jobs)
true
Other
laravel
framework
f857dd2248df3b909cb7dd0bd47c9117f8a38a39.json
Improve Bus::batch() doc block (#34888)
src/Illuminate/Support/Facades/Bus.php
@@ -8,7 +8,7 @@ /** * @method static \Illuminate\Bus\Batch|null findBatch(string $batchId) - * @method static \Illuminate\Bus\PendingBatch batch(array $jobs) + * @method static \Illuminate\Bus\PendingBatch batch(array|mixed $jobs) * @method static \Illuminate\Contracts\Bus\Dispatcher map(array $map) * @method static \Illuminate\Contracts\Bus\Dispatcher pipeThrough(array $pipes) * @method static \Illuminate\Foundation\Bus\PendingChain chain(array $jobs)
true
Other
laravel
framework
3e4f5f4b771fbdc12a10db1694d55c7c91441161.json
Fix config item referenced. (#34852)
src/Illuminate/Queue/Console/BatchesTableCommand.php
@@ -57,7 +57,7 @@ public function __construct(Filesystem $files, Composer $composer) */ public function handle() { - $table = $this->laravel['config']['queue.batches.table'] ?? 'job_batches'; + $table = $this->laravel['config']['queue.batching.table'] ?? 'job_batches'; $this->replaceMigration( $this->createBaseMigration($table), $table, Str::studly($table)
false
Other
laravel
framework
11d747064030963c906412012ac8f6581711022e.json
add multiple_of custom replacer (#34858)
src/Illuminate/Validation/Concerns/ReplacesAttributes.php
@@ -104,6 +104,20 @@ protected function replaceMax($message, $attribute, $rule, $parameters) return str_replace(':max', $parameters[0], $message); } + /** + * Replace all place-holders for the multiple_of rule. + * + * @param string $message + * @param string $attribute + * @param string $rule + * @param array $parameters + * @return string + */ + protected function replaceMultipleOf($message, $attribute, $rule, $parameters) + { + return str_replace(':value', $parameters[0], $message); + } + /** * Replace all place-holders for the in rule. *
true
Other
laravel
framework
11d747064030963c906412012ac8f6581711022e.json
add multiple_of custom replacer (#34858)
tests/Validation/ValidationValidatorTest.php
@@ -1857,9 +1857,16 @@ public function testValidateMax() public function testValidateMutlpleOf($input, $allowed, $passes) { $trans = $this->getIlluminateArrayTranslator(); + $trans->addLines(['validation.multiple_of' => 'The :attribute must be a multiple of :value'], 'en'); $v = new Validator($trans, ['foo' => $input], ['foo' => "multiple_of:{$allowed}"]); + $this->assertSame($passes, $v->passes()); + if ($v->fails()) { + $this->assertSame("The foo must be a multiple of {$allowed}", $v->messages()->first('foo')); + } else { + $this->assertSame('', $v->messages()->first('foo')); + } } public function multipleOfDataProvider() @@ -1920,6 +1927,8 @@ public function multipleOfDataProvider() ['foo', 1, false], // invalid values [1, 'foo', false], ['foo', 'foo', false], + [1, '', false], + [1, null, false], ]; }
true
Other
laravel
framework
de94375ece99b258dc71ab905283cf09636a464d.json
Add Redis rate limiting job middleware
src/Illuminate/Queue/Middleware/RateLimitsJobsWithRedis.php
@@ -0,0 +1,90 @@ +<?php + +namespace Illuminate\Queue\Middleware; + +use Illuminate\Container\Container; +use Illuminate\Contracts\Redis\Factory as Redis; +use Illuminate\Redis\Limiters\DurationLimiter; +use Illuminate\Support\InteractsWithTime; + +class RateLimitsJobsWithRedis extends RateLimitsJobs +{ + use InteractsWithTime; + + /** + * The Redis factory implementation. + * + * @var \Illuminate\Contracts\Redis\Factory + */ + protected $redis; + + /** + * The timestamp of the end of the current duration by key. + * + * @var array + */ + public $decaysAt = []; + + /** + * Create a new rate limiter middleware instance. + * + * @param string $limiterName + * + * @return void + */ + public function __construct($limiterName) + { + parent::__construct($limiterName); + + $this->redis = Container::getInstance()->make(Redis::class); + } + + /** + * Handle a rate limited job. + * + * @param mixed $job + * @param callable $next + * @param array $limits + * @return mixed + */ + protected function handleJob($job, $next, array $limits) + { + foreach ($limits as $limit) { + if ($this->tooManyAttempts($limit->key, $limit->maxAttempts, $limit->decayMinutes)) { + return $job->release($this->getTimeUntilNextRetry($limit->key)); + } + } + + return $next($job); + } + + /** + * Determine if the given key has been "accessed" too many times. + * + * @param string $key + * @param int $maxAttempts + * @param int $decayMinutes + * @return bool + */ + protected function tooManyAttempts($key, $maxAttempts, $decayMinutes) + { + $limiter = new DurationLimiter( + $this->redis, $key, $maxAttempts, $decayMinutes * 60 + ); + + return tap(! $limiter->acquire(), function () use ($key, $limiter) { + $this->decaysAt[$key] = $limiter->decaysAt; + }); + } + + /** + * Get the number of seconds until the lock is released. + * + * @param string $key + * @return int + */ + protected function getTimeUntilNextRetry($key) + { + return $this->decaysAt[$key] - $this->currentTime(); + } +}
true
Other
laravel
framework
de94375ece99b258dc71ab905283cf09636a464d.json
Add Redis rate limiting job middleware
tests/Integration/Queue/RateLimitsJobsWithRedisTest.php
@@ -0,0 +1,176 @@ +<?php + +namespace Illuminate\Tests\Integration\Queue; + +use Illuminate\Bus\Dispatcher; +use Illuminate\Bus\Queueable; +use Illuminate\Cache\RateLimiter; +use Illuminate\Cache\RateLimiting\Limit; +use Illuminate\Contracts\Queue\Job; +use Illuminate\Foundation\Testing\Concerns\InteractsWithRedis; +use Illuminate\Queue\CallQueuedHandler; +use Illuminate\Queue\InteractsWithQueue; +use Illuminate\Queue\Middleware\RateLimitsJobsWithRedis; +use Illuminate\Support\Str; +use Mockery as m; +use Orchestra\Testbench\TestCase; + +/** + * @group integration + */ +class RateLimitsJobsWithRedisTest extends TestCase +{ + use InteractsWithRedis; + + protected function setUp(): void + { + parent::setUp(); + + $this->setUpRedis(); + } + + protected function tearDown(): void + { + parent::tearDown(); + + $this->tearDownRedis(); + + m::close(); + } + + public function testUnlimitedJobsAreExecuted() + { + $rateLimiter = $this->app->make(RateLimiter::class); + + $testJob = new RateLimitedTestJob; + + $rateLimiter->for($testJob->key, function ($job) { + return Limit::none(); + }); + + $this->assertJobRanSuccessfully($testJob); + $this->assertJobRanSuccessfully($testJob); + } + + public function testRateLimitedJobsAreNotExecutedOnLimitReached() + { + $rateLimiter = $this->app->make(RateLimiter::class); + + $testJob = new RateLimitedTestJob; + + $rateLimiter->for($testJob->key, function ($job) { + return Limit::perMinute(1); + }); + + $this->assertJobRanSuccessfully($testJob); + $this->assertJobWasReleased($testJob); + } + + public function testJobsCanHaveConditionalRateLimits() + { + $rateLimiter = $this->app->make(RateLimiter::class); + + $adminJob = new AdminTestJob; + + $rateLimiter->for($adminJob->key, function ($job) { + if ($job->isAdmin()) { + return Limit::none(); + } + + return Limit::perMinute(1); + }); + + $this->assertJobRanSuccessfully($adminJob); + $this->assertJobRanSuccessfully($adminJob); + + $nonAdminJob = new NonAdminTestJob; + + $rateLimiter->for($nonAdminJob->key, function ($job) { + if ($job->isAdmin()) { + return Limit::none(); + } + + return Limit::perMinute(1); + }); + + $this->assertJobRanSuccessfully($nonAdminJob); + $this->assertJobWasReleased($nonAdminJob); + } + + protected function assertJobRanSuccessfully($testJob) + { + $testJob::$handled = false; + $instance = new CallQueuedHandler(new Dispatcher($this->app), $this->app); + + $job = m::mock(Job::class); + + $job->shouldReceive('hasFailed')->once()->andReturn(false); + $job->shouldReceive('isReleased')->once()->andReturn(false); + $job->shouldReceive('isDeletedOrReleased')->once()->andReturn(false); + $job->shouldReceive('delete')->once(); + + $instance->call($job, [ + 'command' => serialize($testJob), + ]); + + $this->assertTrue($testJob::$handled); + } + + protected function assertJobWasReleased($testJob) + { + $testJob::$handled = false; + $instance = new CallQueuedHandler(new Dispatcher($this->app), $this->app); + + $job = m::mock(Job::class); + + $job->shouldReceive('hasFailed')->once()->andReturn(false); + $job->shouldReceive('release')->once(); + $job->shouldReceive('isReleased')->once()->andReturn(true); + $job->shouldReceive('isDeletedOrReleased')->once()->andReturn(true); + + $instance->call($job, [ + 'command' => serialize($testJob), + ]); + + $this->assertFalse($testJob::$handled); + } +} + +class RateLimitedTestJob +{ + use InteractsWithQueue, Queueable; + + public $key; + + public static $handled = false; + + public function __construct() { + $this->key = Str::random(10); + } + + public function handle() + { + static::$handled = true; + } + + public function middleware() + { + return [new RateLimitsJobsWithRedis($this->key)]; + } +} + +class AdminTestJob extends RateLimitedTestJob +{ + public function isAdmin() + { + return true; + } +} + +class NonAdminTestJob extends RateLimitedTestJob +{ + public function isAdmin() + { + return false; + } +}
true
Other
laravel
framework
673b35051892debc514fe752dc965e5a3d2bf6ae.json
fix docblock typo
src/Illuminate/Queue/Middleware/PreventOverlappingJobs.php
@@ -33,7 +33,6 @@ class PreventOverlappingJobs * @param string $key * @param string $prefix * @param int $expiresAt - * @param string $prefix * * @return void */
false
Other
laravel
framework
86d08e4b743a37269790482a516936e63f4e881b.json
add `dropConstrainedForeignId` method (#34806)
src/Illuminate/Database/Schema/Blueprint.php
@@ -383,6 +383,19 @@ public function dropForeign($index) return $this->dropIndexCommand('dropForeign', 'foreign', $index); } + /** + * Indicate that the given column and foreign key should be dropped. + * + * @param string $column + * @return \Illuminate\Support\Fluent + */ + public function dropConstrainedForeignId($column) + { + $this->dropForeign([$column]); + + return $this->dropColumn($column); + } + /** * Indicate that the given indexes should be renamed. *
true
Other
laravel
framework
86d08e4b743a37269790482a516936e63f4e881b.json
add `dropConstrainedForeignId` method (#34806)
tests/Database/DatabaseSqlServerSchemaGrammarTest.php
@@ -176,6 +176,17 @@ public function testDropForeign() $this->assertSame('alter table "users" drop constraint "foo"', $statements[0]); } + public function testdropConstrainedForeignId() + { + $blueprint = new Blueprint('users'); + $blueprint->dropConstrainedForeignId('foo'); + $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); + + $this->assertCount(2, $statements); + $this->assertSame('alter table "users" drop constraint "users_foo_foreign"', $statements[0]); + $this->assertSame('DECLARE @sql NVARCHAR(MAX) = \'\';SELECT @sql += \'ALTER TABLE [dbo].[users] DROP CONSTRAINT \' + OBJECT_NAME([default_object_id]) + \';\' FROM SYS.COLUMNS WHERE [object_id] = OBJECT_ID(\'[dbo].[users]\') AND [name] in (\'foo\') AND [default_object_id] <> 0;EXEC(@sql);alter table "users" drop column "foo"', $statements[1]); + } + public function testDropTimestamps() { $blueprint = new Blueprint('users');
true
Other
laravel
framework
aa31b9c00fae5e08c25f150d92ccd6cd8f1b7130.json
Add expiry option for the lock
src/Illuminate/Queue/Middleware/PreventOverlappingJobs.php
@@ -6,6 +6,13 @@ class PreventOverlappingJobs { + /** + * The amount of time (in seconds) to expire the lock. + * + * @var int + */ + public $expiresAt; + /** * The key of the job. * @@ -24,15 +31,17 @@ class PreventOverlappingJobs * Create a new overlapping jobs middleware instance. * * @param string $key + * @param string $prefix * @param int $expiresAt * @param string $prefix * * @return void */ - public function __construct($key = '', $prefix = 'overlap:') + public function __construct($key = '', $prefix = 'overlap:', $expiresAt = 0) { $this->key = $key; $this->prefix = $prefix; + $this->expiresAt = $expiresAt; } /** @@ -44,7 +53,7 @@ public function __construct($key = '', $prefix = 'overlap:') */ public function handle($job, $next) { - $lock = app(Cache::class)->lock($this->getLockKey($job)); + $lock = app(Cache::class)->lock($this->getLockKey($job), $this->expiresAt); if ($lock->get()) { try { @@ -55,6 +64,19 @@ public function handle($job, $next) } } + /** + * Set the expiry (in seconds) of the lock key. + * + * @param int $expiresAt + * @return $this + */ + public function expireAt($expiresAt) + { + $this->expiresAt = $expiresAt; + + return $this; + } + /** * Set the prefix of the lock key. *
false
Other
laravel
framework
b960fd0d3d9e498219e21a88edc0fe18537c28ab.json
Update docblock and include strings (#34779)
src/Illuminate/Console/Scheduling/ManagesFrequencies.php
@@ -473,7 +473,7 @@ public function yearly() * Schedule the event to run yearly on a given month, day, and time. * * @param int $month - * @param int $dayOfMonth + * @param int|string $dayOfMonth * @param string $time * @return $this */
true
Other
laravel
framework
b960fd0d3d9e498219e21a88edc0fe18537c28ab.json
Update docblock and include strings (#34779)
tests/Console/Scheduling/FrequencyTest.php
@@ -169,7 +169,12 @@ public function testYearlyOn() $this->assertSame('8 15 5 4 *', $this->event->yearlyOn(4, 5, '15:08')->getExpression()); } - public function testYearlyOnTuesdays() + public function testYearlyOnMondaysOnly() + { + $this->assertSame('1 9 * 7 1', $this->event->mondays()->yearlyOn(7, '*', '09:01')->getExpression()); + } + + public function testYearlyOnTuesdaysAndDayOfMonth20() { $this->assertSame('1 9 20 7 2', $this->event->tuesdays()->yearlyOn(7, 20, '09:01')->getExpression()); }
true
Other
laravel
framework
4c6fa9c6b5b92c13415e89bfebf11818fca315a1.json
Apply fixes from StyleCI (#34751)
src/Illuminate/Console/Scheduling/ScheduleWorkCommand.php
@@ -4,7 +4,6 @@ use Illuminate\Console\Command; use Illuminate\Support\Carbon; -use Illuminate\Support\Str; use Symfony\Component\Process\Process; class ScheduleWorkCommand extends Command
false
Other
laravel
framework
278db36b876c0be206bf40cf66176a8cf562dcd8.json
Update param type (#34748)
src/Illuminate/Foundation/Console/stubs/cast.stub
@@ -25,7 +25,7 @@ class DummyClass implements CastsAttributes * * @param \Illuminate\Database\Eloquent\Model $model * @param string $key - * @param array $value + * @param mixed $value * @param array $attributes * @return mixed */
false
Other
laravel
framework
9245807f8a1132a30ce669513cf0e99e9e078267.json
fix collection wrapping
src/Illuminate/Database/Eloquent/Factories/BelongsToManyRelationship.php
@@ -3,6 +3,7 @@ namespace Illuminate\Database\Eloquent\Factories; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Collection; class BelongsToManyRelationship { @@ -50,7 +51,7 @@ public function __construct(Factory $factory, $pivot, $relationship) */ public function createFor(Model $model) { - $this->factory->create([], $model)->each(function ($attachable) use ($model) { + Collection::wrap($this->factory->create([], $model))->each(function ($attachable) use ($model) { $model->{$this->relationship}()->attach( $attachable, is_callable($this->pivot) ? call_user_func($this->pivot, $model) : $this->pivot
false
Other
laravel
framework
41305c1dd152824c3b48f7efae5f65a5a768ef2a.json
Apply fixes from StyleCI (#34732)
src/Illuminate/Database/Eloquent/Builder.php
@@ -906,7 +906,7 @@ protected function addTimestampsToUpsertValues(array $values) $columns = array_filter([ $this->model->getCreatedAtColumn(), - $this->model->getUpdatedAtColumn() + $this->model->getUpdatedAtColumn(), ]); foreach ($columns as $column) {
false
Other
laravel
framework
ec98e98f8609b3e56400829e5ebe108c45517037.json
Add missing Scheduler tests (#34723)
tests/Console/Scheduling/FrequencyTest.php
@@ -34,18 +34,36 @@ public function testEveryXMinutes() $this->assertSame('*/3 * * * *', $this->event->everyThreeMinutes()->getExpression()); $this->assertSame('*/4 * * * *', $this->event->everyFourMinutes()->getExpression()); $this->assertSame('*/5 * * * *', $this->event->everyFiveMinutes()->getExpression()); + $this->assertSame('*/10 * * * *', $this->event->everyTenMinutes()->getExpression()); + $this->assertSame('*/15 * * * *', $this->event->everyFifteenMinutes()->getExpression()); + $this->assertSame('0,30 * * * *', $this->event->everyThirtyMinutes()->getExpression()); } public function testDaily() { $this->assertSame('0 0 * * *', $this->event->daily()->getExpression()); } + public function testDailyAt() + { + $this->assertSame('8 13 * * *', $this->event->dailyAt('13:08')->getExpression()); + } + public function testTwiceDaily() { $this->assertSame('0 3,15 * * *', $this->event->twiceDaily(3, 15)->getExpression()); } + public function testWeekly() + { + $this->assertSame('0 0 * * 0', $this->event->weekly()->getExpression()); + } + + public function testWeeklyOn() + { + $this->assertSame('0 8 * * 1', $this->event->weeklyOn(1, '8:00')->getExpression()); + } + public function testOverrideWithHourly() { $this->assertSame('0 * * * *', $this->event->everyFiveMinutes()->hourly()->getExpression()); @@ -61,11 +79,21 @@ public function testHourly() $this->assertSame('0 */6 * * *', $this->event->everySixHours()->getExpression()); } + public function testMonthly() + { + $this->assertSame('0 0 1 * *', $this->event->monthly()->getExpression()); + } + public function testMonthlyOn() { $this->assertSame('0 15 4 * *', $this->event->monthlyOn(4, '15:00')->getExpression()); } + public function testLastDayOfMonth() + { + $this->assertSame('0 0 31 * *', $this->event->lastDayOfMonth()->getExpression()); + } + public function testTwiceMonthly() { $this->assertSame('0 0 1,16 * *', $this->event->twiceMonthly(1, 16)->getExpression()); @@ -131,6 +159,11 @@ public function testQuarterly() $this->assertSame('0 0 1 1-12/3 *', $this->event->quarterly()->getExpression()); } + public function testYearly() + { + $this->assertSame('0 0 1 1 *', $this->event->yearly()->getExpression()); + } + public function testFrequencyMacro() { Event::macro('everyXMinutes', function ($x) {
false
Other
laravel
framework
12d6a4e12ca23f63ab7852bfb052ba5c257f1fb1.json
add dropColumns method on the schema class
src/Illuminate/Database/Schema/Builder.php
@@ -415,7 +415,7 @@ public function blueprintResolver(Closure $resolver) */ public function dropColumns($table, $columns) { - $this->table($table, function (Blueprint $blueprint) use ($table, $columns) { + $this->table($table, function (Blueprint $blueprint) use ($columns) { $blueprint->dropColumn($columns); }); }
false
Other
laravel
framework
fc600c4594f0122be5f455cbeb908d1af8373ffd.json
add dropColumns method on the schema class
src/Illuminate/Database/Schema/Builder.php
@@ -405,4 +405,18 @@ public function blueprintResolver(Closure $resolver) { $this->resolver = $resolver; } + + /** + * Drop columns from a table schema. + * + * @param string $table + * @param string|array $columns + * @return void + */ + public function dropColumns($table, $columns) + { + $this->table($table, function (Blueprint $blueprint) use ($table, $columns) { + $blueprint->dropColumn($columns); + }); + } }
true
Other
laravel
framework
fc600c4594f0122be5f455cbeb908d1af8373ffd.json
add dropColumns method on the schema class
src/Illuminate/Support/Facades/Schema.php
@@ -12,6 +12,7 @@ * @method static \Illuminate\Database\Schema\Builder table(string $table, \Closure $callback) * @method static bool hasColumn(string $table, string $column) * @method static bool hasColumns(string $table, array $columns) + * @method static bool dropColumns(string $table, array $columns) * @method static bool hasTable(string $table) * @method static void defaultStringLength(int $length) * @method static void registerCustomDoctrineType(string $class, string $name, string $type)
true
Other
laravel
framework
338ffa625e4b16ccd3d3481371c9312a245fdc30.json
Add tests for upserts with update columns
tests/Database/DatabaseQueryBuilderTest.php
@@ -2211,6 +2211,29 @@ public function testUpsertMethod() $this->assertEquals(2, $result); } + public function testUpsertMethodWithUpdateColumns() + { + $builder = $this->getMySqlBuilder(); + $builder->getConnection()->shouldReceive('affectingStatement')->once()->with('insert into `users` (`email`, `name`) values (?, ?), (?, ?) on duplicate key update `name` = values(`name`)', ['foo', 'bar', 'foo2', 'bar2'])->andReturn(2); + $result = $builder->from('users')->upsert([['email' => 'foo', 'name' => 'bar'], ['name' => 'bar2', 'email' => 'foo2']], 'email', ['name']); + $this->assertEquals(2, $result); + + $builder = $this->getPostgresBuilder(); + $builder->getConnection()->shouldReceive('affectingStatement')->once()->with('insert into "users" ("email", "name") values (?, ?), (?, ?) on conflict ("email") do update set "name" = "excluded"."name"', ['foo', 'bar', 'foo2', 'bar2'])->andReturn(2); + $result = $builder->from('users')->upsert([['email' => 'foo', 'name' => 'bar'], ['name' => 'bar2', 'email' => 'foo2']], 'email', ['name']); + $this->assertEquals(2, $result); + + $builder = $this->getSQLiteBuilder(); + $builder->getConnection()->shouldReceive('affectingStatement')->once()->with('insert into "users" ("email", "name") values (?, ?), (?, ?) on conflict ("email") do update set "name" = "excluded"."name"', ['foo', 'bar', 'foo2', 'bar2'])->andReturn(2); + $result = $builder->from('users')->upsert([['email' => 'foo', 'name' => 'bar'], ['name' => 'bar2', 'email' => 'foo2']], 'email', ['name']); + $this->assertEquals(2, $result); + + $builder = $this->getSqlServerBuilder(); + $builder->getConnection()->shouldReceive('affectingStatement')->once()->with('merge [users] using (values (?, ?), (?, ?)) [laravel_source] ([email], [name]) on [laravel_source].[email] = [users].[email] when matched then update set [name] = [laravel_source].[name] when not matched then insert ([email], [name]) values ([email], [name])', ['foo', 'bar', 'foo2', 'bar2'])->andReturn(2); + $result = $builder->from('users')->upsert([['email' => 'foo', 'name' => 'bar'], ['name' => 'bar2', 'email' => 'foo2']], 'email', ['name']); + $this->assertEquals(2, $result); + } + public function testUpdateMethodWithJoins() { $builder = $this->getBuilder();
false
Other
laravel
framework
3722acdf4f53e27812fccce3596d6691efd47d0d.json
use FQN for throws tag
src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php
@@ -1112,7 +1112,8 @@ protected function isClassCastable($key) * * @param string $key * @return bool - * @throws InvalidCastException + * + * @throws \Illuminate\Database\Eloquent\InvalidCastException */ protected function isClassSerializable($key) {
false
Other
laravel
framework
524cf5b9c3700a5d50121f4e6448e08d81c62c1c.json
Update ListFailedCommand.php (#34696)
src/Illuminate/Queue/Console/ListFailedCommand.php
@@ -66,7 +66,7 @@ protected function parseFailedJob(array $failed) { $row = array_values(Arr::except($failed, ['payload', 'exception'])); - array_splice($row, 3, 0, $this->extractJobName($failed['payload'])); + array_splice($row, 3, 0, $this->extractJobName($failed['payload']) ?: ''); return $row; }
false
Other
laravel
framework
884dd4ab56848949fc25d15c3036981446953bd1.json
Add attachMany method to the PendingRequest.php With this method, we can attach multiple files instead of using `attach` for each file.
src/Illuminate/Http/Client/PendingRequest.php
@@ -200,6 +200,21 @@ public function attach($name, $contents, $filename = null, array $headers = []) return $this; } + + /** + * Attach multiple files to the request. Accepts an array containing arrays of files + * + * @param array $files + * @return $this + */ + public function attachMany(array $files) + { + foreach ($files as $file) { + $this->attach(...$file); + } + + return $this; + } /** * Indicate the request is a multi-part form request.
false
Other
laravel
framework
f00248acf69c35570326ba9a6870d8750ff6f23d.json
remove extra line
src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php
@@ -1107,7 +1107,6 @@ protected function isClassCastable($key) throw new InvalidCastException($this->getModel(), $key, $castType); } - /** * Determine if the key is serializable using a custom class. *
false
Other
laravel
framework
bd02d3df746d635cbe120a243083d98ac950ca60.json
Add attachMany method to the PendingRequest.php With this method, we can attach multiple files instead of using `attach` for each file.
src/Illuminate/Http/Client/PendingRequest.php
@@ -200,6 +200,21 @@ public function attach($name, $contents, $filename = null, array $headers = []) return $this; } + + /** + * Attach multiple files to the request. Accepts an array containing arrays of files + * + * @param array $files + * @return $this + */ + public function attachMany(array $files) + { + foreach ($files as $file) { + $this->attach(...$file); + } + + return $this; + } /** * Indicate the request is a multi-part form request.
false
Other
laravel
framework
093a6f8628d15914ebc0c3af8d0fc1dabe9373f6.json
Fix misordered assertEquals arguments (#34688)
tests/Auth/AuthAccessGateTest.php
@@ -672,7 +672,7 @@ public function testResponseReturnsResponseWhenAbilityDenied() $this->assertSame('Not allowed to view as it is not published.', $response->message()); $this->assertFalse($response->allowed()); $this->assertTrue($response->denied()); - $this->assertEquals($response->code(), 'unpublished'); + $this->assertEquals('unpublished', $response->code()); } public function testAuthorizeReturnsAnAllowedResponseForATruthyReturn()
true
Other
laravel
framework
093a6f8628d15914ebc0c3af8d0fc1dabe9373f6.json
Fix misordered assertEquals arguments (#34688)
tests/Auth/AuthorizeMiddlewareTest.php
@@ -87,7 +87,7 @@ public function testSimpleAbilityAuthorized() $response = $this->router->dispatch(Request::create('dashboard', 'GET')); - $this->assertEquals($response->content(), 'success'); + $this->assertEquals('success', $response->content()); } public function testSimpleAbilityWithStringParameter() @@ -105,7 +105,7 @@ public function testSimpleAbilityWithStringParameter() $response = $this->router->dispatch(Request::create('dashboard', 'GET')); - $this->assertEquals($response->content(), 'success'); + $this->assertEquals('success', $response->content()); } public function testSimpleAbilityWithNullParameter() @@ -154,10 +154,10 @@ public function testSimpleAbilityWithOptionalParameter() ]); $response = $this->router->dispatch(Request::create('posts/1/comments', 'GET')); - $this->assertEquals($response->content(), 'success'); + $this->assertEquals('success', $response->content()); $response = $this->router->dispatch(Request::create('comments', 'GET')); - $this->assertEquals($response->content(), 'success'); + $this->assertEquals('success', $response->content()); } public function testSimpleAbilityWithStringParameterFromRouteParameter() @@ -175,7 +175,7 @@ public function testSimpleAbilityWithStringParameterFromRouteParameter() $response = $this->router->dispatch(Request::create('dashboard/true', 'GET')); - $this->assertEquals($response->content(), 'success'); + $this->assertEquals('success', $response->content()); } public function testModelTypeUnauthorized() @@ -184,7 +184,7 @@ public function testModelTypeUnauthorized() $this->expectExceptionMessage('This action is unauthorized.'); $this->gate()->define('create', function ($user, $model) { - $this->assertEquals($model, 'App\User'); + $this->assertEquals('App\User', $model); return false; }); @@ -202,7 +202,7 @@ public function testModelTypeUnauthorized() public function testModelTypeAuthorized() { $this->gate()->define('create', function ($user, $model) { - $this->assertEquals($model, 'App\User'); + $this->assertEquals('App\User', $model); return true; }); @@ -216,7 +216,7 @@ public function testModelTypeAuthorized() $response = $this->router->dispatch(Request::create('users/create', 'GET')); - $this->assertEquals($response->content(), 'success'); + $this->assertEquals('success', $response->content()); } public function testModelUnauthorized() @@ -269,7 +269,7 @@ public function testModelAuthorized() $response = $this->router->dispatch(Request::create('posts/1/edit', 'GET')); - $this->assertEquals($response->content(), 'success'); + $this->assertEquals('success', $response->content()); } public function testModelInstanceAsParameter()
true
Other
laravel
framework
093a6f8628d15914ebc0c3af8d0fc1dabe9373f6.json
Fix misordered assertEquals arguments (#34688)
tests/Cache/CacheRepositoryTest.php
@@ -240,7 +240,7 @@ public function testRegisterMacroWithNonStaticCall() $repo::macro(__CLASS__, function () { return 'Taylor'; }); - $this->assertEquals($repo->{__CLASS__}(), 'Taylor'); + $this->assertEquals('Taylor', $repo->{__CLASS__}()); } public function testForgettingCacheKey()
true
Other
laravel
framework
093a6f8628d15914ebc0c3af8d0fc1dabe9373f6.json
Fix misordered assertEquals arguments (#34688)
tests/Container/ContainerTest.php
@@ -398,7 +398,7 @@ public function testGetAlias() { $container = new Container; $container->alias('ConcreteStub', 'foo'); - $this->assertEquals($container->getAlias('foo'), 'ConcreteStub'); + $this->assertEquals('ConcreteStub', $container->getAlias('foo')); } public function testItThrowsExceptionWhenAbstractIsSameAsAlias()
true
Other
laravel
framework
093a6f8628d15914ebc0c3af8d0fc1dabe9373f6.json
Fix misordered assertEquals arguments (#34688)
tests/Database/DatabaseEloquentIntegrationTest.php
@@ -352,7 +352,7 @@ public function testUpdateOrCreate() ); $this->assertSame('Mohamed Said', $user3->name); - $this->assertEquals(EloquentTestUser::count(), 2); + $this->assertEquals(2, EloquentTestUser::count()); } public function testUpdateOrCreateOnDifferentConnection() @@ -369,8 +369,8 @@ public function testUpdateOrCreateOnDifferentConnection() ['name' => 'Mohamed Said'] ); - $this->assertEquals(EloquentTestUser::count(), 1); - $this->assertEquals(EloquentTestUser::on('second_connection')->count(), 2); + $this->assertEquals(1, EloquentTestUser::count()); + $this->assertEquals(2, EloquentTestUser::on('second_connection')->count()); } public function testCheckAndCreateMethodsOnMultiConnections() @@ -1220,8 +1220,8 @@ public function testEagerLoadedMorphToRelationsOnAnotherDatabaseConnection() $defaultConnectionPost = EloquentTestPhoto::with('imageable')->first()->imageable; $secondConnectionPost = EloquentTestPhoto::on('second_connection')->with('imageable')->first()->imageable; - $this->assertEquals($defaultConnectionPost->name, 'Default Connection Post'); - $this->assertEquals($secondConnectionPost->name, 'Second Connection Post'); + $this->assertEquals('Default Connection Post', $defaultConnectionPost->name); + $this->assertEquals('Second Connection Post', $secondConnectionPost->name); } public function testBelongsToManyCustomPivot()
true
Other
laravel
framework
093a6f8628d15914ebc0c3af8d0fc1dabe9373f6.json
Fix misordered assertEquals arguments (#34688)
tests/Database/DatabaseSchemaBuilderTest.php
@@ -53,6 +53,6 @@ public function testGetColumnTypeAddsPrefix() $column->shouldReceive('getType')->once()->andReturn($type); $type->shouldReceive('getName')->once()->andReturn('integer'); - $this->assertEquals($builder->getColumnType('users', 'id'), 'integer'); + $this->assertEquals('integer', $builder->getColumnType('users', 'id')); } }
true
Other
laravel
framework
093a6f8628d15914ebc0c3af8d0fc1dabe9373f6.json
Fix misordered assertEquals arguments (#34688)
tests/Events/EventsSubscriberTest.php
@@ -41,10 +41,10 @@ public function testEventSubscribeCanReturnMappings() $d->subscribe(DeclarativeSubscriber::class); $d->dispatch('myEvent1'); - $this->assertEquals(DeclarativeSubscriber::$string, 'L1_L2_'); + $this->assertEquals('L1_L2_', DeclarativeSubscriber::$string); $d->dispatch('myEvent2'); - $this->assertEquals(DeclarativeSubscriber::$string, 'L1_L2_L3'); + $this->assertEquals('L1_L2_L3', DeclarativeSubscriber::$string); } }
true
Other
laravel
framework
093a6f8628d15914ebc0c3af8d0fc1dabe9373f6.json
Fix misordered assertEquals arguments (#34688)
tests/Foundation/FoundationApplicationTest.php
@@ -145,7 +145,7 @@ public function testDeferredServiceDontRunWhenInstanceSet() $app->setDeferredServices(['foo' => ApplicationDeferredServiceProviderStub::class]); $app->instance('foo', 'bar'); $instance = $app->make('foo'); - $this->assertEquals($instance, 'bar'); + $this->assertEquals('bar', $instance); } public function testDeferredServicesAreLazilyInitialized() @@ -192,7 +192,7 @@ public function testDeferredServiceIsLoadedWhenAccessingImplementationThroughInt SampleImplementation::class => SampleImplementationDeferredServiceProvider::class, ]); $instance = $app->make(SampleInterface::class); - $this->assertEquals($instance->getPrimitive(), 'foo'); + $this->assertEquals('foo', $instance->getPrimitive()); } public function testEnvironment()
true
Other
laravel
framework
093a6f8628d15914ebc0c3af8d0fc1dabe9373f6.json
Fix misordered assertEquals arguments (#34688)
tests/Http/HttpRequestTest.php
@@ -1022,19 +1022,19 @@ public function testMagicMethods() $request = Request::create('/', 'GET', ['foo' => 'bar', 'empty' => '']); // Parameter 'foo' is 'bar', then it ISSET and is NOT EMPTY. - $this->assertEquals($request->foo, 'bar'); - $this->assertEquals(isset($request->foo), true); - $this->assertEquals(empty($request->foo), false); + $this->assertEquals('bar', $request->foo); + $this->assertEquals(true, isset($request->foo)); + $this->assertEquals(false, empty($request->foo)); // Parameter 'empty' is '', then it ISSET and is EMPTY. - $this->assertEquals($request->empty, ''); + $this->assertEquals('', $request->empty); $this->assertTrue(isset($request->empty)); $this->assertEmpty($request->empty); // Parameter 'undefined' is undefined/null, then it NOT ISSET and is EMPTY. - $this->assertEquals($request->undefined, null); - $this->assertEquals(isset($request->undefined), false); - $this->assertEquals(empty($request->undefined), true); + $this->assertEquals(null, $request->undefined); + $this->assertEquals(false, isset($request->undefined)); + $this->assertEquals(true, empty($request->undefined)); // Simulates Route parameters. $request = Request::create('/example/bar', 'GET', ['xyz' => 'overwritten']); @@ -1048,19 +1048,19 @@ public function testMagicMethods() // Router parameter 'foo' is 'bar', then it ISSET and is NOT EMPTY. $this->assertSame('bar', $request->foo); $this->assertSame('bar', $request['foo']); - $this->assertEquals(isset($request->foo), true); - $this->assertEquals(empty($request->foo), false); + $this->assertEquals(true, isset($request->foo)); + $this->assertEquals(false, empty($request->foo)); // Router parameter 'undefined' is undefined/null, then it NOT ISSET and is EMPTY. - $this->assertEquals($request->undefined, null); - $this->assertEquals(isset($request->undefined), false); - $this->assertEquals(empty($request->undefined), true); + $this->assertEquals(null, $request->undefined); + $this->assertEquals(false, isset($request->undefined)); + $this->assertEquals(true, empty($request->undefined)); // Special case: router parameter 'xyz' is 'overwritten' by QueryString, then it ISSET and is NOT EMPTY. // Basically, QueryStrings have priority over router parameters. - $this->assertEquals($request->xyz, 'overwritten'); - $this->assertEquals(isset($request->foo), true); - $this->assertEquals(empty($request->foo), false); + $this->assertEquals('overwritten', $request->xyz); + $this->assertEquals(true, isset($request->foo)); + $this->assertEquals(false, empty($request->foo)); // Simulates empty QueryString and Routes. $request = Request::create('/', 'GET'); @@ -1072,18 +1072,18 @@ public function testMagicMethods() }); // Parameter 'undefined' is undefined/null, then it NOT ISSET and is EMPTY. - $this->assertEquals($request->undefined, null); - $this->assertEquals(isset($request->undefined), false); - $this->assertEquals(empty($request->undefined), true); + $this->assertEquals(null, $request->undefined); + $this->assertEquals(false, isset($request->undefined)); + $this->assertEquals(true, empty($request->undefined)); // Special case: simulates empty QueryString and Routes, without the Route Resolver. // It'll happen when you try to get a parameter outside a route. $request = Request::create('/', 'GET'); // Parameter 'undefined' is undefined/null, then it NOT ISSET and is EMPTY. - $this->assertEquals($request->undefined, null); - $this->assertEquals(isset($request->undefined), false); - $this->assertEquals(empty($request->undefined), true); + $this->assertEquals(null, $request->undefined); + $this->assertEquals(false, isset($request->undefined)); + $this->assertEquals(true, empty($request->undefined)); } public function testHttpRequestFlashCallsSessionFlashInputWithInputData()
true
Other
laravel
framework
093a6f8628d15914ebc0c3af8d0fc1dabe9373f6.json
Fix misordered assertEquals arguments (#34688)
tests/Integration/Foundation/FoundationHelpersTest.php
@@ -15,19 +15,28 @@ class FoundationHelpersTest extends TestCase { public function testRescue() { - $this->assertEquals(rescue(function () { - throw new Exception; - }, 'rescued!'), 'rescued!'); - - $this->assertEquals(rescue(function () { - throw new Exception; - }, function () { - return 'rescued!'; - }), 'rescued!'); - - $this->assertEquals(rescue(function () { - return 'no need to rescue'; - }, 'rescued!'), 'no need to rescue'); + $this->assertEquals( + 'rescued!', + rescue(function () { + throw new Exception; + }, 'rescued!') + ); + + $this->assertEquals( + 'rescued!', + rescue(function () { + throw new Exception; + }, function () { + return 'rescued!'; + }) + ); + + $this->assertEquals( + 'no need to rescue', + rescue(function () { + return 'no need to rescue'; + }, 'rescued!') + ); $testClass = new class { public function test(int $a) @@ -36,9 +45,12 @@ public function test(int $a) } }; - $this->assertEquals(rescue(function () use ($testClass) { - $testClass->test([]); - }, 'rescued!'), 'rescued!'); + $this->assertEquals( + 'rescued!', + rescue(function () use ($testClass) { + $testClass->test([]); + }, 'rescued!') + ); } public function testMixReportsExceptionWhenAssetIsMissingFromManifest()
true
Other
laravel
framework
093a6f8628d15914ebc0c3af8d0fc1dabe9373f6.json
Fix misordered assertEquals arguments (#34688)
tests/Queue/QueueSqsQueueTest.php
@@ -127,7 +127,7 @@ public function testSizeProperlyReadsSqsQueueSize() $queue->expects($this->once())->method('getQueue')->with($this->queueName)->willReturn($this->queueUrl); $this->sqs->shouldReceive('getQueueAttributes')->once()->with(['QueueUrl' => $this->queueUrl, 'AttributeNames' => ['ApproximateNumberOfMessages']])->andReturn($this->mockedQueueAttributesResponseModel); $size = $queue->size($this->queueName); - $this->assertEquals($size, 1); + $this->assertEquals(1, $size); } public function testGetQueueProperlyResolvesUrlWithPrefix()
true
Other
laravel
framework
093a6f8628d15914ebc0c3af8d0fc1dabe9373f6.json
Fix misordered assertEquals arguments (#34688)
tests/Session/SessionStoreTest.php
@@ -433,7 +433,7 @@ public function testName() $session = $this->getSession(); $this->assertEquals($session->getName(), $this->getSessionName()); $session->setName('foo'); - $this->assertEquals($session->getName(), 'foo'); + $this->assertEquals('foo', $session->getName()); } public function testKeyExists()
true
Other
laravel
framework
093a6f8628d15914ebc0c3af8d0fc1dabe9373f6.json
Fix misordered assertEquals arguments (#34688)
tests/Support/SupportArrTest.php
@@ -110,7 +110,7 @@ public function testDot() $this->assertEquals(['foo.bar' => []], $array); $array = Arr::dot(['name' => 'taylor', 'languages' => ['php' => true]]); - $this->assertEquals($array, ['name' => 'taylor', 'languages.php' => true]); + $this->assertEquals(['name' => 'taylor', 'languages.php' => true], $array); } public function testExcept()
true
Other
laravel
framework
093a6f8628d15914ebc0c3af8d0fc1dabe9373f6.json
Fix misordered assertEquals arguments (#34688)
tests/Support/SupportFluentTest.php
@@ -64,7 +64,7 @@ public function testArrayAccessToAttributes() $fluent = new Fluent(['attributes' => '1']); $this->assertTrue(isset($fluent['attributes'])); - $this->assertEquals($fluent['attributes'], 1); + $this->assertEquals(1, $fluent['attributes']); $fluent->attributes();
true
Other
laravel
framework
093a6f8628d15914ebc0c3af8d0fc1dabe9373f6.json
Fix misordered assertEquals arguments (#34688)
tests/Validation/ValidationFactoryTest.php
@@ -73,7 +73,7 @@ public function testValidateCallsValidateOnTheValidator() ['foo' => 'required'] ); - $this->assertEquals($validated, ['foo' => 'bar']); + $this->assertEquals(['foo' => 'bar'], $validated); } public function testCustomResolverIsCalled()
true
Other
laravel
framework
093a6f8628d15914ebc0c3af8d0fc1dabe9373f6.json
Fix misordered assertEquals arguments (#34688)
tests/Validation/ValidationValidatorTest.php
@@ -4665,10 +4665,13 @@ public function testInvalidMethod() '*.name' => 'required', ]); - $this->assertEquals($v->invalid(), [ - 1 => ['name' => null], - 2 => ['name' => ''], - ]); + $this->assertEquals( + [ + 1 => ['name' => null], + 2 => ['name' => ''], + ], + $v->invalid() + ); $v = new Validator($trans, [ @@ -4678,9 +4681,12 @@ public function testInvalidMethod() 'name' => 'required', ]); - $this->assertEquals($v->invalid(), [ - 'name' => '', - ]); + $this->assertEquals( + [ + 'name' => '', + ], + $v->invalid() + ); } public function testValidMethod() @@ -4698,10 +4704,13 @@ public function testValidMethod() '*.name' => 'required', ]); - $this->assertEquals($v->valid(), [ - 0 => ['name' => 'John'], - 3 => ['name' => 'Doe'], - ]); + $this->assertEquals( + [ + 0 => ['name' => 'John'], + 3 => ['name' => 'Doe'], + ], + $v->valid() + ); $v = new Validator($trans, [ @@ -4715,10 +4724,13 @@ public function testValidMethod() 'age' => 'required|int', ]); - $this->assertEquals($v->valid(), [ - 'name' => 'Carlos', - 'gender' => 'male', - ]); + $this->assertEquals( + [ + 'name' => 'Carlos', + 'gender' => 'male', + ], + $v->valid() + ); } public function testNestedInvalidMethod() @@ -4741,12 +4753,15 @@ public function testNestedInvalidMethod() 'regex:/[A-F]{3}[0-9]{3}/', ], ]); - $this->assertEquals($v->invalid(), [ - 'testinvalid' => '', - 'records' => [ - 3 => 'ADCD23', + $this->assertEquals( + [ + 'testinvalid' => '', + 'records' => [ + 3 => 'ADCD23', + ], ], - ]); + $v->invalid() + ); } public function testMultipleFileUploads()
true
Other
laravel
framework
0612709ac926414342a4d982fdfd8dca024d4abb.json
Apply fixes from StyleCI (#34684)
src/Illuminate/View/Compilers/Concerns/CompilesLayouts.php
@@ -29,7 +29,7 @@ protected function compileExtends($expression) return ''; } - + /** * Compile the extends-first statements into valid PHP. *
false
Other
laravel
framework
ea3f1e3e456843fb5b0c5cc67c86c2fe3d87b861.json
Apply fixes from StyleCI (#34682)
src/Illuminate/Pagination/AbstractPaginator.php
@@ -346,7 +346,7 @@ public function through(callable $callback) $this->items->transform($callback); return $this; - } + } /** * Get the number of items shown per page.
false
Other
laravel
framework
b2a36411a774dba218fa312b8fd3bcf4be44a4e5.json
Fix breaking change
src/Illuminate/Database/Console/Migrations/MigrateCommand.php
@@ -164,6 +164,14 @@ protected function loadSchemaState() */ protected function schemaPath($connection) { - return $this->option('schema-path') ?: database_path('schema/'.$connection->getName().'-schema.dump'); + if ($this->option('schema-path')) { + return $this->option('schema-path'); + } + + if (file_exists($path = database_path('schema/'.$connection->getName().'-schema.dump'))) { + return $path; + } + + return database_path('schema/'.$connection->getName().'-schema.sql'); } }
false
Other
laravel
framework
eb4f30763780089289f54aad916b79bfb53d7a50.json
Remove unused use statements Signed-off-by: Kevin Ullyott <ullyott.kevin@gmail.com>
tests/Bus/BusBatchTest.php
@@ -16,8 +16,6 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\CallQueuedClosure; -use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Queue\SerializesModels; use Mockery as m; use PHPUnit\Framework\TestCase; use RuntimeException;
false
Other
laravel
framework
71745f4f9d3e14f240a32ebffcddf379f807926e.json
Use test job classes to fix seralization issue Signed-off-by: Kevin Ullyott <ullyott.kevin@gmail.com>
tests/Bus/BusBatchTest.php
@@ -311,17 +311,11 @@ public function test_chain_can_be_added_to_batch() $batch = $this->createTestBatch($queue); - $chainHeadJob = new class implements ShouldQueue { - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, Batchable; - }; + $chainHeadJob = new ChainHeadJob(); - $secondJob = new class implements ShouldQueue { - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, Batchable; - }; + $secondJob = new SecondTestJob(); - $thirdJob = new class implements ShouldQueue { - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, Batchable; - }; + $thirdJob = new ThirdTestJob(); $queue->shouldReceive('connection')->once() ->with('test-connection') @@ -391,3 +385,18 @@ protected function schema() return $this->connection()->getSchemaBuilder(); } } + +class ChainHeadJob implements ShouldQueue +{ + use Dispatchable, Queueable, Batchable; +} + +class SecondTestJob implements ShouldQueue +{ + use Dispatchable, Queueable, Batchable; +} + +class ThirdTestJob implements ShouldQueue +{ + use Dispatchable, Queueable, Batchable; +}
false
Other
laravel
framework
d590d78dc286c88fcf38588f3e0f1d4fbcc45989.json
add doc blocks
src/Illuminate/View/AppendableAttributeValue.php
@@ -4,8 +4,19 @@ class AppendableAttributeValue { + /** + * The attribute value. + * + * @var mixed + */ public $value; + /** + * Create a new appendable attribute value. + * + * @param mixed $value + * @return void + */ public function __construct($value) { $this->value = $value;
false
Other
laravel
framework
09b887b85614d3e2539e74f40d7aa9c1c9f903d3.json
add support for appendable component attributes
src/Illuminate/View/AppendableAttributeValue.php
@@ -0,0 +1,13 @@ +<?php + +namespace Illuminate\View; + +class AppendableAttributeValue +{ + public $value; + + public function __construct($value) + { + $this->value = $value; + } +}
true
Other
laravel
framework
09b887b85614d3e2539e74f40d7aa9c1c9f903d3.json
add support for appendable component attributes
src/Illuminate/View/ComponentAttributeBag.php
@@ -171,31 +171,76 @@ public function exceptProps($keys) */ public function merge(array $attributeDefaults = [], $escape = true) { - $attributes = []; - $attributeDefaults = array_map(function ($value) use ($escape) { - if (! $escape || is_object($value) || is_null($value) || is_bool($value)) { - return $value; - } - - return e($value); + return $this->shouldEscapeAttributeValue($escape, $value) + ? e($value) + : $value; }, $attributeDefaults); - foreach ($this->attributes as $key => $value) { - if ($key !== 'class') { - $attributes[$key] = $value; + [$appendableAttributes, $nonAppendableAttributes] = collect($this->attributes) + ->partition(function ($value, $key) use ($attributeDefaults) { + return $key === 'class' || + (isset($attributeDefaults[$key]) && + $attributeDefaults[$key] instanceof AppendableAttributeValue); + }); - continue; - } + $attributes = $appendableAttributes->mapWithKeys(function ($value, $key) use ($attributeDefaults, $escape) { + $defaultsValue = isset($attributeDefaults[$key]) && $attributeDefaults[$key] instanceof AppendableAttributeValue + ? $this->resolveAppendableAttributeDefault($attributeDefaults, $key, $escape) + : ($attributeDefaults[$key] ?? ''); - $attributes[$key] = implode(' ', array_unique( - array_filter([$attributeDefaults[$key] ?? '', $value]) - )); - } + return [$key => implode(' ', array_unique(array_filter([$defaultsValue, $value])))]; + })->merge($nonAppendableAttributes)->all(); return new static(array_merge($attributeDefaults, $attributes)); } + /** + * Determine if the specific attribute value should be escaped. + * + * @param bool $escape + * @param mixed $value + * @return bool + */ + protected function shouldEscapeAttributeValue($escape, $value) + { + if (! $escape) { + return false; + } + + return ! is_object($value) && + ! is_null($value) && + ! is_bool($value); + } + + /** + * Create a new appendable attribute value. + * + * @param mixed $value + * @return \Illuminate\View\AppendableAttributeValue + */ + public function appends($value) + { + return new AppendableAttributeValue($value); + } + + /** + * Resolve an appendable attribute value default value. + * + * @param array $attributeDefaults + * @param string $key + * @param bool $escape + * @return mixed + */ + protected function resolveAppendableAttributeDefault($attributeDefaults, $key, $escape) + { + if ($this->shouldEscapeAttributeValue($escape, $value = $attributeDefaults[$key]->value)) { + $value = e($value); + } + + return $value; + } + /** * Get all of the raw attributes. *
true
Other
laravel
framework
09b887b85614d3e2539e74f40d7aa9c1c9f903d3.json
add support for appendable component attributes
tests/Integration/View/BladeTest.php
@@ -48,6 +48,15 @@ public function test_rendering_the_same_dynamic_component_with_different_attribu </span>', trim($view)); } + public function test_appendable_attributes() + { + $view = View::make('uses-appendable-panel', ['name' => 'Taylor'])->render(); + + $this->assertEquals('<div class="mt-4 bg-gray-100" data-controller="inside-controller outside-controller" foo="bar"> + Hello Taylor +</div>', trim($view)); + } + protected function getEnvironmentSetUp($app) { $app['config']->set('view.paths', [__DIR__.'/templates']);
true
Other
laravel
framework
09b887b85614d3e2539e74f40d7aa9c1c9f903d3.json
add support for appendable component attributes
tests/Integration/View/templates/components/appendable-panel.blade.php
@@ -0,0 +1,5 @@ +@props(['name']) + +<div {{ $attributes->merge(['class' => 'mt-4', 'data-controller' => $attributes->appends('inside-controller')]) }}> + Hello {{ $name }} +</div>
true
Other
laravel
framework
09b887b85614d3e2539e74f40d7aa9c1c9f903d3.json
add support for appendable component attributes
tests/Integration/View/templates/uses-appendable-panel.blade.php
@@ -0,0 +1,3 @@ +<x-appendable-panel class="bg-gray-100" :name="$name" data-controller="outside-controller" foo="bar"> + Panel contents +</x-appendable-panel>
true
Other
laravel
framework
77676a28826edb3a748ee8981ea9cf8499d4fd75.json
Create a test that a chain can be added Signed-off-by: Kevin Ullyott <ullyott.kevin@gmail.com>
tests/Bus/BusBatchTest.php
@@ -8,11 +8,16 @@ use Illuminate\Bus\BatchFactory; use Illuminate\Bus\DatabaseBatchRepository; use Illuminate\Bus\PendingBatch; +use Illuminate\Bus\Queueable; use Illuminate\Container\Container; use Illuminate\Contracts\Queue\Factory; +use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Database\Capsule\Manager as DB; use Illuminate\Database\Eloquent\Model; +use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\CallQueuedClosure; +use Illuminate\Queue\InteractsWithQueue; +use Illuminate\Queue\SerializesModels; use Mockery as m; use PHPUnit\Framework\TestCase; use RuntimeException; @@ -300,6 +305,47 @@ public function test_batch_state_can_be_inspected() $this->assertTrue(is_string(json_encode($batch))); } + public function test_chain_can_be_added_to_batch() + { + $queue = m::mock(Factory::class); + + $batch = $this->createTestBatch($queue); + + $chainHeadJob = new class implements ShouldQueue { + use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, Batchable; + }; + + $secondJob = new class implements ShouldQueue { + use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, Batchable; + }; + + $thirdJob = new class implements ShouldQueue { + use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, Batchable; + }; + + $queue->shouldReceive('connection')->once() + ->with('test-connection') + ->andReturn($connection = m::mock(stdClass::class)); + + $connection->shouldReceive('bulk')->once()->with(\Mockery::on(function ($args) use ($chainHeadJob, $secondJob, $thirdJob) { + return + $args[0] == $chainHeadJob + && serialize($secondJob) == $args[0]->chained[0] + && serialize($thirdJob) == $args[0]->chained[1]; + }), '', 'test-queue'); + + $batch = $batch->add([ + [$chainHeadJob, $secondJob, $thirdJob] + ]); + + $this->assertEquals(3, $batch->totalJobs); + $this->assertEquals(3, $batch->pendingJobs); + $this->assertTrue(is_string($chainHeadJob->batchId)); + $this->assertTrue(is_string($secondJob->batchId)); + $this->assertTrue(is_string($thirdJob->batchId)); + $this->assertInstanceOf(CarbonImmutable::class, $batch->createdAt); + } + protected function createTestBatch($queue, $allowFailures = false) { $repository = new DatabaseBatchRepository(new BatchFactory($queue), DB::connection(), 'job_batches');
false
Other
laravel
framework
adbaf16c2ecea1ed7be657e3f1c4c9f8d77849ca.json
Add withUserAgent to HTTP client (#34611)
src/Illuminate/Http/Client/PendingRequest.php
@@ -341,6 +341,17 @@ public function withoutRedirecting() }); } + /** + * Specify the user agent for the request. + * + * @param string $userAgent + * @return $this + */ + public function withUserAgent($userAgent) + { + return $this->withHeaders(['User-Agent' => $userAgent]); + } + /** * Indicate that TLS certificates should not be verified. *
true
Other
laravel
framework
adbaf16c2ecea1ed7be657e3f1c4c9f8d77849ca.json
Add withUserAgent to HTTP client (#34611)
tests/Http/HttpClientTest.php
@@ -237,6 +237,18 @@ public function testItCanSendToken() }); } + public function testItCanSendUserAgent() + { + $this->factory->fake(); + + $this->factory->withUserAgent('Laravel')->post('http://foo.com/json'); + + $this->factory->assertSent(function (Request $request) { + return $request->url() === 'http://foo.com/json' && + $request->hasHeader('User-Agent', 'Laravel'); + }); + } + public function testSequenceBuilder() { $this->factory->fake([
true
Other
laravel
framework
cfef0246e490b86289893833f0e15cb6f2ec240a.json
Use stricter assertions. (#34595)
tests/Bus/BusBatchTest.php
@@ -198,7 +198,7 @@ public function test_failed_jobs_can_be_recorded_while_not_allowing_failures() $this->assertTrue($batch->cancelled()); $this->assertEquals(1, $_SERVER['__finally.count']); $this->assertEquals(1, $_SERVER['__catch.count']); - $this->assertEquals('Something went wrong.', $_SERVER['__catch.exception']->getMessage()); + $this->assertSame('Something went wrong.', $_SERVER['__catch.exception']->getMessage()); } public function test_failed_jobs_can_be_recorded_while_allowing_failures() @@ -236,7 +236,7 @@ public function test_failed_jobs_can_be_recorded_while_allowing_failures() $this->assertFalse($batch->finished()); $this->assertFalse($batch->cancelled()); $this->assertEquals(1, $_SERVER['__catch.count']); - $this->assertEquals('Something went wrong.', $_SERVER['__catch.exception']->getMessage()); + $this->assertSame('Something went wrong.', $_SERVER['__catch.exception']->getMessage()); } public function test_batch_can_be_cancelled()
true
Other
laravel
framework
cfef0246e490b86289893833f0e15cb6f2ec240a.json
Use stricter assertions. (#34595)
tests/Bus/BusBatchableTest.php
@@ -22,15 +22,15 @@ public function test_batch_may_be_retrieved() }; $this->assertSame($class, $class->withBatchId('test-batch-id')); - $this->assertEquals('test-batch-id', $class->batchId); + $this->assertSame('test-batch-id', $class->batchId); Container::setInstance($container = new Container); $repository = m::mock(BatchRepository::class); $repository->shouldReceive('find')->once()->with('test-batch-id')->andReturn('test-batch'); $container->instance(BatchRepository::class, $repository); - $this->assertEquals('test-batch', $class->batch()); + $this->assertSame('test-batch', $class->batch()); Container::setInstance(null); }
true
Other
laravel
framework
cfef0246e490b86289893833f0e15cb6f2ec240a.json
Use stricter assertions. (#34595)
tests/Bus/BusPendingBatchTest.php
@@ -40,8 +40,8 @@ public function test_pending_batch_may_be_configured_and_dispatched() // })->allowFailures()->onConnection('test-connection')->onQueue('test-queue'); - $this->assertEquals('test-connection', $pendingBatch->connection()); - $this->assertEquals('test-queue', $pendingBatch->queue()); + $this->assertSame('test-connection', $pendingBatch->connection()); + $this->assertSame('test-queue', $pendingBatch->queue()); $this->assertCount(1, $pendingBatch->thenCallbacks()); $this->assertCount(1, $pendingBatch->catchCallbacks());
true
Other
laravel
framework
cfef0246e490b86289893833f0e15cb6f2ec240a.json
Use stricter assertions. (#34595)
tests/Database/DatabaseEloquentFactoryTest.php
@@ -94,7 +94,7 @@ public function test_basic_model_can_be_created() $user = FactoryTestUserFactory::new()->create(['name' => 'Taylor Otwell']); $this->assertInstanceOf(Eloquent::class, $user); - $this->assertEquals('Taylor Otwell', $user->name); + $this->assertSame('Taylor Otwell', $user->name); $users = FactoryTestUserFactory::new()->createMany([ ['name' => 'Taylor Otwell'], @@ -118,7 +118,7 @@ public function test_expanded_closure_attributes_are_resolved_and_passed_to_clos }, ]); - $this->assertEquals('taylor-options', $user->options); + $this->assertSame('taylor-options', $user->options); } public function test_make_creates_unpersisted_model_instance() @@ -129,7 +129,7 @@ public function test_make_creates_unpersisted_model_instance() $user = FactoryTestUserFactory::new()->make(['name' => 'Taylor Otwell']); $this->assertInstanceOf(Eloquent::class, $user); - $this->assertEquals('Taylor Otwell', $user->name); + $this->assertSame('Taylor Otwell', $user->name); $this->assertCount(0, FactoryTestUser::all()); } @@ -140,7 +140,7 @@ public function test_basic_model_attributes_can_be_created() $user = FactoryTestUserFactory::new()->raw(['name' => 'Taylor Otwell']); $this->assertIsArray($user); - $this->assertEquals('Taylor Otwell', $user['name']); + $this->assertSame('Taylor Otwell', $user['name']); } public function test_expanded_model_attributes_can_be_created() @@ -151,7 +151,7 @@ public function test_expanded_model_attributes_can_be_created() $post = FactoryTestPostFactory::new()->raw(['title' => 'Test Title']); $this->assertIsArray($post); $this->assertIsInt($post['user_id']); - $this->assertEquals('Test Title', $post['title']); + $this->assertSame('Test Title', $post['title']); } public function test_after_creating_and_making_callbacks_are_called() @@ -225,7 +225,7 @@ public function test_morph_to_relationship() ->for(FactoryTestPostFactory::new(['title' => 'Test Title']), 'commentable') ->create(); - $this->assertEquals('Test Title', FactoryTestPost::first()->title); + $this->assertSame('Test Title', FactoryTestPost::first()->title); $this->assertCount(3, FactoryTestPost::first()->comments); $this->assertCount(1, FactoryTestPost::all()); @@ -250,7 +250,7 @@ public function test_belongs_to_many_relationship() $user = FactoryTestUser::latest()->first(); $this->assertCount(3, $user->roles); - $this->assertEquals('Y', $user->roles->first()->pivot->admin); + $this->assertSame('Y', $user->roles->first()->pivot->admin); $this->assertInstanceOf(Eloquent::class, $_SERVER['__test.role.creating-role']); $this->assertInstanceOf(Eloquent::class, $_SERVER['__test.role.creating-user']); @@ -266,8 +266,8 @@ public function test_sequences() ['name' => 'Abigail Otwell'], )->create(); - $this->assertEquals('Taylor Otwell', $users[0]->name); - $this->assertEquals('Abigail Otwell', $users[1]->name); + $this->assertSame('Taylor Otwell', $users[0]->name); + $this->assertSame('Abigail Otwell', $users[1]->name); $user = FactoryTestUserFactory::new() ->hasAttached( @@ -329,7 +329,7 @@ public function test_dynamic_has_and_for_methods() ->create(); $this->assertInstanceOf(FactoryTestUser::class, $post->author); - $this->assertEquals('Taylor Otwell', $post->author->name); + $this->assertSame('Taylor Otwell', $post->author->name); $this->assertCount(2, $post->comments); }
true
Other
laravel
framework
cfef0246e490b86289893833f0e15cb6f2ec240a.json
Use stricter assertions. (#34595)
tests/Database/DatabaseEloquentModelTest.php
@@ -67,7 +67,7 @@ public function testAttributeManipulation() $model->list_items = ['name' => 'taylor']; $this->assertEquals(['name' => 'taylor'], $model->list_items); $attributes = $model->getAttributes(); - $this->assertEquals(json_encode(['name' => 'taylor']), $attributes['list_items']); + $this->assertSame(json_encode(['name' => 'taylor']), $attributes['list_items']); } public function testSetAttributeWithNumericKey()
true
Other
laravel
framework
cfef0246e490b86289893833f0e15cb6f2ec240a.json
Use stricter assertions. (#34595)
tests/Database/DatabaseEloquentPivotTest.php
@@ -161,13 +161,13 @@ public function testWithoutRelations() $original->pivotParent = 'foo'; $original->setRelation('bar', 'baz'); - $this->assertEquals('baz', $original->getRelation('bar')); + $this->assertSame('baz', $original->getRelation('bar')); $pivot = $original->withoutRelations(); $this->assertInstanceOf(Pivot::class, $pivot); $this->assertNotSame($pivot, $original); - $this->assertEquals('foo', $original->pivotParent); + $this->assertSame('foo', $original->pivotParent); $this->assertNull($pivot->pivotParent); $this->assertTrue($original->relationLoaded('bar')); $this->assertFalse($pivot->relationLoaded('bar'));
true
Other
laravel
framework
cfef0246e490b86289893833f0e15cb6f2ec240a.json
Use stricter assertions. (#34595)
tests/Database/DatabaseQueryBuilderTest.php
@@ -3077,12 +3077,12 @@ public function testSubSelectResetBindings() $query->from('two')->select('baz')->where('subkey', '=', 'subval'); }, 'sub'); - $this->assertEquals('select (select "baz" from "two" where "subkey" = ?) as "sub" from "one"', $builder->toSql()); + $this->assertSame('select (select "baz" from "two" where "subkey" = ?) as "sub" from "one"', $builder->toSql()); $this->assertEquals(['subval'], $builder->getBindings()); $builder->select('*'); - $this->assertEquals('select * from "one"', $builder->toSql()); + $this->assertSame('select * from "one"', $builder->toSql()); $this->assertEquals([], $builder->getBindings()); }
true
Other
laravel
framework
cfef0246e490b86289893833f0e15cb6f2ec240a.json
Use stricter assertions. (#34595)
tests/Integration/Database/DatabaseEloquentModelCustomCastingTest.php
@@ -31,15 +31,15 @@ public function testBasicCustomCasting() $model->syncOriginal(); $model->uppercase = 'dries'; - $this->assertEquals('TAYLOR', $model->getOriginal('uppercase')); + $this->assertSame('TAYLOR', $model->getOriginal('uppercase')); $model = new TestEloquentModelWithCustomCast; $model->uppercase = 'taylor'; $model->syncOriginal(); $model->uppercase = 'dries'; $model->getOriginal(); - $this->assertEquals('DRIES', $model->uppercase); + $this->assertSame('DRIES', $model->uppercase); $model = new TestEloquentModelWithCustomCast; @@ -82,7 +82,7 @@ public function testBasicCustomCasting() $this->assertEquals(['foo' => 'bar'], $model->options); $this->assertEquals(['foo' => 'bar'], $model->options); - $this->assertEquals(json_encode(['foo' => 'bar']), $model->getAttributes()['options']); + $this->assertSame(json_encode(['foo' => 'bar']), $model->getAttributes()['options']); $model = new TestEloquentModelWithCustomCast(['options' => []]); $model->syncOriginal(); @@ -104,9 +104,9 @@ public function testGetOriginalWithCastValueObjects() $model->address = new Address('117 Spencer St.', 'Another house.'); - $this->assertEquals('117 Spencer St.', $model->address->lineOne); - $this->assertEquals('110 Kingsbrook St.', $model->getOriginal('address')->lineOne); - $this->assertEquals('117 Spencer St.', $model->address->lineOne); + $this->assertSame('117 Spencer St.', $model->address->lineOne); + $this->assertSame('110 Kingsbrook St.', $model->getOriginal('address')->lineOne); + $this->assertSame('117 Spencer St.', $model->address->lineOne); $model = new TestEloquentModelWithCustomCast([ 'address' => new Address('110 Kingsbrook St.', 'My Childhood House'), @@ -116,10 +116,10 @@ public function testGetOriginalWithCastValueObjects() $model->address = new Address('117 Spencer St.', 'Another house.'); - $this->assertEquals('117 Spencer St.', $model->address->lineOne); - $this->assertEquals('110 Kingsbrook St.', $model->getOriginal()['address_line_one']); - $this->assertEquals('117 Spencer St.', $model->address->lineOne); - $this->assertEquals('110 Kingsbrook St.', $model->getOriginal()['address_line_one']); + $this->assertSame('117 Spencer St.', $model->address->lineOne); + $this->assertSame('110 Kingsbrook St.', $model->getOriginal()['address_line_one']); + $this->assertSame('117 Spencer St.', $model->address->lineOne); + $this->assertSame('110 Kingsbrook St.', $model->getOriginal()['address_line_one']); $model = new TestEloquentModelWithCustomCast([ 'address' => new Address('110 Kingsbrook St.', 'My Childhood House'), @@ -187,7 +187,7 @@ public function testWithCastableInterface() 'value_object_caster_with_argument' => null, ]); - $this->assertEquals('argument', $model->value_object_caster_with_argument); + $this->assertSame('argument', $model->value_object_caster_with_argument); $model->setRawAttributes([ 'value_object_caster_with_caster_instance' => serialize(new ValueObject('hello')),
true
Other
laravel
framework
cfef0246e490b86289893833f0e15cb6f2ec240a.json
Use stricter assertions. (#34595)
tests/Integration/Database/DatabaseSchemaBuilderAlterTableWithEnumTest.php
@@ -22,7 +22,7 @@ public function testChangeColumnOnTableWithEnum() $table->unsignedInteger('age')->charset('')->change(); }); - $this->assertEquals('integer', Schema::getColumnType('users', 'age')); + $this->assertSame('integer', Schema::getColumnType('users', 'age')); } protected function setUp(): void
true
Other
laravel
framework
cfef0246e490b86289893833f0e15cb6f2ec240a.json
Use stricter assertions. (#34595)
tests/Integration/Database/EloquentModelWithoutEventsTest.php
@@ -31,7 +31,7 @@ public function testWithoutEventsRegistersBootedListenersForLater() $model->save(); - $this->assertEquals('Laravel', $model->project); + $this->assertSame('Laravel', $model->project); } }
true
Other
laravel
framework
cfef0246e490b86289893833f0e15cb6f2ec240a.json
Use stricter assertions. (#34595)
tests/Integration/Foundation/MaintenanceModeTest.php
@@ -67,7 +67,7 @@ public function testMaintenanceModeCanHaveCustomTemplate() $response->assertStatus(503); $response->assertHeader('Retry-After', '60'); - $this->assertEquals('Rendered Content', $response->original); + $this->assertSame('Rendered Content', $response->original); } public function testMaintenanceModeCanRedirectWithBypassCookie() @@ -106,7 +106,7 @@ public function testMaintenanceModeCanBeBypassedWithValidCookie() ])->get('/test'); $response->assertStatus(200); - $this->assertEquals('Hello World', $response->original); + $this->assertSame('Hello World', $response->original); } public function testMaintenanceModeCantBeBypassedWithInvalidCookie() @@ -134,7 +134,7 @@ public function testCanCreateBypassCookies() $cookie = MaintenanceModeBypassCookie::create('test-key'); $this->assertInstanceOf(Cookie::class, $cookie); - $this->assertEquals('laravel_maintenance', $cookie->getName()); + $this->assertSame('laravel_maintenance', $cookie->getName()); $this->assertTrue(MaintenanceModeBypassCookie::isValid($cookie->getValue(), 'test-key')); $this->assertFalse(MaintenanceModeBypassCookie::isValid($cookie->getValue(), 'wrong-key'));
true
Other
laravel
framework
cfef0246e490b86289893833f0e15cb6f2ec240a.json
Use stricter assertions. (#34595)
tests/Integration/View/BladeTest.php
@@ -14,7 +14,7 @@ public function test_basic_blade_rendering() { $view = View::make('hello', ['name' => 'Taylor'])->render(); - $this->assertEquals('Hello Taylor', trim($view)); + $this->assertSame('Hello Taylor', trim($view)); } public function test_rendering_a_component() @@ -30,7 +30,7 @@ public function test_rendering_a_dynamic_component() { $view = View::make('uses-panel-dynamically', ['name' => 'Taylor'])->render(); - $this->assertEquals('<div class="ml-2" wire:model="foo" wire:model.lazy="bar"> + $this->assertSame('<div class="ml-2" wire:model="foo" wire:model.lazy="bar"> Hello Taylor </div>', trim($view)); }
true
Other
laravel
framework
cfef0246e490b86289893833f0e15cb6f2ec240a.json
Use stricter assertions. (#34595)
tests/Queue/QueueDatabaseQueueUnitTest.php
@@ -31,7 +31,7 @@ public function testPushProperlyPushesJobOntoDatabase() $database->shouldReceive('table')->with('table')->andReturn($query = m::mock(stdClass::class)); $query->shouldReceive('insertGetId')->once()->andReturnUsing(function ($array) use ($uuid) { $this->assertSame('default', $array['queue']); - $this->assertEquals(json_encode(['uuid' => $uuid, 'displayName' => 'foo', 'job' => 'foo', 'maxTries' => null, 'maxExceptions' => null, 'backoff' => null, 'timeout' => null, 'data' => ['data']]), $array['payload']); + $this->assertSame(json_encode(['uuid' => $uuid, 'displayName' => 'foo', 'job' => 'foo', 'maxTries' => null, 'maxExceptions' => null, 'backoff' => null, 'timeout' => null, 'data' => ['data']]), $array['payload']); $this->assertEquals(0, $array['attempts']); $this->assertNull($array['reserved_at']); $this->assertIsInt($array['available_at']); @@ -59,7 +59,7 @@ public function testDelayedPushProperlyPushesJobOntoDatabase() $database->shouldReceive('table')->with('table')->andReturn($query = m::mock(stdClass::class)); $query->shouldReceive('insertGetId')->once()->andReturnUsing(function ($array) use ($uuid) { $this->assertSame('default', $array['queue']); - $this->assertEquals(json_encode(['uuid' => $uuid, 'displayName' => 'foo', 'job' => 'foo', 'maxTries' => null, 'maxExceptions' => null, 'backoff' => null, 'timeout' => null, 'data' => ['data']]), $array['payload']); + $this->assertSame(json_encode(['uuid' => $uuid, 'displayName' => 'foo', 'job' => 'foo', 'maxTries' => null, 'maxExceptions' => null, 'backoff' => null, 'timeout' => null, 'data' => ['data']]), $array['payload']); $this->assertEquals(0, $array['attempts']); $this->assertNull($array['reserved_at']); $this->assertIsInt($array['available_at']);
true
Other
laravel
framework
cfef0246e490b86289893833f0e15cb6f2ec240a.json
Use stricter assertions. (#34595)
tests/Redis/RedisConnectorTest.php
@@ -34,7 +34,7 @@ public function testDefaultConfiguration() $predisClient = $this->redis['predis']->connection()->client(); $parameters = $predisClient->getConnection()->getParameters(); - $this->assertEquals('tcp', $parameters->scheme); + $this->assertSame('tcp', $parameters->scheme); $this->assertEquals($host, $parameters->host); $this->assertEquals($port, $parameters->port); @@ -61,7 +61,7 @@ public function testUrl() ]); $predisClient = $predis->connection()->client(); $parameters = $predisClient->getConnection()->getParameters(); - $this->assertEquals('tcp', $parameters->scheme); + $this->assertSame('tcp', $parameters->scheme); $this->assertEquals($host, $parameters->host); $this->assertEquals($port, $parameters->port); @@ -77,7 +77,7 @@ public function testUrl() ], ]); $phpRedisClient = $phpRedis->connection()->client(); - $this->assertEquals("tcp://{$host}", $phpRedisClient->getHost()); + $this->assertSame("tcp://{$host}", $phpRedisClient->getHost()); $this->assertEquals($port, $phpRedisClient->getPort()); } @@ -99,7 +99,7 @@ public function testUrlWithScheme() ]); $predisClient = $predis->connection()->client(); $parameters = $predisClient->getConnection()->getParameters(); - $this->assertEquals('tls', $parameters->scheme); + $this->assertSame('tls', $parameters->scheme); $this->assertEquals($host, $parameters->host); $this->assertEquals($port, $parameters->port); @@ -115,7 +115,7 @@ public function testUrlWithScheme() ], ]); $phpRedisClient = $phpRedis->connection()->client(); - $this->assertEquals("tcp://{$host}", $phpRedisClient->getHost()); + $this->assertSame("tcp://{$host}", $phpRedisClient->getHost()); $this->assertEquals($port, $phpRedisClient->getPort()); } @@ -139,7 +139,7 @@ public function testScheme() ]); $predisClient = $predis->connection()->client(); $parameters = $predisClient->getConnection()->getParameters(); - $this->assertEquals('tls', $parameters->scheme); + $this->assertSame('tls', $parameters->scheme); $this->assertEquals($host, $parameters->host); $this->assertEquals($port, $parameters->port); @@ -157,7 +157,7 @@ public function testScheme() ], ]); $phpRedisClient = $phpRedis->connection()->client(); - $this->assertEquals("tcp://{$host}", $phpRedisClient->getHost()); + $this->assertSame("tcp://{$host}", $phpRedisClient->getHost()); $this->assertEquals($port, $phpRedisClient->getPort()); } }
true
Other
laravel
framework
cfef0246e490b86289893833f0e15cb6f2ec240a.json
Use stricter assertions. (#34595)
tests/Routing/RoutingRouteTest.php
@@ -202,7 +202,7 @@ public function testMiddlewareCanBeSkipped() return 'hello'; }])->withoutMiddleware(RoutingTestMiddlewareGroupTwo::class); - $this->assertEquals('hello', $router->dispatch(Request::create('foo/bar', 'GET'))->getContent()); + $this->assertSame('hello', $router->dispatch(Request::create('foo/bar', 'GET'))->getContent()); } public function testMiddlewareCanBeSkippedFromResources() @@ -214,7 +214,7 @@ public function testMiddlewareCanBeSkippedFromResources() ->middleware('web') ->withoutMiddleware(RoutingTestMiddlewareGroupTwo::class); - $this->assertEquals('Hello World', $router->dispatch(Request::create('foo', 'GET'))->getContent()); + $this->assertSame('Hello World', $router->dispatch(Request::create('foo', 'GET'))->getContent()); } public function testMiddlewareWorksIfControllerThrowsHttpResponseException()
true
Other
laravel
framework
cfef0246e490b86289893833f0e15cb6f2ec240a.json
Use stricter assertions. (#34595)
tests/Validation/ValidationValidatorTest.php
@@ -61,7 +61,7 @@ public function testNestedErrorMessagesAreRetrievedFromLocalArray() ]); $this->assertFalse($v->passes()); - $this->assertEquals('post name is required', $v->errors()->all()[0]); + $this->assertSame('post name is required', $v->errors()->all()[0]); } public function testSometimesWorksOnNestedArrays()
true
Other
laravel
framework
cfef0246e490b86289893833f0e15cb6f2ec240a.json
Use stricter assertions. (#34595)
tests/View/ViewComponentTest.php
@@ -25,7 +25,7 @@ public function testAttributeParentInheritance() $component->withAttributes(['class' => 'foo', 'attributes' => new ComponentAttributeBag(['class' => 'bar', 'type' => 'button'])]); - $this->assertEquals('class="foo bar" type="button"', (string) $component->attributes); + $this->assertSame('class="foo bar" type="button"', (string) $component->attributes); } public function testPublicMethodsWithNoArgsAreConvertedToStringableCallablesInvokedAndNotCached()
true
Other
laravel
framework
277e3c353235b58dfbe7f6035720b0ca328c9095.json
Fix many docblocks in Illuminate\Bus. (#34596)
src/Illuminate/Bus/Batch.php
@@ -81,21 +81,21 @@ class Batch implements Arrayable, JsonSerializable /** * The date indicating when the batch was created. * - * @var \Illuminate\Support\CarbonImmutable + * @var \Carbon\CarbonImmutable */ public $createdAt; /** * The date indicating when the batch was cancelled. * - * @var \Illuminate\Support\CarbonImmutable|null + * @var \Carbon\CarbonImmutable|null */ public $cancelledAt; /** * The date indicating when the batch was finished. * - * @var \Illuminate\Support\CarbonImmutable|null + * @var \Carbon\CarbonImmutable|null */ public $finishedAt; @@ -111,9 +111,9 @@ class Batch implements Arrayable, JsonSerializable * @param int $failedJobs * @param array $failedJobIds * @param array $options - * @param \Illuminate\Support\CarbonImmutable $createdAt - * @param \Illuminate\Support\CarbonImmutable|null $cancelledAt - * @param \Illuminate\Support\CarbonImmutable|null $finishedAt + * @param \Carbon\CarbonImmutable $createdAt + * @param \Carbon\CarbonImmutable|null $cancelledAt + * @param \Carbon\CarbonImmutable|null $finishedAt * @return void */ public function __construct(QueueFactory $queue, @@ -239,7 +239,7 @@ public function recordSuccessfulJob(string $jobId) * Decrement the pending jobs for the batch. * * @param string $jobId - * @return int + * @return \Illuminate\Bus\UpdatedBatchJobCounts */ public function decrementPendingJobs(string $jobId) { @@ -322,7 +322,7 @@ public function recordFailedJob(string $jobId, $e) * Increment the failed jobs for the batch. * * @param string $jobId - * @return int + * @return \Illuminate\Bus\UpdatedBatchJobCounts */ public function incrementFailedJobs(string $jobId) { @@ -393,7 +393,7 @@ public function delete() * Invoke a batch callback handler. * * @param \Illuminate\Queue\SerializableClosure|callable $handler - * @param \Illuminate\Bus $batch + * @param \Illuminate\Bus\Batch $batch * @param \Throwable|null $e * @return void */
true
Other
laravel
framework
277e3c353235b58dfbe7f6035720b0ca328c9095.json
Fix many docblocks in Illuminate\Bus. (#34596)
src/Illuminate/Bus/BatchFactory.php
@@ -36,9 +36,9 @@ public function __construct(QueueFactory $queue) * @param int $failedJobs * @param array $failedJobIds * @param array $options - * @param \Illuminate\Support\CarbonImmutable $createdAt - * @param \Illuminate\Support\CarbonImmutable|null $cancelledAt - * @param \Illuminate\Support\CarbonImmutable|null $finishedAt + * @param \Carbon\CarbonImmutable $createdAt + * @param \Carbon\CarbonImmutable|null $cancelledAt + * @param \Carbon\CarbonImmutable|null $finishedAt * @return \Illuminate\Bus\Batch */ public function make(BatchRepository $repository,
true
Other
laravel
framework
277e3c353235b58dfbe7f6035720b0ca328c9095.json
Fix many docblocks in Illuminate\Bus. (#34596)
src/Illuminate/Bus/PendingBatch.php
@@ -215,6 +215,7 @@ public function queue() * Dispatch the batch. * * @return \Illuminate\Bus\Batch + * @throws \Throwable */ public function dispatch() {
true
Other
laravel
framework
b5f74acc37c9b0372c094afa28b39cb4d64ea0d9.json
Fix Client\Response `throw` method (#34597)
src/Illuminate/Http/Client/Response.php
@@ -225,14 +225,14 @@ public function toPsrResponse() */ public function throw() { - $callback = func_get_arg(0); + $callback = func_get_args()[0] ?? null; if ($this->serverError() || $this->clientError()) { - if ($callback && is_callable($callback)) { - $callback($this, $exception = new RequestException($this)); - } - - throw $exception; + throw tap(new RequestException($this), function ($exception) use ($callback) { + if ($callback && is_callable($callback)) { + $callback($this, $exception); + } + }); } return $this;
false
Other
laravel
framework
89d9cd46e6cf764171cae2c762872aacf87d65dd.json
Apply fixes from StyleCI (#34579)
src/Illuminate/Database/Eloquent/Relations/MorphPivot.php
@@ -2,7 +2,6 @@ namespace Illuminate\Database\Eloquent\Relations; -use Illuminate\Database\Eloquent\Builder; use Illuminate\Support\Str; class MorphPivot extends Pivot
false
Other
laravel
framework
1b3f62aaeced2c9761a6052a7f0d3c1a046851c9.json
remove type hint
src/Illuminate/Database/Eloquent/Relations/Concerns/AsPivot.php
@@ -88,7 +88,7 @@ public static function fromRawAttributes(Model $parent, $attributes, $table, $ex * @param \Illuminate\Database\Eloquent\Builder $query * @return \Illuminate\Database\Eloquent\Builder */ - protected function setKeysForSaveQuery(Builder $query) + protected function setKeysForSaveQuery($query) { if (isset($this->attributes[$this->getKeyName()])) { return parent::setKeysForSaveQuery($query);
true
Other
laravel
framework
1b3f62aaeced2c9761a6052a7f0d3c1a046851c9.json
remove type hint
src/Illuminate/Database/Eloquent/Relations/MorphPivot.php
@@ -31,7 +31,7 @@ class MorphPivot extends Pivot * @param \Illuminate\Database\Eloquent\Builder $query * @return \Illuminate\Database\Eloquent\Builder */ - protected function setKeysForSaveQuery(Builder $query) + protected function setKeysForSaveQuery($query) { $query->where($this->morphType, $this->morphClass);
true
Other
laravel
framework
c131f471af6e3a45593adbe0ed3bbea074f85500.json
Add throwWith to the HTTP client response Because: - There is a repeated pattern where you want to perform a particular action if the response has failed, such as logging the error. ```php // before... $response = $client->withHeaders($headers)->post($url, $payload); if ($response->failed()) { Log::error('Twitter API failed posting Tweet', [ 'url' => $url, 'payload' => $payload, 'headers' => $headers, 'response' => $response->body(), ]); $response->throw(); } return $response->json(); // after... return $client->withHeaders($headers) ->post($url, $payload) ->throwWith(fn ($response) => Log::error('Twitter API failed posting Tweet', [ 'url' => $url, 'payload' => $payload, 'headers' => $headers, 'response' => $response->body(), ]) )->json(); ``` This commit: - Adds the `throwWith` method to the response. - Updates the `throw` method to utilise the new `throwWith` method, just with an empty closure. Notes: - I'm not convinced this is the best name for this method. - I'm also wondering if the method should be a `tap` method of some kind. `tapWhenThrowing` or something along those lines.
src/Illuminate/Http/Client/Response.php
@@ -208,8 +208,25 @@ public function toPsrResponse() * @throws \Illuminate\Http\Client\RequestException */ public function throw() + { + return $this->throwWith(function () { + // + }); + } + + /** + * Execute the callback and throw an exception if a server of client error occurred. + * + * @param \Closure $callback + * @return $this + * + * @throws \Illuminate\Http\Client\RequestException + */ + public function throwWith($callback) { if ($this->serverError() || $this->clientError()) { + $callback($this); + throw new RequestException($this); }
true
Other
laravel
framework
c131f471af6e3a45593adbe0ed3bbea074f85500.json
Add throwWith to the HTTP client response Because: - There is a repeated pattern where you want to perform a particular action if the response has failed, such as logging the error. ```php // before... $response = $client->withHeaders($headers)->post($url, $payload); if ($response->failed()) { Log::error('Twitter API failed posting Tweet', [ 'url' => $url, 'payload' => $payload, 'headers' => $headers, 'response' => $response->body(), ]); $response->throw(); } return $response->json(); // after... return $client->withHeaders($headers) ->post($url, $payload) ->throwWith(fn ($response) => Log::error('Twitter API failed posting Tweet', [ 'url' => $url, 'payload' => $payload, 'headers' => $headers, 'response' => $response->body(), ]) )->json(); ``` This commit: - Adds the `throwWith` method to the response. - Updates the `throw` method to utilise the new `throwWith` method, just with an empty closure. Notes: - I'm not convinced this is the best name for this method. - I'm also wondering if the method should be a `tap` method of some kind. `tapWhenThrowing` or something along those lines.
tests/Http/HttpClientTest.php
@@ -476,6 +476,42 @@ public function testRequestExceptionEmptyBody() throw new RequestException(new Response($response)); } + public function testThrowWithCallsClosureOnError() + { + $status = 0; + $client = $this->factory->fake([ + 'laravel.com' => $this->factory::response('', 401), + ]); + $response = $client->get('laravel.com'); + + try { + $response->throwWith(function ($response) use (&$status) { + $status = $response->status(); + }); + } catch (RequestException $e) { + // + } + + $this->assertSame(401, $status); + $this->assertSame(401, $response->status()); + } + + public function testThrowWithDoesntCallClosureOnSuccess() + { + $status = 0; + $client = $this->factory->fake([ + 'laravel.com' => $this->factory::response('', 201), + ]); + $response = $client->get('laravel.com'); + + $response->throwWith(function ($response) use (&$status) { + $status = $response->status(); + }); + + $this->assertSame(0, $status); + $this->assertSame(201, $response->status()); + } + public function testSinkToFile() { $this->factory->fakeSequence()->push('abc123');
true
Other
laravel
framework
2ec773802f75c20926a27b8b308b3ea2f13b8d7c.json
set no timeout
src/Illuminate/Database/Schema/MySqlSchemaState.php
@@ -116,7 +116,7 @@ protected function baseVariables(array $config) protected function executeDumpProcess(Process $process, $output, array $variables) { try { - $process->mustRun($output, $variables); + $process->setTimeout(null)->mustRun($output, $variables); } catch (Exception $e) { if (Str::contains($e->getMessage(), ['column-statistics', 'column_statistics'])) { return $this->executeDumpProcess(Process::fromShellCommandLine(
true
Other
laravel
framework
2ec773802f75c20926a27b8b308b3ea2f13b8d7c.json
set no timeout
src/Illuminate/Database/Schema/PostgresSchemaState.php
@@ -31,7 +31,7 @@ protected function appendMigrationData(string $path) { with($process = $this->makeProcess( $this->baseDumpCommand().' --table=migrations --data-only --inserts' - ))->mustRun(null, array_merge($this->baseVariables($this->connection->getConfig()), [ + ))->setTimeout(null)->mustRun(null, array_merge($this->baseVariables($this->connection->getConfig()), [ // ]));
true
Other
laravel
framework
2ec773802f75c20926a27b8b308b3ea2f13b8d7c.json
set no timeout
src/Illuminate/Database/Schema/SqliteSchemaState.php
@@ -15,7 +15,7 @@ public function dump($path) { with($process = $this->makeProcess( $this->baseCommand().' .schema' - ))->mustRun(null, array_merge($this->baseVariables($this->connection->getConfig()), [ + ))->setTimeout(null)->mustRun(null, array_merge($this->baseVariables($this->connection->getConfig()), [ // ]));
true
Other
laravel
framework
20ff6a5db22f6cc8f971a715f09ee65e11bf4adc.json
Fix small issues with CHANGELOG-7.xmd Capitalize first word in sentence, 2 times Change dont -> don't, 3 times
CHANGELOG-7.x.md
@@ -44,7 +44,7 @@ - RefreshDatabase migration commands parameters moved to methods ([#34007](https://github.com/laravel/framework/pull/34007), [8b35c8e](https://github.com/laravel/framework/commit/8b35c8e6ba5879e71fd81fd03b5687ee2b46c55a), [256f71c](https://github.com/laravel/framework/commit/256f71c1f81da2d4bb3e327b18389ac43fa97a72)) ### Changed -- allow to reset forced scheme and root-url in UrlGenerator ([#34039](https://github.com/laravel/framework/pull/34039)) +- Allow to reset forced scheme and root-url in UrlGenerator ([#34039](https://github.com/laravel/framework/pull/34039)) - Updating the make commands to use a custom views path ([#34060](https://github.com/laravel/framework/pull/34060), [b593c62](https://github.com/laravel/framework/commit/b593c6242942623fcc12638d0390da7c58dbbb11)) - Using "public static property" in View Component causes an error ([#34058](https://github.com/laravel/framework/pull/34058)) - Changed postgres processor ([#34055](https://github.com/laravel/framework/pull/34055)) @@ -121,7 +121,7 @@ ### Fixed - Fixed `Illuminate\Support\Arr::query()` ([c6f9ae2](https://github.com/laravel/framework/commit/c6f9ae2b6fdc3c1716938223de731b97f6a5a255)) -- Dont allow mass filling with table names ([9240404](https://github.com/laravel/framework/commit/9240404b22ef6f9e827577b3753e4713ddce7471), [f5fa6e3](https://github.com/laravel/framework/commit/f5fa6e3a0fbf9a93eab45b9ae73265b4dbfc3ad7)) +- Don't allow mass filling with table names ([9240404](https://github.com/laravel/framework/commit/9240404b22ef6f9e827577b3753e4713ddce7471), [f5fa6e3](https://github.com/laravel/framework/commit/f5fa6e3a0fbf9a93eab45b9ae73265b4dbfc3ad7)) ## [v7.23.1 (2020-08-06)](https://github.com/laravel/framework/compare/v7.23.0...v7.23.1) @@ -179,7 +179,7 @@ ### Fixed - Prevent usage of get*AtColumn() when model has no timestamps ([#33634](https://github.com/laravel/framework/pull/33634)) -- Dont decrement transaction below 0 in `Illuminate\Database\Concerns\ManagesTransactions::handleCommitTransactionException()` ([7681795](https://github.com/laravel/framework/commit/768179578e5492b5f80c391bd43b233938e16e27)) +- Don't decrement transaction below 0 in `Illuminate\Database\Concerns\ManagesTransactions::handleCommitTransactionException()` ([7681795](https://github.com/laravel/framework/commit/768179578e5492b5f80c391bd43b233938e16e27)) - Fixed transaction problems on closure transaction ([c4cdfc7](https://github.com/laravel/framework/commit/c4cdfc7c54127b772ef10f37cfc9ef8e9d6b3227)) - Prevent to serialize uninitialized properties ([#33644](https://github.com/laravel/framework/pull/33644)) - Fixed missing statement preventing deletion in `Illuminate\Database\Eloquent\Relations\MorphPivot::delete()` ([#33648](https://github.com/laravel/framework/pull/33648)) @@ -394,7 +394,7 @@ - Fixed `Illuminate\Cache\ArrayStore::increment()` bug that changes expiration to forever ([#32875](https://github.com/laravel/framework/pull/32875)) ### Changed -- Dont cache non objects in `Illuminate/Database/Eloquent/Concerns/HasAttributes::getClassCastableAttributeValue()` ([894fe22](https://github.com/laravel/framework/commit/894fe22c6c111b224de5bada24dcbba4c93f0305)) +- Don't cache non objects in `Illuminate/Database/Eloquent/Concerns/HasAttributes::getClassCastableAttributeValue()` ([894fe22](https://github.com/laravel/framework/commit/894fe22c6c111b224de5bada24dcbba4c93f0305)) - Added explicit `symfony/polyfill-php73` dependency ([5796b1e](https://github.com/laravel/framework/commit/5796b1e43dfe14914050a7e5dd24ddf803ec99b8)) - Set `Cache\FileStore` file permissions only once ([#32845](https://github.com/laravel/framework/pull/32845), [11c533b](https://github.com/laravel/framework/commit/11c533b9aa062f4cba1dd0fe3673bf33d275480f)) - Added alias as key of package's view components ([#32863](https://github.com/laravel/framework/pull/32863)) @@ -885,7 +885,7 @@ - Fixed `trim` of the prefix in the `CompiledRouteCollection::newRoute()` ([ce0355c](https://github.com/laravel/framework/commit/ce0355c72bf4defb93ae80c7bf7812bd6532031a), [b842c65](https://github.com/laravel/framework/commit/b842c65ecfe1ea7839d61a46b177b6b5887fd4d2)) ### Changed -- remove comments before compiling components in the `BladeCompiler` ([2964d2d](https://github.com/laravel/framework/commit/2964d2dfd3cc50f7a709effee0af671c86587915)) +- Remove comments before compiling components in the `BladeCompiler` ([2964d2d](https://github.com/laravel/framework/commit/2964d2dfd3cc50f7a709effee0af671c86587915)) ## [v7.0.1 (2020-03-03)](https://github.com/laravel/framework/compare/v7.0.0...v7.0.1)
false
Other
laravel
framework
f3707046a65f6390f5f19047f8693ac58b9e0c28.json
Fix 2 small issues in change log Change word: dont -> don't Capitalize first word in sentence
CHANGELOG-8.x.md
@@ -27,7 +27,7 @@ - Added `Illuminate\Session\Store::passwordConfirmed()` ([fb3f45a](https://github.com/laravel/framework/commit/fb3f45aa0142764c5c29b97e8bcf8328091986e9)) ### Changed -- check for view existence first in `Illuminate\Mail\Markdown::render()` ([5f78c90](https://github.com/laravel/framework/commit/5f78c90a7af118dd07703a78da06586016973a66)) +- Check for view existence first in `Illuminate\Mail\Markdown::render()` ([5f78c90](https://github.com/laravel/framework/commit/5f78c90a7af118dd07703a78da06586016973a66)) - Guess the model name when using the make:factory command ([#34373](https://github.com/laravel/framework/pull/34373)) @@ -39,7 +39,7 @@ ### Fixed - Fixed `minimal.blade.php` ([#34379](https://github.com/laravel/framework/pull/34379)) -- Dont double escape on ComponentTagCompiler.php ([ec75487](https://github.com/laravel/framework/commit/ec75487062506963dd27a4302fe3680c0e3681a3)) +- Don't double escape on ComponentTagCompiler.php ([ec75487](https://github.com/laravel/framework/commit/ec75487062506963dd27a4302fe3680c0e3681a3)) - Fixed dots in attribute names in `DynamicComponent` ([2d1d962](https://github.com/laravel/framework/commit/2d1d96272a94bce123676ed742af2d80ba628ba4)) ### Changed
false
Other
laravel
framework
3e66eb75ae379f14eb760a19071a07134de797e3.json
use related model for methods
src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php
@@ -585,7 +585,7 @@ public function findOrNew($id, $columns = ['*']) */ public function firstOrNew(array $attributes) { - if (is_null($instance = $this->where($attributes)->first())) { + if (is_null($instance = $this->related->where($attributes)->first())) { $instance = $this->related->newInstance($attributes); } @@ -602,7 +602,7 @@ public function firstOrNew(array $attributes) */ public function firstOrCreate(array $attributes, array $joining = [], $touch = true) { - if (is_null($instance = $this->where($attributes)->first())) { + if (is_null($instance = $this->related->where($attributes)->first())) { $instance = $this->create($attributes, $joining, $touch); } @@ -620,7 +620,7 @@ public function firstOrCreate(array $attributes, array $joining = [], $touch = t */ public function updateOrCreate(array $attributes, array $values = [], array $joining = [], $touch = true) { - if (is_null($instance = $this->where($attributes)->first())) { + if (is_null($instance = $this->related->where($attributes)->first())) { return $this->create($values, $joining, $touch); }
false