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 | 6b190c3d0862f9de9432edf28e939cb5e3f8637d.json | Use implode instead of alias (#22654) | src/Illuminate/Database/Query/Grammars/Grammar.php | @@ -484,7 +484,7 @@ protected function whereRowValues(Builder $query, $where)
{
$values = $this->parameterize($where['values']);
- return '('.join(', ', $where['columns']).') '.$where['operator'].' ('.$values.')';
+ return '('.implode(', ', $where['columns']).') '.$where['operator'].' ('.$values.')';
}
/** | false |
Other | laravel | framework | 61f8477fab55a258f39a3d598f67f7cc0ffd6aca.json | add option for double encode | src/Illuminate/Support/helpers.php | @@ -568,15 +568,16 @@ function dd(...$args)
* Escape HTML special characters in a string.
*
* @param \Illuminate\Contracts\Support\Htmlable|string $value
+ * @param bool $doubleEncode
* @return string
*/
- function e($value)
+ function e($value, $doubleEncode = false)
{
if ($value instanceof Htmlable) {
return $value->toHtml();
}
- return htmlspecialchars($value, ENT_QUOTES, 'UTF-8', false);
+ return htmlspecialchars($value, ENT_QUOTES, 'UTF-8', $doubleEncode);
}
}
| false |
Other | laravel | framework | 74a8738162b4a41a5647d423273720aac1abb0f0.json | Fix typo Query/Builder::where (#22643) | src/Illuminate/Database/Query/Builder.php | @@ -480,7 +480,7 @@ public function mergeWheres($wheres, $bindings)
* Add a basic where clause to the query.
*
* @param string|array|\Closure $column
- * @param string|null $operator
+ * @param mixed $operator
* @param mixed $value
* @param string $boolean
* @return $this | false |
Other | laravel | framework | b373f74ed21bcb04cd86bd71a017e8293fb43ab8.json | Apply fixes from StyleCI (#22651) | src/Illuminate/Auth/RequestGuard.php | @@ -81,7 +81,7 @@ public function validate(array $credentials = [])
public function setRequest(Request $request)
{
$this->user = null;
-
+
$this->request = $request;
return $this; | false |
Other | laravel | framework | 7553c0ba7aeb092f7cf519462a2a32a45a33e682.json | Update Mailer.php (#22639)
Update docblock, fixes #22633 | src/Illuminate/Mail/Mailer.php | @@ -177,7 +177,7 @@ public function plain($view, array $data, $callback)
*
* @param string|array $view
* @param array $data
- * @return \Illuminate\View\View
+ * @return string
*/
public function render($view, array $data = [])
{ | false |
Other | laravel | framework | c22ac4bcb9ed425d599827e89ba274c4ae58f6c9.json | Apply fixes from StyleCI (#22631) | tests/Support/SupportCollectionTest.php | @@ -1614,7 +1614,7 @@ public function testGroupByMultiLevelAndClosurePreservingKeys()
'skilllevel',
function ($item) {
return $item['roles'];
- }
+ },
], true);
$expected_result = [ | false |
Other | laravel | framework | a145ab29a0b06fe4f7924d9e101db0d34d07cd51.json | Implement MorphOne and MorphMany | src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php | @@ -97,7 +97,22 @@ public function morphOne($related, $name, $type = null, $id = null, $localKey =
$localKey = $localKey ?: $this->getKeyName();
- return new MorphOne($instance->newQuery(), $this, $table.'.'.$type, $table.'.'.$id, $localKey);
+ return $this->newMorphOne($instance->newQuery(), $this, $table.'.'.$type, $table.'.'.$id, $localKey);
+ }
+
+ /**
+ * Instantiate a new MorphOne relationship.
+ *
+ * @param \Illuminate\Database\Eloquent\Builder $query
+ * @param \Illuminate\Database\Eloquent\Model $parent
+ * @param string $type
+ * @param string $id
+ * @param string $localKey
+ * @return \Illuminate\Database\Eloquent\Relations\MorphOne
+ */
+ protected function newMorphOne(Builder $query, Model $parent, $type, $id, $localKey)
+ {
+ return new MorphOne($query, $parent, $type, $id, $localKey);
}
/**
@@ -325,7 +340,22 @@ public function morphMany($related, $name, $type = null, $id = null, $localKey =
$localKey = $localKey ?: $this->getKeyName();
- return new MorphMany($instance->newQuery(), $this, $table.'.'.$type, $table.'.'.$id, $localKey);
+ return $this->newMorphMany($instance->newQuery(), $this, $table.'.'.$type, $table.'.'.$id, $localKey);
+ }
+
+ /**
+ * Instantiate a new MorphMany relationship.
+ *
+ * @param \Illuminate\Database\Eloquent\Builder $query
+ * @param \Illuminate\Database\Eloquent\Model $parent
+ * @param string $type
+ * @param string $id
+ * @param string $localKey
+ * @return \Illuminate\Database\Eloquent\Relations\MorphMany
+ */
+ protected function newMorphMany(Builder $query, Model $parent, $type, $id, $localKey)
+ {
+ return new MorphMany($query, $parent, $type, $id, $localKey);
}
/** | true |
Other | laravel | framework | a145ab29a0b06fe4f7924d9e101db0d34d07cd51.json | Implement MorphOne and MorphMany | tests/Integration/Database/EloquentRelationshipsTest.php | @@ -7,6 +7,8 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\HasMany;
+use Illuminate\Database\Eloquent\Relations\MorphOne;
+use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
@@ -25,6 +27,8 @@ public function standard_relationships()
$this->assertInstanceOf(HasOne::class, $post->attachment());
$this->assertInstanceOf(BelongsTo::class, $post->author());
$this->assertInstanceOf(HasMany::class, $post->comments());
+ $this->assertInstanceOf(MorphOne::class, $post->owner());
+ $this->assertInstanceOf(MorphMany::class, $post->replies());
}
/**
@@ -38,6 +42,8 @@ public function overridden_relationships()
$this->assertInstanceOf(CustomHasOne::class, $post->attachment());
$this->assertInstanceOf(CustomBelongsTo::class, $post->author());
$this->assertInstanceOf(CustomHasMany::class, $post->comments());
+ $this->assertInstanceOf(CustomMorphOne::class, $post->owner());
+ $this->assertInstanceOf(CustomMorphMany::class, $post->replies());
}
}
@@ -61,6 +67,16 @@ public function comments()
{
return $this->hasMany(FakeRelationship::class);
}
+
+ public function replies()
+ {
+ return $this->morphMany(FakeRelationship::class, 'actionable');
+ }
+
+ public function owner()
+ {
+ return $this->morphOne(FakeRelationship::class, 'property');
+ }
}
class CustomPost extends Post
@@ -79,6 +95,16 @@ protected function newHasOne(Builder $query, Model $parent, $foreignKey, $localK
{
return new CustomHasOne($query, $parent, $foreignKey, $localKey);
}
+
+ protected function newMorphOne(Builder $query, Model $parent, $type, $id, $localKey)
+ {
+ return new CustomMorphOne($query, $parent, $type, $id, $localKey);
+ }
+
+ protected function newMorphMany(Builder $query, Model $parent, $type, $id, $localKey)
+ {
+ return new CustomMorphMany($query, $parent, $type, $id, $localKey);
+ }
}
class CustomHasOne extends HasOne
@@ -92,3 +118,11 @@ class CustomBelongsTo extends BelongsTo
class CustomHasMany extends HasMany
{
}
+
+class CustomMorphOne extends MorphOne
+{
+}
+
+class CustomMorphMany extends MorphMany
+{
+} | true |
Other | laravel | framework | 2093e7e8e440f90499ececbad759b701cb864853.json | add null to docs | src/Illuminate/Notifications/Messages/SlackAttachment.php | @@ -117,7 +117,7 @@ class SlackAttachment
* Set the title of the attachment.
*
* @param string $title
- * @param string $url
+ * @param string|null $url
* @return $this
*/
public function title($title, $url = null)
@@ -286,8 +286,8 @@ public function timestamp($timestamp)
* Set the author.
*
* @param string $name
- * @param string $link
- * @param string $icon
+ * @param string|null $link
+ * @param string|null $icon
* @return $this
*/
public function author($name, $link = null, $icon = null) | false |
Other | laravel | framework | 68d3a1b60f74d754f375c14c71652fd6db4e9f58.json | Keep packages alphabetically sorted (#22595) | composer.json | @@ -19,10 +19,10 @@
"ext-mbstring": "*",
"ext-openssl": "*",
"doctrine/inflector": "~1.1",
+ "dragonmantank/cron-expression": "~2.0",
"erusev/parsedown": "~1.6",
"league/flysystem": "~1.0",
"monolog/monolog": "~1.12",
- "dragonmantank/cron-expression": "~2.0",
"nesbot/carbon": "~1.20",
"psr/container": "~1.0",
"psr/simple-cache": "^1.0", | false |
Other | laravel | framework | 02d3a0d583eef4bcec3b1150bb072b722a6c689a.json | Remove unused use statements | src/Illuminate/Foundation/Console/ChannelMakeCommand.php | @@ -3,7 +3,6 @@
namespace Illuminate\Foundation\Console;
use Illuminate\Console\GeneratorCommand;
-use Symfony\Component\Console\Input\InputOption;
class ChannelMakeCommand extends GeneratorCommand
{ | false |
Other | laravel | framework | f8ef32f031ea642582f9c33297a4563be29d36e8.json | Fix version of doctrine/dbal for PHP 7.1 (#22563) | composer.json | @@ -72,7 +72,7 @@
},
"require-dev": {
"aws/aws-sdk-php": "~3.0",
- "doctrine/dbal": "~2.5",
+ "doctrine/dbal": "~2.6",
"filp/whoops": "^2.1.4",
"mockery/mockery": "~1.0",
"orchestra/testbench-core": "3.6.*",
@@ -108,7 +108,7 @@
"ext-pcntl": "Required to use all features of the queue worker.",
"ext-posix": "Required to use all features of the queue worker.",
"aws/aws-sdk-php": "Required to use the SQS queue driver and SES mail driver (~3.0).",
- "doctrine/dbal": "Required to rename columns and drop SQLite columns (~2.5).",
+ "doctrine/dbal": "Required to rename columns and drop SQLite columns (~2.6).",
"fzaninotto/faker": "Required to use the eloquent factory builder (~1.4).",
"guzzlehttp/guzzle": "Required to use the Mailgun and Mandrill mail drivers and the ping methods on schedules (~6.0).",
"laravel/tinker": "Required to use the tinker console command (~1.0).", | true |
Other | laravel | framework | f8ef32f031ea642582f9c33297a4563be29d36e8.json | Fix version of doctrine/dbal for PHP 7.1 (#22563) | src/Illuminate/Database/composer.json | @@ -31,7 +31,7 @@
}
},
"suggest": {
- "doctrine/dbal": "Required to rename columns and drop SQLite columns (~2.5).",
+ "doctrine/dbal": "Required to rename columns and drop SQLite columns (~2.6).",
"fzaninotto/faker": "Required to use the eloquent factory builder (~1.4).",
"illuminate/console": "Required to use the database commands (5.6.*).",
"illuminate/events": "Required to use the observers with Eloquent (5.6.*).", | true |
Other | laravel | framework | 65b304e52f92759c3e8233767e2755c7b763fd99.json | Apply fixes from StyleCI (#22557) | tests/Filesystem/FilesystemTest.php | @@ -2,11 +2,11 @@
namespace Illuminate\Tests\Filesystem;
-use Illuminate\Filesystem\FilesystemManager;
-use Illuminate\Foundation\Application;
-use League\Flysystem\Adapter\Ftp;
use PHPUnit\Framework\TestCase;
+use League\Flysystem\Adapter\Ftp;
use Illuminate\Filesystem\Filesystem;
+use Illuminate\Foundation\Application;
+use Illuminate\Filesystem\FilesystemManager;
class FilesystemTest extends TestCase
{
@@ -453,7 +453,7 @@ public function testCreateFtpDriver()
'host' => 'ftp.example.com',
'username' => 'admin',
'permPublic' => 0700,
- 'unsopertedParam' => true
+ 'unsopertedParam' => true,
]);
/** @var Ftp $adapter */ | false |
Other | laravel | framework | 6535186b0f71a6b0cc2d8a821f3de209c05bcf4f.json | allow customization of mail message building | src/Illuminate/Auth/Notifications/ResetPassword.php | @@ -14,6 +14,13 @@ class ResetPassword extends Notification
*/
public $token;
+ /**
+ * The callback that should be used to build the mail message.
+ *
+ * @var \Closure|null
+ */
+ public static $toMailCallback;
+
/**
* Create a notification instance.
*
@@ -44,9 +51,24 @@ public function via($notifiable)
*/
public function toMail($notifiable)
{
+ if (static::$toMailCallback) {
+ return call_user_func(static::$toMailCallback, $notifiable, $this->token);
+ }
+
return (new MailMessage)
->line('You are receiving this email because we received a password reset request for your account.')
->action('Reset Password', url(config('app.url').route('password.reset', $this->token, false)))
->line('If you did not request a password reset, no further action is required.');
}
+
+ /**
+ * Set a callback that should be used when building the notification mail message.
+ *
+ * @param \Closure $callback
+ * @return void
+ */
+ public static function toMailUsing($callback)
+ {
+ static::$toMailCallback = $callback;
+ }
} | false |
Other | laravel | framework | a926eede7a37b04123c103c398664a6f0389d0e0.json | Ignore VSCode IDE Local Workspace Folder (#22550)
VSCode creates a hidden folder called ".vscode" when storing workspace settings for instance which we do not necessarily want to be added to our source control. | .gitignore | @@ -5,3 +5,4 @@ composer.lock
Thumbs.db
/phpunit.xml
/.idea
+/.vscode | false |
Other | laravel | framework | a55c4bf892d4cdcd0213218fe77076c4a1b6969c.json | add assertDispatchedTimes for event fakes (#22528) | src/Illuminate/Support/Testing/Fakes/EventFake.php | @@ -47,17 +47,36 @@ public function __construct(Dispatcher $dispatcher, $eventsToFake = [])
* Assert if an event was dispatched based on a truth-test callback.
*
* @param string $event
- * @param callable|null $callback
+ * @param callable|int|null $callback
* @return void
*/
public function assertDispatched($event, $callback = null)
{
+ if (is_int($callback)) {
+ return $this->assertDispatchedTimes($event, $callback);
+ }
+
PHPUnit::assertTrue(
$this->dispatched($event, $callback)->count() > 0,
"The expected [{$event}] event was not dispatched."
);
}
+ /**
+ * Assert if a event was dispatched a number of times.
+ *
+ * @param string $event
+ * @param int $times
+ * @return void
+ */
+ public function assertDispatchedTimes($event, $times = 1)
+ {
+ PHPUnit::assertTrue(
+ ($count = $this->dispatched($event)->count()) === $times,
+ "The expected [{$event}] event was dispatched {$count} times instead of {$times} times."
+ );
+ }
+
/**
* Determine if an event was dispatched based on a truth-test callback.
* | true |
Other | laravel | framework | a55c4bf892d4cdcd0213218fe77076c4a1b6969c.json | add assertDispatchedTimes for event fakes (#22528) | tests/Support/SupportTestingEventFakeTest.php | @@ -0,0 +1,65 @@
+<?php
+
+namespace Illuminate\Tests\Support;
+
+use Mockery as m;
+use PHPUnit\Framework\TestCase;
+use Illuminate\Contracts\Events\Dispatcher;
+use Illuminate\Support\Testing\Fakes\EventFake;
+
+class SupportTestingEventFakeTest extends TestCase
+{
+ protected function setUp()
+ {
+ parent::setUp();
+ $this->fake = new EventFake(m::mock(Dispatcher::class));
+ }
+
+ public function testAssertDispacthed()
+ {
+ $this->fake->dispatch(EventStub::class);
+
+ $this->fake->assertDispatched(EventStub::class);
+ }
+
+ /**
+ * @expectedException PHPUnit\Framework\ExpectationFailedException
+ * @expectedExceptionMessage The expected [Illuminate\Tests\Support\EventStub] event was dispatched 2 times instead of 1 times.
+ */
+ public function testAssertDispatchedWithCallbackInt()
+ {
+ $this->fake->dispatch(EventStub::class);
+ $this->fake->dispatch(EventStub::class);
+
+ $this->fake->assertDispatched(EventStub::class, 2);
+ $this->fake->assertDispatched(EventStub::class, 1);
+ }
+
+ /**
+ * @expectedException PHPUnit\Framework\ExpectationFailedException
+ * @expectedExceptionMessage The expected [Illuminate\Tests\Support\EventStub] event was dispatched 2 times instead of 1 times.
+ */
+ public function testAssertDispatchedTimes()
+ {
+ $this->fake->dispatch(EventStub::class);
+ $this->fake->dispatch(EventStub::class);
+
+ $this->fake->assertDispatchedTimes(EventStub::class, 2);
+ $this->fake->assertDispatchedTimes(EventStub::class, 1);
+ }
+
+ /**
+ * @expectedException PHPUnit\Framework\ExpectationFailedException
+ * @expectedExceptionMessage The unexpected [Illuminate\Tests\Support\EventStub] event was dispatched.
+ */
+ public function testAssertNotDispatched()
+ {
+ $this->fake->dispatch(EventStub::class);
+
+ $this->fake->assertNotDispatched(EventStub::class);
+ }
+}
+
+class EventStub
+{
+} | true |
Other | laravel | framework | 90ef1d31b22a042233adb6bfbc1e7f162bb96b73.json | Add test for size inline messages | tests/Validation/ValidationValidatorTest.php | @@ -562,6 +562,12 @@ public function testInlineValidationMessagesAreRespected()
$this->assertFalse($v->passes());
$v->messages()->setFormat(':message');
$this->assertEquals('require it please!', $v->messages()->first('name'));
+
+ $trans = $this->getIlluminateArrayTranslator();
+ $v = new Validator($trans, ['name' => 'foobarba'], ['name' => 'size:9'], ['size' => ['string' => ':attribute should be of length :size']]);
+ $this->assertFalse($v->passes());
+ $v->messages()->setFormat(':message');
+ $this->assertEquals('name should be of length 9', $v->messages()->first('name'));
}
public function testInlineValidationMessagesAreRespectedWithAsterisks() | false |
Other | laravel | framework | ae2f7043a95f18fa520c886730670f28667f08ea.json | Fix prepareResponse()'s return type (#22517)
As it is converted to `\Illuminate\Http\Response` | src/Illuminate/Foundation/Exceptions/Handler.php | @@ -277,7 +277,7 @@ protected function invalidJson($request, ValidationException $exception)
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
- * @return \Symfony\Component\HttpFoundation\Response
+ * @return \Illuminate\Http\Response
*/
protected function prepareResponse($request, Exception $e)
{ | false |
Other | laravel | framework | 334d5a618e7b76ef5c5d90151a05af22e0e32057.json | Apply fixes from StyleCI (#22481) | src/Illuminate/Http/Request.php | @@ -292,7 +292,7 @@ public function userAgent()
public function merge(array $input)
{
$this->getInputSource()->add($input);
-
+
return $this;
}
@@ -305,7 +305,7 @@ public function merge(array $input)
public function replace(array $input)
{
$this->getInputSource()->replace($input);
-
+
return $this;
}
| false |
Other | laravel | framework | c1cdcab67f356c7729d2d1b89747f2ba50fce9e5.json | Apply fixes from StyleCI (#22452) | src/Illuminate/Database/Query/Grammars/SQLiteGrammar.php | @@ -187,7 +187,7 @@ public function compileUpdate(Builder $query, $values)
{
$table = $this->wrapTable($query->from);
- $columns = collect($values)->map(function ($value, $key) use($query) {
+ $columns = collect($values)->map(function ($value, $key) use ($query) {
return $this->wrap(Str::after($key, $query->from.'.')).' = '.$this->parameter($value);
})->implode(', ');
| true |
Other | laravel | framework | c1cdcab67f356c7729d2d1b89747f2ba50fce9e5.json | Apply fixes from StyleCI (#22452) | tests/Integration/Database/EloquentUpdateTest.php | @@ -34,7 +34,7 @@ public function setUp()
$table->string('name')->nullable();
$table->string('title')->nullable();
});
-
+
Schema::create('test_model2', function ($table) {
$table->increments('id');
$table->string('name');
@@ -47,7 +47,7 @@ public function setUp()
public function testBasicUpdate()
{
TestUpdateModel1::create([
- 'name' => str_random(),
+ 'name' => str_random(),
'title' => 'Ms.',
]);
@@ -58,7 +58,7 @@ public function testBasicUpdate()
public function testUpdateWithLimitsAndOrders()
{
- for($i=1; $i <= 10; $i++){
+ for ($i = 1; $i <= 10; $i++) {
TestUpdateModel1::create();
}
@@ -71,19 +71,19 @@ public function testUpdateWithLimitsAndOrders()
public function testUpdatedAtWithJoins()
{
TestUpdateModel1::create([
- 'name' => 'Abdul',
+ 'name' => 'Abdul',
'title' => 'Mr.',
]);
TestUpdateModel2::create([
- 'name' => str_random()
+ 'name' => str_random(),
]);
- TestUpdateModel2::join('test_model1', function($join) {
+ TestUpdateModel2::join('test_model1', function ($join) {
$join->on('test_model1.id', '=', 'test_model2.id')
->where('test_model1.title', '=', 'Mr.');
})->update(['test_model2.name' => 'Abdul', 'job'=>'Engineer']);
-
+
$record = TestUpdateModel2::find(1);
$this->assertEquals('Engineer: Abdul', $record->job.': '.$record->name);
@@ -92,16 +92,15 @@ public function testUpdatedAtWithJoins()
public function testSoftDeleteWithJoins()
{
TestUpdateModel1::create([
- 'name' => str_random(),
+ 'name' => str_random(),
'title' => 'Mr.',
]);
TestUpdateModel2::create([
- 'name' => str_random()
+ 'name' => str_random(),
]);
-
- TestUpdateModel2::join('test_model1', function($join) {
+ TestUpdateModel2::join('test_model1', function ($join) {
$join->on('test_model1.id', '=', 'test_model2.id')
->where('test_model1.title', '=', 'Mr.');
})->delete();
@@ -110,7 +109,6 @@ public function testSoftDeleteWithJoins()
}
}
-
class TestUpdateModel1 extends Model
{
public $table = 'test_model1'; | true |
Other | laravel | framework | 2564437750326edfe5b55da57ae295a770f4c9e5.json | Add array support to Optional (#22417) | src/Illuminate/Support/Optional.php | @@ -2,7 +2,9 @@
namespace Illuminate\Support;
-class Optional
+use ArrayAccess;
+
+class Optional implements ArrayAccess
{
use Traits\Macroable {
__call as macroCall;
@@ -56,4 +58,53 @@ public function __call($method, $parameters)
return $this->value->{$method}(...$parameters);
}
}
+
+ /**
+ * Determine if an item exists at an offset.
+ *
+ * @param mixed $key
+ * @return bool
+ */
+ public function offsetExists($key)
+ {
+ return Arr::accessible($this->value) && Arr::exists($this->value, $key);
+ }
+
+ /**
+ * Get an item at a given offset.
+ *
+ * @param mixed $key
+ * @return mixed
+ */
+ public function offsetGet($key)
+ {
+ return Arr::get($this->value, $key);
+ }
+
+ /**
+ * Set the item at a given offset.
+ *
+ * @param mixed $key
+ * @param mixed $value
+ * @return void
+ */
+ public function offsetSet($key, $value)
+ {
+ if (Arr::accessible($this->value)) {
+ $this->value[$key] = $value;
+ }
+ }
+
+ /**
+ * Unset the item at a given offset.
+ *
+ * @param string $key
+ * @return void
+ */
+ public function offsetUnset($key)
+ {
+ if (Arr::accessible($this->value)) {
+ unset($this->value[$key]);
+ }
+ }
} | true |
Other | laravel | framework | 2564437750326edfe5b55da57ae295a770f4c9e5.json | Add array support to Optional (#22417) | tests/Support/SupportHelpersTest.php | @@ -774,6 +774,13 @@ public function something()
})->something());
}
+ public function testOptionalWithArray()
+ {
+ $this->assertNull(optional(null)['missing']);
+
+ $this->assertEquals('here', optional(['present' => 'here'])['present']);
+ }
+
public function testOptionalIsMacroable()
{
Optional::macro('present', function () { | true |
Other | laravel | framework | 541228883e0c8090acc16ecb47cc8b38c2be75b3.json | Add cattle to $uncountable (#22415)
* Add cattle and tarmac to $uncountable
* Remove tarmac | src/Illuminate/Support/Pluralizer.php | @@ -14,6 +14,7 @@ class Pluralizer
public static $uncountable = [
'audio',
'bison',
+ 'cattle',
'chassis',
'compensation',
'coreopsis', | false |
Other | laravel | framework | f083c6f1f9bab013b57710e50bf3ae4094cd21ec.json | Fix database events phpdoc (#22420) | src/Illuminate/Database/Events/QueryExecuted.php | @@ -44,8 +44,8 @@ class QueryExecuted
*
* @param string $sql
* @param array $bindings
- * @param float $time
- * @param string $connection
+ * @param float|null $time
+ * @param \Illuminate\Database\Connection $connection
* @return void
*/
public function __construct($sql, $bindings, $time, $connection) | false |
Other | laravel | framework | b6a17a13790dd357061ab569b95a1dea9f4c4d06.json | Apply fixes from StyleCI (#22410) | src/Illuminate/Support/Collection.php | @@ -390,7 +390,7 @@ public function every($key, $operator = null, $value = null)
*/
public function except($keys)
{
- if ($keys instanceof Collection) {
+ if ($keys instanceof self) {
$keys = $keys->keys()->all();
} elseif (! is_array($keys)) {
$keys = func_get_args(); | false |
Other | laravel | framework | 5defbd745dc41577e408d9714b137b056c3bd807.json | Add an HTTP cache middleware | src/Illuminate/Http/Middleware/Cache.php | @@ -0,0 +1,49 @@
+<?php
+
+namespace Illuminate\Http\Middleware;
+
+use Closure;
+
+class Cache
+{
+ /**
+ * Add cache related HTTP headers.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param \Closure $next
+ * @param int|null $maxAge
+ * @param int|null $sharedMaxAge
+ * @param bool|null $public
+ * @param bool|null $etag
+ * @return \Symfony\Component\HttpFoundation\Response
+ */
+ public function handle($request, Closure $next, int $maxAge = null, int $sharedMaxAge = null, bool $public = null, bool $etag = false)
+ {
+ /**
+ * @var \Symfony\Component\HttpFoundation\Response
+ */
+ $response = $next($request);
+
+ if (! $request->isMethodCacheable() || ! $response->getContent()) {
+ return $response;
+ }
+
+ if (! $response->getContent()) {
+ return;
+ }
+ if ($etag) {
+ $response->setEtag(md5($response->getContent()));
+ }
+ if (null !== $maxAge) {
+ $response->setMaxAge($maxAge);
+ }
+ if (null !== $sharedMaxAge) {
+ $response->setSharedMaxAge($sharedMaxAge);
+ }
+ if (null !== $public) {
+ $public ? $response->setPublic() : $response->setPrivate();
+ }
+
+ return $response;
+ }
+} | true |
Other | laravel | framework | 5defbd745dc41577e408d9714b137b056c3bd807.json | Add an HTTP cache middleware | tests/Http/Middleware/CacheTest.php | @@ -0,0 +1,44 @@
+<?php
+
+namespace Illuminate\Tests\Http\Middleware;
+
+use Illuminate\Http\Request;
+use Illuminate\Http\Response;
+use PHPUnit\Framework\TestCase;
+use Illuminate\Http\Middleware\Cache;
+
+class CacheTest extends TestCase
+{
+ public function testDoNotSetHeaderWhenMethodNotCacheable()
+ {
+ $request = new Request();
+ $request->setMethod('PUT');
+
+ $response = (new Cache())->handle($request, function () {
+ return new Response('Hello Laravel');
+ }, 1, 2, true, true);
+
+ $this->assertNull($response->getMaxAge());
+ $this->assertNull($response->getEtag());
+ }
+
+ public function testDoNotSetHeaderWhenNoContent()
+ {
+ $response = (new Cache())->handle(new Request(), function () {
+ return new Response();
+ }, 1, 2, true, true);
+
+ $this->assertNull($response->getMaxAge());
+ $this->assertNull($response->getEtag());
+ }
+
+ public function testAddHeaders()
+ {
+ $response = (new Cache())->handle(new Request(), function () {
+ return new Response('some content');
+ }, 100, 200, true, true);
+
+ $this->assertSame('"9893532233caff98cd083a116b013c0b"', $response->getEtag());
+ $this->assertSame('max-age=100, public, s-maxage=200', $response->headers->get('Cache-Control'));
+ }
+} | true |
Other | laravel | framework | 54e6048e3ca49715252505ffe2b3668689b5f8bf.json | Use Null Coalesce Operator (#22383) | src/Illuminate/Auth/AuthManager.php | @@ -65,9 +65,7 @@ public function guard($name = null)
{
$name = $name ?: $this->getDefaultDriver();
- return isset($this->guards[$name])
- ? $this->guards[$name]
- : $this->guards[$name] = $this->resolve($name);
+ return $this->guards[$name] ?? $this->guards[$name] = $this->resolve($name);
}
/** | false |
Other | laravel | framework | 26e10c7e57ad309c9e8d7a5766a0c0160890d9bc.json | Apply StyleCI recommendations | src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php | @@ -506,7 +506,6 @@ protected function typeYear(Fluent $column)
return $this->typeInteger($column);
}
-
/**
* Create the column definition for a date-time type.
* | false |
Other | laravel | framework | 2d1328b5eae791ea5771fabe077666321b3cdb70.json | Add Support for 'year' datatype for Schema | src/Illuminate/Database/Schema/Blueprint.php | @@ -783,6 +783,17 @@ public function dateTime($column, $precision = 0)
return $this->addColumn('dateTime', $column, compact('precision'));
}
+ /**
+ * Create a new year column on the table.
+ *
+ * @param string $column
+ * @return \Illuminate\Support\Fluent
+ */
+ public function year($column)
+ {
+ return $this->addColumn('year', $column);
+ }
+
/**
* Create a new date-time column (with time zone) on the table.
* | true |
Other | laravel | framework | 2d1328b5eae791ea5771fabe077666321b3cdb70.json | Add Support for 'year' datatype for Schema | src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php | @@ -585,6 +585,17 @@ protected function typeDate(Fluent $column)
return 'date';
}
+ /**
+ * Create the column definition for a year type.
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ protected function typeYear(Fluent $column)
+ {
+ return 'year';
+ }
+
/**
* Create the column definition for a date-time type.
* | true |
Other | laravel | framework | 2d1328b5eae791ea5771fabe077666321b3cdb70.json | Add Support for 'year' datatype for Schema | src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php | @@ -536,6 +536,17 @@ protected function typeDate(Fluent $column)
return 'date';
}
+ /**
+ * Create the column definition for a year type (Polyfill).
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ protected function typeYear(Fluent $column)
+ {
+ return $this->typeInteger($column);
+ }
+
/**
* Create the column definition for a date-time type.
* | true |
Other | laravel | framework | 2d1328b5eae791ea5771fabe077666321b3cdb70.json | Add Support for 'year' datatype for Schema | src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php | @@ -545,6 +545,17 @@ protected function typeDate(Fluent $column)
return 'date';
}
+ /**
+ * Create the column definition for a year type (Polyfill).
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ protected function typeYear(Fluent $column)
+ {
+ return $this->typeInteger($column);
+ }
+
/**
* Create the column definition for a date-time type.
* | true |
Other | laravel | framework | 2d1328b5eae791ea5771fabe077666321b3cdb70.json | Add Support for 'year' datatype for Schema | src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php | @@ -495,6 +495,18 @@ protected function typeDate(Fluent $column)
return 'date';
}
+ /**
+ * Create the column definition for a year type (Polyfill).
+ *
+ * @param \Illuminate\Support\Fluent $column
+ * @return string
+ */
+ protected function typeYear(Fluent $column)
+ {
+ return $this->typeInteger($column);
+ }
+
+
/**
* Create the column definition for a date-time type.
* | true |
Other | laravel | framework | 2d1328b5eae791ea5771fabe077666321b3cdb70.json | Add Support for 'year' datatype for Schema | tests/Database/DatabaseMySqlSchemaGrammarTest.php | @@ -626,6 +626,15 @@ public function testAddingDate()
$this->assertEquals('alter table `users` add `foo` date not null', $statements[0]);
}
+ public function testAddingYear()
+ {
+ $blueprint = new Blueprint('users');
+ $blueprint->year('birth_year');
+ $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
+ $this->assertCount(1, $statements);
+ $this->assertEquals('alter table `users` add `birth_year` year not null', $statements[0]);
+ }
+
public function testAddingDateTime()
{
$blueprint = new Blueprint('users'); | true |
Other | laravel | framework | 2d1328b5eae791ea5771fabe077666321b3cdb70.json | Add Support for 'year' datatype for Schema | tests/Database/DatabasePostgresSchemaGrammarTest.php | @@ -449,6 +449,15 @@ public function testAddingDate()
$this->assertEquals('alter table "users" add column "foo" date not null', $statements[0]);
}
+ public function testAddingYear()
+ {
+ $blueprint = new Blueprint('users');
+ $blueprint->year('birth_year');
+ $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
+ $this->assertCount(1, $statements);
+ $this->assertEquals('alter table "users" add column "birth_year" integer not null', $statements[0]);
+ }
+
public function testAddingJson()
{
$blueprint = new Blueprint('users'); | true |
Other | laravel | framework | 2d1328b5eae791ea5771fabe077666321b3cdb70.json | Add Support for 'year' datatype for Schema | tests/Database/DatabaseSQLiteSchemaGrammarTest.php | @@ -416,6 +416,15 @@ public function testAddingDate()
$this->assertEquals('alter table "users" add column "foo" date not null', $statements[0]);
}
+ public function testAddingYear()
+ {
+ $blueprint = new Blueprint('users');
+ $blueprint->year('birth_year');
+ $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
+ $this->assertCount(1, $statements);
+ $this->assertEquals('alter table "users" add column "birth_year" integer not null', $statements[0]);
+ }
+
public function testAddingDateTime()
{
$blueprint = new Blueprint('users'); | true |
Other | laravel | framework | 2d1328b5eae791ea5771fabe077666321b3cdb70.json | Add Support for 'year' datatype for Schema | tests/Database/DatabaseSqlServerSchemaGrammarTest.php | @@ -482,6 +482,15 @@ public function testAddingDate()
$this->assertEquals('alter table "users" add "foo" date not null', $statements[0]);
}
+ public function testAddingYear()
+ {
+ $blueprint = new Blueprint('users');
+ $blueprint->year('birth_year');
+ $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
+ $this->assertCount(1, $statements);
+ $this->assertEquals('alter table "users" add "birth_year" int not null', $statements[0]);
+ }
+
public function testAddingDateTime()
{
$blueprint = new Blueprint('users'); | true |
Other | laravel | framework | c55de5e654d136bc24ca126aca4f5daf87491faa.json | fix sqs queue for 7.2 (#22374) | src/Illuminate/Queue/SqsQueue.php | @@ -121,7 +121,7 @@ public function pop($queue = null)
'AttributeNames' => ['ApproximateReceiveCount'],
]);
- if (count($response['Messages']) > 0) {
+ if (! is_null($response['Messages']) && count($response['Messages']) > 0) {
return new SqsJob(
$this->container, $this->sqs, $response['Messages'][0],
$this->connectionName, $queue | true |
Other | laravel | framework | c55de5e654d136bc24ca126aca4f5daf87491faa.json | fix sqs queue for 7.2 (#22374) | tests/Queue/QueueSqsQueueTest.php | @@ -52,6 +52,10 @@ public function setUp()
],
]);
+ $this->mockedReceiveEmptyMessageResponseModel = new Result([
+ 'Messages' => null,
+ ]);
+
$this->mockedQueueAttributesResponseModel = new Result([
'Attributes' => [
'ApproximateNumberOfMessages' => 1,
@@ -69,6 +73,16 @@ public function testPopProperlyPopsJobOffOfSqs()
$this->assertInstanceOf('Illuminate\Queue\Jobs\SqsJob', $result);
}
+ public function testPopProperlyHandlesEmptyMessage()
+ {
+ $queue = $this->getMockBuilder('Illuminate\Queue\SqsQueue')->setMethods(['getQueue'])->setConstructorArgs([$this->sqs, $this->queueName, $this->account])->getMock();
+ $queue->setContainer(m::mock('Illuminate\Container\Container'));
+ $queue->expects($this->once())->method('getQueue')->with($this->queueName)->will($this->returnValue($this->queueUrl));
+ $this->sqs->shouldReceive('receiveMessage')->once()->with(['QueueUrl' => $this->queueUrl, 'AttributeNames' => ['ApproximateReceiveCount']])->andReturn($this->mockedReceiveEmptyMessageResponseModel);
+ $result = $queue->pop($this->queueName);
+ $this->assertNull($result);
+ }
+
public function testDelayedPushWithDateTimeProperlyPushesJobOntoSqs()
{
$now = \Illuminate\Support\Carbon::now(); | true |
Other | laravel | framework | d44d156aaa545c3231608a423728523a976c4e4b.json | Simplify doc block | src/Illuminate/Database/Schema/PostgresBuilder.php | @@ -83,9 +83,7 @@ public function getColumnListing($table)
}
/**
- * Determines which schema should be used
- * Returns and array of schema and table name
- * less schema name if found
+ * Determines which schema should be used.
*
* @param string $table
* @return [ string, string ] | false |
Other | laravel | framework | ada99e5e6b8c77feb8d0c5942612b5b431c59043.json | fix SQLite Update | src/Illuminate/Database/Query/Grammars/SQLiteGrammar.php | @@ -3,6 +3,7 @@
namespace Illuminate\Database\Query\Grammars;
use Illuminate\Support\Arr;
+use Illuminate\Support\Str;
use Illuminate\Database\Query\Builder;
class SQLiteGrammar extends Grammar
@@ -175,6 +176,54 @@ public function compileInsert(Builder $query, array $values)
return "insert into $table ($names) select ".implode(' union all select ', $columns);
}
+ /**
+ * Compile an update statement into SQL.
+ *
+ * @param \Illuminate\Database\Query\Builder $query
+ * @param array $values
+ * @return string
+ */
+ public function compileUpdate(Builder $query, $values)
+ {
+ $table = $this->wrapTable($query->from);
+
+ // SQLite doesn't support dots (table.column) in update columns.
+ // if there is any, We only remove the current table and leave other
+ // table names as they might be columns that based on a join statement.
+ $columns = collect($values)->map(function ($value, $key) use($query) {
+ return $this->wrap(Str::after($key, $query->from.'.')).' = '.$this->parameter($value);
+ })->implode(', ');
+
+
+ // SQLite doesn't support limits or orders by default in update/delete,
+ // so we use A workaround sub-query where.
+ if (isset($query->joins) || isset($query->limit)) {
+ $selectSql = parent::compileSelect($query->select("{$query->from}.rowid"));
+
+ return "update {$table} set $columns where {$this->wrap('rowid')} in ({$selectSql})";
+ }
+
+ $wheres = $this->compileWheres($query);
+
+ return trim("update {$table} set $columns $wheres");
+ }
+
+ /**
+ * Prepare the bindings for an update statement.
+ *
+ * @param array $bindings
+ * @param array $values
+ * @return array
+ */
+ public function prepareBindingsForUpdate(array $bindings, array $values)
+ {
+ $cleanBindings = Arr::except($bindings, ['join', 'select']);
+
+ return array_values(
+ array_merge($values, $bindings['join'], Arr::flatten($cleanBindings))
+ );
+ }
+
/**
* Compile a delete statement into SQL.
* | true |
Other | laravel | framework | ada99e5e6b8c77feb8d0c5942612b5b431c59043.json | fix SQLite Update | tests/Database/DatabaseQueryBuilderTest.php | @@ -1485,12 +1485,17 @@ public function testUpdateMethodWithJoinsOnMySql()
public function testUpdateMethodWithJoinsOnSQLite()
{
$builder = $this->getSQLiteBuilder();
- $builder->getConnection()->shouldReceive('update')->once()->with('update "users" inner join "orders" on "users"."id" = "orders"."user_id" set "email" = ?, "name" = ? where "users"."id" = ?', ['foo', 'bar', 1])->andReturn(1);
+ $builder->getConnection()->shouldReceive('update')->once()->with('update "users" set "email" = ?, "name" = ? where "rowid" in (select "users"."rowid" from "users" where "users"."id" > ? order by "id" asc limit 3)', ['foo', 'bar', 1])->andReturn(1);
+ $result = $builder->from('users')->where('users.id', '>', 1)->limit(3)->oldest('id')->update(['email' => 'foo', 'name' => 'bar']);
+ $this->assertEquals(1, $result);
+
+ $builder = $this->getSQLiteBuilder();
+ $builder->getConnection()->shouldReceive('update')->once()->with('update "users" set "email" = ?, "name" = ? where "rowid" in (select "users"."rowid" from "users" inner join "orders" on "users"."id" = "orders"."user_id" where "users"."id" = ?)', ['foo', 'bar', 1])->andReturn(1);
$result = $builder->from('users')->join('orders', 'users.id', '=', 'orders.user_id')->where('users.id', '=', 1)->update(['email' => 'foo', 'name' => 'bar']);
$this->assertEquals(1, $result);
$builder = $this->getSQLiteBuilder();
- $builder->getConnection()->shouldReceive('update')->once()->with('update "users" inner join "orders" on "users"."id" = "orders"."user_id" and "users"."id" = ? set "email" = ?, "name" = ?', [1, 'foo', 'bar'])->andReturn(1);
+ $builder->getConnection()->shouldReceive('update')->once()->with('update "users" set "email" = ?, "name" = ? where "rowid" in (select "users"."rowid" from "users" inner join "orders" on "users"."id" = "orders"."user_id" and "users"."id" = ?)', ['foo', 'bar', 1])->andReturn(1);
$result = $builder->from('users')->join('orders', function ($join) {
$join->on('users.id', '=', 'orders.user_id')
->where('users.id', '=', 1); | true |
Other | laravel | framework | ada99e5e6b8c77feb8d0c5942612b5b431c59043.json | fix SQLite Update | tests/Integration/Database/EloquentUpdateTest.php | @@ -0,0 +1,128 @@
+<?php
+
+namespace Illuminate\Tests\Integration\Database;
+
+use Orchestra\Testbench\TestCase;
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\SoftDeletes;
+
+/**
+ * @group integration
+ */
+class EloquentUpdateTest extends TestCase
+{
+ protected function getEnvironmentSetUp($app)
+ {
+ $app['config']->set('app.debug', 'true');
+
+ $app['config']->set('database.default', 'testbench');
+
+ $app['config']->set('database.connections.testbench', [
+ 'driver' => 'sqlite',
+ 'database' => ':memory:',
+ 'prefix' => '',
+ ]);
+ }
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ Schema::create('test_model1', function ($table) {
+ $table->increments('id');
+ $table->string('name')->nullable();
+ $table->string('title')->nullable();
+ });
+
+ Schema::create('test_model2', function ($table) {
+ $table->increments('id');
+ $table->string('name');
+ $table->string('job')->nullable();
+ $table->softDeletes();
+ $table->timestamps();
+ });
+ }
+
+ public function testBasicUpdate()
+ {
+ TestUpdateModel1::create([
+ 'name' => str_random(),
+ 'title' => 'Ms.',
+ ]);
+
+ TestUpdateModel1::where('title', 'Ms.')->delete();
+
+ $this->assertEquals(0, TestUpdateModel1::all()->count());
+ }
+
+ public function testUpdateWithLimitsAndOrders()
+ {
+ for($i=1; $i <= 10; $i++){
+ TestUpdateModel1::create();
+ }
+
+ TestUpdateModel1::latest('id')->limit(3)->update(['title'=>'Dr.']);
+
+ $this->assertEquals('Dr.', TestUpdateModel1::find(8)->title);
+ $this->assertNotEquals('Dr.', TestUpdateModel1::find(7)->title);
+ }
+
+ public function testUpdatedAtWithJoins()
+ {
+ TestUpdateModel1::create([
+ 'name' => 'Abdul',
+ 'title' => 'Mr.',
+ ]);
+
+ TestUpdateModel2::create([
+ 'name' => str_random()
+ ]);
+
+ TestUpdateModel2::join('test_model1', function($join) {
+ $join->on('test_model1.id', '=', 'test_model2.id')
+ ->where('test_model1.title', '=', 'Mr.');
+ })->update(['test_model2.name' => 'Abdul', 'job'=>'Engineer']);
+
+ $record = TestUpdateModel2::find(1);
+
+ $this->assertEquals('Engineer: Abdul', $record->job.': '.$record->name);
+ }
+
+ public function testSoftDeleteWithJoins()
+ {
+ TestUpdateModel1::create([
+ 'name' => str_random(),
+ 'title' => 'Mr.',
+ ]);
+
+ TestUpdateModel2::create([
+ 'name' => str_random()
+ ]);
+
+
+ TestUpdateModel2::join('test_model1', function($join) {
+ $join->on('test_model1.id', '=', 'test_model2.id')
+ ->where('test_model1.title', '=', 'Mr.');
+ })->delete();
+
+ $this->assertEquals(0, TestUpdateModel2::all()->count());
+ }
+}
+
+
+class TestUpdateModel1 extends Model
+{
+ public $table = 'test_model1';
+ public $timestamps = false;
+ protected $guarded = ['id'];
+}
+
+class TestUpdateModel2 extends Model
+{
+ use SoftDeletes;
+
+ public $table = 'test_model2';
+ protected $fillable = ['name'];
+ protected $dates = ['deleted_at'];
+} | true |
Other | laravel | framework | 71372121752d49d47d9c0407943cfe0092c11cf0.json | Allow setting editor for Whoops | src/Illuminate/Foundation/Exceptions/Handler.php | @@ -371,6 +371,10 @@ protected function whoopsHandler()
}
}
+ if (config('app.debug_editor', false)) {
+ $handler->setEditor(config('app.debug_editor');
+ }
+
$handler->setApplicationPaths(
array_flip(Arr::except(
array_flip($files->directories(base_path())), [base_path('vendor')] | false |
Other | laravel | framework | 015ea8fd59e7a1bd38d08a3036ce08c045fe9075.json | Apply fixes from StyleCI (#22346) | tests/Queue/QueueDatabaseQueueUnitTest.php | @@ -112,8 +112,8 @@ public function testBulkBatchPushesOntoDatabase()
public function testBuildDatabaseRecordWithPayloadAtTheEnd()
{
$queue = m::mock('Illuminate\Queue\DatabaseQueue');
- $record = $queue->buildDatabaseRecord('queue','any_payload',0);
+ $record = $queue->buildDatabaseRecord('queue', 'any_payload', 0);
$this->assertArrayHasKey('payload', $record);
- $this->assertArrayHasKey('payload', array_slice($record, -1, 1, TRUE));
+ $this->assertArrayHasKey('payload', array_slice($record, -1, 1, true));
}
} | false |
Other | laravel | framework | 2054da77e02f1eebfd367fbfe903e84aa35e5085.json | Apply fixes from StyleCI (#22341) | tests/Database/DatabaseSchemaBuilderIntegrationTest.php | @@ -59,7 +59,7 @@ public function testDropAllTablesWorksWithForeignKeys()
public function testHasColumnWithTablePrefix()
{
$this->db->connection()->setTablePrefix('test_');
-
+
$this->db->connection()->getSchemaBuilder()->create('table1', function ($table) {
$table->integer('id');
$table->string('name'); | false |
Other | laravel | framework | 47fbf49d11194fcd985163093fa6791352df1d8e.json | Add flushCache method | src/Illuminate/Filesystem/FilesystemAdapter.php | @@ -614,6 +614,20 @@ public function getDriver()
return $this->driver;
}
+ /**
+ * Flush the Flysystem cache.
+ *
+ * @return void
+ */
+ public function flushCache()
+ {
+ $adapter = $this->driver->getAdapter();
+
+ if ($adapter instanceof CachedAdapter) {
+ $adapter->getCache()->flush();
+ }
+ }
+
/**
* Filter directory contents by type.
* | false |
Other | laravel | framework | afbc5ac7c32f3ad5d862a6d6c4063bdde964b966.json | Remove unused import | src/Illuminate/Filesystem/FilesystemManager.php | @@ -16,7 +16,6 @@
use League\Flysystem\Adapter\Local as LocalAdapter;
use League\Flysystem\AwsS3v3\AwsS3Adapter as S3Adapter;
use League\Flysystem\Cached\Storage\Memory as MemoryStore;
-use League\Flysystem\Cached\Storage\Predis as PredisStore;
use Illuminate\Contracts\Filesystem\Factory as FactoryContract;
/** | false |
Other | laravel | framework | 7d0528112358a0312d2ac52aae653f71b0db8233.json | Support all cache drivers | src/Illuminate/Filesystem/Cache.php | @@ -0,0 +1,77 @@
+<?php
+
+namespace Illuminate\Filesystem;
+
+use Illuminate\Contracts\Cache\Repository;
+use League\Flysystem\Cached\Storage\AbstractCache;
+
+class Cache extends AbstractCache
+{
+ /**
+ * The cache repository instance.
+ *
+ * @var \Illuminate\Contracts\Cache\Repository
+ */
+ protected $repo;
+
+ /**
+ * The cache key.
+ *
+ * @var string
+ */
+ protected $key;
+
+ /**
+ * The cache expire in minutes.
+ *
+ * @var int
+ */
+ protected $expire;
+
+ /**
+ * Create a new cache instance.
+ *
+ * @param \Illuminate\Contracts\Cache\Repository $repo
+ * @param string $key
+ * @param int|null $expire
+ */
+ public function __construct(Repository $repo, string $key = 'flysystem', int $expire = null)
+ {
+ $this->repo = $repo;
+ $this->key = $key;
+
+ if ($expire) {
+ $this->expire = (int) ceil($expire / 60);
+ }
+ }
+
+ /**
+ * Load the cache.
+ *
+ * @return void
+ */
+ public function load()
+ {
+ $contents = $this->repo->get($this->key);
+
+ if ($contents !== null) {
+ $this->setFromStorage($contents);
+ }
+ }
+
+ /**
+ * Store the cache.
+ *
+ * @return void
+ */
+ public function save()
+ {
+ $contents = $this->getForStorage();
+
+ if ($this->expire !== null) {
+ $this->repo->put($this->key, $contents, $this->expire);
+ } else {
+ $this->repo->forever($this->key, $contents);
+ }
+ }
+} | true |
Other | laravel | framework | 7d0528112358a0312d2ac52aae653f71b0db8233.json | Support all cache drivers | src/Illuminate/Filesystem/FilesystemManager.php | @@ -286,29 +286,10 @@ protected function createCacheStore($config)
return new MemoryStore;
}
- $storeConfig = $this->app['config']['cache.stores.'.Arr::get($config, 'store')];
-
- if (Arr::get($storeConfig, 'driver') === 'redis') {
- return $this->createRedisCacheStore($config, $storeConfig);
- }
-
- throw new InvalidArgumentException("Cache driver [$driver] is not supported.");
- }
-
- /**
- * Create a Redis cache store instance.
- *
- * @param array $cacheConfig
- * @param array $storeConfig
- * @return \League\Flysystem\Cached\CacheInterface
- */
- protected function createRedisCacheStore(array $cacheConfig, array $storeConfig)
- {
- $key = $cacheConfig['prefix']
- ?? sprintf('%s:flysystem', $storeConfig['prefix'] ?? $this->app['config']['cache.prefix']);
-
- return new PredisStore(
- $this->app['redis.connection']->client(), $key, Arr::get($cacheConfig, 'expire')
+ return new Cache(
+ $this->app['cache']->store($config['store']),
+ Arr::get($config, 'prefix', 'flysystem'),
+ Arr::get($config, 'expire')
);
}
| true |
Other | laravel | framework | 7bdf8674651ad21bcf647a1a64efd569356313ef.json | Apply fixes from StyleCI (#22327) | tests/Database/DatabaseQueryBuilderTest.php | @@ -1583,7 +1583,6 @@ public function testDeleteMethod()
$result = $builder->from('users')->where('email', '=', 'foo')->orderBy('id')->take(1)->delete();
$this->assertEquals(1, $result);
-
$builder = $this->getMySqlBuilder();
$builder->getConnection()->shouldReceive('delete')->once()->with('delete from `users` where `email` = ? order by `id` asc limit 1', ['foo'])->andReturn(1);
$result = $builder->from('users')->where('email', '=', 'foo')->orderBy('id')->take(1)->delete(); | true |
Other | laravel | framework | 7bdf8674651ad21bcf647a1a64efd569356313ef.json | Apply fixes from StyleCI (#22327) | tests/Integration/Database/EloquentDeleteTest.php | @@ -44,12 +44,12 @@ public function setUp()
public function testOnlyDeleteWhatGiven()
{
- for($i = 1; $i <= 10; $i++) {
+ for ($i = 1; $i <= 10; $i++) {
Comment::create([
- 'post_id' => Post::create()->id
+ 'post_id' => Post::create()->id,
]);
}
-
+
Post::latest('id')->limit(1)->delete();
$this->assertEquals(9, Post::all()->count());
| true |
Other | laravel | framework | 878f1cfb5eeca55bb52e566cc2f96d9a9fb20255.json | Add composer suggestion | composer.json | @@ -114,6 +114,7 @@
"laravel/tinker": "Required to use the tinker console command (~1.0).",
"league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (~1.0).",
"league/flysystem-rackspace": "Required to use the Flysystem Rackspace driver (~1.0).",
+ "league/flysystem-cached-adapter": "Required to use Flysystem caching (~1.0).",
"nexmo/client": "Required to use the Nexmo transport (~1.0).",
"pda/pheanstalk": "Required to use the beanstalk queue driver (~3.0).",
"predis/predis": "Required to use the redis cache and queue drivers (~1.0).", | false |
Other | laravel | framework | 54f23fe1e08b25405b1ceaae1b7389dd572bc400.json | add a missing import | src/Illuminate/Database/Query/Grammars/SQLiteGrammar.php | @@ -2,6 +2,7 @@
namespace Illuminate\Database\Query\Grammars;
+use Illuminate\Support\Arr;
use Illuminate\Database\Query\Builder;
class SQLiteGrammar extends Grammar | false |
Other | laravel | framework | 76cb1f3ff1d9ed72acb90224ab7184d15bcc502f.json | Apply fixes from StyleCI (#22296) | src/Illuminate/Foundation/Testing/WithFaker.php | @@ -3,7 +3,6 @@
namespace Illuminate\Foundation\Testing;
use Faker\Factory;
-use Faker\Generator;
trait WithFaker
{ | false |
Other | laravel | framework | d48d7b4d4b91a0597960407687bc01b2094da02a.json | detect persistent connection reset (#22277) | src/Illuminate/Database/DetectsLostConnections.php | @@ -31,6 +31,7 @@ protected function causedByLostConnection(Exception $e)
'Transaction() on null',
'child connection forced to terminate due to client_idle_limit',
'query_wait_timeout',
+ 'reset by peer',
]);
}
} | false |
Other | laravel | framework | cbe8123a479e81779cd85251eb4a5cf861e93ea3.json | add accessor for pivot timestamp informaiton | src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php | @@ -75,6 +75,13 @@ class BelongsToMany extends Relation
*/
protected $pivotWhereIns = [];
+ /**
+ * Indicates if timestamps are available on the pivot table.
+ *
+ * @var bool
+ */
+ public $withTimestamps = false;
+
/**
* The custom pivot table column for the created_at timestamp.
*
@@ -877,6 +884,8 @@ public function getRelationCountHash()
*/
public function withTimestamps($createdAt = null, $updatedAt = null)
{
+ $this->withTimestamps = true;
+
$this->pivotCreatedAt = $createdAt;
$this->pivotUpdatedAt = $updatedAt;
| false |
Other | laravel | framework | f09ea98bc814c708215896dad702d715923f3bc3.json | add accessor for pivot accessor | src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php | @@ -952,4 +952,14 @@ public function getRelationName()
{
return $this->relationName;
}
+
+ /**
+ * Get the name of the pivot accessor for this relationship.
+ *
+ * @return string
+ */
+ public function getPivotAccessor()
+ {
+ return $this->accessor;
+ }
} | false |
Other | laravel | framework | a472d71fdfeb3e02a5e487e6fa395f7ea56d20ed.json | Apply fixes from StyleCI (#22259) | src/Illuminate/Console/Scheduling/Schedule.php | @@ -3,7 +3,6 @@
namespace Illuminate\Console\Scheduling;
use DateTimeInterface;
-use Illuminate\Support\Carbon;
use Illuminate\Console\Application;
use Illuminate\Container\Container;
use Illuminate\Contracts\Queue\ShouldQueue; | false |
Other | laravel | framework | a039b0c627dc26d3b132e5ab56bd288b23806f65.json | Fix incorrect paramerter name in docBlock (#22248) | src/Illuminate/Validation/Concerns/FormatsMessages.php | @@ -271,7 +271,7 @@ protected function replaceAttributePlaceholder($message, $value)
* Replace the :input placeholder in the given message.
*
* @param string $message
- * @param string $value
+ * @param string $attribute
* @return string
*/
protected function replaceInputPlaceholder($message, $attribute) | false |
Other | laravel | framework | 77227bd9f53ac0b6ad07e9007582443e8767f612.json | Apply fixes from StyleCI (#22223) | src/Illuminate/Database/Eloquent/Model.php | @@ -1155,9 +1155,9 @@ public static function unsetConnectionResolver()
public function getTable()
{
if (! isset($this->table)) {
- $this->setTable(str_replace(
- '\\', '', Str::snake(Str::plural(class_basename($this)))
- ));
+ $this->setTable(str_replace(
+ '\\', '', Str::snake(Str::plural(class_basename($this)))
+ ));
}
return $this->table; | false |
Other | laravel | framework | cabb61012f67c4a1ad9278dc88ce47b710dbe9d3.json | Use assertFileExists (#22219) | tests/Filesystem/FilesystemTest.php | @@ -405,7 +405,7 @@ public function testCopyCopiesFileProperly()
mkdir($this->tempDir.'/foo');
file_put_contents($this->tempDir.'/foo/foo.txt', $data);
$filesystem->copy($this->tempDir.'/foo/foo.txt', $this->tempDir.'/foo/foo2.txt');
- $this->assertTrue(file_exists($this->tempDir.'/foo/foo2.txt'));
+ $this->assertFileExists($this->tempDir.'/foo/foo2.txt');
$this->assertEquals($data, file_get_contents($this->tempDir.'/foo/foo2.txt'));
}
| false |
Other | laravel | framework | 5434f834cfa9411401003786fada6f30ff748a6d.json | Detect MySQL Galera deadblocks. (#22214) | src/Illuminate/Database/DetectsDeadlocks.php | @@ -26,6 +26,7 @@ protected function causedByDeadlock(Exception $e)
'A table in the database is locked',
'has been chosen as the deadlock victim',
'Lock wait timeout exceeded; try restarting transaction',
+ 'WSREP detected deadlock/conflict and aborted the transaction. Try restarting the transaction',
]);
}
} | false |
Other | laravel | framework | c91c742eb1f6a0cefacde3a558566081f7738f2c.json | Fix docblock style for 'param' attributes (#22159) | src/Illuminate/Database/Eloquent/FactoryBuilder.php | @@ -286,8 +286,8 @@ protected function applyStates(array $definition, array $attributes = [])
/**
* Get the state attributes.
*
- * @param string $state
- * @param array $attributes
+ * @param string $state
+ * @param array $attributes
* @return array
*/
protected function stateAttributes($state, array $attributes) | true |
Other | laravel | framework | c91c742eb1f6a0cefacde3a558566081f7738f2c.json | Fix docblock style for 'param' attributes (#22159) | src/Illuminate/Database/Query/Grammars/Grammar.php | @@ -551,7 +551,7 @@ protected function compileOrders(Builder $query, $orders)
/**
* Compile the query orders to an array.
*
- * @param \Illuminate\Database\Query\Builder
+ * @param \Illuminate\Database\Query\Builder $query
* @param array $orders
* @return array
*/ | true |
Other | laravel | framework | c91c742eb1f6a0cefacde3a558566081f7738f2c.json | Fix docblock style for 'param' attributes (#22159) | src/Illuminate/Filesystem/FilesystemAdapter.php | @@ -496,10 +496,10 @@ public function getAwsTemporaryUrl($adapter, $path, $expiration, $options)
/**
* Get a temporary URL for the file at the given path.
*
- * @param \League\Flysystem\Rackspace\RackspaceAdapter $adapter
- * @param string $path
- * @param \DateTimeInterface $expiration
- * @param $options
+ * @param \League\Flysystem\Rackspace\RackspaceAdapter $adapter
+ * @param string $path
+ * @param \DateTimeInterface $expiration
+ * @param array $options
* @return string
*/
public function getRackspaceTemporaryUrl($adapter, $path, $expiration, $options) | true |
Other | laravel | framework | c91c742eb1f6a0cefacde3a558566081f7738f2c.json | Fix docblock style for 'param' attributes (#22159) | src/Illuminate/Foundation/Application.php | @@ -299,7 +299,7 @@ protected function bindPathsInContainer()
/**
* Get the path to the application "app" directory.
*
- * @param string $path Optionally, a path to append to the app path
+ * @param string $path Optionally, a path to append to the app path
* @return string
*/
public function path($path = '')
@@ -310,7 +310,7 @@ public function path($path = '')
/**
* Get the base path of the Laravel installation.
*
- * @param string $path Optionally, a path to append to the base path
+ * @param string $path Optionally, a path to append to the base path
* @return string
*/
public function basePath($path = '')
@@ -321,7 +321,7 @@ public function basePath($path = '')
/**
* Get the path to the bootstrap directory.
*
- * @param string $path Optionally, a path to append to the bootstrap path
+ * @param string $path Optionally, a path to append to the bootstrap path
* @return string
*/
public function bootstrapPath($path = '')
@@ -332,7 +332,7 @@ public function bootstrapPath($path = '')
/**
* Get the path to the application configuration files.
*
- * @param string $path Optionally, a path to append to the config path
+ * @param string $path Optionally, a path to append to the config path
* @return string
*/
public function configPath($path = '')
@@ -343,7 +343,7 @@ public function configPath($path = '')
/**
* Get the path to the database directory.
*
- * @param string $path Optionally, a path to append to the database path
+ * @param string $path Optionally, a path to append to the database path
* @return string
*/
public function databasePath($path = '') | true |
Other | laravel | framework | c91c742eb1f6a0cefacde3a558566081f7738f2c.json | Fix docblock style for 'param' attributes (#22159) | src/Illuminate/Foundation/Auth/ResetsPasswords.php | @@ -128,7 +128,7 @@ protected function sendResetResponse($response)
/**
* Get the response for a failed password reset.
*
- * @param \Illuminate\Http\Request
+ * @param \Illuminate\Http\Request $request
* @param string $response
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
*/ | true |
Other | laravel | framework | c91c742eb1f6a0cefacde3a558566081f7738f2c.json | Fix docblock style for 'param' attributes (#22159) | src/Illuminate/Foundation/Auth/SendsPasswordResetEmails.php | @@ -42,7 +42,7 @@ public function sendResetLinkEmail(Request $request)
/**
* Validate the email for the given request.
*
- * @param \Illuminate\Http\Request $request
+ * @param \Illuminate\Http\Request $request
* @return void
*/
protected function validateEmail(Request $request)
@@ -64,7 +64,7 @@ protected function sendResetLinkResponse($response)
/**
* Get the response for a failed password reset link.
*
- * @param \Illuminate\Http\Request
+ * @param \Illuminate\Http\Request $request
* @param string $response
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
*/ | true |
Other | laravel | framework | c91c742eb1f6a0cefacde3a558566081f7738f2c.json | Fix docblock style for 'param' attributes (#22159) | src/Illuminate/Foundation/Console/PackageDiscoverCommand.php | @@ -24,7 +24,7 @@ class PackageDiscoverCommand extends Command
/**
* Execute the console command.
*
- * @param \Illuminate\Foundation\PackageManifest
+ * @param \Illuminate\Foundation\PackageManifest $manifest
* @return void
*/
public function handle(PackageManifest $manifest) | true |
Other | laravel | framework | c91c742eb1f6a0cefacde3a558566081f7738f2c.json | Fix docblock style for 'param' attributes (#22159) | src/Illuminate/Foundation/Console/VendorPublishCommand.php | @@ -135,7 +135,7 @@ protected function publishableChoices()
/**
* Parse the answer that was given via the prompt.
*
- * @param string $choice
+ * @param string $choice
* @return void
*/
protected function parseChoice($choice) | true |
Other | laravel | framework | c91c742eb1f6a0cefacde3a558566081f7738f2c.json | Fix docblock style for 'param' attributes (#22159) | src/Illuminate/Foundation/Console/stubs/resource-collection.stub | @@ -9,7 +9,7 @@ class DummyClass extends ResourceCollection
/**
* Transform the resource collection into an array.
*
- * @param \Illuminate\Http\Request
+ * @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request) | true |
Other | laravel | framework | c91c742eb1f6a0cefacde3a558566081f7738f2c.json | Fix docblock style for 'param' attributes (#22159) | src/Illuminate/Foundation/Console/stubs/resource.stub | @@ -9,7 +9,7 @@ class DummyClass extends Resource
/**
* Transform the resource into an array.
*
- * @param \Illuminate\Http\Request
+ * @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request) | true |
Other | laravel | framework | c91c742eb1f6a0cefacde3a558566081f7738f2c.json | Fix docblock style for 'param' attributes (#22159) | src/Illuminate/Foundation/Testing/Concerns/InteractsWithAuthentication.php | @@ -74,7 +74,7 @@ protected function isAuthenticated($guard = null)
/**
* Assert that the user is authenticated as the given user.
*
- * @param $user
+ * @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param string|null $guard
* @return $this
*/ | true |
Other | laravel | framework | c91c742eb1f6a0cefacde3a558566081f7738f2c.json | Fix docblock style for 'param' attributes (#22159) | src/Illuminate/Foundation/Testing/Concerns/InteractsWithExceptionHandling.php | @@ -71,7 +71,7 @@ protected function withoutExceptionHandling(array $except = [])
/**
* Create a new class instance.
*
- * @param \Illuminate\Contracts\Debug\ExceptionHandler
+ * @param \Illuminate\Contracts\Debug\ExceptionHandler $originalHandler
* @param array $except
* @return void
*/
@@ -121,7 +121,7 @@ public function render($request, Exception $e)
/**
* Render the exception for the console.
*
- * @param \Symfony\Component\Console\Output\OutputInterface
+ * @param \Symfony\Component\Console\Output\OutputInterface $output
* @param \Exception $e
* @return void
*/ | true |
Other | laravel | framework | c91c742eb1f6a0cefacde3a558566081f7738f2c.json | Fix docblock style for 'param' attributes (#22159) | src/Illuminate/Foundation/Testing/TestResponse.php | @@ -454,8 +454,8 @@ public function assertJsonStructure(array $structure = null, $responseData = nul
/**
* Assert that the response JSON has the expected count of items at the given key.
*
- * @param int $count
- * @param string|null $key
+ * @param int $count
+ * @param string|null $key
* @return $this
*/
public function assertJsonCount(int $count, $key = null)
@@ -480,7 +480,7 @@ public function assertJsonCount(int $count, $key = null)
/**
* Assert that the response has the given JSON validation errors for the given keys.
*
- * @param string|array $keys
+ * @param string|array $keys
* @return $this
*/
public function assertJsonValidationErrors($keys) | true |
Other | laravel | framework | c91c742eb1f6a0cefacde3a558566081f7738f2c.json | Fix docblock style for 'param' attributes (#22159) | src/Illuminate/Http/Resources/Json/Resource.php | @@ -116,7 +116,7 @@ public function toArray($request)
/**
* Get any additional data that should be returned with the resource array.
*
- * @param \Illuminate\Http\Request $request
+ * @param \Illuminate\Http\Request $request
* @return array
*/
public function with($request) | true |
Other | laravel | framework | c91c742eb1f6a0cefacde3a558566081f7738f2c.json | Fix docblock style for 'param' attributes (#22159) | src/Illuminate/Mail/Transport/SparkPostTransport.php | @@ -105,7 +105,7 @@ protected function getRecipients(Swift_Mime_SimpleMessage $message)
/**
* Get the transmission ID from the response.
*
- * @param \GuzzleHttp\Psr7\Response $response
+ * @param \GuzzleHttp\Psr7\Response $response
* @return string
*/
protected function getTransmissionId($response) | true |
Other | laravel | framework | c91c742eb1f6a0cefacde3a558566081f7738f2c.json | Fix docblock style for 'param' attributes (#22159) | src/Illuminate/Redis/Connections/PhpRedisConnection.php | @@ -50,7 +50,7 @@ public function mget(array $keys)
/**
* Determine if the given keys exist.
*
- * @param dynamic $key
+ * @param dynamic $keys
* @return int
*/
public function exists(...$keys)
@@ -65,11 +65,11 @@ public function exists(...$keys)
/**
* Set the string value in argument as value of the key.
*
- * @param string $key
- * @param mixed $value
- * @param string|null $expireResolution
- * @param int|null $expireTTL
- * @param string|null $flag
+ * @param string $key
+ * @param mixed $value
+ * @param string|null $expireResolution
+ * @param int|null $expireTTL
+ * @param string|null $flag
* @return bool
*/
public function set($key, $value, $expireResolution = null, $expireTTL = null, $flag = null)
@@ -385,7 +385,8 @@ public function disconnect()
/**
* Apply prefix to the given key if necessary.
*
- * @param $key
+ * @param string $key
+ * @return string
*/
private function applyPrefix($key)
{ | true |
Other | laravel | framework | c91c742eb1f6a0cefacde3a558566081f7738f2c.json | Fix docblock style for 'param' attributes (#22159) | src/Illuminate/Routing/RouteUrlGenerator.php | @@ -11,7 +11,7 @@ class RouteUrlGenerator
/**
* The URL generator instance.
*
- * @param \Illuminate\Routing\UrlGenerator
+ * @var \Illuminate\Routing\UrlGenerator
*/
protected $url;
| true |
Other | laravel | framework | c91c742eb1f6a0cefacde3a558566081f7738f2c.json | Fix docblock style for 'param' attributes (#22159) | src/Illuminate/Routing/Router.php | @@ -230,9 +230,9 @@ public function fallback($action)
/**
* Create a redirect from one URI to another.
*
- * @param string $uri
- * @param string $destination
- * @param int $status
+ * @param string $uri
+ * @param string $destination
+ * @param int $status
* @return \Illuminate\Routing\Route
*/
public function redirect($uri, $destination, $status = 301) | true |
Other | laravel | framework | c91c742eb1f6a0cefacde3a558566081f7738f2c.json | Fix docblock style for 'param' attributes (#22159) | src/Illuminate/Support/InteractsWithTime.php | @@ -40,7 +40,7 @@ protected function availableAt($delay = 0)
/**
* If the given value is an interval, convert it to a DateTime instance.
*
- * @param \DateTimeInterface|\DateInterval|int
+ * @param \DateTimeInterface|\DateInterval|int $delay
* @return \DateTimeInterface|int
*/
protected function parseDateInterval($delay) | true |
Other | laravel | framework | c91c742eb1f6a0cefacde3a558566081f7738f2c.json | Fix docblock style for 'param' attributes (#22159) | src/Illuminate/Support/helpers.php | @@ -548,7 +548,7 @@ function data_set(&$target, $key, $value, $overwrite = true)
/**
* Dump the passed variables and end the script.
*
- * @param mixed
+ * @param mixed $args
* @return void
*/
function dd(...$args) | true |
Other | laravel | framework | c91c742eb1f6a0cefacde3a558566081f7738f2c.json | Fix docblock style for 'param' attributes (#22159) | src/Illuminate/View/Compilers/Concerns/CompilesIncludes.php | @@ -44,7 +44,7 @@ protected function compileIncludeIf($expression)
/**
* Compile the include-when statements into valid PHP.
*
- * @param string $expression
+ * @param string $expression
* @return string
*/
protected function compileIncludeWhen($expression) | true |
Other | laravel | framework | 54b2cb66de5ea72a4cd392caf473dc94006401f1.json | Add support for newQueryForRestoration from queues | src/Illuminate/Database/Eloquent/Model.php | @@ -878,6 +878,25 @@ public function newQueryWithoutScope($scope)
return $builder->withoutGlobalScope($scope);
}
+ /**
+ * Get a new query to restore one or more models by the queueable IDs.
+ *
+ * @param array|int $ids
+ *
+ * @return \Illuminate\Database\Eloquent\Builder
+ */
+ public function newQueryForRestoration($ids)
+ {
+ if (is_array($ids)) {
+ return $this->newQueryWithoutScopes()->whereIn(
+ $this->getQualifiedKeyName(),
+ $ids
+ );
+ }
+
+ return $this->newQueryWithoutScopes()->whereKey($ids);
+ }
+
/**
* Create a new Eloquent query builder for the model.
* | true |
Other | laravel | framework | 54b2cb66de5ea72a4cd392caf473dc94006401f1.json | Add support for newQueryForRestoration from queues | src/Illuminate/Queue/SerializesAndRestoresModelIdentifiers.php | @@ -48,10 +48,12 @@ protected function getRestoredPropertyValue($value)
return $value;
}
+ $model = (new $value->class)->setConnection($value->connection);
+
return is_array($value->id)
- ? $this->restoreCollection($value)
- : $this->getQueryForModelRestoration((new $value->class)->setConnection($value->connection))
- ->useWritePdo()->findOrFail($value->id);
+ ? $this->restoreCollection($value)
+ : $this->getQueryForModelRestoration($model, $value->id)
+ ->useWritePdo()->firstOrFail();
}
/**
@@ -68,18 +70,19 @@ protected function restoreCollection($value)
$model = (new $value->class)->setConnection($value->connection);
- return $this->getQueryForModelRestoration($model)->useWritePdo()
- ->whereIn($model->getQualifiedKeyName(), $value->id)->get();
+ return $this->getQueryForModelRestoration($model, $value->id)
+ ->useWritePdo()->get();
}
/**
* Get the query for restoration.
*
* @param \Illuminate\Database\Eloquent\Model $model
+ * @param array|int $ids
* @return \Illuminate\Database\Eloquent\Builder
*/
- protected function getQueryForModelRestoration($model)
+ protected function getQueryForModelRestoration($model, $ids)
{
- return $model->newQueryWithoutScopes();
+ return $model->newQueryForRestoration($ids);
}
} | true |
Other | laravel | framework | 57d31b1a209b3ac74959d93b79612c96a4d58386.json | Add missing return docblocks (#22116) | src/Illuminate/Auth/Access/Response.php | @@ -15,6 +15,7 @@ class Response
* Create a new response.
*
* @param string|null $message
+ * @return void
*/
public function __construct($message = null)
{ | true |
Other | laravel | framework | 57d31b1a209b3ac74959d93b79612c96a4d58386.json | Add missing return docblocks (#22116) | src/Illuminate/Auth/Events/Attempting.php | @@ -23,6 +23,7 @@ class Attempting
*
* @param array $credentials
* @param bool $remember
+ * @return void
*/
public function __construct($credentials, $remember)
{ | true |
Other | laravel | framework | 57d31b1a209b3ac74959d93b79612c96a4d58386.json | Add missing return docblocks (#22116) | src/Illuminate/Auth/Events/Failed.php | @@ -23,6 +23,7 @@ class Failed
*
* @param \Illuminate\Contracts\Auth\Authenticatable|null $user
* @param array $credentials
+ * @return void
*/
public function __construct($user, $credentials)
{ | true |
Other | laravel | framework | 57d31b1a209b3ac74959d93b79612c96a4d58386.json | Add missing return docblocks (#22116) | src/Illuminate/Database/Console/Migrations/StatusCommand.php | @@ -33,7 +33,7 @@ class StatusCommand extends BaseCommand
* Create a new migration rollback command instance.
*
* @param \Illuminate\Database\Migrations\Migrator $migrator
- * @return \Illuminate\Database\Console\Migrations\StatusCommand
+ * @return void
*/
public function __construct(Migrator $migrator)
{ | true |
Other | laravel | framework | 57d31b1a209b3ac74959d93b79612c96a4d58386.json | Add missing return docblocks (#22116) | src/Illuminate/Foundation/AliasLoader.php | @@ -36,6 +36,7 @@ class AliasLoader
* Create a new AliasLoader instance.
*
* @param array $aliases
+ * @return void
*/
private function __construct($aliases)
{ | true |
Other | laravel | framework | 57d31b1a209b3ac74959d93b79612c96a4d58386.json | Add missing return docblocks (#22116) | src/Illuminate/Http/JsonResponse.php | @@ -22,6 +22,7 @@ class JsonResponse extends BaseJsonResponse
* @param int $status
* @param array $headers
* @param int $options
+ * @return void
*/
public function __construct($data = null, $status = 200, $headers = [], $options = 0)
{ | true |
Other | laravel | framework | 57d31b1a209b3ac74959d93b79612c96a4d58386.json | Add missing return docblocks (#22116) | src/Illuminate/Queue/ListenerOptions.php | @@ -21,6 +21,7 @@ class ListenerOptions extends WorkerOptions
* @param int $sleep
* @param int $maxTries
* @param bool $force
+ * @return void
*/
public function __construct($environment = null, $delay = 0, $memory = 128, $timeout = 60, $sleep = 3, $maxTries = 0, $force = false)
{ | true |
Other | laravel | framework | 57d31b1a209b3ac74959d93b79612c96a4d58386.json | Add missing return docblocks (#22116) | src/Illuminate/Queue/WorkerOptions.php | @@ -55,6 +55,7 @@ class WorkerOptions
* @param int $sleep
* @param int $maxTries
* @param bool $force
+ * @return void
*/
public function __construct($delay = 0, $memory = 128, $timeout = 60, $sleep = 3, $maxTries = 0, $force = false)
{ | true |
Other | laravel | framework | 57d31b1a209b3ac74959d93b79612c96a4d58386.json | Add missing return docblocks (#22116) | src/Illuminate/Redis/RedisManager.php | @@ -36,6 +36,7 @@ class RedisManager implements Factory
*
* @param string $driver
* @param array $config
+ * @return void
*/
public function __construct($driver, array $config)
{ | true |
Other | laravel | framework | 8766d9909007bdb318f390a1d157898bd56b8082.json | Add support for newQueryForRestoration from queues | src/Illuminate/Database/Eloquent/Model.php | @@ -878,6 +878,25 @@ public function newQueryWithoutScope($scope)
return $builder->withoutGlobalScope($scope);
}
+ /**
+ * Get a new query to restore one or more models by the queueable IDs.
+ *
+ * @param array|int $ids
+ *
+ * @return \Illuminate\Database\Eloquent\Builder
+ */
+ public function newQueryForRestoration($ids)
+ {
+ if (is_array($ids)) {
+ return $this->newQueryWithoutScopes()->whereIn(
+ $this->getQualifiedKeyName(),
+ $ids
+ );
+ }
+
+ return $this->newQueryWithoutScopes()->whereKey($ids);
+ }
+
/**
* Create a new Eloquent query builder for the model.
* | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.