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 | d98bdacba48ec6ea8aa730a73cff9581502d5038.json | Require symfony/uid (#44202) | src/Illuminate/Support/composer.json | @@ -46,7 +46,7 @@
"league/commonmark": "Required to use Str::markdown() and Stringable::markdown() (^2.0.2).",
"ramsey/uuid": "Required to use Str::uuid() (^4.2.2).",
"symfony/process": "Required to use the composer class (^6.0).",
- "symfony/uid": "Required to generate ULIDs for Eloquent (^6.0).",
+ "symfony/uid": "Required to use Str::ulid() (^6.0).",
"symfony/var-dumper": "Required to use the dd function (^6.0).",
"vlucas/phpdotenv": "Required to use the Env class and env helper (^5.4.1)."
}, | true |
Other | laravel | framework | 6299cd85d728ebb82da13f20abcdf4a7e98ef55b.json | Update BusFake to use new BatchFake (#44173) | src/Illuminate/Support/Testing/Fakes/BatchRepositoryFake.php | @@ -4,11 +4,9 @@
use Carbon\CarbonImmutable;
use Closure;
-use Illuminate\Bus\Batch;
use Illuminate\Bus\BatchRepository;
use Illuminate\Bus\PendingBatch;
use Illuminate\Bus\UpdatedBatchJobCounts;
-use Illuminate\Support\Facades\Facade;
use Illuminate\Support\Str;
class BatchRepositoryFake implements BatchRepository
@@ -53,9 +51,7 @@ public function store(PendingBatch $batch)
{
$id = (string) Str::orderedUuid();
- $this->batches[$id] = new Batch(
- new QueueFake(Facade::getFacadeApplication()),
- $this,
+ $this->batches[$id] = new BatchFake(
$id,
$batch->name,
count($batch->jobs),
@@ -129,7 +125,7 @@ public function markAsFinished(string $batchId)
public function cancel(string $batchId)
{
if (isset($this->batches[$batchId])) {
- $this->batches[$batchId]->cancelledAt = now();
+ $this->batches[$batchId]->cancel();
}
}
| false |
Other | laravel | framework | a09015af2edc14a85acf40b8899d3f581534f7dd.json | Apply fixes from StyleCI | tests/Filesystem/FilesystemManagerTest.php | @@ -96,6 +96,5 @@ public function testCanBuildScopedDisks()
} finally {
rmdir(__DIR__.'/../../to-be-scoped');
}
-
}
} | false |
Other | laravel | framework | a155ccdafa229cbd0fac0033a98a24119064f87a.json | Improve testability of batched jobs (#44075)
* Track batched jobs
* Add helper to fake batch jobs
* formatting
* formatting
Co-authored-by: Taylor Otwell <taylor@laravel.com> | src/Illuminate/Support/Testing/Fakes/BatchRepositoryFake.php | @@ -13,6 +13,13 @@
class BatchRepositoryFake implements BatchRepository
{
+ /**
+ * The batches stored in the repository.
+ *
+ * @var \Illuminate\Bus\Batch[]
+ */
+ protected $batches = [];
+
/**
* Retrieve a list of batches.
*
@@ -22,7 +29,7 @@ class BatchRepositoryFake implements BatchRepository
*/
public function get($limit, $before)
{
- return [];
+ return $this->batches;
}
/**
@@ -33,7 +40,7 @@ public function get($limit, $before)
*/
public function find(string $batchId)
{
- //
+ return $this->batches[$batchId] ?? null;
}
/**
@@ -44,10 +51,12 @@ public function find(string $batchId)
*/
public function store(PendingBatch $batch)
{
- return new Batch(
+ $id = (string) Str::orderedUuid();
+
+ $this->batches[$id] = new Batch(
new QueueFake(Facade::getFacadeApplication()),
$this,
- (string) Str::orderedUuid(),
+ $id,
$batch->name,
count($batch->jobs),
count($batch->jobs),
@@ -58,6 +67,8 @@ public function store(PendingBatch $batch)
null,
null
);
+
+ return $this->batches[$id];
}
/**
@@ -104,7 +115,9 @@ public function incrementFailedJobs(string $batchId, string $jobId)
*/
public function markAsFinished(string $batchId)
{
- //
+ if (isset($this->batches[$batchId])) {
+ $this->batches[$batchId]->finishedAt = now();
+ }
}
/**
@@ -115,7 +128,9 @@ public function markAsFinished(string $batchId)
*/
public function cancel(string $batchId)
{
- //
+ if (isset($this->batches[$batchId])) {
+ $this->batches[$batchId]->cancelledAt = now();
+ }
}
/**
@@ -126,7 +141,7 @@ public function cancel(string $batchId)
*/
public function delete(string $batchId)
{
- //
+ unset($this->batches[$batchId]);
}
/** | true |
Other | laravel | framework | a155ccdafa229cbd0fac0033a98a24119064f87a.json | Improve testability of batched jobs (#44075)
* Track batched jobs
* Add helper to fake batch jobs
* formatting
* formatting
Co-authored-by: Taylor Otwell <taylor@laravel.com> | src/Illuminate/Support/Testing/Fakes/BusFake.php | @@ -28,6 +28,13 @@ class BusFake implements QueueingDispatcher
*/
protected $jobsToFake;
+ /**
+ * The fake repository to track batched jobs.
+ *
+ * @var \Illuminate\Bus\BatchRepository
+ */
+ protected $batchRepository;
+
/**
* The commands that have been dispatched.
*
@@ -66,8 +73,8 @@ class BusFake implements QueueingDispatcher
public function __construct(QueueingDispatcher $dispatcher, $jobsToFake = [])
{
$this->dispatcher = $dispatcher;
-
$this->jobsToFake = Arr::wrap($jobsToFake);
+ $this->batchRepository = new BatchRepositoryFake;
}
/**
@@ -634,7 +641,7 @@ public function chain($jobs)
*/
public function findBatch(string $batchId)
{
- //
+ return $this->batchRepository->find($batchId);
}
/**
@@ -658,7 +665,7 @@ public function recordPendingBatch(PendingBatch $pendingBatch)
{
$this->batches[] = $pendingBatch;
- return (new BatchRepositoryFake)->store($pendingBatch);
+ return $this->batchRepository->store($pendingBatch);
}
/** | true |
Other | laravel | framework | a155ccdafa229cbd0fac0033a98a24119064f87a.json | Improve testability of batched jobs (#44075)
* Track batched jobs
* Add helper to fake batch jobs
* formatting
* formatting
Co-authored-by: Taylor Otwell <taylor@laravel.com> | tests/Support/SupportTestingBusFakeTest.php | @@ -468,6 +468,26 @@ public function testAssertNothingBatched()
$this->assertThat($e, new ExceptionMessage('Batched jobs were dispatched unexpectedly.'));
}
}
+
+ public function testFindBatch()
+ {
+ $this->assertNull($this->fake->findBatch('non-existent-batch'));
+
+ $batch = $this->fake->batch([])->dispatch();
+
+ $this->assertSame($batch, $this->fake->findBatch($batch->id));
+ }
+
+ public function testBatchesCanBeCancelled()
+ {
+ $batch = $this->fake->batch([])->dispatch();
+
+ $this->assertFalse($batch->cancelled());
+
+ $batch->cancel();
+
+ $this->assertTrue($batch->cancelled());
+ }
}
class BusJobStub | true |
Other | laravel | framework | 59cf9c7bf2ba8e11b8f8ba5f48646d05c2630038.json | Apply fixes from StyleCI | tests/Http/Middleware/CacheTest.php | @@ -36,8 +36,9 @@ public function testDoNotSetHeaderWhenNoContent()
public function testSetHeaderToFileEvenWithNoContent()
{
- $response = (new Cache)->handle(new Request, function () {
+ $response = (new Cache)->handle(new Request, function () {
$filePath = __DIR__.'/../fixtures/test.txt';
+
return new BinaryFileResponse($filePath);
}, 'max_age=120;s_maxage=60');
| false |
Other | laravel | framework | 2c463284582f9ec43083ccae459838380c87df1d.json | Add filename option | src/Illuminate/Foundation/Console/EnvironmentDecryptCommand.php | @@ -22,7 +22,8 @@ class EnvironmentDecryptCommand extends Command
{--key= : The encryption key}
{--cipher= : The encryption cipher}
{--env= : The environment to be decrypted}
- {--force : Overwrite existing environment file}';
+ {--force : Overwrite existing environment file}
+ {--filename : Filename to which to write the decrypted contents}';
/**
* The name of the console command.
@@ -77,6 +78,7 @@ public function handle()
? base_path('.env').'.'.$this->option('env')
: $this->laravel->environmentFilePath();
$encryptedFile = $environmentFile.'.encrypted';
+ $filename = $this->option('filename') ? base_path($this->option('filename')) : $environmentFile;
if (! $this->files->exists($encryptedFile)) {
$this->components->error('Encrypted environment file not found.');
@@ -94,7 +96,7 @@ public function handle()
$encrypter = new Encrypter($key, $cipher);
$this->files->put(
- $environmentFile,
+ $filename,
$encrypter->decrypt($this->files->get($encryptedFile))
);
} catch (Exception $e) { | true |
Other | laravel | framework | 2c463284582f9ec43083ccae459838380c87df1d.json | Add filename option | tests/Integration/Console/EnvironmentDecryptCommandTest.php | @@ -202,4 +202,27 @@ public function testItDecryptsMultiLineEnvironmentCorrectly()
$this->filesystem->shouldHaveReceived('put')
->with(base_path('.env'), $contents);
}
+
+ public function testItWritesTheEnvironmentFileCustomFilename()
+ {
+ $this->filesystem->shouldReceive('exists')
+ ->once()
+ ->andReturn(true)
+ ->shouldReceive('exists')
+ ->once()
+ ->andReturn(false)
+ ->shouldReceive('get')
+ ->once()
+ ->andReturn(
+ (new Encrypter('abcdefghijklmnop'))
+ ->encrypt('APP_NAME="Laravel Two"')
+ );
+
+ $this->artisan('env:decrypt', ['--env' => 'production', '--key' => 'abcdefghijklmnop', '--filename' => '.env'])
+ ->expectsOutputToContain('Environment successfully decrypted.')
+ ->assertExitCode(0);
+
+ $this->filesystem->shouldHaveReceived('put')
+ ->with(base_path('.env'), 'APP_NAME="Laravel Two"');
+ }
} | true |
Other | laravel | framework | 77d3b687904158e319f80ac5565404b3ea2e6d34.json | Remove environment check | src/Illuminate/Foundation/Console/EnvironmentEncryptCommand.php | @@ -6,7 +6,6 @@
use Illuminate\Console\Command;
use Illuminate\Encryption\Encrypter;
use Illuminate\Filesystem\Filesystem;
-use Illuminate\Support\Env;
use Symfony\Component\Console\Attribute\AsCommand;
#[AsCommand(name: 'env:encrypt')]
@@ -63,7 +62,8 @@ public function __construct(Filesystem $files)
public function handle()
{
$cipher = $this->option('cipher') ?: 'aes-128-cbc';
- $key = $keyPassed = $this->option('key') ?: Env::get('ENVIRONMENT_ENCRYPTION_KEY');
+ $key = $this->option('key');
+ $keyPassed = $key !== null;
$environmentFile = $this->option('env')
? base_path('.env').'.'.$this->option('env')
: $this->laravel->environmentFilePath(); | false |
Other | laravel | framework | e12cb1327ee652180a8fa918e025aa1f6a5d173e.json | Apply fixes from StyleCI | tests/Foundation/FoundationApplicationTest.php | @@ -7,7 +7,6 @@
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Bootstrap\RegisterFacades;
use Illuminate\Foundation\Events\LocaleUpdated;
-use Illuminate\Support\Facades\App;
use Illuminate\Support\ServiceProvider;
use Mockery as m;
use PHPUnit\Framework\TestCase;
@@ -501,22 +500,22 @@ public function testEnvPathsAreAbsoluteInWindows()
);
}
- /** @test */
- public function testMacroable(): void
- {
- $app = new Application;
- $app['env'] = 'foo';
+ /** @test */
+ public function testMacroable(): void
+ {
+ $app = new Application;
+ $app['env'] = 'foo';
- $app->macro('foo', function() {
- return $this->environment('foo');
- });
+ $app->macro('foo', function () {
+ return $this->environment('foo');
+ });
- $this->assertTrue($app->foo());
+ $this->assertTrue($app->foo());
- $app['env'] = 'bar';
+ $app['env'] = 'bar';
- $this->assertFalse($app->foo());
- }
+ $this->assertFalse($app->foo());
+ }
}
class ApplicationBasicServiceProviderStub extends ServiceProvider | false |
Other | laravel | framework | c3befd2a42222aa1c0760c72c4234ac4120ecc63.json | Apply fixes from StyleCI | tests/Validation/ValidationRuleParserTest.php | @@ -197,18 +197,18 @@ public function testExplodeHandlesArraysOfNestedRules()
$results = $parser->explode([
'users.*.name' => Rule::forEach(function ($value, $attribute, $data) {
- $this->assertEquals([
- 'users.0.name' => 'Taylor Otwell',
- 'users.1.name' => 'Abigail Otwell',
- ], $data);
-
- return [
- Rule::requiredIf(true),
- $value === 'Taylor Otwell'
- ? Rule::in('taylor')
- : Rule::in('abigail'),
- ];
- }),
+ $this->assertEquals([
+ 'users.0.name' => 'Taylor Otwell',
+ 'users.1.name' => 'Abigail Otwell',
+ ], $data);
+
+ return [
+ Rule::requiredIf(true),
+ $value === 'Taylor Otwell'
+ ? Rule::in('taylor')
+ : Rule::in('abigail'),
+ ];
+ }),
]);
$this->assertEquals([ | false |
Other | laravel | framework | 0d936a95f201ab696434d828743f1302eb6e55c6.json | Make hotFile() public for Vite (#43875) | src/Illuminate/Foundation/Vite.php | @@ -118,7 +118,7 @@ public function withEntryPoints($entryPoints)
*
* @return string
*/
- protected function hotFile()
+ public function hotFile()
{
return $this->hotFile ?? public_path('/hot');
} | true |
Other | laravel | framework | 0d936a95f201ab696434d828743f1302eb6e55c6.json | Make hotFile() public for Vite (#43875) | src/Illuminate/Support/Facades/Vite.php | @@ -6,6 +6,7 @@
* @method static string useCspNonce(?string $nonce = null)
* @method static string|null cspNonce()
* @method static string asset(string $asset, string|null $buildDirectory)
+ * @method static string hotFile()
* @method static \Illuminate\Foundation\Vite useBuildDirectory(string $path)
* @method static \Illuminate\Foundation\Vite useHotFile(string $path)
* @method static \Illuminate\Foundation\Vite useIntegrityKey(string|false $key) | true |
Other | laravel | framework | 21dfb6c49304604cf4a33f78b2bdf952132a3c5a.json | Update CacheMemcachedStoreTest.php (#43877) | tests/Cache/CacheMemcachedStoreTest.php | @@ -71,9 +71,6 @@ public function testSetMethodProperlyCallsMemcache()
public function testIncrementMethodProperlyCallsMemcache()
{
- /** @link https://github.com/php-memcached-dev/php-memcached/pull/468 */
- $this->markTestSkipped('Test broken due to parse error in PHP Memcached.');
-
$memcached = m::mock(Memcached::class);
$memcached->shouldReceive('increment')->with('foo', 5)->once()->andReturn(5);
@@ -83,9 +80,6 @@ public function testIncrementMethodProperlyCallsMemcache()
public function testDecrementMethodProperlyCallsMemcache()
{
- /** @link https://github.com/php-memcached-dev/php-memcached/pull/468 */
- $this->markTestSkipped('Test broken due to parse error in PHP Memcached.');
-
$memcached = m::mock(Memcached::class);
$memcached->shouldReceive('decrement')->with('foo', 5)->once()->andReturn(0);
| false |
Other | laravel | framework | d2b14466c27a3d62219256cea27088e6ecd9d32f.json | allow broadcast on demand notifications | src/Illuminate/Notifications/Events/BroadcastNotificationCreated.php | @@ -5,7 +5,9 @@
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
+use Illuminate\Notifications\AnonymousNotifiable;
use Illuminate\Queue\SerializesModels;
+use Illuminate\Support\Arr;
class BroadcastNotificationCreated implements ShouldBroadcast
{
@@ -54,7 +56,12 @@ public function __construct($notifiable, $notification, $data)
*/
public function broadcastOn()
{
- $channels = $this->notification->broadcastOn();
+ if ($this->notifiable instanceof AnonymousNotifiable &&
+ $this->notifiable->routeNotificationFor('broadcast')) {
+ $channels = Arr::wrap($this->notifiable->routeNotificationFor('broadcast'));
+ } else {
+ $channels = $this->notification->broadcastOn();
+ }
if (! empty($channels)) {
return $channels; | false |
Other | laravel | framework | 50bc15f87a78d5f336b2682195409682c75c9b11.json | Convert closures to arrow functions (#43808)
* Convert closures to arrow functions
* Convert closures to arrow functions
fix style | src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php | @@ -42,9 +42,7 @@ public function bootstrap(Application $app)
// Finally, we will set the application's environment based on the configuration
// values that were loaded. We will pass a callback which will be used to get
// the environment in a web context where an "--env" switch is not present.
- $app->detectEnvironment(function () use ($config) {
- return $config->get('app.env', 'production');
- });
+ $app->detectEnvironment(fn () => $config->get('app.env', 'production'));
date_default_timezone_set($config->get('app.timezone', 'UTC'));
| true |
Other | laravel | framework | 50bc15f87a78d5f336b2682195409682c75c9b11.json | Convert closures to arrow functions (#43808)
* Convert closures to arrow functions
* Convert closures to arrow functions
fix style | src/Illuminate/Routing/Route.php | @@ -479,9 +479,7 @@ public function originalParameters()
*/
public function parametersWithoutNulls()
{
- return array_filter($this->parameters(), function ($p) {
- return ! is_null($p);
- });
+ return array_filter($this->parameters(), fn ($p) => ! is_null($p));
}
/**
@@ -507,9 +505,7 @@ protected function compileParameterNames()
{
preg_match_all('/\{(.*?)\}/', $this->getDomain().$this->uri, $matches);
- return array_map(function ($m) {
- return trim($m, '?');
- }, $matches[1]);
+ return array_map(fn ($m) => trim($m, '?'), $matches[1]);
}
/** | true |
Other | laravel | framework | 2d6d02abc87edfc73a4b5154337c86c5933c5c8e.json | Update Migrator.php (#43769)
* Update Migrator.php
Tiny change to grammar in rollback command: "Rolling back" instead of "Rollbacking". Just been bugging me ;)
* Update MigratorTest.php
Fix test so it asserts the new wording during migrate:rollback command | src/Illuminate/Database/Migrations/Migrator.php | @@ -275,7 +275,7 @@ protected function rollbackMigrations(array $migrations, $paths, array $options)
$this->fireMigrationEvent(new MigrationsStarted('down'));
- $this->write(Info::class, 'Rollbacking migrations.');
+ $this->write(Info::class, 'Rolling back migrations.');
// Next we will run through all of the migrations and call the "down" method
// which will reverse each migration in order. This getLast method on the | true |
Other | laravel | framework | 2d6d02abc87edfc73a4b5154337c86c5933c5c8e.json | Update Migrator.php (#43769)
* Update Migrator.php
Tiny change to grammar in rollback command: "Rolling back" instead of "Rollbacking". Just been bugging me ;)
* Update MigratorTest.php
Fix test so it asserts the new wording during migrate:rollback command | tests/Integration/Migration/MigratorTest.php | @@ -60,7 +60,7 @@ public function testRollback()
$this->subject->getRepository()->log('2015_10_04_000000_modify_people_table', 1);
$this->subject->getRepository()->log('2016_10_04_000000_modify_people_table', 1);
- $this->expectInfo('Rollbacking migrations.');
+ $this->expectInfo('Rolling back migrations.');
$this->expectTask('2016_10_04_000000_modify_people_table', 'DONE');
$this->expectTask('2015_10_04_000000_modify_people_table', 'DONE'); | true |
Other | laravel | framework | 76e427ae10d6b7a3a6db02fb040805bfbced402f.json | Convert closures to arrow functions (#43778) | src/Illuminate/Collections/Traits/EnumeratesValues.php | @@ -205,9 +205,7 @@ public function some($key, $operator = null, $value = null)
public function containsStrict($key, $value = null)
{
if (func_num_args() === 2) {
- return $this->contains(function ($item) use ($key, $value) {
- return data_get($item, $key) === $value;
- });
+ return $this->contains(fn ($item) => data_get($item, $key) === $value);
}
if ($this->useAsCallable($key)) {
@@ -404,9 +402,7 @@ public function flatMap(callable $callback)
*/
public function mapInto($class)
{
- return $this->map(function ($value, $key) use ($class) {
- return new $class($value, $key);
- });
+ return $this->map(fn ($value, $key) => new $class($value, $key));
}
/**
@@ -419,13 +415,9 @@ public function min($callback = null)
{
$callback = $this->valueRetriever($callback);
- return $this->map(function ($value) use ($callback) {
- return $callback($value);
- })->filter(function ($value) {
- return ! is_null($value);
- })->reduce(function ($result, $value) {
- return is_null($result) || $value < $result ? $value : $result;
- });
+ return $this->map(fn ($value) => $callback($value))
+ ->filter(fn ($value) => ! is_null($value))
+ ->reduce(fn ($result, $value) => is_null($result) || $value < $result ? $value : $result);
}
/**
@@ -438,9 +430,7 @@ public function max($callback = null)
{
$callback = $this->valueRetriever($callback);
- return $this->filter(function ($value) {
- return ! is_null($value);
- })->reduce(function ($result, $item) use ($callback) {
+ return $this->filter(fn ($value) => ! is_null($value))->reduce(function ($result, $item) use ($callback) {
$value = $callback($item);
return is_null($result) || $value > $result ? $value : $result;
@@ -501,9 +491,7 @@ public function sum($callback = null)
? $this->identity()
: $this->valueRetriever($callback);
- return $this->reduce(function ($result, $item) use ($callback) {
- return $result + $callback($item);
- }, 0);
+ return $this->reduce(fn ($result, $item) => $result + $callback($item), 0);
}
/**
@@ -621,9 +609,7 @@ public function whereIn($key, $values, $strict = false)
{
$values = $this->getArrayableItems($values);
- return $this->filter(function ($item) use ($key, $values, $strict) {
- return in_array(data_get($item, $key), $values, $strict);
- });
+ return $this->filter(fn ($item) => in_array(data_get($item, $key), $values, $strict));
}
/**
@@ -659,9 +645,9 @@ public function whereBetween($key, $values)
*/
public function whereNotBetween($key, $values)
{
- return $this->filter(function ($item) use ($key, $values) {
- return data_get($item, $key) < reset($values) || data_get($item, $key) > end($values);
- });
+ return $this->filter(
+ fn ($item) => data_get($item, $key) < reset($values) || data_get($item, $key) > end($values)
+ );
}
/**
@@ -676,9 +662,7 @@ public function whereNotIn($key, $values, $strict = false)
{
$values = $this->getArrayableItems($values);
- return $this->reject(function ($item) use ($key, $values, $strict) {
- return in_array(data_get($item, $key), $values, $strict);
- });
+ return $this->reject(fn ($item) => in_array(data_get($item, $key), $values, $strict));
}
/**
@@ -751,9 +735,7 @@ public function pipeInto($class)
public function pipeThrough($callbacks)
{
return Collection::make($callbacks)->reduce(
- function ($carry, $callback) {
- return $callback($carry);
- },
+ fn ($carry, $callback) => $callback($carry),
$this,
);
}
@@ -886,9 +868,7 @@ public function collect()
*/
public function toArray()
{
- return $this->map(function ($value) {
- return $value instanceof Arrayable ? $value->toArray() : $value;
- })->all();
+ return $this->map(fn ($value) => $value instanceof Arrayable ? $value->toArray() : $value)->all();
}
/**
@@ -1089,9 +1069,7 @@ protected function valueRetriever($value)
return $value;
}
- return function ($item) use ($value) {
- return data_get($item, $value);
- };
+ return fn ($item) => data_get($item, $value);
}
/**
@@ -1102,9 +1080,7 @@ protected function valueRetriever($value)
*/
protected function equality($value)
{
- return function ($item) use ($value) {
- return $item === $value;
- };
+ return fn ($item) => $item === $value;
}
/**
@@ -1115,9 +1091,7 @@ protected function equality($value)
*/
protected function negate(Closure $callback)
{
- return function (...$params) use ($callback) {
- return ! $callback(...$params);
- };
+ return fn (...$params) => ! $callback(...$params);
}
/**
@@ -1127,8 +1101,6 @@ protected function negate(Closure $callback)
*/
protected function identity()
{
- return function ($value) {
- return $value;
- };
+ return fn ($value) => $value;
}
} | false |
Other | laravel | framework | 548f42f062f9350bf82c4eb5790642f8d4b7c292.json | fix typos in phpdoc (#43759) | src/Illuminate/Support/Facades/Vite.php | @@ -6,9 +6,9 @@
* @method static string useCspNonce(?string $nonce = null)
* @method static string|null cspNonce()
* @method static string asset(string $asset, string|null $buildDirectory)
- * @method static \Illuminte\Foundation\Vite useIntegrityKey(string|false $key)
- * @method static \Illuminte\Foundation\Vite useScriptTagAttributes(callable|array $callback)
- * @method static \Illuminte\Foundation\Vite useStyleTagAttributes(callable|array $callback)
+ * @method static \Illuminate\Foundation\Vite useIntegrityKey(string|false $key)
+ * @method static \Illuminate\Foundation\Vite useScriptTagAttributes(callable|array $callback)
+ * @method static \Illuminate\Foundation\Vite useStyleTagAttributes(callable|array $callback)
*
* @see \Illuminate\Foundation\Vite
*/ | false |
Other | laravel | framework | 1814e8066a6ba658ad42a662de9d3263b9637f9c.json | Fix incorrect unit of measurement (#43667) | src/Illuminate/Database/Console/ShowCommand.php | @@ -148,13 +148,13 @@ protected function displayForCli(array $data)
$this->components->twoColumnDetail('Tables', $tables->count());
if ($tableSizeSum = $tables->sum('size')) {
- $this->components->twoColumnDetail('Total Size', number_format($tableSizeSum / 1024 / 1024, 2).'Mb');
+ $this->components->twoColumnDetail('Total Size', number_format($tableSizeSum / 1024 / 1024, 2).'MiB');
}
$this->newLine();
if ($tables->isNotEmpty()) {
- $this->components->twoColumnDetail('<fg=green;options=bold>Table</>', 'Size (Mb)'.($this->option('counts') ? ' <fg=gray;options=bold>/</> <fg=yellow;options=bold>Rows</>' : ''));
+ $this->components->twoColumnDetail('<fg=green;options=bold>Table</>', 'Size (MiB)'.($this->option('counts') ? ' <fg=gray;options=bold>/</> <fg=yellow;options=bold>Rows</>' : ''));
$tables->each(function ($table) {
if ($tableSize = $table['size']) { | true |
Other | laravel | framework | 1814e8066a6ba658ad42a662de9d3263b9637f9c.json | Fix incorrect unit of measurement (#43667) | src/Illuminate/Database/Console/TableCommand.php | @@ -195,7 +195,7 @@ protected function displayForCli(array $data)
$this->components->twoColumnDetail('Columns', $table['columns']);
if ($size = $table['size']) {
- $this->components->twoColumnDetail('Size', number_format($size / 1024 / 1024, 2).'Mb');
+ $this->components->twoColumnDetail('Size', number_format($size / 1024 / 1024, 2).'MiB');
}
$this->newLine(); | true |
Other | laravel | framework | 2d834af7b54a24380819ec35c59e258e1cac3216.json | Handle assoc mode within db commands (#43636) | src/Illuminate/Database/Console/DatabaseInspectionCommand.php | @@ -8,6 +8,7 @@
use Illuminate\Database\MySqlConnection;
use Illuminate\Database\PostgresConnection;
use Illuminate\Database\SQLiteConnection;
+use Illuminate\Database\SqlServerConnection;
use Illuminate\Support\Arr;
use Illuminate\Support\Composer;
use Symfony\Component\Process\Exception\ProcessSignaledException;
@@ -83,10 +84,12 @@ protected function getTableSize(ConnectionInterface $connection, string $table)
*/
protected function getMySQLTableSize(ConnectionInterface $connection, string $table)
{
- return $connection->selectOne('SELECT (data_length + index_length) AS size FROM information_schema.TABLES WHERE table_schema = ? AND table_name = ?', [
+ $result = $connection->selectOne('SELECT (data_length + index_length) AS size FROM information_schema.TABLES WHERE table_schema = ? AND table_name = ?', [
$connection->getDatabaseName(),
$table,
- ])->size;
+ ]);
+
+ return Arr::wrap((array) $result)['size'];
}
/**
@@ -98,9 +101,11 @@ protected function getMySQLTableSize(ConnectionInterface $connection, string $ta
*/
protected function getPostgresTableSize(ConnectionInterface $connection, string $table)
{
- return $connection->selectOne('SELECT pg_total_relation_size(?) AS size;', [
+ $result = $connection->selectOne('SELECT pg_total_relation_size(?) AS size;', [
$table,
- ])->size;
+ ]);
+
+ return Arr::wrap((array) $result)['size'];
}
/**
@@ -112,25 +117,33 @@ protected function getPostgresTableSize(ConnectionInterface $connection, string
*/
protected function getSqliteTableSize(ConnectionInterface $connection, string $table)
{
- return $connection->selectOne('SELECT SUM(pgsize) FROM dbstat WHERE name=?', [
+ $result = $connection->selectOne('SELECT SUM(pgsize) FROM dbstat WHERE name=?', [
$table,
- ])->size;
+ ]);
+
+ return Arr::wrap((array) $result)['size'];
}
/**
* Get the number of open connections for a database.
*
* @param \Illuminate\Database\ConnectionInterface $connection
- * @return null
+ * @return int|null
*/
protected function getConnectionCount(ConnectionInterface $connection)
{
- return match (class_basename($connection)) {
- 'MySqlConnection' => (int) $connection->selectOne($connection->raw('show status where variable_name = "threads_connected"'))->Value,
- 'PostgresConnection' => (int) $connection->selectOne('select count(*) as connections from pg_stat_activity')->connections,
- 'SqlServerConnection' => (int) $connection->selectOne('SELECT COUNT(*) connections FROM sys.dm_exec_sessions WHERE status = ?', ['running'])->connections,
+ $result = match (true) {
+ $connection instanceof MySqlConnection => $connection->selectOne('show status where variable_name = "threads_connected"'),
+ $connection instanceof PostgresConnection => $connection->selectOne('select count(*) AS "Value" from pg_stat_activity'),
+ $connection instanceof SqlServerConnection => $connection->selectOne('SELECT COUNT(*) Value FROM sys.dm_exec_sessions WHERE status = ?', ['running']),
default => null,
};
+
+ if (! $result) {
+ return null;
+ }
+
+ return Arr::wrap((array) $result)['Value'];
}
/** | false |
Other | laravel | framework | ad6928baacb69939fa0bfe4ea3083c3c178a3568.json | Add NotificationFake::assertCount() (#43659) | src/Illuminate/Support/Facades/Notification.php | @@ -11,6 +11,7 @@
* @method static \Illuminate\Support\Collection sent(mixed $notifiable, string $notification, callable $callback = null)
* @method static bool hasSent(mixed $notifiable, string $notification)
* @method static mixed channel(string|null $name = null)
+ * @method static void assertCount(int $expectedCount)
* @method static void assertNotSentTo(mixed $notifiable, string|\Closure $notification, callable $callback = null)
* @method static void assertNothingSent()
* @method static void assertNothingSentTo(mixed $notifiable) | false |
Other | laravel | framework | 47ab01c0101d4bda3e11fe3699a9107a026dc2b5.json | Add missing method documentation (#43601) | src/Illuminate/Support/Facades/Mail.php | @@ -10,6 +10,7 @@
* @method static void alwaysReplyTo(string $address, string|null $name = null)
* @method static void alwaysReturnPath(string $address)
* @method static void alwaysTo(string $address, string|null $name = null)
+ * @method static \Illuminate\Mail\PendingMail cc($users)
* @method static \Illuminate\Mail\PendingMail bcc($users)
* @method static \Illuminate\Mail\PendingMail to($users)
* @method static \Illuminate\Support\Collection queued(string $mailable, \Closure|string $callback = null) | false |
Other | laravel | framework | 56c6314eefea7e5b298a0d84d742371d5d54ff6f.json | Fix flakey tests (#43595) | tests/Integration/Queue/ThrottlesExceptionsWithRedisTest.php | @@ -54,7 +54,10 @@ public function testCircuitResetsAfterSuccess()
$this->assertJobRanSuccessfully(CircuitBreakerWithRedisSuccessfulJob::class, $key);
$this->assertJobWasReleasedImmediately(CircuitBreakerWithRedisTestJob::class, $key);
$this->assertJobWasReleasedImmediately(CircuitBreakerWithRedisTestJob::class, $key);
- $this->assertJobWasReleasedWithDelay(CircuitBreakerWithRedisTestJob::class, $key);
+
+ retry(2, function () use ($key) {
+ $this->assertJobWasReleasedWithDelay(CircuitBreakerWithRedisTestJob::class, $key);
+ });
}
protected function assertJobWasReleasedImmediately($class, $key) | false |
Other | laravel | framework | 7e05da7dcd7bbceb3f36a047e091b02d630f5cfb.json | add test for dynamic relations of models (#43577) | tests/Database/DatabaseEloquentDynamicRelationsTest.php | @@ -0,0 +1,108 @@
+<?php
+
+namespace Illuminate\Tests\Database;
+
+use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\HasMany;
+use Illuminate\Database\Eloquent\Relations\HasOne;
+use Illuminate\Database\Query\Builder as Query;
+use Illuminate\Tests\Database\DynamicRelationModel2 as Related;
+use PHPUnit\Framework\TestCase;
+
+class DatabaseEloquentDynamicRelationsTest extends TestCase
+{
+ public function testBasicDynamicRelations()
+ {
+ DynamicRelationModel::resolveRelationUsing('dynamicRel_2', fn () => new FakeHasManyRel);
+ $model = new DynamicRelationModel;
+ $this->assertEquals(['many' => 'related'], $model->dynamicRel_2);
+ $this->assertEquals(['many' => 'related'], $model->getRelationValue('dynamicRel_2'));
+ }
+
+ public function testDynamicRelationsOverride()
+ {
+ // Dynamic Relations can override each other.
+ DynamicRelationModel::resolveRelationUsing('dynamicRelConflict', fn ($m) => $m->hasOne(Related::class));
+ DynamicRelationModel::resolveRelationUsing('dynamicRelConflict', fn (DynamicRelationModel $m) => new FakeHasManyRel);
+
+ $model = new DynamicRelationModel;
+ $this->assertInstanceOf(HasMany::class, $model->dynamicRelConflict());
+ $this->assertEquals(['many' => 'related'], $model->dynamicRelConflict);
+ $this->assertEquals(['many' => 'related'], $model->getRelationValue('dynamicRelConflict'));
+ $this->assertTrue($model->isRelation('dynamicRelConflict'));
+ }
+
+ public function testDynamicRelationsCanNotHaveTheSameNameAsNormalRelations()
+ {
+ $model = new DynamicRelationModel;
+
+ // Dynamic relations can not override hard-coded methods.
+ DynamicRelationModel::resolveRelationUsing('hardCodedRelation', fn ($m) => $m->hasOne(Related::class));
+ $this->assertInstanceOf(HasMany::class, $model->hardCodedRelation());
+ $this->assertEquals(['many' => 'related'], $model->hardCodedRelation);
+ $this->assertEquals(['many' => 'related'], $model->getRelationValue('hardCodedRelation'));
+ $this->assertTrue($model->isRelation('hardCodedRelation'));
+ }
+
+ public function testRelationResolvers()
+ {
+ $model1 = new DynamicRelationModel;
+ $model3 = new DynamicRelationModel3;
+
+ // Same dynamic methods with the same name on two models do not conflict or override.
+ DynamicRelationModel::resolveRelationUsing('dynamicRel', fn ($m) => $m->hasOne(Related::class));
+ DynamicRelationModel3::resolveRelationUsing('dynamicRel', fn (DynamicRelationModel3 $m) => $m->hasMany(Related::class));
+ $this->assertInstanceOf(HasOne::class, $model1->dynamicRel());
+ $this->assertInstanceOf(HasMany::class, $model3->dynamicRel());
+ $this->assertTrue($model1->isRelation('dynamicRel'));
+ $this->assertTrue($model3->isRelation('dynamicRel'));
+ }
+}
+
+class DynamicRelationModel extends Model
+{
+ public function hardCodedRelation()
+ {
+ return new FakeHasManyRel();
+ }
+}
+
+class DynamicRelationModel2 extends Model
+{
+ public function getResults()
+ {
+ //
+ }
+
+ public function newQuery()
+ {
+ $query = new class extends Query
+ {
+ public function __construct()
+ {
+ //
+ }
+ };
+
+ return new Builder($query);
+ }
+}
+
+class DynamicRelationModel3 extends Model
+{
+ //
+}
+
+class FakeHasManyRel extends HasMany
+{
+ public function __construct()
+ {
+ //
+ }
+
+ public function getResults()
+ {
+ return ['many' => 'related'];
+ }
+} | true |
Other | laravel | framework | 7e05da7dcd7bbceb3f36a047e091b02d630f5cfb.json | add test for dynamic relations of models (#43577) | tests/Database/DatabaseEloquentRelationTest.php | @@ -269,20 +269,6 @@ public function testMacroable()
$this->assertSame('foo', $result);
}
- public function testRelationResolvers()
- {
- $model = new EloquentRelationResetModelStub;
- $builder = m::mock(Builder::class);
- $builder->shouldReceive('getModel')->andReturn($model);
-
- EloquentRelationResetModelStub::resolveRelationUsing('customer', function ($model) use ($builder) {
- return new EloquentResolverRelationStub($builder, $model);
- });
-
- $this->assertInstanceOf(EloquentResolverRelationStub::class, $model->customer());
- $this->assertSame(['key' => 'value'], $model->customer);
- }
-
public function testIsRelationIgnoresAttribute()
{
$model = new EloquentRelationAndAtrributeModelStub;
@@ -353,14 +339,6 @@ class EloquentNoTouchingAnotherModelStub extends Model
];
}
-class EloquentResolverRelationStub extends EloquentRelationStub
-{
- public function getResults()
- {
- return ['key' => 'value'];
- }
-}
-
class EloquentRelationAndAtrributeModelStub extends Model
{
protected $table = 'one_more_table'; | true |
Other | laravel | framework | 7f67ce97f663cfc01f572f0b5b039f99eae7c4a5.json | Remove incorrect `static` modifier (#43576) | src/Illuminate/Support/DateFactory.php | @@ -9,77 +9,77 @@
* @see https://carbon.nesbot.com/docs/
* @see https://github.com/briannesbitt/Carbon/blob/master/src/Carbon/Factory.php
*
- * @method static Carbon create($year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $tz = null)
- * @method static Carbon createFromDate($year = null, $month = null, $day = null, $tz = null)
- * @method static Carbon|false createFromFormat($format, $time, $tz = null)
- * @method static Carbon createFromTime($hour = 0, $minute = 0, $second = 0, $tz = null)
- * @method static Carbon createFromTimeString($time, $tz = null)
- * @method static Carbon createFromTimestamp($timestamp, $tz = null)
- * @method static Carbon createFromTimestampMs($timestamp, $tz = null)
- * @method static Carbon createFromTimestampUTC($timestamp)
- * @method static Carbon createMidnightDate($year = null, $month = null, $day = null, $tz = null)
- * @method static Carbon|false createSafe($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $tz = null)
- * @method static Carbon disableHumanDiffOption($humanDiffOption)
- * @method static Carbon enableHumanDiffOption($humanDiffOption)
- * @method static mixed executeWithLocale($locale, $func)
- * @method static Carbon fromSerialized($value)
- * @method static array getAvailableLocales()
- * @method static array getDays()
- * @method static int getHumanDiffOptions()
- * @method static array getIsoUnits()
- * @method static Carbon getLastErrors()
- * @method static string getLocale()
- * @method static int getMidDayAt()
- * @method static Carbon getTestNow()
- * @method static \Symfony\Component\Translation\TranslatorInterface getTranslator()
- * @method static int getWeekEndsAt()
- * @method static int getWeekStartsAt()
- * @method static array getWeekendDays()
- * @method static bool hasFormat($date, $format)
- * @method static bool hasMacro($name)
- * @method static bool hasRelativeKeywords($time)
- * @method static bool hasTestNow()
- * @method static Carbon instance($date)
- * @method static bool isImmutable()
- * @method static bool isModifiableUnit($unit)
- * @method static Carbon isMutable()
- * @method static bool isStrictModeEnabled()
- * @method static bool localeHasDiffOneDayWords($locale)
- * @method static bool localeHasDiffSyntax($locale)
- * @method static bool localeHasDiffTwoDayWords($locale)
- * @method static bool localeHasPeriodSyntax($locale)
- * @method static bool localeHasShortUnits($locale)
- * @method static void macro($name, $macro)
- * @method static Carbon|null make($var)
- * @method static Carbon maxValue()
- * @method static Carbon minValue()
- * @method static void mixin($mixin)
- * @method static Carbon now($tz = null)
- * @method static Carbon parse($time = null, $tz = null)
- * @method static string pluralUnit(string $unit)
- * @method static void resetMonthsOverflow()
- * @method static void resetToStringFormat()
- * @method static void resetYearsOverflow()
- * @method static void serializeUsing($callback)
- * @method static Carbon setHumanDiffOptions($humanDiffOptions)
- * @method static bool setLocale($locale)
- * @method static void setMidDayAt($hour)
- * @method static void setTestNow($testNow = null)
- * @method static void setToStringFormat($format)
- * @method static void setTranslator(\Symfony\Component\Translation\TranslatorInterface $translator)
- * @method static Carbon setUtf8($utf8)
- * @method static void setWeekEndsAt($day)
- * @method static void setWeekStartsAt($day)
- * @method static void setWeekendDays($days)
- * @method static bool shouldOverflowMonths()
- * @method static bool shouldOverflowYears()
- * @method static string singularUnit(string $unit)
- * @method static Carbon today($tz = null)
- * @method static Carbon tomorrow($tz = null)
- * @method static void useMonthsOverflow($monthsOverflow = true)
- * @method static Carbon useStrictMode($strictModeEnabled = true)
- * @method static void useYearsOverflow($yearsOverflow = true)
- * @method static Carbon yesterday($tz = null)
+ * @method Carbon create($year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $tz = null)
+ * @method Carbon createFromDate($year = null, $month = null, $day = null, $tz = null)
+ * @method Carbon|false createFromFormat($format, $time, $tz = null)
+ * @method Carbon createFromTime($hour = 0, $minute = 0, $second = 0, $tz = null)
+ * @method Carbon createFromTimeString($time, $tz = null)
+ * @method Carbon createFromTimestamp($timestamp, $tz = null)
+ * @method Carbon createFromTimestampMs($timestamp, $tz = null)
+ * @method Carbon createFromTimestampUTC($timestamp)
+ * @method Carbon createMidnightDate($year = null, $month = null, $day = null, $tz = null)
+ * @method Carbon|false createSafe($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $tz = null)
+ * @method Carbon disableHumanDiffOption($humanDiffOption)
+ * @method Carbon enableHumanDiffOption($humanDiffOption)
+ * @method mixed executeWithLocale($locale, $func)
+ * @method Carbon fromSerialized($value)
+ * @method array getAvailableLocales()
+ * @method array getDays()
+ * @method int getHumanDiffOptions()
+ * @method array getIsoUnits()
+ * @method Carbon getLastErrors()
+ * @method string getLocale()
+ * @method int getMidDayAt()
+ * @method Carbon getTestNow()
+ * @method \Symfony\Component\Translation\TranslatorInterface getTranslator()
+ * @method int getWeekEndsAt()
+ * @method int getWeekStartsAt()
+ * @method array getWeekendDays()
+ * @method bool hasFormat($date, $format)
+ * @method bool hasMacro($name)
+ * @method bool hasRelativeKeywords($time)
+ * @method bool hasTestNow()
+ * @method Carbon instance($date)
+ * @method bool isImmutable()
+ * @method bool isModifiableUnit($unit)
+ * @method Carbon isMutable()
+ * @method bool isStrictModeEnabled()
+ * @method bool localeHasDiffOneDayWords($locale)
+ * @method bool localeHasDiffSyntax($locale)
+ * @method bool localeHasDiffTwoDayWords($locale)
+ * @method bool localeHasPeriodSyntax($locale)
+ * @method bool localeHasShortUnits($locale)
+ * @method void macro($name, $macro)
+ * @method Carbon|null make($var)
+ * @method Carbon maxValue()
+ * @method Carbon minValue()
+ * @method void mixin($mixin)
+ * @method Carbon now($tz = null)
+ * @method Carbon parse($time = null, $tz = null)
+ * @method string pluralUnit(string $unit)
+ * @method void resetMonthsOverflow()
+ * @method void resetToStringFormat()
+ * @method void resetYearsOverflow()
+ * @method void serializeUsing($callback)
+ * @method Carbon setHumanDiffOptions($humanDiffOptions)
+ * @method bool setLocale($locale)
+ * @method void setMidDayAt($hour)
+ * @method void setTestNow($testNow = null)
+ * @method void setToStringFormat($format)
+ * @method void setTranslator(\Symfony\Component\Translation\TranslatorInterface $translator)
+ * @method Carbon setUtf8($utf8)
+ * @method void setWeekEndsAt($day)
+ * @method void setWeekStartsAt($day)
+ * @method void setWeekendDays($days)
+ * @method bool shouldOverflowMonths()
+ * @method bool shouldOverflowYears()
+ * @method string singularUnit(string $unit)
+ * @method Carbon today($tz = null)
+ * @method Carbon tomorrow($tz = null)
+ * @method void useMonthsOverflow($monthsOverflow = true)
+ * @method Carbon useStrictMode($strictModeEnabled = true)
+ * @method void useYearsOverflow($yearsOverflow = true)
+ * @method Carbon yesterday($tz = null)
*/
class DateFactory
{ | false |
Other | laravel | framework | 50f5a916f1285d97bab896c557ed2f76df274f92.json | Improve windows support and WSL support (#43585) | src/Illuminate/Foundation/Console/DocsCommand.php | @@ -388,25 +388,28 @@ protected function openViaCustomStrategy($url)
*/
protected function openViaBuiltInStrategy($url)
{
- $binary = (new ExecutableFinder())->find(match ($this->systemOsFamily) {
- 'Darwin' => 'open',
- 'Windows' => 'start',
- 'Linux' => 'xdg-open',
- });
+ if ($this->systemOsFamily === 'Windows') {
+ $process = tap(Process::fromShellCommandline(escapeshellcmd("start {$url}")))->run();
+
+ if (! $process->isSuccessful()) {
+ throw new ProcessFailedException($process);
+ }
+
+ return;
+ }
+
+ $binary = Collection::make(match ($this->systemOsFamily) {
+ 'Darwin' => ['open'],
+ 'Linux' => ['xdg-open', 'wslview'],
+ })->first(fn ($binary) => (new ExecutableFinder)->find($binary) !== null);
if ($binary === null) {
$this->components->warn('Unable to open the URL on your system. You will need to open it yourself or create a custom opener for your system.');
return;
}
- $binaryExecutable = [
- 'Darwin' => 'open',
- 'Windows' => 'start',
- 'Linux' => 'xdg-open',
- ][$this->systemOsFamily];
-
- $process = tap(Process::fromShellCommandline($binaryExecutable.' '.escapeshellcmd($url)))->run();
+ $process = tap(Process::fromShellCommandline(escapeshellcmd("{$binary} {$url}")))->run();
if (! $process->isSuccessful()) {
throw new ProcessFailedException($process); | false |
Other | laravel | framework | 7e77f4edc533c02d3741afbb551afd2cb77f2754.json | Remove redundant @group annotation (#43580) | tests/Testing/TestResponseTest.php | @@ -1651,9 +1651,6 @@ public function testJsonHelper()
);
}
- /**
- * @group 1
- */
public function testResponseCanBeReturnedAsCollection()
{
$response = TestResponse::fromBaseResponse(new Response(new JsonSerializableMixedResourcesStub)); | false |
Other | laravel | framework | 3f788b7121ded5ca096c55e062124733f506f2f9.json | Apply fixes from StyleCI | src/Illuminate/Foundation/Console/DocsCommand.php | @@ -401,9 +401,9 @@ protected function openViaBuiltInStrategy($url)
}
$binaryExecutable = [
- 'Darwin' => 'open',
- 'Windows' => 'start',
- 'Linux' => 'xdg-open'
+ 'Darwin' => 'open',
+ 'Windows' => 'start',
+ 'Linux' => 'xdg-open',
][$this->systemOsFamily];
$process = tap(Process::fromShellCommandline($binaryExecutable.' '.escapeshellcmd($url)))->run(); | false |
Other | laravel | framework | bb91bf7c0883707dfef34a20a87e95a4f75e6c29.json | Apply fixes from StyleCI | src/Illuminate/View/Compilers/ComponentTagCompiler.php | @@ -574,7 +574,7 @@ protected function parseAttributeBag(string $attributeString)
*/
protected function parseComponentTagClassStatements(string $attributeString)
{
- return preg_replace_callback(
+ return preg_replace_callback(
'/@(class)(\( ( (?>[^()]+) | (?2) )* \))/x', function ($match) {
if ($match[1] === 'class') {
$match[2] = str_replace('"', "'", $match[2]); | false |
Other | laravel | framework | 075dde12e118419dfa5badd26acbe34c7f15c24f.json | add test for delete quietly (#43538) | tests/Integration/Database/EloquentDeleteTest.php | @@ -65,6 +65,30 @@ public function testForceDeletedEventIsFired()
$this->assertEquals($role->id, RoleObserver::$model->id);
}
+
+ public function testDeleteQuietly()
+ {
+ $_SERVER['(-_-)'] = '\(^_^)/';
+ Post::deleting(fn () => $_SERVER['(-_-)'] = null);
+ Post::deleted(fn () => $_SERVER['(-_-)'] = null);
+ $post = Post::query()->create([]);
+ $result = $post->deleteQuietly();
+
+ $this->assertEquals('\(^_^)/', $_SERVER['(-_-)']);
+ $this->assertTrue($result);
+ $this->assertFalse($post->exists);
+
+ // For a soft-deleted model:
+ Role::deleting(fn () => $_SERVER['(-_-)'] = null);
+ Role::deleted(fn () => $_SERVER['(-_-)'] = null);
+ Role::softDeleted(fn () => $_SERVER['(-_-)'] = null);
+ $role = Role::create([]);
+ $result = $role->deleteQuietly();
+ $this->assertTrue($result);
+ $this->assertEquals('\(^_^)/', $_SERVER['(-_-)']);
+
+ unset($_SERVER['(-_-)']);
+ }
}
class Comment extends Model | false |
Other | laravel | framework | 75d10c51a9cd08c9f8c95444088d8987febd11ea.json | add union type for expected listener (#43522)
Co-authored-by: charlesbilbo <c.bilbo@rxmg.com> | src/Illuminate/Support/Facades/Event.php | @@ -17,7 +17,7 @@
* @method static void assertDispatchedTimes(string $event, int $times = 1)
* @method static void assertNotDispatched(string|\Closure $event, callable|int $callback = null)
* @method static void assertNothingDispatched()
- * @method static void assertListening(string $expectedEvent, string $expectedListener)
+ * @method static void assertListening(string $expectedEvent, string|array $expectedListener)
* @method static void flush(string $event)
* @method static void forget(string $event)
* @method static void forgetPushed() | false |
Other | laravel | framework | 79b8b701e1be8e90372aec1f34724b63204b44a4.json | Update method signature
Fix default value for confirm component's second argument | src/Illuminate/Console/View/Components/Factory.php | @@ -8,7 +8,7 @@
* @method void alert(string $string, int $verbosity = \Symfony\Component\Console\Output\OutputInterface::VERBOSITY_NORMAL)
* @method void bulletList(array $elements, int $verbosity = \Symfony\Component\Console\Output\OutputInterface::VERBOSITY_NORMAL)
* @method mixed choice(string $question, array $choices, $default = null)
- * @method bool confirm(string $question, bool $default = true)
+ * @method bool confirm(string $question, bool $default = false)
* @method void error(string $string, int $verbosity = \Symfony\Component\Console\Output\OutputInterface::VERBOSITY_NORMAL)
* @method void info(string $string, int $verbosity = \Symfony\Component\Console\Output\OutputInterface::VERBOSITY_NORMAL)
* @method void line(string $style, string $string, int $verbosity = \Symfony\Component\Console\Output\OutputInterface::VERBOSITY_NORMAL) | false |
Other | laravel | framework | 71c7fe77b432966162a0ca2ec957c033ae591954.json | Fix typo in BelongsToMany (#43496) | src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php | @@ -877,7 +877,7 @@ protected function shouldSelect(array $columns = ['*'])
/**
* Get the pivot columns for the relation.
*
- * "pivot_" is prefixed ot each column for easy removal later.
+ * "pivot_" is prefixed at each column for easy removal later.
*
* @return array
*/ | false |
Other | laravel | framework | d1c3faa3e70a5862287a10846dee5aedc13130f8.json | Apply fixes from StyleCI | src/Illuminate/Foundation/Console/DocsCommand.php | @@ -51,7 +51,7 @@ class DocsCommand extends Command
protected $help = 'If you would like to perform a content search against the documention, you may call: <fg=green>php artisan docs -- </><fg=green;options=bold;>search query here</>';
/**
- * The HTTP client instance
+ * The HTTP client instance.
*
* @var \Illuminate\Http\Client\Factory
*/ | false |
Other | laravel | framework | 83c425b17758315964be7bc605c740a4c008b56b.json | allow simpler singleton binding syntax (#43469) | src/Illuminate/Foundation/Application.php | @@ -696,6 +696,8 @@ public function register($provider, $force = false)
if (property_exists($provider, 'singletons')) {
foreach ($provider->singletons as $key => $value) {
+ $key = is_int($key) ? $value : $key;
+
$this->singleton($key, $value);
}
} | true |
Other | laravel | framework | 83c425b17758315964be7bc605c740a4c008b56b.json | allow simpler singleton binding syntax (#43469) | tests/Foundation/FoundationApplicationTest.php | @@ -67,6 +67,7 @@ public function testSingletonsAreCreatedWhenServiceProviderIsRegistered()
$app->register($provider = new class($app) extends ServiceProvider
{
public $singletons = [
+ NonContractBackedClass::class,
AbstractClass::class => ConcreteClass::class,
];
});
@@ -77,6 +78,11 @@ public function testSingletonsAreCreatedWhenServiceProviderIsRegistered()
$this->assertInstanceOf(ConcreteClass::class, $instance);
$this->assertSame($instance, $app->make(AbstractClass::class));
+
+ $instance = $app->make(NonContractBackedClass::class);
+
+ $this->assertInstanceOf(NonContractBackedClass::class, $instance);
+ $this->assertSame($instance, $app->make(NonContractBackedClass::class));
}
public function testServiceProvidersAreCorrectlyRegisteredWhenRegisterMethodIsNotFilled()
@@ -613,6 +619,11 @@ class ConcreteClass extends AbstractClass
//
}
+class NonContractBackedClass
+{
+ //
+}
+
class ConcreteTerminator
{
public static $counter = 0; | true |
Other | laravel | framework | 6baf6c0b15f4374a50bdc72b1911cdb2791a203a.json | Report Closure observers instead of breaking | src/Illuminate/Foundation/Console/ShowModelCommand.php | @@ -270,7 +270,10 @@ protected function getObservers($model)
$formatted = [];
foreach($listeners as $key => $observerMethods) {
- $formatted[] = ['event' => $extractVerb($key), 'observer' => $observerMethods];
+ $formatted[] = [
+ 'event' => $extractVerb($key),
+ 'observer' => array_map(fn ($obs) => is_string($obs) ? $obs : 'Closure', $observerMethods),
+ ];
}
return collect($formatted); | false |
Other | laravel | framework | 22e3efcf909095828cc347f185fc29cdb8e3a947.json | Update ComponentMakeCommand.php (#43446) | src/Illuminate/Foundation/Console/ComponentMakeCommand.php | @@ -92,7 +92,7 @@ protected function writeView($onSuccess = null)
file_put_contents(
$path,
'<div>
- <!-- '.Inspiring::quote().' -->
+ <!-- '.Inspiring::quotes()->random().' -->
</div>'
);
@@ -112,7 +112,7 @@ protected function buildClass($name)
if ($this->option('inline')) {
return str_replace(
['DummyView', '{{ view }}'],
- "<<<'blade'\n<div>\n <!-- ".Inspiring::quote()." -->\n</div>\nblade",
+ "<<<'blade'\n<div>\n <!-- ".Inspiring::quotes()->random()." -->\n</div>\nblade",
parent::buildClass($name)
);
} | false |
Other | laravel | framework | 7cde02d2b7cc6bdd415b33a0f3d54b579c41ebe8.json | Fix doc block (#43444) | src/Illuminate/Notifications/Messages/MailMessage.php | @@ -356,7 +356,7 @@ protected function arrayOfAddresses($address)
/**
* Render the mail notification message into an HTML string.
*
- * @return string
+ * @return \Illuminate\Support\HtmlString
*/
public function render()
{ | false |
Other | laravel | framework | 09e89cf6cc23438c415b516d117eb551f4c9d362.json | Apply fixes from StyleCI | tests/Integration/Broadcasting/BroadcastManagerTest.php | @@ -46,7 +46,7 @@ public function testUniqueEventsCanBeBroadcast()
Bus::assertNotDispatched(UniqueBroadcastEvent::class);
Queue::assertPushed(UniqueBroadcastEvent::class);
-
+
$lockKey = 'laravel_unique_job:'.UniqueBroadcastEvent::class.TestEventUnique::class;
$this->assertTrue($this->app->get(Cache::class)->lock($lockKey, 10)->get());
} | false |
Other | laravel | framework | 6bdc08511762479189a1046a3ea7f413216a412a.json | Update Task.php (#43400) | src/Illuminate/Console/View/Components/Task.php | @@ -38,7 +38,7 @@ public function render($description, $task = null, $verbosity = OutputInterface:
throw $e;
} finally {
$runTime = $task
- ? (' '.number_format((microtime(true) - $startTime) * 1000, 2).'ms')
+ ? (' '.number_format((microtime(true) - $startTime) * 1000).'ms')
: '';
$runTimeWidth = mb_strlen($runTime); | false |
Other | laravel | framework | 3a0ad1a739ee0140e4770c0c66eb40d0125e9cf8.json | Add conditional line to MailMessage (#43387) | src/Illuminate/Notifications/Messages/SimpleMessage.php | @@ -157,6 +157,22 @@ public function line($line)
return $this->with($line);
}
+ /**
+ * Add a line of text to the notification if the given condition is true.
+ *
+ * @param bool $boolean
+ * @param mixed $line
+ * @return $this
+ */
+ public function lineIf($boolean, $line)
+ {
+ if ($boolean) {
+ return $this->line($line);
+ }
+
+ return $this;
+ }
+
/**
* Add lines of text to the notification.
*
@@ -172,6 +188,22 @@ public function lines($lines)
return $this;
}
+ /**
+ * Add lines of text to the notification if the given condition is true.
+ *
+ * @param bool $boolean
+ * @param iterable $lines
+ * @return $this
+ */
+ public function linesIf($boolean, $lines)
+ {
+ if ($boolean) {
+ return $this->lines($lines);
+ }
+
+ return $this;
+ }
+
/**
* Add a line of text to the notification.
* | false |
Other | laravel | framework | 7a0a7357a20eeddb2c534a1daed9715051eaeaf5.json | Fix typos in `PruneCommand` (#43316) | src/Illuminate/Database/Console/PruneCommand.php | @@ -56,15 +56,15 @@ public function handle(Dispatcher $events)
return;
}
- $prunning = [];
+ $pruning = [];
- $events->listen(ModelsPruned::class, function ($event) use (&$prunning) {
- if (! in_array($event->model, $prunning)) {
- $prunning[] = $event->model;
+ $events->listen(ModelsPruned::class, function ($event) use (&$pruning) {
+ if (! in_array($event->model, $pruning)) {
+ $pruning[] = $event->model;
$this->newLine();
- $this->components->info(sprintf('Prunning [%s] records.', $event->model));
+ $this->components->info(sprintf('Pruning [%s] records.', $event->model));
}
$this->components->twoColumnDetail($event->model, "{$event->count} records"); | false |
Other | laravel | framework | c9483ef91971b366003a4d3ee48c9dd6d35f5d4e.json | Add "Logs" driver to the `about` command (#43307) | src/Illuminate/Foundation/Console/AboutCommand.php | @@ -165,10 +165,23 @@ protected function gatherApplicationInformation()
'Views' => $this->hasPhpFiles($this->laravel->storagePath('framework/views')) ? '<fg=green;options=bold>CACHED</>' : '<fg=yellow;options=bold>NOT CACHED</>',
]);
+ $logChannel = config('logging.default');
+ $logChannelDriver = config('logging.channels.'.$logChannel.'.driver');
+
+ if ($logChannelDriver === 'stack') {
+ $secondary = collect(config('logging.channels.'.$logChannel.'.channels'))
+ ->implode(', ');
+
+ $logs = '<fg=yellow;options=bold>'.$logChannel.'</> <fg=gray;options=bold>/</> '.$secondary;
+ } else {
+ $logs = $logChannel;
+ }
+
static::add('Drivers', array_filter([
'Broadcasting' => config('broadcasting.default'),
'Cache' => config('cache.default'),
'Database' => config('database.default'),
+ 'Logs' => $logs,
'Mail' => config('mail.default'),
'Octane' => config('octane.server'),
'Queue' => config('queue.default'), | false |
Other | laravel | framework | 2a0bb9c7061bf4b577121a878412d96642d94e32.json | improve test for first in Collection (#43268)
* improve test of filter in Collection
If no callback is supplied, all entries of the collection that are equivalent to false will be removed
* improve test for first
if callback not supplied, and collection is not empty, default value is effectless | tests/Support/SupportCollectionTest.php | @@ -71,6 +71,10 @@ public function testFirstWithDefaultAndWithoutCallback($collection)
$data = new $collection;
$result = $data->first(null, 'default');
$this->assertSame('default', $result);
+
+ $data = new $collection(['foo', 'bar']);
+ $result = $data->first(null, 'default');
+ $this->assertSame('foo', $result);
}
/** | false |
Other | laravel | framework | b15dc2ac7e4c7b382ec5cf09e2983ab94cccc83c.json | improve test of filter in Collection (#43258)
If no callback is supplied, all entries of the collection that are equivalent to false will be removed | tests/Support/SupportCollectionTest.php | @@ -868,6 +868,9 @@ public function testFilter($collection)
$this->assertEquals(['first' => 'Hello', 'second' => 'World'], $c->filter(function ($item, $key) {
return $key !== 'id';
})->all());
+
+ $c = new $collection([1, 2, 3, null, false, '', 0, []]);
+ $this->assertEquals([1, 2, 3], $c->filter()->all());
}
/** | false |
Other | laravel | framework | b3b6f5b1f0797f6c2b43502dda5837e7f245cd54.json | Support closures as values (#43225) | src/Illuminate/Foundation/Console/AboutCommand.php | @@ -120,7 +120,7 @@ protected function displayDetail($data)
foreach ($data as $detail) {
[$label, $value] = $detail;
- $this->components->twoColumnDetail($label, $value);
+ $this->components->twoColumnDetail($label, value($value));
}
});
}
@@ -134,7 +134,7 @@ protected function displayDetail($data)
protected function displayJson($data)
{
$output = $data->flatMap(function ($data, $section) {
- return [(string) Str::of($section)->snake() => collect($data)->mapWithKeys(fn ($item, $key) => [(string) Str::of($item[0])->lower()->snake() => $item[1]])];
+ return [(string) Str::of($section)->snake() => collect($data)->mapWithKeys(fn ($item, $key) => [(string) Str::of($item[0])->lower()->snake() => value($item[1])])];
});
$this->output->writeln(strip_tags(json_encode($output))); | false |
Other | laravel | framework | 90f73be45ae207982e5d5ea943c35a5ee5a8c1f8.json | Apply fixes from StyleCI | tests/Support/SupportCollectionTest.php | @@ -3993,7 +3993,7 @@ public function testGettingAvgItemsFromCollection($collection)
$c = new $collection;
$this->assertNull($c->avg());
- $c = new $collection([['foo' => "4"], ['foo' => "2"]]);
+ $c = new $collection([['foo' => '4'], ['foo' => '2']]);
$this->assertIsInt($c->avg('foo'));
$this->assertEquals(3, $c->avg('foo'));
@@ -4003,9 +4003,9 @@ public function testGettingAvgItemsFromCollection($collection)
$c = new $collection([
['foo' => 1], ['foo' => 2],
- (object)['foo' => 6]
+ (object) ['foo' => 6],
]);
- $this->assertEquals(3,$c->avg('foo'));
+ $this->assertEquals(3, $c->avg('foo'));
}
/** | false |
Other | laravel | framework | 61b260556da4e75bff9b721b0085dd8848b9ea31.json | improve mode function in collection (#43240) | src/Illuminate/Collections/Collection.php | @@ -104,9 +104,8 @@ public function avg($callback = null)
public function median($key = null)
{
$values = (isset($key) ? $this->pluck($key) : $this)
- ->filter(function ($item) {
- return ! is_null($item);
- })->sort()->values();
+ ->filter(fn ($item) => ! is_null($item))
+ ->sort()->values();
$count = $values->count();
@@ -141,17 +140,14 @@ public function mode($key = null)
$counts = new static;
- $collection->each(function ($value) use ($counts) {
- $counts[$value] = isset($counts[$value]) ? $counts[$value] + 1 : 1;
- });
+ $collection->each(fn ($value) => $counts[$value] = isset($counts[$value]) ? $counts[$value] + 1 : 1);
$sorted = $counts->sort();
$highestValue = $sorted->last();
- return $sorted->filter(function ($value) use ($highestValue) {
- return $value == $highestValue;
- })->sort()->keys()->all();
+ return $sorted->filter(fn ($value) => $value == $highestValue)
+ ->sort()->keys()->all();
}
/** | true |
Other | laravel | framework | 61b260556da4e75bff9b721b0085dd8848b9ea31.json | improve mode function in collection (#43240) | tests/Support/SupportCollectionTest.php | @@ -3992,6 +3992,20 @@ public function testGettingAvgItemsFromCollection($collection)
$c = new $collection;
$this->assertNull($c->avg());
+
+ $c = new $collection([['foo' => "4"], ['foo' => "2"]]);
+ $this->assertIsInt($c->avg('foo'));
+ $this->assertEquals(3, $c->avg('foo'));
+
+ $c = new $collection([['foo' => 1], ['foo' => 2]]);
+ $this->assertIsFloat($c->avg('foo'));
+ $this->assertEquals(1.5, $c->avg('foo'));
+
+ $c = new $collection([
+ ['foo' => 1], ['foo' => 2],
+ (object)['foo' => 6]
+ ]);
+ $this->assertEquals(3,$c->avg('foo'));
}
/**
@@ -4323,6 +4337,7 @@ public function testModeOnNullCollection($collection)
public function testMode($collection)
{
$data = new $collection([1, 2, 3, 4, 4, 5]);
+ $this->assertIsArray($data->mode());
$this->assertEquals([4], $data->mode());
}
@@ -4337,7 +4352,14 @@ public function testModeValueByKey($collection)
(object) ['foo' => 2],
(object) ['foo' => 4],
]);
+ $data2 = new Collection([
+ ['foo' => 1],
+ ['foo' => 1],
+ ['foo' => 2],
+ ['foo' => 4],
+ ]);
$this->assertEquals([1], $data->mode('foo'));
+ $this->assertEquals($data2->mode('foo'), $data->mode('foo'));
}
/** | true |
Other | laravel | framework | 51b5edaa2f8dfb0acb520ecb394706ade2200a35.json | Print new line at end of `about` command output | src/Illuminate/Foundation/Console/AboutCommand.php | @@ -86,6 +86,8 @@ public function handle()
})
->pipe(fn ($data) => $this->display($data));
+ $this->newLine();
+
return 0;
}
| false |
Other | laravel | framework | 8734c47fff3fe51cd80d48cfde65bedfbc14a81f.json | Remove valid password | tests/Validation/ValidationPasswordRuleTest.php | @@ -111,7 +111,6 @@ public function testUncompromised()
'123456',
'password',
'welcome',
- 'ninja',
'abc123',
'123456789',
'12345678', | false |
Other | laravel | framework | 6ee81be055a0b7fc6d5c2c5c3566a897707c8250.json | Apply fixes from StyleCI | tests/Integration/Routing/UrlSigningTest.php | @@ -273,7 +273,8 @@ public function testSignedMiddlewareIgnoringParameter()
protected function createValidateSignatureMiddleware(array $ignore)
{
- return new class ($ignore) extends ValidateSignature {
+ return new class($ignore) extends ValidateSignature
+ {
public function __construct(array $ignore)
{
$this->ignore = $ignore; | false |
Other | laravel | framework | 57c5672e12a9bcb6143134dc5644a2b45fe9d207.json | Simplify sone FQCN. (#43053) | src/Illuminate/Auth/Access/Gate.php | @@ -4,6 +4,7 @@
use Closure;
use Exception;
+use Illuminate\Auth\Access\Events\GateEvaluated;
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\Events\Dispatcher;
@@ -592,7 +593,7 @@ protected function dispatchGateEvaluatedEvent($user, $ability, array $arguments,
{
if ($this->container->bound(Dispatcher::class)) {
$this->container->make(Dispatcher::class)->dispatch(
- new Events\GateEvaluated($user, $ability, $result, $arguments)
+ new GateEvaluated($user, $ability, $result, $arguments)
);
}
} | true |
Other | laravel | framework | 57c5672e12a9bcb6143134dc5644a2b45fe9d207.json | Simplify sone FQCN. (#43053) | src/Illuminate/Queue/CallQueuedHandler.php | @@ -113,7 +113,7 @@ protected function getCommand(array $data)
protected function dispatchThroughMiddleware(Job $job, $command)
{
if ($command instanceof \__PHP_Incomplete_Class) {
- throw new \Exception('Job is incomplete class: '.json_encode($command));
+ throw new Exception('Job is incomplete class: '.json_encode($command));
}
return (new Pipeline($this->container))->send($command) | true |
Other | laravel | framework | 57c5672e12a9bcb6143134dc5644a2b45fe9d207.json | Simplify sone FQCN. (#43053) | tests/Conditionable/ConditionableTest.php | @@ -3,7 +3,9 @@
namespace Illuminate\Tests\Conditionable;
use Illuminate\Database\Capsule\Manager as DB;
+use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\HigherOrderWhenProxy;
use PHPUnit\Framework\TestCase;
class ConditionableTest extends TestCase
@@ -23,19 +25,19 @@ protected function setUp(): void
public function testWhen(): void
{
- $this->assertInstanceOf(\Illuminate\Support\HigherOrderWhenProxy::class, TestConditionableModel::query()->when(true));
- $this->assertInstanceOf(\Illuminate\Support\HigherOrderWhenProxy::class, TestConditionableModel::query()->when(false));
- $this->assertInstanceOf(\Illuminate\Database\Eloquent\Builder::class, TestConditionableModel::query()->when(false, null));
- $this->assertInstanceOf(\Illuminate\Database\Eloquent\Builder::class, TestConditionableModel::query()->when(true, function () {
+ $this->assertInstanceOf(HigherOrderWhenProxy::class, TestConditionableModel::query()->when(true));
+ $this->assertInstanceOf(HigherOrderWhenProxy::class, TestConditionableModel::query()->when(false));
+ $this->assertInstanceOf(Builder::class, TestConditionableModel::query()->when(false, null));
+ $this->assertInstanceOf(Builder::class, TestConditionableModel::query()->when(true, function () {
}));
}
public function testUnless(): void
{
- $this->assertInstanceOf(\Illuminate\Support\HigherOrderWhenProxy::class, TestConditionableModel::query()->unless(true));
- $this->assertInstanceOf(\Illuminate\Support\HigherOrderWhenProxy::class, TestConditionableModel::query()->unless(false));
- $this->assertInstanceOf(\Illuminate\Database\Eloquent\Builder::class, TestConditionableModel::query()->unless(true, null));
- $this->assertInstanceOf(\Illuminate\Database\Eloquent\Builder::class, TestConditionableModel::query()->unless(false, function () {
+ $this->assertInstanceOf(HigherOrderWhenProxy::class, TestConditionableModel::query()->unless(true));
+ $this->assertInstanceOf(HigherOrderWhenProxy::class, TestConditionableModel::query()->unless(false));
+ $this->assertInstanceOf(Builder::class, TestConditionableModel::query()->unless(true, null));
+ $this->assertInstanceOf(Builder::class, TestConditionableModel::query()->unless(false, function () {
}));
}
} | true |
Other | laravel | framework | 57c5672e12a9bcb6143134dc5644a2b45fe9d207.json | Simplify sone FQCN. (#43053) | tests/Database/DatabaseEloquentFactoryTest.php | @@ -2,6 +2,7 @@
namespace Illuminate\Tests\Database;
+use BadMethodCallException;
use Carbon\Carbon;
use Faker\Generator;
use Illuminate\Container\Container;
@@ -17,6 +18,7 @@
use Illuminate\Tests\Database\Fixtures\Models\Money\Price;
use Mockery as m;
use PHPUnit\Framework\TestCase;
+use ReflectionClass;
class DatabaseEloquentFactoryTest extends TestCase
{
@@ -443,7 +445,7 @@ public function test_counted_sequence()
['name' => 'Dayle Rees']
);
- $class = new \ReflectionClass($factory);
+ $class = new ReflectionClass($factory);
$prop = $class->getProperty('count');
$prop->setAccessible(true);
$value = $prop->getValue($factory);
@@ -622,7 +624,7 @@ public function test_dynamic_trashed_state_respects_existing_state()
public function test_dynamic_trashed_state_throws_exception_when_not_a_softdeletes_model()
{
- $this->expectException(\BadMethodCallException::class);
+ $this->expectException(BadMethodCallException::class);
FactoryTestUserFactory::new()->trashed()->create();
}
| true |
Other | laravel | framework | 57c5672e12a9bcb6143134dc5644a2b45fe9d207.json | Simplify sone FQCN. (#43053) | tests/Database/DatabaseMySqlSchemaStateTest.php | @@ -2,9 +2,11 @@
namespace Illuminate\Tests\Database;
+use Generator;
use Illuminate\Database\MySqlConnection;
use Illuminate\Database\Schema\MySqlSchemaState;
use PHPUnit\Framework\TestCase;
+use ReflectionMethod;
class DatabaseMySqlSchemaStateTest extends TestCase
{
@@ -19,19 +21,19 @@ public function testConnectionString(string $expectedConnectionString, array $ex
$schemaState = new MySqlSchemaState($connection);
// test connectionString
- $method = new \ReflectionMethod(get_class($schemaState), 'connectionString');
+ $method = new ReflectionMethod(get_class($schemaState), 'connectionString');
$connString = tap($method)->setAccessible(true)->invoke($schemaState);
self::assertEquals($expectedConnectionString, $connString);
// test baseVariables
- $method = new \ReflectionMethod(get_class($schemaState), 'baseVariables');
+ $method = new ReflectionMethod(get_class($schemaState), 'baseVariables');
$variables = tap($method)->setAccessible(true)->invoke($schemaState, $dbConfig);
self::assertEquals($expectedVariables, $variables);
}
- public function provider(): \Generator
+ public function provider(): Generator
{
yield 'default' => [
' --user="${:LARAVEL_LOAD_USER}" --password="${:LARAVEL_LOAD_PASSWORD}" --host="${:LARAVEL_LOAD_HOST}" --port="${:LARAVEL_LOAD_PORT}"', [ | true |
Other | laravel | framework | 57c5672e12a9bcb6143134dc5644a2b45fe9d207.json | Simplify sone FQCN. (#43053) | tests/Foundation/Testing/BootTraitsTest.php | @@ -5,6 +5,7 @@
use Illuminate\Foundation\Testing\TestCase as FoundationTestCase;
use Orchestra\Testbench\Concerns\CreatesApplication;
use PHPUnit\Framework\TestCase;
+use ReflectionMethod;
trait TestTrait
{
@@ -34,12 +35,12 @@ public function testSetUpAndTearDownTraits()
{
$testCase = new TestCaseWithTrait;
- $method = new \ReflectionMethod($testCase, 'setUpTraits');
+ $method = new ReflectionMethod($testCase, 'setUpTraits');
tap($method)->setAccessible(true)->invoke($testCase);
$this->assertTrue($testCase->setUp);
- $method = new \ReflectionMethod($testCase, 'callBeforeApplicationDestroyedCallbacks');
+ $method = new ReflectionMethod($testCase, 'callBeforeApplicationDestroyedCallbacks');
tap($method)->setAccessible(true)->invoke($testCase);
$this->assertTrue($testCase->tearDown); | true |
Other | laravel | framework | 57c5672e12a9bcb6143134dc5644a2b45fe9d207.json | Simplify sone FQCN. (#43053) | tests/Integration/Database/DatabaseEloquentModelCustomCastingTest.php | @@ -2,6 +2,7 @@
namespace Illuminate\Tests\Integration\Database;
+use Exception;
use Illuminate\Contracts\Database\Eloquent\Castable;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
use Illuminate\Contracts\Database\Eloquent\CastsInboundAttributes;
@@ -392,7 +393,7 @@ public function set($model, string $key, $value, array $attributes): ?string
}
if (! $value instanceof Settings) {
- throw new \Exception("Attribute `{$key}` with JsonSettingsCaster should be a Settings object");
+ throw new Exception("Attribute `{$key}` with JsonSettingsCaster should be a Settings object");
}
return $value->toJson(); | true |
Other | laravel | framework | 57c5672e12a9bcb6143134dc5644a2b45fe9d207.json | Simplify sone FQCN. (#43053) | tests/Support/SupportStrTest.php | @@ -2,6 +2,7 @@
namespace Illuminate\Tests\Support;
+use Exception;
use Illuminate\Support\Str;
use PHPUnit\Framework\TestCase;
use Ramsey\Uuid\UuidInterface;
@@ -504,7 +505,7 @@ public function testItCanSpecifyASequenceOfRandomStringsToUtilise()
public function testItCanSpecifyAFallbackForARandomStringSequence()
{
- Str::createRandomStringsUsingSequence([Str::random(), Str::random()], fn () => throw new \Exception('Out of random strings.'));
+ Str::createRandomStringsUsingSequence([Str::random(), Str::random()], fn () => throw new Exception('Out of random strings.'));
Str::random();
Str::random();
@@ -1015,7 +1016,7 @@ public function testItCanSpecifyASequenceOfUuidsToUtilise()
public function testItCanSpecifyAFallbackForASequence()
{
- Str::createUuidsUsingSequence([Str::uuid(), Str::uuid()], fn () => throw new \Exception('Out of Uuids.'));
+ Str::createUuidsUsingSequence([Str::uuid(), Str::uuid()], fn () => throw new Exception('Out of Uuids.'));
Str::uuid();
Str::uuid();
| true |
Other | laravel | framework | 57c5672e12a9bcb6143134dc5644a2b45fe9d207.json | Simplify sone FQCN. (#43053) | tests/Testing/TestResponseTest.php | @@ -6,6 +6,7 @@
use Illuminate\Container\Container;
use Illuminate\Contracts\View\View;
use Illuminate\Cookie\CookieValuePrefix;
+use Illuminate\Database\Eloquent\Collection as EloquentCollection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Encryption\Encrypter;
use Illuminate\Filesystem\Filesystem;
@@ -116,7 +117,7 @@ public function testAssertViewHasWithNestedValue()
public function testAssertViewHasEloquentCollection()
{
- $collection = new \Illuminate\Database\Eloquent\Collection([
+ $collection = new EloquentCollection([
new TestModel(['id' => 1]),
new TestModel(['id' => 2]),
new TestModel(['id' => 3]),
@@ -132,7 +133,7 @@ public function testAssertViewHasEloquentCollection()
public function testAssertViewHasEloquentCollectionRespectsOrder()
{
- $collection = new \Illuminate\Database\Eloquent\Collection([
+ $collection = new EloquentCollection([
new TestModel(['id' => 3]),
new TestModel(['id' => 2]),
new TestModel(['id' => 1]),
@@ -150,7 +151,7 @@ public function testAssertViewHasEloquentCollectionRespectsOrder()
public function testAssertViewHasEloquentCollectionRespectsType()
{
- $actual = new \Illuminate\Database\Eloquent\Collection([
+ $actual = new EloquentCollection([
new TestModel(['id' => 1]),
new TestModel(['id' => 2]),
]);
@@ -160,7 +161,7 @@ public function testAssertViewHasEloquentCollectionRespectsType()
'gatherData' => ['foos' => $actual],
]);
- $expected = new \Illuminate\Database\Eloquent\Collection([
+ $expected = new EloquentCollection([
new AnotherTestModel(['id' => 1]),
new AnotherTestModel(['id' => 2]),
]);
@@ -172,7 +173,7 @@ public function testAssertViewHasEloquentCollectionRespectsType()
public function testAssertViewHasEloquentCollectionRespectsSize()
{
- $actual = new \Illuminate\Database\Eloquent\Collection([
+ $actual = new EloquentCollection([
new TestModel(['id' => 1]),
new TestModel(['id' => 2]),
]); | true |
Other | laravel | framework | 57c5672e12a9bcb6143134dc5644a2b45fe9d207.json | Simplify sone FQCN. (#43053) | tests/View/Blade/BladeComponentsTest.php | @@ -4,6 +4,7 @@
use Illuminate\View\Component;
use Illuminate\View\ComponentAttributeBag;
+use Illuminate\View\Factory;
use Mockery as m;
class BladeComponentsTest extends AbstractBladeTestCase
@@ -61,7 +62,7 @@ public function testPropsAreExtractedFromParentAttributesCorrectlyForClassCompon
$component->shouldReceive('withName', 'test');
$component->shouldReceive('shouldRender')->andReturn(false);
- $__env = m::mock(\Illuminate\View\Factory::class);
+ $__env = m::mock(Factory::class);
$__env->shouldReceive('getContainer->make')->with('Test', ['foo' => 'bar', 'other' => 'ok'])->andReturn($component);
$template = $this->compiler->compileString('@component(\'Test::class\', \'test\', ["foo" => "bar"])'); | true |
Other | laravel | framework | 6e02015f2f3ce8eaa056ea297b78ac0473a34375.json | Apply fixes from StyleCI | tests/Support/SupportCollectionTest.php | @@ -2286,7 +2286,7 @@ public function testRandom($collection)
$this->assertInstanceOf($collection, $random);
$this->assertCount(2, $random);
- $random = $data->random(fn($items) => min(10, count($items)));
+ $random = $data->random(fn ($items) => min(10, count($items)));
$this->assertInstanceOf($collection, $random);
$this->assertCount(6, $random);
} | false |
Other | laravel | framework | 4e7ebabd92763d4054ee36186a6ad2d040f61c50.json | Add App::forgetInstance() docblock (#43031) | src/Illuminate/Support/Facades/App.php | @@ -26,6 +26,7 @@
* @method static string environmentFile()
* @method static string environmentFilePath()
* @method static string environmentPath()
+ * @method static void forgetInstance(string $abstract)
* @method static string getCachedConfigPath()
* @method static string getCachedPackagesPath()
* @method static string getCachedRoutesPath() | false |
Other | laravel | framework | 95ce178cbde9f9f38013862f677a5314da67af85.json | add tests for whereNot database rule (#43003) | tests/Validation/ValidationExistsRuleTest.php | @@ -200,6 +200,29 @@ public function testItChoosesValidRecordsUsingWhereNotInAndWhereNotInRulesTogeth
$this->assertTrue($v->passes());
}
+ public function testItChoosesValidRecordsUsingWhereNotRule()
+ {
+ $rule = new Exists('users', 'id');
+
+ $rule->whereNot('type', 'baz');
+
+ User::create(['id' => '1', 'type' => 'foo']);
+ User::create(['id' => '2', 'type' => 'bar']);
+ User::create(['id' => '3', 'type' => 'baz']);
+ User::create(['id' => '4', 'type' => 'other']);
+ User::create(['id' => '5', 'type' => 'baz']);
+
+ $trans = $this->getIlluminateArrayTranslator();
+ $v = new Validator($trans, [], ['id' => $rule]);
+ $v->setPresenceVerifier(new DatabasePresenceVerifier(Eloquent::getConnectionResolver()));
+
+ $v->setData(['id' => 3]);
+ $this->assertFalse($v->passes());
+
+ $v->setData(['id' => 4]);
+ $this->assertTrue($v->passes());
+ }
+
public function testItIgnoresSoftDeletes()
{
$rule = new Exists('table'); | false |
Other | laravel | framework | 46fd62311e8fcfb06ba8af1cc455d9ed1d3a84ef.json | Update CHANGELOG.md (#43002)
The Str::mask PR for 9.x was already some versions ago. Removing the reference to the 8.x PR. | CHANGELOG.md | @@ -14,7 +14,6 @@
- Fixed bug on forceCreate on a MorphMay relationship not including morph type ([#42929](https://github.com/laravel/framework/pull/42929))
- Fix default parameter bug in routes ([#42942](https://github.com/laravel/framework/pull/42942))
- Handle cursor paginator when no items are found ([#42963](https://github.com/laravel/framework/pull/42963))
-- Fixed Str::Mask() for repeating chars ([#42956](https://github.com/laravel/framework/pull/42956))
- Fix undefined constant error when use slot name as key of object ([#42943](https://github.com/laravel/framework/pull/42943))
- Fix BC break for Log feature tests ([#42987](https://github.com/laravel/framework/pull/42987))
| false |
Other | laravel | framework | 0131fd5a395949dceacb2ef57eb21fa0992a1680.json | Apply fixes from StyleCI | src/Illuminate/Database/Eloquent/Relations/MorphMany.php | @@ -53,7 +53,7 @@ public function match(array $models, Collection $results, $relation)
* @param array $attributes
* @return \Illuminate\Database\Eloquent\Model
*/
- public function forceCreate(array $attributes = [])
+ public function forceCreate(array $attributes = [])
{
$attributes[$this->getMorphType()] = $this->morphClass;
| false |
Other | laravel | framework | ce79bfac0d4a9f70f57a736710b303e7c68a3591.json | add test for collection multiple wheres (#42908) | tests/Support/SupportCollectionTest.php | @@ -1052,6 +1052,17 @@ public function testWhere($collection)
[['v' => 1], ['v' => 2]],
$c->where('v')->values()->all()
);
+
+ $c = new $collection([
+ ['v' => 1, 'g' => 3],
+ ['v' => 2, 'g' => 2],
+ ['v' => 2, 'g' => 3],
+ ['v' => 2, 'g' => null],
+ ]);
+ $this->assertEquals([['v' => 2, 'g' => 3]], $c->where('v', 2)->where('g', 3)->values()->all());
+ $this->assertEquals([['v' => 2, 'g' => 3]], $c->where('v', 2)->where('g', '>', 2)->values()->all());
+ $this->assertEquals([], $c->where('v', 2)->where('g', 4)->values()->all());
+ $this->assertEquals([['v' => 2, 'g' => null]], $c->where('v', 2)->whereNull('g')->values()->all());
}
/**
@@ -1085,6 +1096,8 @@ public function testWhereIn($collection)
{
$c = new $collection([['v' => 1], ['v' => 2], ['v' => 3], ['v' => '3'], ['v' => 4]]);
$this->assertEquals([['v' => 1], ['v' => 3], ['v' => '3']], $c->whereIn('v', [1, 3])->values()->all());
+ $this->assertEquals([], $c->whereIn('v', [2])->whereIn('v', [1, 3])->values()->all());
+ $this->assertEquals([['v' => 1]], $c->whereIn('v', [1])->whereIn('v', [1, 3])->values()->all());
}
/**
@@ -1103,6 +1116,7 @@ public function testWhereNotIn($collection)
{
$c = new $collection([['v' => 1], ['v' => 2], ['v' => 3], ['v' => '3'], ['v' => 4]]);
$this->assertEquals([['v' => 2], ['v' => 4]], $c->whereNotIn('v', [1, 3])->values()->all());
+ $this->assertEquals([['v' => 4]], $c->whereNotIn('v', [2])->whereNotIn('v', [1, 3])->values()->all());
}
/** | false |
Other | laravel | framework | 8902690a87f87f516e298c6e00fa1dbf8a0224dd.json | Apply fixes from StyleCI | tests/Database/DatabaseQueryBuilderTest.php | @@ -4370,6 +4370,7 @@ public function testCursorPaginateWithUnionWheres()
$builder->toSql());
$this->assertEquals([$ts], $builder->bindings['where']);
$this->assertEquals([$ts], $builder->bindings['union']);
+
return $results;
});
@@ -4416,6 +4417,7 @@ public function testCursorPaginateWithUnionWheresWithRawOrderExpression()
$builder->toSql());
$this->assertEquals([true, $ts], $builder->bindings['where']);
$this->assertEquals([true, $ts], $builder->bindings['union']);
+
return $results;
});
@@ -4462,6 +4464,7 @@ public function testCursorPaginateWithUnionWheresReverseOrder()
$builder->toSql());
$this->assertEquals([$ts], $builder->bindings['where']);
$this->assertEquals([$ts], $builder->bindings['union']);
+
return $results;
});
@@ -4478,8 +4481,8 @@ public function testCursorPaginateWithUnionWheresReverseOrder()
]), $result);
}
- public function testCursorPaginateWithUnionWheresMultipleOrders()
- {
+ public function testCursorPaginateWithUnionWheresMultipleOrders()
+ {
$ts = now()->toDateTimeString();
$perPage = 16;
@@ -4508,6 +4511,7 @@ public function testCursorPaginateWithUnionWheresMultipleOrders()
$builder->toSql());
$this->assertEquals([$ts, $ts, 1], $builder->bindings['where']);
$this->assertEquals([$ts, $ts, 1], $builder->bindings['union']);
+
return $results;
});
| false |
Other | laravel | framework | a093f921d46073f780c2e48cc6dd0405ce76c977.json | Use arrow function (#42838)
* Use arrow function
* Update AuthServiceProvider.php
Co-authored-by: Taylor Otwell <taylor@laravel.com> | src/Illuminate/Auth/AuthServiceProvider.php | @@ -57,9 +57,7 @@ protected function registerUserResolver()
protected function registerAccessGate()
{
$this->app->singleton(GateContract::class, function ($app) {
- return new Gate($app, function () use ($app) {
- return call_user_func($app['auth']->userResolver());
- });
+ return new Gate($app, fn () => call_user_func($app['auth']->userResolver()));
});
}
| false |
Other | laravel | framework | 4170afad1ce02f42705c8a2a422a273c599fe7e7.json | Apply fixes from StyleCI | src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php | @@ -110,7 +110,7 @@ public function withToken(string $token, string $type = 'Bearer')
public function withoutToken()
{
unset($this->defaultHeaders['Authorization']);
-
+
return $this;
}
| true |
Other | laravel | framework | 4170afad1ce02f42705c8a2a422a273c599fe7e7.json | Apply fixes from StyleCI | tests/Foundation/Testing/Concerns/MakesHttpRequestsTest.php | @@ -26,7 +26,6 @@ public function testWithTokenSetsAuthorizationHeader()
$this->assertSame('Basic foobar', $this->defaultHeaders['Authorization']);
}
-
public function testWithoutTokenRemovesAuthorizationHeader()
{
$this->withToken('foobar'); | true |
Other | laravel | framework | 98548073b4f7bc201c0c8e6d215f65faa8f5c739.json | Fix Factory::createQuietly parameter type (#42807) | src/Illuminate/Database/Eloquent/Factories/Factory.php | @@ -280,7 +280,7 @@ public function create($attributes = [], ?Model $parent = null)
/**
* Create a collection of models and persist them to the database without dispatching any model events.
*
- * @param array<string, mixed> $attributes
+ * @param (callable(array<string, mixed>): array<string, mixed>)|array<string, mixed> $attributes
* @param \Illuminate\Database\Eloquent\Model|null $parent
* @return \Illuminate\Database\Eloquent\Collection<int, \Illuminate\Database\Eloquent\Model|TModel>|\Illuminate\Database\Eloquent\Model|TModel
*/ | true |
Other | laravel | framework | 98548073b4f7bc201c0c8e6d215f65faa8f5c739.json | Fix Factory::createQuietly parameter type (#42807) | types/Database/Eloquent/Factories/Factory.php | @@ -102,6 +102,11 @@ public function definition()
assertType('Illuminate\Database\Eloquent\Collection<int, Illuminate\Database\Eloquent\Model>|Illuminate\Database\Eloquent\Model', $factory->createQuietly([
'string' => 'string',
]));
+assertType('Illuminate\Database\Eloquent\Collection<int, Illuminate\Database\Eloquent\Model>|Illuminate\Database\Eloquent\Model', $factory->createQuietly(function ($attributes) {
+ assertType('array<string, mixed>', $attributes);
+
+ return ['string' => 'string'];
+}));
// assertType('Closure(): Illuminate\Database\Eloquent\Collection<int, User>|User', $factory->lazy());
// assertType('Closure(): Illuminate\Database\Eloquent\Collection<int, User>|User', $factory->lazy([ | true |
Other | laravel | framework | 52cea7fb5f7f5e4704518b6a82b21a1e8ecb1cc9.json | Fix broken Arr::keyBy() typehint (#42745) | src/Illuminate/Collections/Arr.php | @@ -458,7 +458,7 @@ public static function join($array, $glue, $finalGlue = '')
* Key an associative array by a field or using a callback.
*
* @param array $array
- * @param callable|array|string
+ * @param callable|array|string $keyBy
* @return array
*/
public static function keyBy($array, $keyBy) | false |
Other | laravel | framework | 303fbcb61fb290656d5b7ef8648e280051899fba.json | Fix incorrect PHPDoc syntax in `Collection` | src/Illuminate/Collections/Collection.php | @@ -1321,7 +1321,7 @@ public function sortDesc($options = SORT_REGULAR)
/**
* Sort the collection using the given callback.
*
- * @param array<array-key, (callable(TValue, TKey): mixed)|array<array-key, string>|(callable(TValue, TKey): mixed)|string $callback
+ * @param array<array-key, (callable(TValue, TKey): mixed)>|array<array-key, string>|(callable(TValue, TKey): mixed)|string $callback
* @param int $options
* @param bool $descending
* @return static
@@ -1359,7 +1359,7 @@ public function sortBy($callback, $options = SORT_REGULAR, $descending = false)
/**
* Sort the collection using multiple comparisons.
*
- * @param array<array-key, (callable(TValue, TKey): mixed)|array<array-key, string> $comparisons
+ * @param array<array-key, (callable(TValue, TKey): mixed)>|array<array-key, string> $comparisons
* @return static
*/
protected function sortByMany(array $comparisons = [])
@@ -1401,7 +1401,7 @@ protected function sortByMany(array $comparisons = [])
/**
* Sort the collection in descending order using the given callback.
*
- * @param array<array-key, (callable(TValue, TKey): mixed)|array<array-key, string>|(callable(TValue, TKey): mixed)|string $callback
+ * @param array<array-key, (callable(TValue, TKey): mixed)>|array<array-key, string>|(callable(TValue, TKey): mixed)|string $callback
* @param int $options
* @return static
*/ | false |
Other | laravel | framework | 76faca7a1118ebdf475e94f11e2bc23f57225e8c.json | Apply fixes from StyleCI | src/Illuminate/Database/Concerns/BuildsQueries.php | @@ -348,7 +348,7 @@ protected function paginateUsingCursor($perPage, $columns = ['*'], $cursorName =
$cursor->parameter($previousColumn)
);
- $unionBuilders->each(function ($unionBuilder) use($previousColumn, $cursor) {
+ $unionBuilders->each(function ($unionBuilder) use ($previousColumn, $cursor) {
$unionBuilder->where(
$this->getOriginalColumnNameForCursorPagination($this, $previousColumn),
'=',
@@ -374,7 +374,7 @@ protected function paginateUsingCursor($perPage, $columns = ['*'], $cursorName =
});
}
- $unionBuilders->each(function ($unionBuilder) use ($column, $direction, $cursor, $i, $orders, $addCursorConditions){
+ $unionBuilders->each(function ($unionBuilder) use ($column, $direction, $cursor, $i, $orders, $addCursorConditions) {
$unionBuilder->where(function ($unionBuilder) use ($column, $direction, $cursor, $i, $orders, $addCursorConditions) {
$unionBuilder->where(
$this->getOriginalColumnNameForCursorPagination($this, $column), | true |
Other | laravel | framework | 76faca7a1118ebdf475e94f11e2bc23f57225e8c.json | Apply fixes from StyleCI | tests/Database/DatabaseQueryBuilderTest.php | @@ -4053,6 +4053,7 @@ public function testCursorPaginateWithUnionWheres()
$builder->toSql());
$this->assertEquals([$ts], $builder->bindings['where']);
$this->assertEquals([$ts], $builder->bindings['union']);
+
return $results;
});
@@ -4099,6 +4100,7 @@ public function testCursorPaginateWithUnionWheresWithRawOrderExpression()
$builder->toSql());
$this->assertEquals([true, $ts], $builder->bindings['where']);
$this->assertEquals([true, $ts], $builder->bindings['union']);
+
return $results;
});
@@ -4145,6 +4147,7 @@ public function testCursorPaginateWithUnionWheresReverseOrder()
$builder->toSql());
$this->assertEquals([$ts], $builder->bindings['where']);
$this->assertEquals([$ts], $builder->bindings['union']);
+
return $results;
});
@@ -4161,8 +4164,8 @@ public function testCursorPaginateWithUnionWheresReverseOrder()
]), $result);
}
- public function testCursorPaginateWithUnionWheresMultipleOrders()
- {
+ public function testCursorPaginateWithUnionWheresMultipleOrders()
+ {
$ts = now()->toDateTimeString();
$perPage = 16;
@@ -4191,6 +4194,7 @@ public function testCursorPaginateWithUnionWheresMultipleOrders()
$builder->toSql());
$this->assertEquals([$ts, $ts, 1], $builder->bindings['where']);
$this->assertEquals([$ts, $ts, 1], $builder->bindings['union']);
+
return $results;
});
| true |
Other | laravel | framework | 93ff6458081256c807913ca63278e6e9abd8dd02.json | Add `shared` method to the View facade (#42722) | src/Illuminate/Support/Facades/View.php | @@ -13,6 +13,7 @@
* @method static array creator(array|string $views, \Closure|string $callback)
* @method static bool exists(string $view)
* @method static mixed share(array|string $key, $value = null)
+ * @method static mixed shared(string $key, $default = null)
*
* @see \Illuminate\View\Factory
*/ | false |
Other | laravel | framework | e0e516cd50882bc8de500d164cd7c28eacd64430.json | improve property type (#42728) | src/Illuminate/Pipeline/Pipeline.php | @@ -13,7 +13,7 @@ class Pipeline implements PipelineContract
/**
* The container implementation.
*
- * @var \Illuminate\Contracts\Container\Container
+ * @var \Illuminate\Contracts\Container\Container|null
*/
protected $container;
| false |
Other | laravel | framework | 302a579f00ebcb2573f481054cbeadad9c970605.json | Apply fixes from StyleCI | src/Illuminate/Validation/Concerns/ReplacesAttributes.php | @@ -627,7 +627,7 @@ protected function replaceStartsWith($message, $attribute, $rule, $parameters)
return str_replace(':values', implode(', ', $parameters), $message);
}
-
+
/**
* Replace all place-holders for the doesnt_start_with rule.
* | true |
Other | laravel | framework | 302a579f00ebcb2573f481054cbeadad9c970605.json | Apply fixes from StyleCI | src/Illuminate/Validation/Concerns/ValidatesAttributes.php | @@ -1949,7 +1949,7 @@ public function validateStartsWith($attribute, $value, $parameters)
{
return Str::startsWith($value, $parameters);
}
-
+
/**
* Validate the attribute does not start with a given substring.
* | true |
Other | laravel | framework | 6149c624aefceef18829dec971249b6948891a64.json | Apply fixes from StyleCI | src/Illuminate/Support/Testing/Fakes/MailFake.php | @@ -363,7 +363,6 @@ public function send($view, array $data = [], $callback = null)
$view->mailer($this->currentMailer);
-
if ($view instanceof ShouldQueue) {
return $this->queue($view, $data);
} | false |
Other | laravel | framework | 6226955654cbb98146f3acdfcce1b31770888d7f.json | Apply fixes from StyleCI | src/Illuminate/Database/Eloquent/Builder.php | @@ -1573,7 +1573,7 @@ public function setEagerLoads(array $eagerLoad)
return $this;
}
-
+
/**
* Indicate that the given relationships should not be eagerly loaded.
* | false |
Other | laravel | framework | ff5c52b7556a41901b961d9ceee4fee55da27b3a.json | Add missing `throwUnless` magic method (#42617)
* Add missing `throwUnless` magic method
* Add missing `throwUnless` magic method | src/Illuminate/Http/Client/Factory.php | @@ -43,6 +43,7 @@
* @method \Illuminate\Http\Client\PendingRequest withoutVerifying()
* @method \Illuminate\Http\Client\PendingRequest throw(callable $callback = null)
* @method \Illuminate\Http\Client\PendingRequest throwIf($condition)
+ * @method \Illuminate\Http\Client\PendingRequest throwUnless($condition)
* @method array pool(callable $callback)
* @method \Illuminate\Http\Client\Response delete(string $url, array $data = [])
* @method \Illuminate\Http\Client\Response get(string $url, array|string|null $query = null) | true |
Other | laravel | framework | ff5c52b7556a41901b961d9ceee4fee55da27b3a.json | Add missing `throwUnless` magic method (#42617)
* Add missing `throwUnless` magic method
* Add missing `throwUnless` magic method | src/Illuminate/Support/Facades/Http.php | @@ -38,6 +38,7 @@
* @method static \Illuminate\Http\Client\PendingRequest withoutVerifying()
* @method static \Illuminate\Http\Client\PendingRequest throw(callable $callback = null)
* @method static \Illuminate\Http\Client\PendingRequest throwIf($condition)
+ * @method \Illuminate\Http\Client\PendingRequest throwUnless($condition)
* @method static array pool(callable $callback)
* @method static \Illuminate\Http\Client\Response delete(string $url, array $data = [])
* @method static \Illuminate\Http\Client\Response get(string $url, array|string|null $query = null) | true |
Other | laravel | framework | fbbbeb3b6c5cd966f0af0ca614ac9314aff78aa1.json | remove unnecessary commentted line (#42616) | src/Illuminate/Foundation/Exceptions/Handler.php | @@ -325,7 +325,6 @@ protected function context()
try {
return array_filter([
'userId' => Auth::id(),
- // 'email' => optional(Auth::user())->email,
]);
} catch (Throwable $e) {
return []; | false |
Other | laravel | framework | 20faf9fc0dc9302eec46a62aa477a700edddae36.json | Apply fixes from StyleCI | tests/Broadcasting/BroadcasterTest.php | @@ -10,7 +10,6 @@
use Illuminate\Http\Request;
use Mockery as m;
use PHPUnit\Framework\TestCase;
-use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\HttpException;
class BroadcasterTest extends TestCase | false |
Other | laravel | framework | 6fb604f43a5f2dbce928c704532fde291f313416.json | add test for between validation rule (#42596) | tests/Validation/ValidationValidatorTest.php | @@ -2389,6 +2389,24 @@ public function testValidateBetween()
$v = new Validator($trans, ['foo' => '123'], ['foo' => 'Numeric|Between:50,100']);
$this->assertFalse($v->passes());
+ // inclusive on min
+ $v = new Validator($trans, ['foo' => '123'], ['foo' => 'Numeric|Between:123,200']);
+ $this->assertTrue($v->passes());
+
+ // inclusive on max
+ $v = new Validator($trans, ['foo' => '123'], ['foo' => 'Numeric|Between:0,123']);
+ $this->assertTrue($v->passes());
+
+ // can work with float
+ $v = new Validator($trans, ['foo' => '0.02'], ['foo' => 'Numeric|Between:0.01,0.02']);
+ $this->assertTrue($v->passes());
+
+ $v = new Validator($trans, ['foo' => '0.02'], ['foo' => 'Numeric|Between:0.01,0.03']);
+ $this->assertTrue($v->passes());
+
+ $v = new Validator($trans, ['foo' => '0.001'], ['foo' => 'Numeric|Between:0.01,0.03']);
+ $this->assertFalse($v->passes());
+
$v = new Validator($trans, ['foo' => '3'], ['foo' => 'Numeric|Between:1,5']);
$this->assertTrue($v->passes());
| false |
Other | laravel | framework | 8ff75a36b552e93eeedc1f410ccedbe6232fe3c2.json | Apply fixes from StyleCI | src/Illuminate/Http/Client/PendingRequest.php | @@ -586,7 +586,7 @@ public function throwIf($condition)
{
return $condition ? $this->throw() : $this;
}
-
+
/**
* Throw an exception if a server or client error occurred and the given condition evaluates to false.
* | false |
Other | laravel | framework | 91824b0833912ddee194f8fb722b74ab0dc57803.json | Fix exception message in reduceSpread (#42568)
Updating an incorrect exception message when `EnumeratesValues::reduceSpread()` does not produce an array. `reduceMany` has been deprecated. | src/Illuminate/Collections/Traits/EnumeratesValues.php | @@ -796,7 +796,7 @@ public function reduceSpread(callable $callback, ...$initial)
if (! is_array($result)) {
throw new UnexpectedValueException(sprintf(
- "%s::reduceMany expects reducer to return an array, but got a '%s' instead.",
+ "%s::reduceSpread expects reducer to return an array, but got a '%s' instead.",
class_basename(static::class), gettype($result)
));
} | false |
Other | laravel | framework | acddea7ab355f218f193bea071d6d63257a68c46.json | Remove meaningless parameter (#42546) | src/Illuminate/View/Concerns/ManagesEvents.php | @@ -55,7 +55,7 @@ public function composer($views, $callback)
$composers = [];
foreach ((array) $views as $view) {
- $composers[] = $this->addViewEvent($view, $callback, 'composing: ');
+ $composers[] = $this->addViewEvent($view, $callback);
}
return $composers; | false |
Other | laravel | framework | 79963c6599ba340635b25baa7f7a08d16456dc39.json | Apply fixes from StyleCI | src/Illuminate/Foundation/Console/RouteListCommand.php | @@ -267,7 +267,7 @@ protected function filterRoute(array $route)
($this->option('method') && ! Str::contains($route['method'], strtoupper($this->option('method')))) ||
($this->option('domain') && ! Str::contains((string) $route['domain'], $this->option('domain'))) ||
($this->option('except-vendor') && $route['vendor']) ||
- ($this->option('only-vendor') && !$route['vendor'])) {
+ ($this->option('only-vendor') && ! $route['vendor'])) {
return;
}
| false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.