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
3ade2155a2af35964ee99f583f0a30d8ce70cb23.json
Add missing params in docblocks
src/Illuminate/Testing/ParallelConsoleOutput.php
@@ -27,7 +27,7 @@ class ParallelConsoleOutput extends ConsoleOutput /** * Create a new Parallel ConsoleOutput instance. * - * @param \Symfony\Component\Console\Output\OutputInterface + * @param \Symfony\Component\Console\Output\OutputInterface $output * @return void */ public function __construct($output)
true
Other
laravel
framework
e89ab5a8fec46f6e7d6ed7039dd8c518df1ed4fa.json
add ReturnTypeWillChange attribute (#37838)
src/Illuminate/Bus/Batch.php
@@ -11,6 +11,7 @@ use Illuminate\Support\Arr; use Illuminate\Support\Collection; use JsonSerializable; +use ReturnTypeWillChange; use Throwable; class Batch implements Arrayable, JsonSerializable @@ -459,6 +460,7 @@ public function toArray() * * @return array */ + #[ReturnTypeWillChange] public function jsonSerialize() { return $this->toArray();
true
Other
laravel
framework
e89ab5a8fec46f6e7d6ed7039dd8c518df1ed4fa.json
add ReturnTypeWillChange attribute (#37838)
src/Illuminate/Collections/Traits/EnumeratesValues.php
@@ -13,6 +13,7 @@ use Illuminate\Support\HigherOrderCollectionProxy; use Illuminate\Support\HigherOrderWhenProxy; use JsonSerializable; +use ReturnTypeWillChange; use Symfony\Component\VarDumper\VarDumper; use Traversable; @@ -833,6 +834,7 @@ public function toArray() * * @return array */ + #[ReturnTypeWillChange] public function jsonSerialize() { return array_map(function ($value) {
true
Other
laravel
framework
e89ab5a8fec46f6e7d6ed7039dd8c518df1ed4fa.json
add ReturnTypeWillChange attribute (#37838)
src/Illuminate/Database/Eloquent/Casts/ArrayObject.php
@@ -5,6 +5,7 @@ use ArrayObject as BaseArrayObject; use Illuminate\Contracts\Support\Arrayable; use JsonSerializable; +use ReturnTypeWillChange; class ArrayObject extends BaseArrayObject implements Arrayable, JsonSerializable { @@ -33,6 +34,7 @@ public function toArray() * * @return array */ + #[ReturnTypeWillChange] public function jsonSerialize() { return $this->getArrayCopy();
true
Other
laravel
framework
e89ab5a8fec46f6e7d6ed7039dd8c518df1ed4fa.json
add ReturnTypeWillChange attribute (#37838)
src/Illuminate/Database/Eloquent/Model.php
@@ -21,6 +21,7 @@ use Illuminate\Support\Traits\ForwardsCalls; use JsonSerializable; use LogicException; +use ReturnTypeWillChange; abstract class Model implements Arrayable, ArrayAccess, HasBroadcastChannel, Jsonable, JsonSerializable, QueueableEntity, UrlRoutable { @@ -1426,6 +1427,7 @@ public function toJson($options = 0) * * @return array */ + #[ReturnTypeWillChange] public function jsonSerialize() { return $this->toArray();
true
Other
laravel
framework
e89ab5a8fec46f6e7d6ed7039dd8c518df1ed4fa.json
add ReturnTypeWillChange attribute (#37838)
src/Illuminate/Http/Resources/Json/JsonResource.php
@@ -11,6 +11,7 @@ use Illuminate\Http\Resources\ConditionallyLoadsAttributes; use Illuminate\Http\Resources\DelegatesToResource; use JsonSerializable; +use ReturnTypeWillChange; class JsonResource implements ArrayAccess, JsonSerializable, Responsable, UrlRoutable { @@ -226,6 +227,7 @@ public function toResponse($request) * * @return array */ + #[ReturnTypeWillChange] public function jsonSerialize() { return $this->resolve(Container::getInstance()->make('request'));
true
Other
laravel
framework
e89ab5a8fec46f6e7d6ed7039dd8c518df1ed4fa.json
add ReturnTypeWillChange attribute (#37838)
src/Illuminate/Pagination/CursorPaginator.php
@@ -10,6 +10,7 @@ use Illuminate\Support\Collection; use IteratorAggregate; use JsonSerializable; +use ReturnTypeWillChange; class CursorPaginator extends AbstractCursorPaginator implements Arrayable, ArrayAccess, Countable, IteratorAggregate, Jsonable, JsonSerializable, PaginatorContract { @@ -142,6 +143,7 @@ public function toArray() * * @return array */ + #[ReturnTypeWillChange] public function jsonSerialize() { return $this->toArray();
true
Other
laravel
framework
e89ab5a8fec46f6e7d6ed7039dd8c518df1ed4fa.json
add ReturnTypeWillChange attribute (#37838)
src/Illuminate/Pagination/LengthAwarePaginator.php
@@ -10,6 +10,7 @@ use Illuminate\Support\Collection; use IteratorAggregate; use JsonSerializable; +use ReturnTypeWillChange; class LengthAwarePaginator extends AbstractPaginator implements Arrayable, ArrayAccess, Countable, IteratorAggregate, Jsonable, JsonSerializable, LengthAwarePaginatorContract { @@ -213,6 +214,7 @@ public function toArray() * * @return array */ + #[ReturnTypeWillChange] public function jsonSerialize() { return $this->toArray();
true
Other
laravel
framework
e89ab5a8fec46f6e7d6ed7039dd8c518df1ed4fa.json
add ReturnTypeWillChange attribute (#37838)
src/Illuminate/Pagination/Paginator.php
@@ -10,6 +10,7 @@ use Illuminate\Support\Collection; use IteratorAggregate; use JsonSerializable; +use ReturnTypeWillChange; class Paginator extends AbstractPaginator implements Arrayable, ArrayAccess, Countable, IteratorAggregate, Jsonable, JsonSerializable, PaginatorContract { @@ -158,6 +159,7 @@ public function toArray() * * @return array */ + #[ReturnTypeWillChange] public function jsonSerialize() { return $this->toArray();
true
Other
laravel
framework
e89ab5a8fec46f6e7d6ed7039dd8c518df1ed4fa.json
add ReturnTypeWillChange attribute (#37838)
src/Illuminate/Session/ArraySessionHandler.php
@@ -3,6 +3,7 @@ namespace Illuminate\Session; use Illuminate\Support\InteractsWithTime; +use ReturnTypeWillChange; use SessionHandlerInterface; class ArraySessionHandler implements SessionHandlerInterface @@ -37,6 +38,7 @@ public function __construct($minutes) /** * {@inheritdoc} */ + #[ReturnTypeWillChange] public function open($savePath, $sessionName) { return true; @@ -45,6 +47,7 @@ public function open($savePath, $sessionName) /** * {@inheritdoc} */ + #[ReturnTypeWillChange] public function close() { return true; @@ -53,6 +56,7 @@ public function close() /** * {@inheritdoc} */ + #[ReturnTypeWillChange] public function read($sessionId) { if (! isset($this->storage[$sessionId])) { @@ -73,6 +77,7 @@ public function read($sessionId) /** * {@inheritdoc} */ + #[ReturnTypeWillChange] public function write($sessionId, $data) { $this->storage[$sessionId] = [ @@ -86,6 +91,7 @@ public function write($sessionId, $data) /** * {@inheritdoc} */ + #[ReturnTypeWillChange] public function destroy($sessionId) { if (isset($this->storage[$sessionId])) { @@ -98,6 +104,7 @@ public function destroy($sessionId) /** * {@inheritdoc} */ + #[ReturnTypeWillChange] public function gc($lifetime) { $expiration = $this->calculateExpiration($lifetime);
true
Other
laravel
framework
e89ab5a8fec46f6e7d6ed7039dd8c518df1ed4fa.json
add ReturnTypeWillChange attribute (#37838)
src/Illuminate/Session/NullSessionHandler.php
@@ -2,13 +2,15 @@ namespace Illuminate\Session; +use ReturnTypeWillChange; use SessionHandlerInterface; class NullSessionHandler implements SessionHandlerInterface { /** * {@inheritdoc} */ + #[ReturnTypeWillChange] public function open($savePath, $sessionName) { return true; @@ -17,6 +19,7 @@ public function open($savePath, $sessionName) /** * {@inheritdoc} */ + #[ReturnTypeWillChange] public function close() { return true; @@ -25,6 +28,7 @@ public function close() /** * {@inheritdoc} */ + #[ReturnTypeWillChange] public function read($sessionId) { return ''; @@ -33,6 +37,7 @@ public function read($sessionId) /** * {@inheritdoc} */ + #[ReturnTypeWillChange] public function write($sessionId, $data) { return true; @@ -41,6 +46,7 @@ public function write($sessionId, $data) /** * {@inheritdoc} */ + #[ReturnTypeWillChange] public function destroy($sessionId) { return true; @@ -49,6 +55,7 @@ public function destroy($sessionId) /** * {@inheritdoc} */ + #[ReturnTypeWillChange] public function gc($lifetime) { return true;
true
Other
laravel
framework
e89ab5a8fec46f6e7d6ed7039dd8c518df1ed4fa.json
add ReturnTypeWillChange attribute (#37838)
src/Illuminate/Support/Fluent.php
@@ -6,6 +6,7 @@ use Illuminate\Contracts\Support\Arrayable; use Illuminate\Contracts\Support\Jsonable; use JsonSerializable; +use ReturnTypeWillChange; class Fluent implements Arrayable, ArrayAccess, Jsonable, JsonSerializable { @@ -70,6 +71,7 @@ public function toArray() * * @return array */ + #[ReturnTypeWillChange] public function jsonSerialize() { return $this->toArray();
true
Other
laravel
framework
e89ab5a8fec46f6e7d6ed7039dd8c518df1ed4fa.json
add ReturnTypeWillChange attribute (#37838)
src/Illuminate/Support/MessageBag.php
@@ -8,6 +8,7 @@ use Illuminate\Contracts\Support\MessageBag as MessageBagContract; use Illuminate\Contracts\Support\MessageProvider; use JsonSerializable; +use ReturnTypeWillChange; class MessageBag implements Arrayable, Countable, Jsonable, JsonSerializable, MessageBagContract, MessageProvider { @@ -389,6 +390,7 @@ public function toArray() * * @return array */ + #[ReturnTypeWillChange] public function jsonSerialize() { return $this->toArray();
true
Other
laravel
framework
e89ab5a8fec46f6e7d6ed7039dd8c518df1ed4fa.json
add ReturnTypeWillChange attribute (#37838)
src/Illuminate/Support/Stringable.php
@@ -7,6 +7,7 @@ use Illuminate\Support\Traits\Macroable; use Illuminate\Support\Traits\Tappable; use JsonSerializable; +use ReturnTypeWillChange; use Symfony\Component\VarDumper\VarDumper; class Stringable implements JsonSerializable @@ -782,6 +783,7 @@ public function dd() * * @return string */ + #[ReturnTypeWillChange] public function jsonSerialize() { return $this->__toString();
true
Other
laravel
framework
e89ab5a8fec46f6e7d6ed7039dd8c518df1ed4fa.json
add ReturnTypeWillChange attribute (#37838)
tests/Database/DatabaseProcessorTest.php
@@ -8,6 +8,7 @@ use Mockery as m; use PDO; use PHPUnit\Framework\TestCase; +use ReturnTypeWillChange; class DatabaseProcessorTest extends TestCase { @@ -38,7 +39,8 @@ public function __construct() // } - public function lastInsertId($sequence = null) + #[ReturnTypeWillChange] + public function lastInsertId(string $sequence = null) { // }
true
Other
laravel
framework
e89ab5a8fec46f6e7d6ed7039dd8c518df1ed4fa.json
add ReturnTypeWillChange attribute (#37838)
tests/Http/HttpJsonResponseTest.php
@@ -124,7 +124,7 @@ public function toJson($options = 0) class JsonResponseTestJsonSerializeObject implements JsonSerializable { - public function jsonSerialize() + public function jsonSerialize(): array { return ['foo' => 'bar']; }
true
Other
laravel
framework
e89ab5a8fec46f6e7d6ed7039dd8c518df1ed4fa.json
add ReturnTypeWillChange attribute (#37838)
tests/Http/HttpResponseTest.php
@@ -245,7 +245,7 @@ public function toJson($options = 0) class JsonSerializableStub implements JsonSerializable { - public function jsonSerialize() + public function jsonSerialize(): array { return ['foo' => 'bar']; }
true
Other
laravel
framework
e89ab5a8fec46f6e7d6ed7039dd8c518df1ed4fa.json
add ReturnTypeWillChange attribute (#37838)
tests/Integration/Http/Fixtures/JsonSerializableResource.php
@@ -13,7 +13,7 @@ public function __construct($resource) $this->resource = $resource; } - public function jsonSerialize() + public function jsonSerialize(): array { return [ 'id' => $this->resource->id,
true
Other
laravel
framework
e89ab5a8fec46f6e7d6ed7039dd8c518df1ed4fa.json
add ReturnTypeWillChange attribute (#37838)
tests/Integration/Http/JsonResponseTest.php
@@ -19,7 +19,7 @@ public function testResponseWithInvalidJsonThrowsException() Route::get('/response', function () { return new JsonResponse(new class implements \JsonSerializable { - public function jsonSerialize() + public function jsonSerialize(): string { return "\xB1\x31"; }
true
Other
laravel
framework
e89ab5a8fec46f6e7d6ed7039dd8c518df1ed4fa.json
add ReturnTypeWillChange attribute (#37838)
tests/Integration/Http/ResponseTest.php
@@ -19,7 +19,7 @@ public function testResponseWithInvalidJsonThrowsException() Route::get('/response', function () { return (new Response())->setContent(new class implements \JsonSerializable { - public function jsonSerialize() + public function jsonSerialize(): string { return "\xB1\x31"; }
true
Other
laravel
framework
e89ab5a8fec46f6e7d6ed7039dd8c518df1ed4fa.json
add ReturnTypeWillChange attribute (#37838)
tests/Support/SupportCollectionTest.php
@@ -4789,15 +4789,15 @@ public function toJson($options = 0) class TestJsonSerializeObject implements JsonSerializable { - public function jsonSerialize() + public function jsonSerialize(): array { return ['foo' => 'bar']; } } class TestJsonSerializeWithScalarValueObject implements JsonSerializable { - public function jsonSerialize() + public function jsonSerialize(): string { return 'foo'; }
true
Other
laravel
framework
e89ab5a8fec46f6e7d6ed7039dd8c518df1ed4fa.json
add ReturnTypeWillChange attribute (#37838)
tests/Testing/TestResponseTest.php
@@ -1381,7 +1381,7 @@ private function makeMockResponse($content) class JsonSerializableMixedResourcesStub implements JsonSerializable { - public function jsonSerialize() + public function jsonSerialize(): array { return [ 'foo' => 'bar', @@ -1415,7 +1415,7 @@ public function jsonSerialize() class JsonSerializableSingleResourceStub implements JsonSerializable { - public function jsonSerialize() + public function jsonSerialize(): array { return [ ['foo' => 'foo 0', 'bar' => 'bar 0', 'foobar' => 'foobar 0'], @@ -1428,7 +1428,7 @@ public function jsonSerialize() class JsonSerializableSingleResourceWithIntegersStub implements JsonSerializable { - public function jsonSerialize() + public function jsonSerialize(): array { return [ ['id' => 10, 'foo' => 'bar'],
true
Other
laravel
framework
f46a96c8b5fec4a8778f27b786c5d9f6f49b2949.json
Apply fixes from StyleCI (#37805)
src/Illuminate/Http/ResponseTrait.php
@@ -40,7 +40,7 @@ public function status() public function statusText() { return $this->statusText; - } + } /** * Get the content of the response.
true
Other
laravel
framework
f46a96c8b5fec4a8778f27b786c5d9f6f49b2949.json
Apply fixes from StyleCI (#37805)
tests/Http/HttpResponseTest.php
@@ -119,7 +119,7 @@ public function testSetStatusCodeAndRetrieveStatusText() $response->setStatusCode(404); $this->assertSame('Not Found', $response->statusText()); } - + public function testOnlyInputOnRedirect() { $response = new RedirectResponse('foo.bar');
true
Other
laravel
framework
cc84229a96870027793e11e7e8cf2182fc9fbba1.json
Fix merge conflicts
src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php
@@ -68,12 +68,8 @@ use Illuminate\Queue\Console\ForgetFailedCommand as ForgetFailedQueueCommand; use Illuminate\Queue\Console\ListenCommand as QueueListenCommand; use Illuminate\Queue\Console\ListFailedCommand as ListFailedQueueCommand; -<<<<<<< HEAD use Illuminate\Queue\Console\PruneBatchesCommand as QueuePruneBatchesCommand; -======= -use Illuminate\Queue\Console\PruneBatchesCommand as PruneBatchesQueueCommand; -use Illuminate\Queue\Console\PruneFailedJobsCommand; ->>>>>>> 8.x +use Illuminate\Queue\Console\PruneFailedJobsCommand as QueuePruneFailedJobsCommand; use Illuminate\Queue\Console\RestartCommand as QueueRestartCommand; use Illuminate\Queue\Console\RetryBatchCommand as QueueRetryBatchCommand; use Illuminate\Queue\Console\RetryCommand as QueueRetryCommand; @@ -99,7 +95,6 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid 'ConfigCache' => ConfigCacheCommand::class, 'ConfigClear' => ConfigClearCommand::class, 'Db' => DbCommand::class, -<<<<<<< HEAD 'DbWipe' => WipeCommand::class, 'Down' => DownCommand::class, 'Environment' => EnvironmentCommand::class, @@ -116,6 +111,7 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid 'QueueForget' => ForgetFailedQueueCommand::class, 'QueueListen' => QueueListenCommand::class, 'QueuePruneBatches' => QueuePruneBatchesCommand::class, + 'QueuePruneFailedJobs' => QueuePruneFailedJobsCommand::class, 'QueueRestart' => QueueRestartCommand::class, 'QueueRetry' => QueueRetryCommand::class, 'QueueRetryBatch' => QueueRetryBatchCommand::class, @@ -125,34 +121,6 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid 'RouteList' => RouteListCommand::class, 'SchemaDump' => DumpCommand::class, 'Seed' => SeedCommand::class, -======= - 'DbWipe' => 'command.db.wipe', - 'Down' => 'command.down', - 'Environment' => 'command.environment', - 'EventCache' => 'command.event.cache', - 'EventClear' => 'command.event.clear', - 'EventList' => 'command.event.list', - 'KeyGenerate' => 'command.key.generate', - 'Optimize' => 'command.optimize', - 'OptimizeClear' => 'command.optimize.clear', - 'PackageDiscover' => 'command.package.discover', - 'QueueClear' => 'command.queue.clear', - 'QueueFailed' => 'command.queue.failed', - 'QueueFlush' => 'command.queue.flush', - 'QueueForget' => 'command.queue.forget', - 'QueueListen' => 'command.queue.listen', - 'QueuePruneBatches' => 'command.queue.prune-batches', - 'QueuePruneFailedJobs' => 'command.queue.prune-failed-jobs', - 'QueueRestart' => 'command.queue.restart', - 'QueueRetry' => 'command.queue.retry', - 'QueueRetryBatch' => 'command.queue.retry-batch', - 'QueueWork' => 'command.queue.work', - 'RouteCache' => 'command.route.cache', - 'RouteClear' => 'command.route.clear', - 'RouteList' => 'command.route.list', - 'SchemaDump' => 'command.schema.dump', - 'Seed' => 'command.seed', ->>>>>>> 8.x 'ScheduleFinish' => ScheduleFinishCommand::class, 'ScheduleList' => ScheduleListCommand::class, 'ScheduleRun' => ScheduleRunCommand::class, @@ -712,7 +680,7 @@ protected function registerQueuePruneBatchesCommand() protected function registerQueuePruneFailedJobsCommand() { $this->app->singleton('command.queue.prune-failed-jobs', function () { - return new PruneFailedJobsCommand; + return new QueuePruneFailedJobsCommand; }); }
false
Other
laravel
framework
96fe7ec3bab10b64ad19756ac0ade27d6719999d.json
Apply fixes from StyleCI (#37763)
tests/Http/HttpTestingFileFactoryTest.php
@@ -44,8 +44,9 @@ public function testImageJpeg() public function testImageGif() { - if (! function_exists('imagegif')) + if (! function_exists('imagegif')) { $this->markTestSkipped('The extension gd is missing from your system or was compiled without GIF support.'); + } $image = (new FileFactory)->image('test.gif'); @@ -57,8 +58,9 @@ public function testImageGif() public function testImageWebp() { - if (! function_exists('imagewebp')) + if (! function_exists('imagewebp')) { $this->markTestSkipped('The extension gd is missing from your system or was compiled without WEBP support.'); + } $image = (new FileFactory)->image('test.webp'); @@ -70,8 +72,9 @@ public function testImageWebp() public function testImageWbmp() { - if (! function_exists('imagewbmp')) + if (! function_exists('imagewbmp')) { $this->markTestSkipped('The extension gd is missing from your system or was compiled without WBMP support.'); + } $image = (new FileFactory)->image('test.wbmp'); @@ -83,8 +86,9 @@ public function testImageWbmp() public function testImageBmp() { - if (! function_exists('imagebmp')) + if (! function_exists('imagebmp')) { $this->markTestSkipped('The extension gd is missing from your system or was compiled without BMP support.'); + } $image = (new FileFactory)->image('test.bmp');
false
Other
laravel
framework
4be33548469b417bebbdb034562877d29eb9f453.json
Add collection `sliding` method (#37751)
src/Illuminate/Collections/Collection.php
@@ -959,6 +959,22 @@ public function shuffle($seed = null) return new static(Arr::shuffle($this->items, $seed)); } + /** + * Create chunks representing a "sliding window" view of the items in the collection. + * + * @param int $size + * @param int $step + * @return static + */ + public function sliding($size = 2, $step = 1) + { + $chunks = floor(($this->count() - $size) / $step) + 1; + + return static::times($chunks, function ($number) use ($size, $step) { + return $this->slice(($number - 1) * $step, $size); + }); + } + /** * Skip the first {$count} items. *
true
Other
laravel
framework
4be33548469b417bebbdb034562877d29eb9f453.json
Add collection `sliding` method (#37751)
src/Illuminate/Collections/LazyCollection.php
@@ -920,6 +920,45 @@ public function shuffle($seed = null) return $this->passthru('shuffle', func_get_args()); } + /** + * Create chunks representing a "sliding window" view of the items in the collection. + * + * @param int $size + * @param int $step + * @return static + */ + public function sliding($size = 2, $step = 1) + { + return new static(function () use ($size, $step) { + $iterator = $this->getIterator(); + + $chunk = []; + + while ($iterator->valid()) { + $chunk[$iterator->key()] = $iterator->current(); + + if (count($chunk) == $size) { + yield tap(new static($chunk), function () use (&$chunk, $step) { + $chunk = array_slice($chunk, $step, null, true); + }); + + // If the $step between chunks is bigger than each chunk's $size, + // we will skip the extra items (which should never be in any + // chunk) before we continue to the next chunk in the loop. + if ($step > $size) { + $skip = $step - $size; + + for ($i = 0; $i < $skip && $iterator->valid(); $i++) { + $iterator->next(); + } + } + } + + $iterator->next(); + } + }); + } + /** * Skip the first {$count} items. *
true
Other
laravel
framework
4be33548469b417bebbdb034562877d29eb9f453.json
Add collection `sliding` method (#37751)
tests/Support/SupportCollectionTest.php
@@ -235,6 +235,65 @@ public function testShiftReturnsAndRemovesFirstItemInCollection() $this->assertNull($data->first()); } + /** + * @dataProvider collectionClassProvider + */ + public function testSliding($collection) + { + // Default parameters: $size = 2, $step = 1 + $this->assertSame([], $collection::times(0)->sliding()->toArray()); + $this->assertSame([], $collection::times(1)->sliding()->toArray()); + $this->assertSame([[1, 2]], $collection::times(2)->sliding()->toArray()); + $this->assertSame( + [[1, 2], [2, 3]], + $collection::times(3)->sliding()->map->values()->toArray() + ); + + // Custom step: $size = 2, $step = 3 + $this->assertSame([], $collection::times(1)->sliding(2, 3)->toArray()); + $this->assertSame([[1, 2]], $collection::times(2)->sliding(2, 3)->toArray()); + $this->assertSame([[1, 2]], $collection::times(3)->sliding(2, 3)->toArray()); + $this->assertSame([[1, 2]], $collection::times(4)->sliding(2, 3)->toArray()); + $this->assertSame( + [[1, 2], [4, 5]], + $collection::times(5)->sliding(2, 3)->map->values()->toArray() + ); + + // Custom size: $size = 3, $step = 1 + $this->assertSame([], $collection::times(2)->sliding(3)->toArray()); + $this->assertSame([[1, 2, 3]], $collection::times(3)->sliding(3)->toArray()); + $this->assertSame( + [[1, 2, 3], [2, 3, 4]], + $collection::times(4)->sliding(3)->map->values()->toArray() + ); + $this->assertSame( + [[1, 2, 3], [2, 3, 4]], + $collection::times(4)->sliding(3)->map->values()->toArray() + ); + + // Custom size and custom step: $size = 3, $step = 2 + $this->assertSame([], $collection::times(2)->sliding(3, 2)->toArray()); + $this->assertSame([[1, 2, 3]], $collection::times(3)->sliding(3, 2)->toArray()); + $this->assertSame([[1, 2, 3]], $collection::times(4)->sliding(3, 2)->toArray()); + $this->assertSame( + [[1, 2, 3], [3, 4, 5]], + $collection::times(5)->sliding(3, 2)->map->values()->toArray() + ); + $this->assertSame( + [[1, 2, 3], [3, 4, 5]], + $collection::times(6)->sliding(3, 2)->map->values()->toArray() + ); + + // Ensure keys are preserved, and inner chunks are also collections + $chunks = $collection::times(3)->sliding(); + + $this->assertSame([[0 => 1, 1 => 2], [1 => 2, 2 => 3]], $chunks->toArray()); + + $this->assertInstanceOf($collection, $chunks); + $this->assertInstanceOf($collection, $chunks->first()); + $this->assertInstanceOf($collection, $chunks->skip(1)->first()); + } + /** * @dataProvider collectionClassProvider */
true
Other
laravel
framework
4be33548469b417bebbdb034562877d29eb9f453.json
Add collection `sliding` method (#37751)
tests/Support/SupportLazyCollectionIsLazyTest.php
@@ -897,6 +897,29 @@ public function testShuffleIsLazy() }); } + public function testSlidingIsLazy() + { + $this->assertDoesNotEnumerate(function ($collection) { + $collection->sliding(); + }); + + $this->assertEnumerates(2, function ($collection) { + $collection->sliding()->take(1)->all(); + }); + + $this->assertEnumerates(3, function ($collection) { + $collection->sliding()->take(2)->all(); + }); + + $this->assertEnumerates(13, function ($collection) { + $collection->sliding(3, 5)->take(3)->all(); + }); + + $this->assertEnumeratesOnce(function ($collection) { + $collection->sliding()->all(); + }); + } + public function testSkipIsLazy() { $this->assertDoesNotEnumerate(function ($collection) {
true
Other
laravel
framework
8c7d2dc9842f72344cd44dd75e45e3a921e50046.json
fix minor spelling error
src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php
@@ -773,7 +773,7 @@ public function getResults() public function get($columns = ['*']) { // First we'll add the proper select columns onto the query so it is run with - // the proper columns. Then, we will get the results and hydrate out pivot + // the proper columns. Then, we will get the results and hydrate our pivot // models with the result of those columns as a separate model relation. $builder = $this->query->applyScopes();
false
Other
laravel
framework
c655e6fc7dd07805b1f7cc3a95c53fcc2bbfb40b.json
add tests for singletonInstance
tests/Foundation/Testing/Concerns/InteractsWithContainerTest.php
@@ -27,4 +27,12 @@ public function testWithMixRestoresOriginalHandlerAndReturnsInstance() $this->assertSame($handler, resolve(Mix::class)); $this->assertSame($this, $instance); } + + public function testSingletonBoundInstancesCanBeResolved() + { + $this->singletonInstance('foo', 'bar'); + + $this->assertEquals('bar', $this->app->make('foo')); + $this->assertEquals('bar', $this->app->make('foo', ['with' => 'params'])); + } }
false
Other
laravel
framework
952f84a3a5449a5f80190479240fce15bdaad558.json
add missing docblock (#37733) small follow up to #37720
src/Illuminate/Filesystem/FilesystemManager.php
@@ -119,6 +119,7 @@ protected function get($name) * Resolve the given disk. * * @param string $name + * @param array|null $config * @return \Illuminate\Contracts\Filesystem\Filesystem * * @throws \InvalidArgumentException
false
Other
laravel
framework
416339e57a0b49f7df89b4425c2c07f7baea014b.json
Fix 7.3 regression with short closure
src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php
@@ -185,7 +185,9 @@ protected function compileAnsiOffset(Builder $query, $components) // move the bindings to the right position: right after "select". if ($this->queryOrderContainsSubquery($query)) { $preferredBindingOrder = ['select', 'order', 'from', 'join', 'where', 'groupBy', 'having', 'union', 'unionOrder']; - $sortedBindings = Arr::sort($query->bindings, fn ($bindings, $key) => array_search($key, $preferredBindingOrder)); + $sortedBindings = Arr::sort($query->bindings, function ($bindings, $key) use ($preferredBindingOrder) { + return array_search($key, $preferredBindingOrder); + }); $query->bindings = $sortedBindings; }
false
Other
laravel
framework
3abd69a10f0062540f5991431363ed7ed54004a8.json
Apply fixes from StyleCI (#37732)
src/Illuminate/Filesystem/FilesystemManager.php
@@ -100,7 +100,7 @@ public function build($config) { return $this->resolve('ondemand', is_array($config) ? $config : [ 'driver' => 'local', - 'root' => $config + 'root' => $config, ]); }
false
Other
laravel
framework
27ddf7da753290940a3a359ef7c3be37542b84d9.json
Use regular function for php 7.3 compatibility
src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php
@@ -184,7 +184,9 @@ protected function compileAnsiOffset(Builder $query, $components) // As this moves the order statement to be part of the "select" statement, we need to // move the bindings to the right position: right after "select". $preferredBindingOrder = ['select', 'order', 'from', 'join', 'where', 'groupBy', 'having', 'union', 'unionOrder']; - $sortedBindings = Arr::sort($query->bindings, fn ($bindings, $key) => array_search($key, $preferredBindingOrder)); + $sortedBindings = Arr::sort($query->bindings, function ($bindings, $key) use ($preferredBindingOrder) { + return array_search($key, $preferredBindingOrder); + }); $query->bindings = $sortedBindings; // Next we need to calculate the constraints that should be placed on the query
false
Other
laravel
framework
2bcdbb0d13e3d9d7bcbc5ba20c4ddead67cf77fc.json
Fix style issue
src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php
@@ -184,7 +184,7 @@ protected function compileAnsiOffset(Builder $query, $components) // As this moves the order statement to be part of the "select" statement, we need to // move the bindings to the right position: right after "select". $preferredBindingOrder = ['select', 'order', 'from', 'join', 'where', 'groupBy', 'having', 'union', 'unionOrder']; - $sortedBindings = Arr::sort($query->bindings, fn($bindings, $key) => array_search($key, $preferredBindingOrder)); + $sortedBindings = Arr::sort($query->bindings, fn ($bindings, $key) => array_search($key, $preferredBindingOrder)); $query->bindings = $sortedBindings; // Next we need to calculate the constraints that should be placed on the query
false
Other
laravel
framework
3ec57b2d21129d5af78fe8978d247d1db50b602d.json
add method to build an on-demand filesystem the `build` method allows the user to create an on-demand filesystem disk. a string passed to the method will be treated as the "root" of a local driver (99% use case). passing an array allows full customization of the disk config.
src/Illuminate/Filesystem/FilesystemManager.php
@@ -90,6 +90,19 @@ public function cloud() return $this->disks[$name] = $this->get($name); } + /** + * Build an on-demand disk. + * + * @param string|array $root + * @return \Illuminate\Contracts\Filesystem\Filesystem + */ + public function build($root) + { + $config = is_array($root) ? $root : ['driver' => 'local', 'root' => $root]; + + return $this->disks['ondemand'] = $this->resolve('ondemand', $config); + } + /** * Attempt to get the disk from the local cache. * @@ -109,9 +122,9 @@ protected function get($name) * * @throws \InvalidArgumentException */ - protected function resolve($name) + protected function resolve($name, $config = null) { - $config = $this->getConfig($name); + $config = $config ?? $this->getConfig($name); if (empty($config['driver'])) { throw new InvalidArgumentException("Disk [{$name}] does not have a configured driver.");
true
Other
laravel
framework
3ec57b2d21129d5af78fe8978d247d1db50b602d.json
add method to build an on-demand filesystem the `build` method allows the user to create an on-demand filesystem disk. a string passed to the method will be treated as the "root" of a local driver (99% use case). passing an array allows full customization of the disk config.
src/Illuminate/Support/Facades/Storage.php
@@ -8,6 +8,7 @@ * @method static \Illuminate\Contracts\Filesystem\Filesystem assertExists(string|array $path) * @method static \Illuminate\Contracts\Filesystem\Filesystem assertMissing(string|array $path) * @method static \Illuminate\Contracts\Filesystem\Filesystem cloud() + * @method static \Illuminate\Contracts\Filesystem\Filesystem build(string|array $root) * @method static \Illuminate\Contracts\Filesystem\Filesystem disk(string|null $name = null) * @method static \Illuminate\Filesystem\FilesystemManager extend(string $driver, \Closure $callback) * @method static \Symfony\Component\HttpFoundation\StreamedResponse download(string $path, string|null $name = null, array|null $headers = [])
true
Other
laravel
framework
3ec57b2d21129d5af78fe8978d247d1db50b602d.json
add method to build an on-demand filesystem the `build` method allows the user to create an on-demand filesystem disk. a string passed to the method will be treated as the "root" of a local driver (99% use case). passing an array allows full customization of the disk config.
tests/Filesystem/FilesystemManagerTest.php
@@ -2,6 +2,7 @@ namespace Illuminate\Tests\Filesystem; +use Illuminate\Contracts\Filesystem\Filesystem; use Illuminate\Filesystem\FilesystemManager; use Illuminate\Foundation\Application; use InvalidArgumentException; @@ -20,4 +21,18 @@ public function testExceptionThrownOnUnsupportedDriver() $filesystem->disk('local'); } + + public function testCanBuildOnDemandDisk() + { + $filesystem = new FilesystemManager(new Application); + + $this->assertInstanceOf(Filesystem::class, $filesystem->build('my-custom-path')); + + $this->assertInstanceOf(Filesystem::class, $filesystem->build([ + 'driver' => 'local', + 'root' => 'my-custom-path', + 'url' => 'my-custom-url', + 'visibility' => 'public', + ])); + } }
true
Other
laravel
framework
40104bac79e74aeea5b2b5479de3d9430198899a.json
Update Builder.php (#37717)
src/Illuminate/Database/Eloquent/Builder.php
@@ -283,7 +283,7 @@ public function where($column, $operator = null, $value = null, $boolean = 'and' * @param mixed $operator * @param mixed $value * @param string $boolean - * @return \Illuminate\Database\Eloquent\Model|static + * @return \Illuminate\Database\Eloquent\Model|static|null */ public function firstWhere($column, $operator = null, $value = null, $boolean = 'and') {
false
Other
laravel
framework
5781ad4fc123731eb485c919a1d388faef467da9.json
Apply fixes from StyleCI (#37689)
src/Illuminate/Validation/Rules/RequiredIf.php
@@ -24,7 +24,7 @@ public function __construct($condition) if (! is_string($condition) && (is_bool($condition) || is_callable($condition))) { $this->condition = $condition; } else { - throw new InvalidArgumentException("The provided condition must be a callable or boolean."); + throw new InvalidArgumentException('The provided condition must be a callable or boolean.'); } }
false
Other
laravel
framework
a590739385318b7fba687c91142d72049a01a307.json
Simplify `Conditionable` tests (#37657)
tests/Support/SupportConditionableTest.php
@@ -2,107 +2,87 @@ namespace Illuminate\Tests\Support; -use Exception; use Illuminate\Support\Traits\Conditionable; use PHPUnit\Framework\TestCase; class SupportConditionableTest extends TestCase { public function testWhenConditionCallback() { - $object = (new CustomConditionableObject()) - ->when(2, function ($object, $condition) { - $object->on(); - $this->assertEquals(2, $condition); + $logger = (new ConditionableLogger()) + ->when(2, function ($logger, $condition) { + $logger->log('when', $condition); }, function () { - throw new Exception('when() should not trigger default callback on a truthy value'); + $logger->log('default', $condition); }); - $this->assertTrue($object->enabled); + $this->assertSame(['when', 2], $logger->values); } public function testWhenDefaultCallback() { - $object = (new CustomConditionableObject()) + $logger = (new ConditionableLogger()) ->when(null, function () { - throw new Exception('when() should not trigger on a falsy value'); - }, function ($object, $condition) { - $object->on(); - $this->assertNull($condition); + $logger->log('when', $condition); + }, function ($logger, $condition) { + $logger->log('default', $condition); }); - $this->assertTrue($object->enabled); + $this->assertSame(['default', null], $logger->values); } public function testUnlessConditionCallback() { - $object = (new CustomConditionableObject()) - ->unless(null, function ($object, $condition) { - $object->on(); - $this->assertNull($condition); + $logger = (new ConditionableLogger()) + ->unless(null, function ($logger, $condition) { + $logger->log('unless', $condition); }, function () { - throw new Exception('unless() should not trigger default callback on a falsy value'); + $logger->log('default', $condition); }); - $this->assertTrue($object->enabled); + $this->assertSame(['unless', null], $logger->values); } public function testUnlessDefaultCallback() { - $object = (new CustomConditionableObject()) + $logger = (new ConditionableLogger()) ->unless(2, function () { - throw new Exception('unless() should not trigger on a truthy value'); - }, function ($object, $condition) { - $object->on(); - $this->assertEquals(2, $condition); + $logger->log('unless', $condition); + }, function ($logger, $condition) { + $logger->log('default', $condition); }); - $this->assertTrue($object->enabled); + $this->assertSame(['default', 2], $logger->values); } public function testWhenProxy() { - $object = (new CustomConditionableObject())->when(true)->on(); + $logger = (new ConditionableLogger()) + ->when(true)->log('one') + ->when(false)->log('two'); - $this->assertInstanceOf(CustomConditionableObject::class, $object); - $this->assertTrue($object->enabled); - - $object = (new CustomConditionableObject())->when(false)->on(); - - $this->assertInstanceOf(CustomConditionableObject::class, $object); - $this->assertFalse($object->enabled); + $this->assertSame(['one'], $logger->values); } public function testUnlessProxy() { - $object = (new CustomConditionableObject())->unless(false)->on(); - - $this->assertInstanceOf(CustomConditionableObject::class, $object); - $this->assertTrue($object->enabled); + $logger = (new ConditionableLogger()) + ->unless(true)->log('one') + ->unless(false)->log('two'); - $object = (new CustomConditionableObject())->unless(true)->on(); - - $this->assertInstanceOf(CustomConditionableObject::class, $object); - $this->assertFalse($object->enabled); + $this->assertSame(['two'], $logger->values); } } -class CustomConditionableObject +class ConditionableLogger { use Conditionable; - public $enabled = false; - - public function on() - { - $this->enabled = true; - - return $this; - } + public $values = []; - public function off() + public function log(...$values) { - $this->enabled = false; + array_push($this->values, ...$values); return $this; }
false
Other
laravel
framework
0b1610f7a934787856b141205a9f178f33e17f8b.json
fix callable password defaults
src/Illuminate/Validation/Rules/Password.php
@@ -132,7 +132,9 @@ public static function defaults($callback = null) */ public static function default() { - $password = value(static::$defaultCallback); + $password = is_callable(static::$defaultCallback) + ? call_user_func(static::$defaultCallback) + : static::$defaultCallback; return $password instanceof Rule ? $password : static::min(8); }
false
Other
laravel
framework
019277c92d8f5c00fc307ea73ece23d242fa73c9.json
Apply fixes from StyleCI (#37655)
src/Illuminate/Validation/Rules/Password.php
@@ -168,7 +168,7 @@ public function setValidator($validator) $this->validator = $validator; return $this; - } + } /** * Set the data under validation.
false
Other
laravel
framework
bf2acca4e7f3db44ceb28483a0b43b9e66375eec.json
Apply fixes from StyleCI (#37637)
tests/Testing/Fluent/AssertTest.php
@@ -435,13 +435,13 @@ public function testAssertWhereContainsFailsWithMissingNestedValue() $this->expectException(AssertionFailedError::class); $this->expectExceptionMessage('Property [id] does not contain [5].'); - $assert->whereContains('id', [1,2,3,4,5]); + $assert->whereContains('id', [1, 2, 3, 4, 5]); } public function testAssertWhereContainsFailsWhenDoesNotMatchType() { $assert = AssertableJson::fromArray([ - 'foo' => [1,2,3,4] + 'foo' => [1, 2, 3, 4], ]); $this->expectException(AssertionFailedError::class); @@ -460,20 +460,20 @@ public function testAssertWhereContainsWithNestedValue() ]); $assert->whereContains('id', 1); - $assert->whereContains('id', [1,2,3,4]); - $assert->whereContains('id', [4,3,2,1]); + $assert->whereContains('id', [1, 2, 3, 4]); + $assert->whereContains('id', [4, 3, 2, 1]); } public function testAssertWhereContainsWithMatchingType() { $assert = AssertableJson::fromArray([ - 'foo' => [1,2,3,4] + 'foo' => [1, 2, 3, 4], ]); $assert->whereContains('foo', 1); $assert->whereContains('foo', [1]); } - + public function testAssertWhereContainsWithNullValue() { $assert = AssertableJson::fromArray([ @@ -487,10 +487,10 @@ public function testAssertWhereContainsWithNullValue() public function testAssertWhereContainsWithOutOfOrderMatchingType() { $assert = AssertableJson::fromArray([ - 'foo' => [4,1,7,3] + 'foo' => [4, 1, 7, 3], ]); - $assert->whereContains('foo', [1,7,4,3]); + $assert->whereContains('foo', [1, 7, 4, 3]); } public function testAssertWhereContainsWithOutOfOrderNestedMatchingType() @@ -512,6 +512,7 @@ public function testAssertWhereContainsWithNullExpectation() $assert->whereContains('foo', null); } + public function testAssertNestedWhereMatchesValue() { $assert = AssertableJson::fromArray([
false
Other
laravel
framework
ee1e6b4db76ff11505deb9e5faba3a04de424e97.json
add setter for record modification state
src/Illuminate/Database/Connection.php
@@ -891,6 +891,19 @@ public function recordsHaveBeenModified($value = true) } } + /** + * Set the record modification state. + * + * @param bool $value + * @return $this + */ + public function setRecordModificationState(bool $value) + { + $this->recordsModified = $value; + + return $this; + } + /** * Reset the record modification state. *
false
Other
laravel
framework
451f08565d7d491328fe3fa7be7e142f5c81ebd3.json
Adjust code doc
src/Illuminate/Testing/Fluent/Concerns/Matching.php
@@ -104,7 +104,7 @@ public function whereAllType(array $bindings): self } /** - * Asserts that all values exist and match their expected values. + * Asserts that the property matches their expected values. * * @param string $key * @param array|string $expected
false
Other
laravel
framework
3ff3c9a81207acd7c2825cc0c737e2fd41a82e41.json
Add another test
tests/Testing/Fluent/AssertTest.php
@@ -504,6 +504,14 @@ public function testAssertWhereHasWithOutOfOrderNestedMatchingType() $assert->whereHas('baz', 4); } + public function testAssertWhereHasWithNullExpectation() + { + $assert = AssertableJson::fromArray([ + 'foo' => 1, + ]); + + $assert->whereHas('foo', null); + } public function testAssertNestedWhereMatchesValue() { $assert = AssertableJson::fromArray([
false
Other
laravel
framework
77c577a4ac1c431c6012d24e6c64cdc59e9e9327.json
Fix typo and move below other where methods
src/Illuminate/Testing/Fluent/Concerns/Matching.php
@@ -9,42 +9,6 @@ trait Matching { - /** - * Assets that all values exist and match their expected values. - * - * @param string $key - * @param array|string $expected - * - * @return $this - */ - public function whereHas(string $key, $expected) - { - $actual = Collection::make( - $this->prop($key) ?? $this->prop() - ); - - $missing = Collection::make($expected)->reject(function ($search) use ($key, $actual) { - if ($actual->containsStrict($key, $search)) { - return true; - } - - return $actual->containsStrict($search); - })->toArray(); - - $values = array_values($missing); - - PHPUnit::assertEmpty( - $missing, - sprintf( - 'Property [%s] does not contain [%s].', - $key, - implode(', ', $values) - ) - ); - - return $this; - } - /** * Asserts that the property matches the expected value. * @@ -139,6 +103,42 @@ public function whereAllType(array $bindings): self return $this; } + /** + * Asserts that all values exist and match their expected values. + * + * @param string $key + * @param array|string $expected + * + * @return $this + */ + public function whereHas(string $key, $expected) + { + $actual = Collection::make( + $this->prop($key) ?? $this->prop() + ); + + $missing = Collection::make($expected)->reject(function ($search) use ($key, $actual) { + if ($actual->containsStrict($key, $search)) { + return true; + } + + return $actual->containsStrict($search); + })->toArray(); + + $values = array_values($missing); + + PHPUnit::assertEmpty( + $missing, + sprintf( + 'Property [%s] does not contain [%s].', + $key, + implode(', ', $values) + ) + ); + + return $this; + } + /** * Ensures that all properties are sorted the same way, recursively. *
false
Other
laravel
framework
cbdfde20578553816a69ccd8f4d1f9e42958ba72.json
Add `whereHas` assertable JSON method
src/Illuminate/Testing/Fluent/Concerns/Matching.php
@@ -9,6 +9,42 @@ trait Matching { + /** + * Assets that all values exist and match their expected values. + * + * @param string $key + * @param array|string $expected + * + * @return $this + */ + public function whereHas(string $key, $expected) + { + $actual = Collection::make( + $this->prop($key) ?? $this->prop() + ); + + $missing = Collection::make($expected)->reject(function ($search) use ($key, $actual) { + if ($actual->containsStrict($key, $search)) { + return true; + } + + return $actual->containsStrict($search); + })->toArray(); + + $values = array_values($missing); + + PHPUnit::assertEmpty( + $missing, + sprintf( + 'Property [%s] does not contain [%s].', + $key, + implode(', ', $values) + ) + ); + + return $this; + } + /** * Asserts that the property matches the expected value. *
true
Other
laravel
framework
cbdfde20578553816a69ccd8f4d1f9e42958ba72.json
Add `whereHas` assertable JSON method
tests/Testing/Fluent/AssertTest.php
@@ -401,6 +401,109 @@ public function testAssertWhereFailsWhenDoesNotMatchValueUsingArrayable() ]); } + public function testAssertWhereHasFailsWithEmptyValue() + { + $assert = AssertableJson::fromArray([]); + + $this->expectException(AssertionFailedError::class); + $this->expectExceptionMessage('Property [foo] does not contain [1].'); + + $assert->whereHas('foo', ['1']); + } + + public function testAssertWhereHasFailsWithMissingValue() + { + $assert = AssertableJson::fromArray([ + 'foo' => ['bar', 'baz'], + ]); + + $this->expectException(AssertionFailedError::class); + $this->expectExceptionMessage('Property [foo] does not contain [invalid].'); + + $assert->whereHas('foo', ['bar', 'baz', 'invalid']); + } + + public function testAssertWhereHasFailsWithMissingNestedValue() + { + $assert = AssertableJson::fromArray([ + ['id' => 1], + ['id' => 2], + ['id' => 3], + ['id' => 4], + ]); + + $this->expectException(AssertionFailedError::class); + $this->expectExceptionMessage('Property [id] does not contain [5].'); + + $assert->whereHas('id', [1,2,3,4,5]); + } + + public function testAssertWhereHasFailsWhenDoesNotMatchType() + { + $assert = AssertableJson::fromArray([ + 'foo' => [1,2,3,4] + ]); + + $this->expectException(AssertionFailedError::class); + $this->expectExceptionMessage('Property [foo] does not contain [1].'); + + $assert->whereHas('foo', ['1']); + } + + public function testAssertWhereHasWithNestedValue() + { + $assert = AssertableJson::fromArray([ + ['id' => 1], + ['id' => 2], + ['id' => 3], + ['id' => 4], + ]); + + $assert->whereHas('id', 1); + $assert->whereHas('id', [1,2,3,4]); + $assert->whereHas('id', [4,3,2,1]); + } + + public function testAssertWhereHasWithMatchingType() + { + $assert = AssertableJson::fromArray([ + 'foo' => [1,2,3,4] + ]); + + $assert->whereHas('foo', 1); + $assert->whereHas('foo', [1]); + } + + public function testAssertWhereHasWithNullValue() + { + $assert = AssertableJson::fromArray([ + 'foo' => null, + ]); + + $assert->whereHas('foo', null); + $assert->whereHas('foo', [null]); + } + + public function testAssertWhereHasWithOutOfOrderMatchingType() + { + $assert = AssertableJson::fromArray([ + 'foo' => [4,1,7,3] + ]); + + $assert->whereHas('foo', [1,7,4,3]); + } + + public function testAssertWhereHasWithOutOfOrderNestedMatchingType() + { + $assert = AssertableJson::fromArray([ + ['bar' => 5], + ['baz' => 4], + ['zal' => 8], + ]); + + $assert->whereHas('baz', 4); + } + public function testAssertNestedWhereMatchesValue() { $assert = AssertableJson::fromArray([
true
Other
laravel
framework
fc46309cfa4678f06acf0a91a5eee34d33f3516d.json
Apply fixes from StyleCI (#37620)
src/Illuminate/Foundation/Providers/FoundationServiceProvider.php
@@ -87,7 +87,7 @@ public function registerRequestSignatureValidation() }); Request::macro('hasValidSignatureWhileIgnoring', function ($ignoreQuery = [], $absolute = true) { - return URL::hasValidSignature($this, $absolute, $ignoreQuery); - }); + return URL::hasValidSignature($this, $absolute, $ignoreQuery); + }); } }
false
Other
laravel
framework
a2dc47c89efa8101d14a3592dec4e666bf8146fa.json
use modern template
src/Illuminate/Foundation/Console/stubs/markdown-notification.stub
@@ -1,13 +1,13 @@ <?php -namespace DummyNamespace; +namespace {{ namespace }}; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; -class DummyClass extends Notification +class {{ class }} extends Notification { use Queueable;
true
Other
laravel
framework
a2dc47c89efa8101d14a3592dec4e666bf8146fa.json
use modern template
src/Illuminate/Foundation/Console/stubs/notification.stub
@@ -1,13 +1,13 @@ <?php -namespace DummyNamespace; +namespace {{ namespace }}; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; -class DummyClass extends Notification +class {{ class }} extends Notification { use Queueable;
true
Other
laravel
framework
c0ed2e420d1853e213c7b39729346a3c9c51a6e5.json
Apply fixes from StyleCI (#37547)
src/Illuminate/Mail/MailManager.php
@@ -263,8 +263,8 @@ protected function createSendmailTransport(array $config) protected function createSesTransport(array $config) { $config = array_merge( - $this->app['config']->get('services.ses', []), - ['version' => 'latest', 'service' => 'email'], + $this->app['config']->get('services.ses', []), + ['version' => 'latest', 'service' => 'email'], $config );
false
Other
laravel
framework
b3eafbdbb054b1cf0f59fb674eec8f92474f7c7d.json
Remove unused dependency (#37542)
src/Illuminate/Foundation/Console/DownCommand.php
@@ -5,7 +5,6 @@ use Exception; use Illuminate\Console\Command; use Illuminate\Foundation\Exceptions\RegisterErrorViewPaths; -use Illuminate\Support\Facades\View; class DownCommand extends Command {
false
Other
laravel
framework
1808581f2cb08b7fa79f79760668f3e17abe9162.json
Introduce Conditional trait on validation rules
src/Illuminate/Support/Traits/Conditional.php
@@ -0,0 +1,45 @@ +<?php + +namespace Illuminate\Support\Traits; + +use BadMethodCallException; +use Closure; +use ReflectionClass; +use ReflectionMethod; + +trait Conditional +{ + /** + * Apply the callback if the given "value" is true. + * + * @param mixed $value + * @param callable $callback + * @param callable|null $default + * + * @return mixed|$this + */ + public function when($value, $callback, $default = null) + { + if ($value) { + return $callback($this, $value) ?: $this; + } elseif ($default) { + return $default($this, $value) ?: $this; + } + + return $this; + } + + /** + * Apply the callback if the given "value" is false. + * + * @param mixed $value + * @param callable $callback + * @param callable|null $default + * + * @return mixed|$this + */ + public function unless($value, $callback, $default = null) + { + return $this->when(! $value, $callback, $default); + } +}
true
Other
laravel
framework
1808581f2cb08b7fa79f79760668f3e17abe9162.json
Introduce Conditional trait on validation rules
src/Illuminate/Validation/Rules/Dimensions.php
@@ -2,8 +2,12 @@ namespace Illuminate\Validation\Rules; +use Illuminate\Support\Traits\Conditional; + class Dimensions { + use Conditional; + /** * The constraints for the dimensions rule. *
true
Other
laravel
framework
1808581f2cb08b7fa79f79760668f3e17abe9162.json
Introduce Conditional trait on validation rules
src/Illuminate/Validation/Rules/Exists.php
@@ -2,9 +2,12 @@ namespace Illuminate\Validation\Rules; +use Illuminate\Support\Traits\Conditional; + class Exists { use DatabaseRule; + use Conditional; /** * Convert the rule to a validation string.
true
Other
laravel
framework
1808581f2cb08b7fa79f79760668f3e17abe9162.json
Introduce Conditional trait on validation rules
src/Illuminate/Validation/Rules/Password.php
@@ -8,10 +8,13 @@ use Illuminate\Contracts\Validation\UncompromisedVerifier; use Illuminate\Support\Arr; use Illuminate\Support\Facades\Validator; +use Illuminate\Support\Traits\Conditional; use InvalidArgumentException; class Password implements Rule, DataAwareRule { + use Conditional; + /** * The data under validation. *
true
Other
laravel
framework
1808581f2cb08b7fa79f79760668f3e17abe9162.json
Introduce Conditional trait on validation rules
src/Illuminate/Validation/Rules/Unique.php
@@ -3,10 +3,12 @@ namespace Illuminate\Validation\Rules; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Traits\Conditional; class Unique { use DatabaseRule; + use Conditional; /** * The ID that should be ignored.
true
Other
laravel
framework
1808581f2cb08b7fa79f79760668f3e17abe9162.json
Introduce Conditional trait on validation rules
tests/Validation/ValidationDimensionsRuleTest.php
@@ -29,5 +29,14 @@ public function testItCorrectlyFormatsAStringVersionOfTheRule() $rule = Rule::dimensions()->minWidth(300)->minHeight(400); $this->assertSame('dimensions:min_width=300,min_height=400', (string) $rule); + + $rule = Rule::dimensions() + ->when(true, function($rule) { + $rule->height('100'); + }) + ->unless(true, function($rule) { + $rule->width('200'); + }); + $this->assertSame('dimensions:height=100', (string) $rule); } }
true
Other
laravel
framework
1808581f2cb08b7fa79f79760668f3e17abe9162.json
Introduce Conditional trait on validation rules
tests/Validation/ValidationExistsRuleTest.php
@@ -116,6 +116,35 @@ public function testItChoosesValidRecordsUsingWhereNotInRule() $this->assertTrue($v->passes()); } + public function testItChoosesValidRecordsUsingConditionalModifiers() + { + $rule = new Exists('users', 'id'); + $rule->when(true, function($rule) { + $rule->whereNotIn('type', [ 'foo', 'bar' ]); + }); + $rule->unless(true, function($rule) { + $rule->whereNotIn('type', [ 'baz', 'other' ]); + }); + + User::create([ 'id' => '1', 'type' => 'foo' ]); + User::create([ 'id' => '2', 'type' => 'bar' ]); + User::create([ 'id' => '3', 'type' => 'baz' ]); + User::create([ 'id' => '4', 'type' => 'other' ]); + + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, [], [ 'id' => $rule ]); + $v->setPresenceVerifier(new DatabasePresenceVerifier(Eloquent::getConnectionResolver())); + + $v->setData([ 'id' => 1 ]); + $this->assertFalse($v->passes()); + $v->setData([ 'id' => 2 ]); + $this->assertFalse($v->passes()); + $v->setData([ 'id' => 3 ]); + $this->assertTrue($v->passes()); + $v->setData([ 'id' => 4 ]); + $this->assertTrue($v->passes()); + } + public function testItChoosesValidRecordsUsingWhereNotInAndWhereNotInRulesTogether() { $rule = new Exists('users', 'id');
true
Other
laravel
framework
1808581f2cb08b7fa79f79760668f3e17abe9162.json
Introduce Conditional trait on validation rules
tests/Validation/ValidationPasswordRuleTest.php
@@ -41,6 +41,25 @@ public function testMin() $this->passes(new Password(8), ['88888888']); } + public function testConditional() + { + $is_privileged_user = true; + $rule = (new Password(8))->when($is_privileged_user, function($rule) { + $rule->symbols(); + }); + + $this->fails($rule, [ 'aaaaaaaa', '11111111' ], [ + 'The my password must contain at least one symbol.', + ]); + + $is_privileged_user = false; + $rule = (new Password(8))->when($is_privileged_user, function($rule) { + $rule->symbols(); + }); + + $this->passes($rule, [ 'aaaaaaaa', '11111111' ]); + } + public function testMixedCase() { $this->fails(Password::min(2)->mixedCase(), ['nn', 'MM'], [
true
Other
laravel
framework
1808581f2cb08b7fa79f79760668f3e17abe9162.json
Introduce Conditional trait on validation rules
tests/Validation/ValidationUniqueRuleTest.php
@@ -40,6 +40,16 @@ public function testItCorrectlyFormatsAStringVersionOfTheRule() $rule->where('foo', 'bar'); $this->assertSame('unique:table,column,"Taylor, Otwell",id_column,foo,"bar"', (string) $rule); + $rule = new Unique(EloquentModelStub::class, 'column'); + $rule->where('foo', 'bar'); + $rule->when(true, function($rule) { + $rule->ignore('Taylor, Otwell', 'id_column'); + }); + $rule->unless(true, function($rule) { + $rule->ignore('Chris', 'id_column'); + }); + $this->assertSame('unique:table,column,"Taylor, Otwell",id_column,foo,"bar"', (string) $rule); + $rule = new Unique('table', 'column'); $rule->ignore('Taylor, Otwell"\'..-"', 'id_column'); $rule->where('foo', 'bar');
true
Other
laravel
framework
e4b509e6571bbdc99db0725ce3ca897d47afccf1.json
Extract removable symlink check to method
src/Illuminate/Foundation/Console/StorageLinkCommand.php
@@ -33,7 +33,7 @@ public function handle() $force = $this->option('force'); foreach ($this->links() as $link => $target) { - if (file_exists($link) && ! (is_link($link) && $force)) { + if (file_exists($link) && ! $this->removableSymlink($link, $force)) { $this->error("The [$link] link already exists."); continue; } @@ -64,4 +64,16 @@ protected function links() return $this->laravel['config']['filesystems.links'] ?? [public_path('storage') => storage_path('app/public')]; } + + /** + * Checks that the provided path is a symlink and force option is turned on. + * + * @param string $link + * @param bool $force + * @return bool + */ + protected function removableSymlink(string $link, bool $force): bool + { + return is_link($link) && $force; + } }
false
Other
laravel
framework
968a36478814c740d25ec4d6f9c8bef859a2f834.json
Update signature formatting Co-authored-by: Dries Vints <dries@vints.io>
src/Illuminate/Foundation/Console/StorageLinkCommand.php
@@ -11,7 +11,8 @@ class StorageLinkCommand extends Command * * @var string */ - protected $signature = 'storage:link {--relative : Create the symbolic link using relative paths} + protected $signature = 'storage:link + {--relative : Create the symbolic link using relative paths} {--force : Recreate already existing symbolic links}'; /**
false
Other
laravel
framework
306208394bf05f9acebce3663c3cfb7e3b1ac21c.json
Fix types of Console\Command properties (#37495) `Command::$description` and `Command::$help` are never null, because they are set via `Command::setDescription()` and `Command::setHelp()` respectively in the constructor.
src/Illuminate/Console/Command.php
@@ -38,14 +38,14 @@ class Command extends SymfonyCommand /** * The console command description. * - * @var string|null + * @var string */ protected $description; /** * The console command help text. * - * @var string|null + * @var string */ protected $help;
false
Other
laravel
framework
5a92f04b0287c609d025cd8ea87829b9c7b3e290.json
fix #37483 (aggregates with having) (#37487)
src/Illuminate/Database/Query/Builder.php
@@ -2826,8 +2826,8 @@ public function average($column) */ public function aggregate($function, $columns = ['*']) { - $results = $this->cloneWithout($this->unions ? [] : ['columns']) - ->cloneWithoutBindings($this->unions ? [] : ['select']) + $results = $this->cloneWithout($this->unions || $this->havings ? [] : ['columns']) + ->cloneWithoutBindings($this->unions || $this->havings ? [] : ['select']) ->setAggregate($function, $columns) ->get($columns);
true
Other
laravel
framework
5a92f04b0287c609d025cd8ea87829b9c7b3e290.json
fix #37483 (aggregates with having) (#37487)
src/Illuminate/Database/Query/Grammars/Grammar.php
@@ -45,7 +45,7 @@ class Grammar extends BaseGrammar */ public function compileSelect(Builder $query) { - if ($query->unions && $query->aggregate) { + if (($query->unions || $query->havings) && $query->aggregate) { return $this->compileUnionAggregate($query); }
true
Other
laravel
framework
5a92f04b0287c609d025cd8ea87829b9c7b3e290.json
fix #37483 (aggregates with having) (#37487)
tests/Database/DatabaseQueryBuilderTest.php
@@ -1034,6 +1034,22 @@ public function testUnionAggregate() $builder->from('posts')->union($this->getSqlServerBuilder()->from('videos'))->count(); } + public function testHavingAggregate() + { + $expected = 'select count(*) as aggregate from (select (select `count(*)` from `videos` where `posts`.`id` = `videos`.`post_id`) as `videos_count` from `posts` having `videos_count` > ?) as `temp_table`'; + $builder = $this->getMySqlBuilder(); + $builder->getConnection()->shouldReceive('getDatabaseName'); + $builder->getConnection()->shouldReceive('select')->once()->with($expected, [0 => 1], true)->andReturn([['aggregate' => 1]]); + $builder->getProcessor()->shouldReceive('processSelect')->once()->andReturnUsing(function ($builder, $results) { + return $results; + }); + + $builder->from('posts')->selectSub(function ($query) { + $query->from('videos')->select('count(*)')->whereColumn('posts.id', '=', 'videos.post_id'); + }, 'videos_count')->having('videos_count', '>', 1); + $builder->count(); + } + public function testSubSelectWhereIns() { $builder = $this->getBuilder();
true
Other
laravel
framework
188c99485dc3954be93c6c5e0f509d9cbe2ab13d.json
Add global callback handler Adds a way to call `Model::handleLazyLoadingViolationUsing()` from a service provider to add a way to handle violations for all models instead of overriding `violatedLazyLoading` on the models themselves.
src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php
@@ -468,6 +468,11 @@ public function isRelation($key) */ protected function violatedLazyLoading($key) { + if (isset(static::$violatedLazyLoadingCallback)) { + call_user_func(static::$violatedLazyLoadingCallback, $this, $key); + return; + } + throw new LazyLoadingViolationException($this, $key); }
true
Other
laravel
framework
188c99485dc3954be93c6c5e0f509d9cbe2ab13d.json
Add global callback handler Adds a way to call `Model::handleLazyLoadingViolationUsing()` from a service provider to add a way to handle violations for all models instead of overriding `violatedLazyLoading` on the models themselves.
src/Illuminate/Database/Eloquent/Model.php
@@ -158,6 +158,13 @@ abstract class Model implements Arrayable, ArrayAccess, Jsonable, JsonSerializab */ protected static $modelsShouldPreventLazyLoading = false; + /** + * The callback that is responsible for handing lazy loading violations. + * + * @var callable|null + */ + protected static $violatedLazyLoadingCallback; + /** * The name of the "created at" column. * @@ -358,6 +365,16 @@ public static function preventLazyLoading($value = true) static::$modelsShouldPreventLazyLoading = $value; } + /** + * Register a callback that is responsible for handling lazy loading violations. + * + * @param callable $callback + */ + public static function handleLazyLoadingViolationUsing(callable $callback) + { + static::$violatedLazyLoadingCallback = $callback; + } + /** * Fill the model with an array of attributes. *
true
Other
laravel
framework
188c99485dc3954be93c6c5e0f509d9cbe2ab13d.json
Add global callback handler Adds a way to call `Model::handleLazyLoadingViolationUsing()` from a service provider to add a way to handle violations for all models instead of overriding `violatedLazyLoading` on the models themselves.
tests/Integration/Database/EloquentStrictLoadingTest.php
@@ -100,6 +100,35 @@ public function testStrictModeThrowsAnExceptionOnLazyLoadingInRelations() $models[0]->modelTwos[0]->modelThrees; } + + public function testStrictModeWithCustomCallbackOnLazyLoading() + { + $this->expectsEvents(ViolatedLazyLoadingEvent::class); + + Model::handleLazyLoadingViolationUsing(function ($model, $key) { + event(new ViolatedLazyLoadingEvent($model, $key)); + }); + + EloquentStrictLoadingTestModel1::create(); + EloquentStrictLoadingTestModel1::create(); + + $models = EloquentStrictLoadingTestModel1::get(); + + $models[0]->modelTwos; + } + + public function testStrictModeWithOverriddenHandlerOnLazyLoading() + { + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('Violated'); + + EloquentStrictLoadingTestModel1WithCustomHandler::create(); + EloquentStrictLoadingTestModel1WithCustomHandler::create(); + + $models = EloquentStrictLoadingTestModel1WithCustomHandler::get(); + + $models[0]->modelTwos; + } } class EloquentStrictLoadingTestModel1 extends Model @@ -114,6 +143,23 @@ public function modelTwos() } } +class EloquentStrictLoadingTestModel1WithCustomHandler extends Model +{ + public $table = 'test_model1'; + public $timestamps = false; + protected $guarded = []; + + public function modelTwos() + { + return $this->hasMany(EloquentStrictLoadingTestModel2::class, 'model_1_id'); + } + + protected function violatedLazyLoading($key) + { + throw new \RuntimeException("Violated {$key}"); + } +} + class EloquentStrictLoadingTestModel2 extends Model { public $table = 'test_model2'; @@ -132,3 +178,15 @@ class EloquentStrictLoadingTestModel3 extends Model public $timestamps = false; protected $guarded = []; } + +class ViolatedLazyLoadingEvent +{ + public $model; + public $key; + + public function __construct($model, $key) + { + $this->model = $model; + $this->key = $key; + } +}
true
Other
laravel
framework
bed4033c8ff1a987a957c20126d6d2f7cc519cb8.json
Add model support for database assertions
src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php
@@ -17,15 +17,15 @@ trait InteractsWithDatabase /** * Assert that a given where condition exists in the database. * - * @param string $table + * @param \Illuminate\Database\Eloquent\Model|string $table * @param array $data * @param string|null $connection * @return $this */ protected function assertDatabaseHas($table, array $data, $connection = null) { $this->assertThat( - $table, new HasInDatabase($this->getConnection($connection), $data) + $this->getTable($table), new HasInDatabase($this->getConnection($connection), $data) ); return $this; @@ -34,7 +34,7 @@ protected function assertDatabaseHas($table, array $data, $connection = null) /** * Assert that a given where condition does not exist in the database. * - * @param string $table + * @param \Illuminate\Database\Eloquent\Model|string $table * @param array $data * @param string|null $connection * @return $this @@ -45,23 +45,23 @@ protected function assertDatabaseMissing($table, array $data, $connection = null new HasInDatabase($this->getConnection($connection), $data) ); - $this->assertThat($table, $constraint); + $this->assertThat($this->getTable($table), $constraint); return $this; } /** * Assert the count of table entries. * - * @param string $table + * @param \Illuminate\Database\Eloquent\Model|string $table * @param int $count * @param string|null $connection * @return $this */ protected function assertDatabaseCount($table, int $count, $connection = null) { $this->assertThat( - $table, new CountInDatabase($this->getConnection($connection), $count) + $this->getTable($table), new CountInDatabase($this->getConnection($connection), $count) ); return $this; @@ -81,7 +81,7 @@ protected function assertDeleted($table, array $data = [], $connection = null) return $this->assertDatabaseMissing($table->getTable(), [$table->getKeyName() => $table->getKey()], $table->getConnectionName()); } - $this->assertDatabaseMissing($table, $data, $connection); + $this->assertDatabaseMissing($this->getTable($table), $data, $connection); return $this; } @@ -102,7 +102,7 @@ protected function assertSoftDeleted($table, array $data = [], $connection = nul } $this->assertThat( - $table, new SoftDeletedInDatabase($this->getConnection($connection), $data, $deletedAtColumn) + $this->getTable($table), new SoftDeletedInDatabase($this->getConnection($connection), $data, $deletedAtColumn) ); return $this; @@ -152,6 +152,21 @@ protected function getConnection($connection = null) return $database->connection($connection); } + /** + * Get the table name. + * + * @param \Illuminate\Database\Eloquent\Model|string $table + * @return string + */ + protected function getTable($table) + { + if (is_subclass_of($table, Model::class)) { + return (new $table)->getTable(); + } + + return $table; + } + /** * Seed a given database connection. *
true
Other
laravel
framework
bed4033c8ff1a987a957c20126d6d2f7cc519cb8.json
Add model support for database assertions
tests/Foundation/FoundationInteractsWithDatabaseTest.php
@@ -41,6 +41,14 @@ public function testSeeInDatabaseFindsResults() $this->assertDatabaseHas($this->table, $this->data); } + public function testAssertDatabaseHasSupportModels() + { + $this->mockCountBuilder(1); + + $this->assertDatabaseHas(ProductStub::class, $this->data); + $this->assertDatabaseHas(new ProductStub, $this->data); + } + public function testSeeInDatabaseDoesNotFindResults() { $this->expectException(ExpectationFailedException::class); @@ -91,6 +99,14 @@ public function testDontSeeInDatabaseDoesNotFindResults() $this->assertDatabaseMissing($this->table, $this->data); } + public function testAssertDatabaseMissingSupportModels() + { + $this->mockCountBuilder(0); + + $this->assertDatabaseMissing(ProductStub::class, $this->data); + $this->assertDatabaseMissing(new ProductStub, $this->data); + } + public function testDontSeeInDatabaseFindsResults() { $this->expectException(ExpectationFailedException::class); @@ -110,6 +126,14 @@ public function testAssertTableEntriesCount() $this->assertDatabaseCount($this->table, 1); } + public function testAssertDatabaseCountSupportModels() + { + $this->mockCountBuilder(1); + + $this->assertDatabaseCount(ProductStub::class, 1); + $this->assertDatabaseCount(new ProductStub, 1); + } + public function testAssertTableEntriesCountWrong() { $this->expectException(ExpectationFailedException::class); @@ -168,6 +192,13 @@ public function testAssertSoftDeletedInDatabaseFindsResults() $this->assertSoftDeleted($this->table, $this->data); } + public function testAssertSoftDeletedSupportModelStrings() + { + $this->mockCountBuilder(1); + + $this->assertSoftDeleted(ProductStub::class, $this->data); + } + public function testAssertSoftDeletedInDatabaseDoesNotFindResults() { $this->expectException(ExpectationFailedException::class); @@ -208,6 +239,13 @@ public function testAssertSoftDeletedInDatabaseDoesNotFindModelWithCustomColumnR $this->assertSoftDeleted(new CustomProductStub($this->data)); } + public function testGetTableNameFromModel() + { + $this->assertEquals($this->table, $this->getTable(ProductStub::class)); + $this->assertEquals($this->table, $this->getTable(new ProductStub)); + $this->assertEquals($this->table, $this->getTable($this->table)); + } + protected function mockCountBuilder($countResult, $deletedAtColumn = 'deleted_at') { $builder = m::mock(Builder::class);
true
Other
laravel
framework
3a0af0a42cc22b030089ecc794e0211da6f64650.json
Add default timeout to NotPwnedVerifier
src/Illuminate/Validation/NotPwnedVerifier.php
@@ -15,15 +15,24 @@ class NotPwnedVerifier implements UncompromisedVerifier */ protected $factory; + /** + * The number of seconds the request can run before timing out. + * + * @var int + */ + public $timeout; + /** * Create a new uncompromised verifier. * * @param \Illuminate\Http\Client\Factory $factory + * @param int|null $timeout * @return void */ - public function __construct($factory) + public function __construct($factory, $timeout = null) { $this->factory = $factory; + $this->timeout = $timeout ?? 15; } /** @@ -77,7 +86,7 @@ protected function search($hashPrefix) try { $response = $this->factory->withHeaders([ 'Add-Padding' => true, - ])->get( + ])->timeout($this->timeout)->get( 'https://api.pwnedpasswords.com/range/'.$hashPrefix ); } catch (Exception $e) {
true
Other
laravel
framework
3a0af0a42cc22b030089ecc794e0211da6f64650.json
Add default timeout to NotPwnedVerifier
tests/Validation/ValidationNotPwnedVerifierTest.php
@@ -46,6 +46,12 @@ public function testApiResponseGoesWrong() ->with(['Add-Padding' => true]) ->andReturn($httpFactory); + $httpFactory + ->shouldReceive('timeout') + ->once() + ->with(15) + ->andReturn($httpFactory); + $httpFactory->shouldReceive('get') ->once() ->andReturn($response); @@ -77,6 +83,12 @@ public function testApiGoesDown() ->with(['Add-Padding' => true]) ->andReturn($httpFactory); + $httpFactory + ->shouldReceive('timeout') + ->once() + ->with(15) + ->andReturn($httpFactory); + $httpFactory->shouldReceive('get') ->once() ->andReturn($response); @@ -112,6 +124,12 @@ public function testDnsDown() ->with(['Add-Padding' => true]) ->andReturn($httpFactory); + $httpFactory + ->shouldReceive('timeout') + ->once() + ->with(15) + ->andReturn($httpFactory); + $httpFactory ->shouldReceive('get') ->once()
true
Other
laravel
framework
6a42e1216210b3ad3f738ab27e51e850190d9a1f.json
Apply fixes from StyleCI (#37427)
src/Illuminate/Database/Eloquent/Builder.php
@@ -356,7 +356,6 @@ public function hydrate(array $items) $model->preventsLazyLoading = Model::preventsLazyLoading(); - return $model; }, $items)); }
true
Other
laravel
framework
6a42e1216210b3ad3f738ab27e51e850190d9a1f.json
Apply fixes from StyleCI (#37427)
src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php
@@ -11,7 +11,6 @@ use Illuminate\Database\Eloquent\JsonEncodingException; use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Database\LazyLoadingViolationException; -use Illuminate\Database\StrictLoadingViolationException; use Illuminate\Support\Arr; use Illuminate\Support\Carbon; use Illuminate\Support\Collection as BaseCollection;
true
Other
laravel
framework
6a42e1216210b3ad3f738ab27e51e850190d9a1f.json
Apply fixes from StyleCI (#37427)
tests/Integration/Database/EloquentStrictLoadingTest.php
@@ -4,8 +4,8 @@ use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\LazyLoadingViolationException; +use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; /**
true
Other
laravel
framework
b68826962fe28117f0efa9be001eee4d8fe7ad2e.json
Fix code style
src/Illuminate/Contracts/Foundation/ExceptionRenderer.php
@@ -7,8 +7,7 @@ interface ExceptionRenderer /** * Renders the given exception as HTML. * - * @param \Throwable $throwable - * + * @param \Throwable $throwable * @return string */ public function render($throwable);
false
Other
laravel
framework
3baf47598da6cfdefda6625c713e79f0ff2c29a5.json
Apply fixes from StyleCI
src/Illuminate/Database/Eloquent/Relations/HasOne.php
@@ -70,10 +70,10 @@ public function match(array $models, Collection $results, $relation) */ public function getRelationExistenceQuery(Builder $query, Builder $parentQuery, $columns = ['*']) { - if($this->isOneOfMany()) { + if ($this->isOneOfMany()) { $this->mergeJoinsTo($query); } - + return parent::getRelationExistenceQuery($query, $parentQuery, $columns); }
true
Other
laravel
framework
3baf47598da6cfdefda6625c713e79f0ff2c29a5.json
Apply fixes from StyleCI
src/Illuminate/Database/Eloquent/Relations/MorphOne.php
@@ -68,7 +68,7 @@ public function match(array $models, Collection $results, $relation) */ public function getRelationExistenceQuery(Builder $query, Builder $parentQuery, $columns = ['*']) { - if($this->isOneOfMany()) { + if ($this->isOneOfMany()) { $this->mergeJoinsTo($query); }
true
Other
laravel
framework
3baf47598da6cfdefda6625c713e79f0ff2c29a5.json
Apply fixes from StyleCI
tests/Database/DatabaseEloquentMorphOneOfManyTest.php
@@ -133,7 +133,7 @@ public function testWithExistsWithConstraintsInJoinSubSelect() $product->states()->create([ 'state' => 'draft', - 'type' => 'foo' + 'type' => 'foo', ]); $product = MorphOneOfManyTestProduct::withExists('current_foo_state')->first(); $this->assertTrue($product->current_foo_state_exists); @@ -183,7 +183,7 @@ public function current_foo_state() { return $this->morphOne(MorphOneOfManyTestState::class, 'stateful')->ofMany( ['id' => 'max'], - function($q) { + function ($q) { $q->where('type', 'foo'); } );
true
Other
laravel
framework
12b4a9e3fefe28b0afe9f5dd590394b13e1efdce.json
Fix PostgreSQL dump and load for Windows (#37320)
src/Illuminate/Database/Schema/PostgresSchemaState.php
@@ -25,7 +25,7 @@ public function dump(Connection $connection, $path) })->implode(' '); $this->makeProcess( - $this->baseDumpCommand().' --file=$LARAVEL_LOAD_PATH '.$excludedTables + $this->baseDumpCommand().' --file="${:LARAVEL_LOAD_PATH}" '.$excludedTables )->mustRun($this->output, array_merge($this->baseVariables($this->connection->getConfig()), [ 'LARAVEL_LOAD_PATH' => $path, ])); @@ -39,10 +39,10 @@ public function dump(Connection $connection, $path) */ public function load($path) { - $command = 'PGPASSWORD=$LARAVEL_LOAD_PASSWORD pg_restore --no-owner --no-acl --clean --if-exists --host=$LARAVEL_LOAD_HOST --port=$LARAVEL_LOAD_PORT --username=$LARAVEL_LOAD_USER --dbname=$LARAVEL_LOAD_DATABASE $LARAVEL_LOAD_PATH'; + $command = 'pg_restore --no-owner --no-acl --clean --if-exists --host="${:LARAVEL_LOAD_HOST}" --port="${:LARAVEL_LOAD_PORT}" --username="${:LARAVEL_LOAD_USER}" --dbname="${:LARAVEL_LOAD_DATABASE}" "${:LARAVEL_LOAD_PATH}"'; if (Str::endsWith($path, '.sql')) { - $command = 'PGPASSWORD=$LARAVEL_LOAD_PASSWORD psql --file=$LARAVEL_LOAD_PATH --host=$LARAVEL_LOAD_HOST --port=$LARAVEL_LOAD_PORT --username=$LARAVEL_LOAD_USER --dbname=$LARAVEL_LOAD_DATABASE'; + $command = 'psql --file="${:LARAVEL_LOAD_PATH}" --host="${:LARAVEL_LOAD_HOST}" --port="${:LARAVEL_LOAD_PORT}" --username="${:LARAVEL_LOAD_USER}" --dbname="${:LARAVEL_LOAD_DATABASE}"'; } $process = $this->makeProcess($command); @@ -59,7 +59,7 @@ public function load($path) */ protected function baseDumpCommand() { - return 'PGPASSWORD=$LARAVEL_LOAD_PASSWORD pg_dump --no-owner --no-acl -Fc --host=$LARAVEL_LOAD_HOST --port=$LARAVEL_LOAD_PORT --username=$LARAVEL_LOAD_USER $LARAVEL_LOAD_DATABASE'; + return 'pg_dump --no-owner --no-acl -Fc --host="${:LARAVEL_LOAD_HOST}" --port="${:LARAVEL_LOAD_PORT}" --username="${:LARAVEL_LOAD_USER}" --dbname="${:LARAVEL_LOAD_DATABASE}"'; } /** @@ -76,7 +76,7 @@ protected function baseVariables(array $config) 'LARAVEL_LOAD_HOST' => is_array($config['host']) ? $config['host'][0] : $config['host'], 'LARAVEL_LOAD_PORT' => $config['port'], 'LARAVEL_LOAD_USER' => $config['username'], - 'LARAVEL_LOAD_PASSWORD' => $config['password'], + 'PGPASSWORD' => $config['password'], 'LARAVEL_LOAD_DATABASE' => $config['database'], ]; }
false
Other
laravel
framework
0f2db34406f6fb0aab98de10e3d2fce5a8f97fc6.json
remove header setting
src/Illuminate/Routing/Router.php
@@ -795,10 +795,6 @@ public static function toResponse($request, $response) $response->setNotModified(); } - if (! $response->headers->has('Permissions-Policy')) { - $response->headers->set('Permissions-Policy', 'interest-cohort=()'); - } - return $response->prepare($request); }
false
Other
laravel
framework
0740f78a9869f0c96a78781b21ccd4c127ce460f.json
Apply fixes from StyleCI (#37241)
tests/Support/SupportStrTest.php
@@ -20,7 +20,7 @@ public function testStringCanBeLimitedByWordsNonAscii() $this->assertSame('这是...', Str::words('这是 段中文', 1)); $this->assertSame('这是___', Str::words('这是 段中文', 1, '___')); $this->assertSame('这是-段中文', Str::words('这是-段中文', 3, '___')); - $this->assertSame('这是___', Str::words('这是 段中文',1, '___')); + $this->assertSame('这是___', Str::words('这是 段中文', 1, '___')); } public function testStringTrimmedOnlyWhereNecessary()
false
Other
laravel
framework
c42988a551ffdae0e70aa15959969732265789c0.json
set interest cohort
src/Illuminate/Routing/Router.php
@@ -795,6 +795,10 @@ public static function toResponse($request, $response) $response->setNotModified(); } + if (! $response->headers->has('Permissions-Policy')) { + $response->headers->set('Permissions-Policy', 'interest-cohort=()'); + } + return $response->prepare($request); }
false
Other
laravel
framework
227f982f11c8485ce7dda6e75bcb91eea7b9a23d.json
enhance Handle docblocks (#37211)
src/Illuminate/Foundation/Exceptions/Handler.php
@@ -54,28 +54,28 @@ class Handler implements ExceptionHandlerContract /** * A list of the exception types that are not reported. * - * @var array + * @var string[] */ protected $dontReport = []; /** * The callbacks that should be used during reporting. * - * @var array + * @var \Illuminate\Foundation\Exceptions\ReportableHandler[] */ protected $reportCallbacks = []; /** * The callbacks that should be used during rendering. * - * @var array + * @var \Closure[] */ protected $renderCallbacks = []; /** * The registered exception mappings. * - * @var array + * @var array<string, \Closure> */ protected $exceptionMap = [];
false
Other
laravel
framework
f370220e794b3ee6faa447979bf8978e4ebfef10.json
Apply fixes from StyleCI (#37194)
tests/Support/SupportStringableTest.php
@@ -439,7 +439,7 @@ public function testReplace() $this->assertSame('foo/foo/foo', (string) $this->stringable('?/?/?')->replace('?', 'foo')); $this->assertSame('bar/bar', (string) $this->stringable('?/?')->replace('?', 'bar')); $this->assertSame('?/?/?', (string) $this->stringable('? ? ?')->replace(' ', '/')); - $this->assertSame('foo/bar/baz/bam', (string) $this->stringable('?1/?2/?3/?4')->replace(['?1', '?2', '?3', '?4'], ['foo','bar','baz', 'bam'])); + $this->assertSame('foo/bar/baz/bam', (string) $this->stringable('?1/?2/?3/?4')->replace(['?1', '?2', '?3', '?4'], ['foo', 'bar', 'baz', 'bam'])); } public function testReplaceArray()
false
Other
laravel
framework
9edd46fc6dcd550e4fd5d081bea37b0a43162165.json
Apply fixes from StyleCI (#37170)
src/Illuminate/Database/Eloquent/Model.php
@@ -782,7 +782,7 @@ public function update(array $attributes = [], array $options = []) return $this->fill($attributes)->save($options); } - + /** * Update the model in the database without raising any events. *
false
Other
laravel
framework
86fd558b4e5d8d7d45cf457cd1a72d54334297a1.json
Remove redundant check
src/Illuminate/Validation/Concerns/ValidatesAttributes.php
@@ -1516,7 +1516,7 @@ protected function prepareValuesAndOther($parameters) $values = $this->convertValuesToBoolean($values); } - if ($this->shouldConvertToNull($parameters[0]) || is_null($other)) { + if (is_null($other)) { $values = $this->convertValuesToNull($values); } @@ -1534,17 +1534,6 @@ protected function shouldConvertToBoolean($parameter) return in_array('boolean', Arr::get($this->rules, $parameter, [])); } - /** - * Check if parameter should be converted to null. - * - * @param string $parameter - * @return bool - */ - protected function shouldConvertToNull($parameter) - { - return in_array('nullable', Arr::get($this->rules, $parameter, [])); - } - /** * Convert the given values to boolean if they are string "true" / "false". * @@ -1573,11 +1562,7 @@ protected function convertValuesToBoolean($values) protected function convertValuesToNull($values) { return array_map(function ($value) { - if ($value === 'null') { - return null; - } - - return $value; + return Str::lower($value) === 'null' ? null : $value; }, $values); }
false
Other
laravel
framework
be961c33d08d3892c797b6bc883c8c7a1e561a3f.json
fix return type of pool (#37137)
src/Illuminate/Http/Client/Factory.php
@@ -35,7 +35,7 @@ * @method \Illuminate\Http\Client\PendingRequest dump() * @method \Illuminate\Http\Client\PendingRequest dd() * @method \Illuminate\Http\Client\PendingRequest async() - * @method \Illuminate\Http\Client\Pool pool(callable $callback) + * @method array pool(callable $callback) * @method \Illuminate\Http\Client\Response delete(string $url, array $data = []) * @method \Illuminate\Http\Client\Response get(string $url, array $query = []) * @method \Illuminate\Http\Client\Response head(string $url, array $query = [])
true
Other
laravel
framework
be961c33d08d3892c797b6bc883c8c7a1e561a3f.json
fix return type of pool (#37137)
src/Illuminate/Support/Facades/Http.php
@@ -33,7 +33,7 @@ * @method static \Illuminate\Http\Client\PendingRequest dump() * @method static \Illuminate\Http\Client\PendingRequest dd() * @method static \Illuminate\Http\Client\PendingRequest async() - * @method static \Illuminate\Http\Client\Pool pool(callable $callback) + * @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 $query = []) * @method static \Illuminate\Http\Client\Response head(string $url, array $query = [])
true
Other
laravel
framework
7ad5e59a7130143db98d6302a9427fd7dc033062.json
remove invalid test (#37112)
tests/View/ViewBladeCompilerTest.php
@@ -177,16 +177,6 @@ public function testDontIncludeEmptyPath() $compiler->compile(); } - public function testDontIncludeNullPath() - { - $compiler = new BladeCompiler($files = $this->getFiles(), __DIR__); - $files->shouldReceive('get')->once()->with(null)->andReturn('Hello World'); - $files->shouldReceive('exists')->once()->with(__DIR__)->andReturn(true); - $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1(null).'.php', 'Hello World'); - $compiler->setPath(null); - $compiler->compile(); - } - public function testShouldStartFromStrictTypesDeclaration() { $compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
false
Other
laravel
framework
724cd761e662971d6d36799934b3ac7c57cefb7d.json
Adjust JsonResource $wrap DocBlock (#37115)
src/Illuminate/Http/Resources/Json/JsonResource.php
@@ -42,7 +42,7 @@ class JsonResource implements ArrayAccess, JsonSerializable, Responsable, UrlRou /** * The "data" wrapper that should be applied. * - * @var string + * @var string|null */ public static $wrap = 'data';
false
Other
laravel
framework
597f5ab16d0d2df67e50fedfd2fa66789b29998c.json
remove invalid docblock (#37077)
src/Illuminate/Database/Eloquent/SoftDeletes.php
@@ -6,7 +6,6 @@ * @method static static|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder withTrashed(bool $withTrashed = true) * @method static static|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder onlyTrashed() * @method static static|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder withoutTrashed() - * @method static static|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder restore() */ trait SoftDeletes {
false
Other
laravel
framework
c35631b524a05d87702c1363bfbf5344550389c0.json
Add tests for `queueForget()` method
tests/Cookie/CookieTest.php
@@ -118,6 +118,22 @@ public function testHasQueuedWithPath(): void $this->assertFalse($cookieJar->hasQueued('foo', '/wrongPath')); } + public function testQueueForget() + { + $cookieJar = $this->getCreator(); + $this->assertCount(0, $cookieJar->getQueuedCookies()); + + $cookieJar->queueForget('foobar', '/path', '/domain'); + + $cookie = $cookieJar->queued('foobar'); + $this->assertEquals('foobar', $cookie->getName()); + $this->assertEquals(null, $cookie->getValue()); + $this->assertEquals('/path', $cookie->getPath()); + $this->assertEquals('/domain', $cookie->getDomain()); + $this->assertTrue($cookie->getExpiresTime() < time()); + $this->assertCount(1, $cookieJar->getQueuedCookies()); + } + public function testUnqueue() { $cookie = $this->getCreator();
false