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 | 06ddd7c7f350d4b4b9cfacf04b87d57f76c7d909.json | Apply fixes from StyleCI (#34533) | src/Illuminate/Database/Eloquent/Relations/MorphTo.php | @@ -152,8 +152,8 @@ protected function gatherKeysByType($type, $keyType)
return $keyType !== 'string'
? array_keys($this->dictionary[$type])
: array_map(function ($modelId) {
- return (string) $modelId;
- }, array_keys($this->dictionary[$type]));
+ return (string) $modelId;
+ }, array_keys($this->dictionary[$type]));
}
/** | false |
Other | laravel | framework | 9fd47f396505ddaa9c1bb0104e0c185b08476f58.json | Add perHour and perDay methods to RateLimiting
I have found my self using rate-limiting with hours and days quite often, in API subscriptions to be precise. | src/Illuminate/Cache/RateLimiting/Limit.php | @@ -58,6 +58,30 @@ public static function perMinute($maxAttempts)
return new static('', $maxAttempts);
}
+ /**
+ * Create a new rate limit using hours as decay time.
+ *
+ * @param int $maxAttempts
+ * @param int $decayHours
+ * @return static
+ */
+ public static function perHour($maxAttempts, $decayHours = 1)
+ {
+ return new static('', $maxAttempts, 60 * $decayHours);
+ }
+
+ /**
+ * Create a new rate limit using days as decay time.
+ *
+ * @param int $maxAttempts
+ * @param int $decayDays
+ * @return static
+ */
+ public static function perDay($maxAttempts, $decayDays = 1)
+ {
+ return new static('', $maxAttempts, 60 * 24 * $decayDays);
+ }
+
/**
* Create a new unlimited rate limit.
* | false |
Other | laravel | framework | 87e6a786fe83b738eb42e16374e24f78ddb1a8af.json | Fix misspelling: dont -> don't | CHANGELOG-8.x.md | @@ -13,7 +13,7 @@
- Fixed problems with dots in validator ([#34355](https://github.com/laravel/framework/pull/34355))
- Maintenance mode: Fix empty Retry-After header ([#34412](https://github.com/laravel/framework/pull/34412))
- Fixed bug with error handling in closure scheduled tasks ([#34420](https://github.com/laravel/framework/pull/34420))
-- Dont double escape on ComponentTagCompiler.php ([12ba0d9](https://github.com/laravel/framework/commit/12ba0d937d54e81eccf8f0a80150f0d70604e1c2))
+- Don't double escape on ComponentTagCompiler.php ([12ba0d9](https://github.com/laravel/framework/commit/12ba0d937d54e81eccf8f0a80150f0d70604e1c2))
- Fixed `mysqldump: unknown variable 'column-statistics=0` for MariaDB schema dump ([#34442](https://github.com/laravel/framework/pull/34442))
| false |
Other | laravel | framework | b084985496bc4ea227d77e17d7105c3b317b0467.json | Use letter abbreviation over undescore
Co-authored-by: Dries Vints <dries@vints.io> | src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php | @@ -915,7 +915,7 @@ protected function asDateTime($value)
// that is returned back out to the developers after we convert it here.
try {
$date = Date::createFromFormat($format, $value);
- } catch (InvalidArgumentException $_) {
+ } catch (InvalidArgumentException $e) {
$date = false;
}
| false |
Other | laravel | framework | 56a0a254ab639d793ddec71c38bb4870744ce3f0.json | Use only root type in exception catch | src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php | @@ -916,7 +916,7 @@ protected function asDateTime($value)
// that is returned back out to the developers after we convert it here.
try {
$date = Date::createFromFormat($format, $value);
- } catch (InvalidFormatException | InvalidArgumentException $_) {
+ } catch (InvalidArgumentException $_) {
$date = false;
}
| false |
Other | laravel | framework | 647d226715f9600e0e61f36f33e1465eff535524.json | Add test to show the handle of special formats | tests/Database/DatabaseEloquentIntegrationTest.php | @@ -1413,6 +1413,34 @@ public function testTimestampsUsingOldSqlServerDateFormatFallbackToDefaultParsin
$this->assertFalse(Date::hasFormat('2017-11-14 08:23:19.734', $model->getDateFormat()));
}
+ public function testSpecialFormats()
+ {
+ $model = new EloquentTestUser;
+ $model->setDateFormat('!Y-d-m \\Y');
+ $model->setRawAttributes([
+ 'updated_at' => '2017-05-11 Y',
+ ]);
+
+ $date = $model->getAttribute('updated_at');
+ $this->assertSame('2017-11-05 00:00:00.000000', $date->format('Y-m-d H:i:s.u'), 'the date should respect the whole format');
+
+ $model->setDateFormat('Y d m|');
+ $model->setRawAttributes([
+ 'updated_at' => '2020 11 09',
+ ]);
+
+ $date = $model->getAttribute('updated_at');
+ $this->assertSame('2020-09-11 00:00:00.000000', $date->format('Y-m-d H:i:s.u'), 'the date should respect the whole format');
+
+ $model->setDateFormat('Y d m|*');
+ $model->setRawAttributes([
+ 'updated_at' => '2020 11 09 foo',
+ ]);
+
+ $date = $model->getAttribute('updated_at');
+ $this->assertSame('2020-09-11 00:00:00.000000', $date->format('Y-m-d H:i:s.u'), 'the date should respect the whole format');
+ }
+
public function testUpdatingChildModelTouchesParent()
{
$before = Carbon::now(); | false |
Other | laravel | framework | 94ad84680a190dc8a213a0a3947f4c3419bd06e2.json | Fix error catch to handle older Carbon versions | src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php | @@ -15,6 +15,7 @@
use Illuminate\Support\Collection as BaseCollection;
use Illuminate\Support\Facades\Date;
use Illuminate\Support\Str;
+use InvalidArgumentException;
use LogicException;
trait HasAttributes
@@ -915,7 +916,7 @@ protected function asDateTime($value)
// that is returned back out to the developers after we convert it here.
try {
$date = Date::createFromFormat($format, $value);
- } catch (InvalidFormatException $_) {
+ } catch (InvalidFormatException | InvalidArgumentException $_) {
$date = false;
}
| false |
Other | laravel | framework | 9c6653e43d374ca301e68c77a760cb9f62377b59.json | Allow modifiers in createFromFormat() | src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php | @@ -3,6 +3,7 @@
namespace Illuminate\Database\Eloquent\Concerns;
use Carbon\CarbonInterface;
+use Carbon\Exceptions\InvalidFormatException;
use DateTimeInterface;
use Illuminate\Contracts\Database\Eloquent\Castable;
use Illuminate\Contracts\Database\Eloquent\CastsInboundAttributes;
@@ -912,11 +913,13 @@ protected function asDateTime($value)
// Finally, we will just assume this date is in the format used by default on
// the database connection and use that format to create the Carbon object
// that is returned back out to the developers after we convert it here.
- if (Date::hasFormat($value, $format)) {
- return Date::createFromFormat($format, $value);
+ try {
+ $date = Date::createFromFormat($format, $value);
+ } catch (InvalidFormatException $_) {
+ $date = false;
}
- return Date::parse($value);
+ return $date ?: Date::parse($value);
}
/** | false |
Other | laravel | framework | 285ef1c4b039f846c6683b2ccb80c3fb1b234aec.json | Fix docblocks again | src/Illuminate/Log/Events/MessageLogged.php | @@ -29,7 +29,7 @@ class MessageLogged
* Create a new event instance.
*
* @param string $level
- * @param mixed $message
+ * @param string $message
* @param array $context
* @return void
*/ | true |
Other | laravel | framework | 285ef1c4b039f846c6683b2ccb80c3fb1b234aec.json | Fix docblocks again | src/Illuminate/Log/Logger.php | @@ -197,7 +197,7 @@ public function listen(Closure $callback)
* Fires a log event.
*
* @param string $level
- * @param mixed $message
+ * @param string $message
* @param array $context
* @return void
*/ | true |
Other | laravel | framework | 4dc48a5d4811ae57466c982c3235120524dfb174.json | remove redundant use for Str from factory stub | src/Illuminate/Database/Console/Factories/stubs/factory.stub | @@ -3,7 +3,6 @@
namespace {{ factoryNamespace }};
use Illuminate\Database\Eloquent\Factories\Factory;
-use Illuminate\Support\Str;
use {{ namespacedModel }};
class {{ model }}Factory extends Factory | false |
Other | laravel | framework | 6b14a77eec4f70ae86fbf3570c5318c296caa8dc.json | Allow schema path on fresh (#34419) | src/Illuminate/Database/Console/Migrations/FreshCommand.php | @@ -48,6 +48,7 @@ public function handle()
'--database' => $database,
'--path' => $this->input->getOption('path'),
'--realpath' => $this->input->getOption('realpath'),
+ '--schema-path' => $this->input->getOption('schema-path'),
'--force' => true,
'--step' => $this->option('step'),
]));
@@ -98,6 +99,7 @@ protected function getOptions()
['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production'],
['path', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The path(s) to the migrations files to be executed'],
['realpath', null, InputOption::VALUE_NONE, 'Indicate any provided migration file paths are pre-resolved absolute paths'],
+ ['schema-path', null, InputOption::VALUE_OPTIONAL, 'The path to a schema dump file'],
['seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run'],
['seeder', null, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder'],
['step', null, InputOption::VALUE_NONE, 'Force the migrations to be run so they can be rolled back individually'], | false |
Other | laravel | framework | 4f9300bfa4ea5103f16d9d9a05b933fb21cb83fb.json | Allow schema path on fresh | src/Illuminate/Database/Console/Migrations/FreshCommand.php | @@ -48,6 +48,7 @@ public function handle()
'--database' => $database,
'--path' => $this->input->getOption('path'),
'--realpath' => $this->input->getOption('realpath'),
+ '--schema-path' => $this->input->getOption('schema-path'),
'--force' => true,
'--step' => $this->option('step'),
]));
@@ -98,6 +99,7 @@ protected function getOptions()
['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production'],
['path', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The path(s) to the migrations files to be executed'],
['realpath', null, InputOption::VALUE_NONE, 'Indicate any provided migration file paths are pre-resolved absolute paths'],
+ ['schema-path', null, InputOption::VALUE_OPTIONAL, 'The path to a schema dump file'],
['seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run'],
['seeder', null, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder'],
['step', null, InputOption::VALUE_NONE, 'Force the migrations to be run so they can be rolled back individually'], | false |
Other | laravel | framework | fb3f45aa0142764c5c29b97e8bcf8328091986e9.json | add method for marking password confirmed | src/Illuminate/Session/Store.php | @@ -637,6 +637,16 @@ public function setPreviousUrl($url)
$this->put('_previous.url', $url);
}
+ /**
+ * Specify that the user has confirmed their password.
+ *
+ * @return void
+ */
+ public function passwordConfirmed()
+ {
+ $this->put('auth.password_confirmed_at', time());
+ }
+
/**
* Get the underlying session handler implementation.
* | false |
Other | laravel | framework | 03e1373af9cf47e6d3378f19387d7ecf17a6b27b.json | Add doc blocks for HTTP facade assertions (#34393) | src/Illuminate/Support/Facades/Http.php | @@ -37,6 +37,11 @@
* @method static \Illuminate\Http\Client\Response put(string $url, array $data = [])
* @method static \Illuminate\Http\Client\Response send(string $method, string $url, array $options = [])
* @method static \Illuminate\Http\Client\ResponseSequence fakeSequence(string $urlPattern = '*')
+ * @method static void assertSent(callable $callback)
+ * @method static void assertNotSent(callable $callback)
+ * @method static void assertNothingSent()
+ * @method static void assertSentCount(int $count)
+ * @method static void assertSequencesAreEmpty()
*
* @see \Illuminate\Http\Client\Factory
*/ | false |
Other | laravel | framework | 2d1d96272a94bce123676ed742af2d80ba628ba4.json | fix dots in attribute names | src/Illuminate/View/DynamicComponent.php | @@ -54,7 +54,7 @@ public function __construct(string $component)
public function render()
{
$template = <<<'EOF'
-<?php extract(collect($attributes->getAttributes())->mapWithKeys(function ($value, $key) { return [Illuminate\Support\Str::camel(str_replace(':', ' ', $key)) => $value]; })->all(), EXTR_SKIP); ?>
+<?php extract(collect($attributes->getAttributes())->mapWithKeys(function ($value, $key) { return [Illuminate\Support\Str::camel(str_replace([':', '.'], ' ', $key)) => $value]; })->all(), EXTR_SKIP); ?>
{{ props }}
<x-{{ component }} {{ bindings }} {{ attributes }}>
{{ slots }}
@@ -113,7 +113,7 @@ protected function compileProps(array $bindings)
protected function compileBindings(array $bindings)
{
return collect($bindings)->map(function ($key) {
- return ':'.$key.'="$'.Str::camel(str_replace(':', ' ', $key)).'"';
+ return ':'.$key.'="$'.Str::camel(str_replace([':', '.'], ' ', $key)).'"';
})->implode(' ');
}
| true |
Other | laravel | framework | 2d1d96272a94bce123676ed742af2d80ba628ba4.json | fix dots in attribute names | tests/Integration/View/BladeTest.php | @@ -30,7 +30,7 @@ public function test_rendering_a_dynamic_component()
{
$view = View::make('uses-panel-dynamically', ['name' => 'Taylor'])->render();
- $this->assertEquals('<div class="ml-2" wire:model="foo">
+ $this->assertEquals('<div class="ml-2" wire:model="foo" wire:model.lazy="bar">
Hello Taylor
</div>', trim($view));
} | true |
Other | laravel | framework | 2d1d96272a94bce123676ed742af2d80ba628ba4.json | fix dots in attribute names | tests/Integration/View/templates/uses-panel-dynamically.blade.php | @@ -1,3 +1,3 @@
-<x-dynamic-component component="panel" class="ml-2" :name="$name" wire:model="foo">
+<x-dynamic-component component="panel" class="ml-2" :name="$name" wire:model="foo" wire:model.lazy="bar">
Panel contents
</x-dynamic-component> | true |
Other | laravel | framework | 0361686e40835a1f48674cf884d67609018d64b4.json | Update minimal.blade.php (#34379) | src/Illuminate/Foundation/Exceptions/views/minimal.blade.php | @@ -31,6 +31,7 @@
<div class="ml-4 text-lg text-gray-500 uppercase tracking-wider">
@yield('message')
</div>
+ </div>
</div>
</div>
</body> | false |
Other | laravel | framework | 602731ab8cc22f721f3777926022c24d519fb8c0.json | Move extension to $path | src/Illuminate/Foundation/Console/ComponentMakeCommand.php | @@ -54,7 +54,7 @@ public function handle()
protected function writeView()
{
$path = $this->viewPath(
- str_replace('.', '/', 'components.'.$this->getView())
+ str_replace('.', '/', 'components.'.$this->getView()).'.blade.php'
);
if (! $this->files->isDirectory(dirname($path))) {
@@ -67,7 +67,7 @@ protected function writeView()
}
file_put_contents(
- $path.'.blade.php',
+ $path,
'<div>
<!-- '.Inspiring::quote().' -->
</div>' | false |
Other | laravel | framework | ecb516445b06a15600f29e51738a409c2b9827ec.json | Show warning if view already exists | src/Illuminate/Foundation/Console/ComponentMakeCommand.php | @@ -61,6 +61,11 @@ protected function writeView()
$this->files->makeDirectory(dirname($path), 0777, true, true);
}
+ if ($this->files->exists($path) && ! $this->option('force')) {
+ $this->warn('View already exists');
+ return;
+ }
+
file_put_contents(
$path.'.blade.php',
'<div> | false |
Other | laravel | framework | ded87415833e3708b4994a4abe8c53575d17f24a.json | fix problems with dots in validator (#34355)
Co-authored-by: Taylor Otwell <taylorotwell@gmail.com> | src/Illuminate/Validation/Validator.php | @@ -314,22 +314,29 @@ protected function replacePlaceholders($data)
$originalData = [];
foreach ($data as $key => $value) {
- if (is_array($value)) {
- $value = $this->replacePlaceholders($value);
- }
-
- $key = str_replace(
- [$this->dotPlaceholder, '__asterisk__'],
- ['.', '*'],
- $key
- );
-
- $originalData[$key] = $value;
+ $originalData[$this->replacePlaceholderInString($key)] = is_array($value)
+ ? $this->replacePlaceholders($value)
+ : $value;
}
return $originalData;
}
+ /**
+ * Replace the placeholders in the given string.
+ *
+ * @param string $value
+ * @return string
+ */
+ protected function replacePlaceholderInString(string $value)
+ {
+ return str_replace(
+ [$this->dotPlaceholder, '__asterisk__'],
+ ['.', '*'],
+ $value
+ );
+ }
+
/**
* Add an after validation callback.
*
@@ -722,6 +729,10 @@ protected function hasNotFailedPreviousRuleIfPresenceRule($rule, $attribute)
*/
protected function validateUsingCustomRule($attribute, $value, $rule)
{
+ $attribute = $this->replacePlaceholderInString($attribute);
+
+ $value = is_array($value) ? $this->replacePlaceholders($value) : $value;
+
if (! $rule->passes($attribute, $value)) {
$this->failedRules[$attribute][get_class($rule)] = [];
@@ -745,21 +756,23 @@ protected function validateUsingCustomRule($attribute, $value, $rule)
*/
protected function shouldStopValidating($attribute)
{
+ $cleanedAttribute = $this->replacePlaceholderInString($attribute);
+
if ($this->hasRule($attribute, ['Bail'])) {
- return $this->messages->has($attribute);
+ return $this->messages->has($cleanedAttribute);
}
- if (isset($this->failedRules[$attribute]) &&
- array_key_exists('uploaded', $this->failedRules[$attribute])) {
+ if (isset($this->failedRules[$cleanedAttribute]) &&
+ array_key_exists('uploaded', $this->failedRules[$cleanedAttribute])) {
return true;
}
// In case the attribute has any rule that indicates that the field is required
// and that rule already failed then we should stop validation at this point
// as now there is no point in calling other rules with this field empty.
return $this->hasRule($attribute, $this->implicitRules) &&
- isset($this->failedRules[$attribute]) &&
- array_intersect(array_keys($this->failedRules[$attribute]), $this->implicitRules);
+ isset($this->failedRules[$cleanedAttribute]) &&
+ array_intersect(array_keys($this->failedRules[$cleanedAttribute]), $this->implicitRules);
}
/** | true |
Other | laravel | framework | ded87415833e3708b4994a4abe8c53575d17f24a.json | fix problems with dots in validator (#34355)
Co-authored-by: Taylor Otwell <taylorotwell@gmail.com> | tests/Validation/ValidationValidatorTest.php | @@ -4932,6 +4932,51 @@ public function message()
$this->assertSame('validation.string', $v->errors()->get('name')[2]);
}
+ public function testCustomValidationObjectWithDotKeysIsCorrectlyPassedValue()
+ {
+ $v = new Validator(
+ $this->getIlluminateArrayTranslator(),
+ ['foo' => ['foo.bar' => 'baz']],
+ [
+ 'foo' => new class implements Rule {
+ public function passes($attribute, $value)
+ {
+ return $value === ['foo.bar' => 'baz'];
+ }
+
+ public function message()
+ {
+ return ':attribute must be baz';
+ }
+ },
+ ]
+ );
+
+ $this->assertTrue($v->passes());
+
+ // Test failed attributes contains proper entries
+ $v = new Validator(
+ $this->getIlluminateArrayTranslator(),
+ ['foo' => ['foo.bar' => 'baz']],
+ [
+ 'foo.foo\.bar' => new class implements Rule {
+ public function passes($attribute, $value)
+ {
+ return false;
+ }
+
+ public function message()
+ {
+ return ':attribute must be baz';
+ }
+ },
+ ]
+ );
+
+ $this->assertFalse($v->passes());
+ $this->assertTrue(is_array($v->failed()['foo.foo.bar']));
+ }
+
public function testImplicitCustomValidationObjects()
{
// Test passing case... | true |
Other | laravel | framework | 7f8ac4f4abee41215b7f421f0dc491c844aea7b9.json | add some missing phpDocs for facades (#34352) | src/Illuminate/Support/Facades/Log.php | @@ -14,6 +14,8 @@
* @method static void log($level, string $message, array $context = [])
* @method static void notice(string $message, array $context = [])
* @method static void warning(string $message, array $context = [])
+ * @method static void write(string $level, string $message, array $context = [])
+ * @method static void listen(\Closure $callback)
*
* @see \Illuminate\Log\Logger
*/ | true |
Other | laravel | framework | 7f8ac4f4abee41215b7f421f0dc491c844aea7b9.json | add some missing phpDocs for facades (#34352) | src/Illuminate/Support/Facades/Mail.php | @@ -14,14 +14,18 @@
* @method static bool hasQueued(string $mailable)
* @method static bool hasSent(string $mailable)
* @method static mixed later(\DateTimeInterface|\DateInterval|int $delay, \Illuminate\Contracts\Mail\Mailable|string|array $view, string $queue = null)
+ * @method static mixed laterOn(string $queue, \DateTimeInterface|\DateInterval|int $delay, \Illuminate\Contracts\Mail\Mailable|string|array $view)
* @method static mixed queue(\Illuminate\Contracts\Mail\Mailable|string|array $view, string $queue = null)
+ * @method static mixed queueOn(string $queue, \Illuminate\Contracts\Mail\Mailable|string|array $view)
* @method static void assertNotQueued(string $mailable, callable $callback = null)
* @method static void assertNotSent(string $mailable, callable|int $callback = null)
* @method static void assertNothingQueued()
* @method static void assertNothingSent()
* @method static void assertQueued(string $mailable, callable|int $callback = null)
* @method static void assertSent(string $mailable, callable|int $callback = null)
* @method static void raw(string $text, $callback)
+ * @method static void plain(string $view, array $data, $callback)
+ * @method static void html(string $html, $callback)
* @method static void send(\Illuminate\Contracts\Mail\Mailable|string|array $view, array $data = [], \Closure|string $callback = null)
*
* @see \Illuminate\Mail\Mailer | true |
Other | laravel | framework | 7f8ac4f4abee41215b7f421f0dc491c844aea7b9.json | add some missing phpDocs for facades (#34352) | src/Illuminate/Support/Facades/Redirect.php | @@ -17,6 +17,7 @@
* @method static \Illuminate\Http\RedirectResponse to(string $path, int $status = 302, array $headers = [], bool $secure = null)
* @method static \Illuminate\Routing\UrlGenerator getUrlGenerator()
* @method static void setSession(\Illuminate\Session\Store $session)
+ * @method static void setIntendedUrl(string $url)
*
* @see \Illuminate\Routing\Redirector
*/ | true |
Other | laravel | framework | 7f8ac4f4abee41215b7f421f0dc491c844aea7b9.json | add some missing phpDocs for facades (#34352) | src/Illuminate/Support/Facades/Route.php | @@ -36,6 +36,10 @@
* @method static void pattern(string $key, string $pattern)
* @method static void resources(array $resources)
* @method static void substituteImplicitBindings(\Illuminate\Support\Facades\Route $route)
+ * @method static boolean uses(...$patterns)
+ * @method static boolean is(...$patterns)
+ * @method static boolean has(string $name)
+ * @method static mixed input(string $key, string|null $default = null)
*
* @see \Illuminate\Routing\Router
*/ | true |
Other | laravel | framework | 7f8ac4f4abee41215b7f421f0dc491c844aea7b9.json | add some missing phpDocs for facades (#34352) | src/Illuminate/Support/Facades/URL.php | @@ -7,6 +7,7 @@
* @method static bool hasValidSignature(\Illuminate\Http\Request $request, bool $absolute = true)
* @method static string action(string $action, $parameters = [], bool $absolute = true)
* @method static string asset(string $path, bool $secure = null)
+ * @method static string secureAsset(string $path)
* @method static string current()
* @method static string full()
* @method static string previous($fallback = false)
@@ -17,6 +18,7 @@
* @method static string to(string $path, $extra = [], bool $secure = null)
* @method static void defaults(array $defaults)
* @method static void forceScheme(string $scheme)
+ * @method static bool isValidUrl(string $path)
*
* @see \Illuminate\Routing\UrlGenerator
*/ | true |
Other | laravel | framework | 7f8ac4f4abee41215b7f421f0dc491c844aea7b9.json | add some missing phpDocs for facades (#34352) | src/Illuminate/Support/Facades/Validator.php | @@ -7,6 +7,7 @@
* @method static void extend(string $rule, \Closure|string $extension, string $message = null)
* @method static void extendImplicit(string $rule, \Closure|string $extension, string $message = null)
* @method static void replacer(string $rule, \Closure|string $replacer)
+ * @method static array validate(array $data, array $rules, array $messages = [], array $customAttributes = [])
*
* @see \Illuminate\Validation\Factory
*/ | true |
Other | laravel | framework | e472489a2f231fe264c11699a056eb2204ea594e.json | Allow int value (#34349) | src/Illuminate/Validation/Rules/DatabaseRule.php | @@ -77,7 +77,7 @@ public function resolveTableName($table)
* Set a "where" constraint on the query.
*
* @param \Closure|string $column
- * @param array|string|null $value
+ * @param array|string|int|null $value
* @return $this
*/
public function where($column, $value = null) | false |
Other | laravel | framework | 0920c23efb9d7042d074729f2f70acbfec629c14.json | handle array hosts | src/Illuminate/Database/Schema/MySqlSchemaState.php | @@ -95,7 +95,7 @@ protected function baseDumpCommand()
protected function baseVariables(array $config)
{
return [
- 'LARAVEL_LOAD_HOST' => $config['host'],
+ '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'], | false |
Other | laravel | framework | 9e4a866cfb0420f4ea6cb4e86b1fbd97a4b8c264.json | fix broken feature | src/Illuminate/Database/Seeder.php | @@ -24,14 +24,14 @@ abstract class Seeder
protected $command;
/**
- * Seed the given connection from the given path.
+ * Run the given seeder class.
*
* @param array|string $class
* @param bool $silent
- * @param mixed ...$parameters
+ * @param array $parameters
* @return $this
*/
- public function call($class, $silent = false, ...$parameters)
+ public function call($class, $silent = false, array $parameters = [])
{
$classes = Arr::wrap($class);
@@ -46,7 +46,7 @@ public function call($class, $silent = false, ...$parameters)
$startTime = microtime(true);
- $seeder->__invoke(...$parameters);
+ $seeder->__invoke($parameters);
$runTime = number_format((microtime(true) - $startTime) * 1000, 2);
@@ -59,15 +59,27 @@ public function call($class, $silent = false, ...$parameters)
}
/**
- * Silently seed the given connection from the given path.
+ * Run the given seeder class.
*
* @param array|string $class
- * @param mixed ...$parameters
+ * @param array $parameters
* @return void
*/
- public function callSilent($class, ...$parameters)
+ public function callWith($class, array $parameters = [])
{
- $this->call($class, true, ...$parameters);
+ $this->call($class, false, $parameters);
+ }
+
+ /**
+ * Silently run the given seeder class.
+ *
+ * @param array|string $class
+ * @param array $parameters
+ * @return void
+ */
+ public function callSilent($class, array $parameters = [])
+ {
+ $this->call($class, true, $parameters);
}
/**
@@ -122,12 +134,12 @@ public function setCommand(Command $command)
/**
* Run the database seeds.
*
- * @param mixed ...$parameters
+ * @param array $parameters
* @return mixed
*
* @throws \InvalidArgumentException
*/
- public function __invoke(...$parameters)
+ public function __invoke(array $parameters = [])
{
if (! method_exists($this, 'run')) {
throw new InvalidArgumentException('Method [run] missing from '.get_class($this)); | true |
Other | laravel | framework | 9e4a866cfb0420f4ea6cb4e86b1fbd97a4b8c264.json | fix broken feature | tests/Database/DatabaseSeederTest.php | @@ -87,7 +87,7 @@ public function testSendParamsOnCallMethodWithDeps()
$seeder = new TestDepsSeeder;
$seeder->setContainer($container);
- $seeder->__invoke('test1', 'test2');
+ $seeder->__invoke(['test1', 'test2']);
$container->shouldHaveReceived('call')->once()->with([$seeder, 'run'], ['test1', 'test2']);
} | true |
Other | laravel | framework | 452826b8f17ff07fcbba99523bb15b015b2d94f8.json | fix style ci errors | src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php | @@ -57,6 +57,7 @@
use Illuminate\Foundation\Console\ViewClearCommand;
use Illuminate\Notifications\Console\NotificationTableCommand;
use Illuminate\Queue\Console\BatchesTableCommand;
+use Illuminate\Queue\Console\ClearCommand as QueueClearCommand;
use Illuminate\Queue\Console\FailedTableCommand;
use Illuminate\Queue\Console\FlushFailedCommand as FlushFailedQueueCommand;
use Illuminate\Queue\Console\ForgetFailedCommand as ForgetFailedQueueCommand;
@@ -65,7 +66,6 @@
use Illuminate\Queue\Console\RestartCommand as QueueRestartCommand;
use Illuminate\Queue\Console\RetryBatchCommand as QueueRetryBatchCommand;
use Illuminate\Queue\Console\RetryCommand as QueueRetryCommand;
-use Illuminate\Queue\Console\ClearCommand as QueueClearCommand;
use Illuminate\Queue\Console\TableCommand;
use Illuminate\Queue\Console\WorkCommand as QueueWorkCommand;
use Illuminate\Routing\Console\ControllerMakeCommand; | true |
Other | laravel | framework | 452826b8f17ff07fcbba99523bb15b015b2d94f8.json | fix style ci errors | src/Illuminate/Queue/Console/ClearCommand.php | @@ -47,7 +47,7 @@ public function handle()
$queueName = $this->getQueue($connection);
$queue = ($this->laravel['queue'])->connection($connection);
- if($queue instanceof ClearableQueue) {
+ if ($queue instanceof ClearableQueue) {
$count = $queue->clear($queueName);
$this->line('<info>Cleared '.$count.' jobs from the '.$queueName.' queue</info> '); | true |
Other | laravel | framework | 452826b8f17ff07fcbba99523bb15b015b2d94f8.json | fix style ci errors | src/Illuminate/Queue/DatabaseQueue.php | @@ -2,8 +2,8 @@
namespace Illuminate\Queue;
-use Illuminate\Contracts\Queue\Queue as QueueContract;
use Illuminate\Contracts\Queue\ClearableQueue;
+use Illuminate\Contracts\Queue\Queue as QueueContract;
use Illuminate\Database\Connection;
use Illuminate\Queue\Jobs\DatabaseJob;
use Illuminate\Queue\Jobs\DatabaseJobRecord; | true |
Other | laravel | framework | 452826b8f17ff07fcbba99523bb15b015b2d94f8.json | fix style ci errors | src/Illuminate/Queue/RedisQueue.php | @@ -2,8 +2,8 @@
namespace Illuminate\Queue;
-use Illuminate\Contracts\Queue\Queue as QueueContract;
use Illuminate\Contracts\Queue\ClearableQueue;
+use Illuminate\Contracts\Queue\Queue as QueueContract;
use Illuminate\Contracts\Redis\Factory as Redis;
use Illuminate\Queue\Jobs\RedisJob;
use Illuminate\Support\Str; | true |
Other | laravel | framework | efcb7e9ef40cbcc087331fec997853926219d72e.json | Return response from named limiter (#34325)
If a named limiter returns a Response object, the `handleRequestUsingNamedLimiter` tried to return the unset variable `$limit`.
Instead, it should return the actual response created by the named limiter. | src/Illuminate/Routing/Middleware/ThrottleRequests.php | @@ -85,7 +85,7 @@ protected function handleRequestUsingNamedLimiter($request, Closure $next, $limi
$limiterResponse = call_user_func($limiter, $request);
if ($limiterResponse instanceof Response) {
- return $limit;
+ return $limiterResponse;
} elseif ($limiterResponse instanceof Unlimited) {
return $next($request);
} | false |
Other | laravel | framework | f34af246d57c51b320f9c5331936399daa9ee364.json | Add ability and command to clear queues | src/Illuminate/Contracts/Queue/ClearableQueue.php | @@ -0,0 +1,14 @@
+<?php
+
+namespace Illuminate\Contracts\Queue;
+
+interface ClearableQueue
+{
+ /**
+ * Clear all jobs from the queue.
+ *
+ * @param string $queue
+ * @return int
+ */
+ public function clear($queue);
+} | true |
Other | laravel | framework | f34af246d57c51b320f9c5331936399daa9ee364.json | Add ability and command to clear queues | src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php | @@ -65,6 +65,7 @@
use Illuminate\Queue\Console\RestartCommand as QueueRestartCommand;
use Illuminate\Queue\Console\RetryBatchCommand as QueueRetryBatchCommand;
use Illuminate\Queue\Console\RetryCommand as QueueRetryCommand;
+use Illuminate\Queue\Console\ClearCommand as QueueClearCommand;
use Illuminate\Queue\Console\TableCommand;
use Illuminate\Queue\Console\WorkCommand as QueueWorkCommand;
use Illuminate\Routing\Console\ControllerMakeCommand;
@@ -96,6 +97,7 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid
'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',
@@ -712,6 +714,18 @@ protected function registerQueueWorkCommand()
});
}
+ /**
+ * Register the command.
+ *
+ * @return void
+ */
+ protected function registerQueueClearCommand()
+ {
+ $this->app->singleton('command.queue.clear', function () {
+ return new QueueClearCommand;
+ });
+ }
+
/**
* Register the command.
* | true |
Other | laravel | framework | f34af246d57c51b320f9c5331936399daa9ee364.json | Add ability and command to clear queues | src/Illuminate/Queue/Console/ClearCommand.php | @@ -0,0 +1,73 @@
+<?php
+
+namespace Illuminate\Queue\Console;
+
+use Illuminate\Console\Command;
+use Illuminate\Console\ConfirmableTrait;
+use Illuminate\Contracts\Queue\ClearableQueue;
+use ReflectionClass;
+
+class ClearCommand extends Command
+{
+ use ConfirmableTrait;
+
+ /**
+ * The console command name.
+ *
+ * @var string
+ */
+ protected $signature = 'queue:clear
+ {connection? : The name of the queue connection to clear}
+ {--queue= : The name of the queue to clear}';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Clear the queue';
+
+ /**
+ * Execute the console command.
+ *
+ * @return int|null
+ */
+ public function handle()
+ {
+ if (! $this->confirmToProceed()) {
+ return 1;
+ }
+
+ $connection = $this->argument('connection')
+ ?: $this->laravel['config']['queue.default'];
+
+ // We need to get the right queue for the connection which is set in the queue
+ // configuration file for the application. We will pull it based on the set
+ // connection being run for the queue operation currently being executed.
+ $queueName = $this->getQueue($connection);
+ $queue = ($this->laravel['queue'])->connection($connection);
+
+ if($queue instanceof ClearableQueue) {
+ $count = $queue->clear($queueName);
+
+ $this->line('<info>Cleared '.$count.' jobs from the '.$queueName.' queue</info> ');
+ } else {
+ $this->line('<error>Clearing queues is not supported on '.(new ReflectionClass($queue))->getShortName().'</error> ');
+ }
+
+ return 0;
+ }
+
+ /**
+ * Get the queue name to clear.
+ *
+ * @param string $connection
+ * @return string
+ */
+ protected function getQueue($connection)
+ {
+ return $this->option('queue') ?: $this->laravel['config']->get(
+ "queue.connections.{$connection}.queue", 'default'
+ );
+ }
+} | true |
Other | laravel | framework | f34af246d57c51b320f9c5331936399daa9ee364.json | Add ability and command to clear queues | src/Illuminate/Queue/DatabaseQueue.php | @@ -303,6 +303,19 @@ protected function markJobAsReserved($job)
return $job;
}
+ /**
+ * Clear all jobs from the queue.
+ *
+ * @param string $queue
+ * @return int
+ */
+ public function clear($queue)
+ {
+ return $this->database->table($this->table)
+ ->where('queue', $this->getQueue($queue))
+ ->delete();
+ }
+
/**
* Delete a reserved job from the queue.
* | true |
Other | laravel | framework | f34af246d57c51b320f9c5331936399daa9ee364.json | Add ability and command to clear queues | src/Illuminate/Queue/LuaScripts.php | @@ -20,6 +20,24 @@ public static function size()
LUA;
}
+ /**
+ * Get the Lua script for clearing the queue.
+ *
+ * KEYS[1] - The name of the primary queue
+ * KEYS[2] - The name of the "delayed" queue
+ * KEYS[3] - The name of the "reserved" queue
+ *
+ * @return string
+ */
+ public static function clear()
+ {
+ return <<<'LUA'
+local size = redis.call('llen', KEYS[1]) + redis.call('zcard', KEYS[2]) + redis.call('zcard', KEYS[3])
+redis.call('del', KEYS[1], KEYS[2], KEYS[3])
+return size
+LUA;
+ }
+
/**
* Get the Lua script for pushing jobs onto the queue.
* | true |
Other | laravel | framework | f34af246d57c51b320f9c5331936399daa9ee364.json | Add ability and command to clear queues | src/Illuminate/Queue/RedisQueue.php | @@ -3,11 +3,12 @@
namespace Illuminate\Queue;
use Illuminate\Contracts\Queue\Queue as QueueContract;
+use Illuminate\Contracts\Queue\ClearableQueue;
use Illuminate\Contracts\Redis\Factory as Redis;
use Illuminate\Queue\Jobs\RedisJob;
use Illuminate\Support\Str;
-class RedisQueue extends Queue implements QueueContract
+class RedisQueue extends Queue implements QueueContract, ClearableQueue
{
/**
* The Redis factory implementation.
@@ -256,6 +257,21 @@ protected function retrieveNextJob($queue, $block = true)
return [$job, $reserved];
}
+ /**
+ * Clear all jobs from the queue.
+ *
+ * @param string $queue
+ * @return int
+ */
+ public function clear($queue)
+ {
+ $queue = $this->getQueue($queue);
+
+ return $this->getConnection()->eval(
+ LuaScripts::clear(), 3, $queue, $queue.':delayed', $queue.':reserved'
+ );
+ }
+
/**
* Delete a reserved job from the queue.
* | true |
Other | laravel | framework | f34af246d57c51b320f9c5331936399daa9ee364.json | Add ability and command to clear queues | tests/Queue/QueueDatabaseQueueIntegrationTest.php | @@ -147,6 +147,35 @@ public function testPoppedJobsIncrementAttempts()
$this->assertEquals(1, $popped_job->attempts(), 'The "attempts" attribute of the Job object was not updated by pop!');
}
+ /**
+ * Test that the queue can be cleared.
+ */
+ public function testThatQueueCanBeCleared()
+ {
+ $this->connection()
+ ->table('jobs')
+ ->insert([[
+ 'id' => 1,
+ 'queue' => $mock_queue_name = 'mock_queue_name',
+ 'payload' => 'mock_payload',
+ 'attempts' => 0,
+ 'reserved_at' => Carbon::now()->addDay()->getTimestamp(),
+ 'available_at' => Carbon::now()->subDay()->getTimestamp(),
+ 'created_at' => Carbon::now()->getTimestamp(),
+ ], [
+ 'id' => 2,
+ 'queue' => $mock_queue_name,
+ 'payload' => 'mock_payload 2',
+ 'attempts' => 0,
+ 'reserved_at' => null,
+ 'available_at' => Carbon::now()->subSeconds(1)->getTimestamp(),
+ 'created_at' => Carbon::now()->getTimestamp(),
+ ]]);
+
+ $this->assertEquals(2, $this->queue->clear($mock_queue_name));
+ $this->assertEquals(0, $this->queue->size());
+ }
+
/**
* Test that jobs that are not reserved and have an available_at value in the future, are not popped.
*/ | true |
Other | laravel | framework | f34af246d57c51b320f9c5331936399daa9ee364.json | Add ability and command to clear queues | tests/Queue/RedisQueueIntegrationTest.php | @@ -414,6 +414,25 @@ public function testDelete($driver)
$this->assertNull($this->queue->pop());
}
+ /**
+ * @dataProvider redisDriverProvider
+ *
+ * @param string $driver
+ */
+ public function testClear($driver)
+ {
+ $this->setQueue($driver);
+
+ $job1 = new RedisQueueIntegrationTestJob(30);
+ $job2 = new RedisQueueIntegrationTestJob(40);
+
+ $this->queue->push($job1);
+ $this->queue->push($job2);
+
+ $this->assertEquals(2, $this->queue->clear(null));
+ $this->assertEquals(0, $this->queue->size());
+ }
+
/**
* @dataProvider redisDriverProvider
* | true |
Other | laravel | framework | 9c61a908a1813c9508f4f88134e03f301f8b6293.json | fix styleci errors | src/Illuminate/Database/Console/Migrations/MigrateCommand.php | @@ -6,7 +6,6 @@
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Database\Events\SchemaLoaded;
use Illuminate\Database\Migrations\Migrator;
-use Illuminate\Database\SQLiteConnection;
use Illuminate\Database\SqlServerConnection;
class MigrateCommand extends BaseCommand | true |
Other | laravel | framework | 9c61a908a1813c9508f4f88134e03f301f8b6293.json | fix styleci errors | src/Illuminate/Database/SQLiteConnection.php | @@ -9,7 +9,6 @@
use Illuminate\Database\Schema\SQLiteBuilder;
use Illuminate\Database\Schema\SqliteSchemaState;
use Illuminate\Filesystem\Filesystem;
-use RuntimeException;
class SQLiteConnection extends Connection
{ | true |
Other | laravel | framework | 9c61a908a1813c9508f4f88134e03f301f8b6293.json | fix styleci errors | src/Illuminate/Database/Schema/SqliteSchemaState.php | @@ -2,10 +2,6 @@
namespace Illuminate\Database\Schema;
-use Exception;
-use Illuminate\Support\Str;
-use Symfony\Component\Process\Process;
-
class SqliteSchemaState extends SchemaState
{
/** | true |
Other | laravel | framework | 93f461344051e8d44c4a50748b7bdc0eae18bcac.json | fix bug in dynamic attributes | src/Illuminate/View/ComponentAttributeBag.php | @@ -219,7 +219,7 @@ public function setAttributes(array $attributes)
unset($attributes['attributes']);
- $attributes = $parentBag->merge($attributes);
+ $attributes = $parentBag->merge($attributes)->getAttributes();
}
$this->attributes = $attributes; | false |
Other | laravel | framework | 4a953728f5e085342d793372329ae534e5885724.json | add new factory method | src/Illuminate/Database/Eloquent/Factories/HasFactory.php | @@ -12,8 +12,20 @@ trait HasFactory
*/
public static function factory(...$parameters)
{
- return Factory::factoryForModel(get_called_class())
+ $factory = static::newFactory() ?: Factory::factoryForModel(get_called_class());
+
+ return $factory
->count(is_numeric($parameters[0] ?? null) ? $parameters[0] : null)
->state(is_array($parameters[0] ?? null) ? $parameters[0] : ($parameters[1] ?? []));
}
+
+ /**
+ * Create a new factory instance for the model.
+ *
+ * @return \Illuminate\Database\Eloquent\Factories\Factory
+ */
+ public static function newFactory()
+ {
+ //
+ }
} | false |
Other | laravel | framework | 3af5110208e2f50865a31298375c9122ccccad12.json | create Faker when a Factory is created (#34298)
when we create a new Factory object, let's resolve the Faker instance and assign it to the local `$faker` property.
this allows us to access it everywhere in the Factory, including states, without the need for a closure. | src/Illuminate/Database/Eloquent/Factories/Factory.php | @@ -126,6 +126,7 @@ public function __construct($count = null,
$this->afterMaking = $afterMaking ?: new Collection;
$this->afterCreating = $afterCreating ?: new Collection;
$this->connection = $connection;
+ $this->faker = $this->withFaker();
}
/**
@@ -346,8 +347,6 @@ protected function getExpandedAttributes(?Model $parent)
*/
protected function getRawAttributes(?Model $parent)
{
- $this->faker = $this->withFaker();
-
return $this->states->pipe(function ($states) {
return $this->for->isEmpty() ? $states : new Collection(array_merge([function () {
return $this->parentResolvers(); | false |
Other | laravel | framework | 8723739746a53442a5ec5bdebe649f8a4d9dd3c2.json | fix problems with dots in validator | src/Illuminate/Validation/Validator.php | @@ -314,22 +314,29 @@ protected function replacePlaceholders($data)
$originalData = [];
foreach ($data as $key => $value) {
- if (is_array($value)) {
- $value = $this->replacePlaceholders($value);
- }
-
- $key = str_replace(
- [$this->dotPlaceholder, '__asterisk__'],
- ['.', '*'],
- $key
- );
-
- $originalData[$key] = $value;
+ $originalData[$this->replacePlaceholderInString($key)] = is_array($value)
+ ? $this->replacePlaceholders($value)
+ : $value;
}
return $originalData;
}
+ /**
+ * Replace the placeholders in the given string.
+ *
+ * @param string $value
+ * @return string
+ */
+ protected function replacePlaceholderInString(string $value)
+ {
+ return str_replace(
+ [$this->dotPlaceholder, '__asterisk__'],
+ ['.', '*'],
+ $value
+ );
+ }
+
/**
* Add an after validation callback.
*
@@ -722,6 +729,10 @@ protected function hasNotFailedPreviousRuleIfPresenceRule($rule, $attribute)
*/
protected function validateUsingCustomRule($attribute, $value, $rule)
{
+ $attribute = $this->replacePlaceholderInString($attribute);
+
+ $value = is_array($value) ? $this->replacePlaceholders($value) : $value;
+
if (! $rule->passes($attribute, $value)) {
$this->failedRules[$attribute][get_class($rule)] = [];
@@ -745,21 +756,23 @@ protected function validateUsingCustomRule($attribute, $value, $rule)
*/
protected function shouldStopValidating($attribute)
{
+ $cleanedAttribute = $this->replacePlaceholderInString($attribute);
+
if ($this->hasRule($attribute, ['Bail'])) {
- return $this->messages->has($attribute);
+ return $this->messages->has($cleanedAttribute);
}
- if (isset($this->failedRules[$attribute]) &&
- array_key_exists('uploaded', $this->failedRules[$attribute])) {
+ if (isset($this->failedRules[$cleanedAttribute]) &&
+ array_key_exists('uploaded', $this->failedRules[$cleanedAttribute])) {
return true;
}
// In case the attribute has any rule that indicates that the field is required
// and that rule already failed then we should stop validation at this point
// as now there is no point in calling other rules with this field empty.
return $this->hasRule($attribute, $this->implicitRules) &&
- isset($this->failedRules[$attribute]) &&
- array_intersect(array_keys($this->failedRules[$attribute]), $this->implicitRules);
+ isset($this->failedRules[$cleanedAttribute]) &&
+ array_intersect(array_keys($this->failedRules[$cleanedAttribute]), $this->implicitRules);
}
/** | true |
Other | laravel | framework | 8723739746a53442a5ec5bdebe649f8a4d9dd3c2.json | fix problems with dots in validator | tests/Validation/ValidationValidatorTest.php | @@ -4932,6 +4932,51 @@ public function message()
$this->assertSame('validation.string', $v->errors()->get('name')[2]);
}
+ public function testCustomValidationObjectWithDotKeysIsCorrectlyPassedValue()
+ {
+ $v = new Validator(
+ $this->getIlluminateArrayTranslator(),
+ ['foo' => ['foo.bar' => 'baz']],
+ [
+ 'foo' => new class implements Rule {
+ public function passes($attribute, $value)
+ {
+ return $value === ['foo.bar' => 'baz'];
+ }
+
+ public function message()
+ {
+ return ':attribute must be baz';
+ }
+ },
+ ]
+ );
+
+ $this->assertTrue($v->passes());
+
+ // Test failed attributes contains proper entries
+ $v = new Validator(
+ $this->getIlluminateArrayTranslator(),
+ ['foo' => ['foo.bar' => 'baz']],
+ [
+ 'foo.foo\.bar' => new class implements Rule {
+ public function passes($attribute, $value)
+ {
+ return false;
+ }
+
+ public function message()
+ {
+ return ':attribute must be baz';
+ }
+ },
+ ]
+ );
+
+ $this->assertFalse($v->passes());
+ $this->assertTrue(is_array($v->failed()['foo.foo.bar']));
+ }
+
public function testImplicitCustomValidationObjects()
{
// Test passing case... | true |
Other | laravel | framework | 7b4d0f793ea59c2e3fb743d0fcbcfa0f1e3b0bc2.json | Update DatabaseUuidFailedJobProvider.php (#34251) | src/Illuminate/Queue/Failed/DatabaseUuidFailedJobProvider.php | @@ -89,7 +89,12 @@ public function all()
*/
public function find($id)
{
- return $this->getTable()->where('uuid', $id)->first();
+ if ($record = $this->getTable()->where('uuid', $id)->first()) {
+ $record->id = $record->uuid;
+ unset($record->uuid);
+ }
+
+ return $record;
}
/** | false |
Other | laravel | framework | c7186e09204cb3ed72ab24fe9f25a6450c2512bb.json | fix bugs with factory creation | src/Illuminate/Database/Console/Factories/FactoryMakeCommand.php | @@ -66,7 +66,14 @@ protected function buildClass($name)
$model = class_basename($namespaceModel);
+ if (Str::startsWith($namespaceModel, 'App\\Models')) {
+ $namespace = Str::beforeLast('Database\\Factories\\'.Str::after($namespaceModel, 'App\\Models\\'), '\\');
+ } else {
+ $namespace = 'Database\\Factories';
+ }
+
$replace = [
+ '{{ factoryNamespace }}' => $namespace,
'NamespacedDummyModel' => $namespaceModel,
'{{ namespacedModel }}' => $namespaceModel,
'{{namespacedModel}}' => $namespaceModel,
@@ -88,13 +95,11 @@ protected function buildClass($name)
*/
protected function getPath($name)
{
- $name = str_replace(
- ['\\', '/'], '', $this->argument('name')
- );
+ $name = Str::replaceFirst('App\\', '', $name);
- $name = Str::finish($name, 'Factory');
+ $name = Str::finish($this->argument('name'), 'Factory');
- return $this->laravel->databasePath()."/factories/{$name}.php";
+ return $this->laravel->databasePath().'/factories/'.str_replace('\\', '/', $name).'.php';
}
/** | true |
Other | laravel | framework | c7186e09204cb3ed72ab24fe9f25a6450c2512bb.json | fix bugs with factory creation | src/Illuminate/Database/Console/Factories/stubs/factory.stub | @@ -1,6 +1,6 @@
<?php
-namespace Database\Factories;
+namespace {{ factoryNamespace }};
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str; | true |
Other | laravel | framework | c7186e09204cb3ed72ab24fe9f25a6450c2512bb.json | fix bugs with factory creation | src/Illuminate/Foundation/Console/ModelMakeCommand.php | @@ -72,7 +72,7 @@ public function handle()
*/
protected function createFactory()
{
- $factory = Str::studly(class_basename($this->argument('name')));
+ $factory = Str::studly($this->argument('name'));
$this->call('make:factory', [
'name' => "{$factory}Factory", | true |
Other | laravel | framework | 13751a187834fabe515c14fb3ac1dc008fd23f37.json | add links property to JSON pagination responses | src/Illuminate/Pagination/LengthAwarePaginator.php | @@ -94,6 +94,36 @@ public function render($view = null, $data = [])
]));
}
+ /**
+ * Get the paginator links as a collection (for JSON responses).
+ *
+ * @return \Illuminate\Support\Collection
+ */
+ protected function linkCollection()
+ {
+ return collect($this->elements())->flatMap(function ($item) {
+ if (! is_array($item)) {
+ return [['url' => null, 'label' => '...', 'active' => false]];
+ }
+
+ return collect($item)->map(function ($url, $page) {
+ return [
+ 'url' => $url,
+ 'label' => $page,
+ 'active' => $this->currentPage() === $page,
+ ];
+ });
+ })->prepend([
+ 'url' => $this->previousPageUrl(),
+ 'label' => 'Previous',
+ 'active' => false,
+ ])->push([
+ 'url' => $this->nextPageUrl(),
+ 'label' => 'Next',
+ 'active' => false,
+ ]);
+ }
+
/**
* Get the array of elements to pass to the view.
*
@@ -168,6 +198,7 @@ public function toArray()
'from' => $this->firstItem(),
'last_page' => $this->lastPage(),
'last_page_url' => $this->url($this->lastPage()),
+ 'links' => $this->linkCollection(),
'next_page_url' => $this->nextPageUrl(),
'path' => $this->path(),
'per_page' => $this->perPage(), | false |
Other | laravel | framework | 75e792d61871780f75ecb4eb170826b0ba2f305e.json | respect local env | src/Illuminate/Foundation/Console/ServeCommand.php | @@ -93,7 +93,9 @@ public function handle()
protected function startProcess()
{
$process = new Process($this->serverCommand(), null, collect($_ENV)->mapWithKeys(function ($value, $key) {
- return [$key => false];
+ return $key === 'APP_ENV'
+ ? [$key => $value]
+ : [$key => false];
})->all());
$process->start(function ($type, $buffer) { | false |
Other | laravel | framework | 5bf30a553a1478ae8d8b3f6791286c7936a19ed5.json | update doc block | src/Illuminate/Routing/Route.php | @@ -852,7 +852,7 @@ public function named(...$patterns)
/**
* Set the handler for the route.
*
- * @param \Closure|string $action
+ * @param \Closure|array|string $action
* @return $this
*/
public function uses($action) | false |
Other | laravel | framework | 9d54a3bbdf32d185a68e2261be1eca95ac071729.json | remove temp variable | src/Illuminate/Database/Schema/MySqlSchemaState.php | @@ -117,11 +117,9 @@ protected function executeDumpProcess(Process $process, $output, array $variable
$process->mustRun($output, $variables);
} catch (Exception $e) {
if (Str::contains($e->getMessage(), 'column_statistics')) {
- $process = Process::fromShellCommandLine(
+ return $this->executeDumpProcess(Process::fromShellCommandLine(
str_replace(' --column-statistics=0', '', $process->getCommandLine())
- );
-
- return $this->executeDumpProcess($process, $output, $variables);
+ ), $output, $variables);
}
}
| false |
Other | laravel | framework | d67be1305bef418d9bdeb8192177202f9d705699.json | update schema state | src/Illuminate/Database/Schema/MySqlSchemaState.php | @@ -2,6 +2,10 @@
namespace Illuminate\Database\Schema;
+use Exception;
+use Illuminate\Support\Str;
+use Symfony\Component\Process\Process;
+
class MySqlSchemaState extends SchemaState
{
/**
@@ -12,9 +16,9 @@ class MySqlSchemaState extends SchemaState
*/
public function dump($path)
{
- $this->makeProcess(
+ $this->executeDumpProcess($this->makeProcess(
$this->baseDumpCommand().' --routines --result-file=$LARAVEL_LOAD_PATH --no-data'
- )->mustRun($this->output, array_merge($this->baseVariables($this->connection->getConfig()), [
+ ), $this->output, array_merge($this->baseVariables($this->connection->getConfig()), [
'LARAVEL_LOAD_PATH' => $path,
]));
@@ -46,9 +50,9 @@ protected function removeAutoIncrementingState(string $path)
*/
protected function appendMigrationData(string $path)
{
- with($process = $this->makeProcess(
+ $process = $this->executeDumpProcess($this->makeProcess(
$this->baseDumpCommand().' migrations --no-create-info --skip-extended-insert --skip-routines --compact'
- ))->mustRun(null, array_merge($this->baseVariables($this->connection->getConfig()), [
+ ), null, array_merge($this->baseVariables($this->connection->getConfig()), [
//
]));
@@ -98,4 +102,29 @@ protected function baseVariables(array $config)
'LARAVEL_LOAD_DATABASE' => $config['database'],
];
}
+
+ /**
+ * Execute the given dump process.
+ *
+ * @param \Symfony\Component\Process\Process $process
+ * @param callable $output
+ * @param array $variables
+ * @return \Symfony\Component\Process\Process
+ */
+ protected function executeDumpProcess(Process $process, $output, array $variables)
+ {
+ try {
+ $process->mustRun($output, $variables);
+ } catch (Exception $e) {
+ if (Str::contains($e->getMessage(), 'column_statistics')) {
+ $process = Process::fromShellCommandLine(
+ str_replace(' --column-statistics=0', '', $process->getCommandLine())
+ );
+
+ return $this->executeDumpProcess($process, $output, $variables);
+ }
+ }
+
+ return $process;
+ }
} | false |
Other | laravel | framework | e0d58c60ac09317b1024955af3cf4bcdc29c2330.json | Correct PHPDoc return type (#34167) | src/Illuminate/Database/Eloquent/Collection.php | @@ -335,7 +335,7 @@ public function intersect($items)
*
* @param string|callable|null $key
* @param bool $strict
- * @return static|\Illuminate\Support\Collection
+ * @return static
*/
public function unique($key = null, $strict = false)
{ | false |
Other | laravel | framework | 3d4a013ec226b7163ade27eae03dcd705b55c968.json | Apply fixes from StyleCI (#34175) | src/Illuminate/Database/Schema/Blueprint.php | @@ -1595,7 +1595,7 @@ public function getChangedColumns()
}
/**
- * Determine if the blueprint has auto increment columns
+ * Determine if the blueprint has auto increment columns.
*
* @return bool
*/ | false |
Other | laravel | framework | a4f7e9bfd2a7d9453ea2b142aa486b2ba29df7e1.json | Apply fixes from StyleCI (#34174) | tests/Database/DatabaseMySqlSchemaGrammarTest.php | @@ -63,7 +63,7 @@ public function testAutoIncrementStartingValue()
$this->assertCount(2, $statements);
$this->assertSame("create table `users` (`id` int unsigned not null auto_increment primary key, `email` varchar(255) not null) default character set utf8 collate 'utf8_unicode_ci'", $statements[0]);
- $this->assertSame("alter table `users` auto_increment = 1000", $statements[1]);
+ $this->assertSame('alter table `users` auto_increment = 1000', $statements[1]);
}
public function testEngineCreateTable() | false |
Other | laravel | framework | e8977adcd4e9c624b4e90ad84e4395481b0c8ea7.json | Improve assertions for classes on Auth folder | tests/Auth/AuthAccessGateTest.php | @@ -328,7 +328,7 @@ public function testCurrentUserThatIsOnGateAlwaysInjectedIntoClosureCallbacks()
$gate = $this->getBasicGate();
$gate->define('foo', function ($user) {
- $this->assertEquals(1, $user->id);
+ $this->assertSame(1, $user->id);
return true;
});
@@ -519,7 +519,7 @@ public function testForUserMethodAttachesANewUserToANewGateInstance()
// Assert that the callback receives the new user with ID of 2 instead of ID of 1...
$gate->define('foo', function ($user) {
- $this->assertEquals(2, $user->id);
+ $this->assertSame(2, $user->id);
return true;
});
@@ -541,16 +541,16 @@ public function testForUserMethodAttachesANewUserToANewGateInstanceWithGuessCall
};
$gate->guessPolicyNamesUsing($guesserCallback);
$gate->getPolicyFor('fooClass');
- $this->assertEquals(1, $counter);
+ $this->assertSame(1, $counter);
// now the guesser callback should be present on the new gate as well
$newGate = $gate->forUser((object) ['id' => 1]);
$newGate->getPolicyFor('fooClass');
- $this->assertEquals(2, $counter);
+ $this->assertSame(2, $counter);
$newGate->getPolicyFor('fooClass');
- $this->assertEquals(3, $counter);
+ $this->assertSame(3, $counter);
}
/** | true |
Other | laravel | framework | e8977adcd4e9c624b4e90ad84e4395481b0c8ea7.json | Improve assertions for classes on Auth folder | tests/Auth/AuthDatabaseUserProviderTest.php | @@ -28,7 +28,7 @@ public function testRetrieveByIDReturnsUserWhenUserIsFound()
$user = $provider->retrieveById(1);
$this->assertInstanceOf(GenericUser::class, $user);
- $this->assertEquals(1, $user->getAuthIdentifier());
+ $this->assertSame(1, $user->getAuthIdentifier());
$this->assertSame('Dayle', $user->name);
}
@@ -98,7 +98,7 @@ public function testRetrieveByCredentialsReturnsUserWhenUserIsFound()
$user = $provider->retrieveByCredentials(['username' => 'dayle', 'password' => 'foo', 'group' => ['one', 'two']]);
$this->assertInstanceOf(GenericUser::class, $user);
- $this->assertEquals(1, $user->getAuthIdentifier());
+ $this->assertSame(1, $user->getAuthIdentifier());
$this->assertSame('taylor', $user->name);
}
| true |
Other | laravel | framework | e8977adcd4e9c624b4e90ad84e4395481b0c8ea7.json | Improve assertions for classes on Auth folder | tests/Auth/AuthPasswordBrokerTest.php | @@ -26,7 +26,7 @@ public function testIfUserIsNotFoundErrorRedirectIsReturned()
$broker = $this->getMockBuilder(PasswordBroker::class)->setMethods(['getUser', 'makeErrorRedirect'])->setConstructorArgs(array_values($mocks))->getMock();
$broker->expects($this->once())->method('getUser')->willReturn(null);
- $this->assertEquals(PasswordBrokerContract::INVALID_USER, $broker->sendResetLink(['credentials']));
+ $this->assertSame(PasswordBrokerContract::INVALID_USER, $broker->sendResetLink(['credentials']));
}
public function testIfTokenIsRecentlyCreated()
@@ -37,7 +37,7 @@ public function testIfTokenIsRecentlyCreated()
$mocks['tokens']->shouldReceive('recentlyCreatedToken')->once()->with($user)->andReturn(true);
$user->shouldReceive('sendPasswordResetNotification')->with('token');
- $this->assertEquals(PasswordBrokerContract::RESET_THROTTLED, $broker->sendResetLink(['foo']));
+ $this->assertSame(PasswordBrokerContract::RESET_THROTTLED, $broker->sendResetLink(['foo']));
}
public function testGetUserThrowsExceptionIfUserDoesntImplementCanResetPassword()
@@ -68,15 +68,15 @@ public function testBrokerCreatesTokenAndRedirectsWithoutError()
$mocks['tokens']->shouldReceive('create')->once()->with($user)->andReturn('token');
$user->shouldReceive('sendPasswordResetNotification')->with('token');
- $this->assertEquals(PasswordBrokerContract::RESET_LINK_SENT, $broker->sendResetLink(['foo']));
+ $this->assertSame(PasswordBrokerContract::RESET_LINK_SENT, $broker->sendResetLink(['foo']));
}
public function testRedirectIsReturnedByResetWhenUserCredentialsInvalid()
{
$broker = $this->getBroker($mocks = $this->getMocks());
$mocks['users']->shouldReceive('retrieveByCredentials')->once()->with(['creds'])->andReturn(null);
- $this->assertEquals(PasswordBrokerContract::INVALID_USER, $broker->reset(['creds'], function () {
+ $this->assertSame(PasswordBrokerContract::INVALID_USER, $broker->reset(['creds'], function () {
//
}));
}
@@ -88,7 +88,7 @@ public function testRedirectReturnedByRemindWhenRecordDoesntExistInTable()
$mocks['users']->shouldReceive('retrieveByCredentials')->once()->with(Arr::except($creds, ['token']))->andReturn($user = m::mock(CanResetPassword::class));
$mocks['tokens']->shouldReceive('exists')->with($user, 'token')->andReturn(false);
- $this->assertEquals(PasswordBrokerContract::INVALID_TOKEN, $broker->reset($creds, function () {
+ $this->assertSame(PasswordBrokerContract::INVALID_TOKEN, $broker->reset($creds, function () {
//
}));
}
@@ -105,7 +105,7 @@ public function testResetRemovesRecordOnReminderTableAndCallsCallback()
return 'foo';
};
- $this->assertEquals(PasswordBrokerContract::PASSWORD_RESET, $broker->reset(['password' => 'password', 'token' => 'token'], $callback));
+ $this->assertSame(PasswordBrokerContract::PASSWORD_RESET, $broker->reset(['password' => 'password', 'token' => 'token'], $callback));
$this->assertEquals(['user' => $user, 'password' => 'password'], $_SERVER['__password.reset.test']);
}
| true |
Other | laravel | framework | e8977adcd4e9c624b4e90ad84e4395481b0c8ea7.json | Improve assertions for classes on Auth folder | tests/Auth/AuthTokenGuardTest.php | @@ -27,10 +27,10 @@ public function testUserCanBeRetrievedByQueryStringVariable()
$user = $guard->user();
- $this->assertEquals(1, $user->id);
+ $this->assertSame(1, $user->id);
$this->assertTrue($guard->check());
$this->assertFalse($guard->guest());
- $this->assertEquals(1, $guard->id());
+ $this->assertSame(1, $guard->id());
}
public function testTokenCanBeHashed()
@@ -45,10 +45,10 @@ public function testTokenCanBeHashed()
$user = $guard->user();
- $this->assertEquals(1, $user->id);
+ $this->assertSame(1, $user->id);
$this->assertTrue($guard->check());
$this->assertFalse($guard->guest());
- $this->assertEquals(1, $guard->id());
+ $this->assertSame(1, $guard->id());
}
public function testUserCanBeRetrievedByAuthHeaders()
@@ -61,7 +61,7 @@ public function testUserCanBeRetrievedByAuthHeaders()
$user = $guard->user();
- $this->assertEquals(1, $user->id);
+ $this->assertSame(1, $user->id);
}
public function testUserCanBeRetrievedByBearerToken()
@@ -74,7 +74,7 @@ public function testUserCanBeRetrievedByBearerToken()
$user = $guard->user();
- $this->assertEquals(1, $user->id);
+ $this->assertSame(1, $user->id);
}
public function testValidateCanDetermineIfCredentialsAreValid()
@@ -124,7 +124,7 @@ public function testItAllowsToPassCustomRequestInSetterAndUseItForValidation()
$user = $guard->user();
- $this->assertEquals(1, $user->id);
+ $this->assertSame(1, $user->id);
}
public function testUserCanBeRetrievedByBearerTokenWithCustomKey()
@@ -137,7 +137,7 @@ public function testUserCanBeRetrievedByBearerTokenWithCustomKey()
$user = $guard->user();
- $this->assertEquals(1, $user->id);
+ $this->assertSame(1, $user->id);
}
public function testUserCanBeRetrievedByQueryStringVariableWithCustomKey()
@@ -152,10 +152,10 @@ public function testUserCanBeRetrievedByQueryStringVariableWithCustomKey()
$user = $guard->user();
- $this->assertEquals(1, $user->id);
+ $this->assertSame(1, $user->id);
$this->assertTrue($guard->check());
$this->assertFalse($guard->guest());
- $this->assertEquals(1, $guard->id());
+ $this->assertSame(1, $guard->id());
}
public function testUserCanBeRetrievedByAuthHeadersWithCustomField()
@@ -168,7 +168,7 @@ public function testUserCanBeRetrievedByAuthHeadersWithCustomField()
$user = $guard->user();
- $this->assertEquals(1, $user->id);
+ $this->assertSame(1, $user->id);
}
public function testValidateCanDetermineIfCredentialsAreValidWithCustomKey() | true |
Other | laravel | framework | 6061e9351c2e440fa51a7889a7558d63a81c0143.json | Apply fixes from StyleCI (#34152) | src/Illuminate/Foundation/Console/ServeCommand.php | @@ -113,8 +113,8 @@ protected function serverCommand()
return [
(new PhpExecutableFinder)->find(false),
'-S',
- $this->host() . ':' . $this->port(),
- base_path('server.php')
+ $this->host().':'.$this->port(),
+ base_path('server.php'),
];
}
| false |
Other | laravel | framework | e0766cfd81a164bd5f0a0070216400b430d30185.json | Apply fixes from StyleCI (#34149) | src/Illuminate/Database/Schema/Blueprint.php | @@ -7,8 +7,8 @@
use Illuminate\Database\Connection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Query\Expression;
-use Illuminate\Database\SQLiteConnection;
use Illuminate\Database\Schema\Grammars\Grammar;
+use Illuminate\Database\SQLiteConnection;
use Illuminate\Support\Fluent;
use Illuminate\Support\Traits\Macroable;
| false |
Other | laravel | framework | 29e4df7497bf0224ff82d6772ee7f109424990dc.json | add foreign id for methodgs | src/Illuminate/Database/Schema/Blueprint.php | @@ -5,9 +5,10 @@
use BadMethodCallException;
use Closure;
use Illuminate\Database\Connection;
+use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Query\Expression;
-use Illuminate\Database\Schema\Grammars\Grammar;
use Illuminate\Database\SQLiteConnection;
+use Illuminate\Database\Schema\Grammars\Grammar;
use Illuminate\Support\Fluent;
use Illuminate\Support\Traits\Macroable;
@@ -833,6 +834,24 @@ public function foreignId($column)
return $column;
}
+ /**
+ * Create a foreign ID column for the given model.
+ *
+ * @param \Illuminate\Database\Eloquent\Model|string $model
+ * @param string|null $column
+ * @return \Illuminate\Database\Schema\ForeignIdColumnDefinition
+ */
+ public function foreignIdFor($model, $column = null)
+ {
+ if (is_string($model)) {
+ $model = new $model;
+ }
+
+ return $model->getKeyType() === 'int' && $model->incrementing
+ ? $this->foreignId($column ?: $model->getForeignKey())
+ : $this->foreignUuid($column ?: $model->getForeignKey());
+ }
+
/**
* Create a new float column on the table.
* | false |
Other | laravel | framework | 82c3db492f0421e874aef8e097ac052c30b65f67.json | Remove incorrect return | src/Illuminate/View/Compilers/BladeCompiler.php | @@ -616,7 +616,7 @@ public function aliasComponent($path, $alias = null)
*/
public function include($path, $alias = null)
{
- return $this->aliasInclude($path, $alias);
+ $this->aliasInclude($path, $alias);
}
/** | false |
Other | laravel | framework | 8af4f77d4c60f6d616e00c6c37eea731543f792d.json | Apply fixes from StyleCI (#34116) | src/Illuminate/Encryption/EncryptionServiceProvider.php | @@ -5,7 +5,6 @@
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Str;
use Opis\Closure\SerializableClosure;
-use RuntimeException;
class EncryptionServiceProvider extends ServiceProvider
{ | false |
Other | laravel | framework | c0d7d3283abe6fb045920ae2ad06d288e9923772.json | Remove app assignment | src/Illuminate/Support/Manager.php | @@ -44,7 +44,6 @@ abstract class Manager
*/
public function __construct(Container $container)
{
- $this->app = $container;
$this->container = $container;
$this->config = $container->make('config');
} | false |
Other | laravel | framework | fcad5ec272c9406e2afa9f1fde25271920ca6e24.json | Remove deprecated method (#34099) | src/Illuminate/Collections/Traits/EnumeratesValues.php | @@ -723,21 +723,6 @@ public function uniqueStrict($key = null)
return $this->unique($key, true);
}
- /**
- * Take items in the collection until the given condition is met.
- *
- * This is an alias to the "takeUntil" method.
- *
- * @param mixed $value
- * @return static
- *
- * @deprecated Use the "takeUntil" method directly.
- */
- public function until($value)
- {
- return $this->takeUntil($value);
- }
-
/**
* Collect the values into a collection.
* | false |
Other | laravel | framework | d338d13eec3ae899250ef4685fbeb85a198f7d2d.json | Remove additional comma | src/Illuminate/View/Concerns/ManagesComponents.php | @@ -114,7 +114,7 @@ protected function componentData()
$this->componentData[count($this->componentStack)],
['slot' => $defaultSlot],
$this->slots[count($this->componentStack)],
- ['__laravel_slots' => $slots],
+ ['__laravel_slots' => $slots]
);
}
| false |
Other | laravel | framework | 27065599b5bb4f701de5e7f256bf863141b1d06a.json | Remove unnecessary comma | src/Illuminate/View/Concerns/ManagesComponents.php | @@ -114,7 +114,7 @@ protected function componentData()
$this->componentData[count($this->componentStack)],
['slot' => $defaultSlot],
$this->slots[count($this->componentStack)],
- ['__laravel_slots' => $slots],
+ ['__laravel_slots' => $slots]
);
}
| false |
Other | laravel | framework | 5eed08c6a2cae6e897192b041076ac49c0192502.json | update model stub | src/Illuminate/Foundation/Console/stubs/model.stub | @@ -2,9 +2,10 @@
namespace {{ namespace }};
+use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class {{ class }} extends Model
{
- //
+ use HasFactory;
} | false |
Other | laravel | framework | 850c91f9a9f9e96a01bb3a3a891cdc2330937cf5.json | use tailwind by default | src/Illuminate/Pagination/AbstractPaginator.php | @@ -112,14 +112,14 @@ abstract class AbstractPaginator implements Htmlable
*
* @var string
*/
- public static $defaultView = 'pagination::bootstrap-4';
+ public static $defaultView = 'pagination::tailwind';
/**
* The default "simple" pagination view.
*
* @var string
*/
- public static $defaultSimpleView = 'pagination::simple-bootstrap-4';
+ public static $defaultSimpleView = 'pagination::simple-tailwind';
/**
* Determine if the given value is a valid page number.
@@ -563,6 +563,17 @@ public static function useTailwind()
static::defaultSimpleView('pagination::simple-tailwind');
}
+ /**
+ * Indicate that Bootstrap 4 styling should be used for generated links.
+ *
+ * @return void
+ */
+ public static function useBootstrap()
+ {
+ static::defaultView('pagination::bootstrap-4');
+ static::defaultSimpleView('pagination::simple-bootstrap-4');
+ }
+
/**
* Indicate that Bootstrap 3 styling should be used for generated links.
* | false |
Other | laravel | framework | cadad245ff1d5e294ef6d3f312d66dc63f728619.json | prefix seeders automatically if necessary | src/Illuminate/Database/Console/Seeds/SeedCommand.php | @@ -83,6 +83,10 @@ protected function getSeeder()
{
$class = $this->input->getOption('class');
+ if (strpos($class, '\\') === false) {
+ $class = 'Database\\Seeders\\'.$class;
+ }
+
if ($class === 'Database\\Seeders\\DatabaseSeeder' &&
! class_exists($class)) {
$class = 'DatabaseSeeder'; | false |
Other | laravel | framework | eb3c9e25a5bc2a96777e5e643ce0f612e4a544d9.json | implement array access | src/Illuminate/Testing/AssertableJsonString.php | @@ -2,13 +2,14 @@
namespace Illuminate\Testing;
+use ArrayAccess;
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Testing\Assert as PHPUnit;
use JsonSerializable;
-class AssertableJsonString
+class AssertableJsonString implements ArrayAccess
{
/**
* The original encoded json.
@@ -327,4 +328,49 @@ protected function jsonSearchStrings($key, $value)
$needle.',',
];
}
+
+ /**
+ * Determine whether an offset exists.
+ *
+ * @param mixed $offset
+ * @return bool
+ */
+ public function offsetExists($offset)
+ {
+ return isset($this->decoded[$offset]);
+ }
+
+ /**
+ * Get the value at the given offset.
+ *
+ * @param string $offset
+ * @return mixed
+ */
+ public function offsetGet($offset)
+ {
+ return $this->decoded[$offset];
+ }
+
+ /**
+ * Set the value at the given offset.
+ *
+ * @param string $offset
+ * @param mixed $value
+ * @return void
+ */
+ public function offsetSet($offset, $value)
+ {
+ $this->decoded[$offset] = $value;
+ }
+
+ /**
+ * Unset the value at the given offset.
+ *
+ * @param string $offset
+ * @return void
+ */
+ public function offsetUnset($offset)
+ {
+ unset($this->decoded[$offset]);
+ }
} | false |
Other | laravel | framework | 06fa47c09419eacd7c82bfedaca41a0956ae6dc9.json | Add support for streamed reads (#34001) | src/Illuminate/Filesystem/FilesystemManager.php | @@ -208,8 +208,10 @@ public function createS3Driver(array $config)
$options = $config['options'] ?? [];
+ $streamReads = $config['stream_reads'] ?? false;
+
return $this->adapt($this->createFlysystem(
- new S3Adapter(new S3Client($s3Config), $s3Config['bucket'], $root, $options), $config
+ new S3Adapter(new S3Client($s3Config), $s3Config['bucket'], $root, $options, $streamReads), $config
));
}
| false |
Other | laravel | framework | 384109ac016e651cb1da84f56b659b4097148139.json | Apply fixes from StyleCI (#33995) | src/Illuminate/Collections/Collection.php | @@ -1092,7 +1092,6 @@ public function chunkWhile(callable $callback)
$previous = $current;
}
-
$chunks[] = new static($chunk);
return new static($chunks); | false |
Other | laravel | framework | e422cedb76bfb689ea3873b37fdb8e4af9d81f79.json | add guard method | src/Illuminate/Session/Middleware/AuthenticateSession.php | @@ -35,12 +35,14 @@ public function __construct(AuthFactory $auth)
*/
public function handle($request, Closure $next)
{
+ $guard = $this->guard();
+
if (! $request->hasSession() || ! $request->user()) {
return $next($request);
}
- if ($this->auth->viaRemember()) {
- $passwordHash = explode('|', $request->cookies->get($this->auth->getRecallerName()))[2];
+ if ($guard->viaRemember()) {
+ $passwordHash = explode('|', $request->cookies->get($guard->getRecallerName()))[2];
if ($passwordHash != $request->user()->getAuthPassword()) {
$this->logout($request);
@@ -87,10 +89,20 @@ protected function storePasswordHashInSession($request)
*/
protected function logout($request)
{
- $this->auth->logoutCurrentDevice();
+ $this->guard()->logoutCurrentDevice();
$request->session()->flush();
throw new AuthenticationException('Unauthenticated.', [$this->auth->getDefaultDriver()]);
}
+
+ /**
+ * Get the guard instance that should be used by the middleware.
+ *
+ * @return \Illuminate\Contracts\Auth\Factory|\Illuminate\Contracts\Auth\Guard
+ */
+ protected function guard()
+ {
+ return $this->auth;
+ }
} | false |
Other | laravel | framework | 7161c83d4f4a28300eb5d1e739c25e3fd7ec5deb.json | Allow nested errors in json assertion (#33989) | src/Illuminate/Testing/TestResponse.php | @@ -729,7 +729,7 @@ public function assertJsonValidationErrors($errors, $responseKey = 'errors')
PHPUnit::assertNotEmpty($errors, 'No validation errors were provided.');
- $jsonErrors = $this->json()[$responseKey] ?? [];
+ $jsonErrors = Arr::get($this->json(), $responseKey) ?? [];
$errorMessage = $jsonErrors
? 'Response has the following JSON validation errors:'. | true |
Other | laravel | framework | 7161c83d4f4a28300eb5d1e739c25e3fd7ec5deb.json | Allow nested errors in json assertion (#33989) | tests/Testing/TestResponseTest.php | @@ -611,6 +611,20 @@ public function testAssertJsonValidationErrorsCustomErrorsName()
$testResponse->assertJsonValidationErrors('foo', 'data');
}
+ public function testAssertJsonValidationErrorsCustomNestedErrorsName()
+ {
+ $data = [
+ 'status' => 'ok',
+ 'data' => ['errors' => ['foo' => 'oops']],
+ ];
+
+ $testResponse = TestResponse::fromBaseResponse(
+ (new Response)->setContent(json_encode($data))
+ );
+
+ $testResponse->assertJsonValidationErrors('foo', 'data.errors');
+ }
+
public function testAssertJsonValidationErrorsCanFail()
{
$this->expectException(AssertionFailedError::class); | true |
Other | laravel | framework | 0a3faed03e24cb5d633abc6cd53781b395952fd7.json | update factory count | src/Illuminate/Database/Eloquent/Factories/HasFactory.php | @@ -13,7 +13,7 @@ trait HasFactory
public static function factory(...$parameters)
{
return Factory::factoryForModel(get_called_class())
- ->count(is_numeric($parameters[0] ?? null) ? $parameters[0] : 1)
+ ->count(is_numeric($parameters[0] ?? null) ? $parameters[0] : null)
->state(is_array($parameters[0] ?? null) ? $parameters[0] : ($parameters[1] ?? []));
}
} | false |
Other | laravel | framework | 46686ae80466bcdf6d9fe1931aeb1408f1f1f72a.json | simulate exit code for closure scheduled tasks | src/Illuminate/Console/Scheduling/CallbackEvent.php | @@ -5,6 +5,7 @@
use Illuminate\Contracts\Container\Container;
use InvalidArgumentException;
use LogicException;
+use Exception;
class CallbackEvent extends Event
{
@@ -76,12 +77,18 @@ public function run(Container $container)
$response = is_object($this->callback)
? $container->call([$this->callback, '__invoke'], $this->parameters)
: $container->call($this->callback, $this->parameters);
+ } catch(Exception $e) {
+ $this->exitCode = 1;
+
+ throw $e;
} finally {
$this->removeMutex();
parent::callAfterCallbacks($container);
}
+ $this->exitCode = $response === false ? 1 : 0;
+
return $response;
}
| true |
Other | laravel | framework | 46686ae80466bcdf6d9fe1931aeb1408f1f1f72a.json | simulate exit code for closure scheduled tasks | tests/Console/Scheduling/CallbackEventTest.php | @@ -0,0 +1,61 @@
+<?php
+
+namespace Illuminate\Tests\Console\Scheduling;
+
+use Illuminate\Console\Scheduling\CallbackEvent;
+use Illuminate\Console\Scheduling\EventMutex;
+use Mockery as m;
+use Orchestra\Testbench\TestCase;
+use Exception;
+
+class CallbackEventTest extends TestCase
+{
+ protected function tearDown(): void
+ {
+ m::close();
+ }
+
+ public function testDefaultResultIsSuccess()
+ {
+ $event = new CallbackEvent(m::mock(EventMutex::class), function() {});
+
+ $event->run($this->app);
+
+ $this->assertSame(0, $event->exitCode);
+ }
+
+ public function testFalseResponseIsFailure()
+ {
+ $event = new CallbackEvent(m::mock(EventMutex::class), function() {
+ return false;
+ });
+
+ $event->run($this->app);
+
+ $this->assertSame(1, $event->exitCode);
+ }
+
+ public function testExceptionIsFailure()
+ {
+ $event = new CallbackEvent(m::mock(EventMutex::class), function() {
+ throw new \Exception;
+ });
+
+ try {
+ $event->run($this->app);
+ } catch(Exception $e) {}
+
+ $this->assertSame(1, $event->exitCode);
+ }
+
+ public function testExceptionBubbles()
+ {
+ $event = new CallbackEvent(m::mock(EventMutex::class), function() {
+ throw new Exception;
+ });
+
+ $this->expectException(Exception::class);
+
+ $event->run($this->app);
+ }
+} | true |
Other | laravel | framework | e90b88bccf104aa90c307e0bcac74688365677b9.json | Remove deprecated method (#33865) | src/Illuminate/Database/Eloquent/Model.php | @@ -345,8 +345,6 @@ public function fill(array $attributes)
$totallyGuarded = $this->totallyGuarded();
foreach ($this->fillableFromArray($attributes) as $key => $value) {
- $key = $this->removeTableFromKey($key);
-
// The developers may choose to place some attributes in the "fillable" array
// which means only those attributes may be set through mass assignment to
// the model, and all others will just get ignored for security reasons.
@@ -391,19 +389,6 @@ public function qualifyColumn($column)
return $this->getTable().'.'.$column;
}
- /**
- * Remove the table name from a given key.
- *
- * @param string $key
- * @return string
- *
- * @deprecated This method is deprecated and will be removed in a future Laravel version.
- */
- protected function removeTableFromKey($key)
- {
- return $key;
- }
-
/**
* Create a new instance of the given model.
* | false |
Other | laravel | framework | 6cc389c9dbd5bf7337826a25f6f09cabfdbf58e8.json | Apply fixes from StyleCI (#33864) | src/Illuminate/Database/Eloquent/Concerns/GuardsAttributes.php | @@ -3,7 +3,6 @@
namespace Illuminate\Database\Eloquent\Concerns;
use Illuminate\Support\Str;
-use LogicException;
trait GuardsAttributes
{ | false |
Other | laravel | framework | 25a313ae4de467b0eacc9d8c427704caed23fda7.json | remove old guarded protection | src/Illuminate/Database/Eloquent/Concerns/GuardsAttributes.php | @@ -250,17 +250,4 @@ protected function fillableFromArray(array $attributes)
return $attributes;
}
-
- /**
- * Ensure the model has a valid guarded configuration.
- *
- * @return void
- */
- protected function ensureModelHasValidGuardState()
- {
- if (! empty($this->getGuarded()) &&
- $this->getGuarded() !== ['*']) {
- throw new LogicException('For added security, guarded attributes are no longer supported. Please use fillable instead.');
- }
- }
} | true |
Other | laravel | framework | 25a313ae4de467b0eacc9d8c427704caed23fda7.json | remove old guarded protection | src/Illuminate/Database/Eloquent/Model.php | @@ -342,8 +342,6 @@ public static function isIgnoringTouch($class = null)
*/
public function fill(array $attributes)
{
- // $this->ensureModelHasValidGuardState();
-
$totallyGuarded = $this->totallyGuarded();
foreach ($this->fillableFromArray($attributes) as $key => $value) { | true |
Other | laravel | framework | a586ad4cf9bfac7ef3602fa770e96af4316c5ca4.json | Handle argon failures robustly (#33856) | src/Illuminate/Hashing/ArgonHasher.php | @@ -60,13 +60,13 @@ public function __construct(array $options = [])
*/
public function make($value, array $options = [])
{
- $hash = password_hash($value, $this->algorithm(), [
+ $hash = @password_hash($value, $this->algorithm(), [
'memory_cost' => $this->memory($options),
'time_cost' => $this->time($options),
'threads' => $this->threads($options),
]);
- if ($hash === false) {
+ if (! is_string($hash)) {
throw new RuntimeException('Argon2 hashing not supported.');
}
| true |
Other | laravel | framework | a586ad4cf9bfac7ef3602fa770e96af4316c5ca4.json | Handle argon failures robustly (#33856) | tests/Hashing/HasherTest.php | @@ -51,6 +51,9 @@ public function testBasicArgon2idHashing()
$this->assertSame('argon2id', password_get_info($value)['algoName']);
}
+ /**
+ * @depends testBasicBcryptHashing
+ */
public function testBasicBcryptVerification()
{
$this->expectException(RuntimeException::class);
@@ -64,6 +67,9 @@ public function testBasicBcryptVerification()
(new BcryptHasher(['verify' => true]))->check('password', $argonHashed);
}
+ /**
+ * @depends testBasicArgon2iHashing
+ */
public function testBasicArgon2iVerification()
{
$this->expectException(RuntimeException::class);
@@ -73,6 +79,9 @@ public function testBasicArgon2iVerification()
(new ArgonHasher(['verify' => true]))->check('password', $bcryptHashed);
}
+ /**
+ * @depends testBasicArgon2idHashing
+ */
public function testBasicArgon2idVerification()
{
$this->expectException(RuntimeException::class); | true |
Other | laravel | framework | 7cd8ca8a308dbc4a31a979fdb0e6684a836da86e.json | Implement LockProvider on DatabaseStore (#33844) | src/Illuminate/Cache/DatabaseStore.php | @@ -4,14 +4,15 @@
use Closure;
use Exception;
+use Illuminate\Contracts\Cache\LockProvider;
use Illuminate\Contracts\Cache\Store;
use Illuminate\Database\ConnectionInterface;
use Illuminate\Database\PostgresConnection;
use Illuminate\Database\QueryException;
use Illuminate\Support\InteractsWithTime;
use Illuminate\Support\Str;
-class DatabaseStore implements Store
+class DatabaseStore implements LockProvider, Store
{
use InteractsWithTime, RetrievesMultipleKeys;
| false |
Other | laravel | framework | d30bc52df0d290dec11c3822f26a89335d15d815.json | Apply fixes from StyleCI (#33861) | src/Illuminate/View/ComponentAttributeBag.php | @@ -117,7 +117,7 @@ public function whereStartsWith($string)
return Str::startsWith($key, $string);
});
}
-
+
/**
* Return a bag of attributes with keys that do not start with the given value / pattern.
* | false |
Other | laravel | framework | 5682bdbc2a14cd982c50981dadfe0df4634084da.json | Support Collection#countBy($key) (#33852) | src/Illuminate/Support/LazyCollection.php | @@ -248,9 +248,9 @@ public function crossJoin(...$arrays)
*/
public function countBy($countBy = null)
{
- if (is_null($countBy)) {
- $countBy = $this->identity();
- }
+ $countBy = is_null($countBy)
+ ? $this->identity()
+ : $this->valueRetriever($countBy);
return new static(function () use ($countBy) {
$counts = []; | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.