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
7880ba75248c849e3137ae9832ec2220ca62d6c6.json
Fix many docblocks (#40589)
src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php
@@ -311,7 +311,7 @@ public function compileGetAllTables($searchPath) /** * Compile the SQL needed to retrieve all view names. * - * @param string|array $schema + * @param string|array $searchPath * @return string */ public function compileGetAllViews($searchPath)
true
Other
laravel
framework
7880ba75248c849e3137ae9832ec2220ca62d6c6.json
Fix many docblocks (#40589)
src/Illuminate/Filesystem/FilesystemAdapter.php
@@ -245,7 +245,7 @@ public function get($path) * * @param string $path * @param string|null $name - * @param array|null $headers + * @param array $headers * @param string|null $disposition * @return \Symfony\Component\HttpFoundation\StreamedResponse */ @@ -279,7 +279,6 @@ public function response($path, $name = null, array $headers = [], $disposition * * @param string $path * @param string|null $name - * @param array|null $headers * @return \Symfony\Component\HttpFoundation\StreamedResponse */ public function download($path, $name = null, array $headers = [])
true
Other
laravel
framework
7880ba75248c849e3137ae9832ec2220ca62d6c6.json
Fix many docblocks (#40589)
src/Illuminate/Foundation/Console/RouteListCommand.php
@@ -399,7 +399,7 @@ public static function getTerminalWidth() /** * Set a callback that should be used when resolving the terminal width. * - * @param \Closure|null $callback + * @param \Closure|null $resolver * @return void */ public static function resolveTerminalWidthUsing($resolver)
true
Other
laravel
framework
7880ba75248c849e3137ae9832ec2220ca62d6c6.json
Fix many docblocks (#40589)
src/Illuminate/Http/Request.php
@@ -139,7 +139,7 @@ public function fullUrlWithQuery(array $query) /** * Get the full URL for the request without the given query string parameters. * - * @param array|string $query + * @param array|string $keys * @return string */ public function fullUrlWithoutQuery($keys)
true
Other
laravel
framework
7880ba75248c849e3137ae9832ec2220ca62d6c6.json
Fix many docblocks (#40589)
src/Illuminate/Queue/Middleware/ThrottlesExceptions.php
@@ -69,7 +69,6 @@ class ThrottlesExceptions * * @param int $maxAttempts * @param int $decayMinutes - * @param string $key * @return void */ public function __construct($maxAttempts = 10, $decayMinutes = 10)
true
Other
laravel
framework
7880ba75248c849e3137ae9832ec2220ca62d6c6.json
Fix many docblocks (#40589)
src/Illuminate/Routing/Console/ControllerMakeCommand.php
@@ -243,7 +243,7 @@ protected function buildFormRequestReplacements(array $replace, $modelClass) /** * Generate the form requests for the given model and classes. * - * @param string $modelName + * @param string $modelClass * @param string $storeRequestClass * @param string $updateRequestClass * @return array
true
Other
laravel
framework
7880ba75248c849e3137ae9832ec2220ca62d6c6.json
Fix many docblocks (#40589)
src/Illuminate/Testing/ParallelTesting.php
@@ -77,7 +77,7 @@ public function __construct(Container $container) /** * Set a callback that should be used when resolving options. * - * @param \Closure|null $callback + * @param \Closure|null $resolver * @return void */ public function resolveOptionsUsing($resolver) @@ -88,7 +88,7 @@ public function resolveOptionsUsing($resolver) /** * Set a callback that should be used when resolving the unique process token. * - * @param \Closure|null $callback + * @param \Closure|null $resolver * @return void */ public function resolveTokenUsing($resolver)
true
Other
laravel
framework
7880ba75248c849e3137ae9832ec2220ca62d6c6.json
Fix many docblocks (#40589)
src/Illuminate/Validation/Concerns/ValidatesAttributes.php
@@ -1530,7 +1530,6 @@ public function validateRequiredIf($attribute, $value, $parameters) * * @param string $attribute * @param mixed $value - * @param mixed $parameters * @return bool */ public function validateProhibited($attribute, $value)
true
Other
laravel
framework
7880ba75248c849e3137ae9832ec2220ca62d6c6.json
Fix many docblocks (#40589)
src/Illuminate/Validation/Validator.php
@@ -667,7 +667,6 @@ protected function getPrimaryAttribute($attribute) * Replace each field parameter which has an escaped dot with the dot placeholder. * * @param array $parameters - * @param array $keys * @return array */ protected function replaceDotInParameters(array $parameters)
true
Other
laravel
framework
ea22e103278516528afceacdaba1bd666ae36139.json
Remove useless imports (#40591)
src/Illuminate/Database/Eloquent/Relations/Concerns/AsPivot.php
@@ -2,7 +2,6 @@ namespace Illuminate\Database\Eloquent\Relations\Concerns; -use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Str;
true
Other
laravel
framework
ea22e103278516528afceacdaba1bd666ae36139.json
Remove useless imports (#40591)
src/Illuminate/Support/Pluralizer.php
@@ -2,7 +2,6 @@ namespace Illuminate\Support; -use Doctrine\Inflector\Inflector; use Doctrine\Inflector\InflectorFactory; class Pluralizer
true
Other
laravel
framework
ea22e103278516528afceacdaba1bd666ae36139.json
Remove useless imports (#40591)
src/Illuminate/Testing/TestComponent.php
@@ -4,7 +4,6 @@ use Illuminate\Testing\Assert as PHPUnit; use Illuminate\Testing\Constraints\SeeInOrder; -use Illuminate\View\Component; class TestComponent {
true
Other
laravel
framework
ea22e103278516528afceacdaba1bd666ae36139.json
Remove useless imports (#40591)
tests/Container/ContainerTest.php
@@ -5,7 +5,6 @@ use Illuminate\Container\Container; use Illuminate\Container\EntryNotFoundException; use Illuminate\Contracts\Container\BindingResolutionException; -use Illuminate\Contracts\Container\CircularDependencyException; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerExceptionInterface; use stdClass; @@ -606,7 +605,7 @@ public function testContainerCanResolveClasses() // public function testContainerCanCatchCircularDependency() // { - // $this->expectException(CircularDependencyException::class); + // $this->expectException(\Illuminate\Contracts\Container\CircularDependencyException::class); // $container = new Container; // $container->get(CircularAStub::class);
true
Other
laravel
framework
ea22e103278516528afceacdaba1bd666ae36139.json
Remove useless imports (#40591)
tests/Routing/RouteRegistrarTest.php
@@ -7,7 +7,6 @@ use Illuminate\Container\Container; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Http\Request; -use Illuminate\Routing\Route; use Illuminate\Routing\Router; use Mockery as m; use PHPUnit\Framework\TestCase;
true
Other
laravel
framework
6bb9b4d992e2914a5c94787144138413411ee748.json
Remove old PHP 7 workarounds (#40558)
tests/Cache/CacheMemcachedStoreTest.php
@@ -71,10 +71,8 @@ public function testSetMethodProperlyCallsMemcache() public function testIncrementMethodProperlyCallsMemcache() { - /* @link https://github.com/php-memcached-dev/php-memcached/pull/468 */ - if (version_compare(phpversion(), '8.0.0', '>=')) { - $this->markTestSkipped('Test broken due to parse error in PHP Memcached.'); - } + /** @link https://github.com/php-memcached-dev/php-memcached/pull/468 */ + $this->markTestSkipped('Test broken due to parse error in PHP Memcached.'); $memcached = m::mock(Memcached::class); $memcached->shouldReceive('increment')->with('foo', 5)->once()->andReturn(5); @@ -85,10 +83,8 @@ public function testIncrementMethodProperlyCallsMemcache() public function testDecrementMethodProperlyCallsMemcache() { - /* @link https://github.com/php-memcached-dev/php-memcached/pull/468 */ - if (version_compare(phpversion(), '8.0.0', '>=')) { - $this->markTestSkipped('Test broken due to parse error in PHP Memcached.'); - } + /** @link https://github.com/php-memcached-dev/php-memcached/pull/468 */ + $this->markTestSkipped('Test broken due to parse error in PHP Memcached.'); $memcached = m::mock(Memcached::class); $memcached->shouldReceive('decrement')->with('foo', 5)->once()->andReturn(0);
true
Other
laravel
framework
6bb9b4d992e2914a5c94787144138413411ee748.json
Remove old PHP 7 workarounds (#40558)
tests/Database/DatabaseEloquentBelongsToTest.php
@@ -78,16 +78,10 @@ public function testEagerConstraintsAreProperlyAdded() public function testIdsInEagerConstraintsCanBeZero() { - $keys = ['foreign.value', 0]; - - if (version_compare(PHP_VERSION, '8.0.0-dev', '>=')) { - sort($keys); - } - $relation = $this->getRelation(); $relation->getRelated()->shouldReceive('getKeyName')->andReturn('id'); $relation->getRelated()->shouldReceive('getKeyType')->andReturn('int'); - $relation->getQuery()->shouldReceive('whereIntegerInRaw')->once()->with('relation.id', $keys); + $relation->getQuery()->shouldReceive('whereIntegerInRaw')->once()->with('relation.id', [0, 'foreign.value']); $models = [new EloquentBelongsToModelStub, new EloquentBelongsToModelStubWithZeroId]; $relation->addEagerConstraints($models); }
true
Other
laravel
framework
6bb9b4d992e2914a5c94787144138413411ee748.json
Remove old PHP 7 workarounds (#40558)
tests/Database/DatabaseEloquentMorphToTest.php
@@ -20,24 +20,23 @@ protected function tearDown(): void m::close(); } + /** + * @requires PHP >= 8.1 + */ public function testLookupDictionaryIsProperlyConstructedForEnums() { - if (version_compare(PHP_VERSION, '8.1') < 0) { - $this->markTestSkipped('PHP 8.1 is required'); + $relation = $this->getRelation(); + $relation->addEagerConstraints([ + $one = (object) ['morph_type' => 'morph_type_2', 'foreign_key' => TestEnum::test], + ]); + $dictionary = $relation->getDictionary(); + $relation->getDictionary(); + $enumKey = TestEnum::test; + if (isset($enumKey->value)) { + $value = $dictionary['morph_type_2'][$enumKey->value][0]->foreign_key; + $this->assertEquals(TestEnum::test, $value); } else { - $relation = $this->getRelation(); - $relation->addEagerConstraints([ - $one = (object) ['morph_type' => 'morph_type_2', 'foreign_key' => TestEnum::test], - ]); - $dictionary = $relation->getDictionary(); - $relation->getDictionary(); - $enumKey = TestEnum::test; - if (isset($enumKey->value)) { - $value = $dictionary['morph_type_2'][$enumKey->value][0]->foreign_key; - $this->assertEquals(TestEnum::test, $value); - } else { - $this->fail('An enum should contain value property'); - } + $this->fail('An enum should contain value property'); } }
true
Other
laravel
framework
6bb9b4d992e2914a5c94787144138413411ee748.json
Remove old PHP 7 workarounds (#40558)
tests/Integration/Database/EloquentModelEnumCastingTest.php
@@ -12,7 +12,7 @@ } /** - * @requires PHP 8.1 + * @requires PHP >= 8.1 */ class EloquentModelEnumCastingTest extends DatabaseTestCase {
true
Other
laravel
framework
6bb9b4d992e2914a5c94787144138413411ee748.json
Remove old PHP 7 workarounds (#40558)
tests/Integration/Foundation/DiscoverEventsTest.php
@@ -32,9 +32,6 @@ class_alias(ListenerInterface::class, 'Tests\Integration\Foundation\Fixtures\Eve ], $events); } - /** - * @requires PHP >= 8 - */ public function testUnionEventsCanBeDiscovered() { class_alias(UnionListener::class, 'Tests\Integration\Foundation\Fixtures\EventDiscovery\UnionListeners\UnionListener');
true
Other
laravel
framework
6bb9b4d992e2914a5c94787144138413411ee748.json
Remove old PHP 7 workarounds (#40558)
tests/Integration/Queue/ModelSerializationTest.php
@@ -274,9 +274,6 @@ public function testItCanUnserializeCustomCollection() $this->assertInstanceOf(ModelSerializationTestCustomUserCollection::class, $unserialized->users); } - /** - * @requires PHP >= 7.4 - */ public function testItSerializesTypedProperties() { require_once __DIR__.'/typed-properties.php';
true
Other
laravel
framework
6bb9b4d992e2914a5c94787144138413411ee748.json
Remove old PHP 7 workarounds (#40558)
tests/Integration/Routing/ImplicitBackedEnumRouteBindingTest.php
@@ -10,7 +10,7 @@ } /** - * @requires PHP 8.1 + * @requires PHP >= 8.1 */ class ImplicitBackedEnumRouteBindingTest extends TestCase {
true
Other
laravel
framework
6bb9b4d992e2914a5c94787144138413411ee748.json
Remove old PHP 7 workarounds (#40558)
tests/Routing/ImplicitRouteBindingTest.php
@@ -16,7 +16,7 @@ class ImplicitRouteBindingTest extends TestCase { /** - * @requires PHP 8.1 + * @requires PHP >= 8.1 */ public function test_it_can_resolve_the_implicit_backed_enum_route_bindings_for_the_given_route() { @@ -37,7 +37,7 @@ public function test_it_can_resolve_the_implicit_backed_enum_route_bindings_for_ } /** - * @requires PHP 8.1 + * @requires PHP >= 8.1 */ public function test_it_does_not_resolve_implicit_non_backed_enum_route_bindings_for_the_given_route() { @@ -59,7 +59,7 @@ public function test_it_does_not_resolve_implicit_non_backed_enum_route_bindings } /** - * @requires PHP 8.1 + * @requires PHP >= 8.1 */ public function test_implicit_backed_enum_internal_exception() {
true
Other
laravel
framework
6bb9b4d992e2914a5c94787144138413411ee748.json
Remove old PHP 7 workarounds (#40558)
tests/Support/SupportReflectorTest.php
@@ -48,9 +48,6 @@ public function testParentClassName() $this->assertSame(A::class, Reflector::getParameterClassName($method->getParameters()[0])); } - /** - * @requires PHP >= 8 - */ public function testUnionTypeName() { $method = (new ReflectionClass(C::class))->getMethod('f');
true
Other
laravel
framework
6bb9b4d992e2914a5c94787144138413411ee748.json
Remove old PHP 7 workarounds (#40558)
tests/Support/SupportReflectsClosuresTest.php
@@ -64,9 +64,6 @@ public function testItThrowsWhenNoFirstParameterType() }); } - /** - * @requires PHP >= 8 - */ public function testItWorksWithUnionTypes() { $types = ReflectsClosuresClass::reflectFirstAll(function (ExampleParameter $a, $b) {
true
Other
laravel
framework
7fd7ad17cf5077fcbdd12b3d39003b4726afa447.json
Add extra tests for validation (#40543)
tests/Validation/ValidationValidatorTest.php
@@ -4225,6 +4225,12 @@ public function testBeforeAndAfterWithFormat() $v = new Validator($trans, ['start' => '31/12/2012', 'ends' => null], ['start' => 'date_format:d/m/Y|before:ends', 'ends' => 'nullable|date_format:d/m/Y|after:start']); $this->assertTrue($v->passes()); + $v = new Validator($trans, ['start' => '31/12/2012', 'ends' => null], ['start' => 'before:ends']); + $this->assertTrue($v->fails()); + + $v = new Validator($trans, ['start' => '31/12/2012', 'ends' => null], ['start' => 'before:ends', 'ends' => 'nullable']); + $this->assertTrue($v->fails()); + $v = new Validator($trans, ['x' => date('d/m/Y')], ['x' => 'date_format:d/m/Y|after:yesterday|before:tomorrow']); $this->assertTrue($v->passes()); @@ -4355,6 +4361,27 @@ public function testWeakBeforeAndAfter() $v = new Validator($trans, ['x' => '17:44'], ['x' => 'date_format:H:i|after_or_equal:17:45']); $this->assertTrue($v->fails()); + + $v = new Validator($trans, ['foo' => '2012-01-14', 'bar' => '2012-01-15'], ['foo' => 'before_or_equal:bar']); + $this->assertTrue($v->passes()); + + $v = new Validator($trans, ['foo' => '2012-01-15', 'bar' => '2012-01-15'], ['foo' => 'before_or_equal:bar']); + $this->assertTrue($v->passes()); + + $v = new Validator($trans, ['foo' => '2012-01-15 13:00', 'bar' => '2012-01-15 12:00'], ['foo' => 'before_or_equal:bar']); + $this->assertTrue($v->fails()); + + $v = new Validator($trans, ['foo' => '2012-01-15 11:00', 'bar' => null], ['foo' => 'date_format:Y-m-d H:i|before_or_equal:bar', 'bar' => 'date_format:Y-m-d H:i']); + $this->assertTrue($v->fails()); + + $v = new Validator($trans, ['foo' => '2012-01-15 11:00', 'bar' => null], ['foo' => 'date_format:Y-m-d H:i|before_or_equal:bar', 'bar' => 'date_format:Y-m-d H:i|nullable']); + $this->assertTrue($v->passes()); + + $v = new Validator($trans, ['foo' => '2012-01-15 11:00', 'bar' => null], ['foo' => 'before_or_equal:bar']); + $this->assertTrue($v->fails()); + + $v = new Validator($trans, ['foo' => '2012-01-15 11:00', 'bar' => null], ['foo' => 'before_or_equal:bar', 'bar' => 'nullable']); + $this->assertTrue($v->fails()); } public function testSometimesAddingRules()
false
Other
laravel
framework
a9c50095980e6f24ca23c811fa55752e0f50dd6c.json
Add better bitwise operators support
src/Illuminate/Database/Query/Builder.php
@@ -203,6 +203,15 @@ class Builder 'not similar to', 'not ilike', '~~*', '!~~*', ]; + /** + * All of the available binary operators. + * + * @var string[] + */ + public $binaryOperators = [ + '&', '|', '^', '<<', '>>', '&~', + ]; + /** * Whether to use write pdo for the select. * @@ -754,6 +763,10 @@ public function where($column, $operator = null, $value = null, $boolean = 'and' } } + if ($this->isBinaryOperator($operator)) { + $type = 'Binary'; + } + // Now that we are working with just a simple query we can put the elements // in our array and add the query binding to our array of bindings that // will be bound to each SQL statements when it is finally executed. @@ -837,6 +850,12 @@ protected function invalidOperator($operator) ! in_array(strtolower($operator), $this->grammar->getOperators(), true); } + protected function isBinaryOperator($operator) + { + return in_array(strtolower($operator), $this->binaryOperators, true) || + in_array(strtolower($operator), $this->grammar->getBinaryOperators(), true); + } + /** * Add an "or where" clause to the query. * @@ -1915,6 +1934,10 @@ public function having($column, $operator = null, $value = null, $boolean = 'and [$value, $operator] = [$operator, '=']; } + if ($this->isBinaryOperator($operator)) { + $type = 'binary'; + } + $this->havings[] = compact('type', 'column', 'operator', 'value', 'boolean'); if (! $value instanceof Expression) {
true
Other
laravel
framework
a9c50095980e6f24ca23c811fa55752e0f50dd6c.json
Add better bitwise operators support
src/Illuminate/Database/Query/Grammars/Grammar.php
@@ -18,6 +18,13 @@ class Grammar extends BaseGrammar */ protected $operators = []; + /** + * The grammar specific binary operators. + * + * @var array + */ + protected $binaryOperators = []; + /** * The components that make up a select clause. * @@ -255,6 +262,15 @@ protected function whereBasic(Builder $query, $where) return $this->wrap($where['column']).' '.$operator.' '.$value; } + protected function whereBinary(Builder $query, $where) + { + $value = $this->parameter($where['value']); + + $operator = str_replace('?', '??', $where['operator']); + + return '('.$this->wrap($where['column']).' '.$operator.' '.$value.') != 0'; + } + /** * Compile a "where in" clause. * @@ -571,7 +587,8 @@ protected function whereJsonContains(Builder $query, $where) $not = $where['not'] ? 'not ' : ''; return $not.$this->compileJsonContains( - $where['column'], $this->parameter($where['value']) + $where['column'], + $this->parameter($where['value']) ); } @@ -610,7 +627,9 @@ public function prepareBindingForJsonContains($binding) protected function whereJsonLength(Builder $query, $where) { return $this->compileJsonLength( - $where['column'], $where['operator'], $this->parameter($where['value']) + $where['column'], + $where['operator'], + $this->parameter($where['value']) ); } @@ -682,6 +701,8 @@ protected function compileHaving(array $having) return $having['boolean'].' '.$having['sql']; } elseif ($having['type'] === 'between') { return $this->compileHavingBetween($having); + } elseif ($having['type'] === 'binary') { + return $this->compileHavingBinary($having); } return $this->compileBasicHaving($having); @@ -721,6 +742,21 @@ protected function compileHavingBetween($having) return $having['boolean'].' '.$column.' '.$between.' '.$min.' and '.$max; } + /** + * Compile a having clause involving a binary operator. + * + * @param array $having + * @return string + */ + protected function compileHavingBinary($having) + { + $column = $this->wrap($having['column']); + + $parameter = $this->parameter($having['value']); + + return $having['boolean'].' ('.$column.' '.$having['operator'].' '.$parameter.') != 0'; + } + /** * Compile the "order by" portions of the query. * @@ -1296,4 +1332,14 @@ public function getOperators() { return $this->operators; } + + /** + * Get the grammar specific binary operators. + * + * @return array + */ + public function getBinaryOperators() + { + return $this->binaryOperators; + } }
true
Other
laravel
framework
a9c50095980e6f24ca23c811fa55752e0f50dd6c.json
Add better bitwise operators support
src/Illuminate/Database/Query/Grammars/PostgresGrammar.php
@@ -21,6 +21,15 @@ class PostgresGrammar extends Grammar 'is distinct from', 'is not distinct from', ]; + /** + * The grammar specific binary operators. + * + * @var array + */ + protected $binaryOperators = [ + '~', '&', '|', '#', '<<', '>>', '<<=', '>>=', + ]; + /** * {@inheritdoc} *
true
Other
laravel
framework
a9c50095980e6f24ca23c811fa55752e0f50dd6c.json
Add better bitwise operators support
tests/Database/DatabaseQueryBuilderTest.php
@@ -3209,6 +3209,25 @@ public function testMySqlSoundsLikeOperator() $this->assertEquals(['John Doe'], $builder->getBindings()); } + public function testBinaryOperators() + { + $builder = $this->getBuilder(); + $builder->select('*')->from('users')->where('bar', '&', 1); + $this->assertSame('select * from "users" where ("bar" & ?) != 0', $builder->toSql()); + + $builder = $this->getPostgresBuilder(); + $builder->select('*')->from('users')->where('bar', '#', 1); + $this->assertSame('select * from "users" where ("bar" # ?) != 0', $builder->toSql()); + + $builder = $this->getBuilder(); + $builder->select('*')->from('users')->having('bar', '&', 1); + $this->assertSame('select * from "users" having ("bar" & ?) != 0', $builder->toSql()); + + $builder = $this->getPostgresBuilder(); + $builder->select('*')->from('users')->having('bar', '#', 1); + $this->assertSame('select * from "users" having ("bar" # ?) != 0', $builder->toSql()); + } + public function testMergeWheresCanMergeWheresAndBindings() { $builder = $this->getBuilder();
true
Other
laravel
framework
9d19d1ece898ccbc0193a89a58a6500b5fb6c146.json
Add ability to nested validation rules
src/Illuminate/Validation/NestedRules.php
@@ -0,0 +1,55 @@ +<?php + +namespace Illuminate\Validation; + +use Illuminate\Support\Arr; + +class NestedRules +{ + /** + * The callback to execute. + * + * @var callable + */ + protected $callback; + + /** + * Create a new nested rule instance. + * + * @param callable $callback + * @return void + */ + public function __construct(callable $callback) + { + $this->callback = $callback; + } + + /** + * Compile the callback into an array of rules. + * + * @param string $attribute + * @param mixed $value + * @param mixed $data + * @return \stdClass + */ + public function compile($attribute, $value, $data = null) + { + $rules = call_user_func($this->callback, $attribute, $value, $data); + + $parser = new ValidationRuleParser( + Arr::undot(Arr::wrap($data)) + ); + + if (is_array($rules) && Arr::isAssoc($rules)) { + $nested = []; + + foreach ($rules as $key => $rule) { + $nested[$attribute.'.'.$key] = $rule; + } + + return $parser->explode($nested); + } + + return $parser->explode([$attribute => $rules]); + } +}
true
Other
laravel
framework
9d19d1ece898ccbc0193a89a58a6500b5fb6c146.json
Add ability to nested validation rules
src/Illuminate/Validation/Rule.php
@@ -28,6 +28,17 @@ public static function when($condition, $rules, $defaultRules = []) return new ConditionalRules($condition, $rules, $defaultRules); } + /** + * Create a new nested rule set. + * + * @param callable $callback + * @return \Illuminate\Validation\NestedRules + */ + public static function nested($callback) + { + return new NestedRules($callback); + } + /** * Get a dimensions constraint builder instance. * @@ -103,4 +114,4 @@ public static function unique($table, $column = 'NULL') { return new Unique($table, $column); } -} +} \ No newline at end of file
true
Other
laravel
framework
9d19d1ece898ccbc0193a89a58a6500b5fb6c146.json
Add ability to nested validation rules
src/Illuminate/Validation/ValidationRuleParser.php
@@ -68,7 +68,7 @@ protected function explodeRules($rules) unset($rules[$key]); } else { - $rules[$key] = $this->explodeExplicitRule($rule); + $rules[$key] = $this->explodeExplicitRule($rule, $key); } } @@ -79,26 +79,34 @@ protected function explodeRules($rules) * Explode the explicit rule into an array if necessary. * * @param mixed $rule + * @param string $attribute * @return array */ - protected function explodeExplicitRule($rule) + protected function explodeExplicitRule($rule, $attribute) { if (is_string($rule)) { return explode('|', $rule); } elseif (is_object($rule)) { - return [$this->prepareRule($rule)]; + return Arr::wrap($this->prepareRule($rule, $attribute)); } - return array_map([$this, 'prepareRule'], $rule); + $attributes = array_fill( + array_key_first($rule), count($rule), $attribute + ); + + return array_map( + [$this, 'prepareRule'], $rule, $attributes + ); } /** * Prepare the given rule for the Validator. * * @param mixed $rule + * @param string $attribute * @return mixed */ - protected function prepareRule($rule) + protected function prepareRule($rule, $attribute) { if ($rule instanceof Closure) { $rule = new ClosureValidationRule($rule); @@ -111,6 +119,12 @@ protected function prepareRule($rule) return $rule; } + if ($rule instanceof NestedRules) { + return $rule->compile( + $attribute, $this->data[$attribute] ?? null, Arr::dot($this->data) + )->rules[$attribute]; + } + return (string) $rule; } @@ -130,10 +144,22 @@ protected function explodeWildcardRules($results, $attribute, $rules) foreach ($data as $key => $value) { if (Str::startsWith($key, $attribute) || (bool) preg_match('/^'.$pattern.'\z/', $key)) { - foreach ((array) $rules as $rule) { - $this->implicitAttributes[$attribute][] = $key; - - $results = $this->mergeRules($results, $key, $rule); + foreach (Arr::flatten((array) $rules) as $rule) { + if ($rule instanceof NestedRules) { + $compiled = $rule->compile($key, $value, $data); + + $this->implicitAttributes = array_merge_recursive( + $compiled->implicitAttributes, + $this->implicitAttributes, + [$attribute => [$key]] + ); + + $results = $this->mergeRules($results, $compiled->rules); + } else { + $this->implicitAttributes[$attribute][] = $key; + + $results = $this->mergeRules($results, $key, $rule); + } } } } @@ -177,7 +203,7 @@ protected function mergeRulesForAttribute($results, $attribute, $rules) $merge = head($this->explodeRules([$rules])); $results[$attribute] = array_merge( - isset($results[$attribute]) ? $this->explodeExplicitRule($results[$attribute]) : [], $merge + isset($results[$attribute]) ? $this->explodeExplicitRule($results[$attribute], $attribute) : [], $merge ); return $results; @@ -191,7 +217,7 @@ protected function mergeRulesForAttribute($results, $attribute, $rules) */ public static function parse($rule) { - if ($rule instanceof RuleContract) { + if ($rule instanceof RuleContract || $rule instanceof NestedRules) { return [$rule, []]; } @@ -302,4 +328,4 @@ public static function filterConditionalRules($rules, array $data = []) })->filter()->flatten(1)->values()->all()]; })->all(); } -} +} \ No newline at end of file
true
Other
laravel
framework
9d19d1ece898ccbc0193a89a58a6500b5fb6c146.json
Add ability to nested validation rules
tests/Validation/ValidationNestedRulesTest.php
@@ -0,0 +1,215 @@ +<?php + +namespace Illuminate\Tests\Validation; + +use Illuminate\Translation\ArrayLoader; +use Illuminate\Translation\Translator; +use Illuminate\Validation\Rule; +use Illuminate\Validation\Validator; +use Mockery as m; +use PHPUnit\Framework\TestCase; + +class ValidationNestedRulesTest extends TestCase +{ + public function testNestedCallbacksCanProperlySegmentRules() + { + $data = [ + 'items' => [ + // Contains duplicate ID. + ['discounts' => [['id' => 1], ['id' => 1], ['id' => 2]]], + ['discounts' => [['id' => 1], ['id' => 2]]], + ], + ]; + + $rules = [ + 'items.*' => Rule::nested(function () { + return ['discounts.*.id' => 'distinct']; + }), + ]; + + $trans = $this->getIlluminateArrayTranslator(); + + $v = new Validator($trans, $data, $rules); + + $this->assertFalse($v->passes()); + + $this->assertEquals([ + 'items.0.discounts.0.id' => ['validation.distinct'], + 'items.0.discounts.1.id' => ['validation.distinct'], + ], $v->getMessageBag()->toArray()); + } + + public function testNestedCallbacksCanBeRecursivelyNested() + { + $data = [ + 'items' => [ + // Contains duplicate ID. + ['discounts' => [['id' => 1], ['id' => 1], ['id' => 2]]], + ['discounts' => [['id' => 1], ['id' => 2]]], + ], + ]; + + $rules = [ + 'items.*' => Rule::nested(function () { + return [ + 'discounts.*.id' => Rule::nested(function () { + return 'distinct'; + }), + ]; + }), + ]; + + $trans = $this->getIlluminateArrayTranslator(); + + $v = new Validator($trans, $data, $rules); + + $this->assertFalse($v->passes()); + + $this->assertEquals([ + 'items.0.discounts.0.id' => ['validation.distinct'], + 'items.0.discounts.1.id' => ['validation.distinct'], + ], $v->getMessageBag()->toArray()); + } + + public function testNestedCallbacksCanReturnMultipleValidationRules() + { + $data = [ + 'items' => [ + [ + 'discounts' => [ + ['id' => 1, 'percent' => 30, 'discount' => 1400], + ['id' => 1, 'percent' => -1, 'discount' => 12300], + ['id' => 2, 'percent' => 120, 'discount' => 1200], + ], + ], + [ + 'discounts' => [ + ['id' => 1, 'percent' => 30, 'discount' => 'invalid'], + ['id' => 2, 'percent' => 'invalid', 'discount' => 1250], + ['id' => 3, 'percent' => 'invalid', 'discount' => 'invalid'], + ], + ], + ], + ]; + $rules = [ + 'items.*' => Rule::nested(function () { + return [ + 'discounts.*.id' => 'distinct', + 'discounts.*' => Rule::nested(function () { + return [ + 'id' => 'distinct', + 'percent' => 'numeric|min:0|max:100', + 'discount' => 'numeric', + ]; + }), + ]; + }), + ]; + + $trans = $this->getIlluminateArrayTranslator(); + + $v = new Validator($trans, $data, $rules); + + $this->assertFalse($v->passes()); + + $this->assertEquals([ + 'items.0.discounts.0.id' => ['validation.distinct'], + 'items.0.discounts.1.id' => ['validation.distinct'], + 'items.0.discounts.1.percent' => ['validation.min.numeric'], + 'items.0.discounts.2.percent' => ['validation.max.numeric'], + 'items.1.discounts.0.discount' => ['validation.numeric'], + 'items.1.discounts.1.percent' => ['validation.numeric'], + 'items.1.discounts.2.percent' => ['validation.numeric'], + 'items.1.discounts.2.discount' => ['validation.numeric'], + ], $v->getMessageBag()->toArray()); + } + + public function testNestedCallbacksCanReturnArraysOfValidationRules() + { + $data = [ + 'items' => [ + // Contains duplicate ID. + ['discounts' => [['id' => 1], ['id' => 1], ['id' => 2]]], + ['discounts' => [['id' => 1], ['id' => 'invalid']]], + ], + ]; + + $rules = [ + 'items.*' => Rule::nested(function () { + return ['discounts.*.id' => ['distinct', 'numeric']]; + }), + ]; + + $trans = $this->getIlluminateArrayTranslator(); + + $v = new Validator($trans, $data, $rules); + + $this->assertFalse($v->passes()); + + $this->assertEquals([ + 'items.0.discounts.0.id' => ['validation.distinct'], + 'items.0.discounts.1.id' => ['validation.distinct'], + 'items.1.discounts.1.id' => ['validation.numeric'], + ], $v->getMessageBag()->toArray()); + } + + public function testNestedCallbacksCanReturnDifferentRules() + { + $data = [ + 'items' => [ + [ + 'discounts' => [ + ['id' => 1, 'type' => 'percent', 'discount' => 120], + ['id' => 1, 'type' => 'absolute', 'discount' => 100], + ['id' => 2, 'type' => 'percent', 'discount' => 50], + ], + ], + [ + 'discounts' => [ + ['id' => 2, 'type' => 'percent', 'discount' => 'invalid'], + ['id' => 3, 'type' => 'absolute', 'discount' => 2000], + ], + ], + ], + ]; + + $rules = [ + 'items.*' => Rule::nested(function () { + return [ + 'discounts.*.id' => 'distinct', + 'discounts.*.type' => 'in:percent,absolute', + 'discounts.*' => Rule::nested(function ($attribute, $value) { + return $value['type'] === 'percent' + ? ['discount' => 'numeric|min:0|max:100'] + : ['discount' => 'numeric']; + }), + ]; + }), + ]; + + $trans = $this->getIlluminateArrayTranslator(); + + $v = new Validator($trans, $data, $rules); + + $this->assertFalse($v->passes()); + + $this->assertEquals([ + 'items.0.discounts.0.id' => ['validation.distinct'], + 'items.0.discounts.1.id' => ['validation.distinct'], + 'items.0.discounts.0.discount' => ['validation.max.numeric'], + 'items.1.discounts.0.discount' => ['validation.numeric'], + ], $v->getMessageBag()->toArray()); + } + + protected function getTranslator() + { + return m::mock(TranslatorContract::class); + } + + public function getIlluminateArrayTranslator() + { + return new Translator( + new ArrayLoader, 'en' + ); + } +}
true
Other
laravel
framework
9d19d1ece898ccbc0193a89a58a6500b5fb6c146.json
Add ability to nested validation rules
tests/Validation/ValidationRuleParserTest.php
@@ -9,7 +9,7 @@ class ValidationRuleParserTest extends TestCase { - public function test_conditional_rules_are_properly_expanded_and_filtered() + public function testConditionalRulesAreProperlyExpandedAndFiltered() { $rules = ValidationRuleParser::filterConditionalRules([ 'name' => Rule::when(true, ['required', 'min:2']), @@ -32,7 +32,7 @@ public function test_conditional_rules_are_properly_expanded_and_filtered() ], $rules); } - public function test_empty_rules_are_preserved() + public function testEmptyRulesArePreserved() { $rules = ValidationRuleParser::filterConditionalRules([ 'name' => [], @@ -47,7 +47,7 @@ public function test_empty_rules_are_preserved() ], $rules); } - public function test_conditional_rules_with_default() + public function testConditionalRulesWithDefault() { $rules = ValidationRuleParser::filterConditionalRules([ 'name' => Rule::when(true, ['required', 'min:2'], ['string', 'max:10']), @@ -66,7 +66,7 @@ public function test_conditional_rules_with_default() ], $rules); } - public function test_empty_conditional_rules_are_preserved() + public function testEmptyConditionalRulesArePreserved() { $rules = ValidationRuleParser::filterConditionalRules([ 'name' => Rule::when(true, '', ['string', 'max:10']), @@ -80,4 +80,169 @@ public function test_empty_conditional_rules_are_preserved() 'password' => ['string', 'max:10'], ], $rules); } -} + + public function testExplodeGeneratesNestedRules() + { + $parser = (new ValidationRuleParser([ + 'users' => [ + ['name' => 'Taylor Otwell'], + ], + ])); + + $results = $parser->explode([ + 'users.*.name' => Rule::nested(function ($attribute, $value, $data) { + $this->assertEquals('users.0.name', $attribute); + $this->assertEquals('Taylor Otwell', $value); + $this->assertEquals($data['users.0.name'], 'Taylor Otwell'); + + return [Rule::requiredIf(true)]; + }), + ]); + + $this->assertEquals(['users.0.name' => ['required']], $results->rules); + $this->assertEquals(['users.*.name' => ['users.0.name']], $results->implicitAttributes); + } + + public function testExplodeGeneratesNestedRulesForNonNestedData() + { + $parser = (new ValidationRuleParser([ + 'name' => 'Taylor Otwell', + ])); + + $results = $parser->explode([ + 'name' => Rule::nested(function ($attribute, $value, $data = null) { + $this->assertEquals('name', $attribute); + $this->assertEquals('Taylor Otwell', $value); + $this->assertEquals(['name' => 'Taylor Otwell'], $data); + + return 'required'; + }), + ]); + + $this->assertEquals(['name' => ['required']], $results->rules); + $this->assertEquals([], $results->implicitAttributes); + } + + public function testExplodeHandlesArraysOfNestedRules() + { + $parser = (new ValidationRuleParser([ + 'users' => [ + ['name' => 'Taylor Otwell'], + ['name' => 'Abigail Otwell'], + ], + ])); + + $results = $parser->explode([ + 'users.*.name' => [ + Rule::nested(function ($attribute, $value, $data) { + $this->assertEquals([ + 'users.0.name' => 'Taylor Otwell', + 'users.1.name' => 'Abigail Otwell', + ], $data); + + return [Rule::requiredIf(true)]; + }), + Rule::nested(function ($attribute, $value, $data) { + $this->assertEquals([ + 'users.0.name' => 'Taylor Otwell', + 'users.1.name' => 'Abigail Otwell', + ], $data); + + return [ + $value === 'Taylor Otwell' + ? Rule::in('taylor') + : Rule::in('abigail'), + ]; + }), + ], + ]); + + $this->assertEquals([ + 'users.0.name' => ['required', 'in:"taylor"'], + 'users.1.name' => ['required', 'in:"abigail"'], + ], $results->rules); + + $this->assertEquals([ + 'users.*.name' => [ + 'users.0.name', + 'users.0.name', + 'users.1.name', + 'users.1.name', + ], + ], $results->implicitAttributes); + } + + public function testExplodeHandlesRecursivelyNestedRules() + { + $parser = (new ValidationRuleParser([ + 'users' => [['name' => 'Taylor Otwell']], + ])); + + $results = $parser->explode([ + 'users.*.name' => [ + Rule::nested(function ($attribute, $value, $data) { + $this->assertEquals('users.0.name', $attribute); + $this->assertEquals('Taylor Otwell', $value); + $this->assertEquals(['users.0.name' => 'Taylor Otwell'], $data); + + return Rule::nested(function ($attribute, $value, $data) { + $this->assertEquals('users.0.name', $attribute); + $this->assertNull($value); + $this->assertEquals(['users.0.name' => 'Taylor Otwell'], $data); + + return Rule::nested(function ($attribute, $value, $data) { + $this->assertEquals('users.0.name', $attribute); + $this->assertNull($value); + $this->assertEquals(['users.0.name' => 'Taylor Otwell'], $data); + + return [Rule::requiredIf(true)]; + }); + }); + }), + ], + ]); + + $this->assertEquals(['users.0.name' => ['required']], $results->rules); + $this->assertEquals(['users.*.name' => ['users.0.name']], $results->implicitAttributes); + } + + public function testExplodeHandlesSegmentingNestedRules() + { + $parser = (new ValidationRuleParser([ + 'items' => [ + ['discounts' => [['id' => 1], ['id' => 2]]], + ['discounts' => [['id' => 1], ['id' => 2]]], + ], + ])); + + $rules = [ + 'items.*' => Rule::nested(function () { + return ['discounts.*.id' => 'distinct']; + }), + ]; + + $results = $parser->explode($rules); + + $this->assertEquals([ + 'items.0.discounts.0.id' => ['distinct'], + 'items.0.discounts.1.id' => ['distinct'], + 'items.1.discounts.0.id' => ['distinct'], + 'items.1.discounts.1.id' => ['distinct'], + ], $results->rules); + + $this->assertEquals([ + 'items.1.discounts.*.id' => [ + 'items.1.discounts.0.id', + 'items.1.discounts.1.id', + ], + 'items.0.discounts.*.id' => [ + 'items.0.discounts.0.id', + 'items.0.discounts.1.id', + ], + 'items.*' => [ + 'items.0', + 'items.1', + ], + ], $results->implicitAttributes); + } +} \ No newline at end of file
true
Other
laravel
framework
1f8e0081a384e82098605826b4d4c3d5c7c184d7.json
Add controller method (#40492)
src/Illuminate/Support/Facades/Route.php
@@ -22,6 +22,7 @@ * @method static \Illuminate\Routing\Route substituteBindings(\Illuminate\Support\Facades\Route $route) * @method static \Illuminate\Routing\Route view(string $uri, string $view, array $data = [], int|array $status = 200, array $headers = []) * @method static \Illuminate\Routing\RouteRegistrar as(string $value) + * @method static \Illuminate\Routing\RouteRegistrar controller(string $controller) * @method static \Illuminate\Routing\RouteRegistrar domain(string $value) * @method static \Illuminate\Routing\RouteRegistrar middleware(array|string|null $middleware) * @method static \Illuminate\Routing\RouteRegistrar name(string $value)
false
Other
laravel
framework
8dd5728d71a4374fa553af542f3754d9be23aafb.json
Add render method (#40480)
src/Illuminate/Support/Facades/Blade.php
@@ -8,6 +8,7 @@ * @method static array getExtensions() * @method static bool check(string $name, array ...$parameters) * @method static string compileString(string $value) + * @method static string render(string $string, array $data, bool $deleteCachedView) * @method static string getPath() * @method static string stripParentheses(string $expression) * @method static void aliasComponent(string $path, string|null $alias = null)
false
Other
laravel
framework
ac6fc32c2933d5868a2c0d2aea4af9405d710378.json
fix bad merge
src/Illuminate/Http/Concerns/InteractsWithInput.php
@@ -60,11 +60,7 @@ public function bearerToken() if ($position !== false) { $header = substr($header, $position + 7); -<<<<<<< HEAD - return str_contains($header, ',') ? strstr(',', $header, true) : $header; -======= - return strpos($header, ',') !== false ? strstr($header, ',', true) : $header; ->>>>>>> 8.x + return str_contains($header, ',') ? strstr($header, ',', true) : $header; } }
false
Other
laravel
framework
c268e2756defc9561207a2c4b4f7400f777751f8.json
Make use of new getConnection method signature
src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php
@@ -26,7 +26,7 @@ trait InteractsWithDatabase protected function assertDatabaseHas($table, array $data, $connection = null) { $this->assertThat( - $this->getTable($table), new HasInDatabase($this->getConnection($connection), $data) + $this->getTable($table), new HasInDatabase($this->getConnection($table, $connection), $data) ); return $this; @@ -43,7 +43,7 @@ protected function assertDatabaseHas($table, array $data, $connection = null) protected function assertDatabaseMissing($table, array $data, $connection = null) { $constraint = new ReverseConstraint( - new HasInDatabase($this->getConnection($connection), $data) + new HasInDatabase($this->getConnection($table, $connection), $data) ); $this->assertThat($this->getTable($table), $constraint); @@ -89,7 +89,7 @@ protected function assertSoftDeleted($table, array $data = [], $connection = nul } $this->assertThat( - $this->getTable($table), new SoftDeletedInDatabase($this->getConnection($connection), $data, $deletedAtColumn) + $this->getTable($table), new SoftDeletedInDatabase($this->getConnection($table, $connection), $data, $deletedAtColumn) ); return $this; @@ -116,7 +116,7 @@ protected function assertNotSoftDeleted($table, array $data = [], $connection = } $this->assertThat( - $this->getTable($table), new NotSoftDeletedInDatabase($this->getConnection($connection), $data, $deletedAtColumn) + $this->getTable($table), new NotSoftDeletedInDatabase($this->getConnection($table, $connection), $data, $deletedAtColumn) ); return $this;
false
Other
laravel
framework
ff907d5f7bfc8d76811eb587158f837604750572.json
Apply fixes from StyleCI
tests/Mail/MailMailableAssertionsTest.php
@@ -3,8 +3,8 @@ namespace Illuminate\Tests\Mail; use Illuminate\Mail\Mailable; -use PHPUnit\Framework\TestCase; use PHPUnit\Framework\AssertionFailedError; +use PHPUnit\Framework\TestCase; class MailMailableAssertionsTest extends TestCase { @@ -125,14 +125,14 @@ class MailableAssertionsStub extends Mailable { protected function renderForAssertions() { - $text = <<<EOD + $text = <<<'EOD' # List - First Item - Second Item - Third Item EOD; - $html = <<<EOD + $html = <<<'EOD' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>
false
Other
laravel
framework
5ce33c0c2d3f6080c6abe610660db48c5899112f.json
Apply fixes from StyleCI
src/Illuminate/View/Compilers/BladeCompiler.php
@@ -280,7 +280,8 @@ public function compileString($value) */ public static function render($string, $data = [], $deleteCachedView = false) { - $component = new class($string) extends Component { + $component = new class($string) extends Component + { protected $template; public function __construct($template)
false
Other
laravel
framework
dc68fb490d6557d33414ce22a5a38ad0ee3e5bda.json
Apply fixes from StyleCI
tests/Database/DatabaseEloquentMorphToTest.php
@@ -406,4 +406,4 @@ public function relation() class EloquentMorphToRelatedStub extends Model { public $table = 'eloquent_morph_to_related_stubs'; -} \ No newline at end of file +}
false
Other
laravel
framework
78041a1529e2b11146939d4a0e9b607b98a9a5b6.json
remove function import
src/Illuminate/Routing/ControllerDispatcher.php
@@ -4,7 +4,6 @@ use Illuminate\Container\Container; use Illuminate\Routing\Contracts\ControllerDispatcher as ControllerDispatcherContract; -use function method_exists; class ControllerDispatcher implements ControllerDispatcherContract {
false
Other
laravel
framework
73d0ee647dc10f7f8fd452e15c171239a1f59e59.json
Add Bootstrap 5 styled pagination
src/Illuminate/Pagination/AbstractPaginator.php
@@ -602,6 +602,17 @@ public static function useTailwind() static::defaultSimpleView('pagination::simple-tailwind'); } + /** + * Indicate that Bootstrap 5 styling should be used for generated links. + * + * @return void + */ + public static function useBootstrapFive() + { + static::defaultView('pagination::bootstrap-5'); + static::defaultSimpleView('pagination::simple-bootstrap-5'); + } + /** * Indicate that Bootstrap 4 styling should be used for generated links. *
true
Other
laravel
framework
73d0ee647dc10f7f8fd452e15c171239a1f59e59.json
Add Bootstrap 5 styled pagination
src/Illuminate/Pagination/resources/views/bootstrap-5.blade.php
@@ -0,0 +1,88 @@ +@if ($paginator->hasPages()) + <nav class="d-flex justify-items-center justify-content-between"> + <div class="d-flex justify-content-between flex-fill d-sm-none"> + <ul class="pagination"> + {{-- Previous Page Link --}} + @if ($paginator->onFirstPage()) + <li class="page-item disabled" aria-disabled="true"> + <span class="page-link">@lang('pagination.previous')</span> + </li> + @else + <li class="page-item"> + <a class="page-link" href="{{ $paginator->previousPageUrl() }}" rel="prev">@lang('pagination.previous')</a> + </li> + @endif + + {{-- Next Page Link --}} + @if ($paginator->hasMorePages()) + <li class="page-item"> + <a class="page-link" href="{{ $paginator->nextPageUrl() }}" rel="next">@lang('pagination.next')</a> + </li> + @else + <li class="page-item disabled" aria-disabled="true"> + <span class="page-link">@lang('pagination.next')</span> + </li> + @endif + </ul> + </div> + + <div class="d-none flex-sm-fill d-sm-flex align-items-sm-center justify-content-sm-between"> + <div> + <p class="small text-muted"> + {!! __('Showing') !!} + <span class="font-medium">{{ $paginator->firstItem() }}</span> + {!! __('to') !!} + <span class="font-medium">{{ $paginator->lastItem() }}</span> + {!! __('of') !!} + <span class="font-medium">{{ $paginator->total() }}</span> + {!! __('results') !!} + </p> + </div> + + <div> + <ul class="pagination"> + {{-- Previous Page Link --}} + @if ($paginator->onFirstPage()) + <li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.previous')"> + <span class="page-link" aria-hidden="true">&lsaquo;</span> + </li> + @else + <li class="page-item"> + <a class="page-link" href="{{ $paginator->previousPageUrl() }}" rel="prev" aria-label="@lang('pagination.previous')">&lsaquo;</a> + </li> + @endif + + {{-- Pagination Elements --}} + @foreach ($elements as $element) + {{-- "Three Dots" Separator --}} + @if (is_string($element)) + <li class="page-item disabled" aria-disabled="true"><span class="page-link">{{ $element }}</span></li> + @endif + + {{-- Array Of Links --}} + @if (is_array($element)) + @foreach ($element as $page => $url) + @if ($page == $paginator->currentPage()) + <li class="page-item active" aria-current="page"><span class="page-link">{{ $page }}</span></li> + @else + <li class="page-item"><a class="page-link" href="{{ $url }}">{{ $page }}</a></li> + @endif + @endforeach + @endif + @endforeach + + {{-- Next Page Link --}} + @if ($paginator->hasMorePages()) + <li class="page-item"> + <a class="page-link" href="{{ $paginator->nextPageUrl() }}" rel="next" aria-label="@lang('pagination.next')">&rsaquo;</a> + </li> + @else + <li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.next')"> + <span class="page-link" aria-hidden="true">&rsaquo;</span> + </li> + @endif + </ul> + </div> + </div> + </nav> +@endif
true
Other
laravel
framework
73d0ee647dc10f7f8fd452e15c171239a1f59e59.json
Add Bootstrap 5 styled pagination
src/Illuminate/Pagination/resources/views/simple-bootstrap-5.blade.php
@@ -0,0 +1,29 @@ +@if ($paginator->hasPages()) + <nav role="navigation" aria-label="Pagination Navigation"> + <ul class="pagination"> + {{-- Previous Page Link --}} + @if ($paginator->onFirstPage()) + <li class="page-item disabled" aria-disabled="true"> + <span class="page-link">{!! __('pagination.previous') !!}</span> + </li> + @else + <li class="page-item"> + <a class="page-link" href="{{ $paginator->previousPageUrl() }}" rel="prev"> + {!! __('pagination.previous') !!} + </a> + </li> + @endif + + {{-- Next Page Link --}} + @if ($paginator->hasMorePages()) + <li class="page-item"> + <a class="page-link" href="{{ $paginator->nextPageUrl() }}" rel="next">{!! __('pagination.next') !!}</a> + </li> + @else + <li class="page-item disabled" aria-disabled="true"> + <span class="page-link">{!! __('pagination.next') !!}</span> + </li> + @endif + </ul> + </nav> +@endif
true
Other
laravel
framework
d464ff5f594a4f8183520d30c807680384e84571.json
Apply fixes from StyleCI
src/Illuminate/Database/Query/Builder.php
@@ -1828,14 +1828,14 @@ protected function addDynamic($segment, $connector, $parameters, $index) $this->where(Str::snake($segment), '=', $parameters[$index], $bool); } - /** - * Add a "where fulltext" clause to the query. - * - * @param string|string[] $columns - * @param string $value - * @param string $boolean - * @return $this - */ + /** + * Add a "where fulltext" clause to the query. + * + * @param string|string[] $columns + * @param string $value + * @param string $boolean + * @return $this + */ public function whereFullText($columns, $value, array $options = [], $boolean = 'and') { $type = 'Fulltext'; @@ -1849,13 +1849,13 @@ public function whereFullText($columns, $value, array $options = [], $boolean = return $this; } - /** - * Add a "or where fulltext" clause to the query. - * - * @param string|string[] $columns - * @param string $value - * @return $this - */ + /** + * Add a "or where fulltext" clause to the query. + * + * @param string|string[] $columns + * @param string $value + * @return $this + */ public function orWhereFullText($columns, $value, array $options = []) { return $this->whereFulltext($columns, $value, $options, 'or');
false
Other
laravel
framework
4ec36ec17ecb3b54aab38fb232a8260a238ce0bc.json
Fix some docblocks
src/Illuminate/Database/DBAL/TimestampType.php
@@ -11,8 +11,6 @@ class TimestampType extends Type implements PhpDateTimeMappingType { /** * {@inheritdoc} - * - * @return string */ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) { @@ -89,8 +87,6 @@ protected function getSQLitePlatformSQLDeclaration(array $fieldDeclaration) /** * {@inheritdoc} - * - * @return string */ public function getName() {
true
Other
laravel
framework
4ec36ec17ecb3b54aab38fb232a8260a238ce0bc.json
Fix some docblocks
src/Illuminate/Database/Query/Builder.php
@@ -847,7 +847,6 @@ protected function invalidOperator($operator) * @param mixed $operator * @param mixed $value * @return $this - * {@inheritdoc} */ public function orWhere($column, $operator = null, $value = null) { @@ -1829,9 +1828,14 @@ protected function addDynamic($segment, $connector, $parameters, $index) $this->where(Str::snake($segment), '=', $parameters[$index], $bool); } - /** - * {@inheritdoc} - */ + /** + * Add a "where fulltext" clause to the query. + * + * @param string|string[] $columns + * @param string $value + * @param string $boolean + * @return $this + */ public function whereFullText($columns, $value, array $options = [], $boolean = 'and') { $type = 'Fulltext'; @@ -1845,9 +1849,13 @@ public function whereFullText($columns, $value, array $options = [], $boolean = return $this; } - /** - * {@inheritdoc} - */ + /** + * Add a "or where fulltext" clause to the query. + * + * @param string|string[] $columns + * @param string $value + * @return $this + */ public function orWhereFullText($columns, $value, array $options = []) { return $this->whereFulltext($columns, $value, $options, 'or');
true
Other
laravel
framework
4ec36ec17ecb3b54aab38fb232a8260a238ce0bc.json
Fix some docblocks
src/Illuminate/Database/Query/Grammars/PostgresGrammar.php
@@ -22,7 +22,7 @@ class PostgresGrammar extends Grammar ]; /** - * {@inheritdoc} + * Compile a basic where clause. * * @param \Illuminate\Database\Query\Builder $query * @param array $where
true
Other
laravel
framework
a5a01581871ab0fdf35f009cb9da01fa0a2a6107.json
Apply fixes from StyleCI
src/Illuminate/Database/Query/Builder.php
@@ -847,7 +847,7 @@ protected function invalidOperator($operator) * @param mixed $operator * @param mixed $value * @return $this - * {@inheritdoc} + * {@inheritdoc} */ public function orWhere($column, $operator = null, $value = null) { @@ -1443,7 +1443,6 @@ public function whereYear($column, $operator, $value = null, $boolean = 'and') return $this->addDateBasedWhere('Year', $column, $operator, $value, $boolean); } - /** * Add an "or where year" statement to the query. *
false
Other
laravel
framework
ef049b3bf5b99bc414f84894b4f48d6ce0eeda55.json
remove empty line
tests/Database/DatabaseEloquentMorphToTest.php
@@ -406,5 +406,4 @@ public function relation() class EloquentMorphToRelatedStub extends Model { public $table = 'eloquent_morph_to_related_stubs'; -} - +} \ No newline at end of file
false
Other
laravel
framework
c9101668667c517bc1bdc5324283d4d4a3b159fa.json
Fix namesapce in test (#40395)
tests/Testing/Console/RouteListCommandTest.php
@@ -1,6 +1,6 @@ <?php -namespace Illuminate\Tests\Testing; +namespace Illuminate\Tests\Testing\Console; use Illuminate\Contracts\Routing\Registrar; use Illuminate\Foundation\Auth\User; @@ -51,8 +51,8 @@ public function testDisplayRoutesForCli() ->assertSuccessful() ->expectsOutput('') ->expectsOutput(' GET|HEAD closure ............................................... ') - ->expectsOutput(' POST controller-invokable Illuminate\Tests\Testing\FooContr…') - ->expectsOutput(' GET|HEAD controller-method/{user} Illuminate\Tests\Testing\FooC…') + ->expectsOutput(' POST controller-invokable Illuminate\Tests\Testing\Console\…') + ->expectsOutput(' GET|HEAD controller-method/{user} Illuminate\Tests\Testing\Cons…') ->expectsOutput(' GET|HEAD {account}.example.com/user/{id} ............. user.show') ->expectsOutput(''); } @@ -75,8 +75,8 @@ public function testDisplayRoutesForCliInVerboseMode() ->assertSuccessful() ->expectsOutput('') ->expectsOutput(' GET|HEAD closure ............................................... ') - ->expectsOutput(' POST controller-invokable Illuminate\\Tests\\Testing\\FooController') - ->expectsOutput(' GET|HEAD controller-method/{user} Illuminate\\Tests\\Testing\\FooController@show') + ->expectsOutput(' POST controller-invokable Illuminate\\Tests\\Testing\\Console\\FooController') + ->expectsOutput(' GET|HEAD controller-method/{user} Illuminate\\Tests\\Testing\\Console\\FooController@show') ->expectsOutput(' GET|HEAD {account}.example.com/user/{id} ............. user.show') ->expectsOutput(' ⇂ web') ->expectsOutput('');
false
Other
laravel
framework
94d9824a218098b6e1277bf1b7997fee031d9b27.json
restore old exception message
src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithDictionary.php
@@ -25,9 +25,7 @@ protected function getDictionaryKey($attribute) return $attribute->value; } - $msg = 'Model attribute value is an object but does not have a __toString method '. - 'and does not implement \Illuminate\Contracts\Database\Eloquent\StringableAttribute interface.'; - throw new InvalidArgumentException($msg); + throw new InvalidArgumentException('Model attribute value is an object but does not have a __toString method.'); } return $attribute;
false
Other
laravel
framework
d3e10fc137d997015e888e098845d8493af617e8.json
fix style ci
tests/Database/DatabaseEloquentMorphToTest.php
@@ -2,7 +2,6 @@ namespace Illuminate\Tests\Database; -use Doctrine\Instantiator\Exception\InvalidArgumentException; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\MorphTo; @@ -23,20 +22,18 @@ protected function tearDown(): void public function testLookupDictionaryIsProperlyConstructedForEnums() { - - if (version_compare(PHP_VERSION,'8.1') < 0) { + if (version_compare(PHP_VERSION, '8.1') < 0) { $this->markTestSkipped('PHP 8.1 is required'); } else { $relation = $this->getRelation(); $relation->addEagerConstraints([ - $one = (object) ['morph_type' => 'morph_type_2', 'foreign_key' => TestEnum::test] + $one = (object) ['morph_type' => 'morph_type_2', 'foreign_key' => TestEnum::test], ]); $dictionary = $relation->getDictionary(); $relation->getDictionary(); $value = $dictionary['morph_type_2'][TestEnum::test->value][0]->foreign_key; $this->assertEquals(TestEnum::test, $value); } - } public function testLookupDictionaryIsProperlyConstructed()
true
Other
laravel
framework
d3e10fc137d997015e888e098845d8493af617e8.json
fix style ci
tests/Database/stubs/TestEnum.php
@@ -4,6 +4,6 @@ enum TestEnum: string { - case test = "test"; + case test = 'test'; }
true
Other
laravel
framework
1eb0ac85aaded5b80cfc7b480fb37b1c1c3d9663.json
update split script
bin/split.sh
@@ -3,7 +3,7 @@ set -e set -x -CURRENT_BRANCH="master" +CURRENT_BRANCH="9.x" function split() {
false
Other
laravel
framework
9dd4b5e052004e37a1af3079cc22f1ba3fd855f7.json
fix tests for php < 8.1
tests/Database/DatabaseEloquentMorphToTest.php
@@ -24,27 +24,31 @@ public function testLookupDictionaryIsProperlyConstructedForStringableEnums() { if (PHP_VERSION < "8.1") { $this->markTestSkipped('PHP 8.1 is required'); + } else { + $relation = $this->getRelation(); + $relation->addEagerConstraints([ + $one = (object) ['morph_type' => 'morph_type_2', 'foreign_key' => TestEnumStringAllowed::test2] + ]); + $dictionary = $relation->getDictionary(); + $value = $dictionary['morph_type_2'][TestEnumStringAllowed::test2->toString()][0]->foreign_key; + $this->assertEquals(TestEnumStringAllowed::test2, $value); } - $relation = $this->getRelation(); - $relation->addEagerConstraints([ - $one = (object) ['morph_type' => 'morph_type_2', 'foreign_key' => TestEnumStringAllowed::test2] - ]); - $dictionary = $relation->getDictionary(); - $value = $dictionary['morph_type_2'][TestEnumStringAllowed::test2->toString()][0]->foreign_key; - $this->assertEquals(TestEnumStringAllowed::test2, $value); + } public function testLookupDictionaryIsNotProperlyConstructedForEnums() { if (PHP_VERSION < "8.1") { $this->markTestSkipped('PHP 8.1 is required'); + } else { + $this->expectException(InvalidArgumentException::class); + $relation = $this->getRelation(); + $relation->addEagerConstraints([ + $one = (object) ['morph_type' => 'morph_type_2', 'foreign_key' => TestEnum::test] + ]); + $relation->getDictionary(); } - $this->expectException(InvalidArgumentException::class); - $relation = $this->getRelation(); - $relation->addEagerConstraints([ - $one = (object) ['morph_type' => 'morph_type_2', 'foreign_key' => TestEnum::test] - ]); - $dictionary = $relation->getDictionary(); + } public function testLookupDictionaryIsProperlyConstructed()
false
Other
laravel
framework
8a728465360f402f6d4b6c1004cd35f5f7d97ab7.json
allow enums as entity_type in morphs
src/Illuminate/Contracts/Database/Eloquent/StringableAttribute.php
@@ -0,0 +1,12 @@ +<?php + +namespace Illuminate\Contracts\Database\Eloquent; + +interface StringableAttribute +{ + /** + * Allows enums to be used as morthed entity type + * @return string + */ + public function toString(): string; +}
true
Other
laravel
framework
8a728465360f402f6d4b6c1004cd35f5f7d97ab7.json
allow enums as entity_type in morphs
src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithDictionary.php
@@ -3,6 +3,7 @@ namespace Illuminate\Database\Eloquent\Relations\Concerns; use Doctrine\Instantiator\Exception\InvalidArgumentException; +use Illuminate\Contracts\Database\Eloquent\StringableAttribute; trait InteractsWithDictionary { @@ -21,7 +22,13 @@ protected function getDictionaryKey($attribute) return $attribute->__toString(); } - throw new InvalidArgumentException('Model attribute value is an object but does not have a __toString method.'); + if ($attribute instanceof StringableAttribute) { + return $attribute->toString(); + } + + $msg = 'Model attribute value is an object but does not have a __toString method '. + 'and does not implement \Illuminate\Contracts\Database\Eloquent\StringableAttribute interface.'; + throw new InvalidArgumentException($msg); } return $attribute;
true
Other
laravel
framework
8a728465360f402f6d4b6c1004cd35f5f7d97ab7.json
allow enums as entity_type in morphs
tests/Database/DatabaseEloquentMorphToTest.php
@@ -2,6 +2,8 @@ namespace Illuminate\Tests\Database; +use Doctrine\Instantiator\Exception\InvalidArgumentException; +use Illuminate\Contracts\Database\Eloquent\StringableAttribute; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\MorphTo; @@ -18,6 +20,32 @@ protected function tearDown(): void { m::close(); } + public function testLookupDictionaryIsProperlyConstructedForStringableEnums() + { + if (PHP_VERSION < "8.1") { + $this->markTestSkipped('PHP 8.1 is required'); + } + $relation = $this->getRelation(); + $relation->addEagerConstraints([ + $one = (object) ['morph_type' => 'morph_type_2', 'foreign_key' => TestEnumStringAllowed::test2] + ]); + $dictionary = $relation->getDictionary(); + $value = $dictionary['morph_type_2'][TestEnumStringAllowed::test2->toString()][0]->foreign_key; + $this->assertEquals(TestEnumStringAllowed::test2, $value); + } + + public function testLookupDictionaryIsNotProperlyConstructedForEnums() + { + if (PHP_VERSION < "8.1") { + $this->markTestSkipped('PHP 8.1 is required'); + } + $this->expectException(InvalidArgumentException::class); + $relation = $this->getRelation(); + $relation->addEagerConstraints([ + $one = (object) ['morph_type' => 'morph_type_2', 'foreign_key' => TestEnum::test] + ]); + $dictionary = $relation->getDictionary(); + } public function testLookupDictionaryIsProperlyConstructed() { @@ -385,3 +413,25 @@ class EloquentMorphToRelatedStub extends Model { public $table = 'eloquent_morph_to_related_stubs'; } + +if (PHP_VERSION >= '8.1') +{ + enum TestEnum: string + { + case test = 'Test'; + } + + enum TestEnumStringAllowed: string implements StringableAttribute + { + case test2 = "Test2"; + + /** + * Allows enums to be used as morthed entity type + * @return string + */ + public function toString(): string + { + return $this->value; + } + } +}
true
Other
laravel
framework
20d9fffe5ea845db6336d089a4d6e5b6c85a9d9c.json
Apply fixes from StyleCI
src/Illuminate/Support/Pluralizer.php
@@ -2,9 +2,8 @@ namespace Illuminate\Support; -use Doctrine\Inflector\InflectorFactory; use Doctrine\Inflector\Inflector; -use Doctrine\Inflector\RulesetInflector; +use Doctrine\Inflector\InflectorFactory; class Pluralizer {
false
Other
laravel
framework
f3b7651bd0ea0fcd4261c4669aadf1d1d5d5382f.json
Apply fixes from StyleCI
src/Illuminate/Collections/Collection.php
@@ -1663,11 +1663,12 @@ public function offsetSet($key, $value) /** * Unset the item at a given offset. * -<<<<<<< HEAD + * <<<<<<< HEAD + * * @param TKey $key -======= + * ======= * @param mixed $key ->>>>>>> 8.x + * >>>>>>> 8.x * @return void */ #[\ReturnTypeWillChange]
false
Other
laravel
framework
29a6692fb0f0d14e5109ae5f02ed70065f10e966.json
fix virtual attributes
src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php
@@ -1637,7 +1637,13 @@ protected function mergeAttributesFromClassCasts() protected function mergeAttributesFromAttributeCasts() { foreach ($this->attributeCastCache as $key => $value) { - $callback = $this->{Str::camel($key)}()->set ?: function ($value) use ($key) { + $attribute = $this->{Str::camel($key)}(); + + if ($attribute->get && ! $attribute->set) { + continue; + } + + $callback = $attribute->set ?: function ($value) use ($key) { $this->attributes[$key] = $value; };
true
Other
laravel
framework
29a6692fb0f0d14e5109ae5f02ed70065f10e966.json
fix virtual attributes
tests/Integration/Database/DatabaseEloquentModelAttributeCastingTest.php
@@ -177,6 +177,17 @@ public function testSettingRawAttributesClearsTheCastCache() $this->assertSame('117 Spencer St.', $model->address->lineOne); } + + public function testCastsThatOnlyHaveGetterDoNotPeristAnythingToModelOnSave() + { + $model = new TestEloquentModelWithAttributeCast; + + $model->virtual; + + $model->getAttributes(); + + $this->assertTrue(empty($model->getDirty())); + } } class TestEloquentModelWithAttributeCast extends Model @@ -253,6 +264,15 @@ public function password(): Attribute return hash('sha256', $value); }); } + + public function virtual(): Attribute + { + return new Attribute( + function () { + return collect(); + } + ); + } } class AttributeCastAddress
true
Other
laravel
framework
66c5afc3cb14f914990d8b8cbf79fa077887cb26.json
Fix cursor pagination with HasManyThrough (#40300)
src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php
@@ -431,6 +431,22 @@ public function simplePaginate($perPage = null, $columns = ['*'], $pageName = 'p return $this->query->simplePaginate($perPage, $columns, $pageName, $page); } + /** + * Paginate the given query into a cursor paginator. + * + * @param int|null $perPage + * @param array $columns + * @param string $cursorName + * @param string|null $cursor + * @return \Illuminate\Contracts\Pagination\CursorPaginator + */ + public function cursorPaginate($perPage = null, $columns = ['*'], $cursorName = 'cursor', $cursor = null) + { + $this->query->addSelect($this->shouldSelect($columns)); + + return $this->query->cursorPaginate($perPage, $columns, $cursorName, $cursor); + } + /** * Set the select clause for the relation query. *
false
Other
laravel
framework
1563361e1a4f786e2ddfc24914d579639782893d.json
Use Swift_TransportException for Mailgun & SES
src/Illuminate/Mail/Transport/MailgunTransport.php
@@ -3,7 +3,9 @@ namespace Illuminate\Mail\Transport; use GuzzleHttp\ClientInterface; +use GuzzleHttp\Exception\GuzzleException; use Swift_Mime_SimpleMessage; +use Swift_TransportException; class MailgunTransport extends Transport { @@ -68,11 +70,15 @@ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = nul $message->setBcc([]); - $response = $this->client->request( - 'POST', - "https://{$this->endpoint}/v3/{$this->domain}/messages.mime", - $this->payload($message, $to) - ); + try { + $response = $this->client->request( + 'POST', + "https://{$this->endpoint}/v3/{$this->domain}/messages.mime", + $this->payload($message, $to) + ); + } catch (GuzzleException $e) { + throw new Swift_TransportException('Failed to make request to Mailgun API', $e->getCode(), $e); + } $messageId = $this->getMessageId($response);
true
Other
laravel
framework
1563361e1a4f786e2ddfc24914d579639782893d.json
Use Swift_TransportException for Mailgun & SES
src/Illuminate/Mail/Transport/SesTransport.php
@@ -2,8 +2,10 @@ namespace Illuminate\Mail\Transport; +use Aws\Exception\AwsException; use Aws\Ses\SesClient; use Swift_Mime_SimpleMessage; +use Swift_TransportException; class SesTransport extends Transport { @@ -43,16 +45,20 @@ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = nul { $this->beforeSendPerformed($message); - $result = $this->ses->sendRawEmail( - array_merge( - $this->options, [ - 'Source' => key($message->getSender() ?: $message->getFrom()), - 'RawMessage' => [ - 'Data' => $message->toString(), - ], - ] - ) - ); + try { + $result = $this->ses->sendRawEmail( + array_merge( + $this->options, [ + 'Source' => key($message->getSender() ?: $message->getFrom()), + 'RawMessage' => [ + 'Data' => $message->toString(), + ], + ] + ) + ); + } catch (AwsException $e) { + throw new Swift_TransportException('Failed to make request to AWS SES API', $e->getCode(), $e); + } $messageId = $result->get('MessageId');
true
Other
laravel
framework
ad24bc3422261dc204dd5bab6d7a69cb389fce56.json
Add allowed plugins (#40246)
composer.json
@@ -155,7 +155,10 @@ "wildbit/swiftmailer-postmark": "Required to use Postmark mail driver (^3.0)." }, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "composer/package-versions-deprecated": true + } }, "minimum-stability": "dev", "prefer-stable": true
false
Other
laravel
framework
8d745f19a8cb0e93c89798406b33dc789219d2f9.json
Fix code style. (#40241)
src/Illuminate/Support/Reflector.php
@@ -135,8 +135,8 @@ public static function isParameterSubclassOf($parameter, $className) { $paramClassName = static::getParameterClassName($parameter); - return ($paramClassName && class_exists($paramClassName)) - ? (new ReflectionClass($paramClassName))->isSubclassOf($className) - : false; + return $paramClassName + && class_exists($paramClassName) + && (new ReflectionClass($paramClassName))->isSubclassOf($className); } }
false
Other
laravel
framework
972538f7071e73dcff429c1cb0ec143d66d82dc1.json
Apply fixes from StyleCI
tests/Integration/Support/Fixtures/MultipleInstanceManager.php
@@ -10,7 +10,8 @@ class MultipleInstanceManager extends BaseMultipleInstanceManager protected function createFooDriver(array $config) { - return new class($config) { + return new class($config) + { public $config; public function __construct($config) @@ -22,7 +23,8 @@ public function __construct($config) protected function createBarDriver(array $config) { - return new class($config) { + return new class($config) + { public $config; public function __construct($config) @@ -65,12 +67,12 @@ public function getInstanceConfig($name) case 'foo': return [ 'driver' => 'foo', - 'foo-option' => 'option-value' + 'foo-option' => 'option-value', ]; case 'bar': return [ 'driver' => 'bar', - 'bar-option' => 'option-value' + 'bar-option' => 'option-value', ]; default: return [];
false
Other
laravel
framework
ca53127994dda58a2dc4a4fe70f1528a1631bb02.json
Add observer mapping
src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php
@@ -22,6 +22,13 @@ class EventServiceProvider extends ServiceProvider */ protected $subscribe = []; + /** + * The observers mapping for the application models. + * + * @var array + */ + protected $observers = []; + /** * Register the application's event listeners. * @@ -41,6 +48,8 @@ public function register() foreach ($this->subscribe as $subscriber) { Event::subscribe($subscriber); } + + $this->registerObservers(); }); } @@ -145,4 +154,26 @@ protected function eventDiscoveryBasePath() { return base_path(); } + + /** + * Get the observers defined on the provider. + * + * @return array + */ + public function observers() + { + return $this->observers; + } + + /** + * Register the application model's observers. + * + * @return void + */ + public function registerObservers() + { + foreach ($this->observers() as $model => $observers) { + $model::observe($observers); + } + } }
false
Other
laravel
framework
891c0140f33a42eafeaa34477243782de325c52e.json
Apply fixes from StyleCI
src/Illuminate/Database/Console/PruneCommand.php
@@ -91,7 +91,7 @@ protected function models() } if (! empty($models) && ! empty($except = $this->option('except'))) { - throw new InvalidArgumentException("The --models and --except options cannot be combined."); + throw new InvalidArgumentException('The --models and --except options cannot be combined.'); } return collect((new Finder)->in(app_path('Models'))->files()->name('*.php'))
false
Other
laravel
framework
69179b843b2b43abd28744a0f25656455870a44e.json
add validate Mac Address (#40098)
src/Illuminate/Validation/Concerns/ValidatesAttributes.php
@@ -1230,6 +1230,18 @@ public function validateIpv6($attribute, $value) return filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false; } + /** + * Validate that an attribute is a valid MAC address. + * + * @param string $attribute + * @param mixed $value + * @return bool + */ + public function validateMacAddress($attribute, $value) + { + return filter_var($value, FILTER_VALIDATE_MAC) !== false; + } + /** * Validate the attribute is a valid JSON string. *
true
Other
laravel
framework
69179b843b2b43abd28744a0f25656455870a44e.json
add validate Mac Address (#40098)
tests/Validation/ValidationValidatorTest.php
@@ -3023,6 +3023,49 @@ public function testValidateIp() $this->assertTrue($v->fails()); } + public function testValidateMacAddress() + { + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, ['mac' => 'foo'], ['mac' => 'mac_address']); + $this->assertFalse($v->passes()); + + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, ['mac' => '01-23-45-67-89-ab'], ['mac' => 'mac_address']); + $this->assertTrue($v->passes()); + + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, ['mac' => '01-23-45-67-89-AB'], ['mac' => 'mac_address']); + $this->assertTrue($v->passes()); + + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, ['mac' => '01-23-45-67-89-aB'], ['mac' => 'mac_address']); + $this->assertTrue($v->passes()); + + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, ['mac' => '01:23:45:67:89:ab'], ['mac' => 'mac_address']); + $this->assertTrue($v->passes()); + + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, ['mac' => '01:23:45:67:89:AB'], ['mac' => 'mac_address']); + $this->assertTrue($v->passes()); + + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, ['mac' => '01:23:45:67:89:aB'], ['mac' => 'mac_address']); + $this->assertTrue($v->passes()); + + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, ['mac' => '01:23:45-67:89:aB'], ['mac' => 'mac_address']); + $this->assertFalse($v->passes()); + + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, ['mac' => 'xx:23:45:67:89:aB'], ['mac' => 'mac_address']); + $this->assertFalse($v->passes()); + + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, ['mac' => '0123.4567.89ab'], ['mac' => 'mac_address']); + $this->assertTrue($v->passes()); + } + public function testValidateEmail() { $trans = $this->getIlluminateArrayTranslator();
true
Other
laravel
framework
66e69a2f674515cd0aa18fc596d228e4d96a959e.json
Apply fixes from StyleCI
src/Illuminate/Foundation/Providers/FoundationServiceProvider.php
@@ -4,7 +4,6 @@ use Illuminate\Contracts\Foundation\MaintenanceMode as MaintenanceModeContract; use Illuminate\Foundation\FileBasedMaintenanceMode; -use Illuminate\Foundation\MaintenanceMode; use Illuminate\Http\Request; use Illuminate\Log\Events\MessageLogged; use Illuminate\Support\AggregateServiceProvider;
false
Other
laravel
framework
bcf9ed1d415fc11b4ba7d956b44284938d2ce467.json
Fix vendor publish command (#40081)
src/Illuminate/Foundation/Console/VendorPublishCommand.php
@@ -7,6 +7,7 @@ use Illuminate\Foundation\Events\VendorTagPublished; use Illuminate\Support\Arr; use Illuminate\Support\ServiceProvider; +use Illuminate\Support\Str; use League\Flysystem\Filesystem as Flysystem; use League\Flysystem\Local\LocalFilesystemAdapter as LocalAdapter; use League\Flysystem\MountManager; @@ -259,8 +260,10 @@ protected function publishDirectory($from, $to) protected function moveManagedFiles($manager) { foreach ($manager->listContents('from://', true) as $file) { - if ($file['type'] === 'file' && (! $manager->fileExists('to://'.$file['path']) || $this->option('force'))) { - $manager->write('to://'.$file['path'], $manager->read('from://'.$file['path'])); + $path = Str::after($file['path'], 'from://'); + + if ($file['type'] === 'file' && (! $manager->fileExists('to://'.$path) || $this->option('force'))) { + $manager->write('to://'.$path, $manager->read($file['path'])); } } }
false
Other
laravel
framework
739d8472eb2c97c4a8d8f86eb699c526e42f57fa.json
fix arg passing in doesntContain
src/Illuminate/Collections/Collection.php
@@ -186,7 +186,7 @@ public function contains($key, $operator = null, $value = null) */ public function doesntContain($key, $operator = null, $value = null) { - return ! $this->contains($key, $operator, $value); + return ! $this->contains(...func_get_args()); } /**
true
Other
laravel
framework
739d8472eb2c97c4a8d8f86eb699c526e42f57fa.json
fix arg passing in doesntContain
src/Illuminate/Collections/LazyCollection.php
@@ -215,7 +215,7 @@ public function contains($key, $operator = null, $value = null) */ public function doesntContain($key, $operator = null, $value = null) { - return ! $this->contains($key, $operator, $value); + return ! $this->contains(...func_get_args()); } /**
true
Other
laravel
framework
09689f2bb14ad2cc014c3756db76b10239afcee9.json
Fix code style
src/Illuminate/Collections/Collection.php
@@ -186,7 +186,7 @@ public function contains($key, $operator = null, $value = null) */ public function missing($key, $operator = null, $value = null) { - return !$this->contains($key, $operator, $value); + return ! $this->contains($key, $operator, $value); } /**
true
Other
laravel
framework
09689f2bb14ad2cc014c3756db76b10239afcee9.json
Fix code style
src/Illuminate/Collections/LazyCollection.php
@@ -215,7 +215,7 @@ public function contains($key, $operator = null, $value = null) */ public function missing($key, $operator = null, $value = null) { - return !$this->contains($key, $operator, $value); + return ! $this->contains($key, $operator, $value); } /**
true
Other
laravel
framework
985b2cf1845b544cdfd744ee68be2dfa95652c51.json
Fix ThrottleRequestsException (#39951)
src/Illuminate/Http/Exceptions/ThrottleRequestsException.php
@@ -10,13 +10,13 @@ class ThrottleRequestsException extends TooManyRequestsHttpException /** * Create a new throttle requests exception instance. * - * @param string|null $message + * @param string $message * @param \Throwable|null $previous * @param array $headers * @param int $code * @return void */ - public function __construct($message = null, Throwable $previous = null, array $headers = [], $code = 0) + public function __construct($message = '', Throwable $previous = null, array $headers = [], $code = 0) { parent::__construct(null, $message, $previous, $code, $headers); }
false
Other
laravel
framework
d5e66bab3df8a90df3ca4ea7e7d789fe39fd65ac.json
Use real return value (#39915)
src/Illuminate/Database/Eloquent/Factories/Sequence.php
@@ -44,8 +44,7 @@ public function __construct(...$sequence) * * @return int */ - #[\ReturnTypeWillChange] - public function count() + public function count(): int { return $this->count; }
false
Other
laravel
framework
6b849d116167d57be4d0ac9c6e49be85602381db.json
Apply fixes from StyleCI
src/Illuminate/Validation/Concerns/ValidatesAttributes.php
@@ -1264,7 +1264,7 @@ protected function shouldBlockPhpUpload($value, $parameters) } $phpExtensions = [ - 'php', 'php3', 'php4', 'php5', 'phtml', 'phar' + 'php', 'php3', 'php4', 'php5', 'phtml', 'phar', ]; return ($value instanceof UploadedFile)
false
Other
laravel
framework
1638472a7a5ee02dc9e808bc203b733785ac1468.json
Add ReturnTypeWillChange to count method
src/Illuminate/Database/Eloquent/Factories/Sequence.php
@@ -44,6 +44,7 @@ public function __construct(...$sequence) * * @return int */ + #[\ReturnTypeWillChange] public function count() { return $this->count;
false
Other
laravel
framework
a69db4280d39d09cf3494462d7e1d26206a86d49.json
Fix non-model children support
src/Illuminate/Database/Eloquent/Model.php
@@ -1895,7 +1895,7 @@ public function resolveSoftDeletableRouteBinding($value, $field = null) /** * Retrieve the model for a bound value. * - * @param Model|Relation $query + * @param Model|Relation $query * @param mixed $value * @param string|null $field * @return Model|Illuminate\Database\Eloquent\Relations\Relation @@ -1947,11 +1947,14 @@ protected function resolveChildRouteBindingQuery($childType, $value, $field) if ($relationship instanceof HasManyThrough || $relationship instanceof BelongsToMany) { - return $relationship->getRelated()->resolveRouteBindingQuery( - $relationship, $value, $relationship->getRelated()->getTable().'.'.$field); + $field = $relationship->getRelated()->getTable().'.'.$field; } - return $relationship->getRelated()->resolveRouteBindingQuery($relationship, $value, $field); + if ($relationship instanceof Model) { + return $relationship->getRelated()->resolveRouteBindingQuery($relationship, $value, $field); + } + + return $relationship->where($field, $value); } /**
false
Other
laravel
framework
81d3587437bb67425ea57dad22b00648f46bc5c4.json
Set the PHP version on StyleCI to 8.1 (#39896)
.styleci.yml
@@ -1,9 +1,6 @@ php: preset: laravel - version: 8 - finder: - not-name: - - Enums.php + version: 8.1 js: finder: not-name:
false
Other
laravel
framework
49aac46f7c1bb9d9e635b1542cfb9925073f8244.json
Use Laravel call for retrieving Session (#39830)
src/Illuminate/Http/Request.php
@@ -421,7 +421,7 @@ public static function createFrom(self $from, $to = null) $request->setJson($from->json()); - if ($from->hasSession() && $session = $from->getSession()) { + if ($from->hasSession() && $session = $from->session()) { $request->setLaravelSession($session); }
false
Other
laravel
framework
63bb589b760b6497c840858409e3b5da0ee287de.json
Add callOnce to Seeder (#39812)
src/Illuminate/Database/Seeder.php
@@ -23,6 +23,13 @@ abstract class Seeder */ protected $command; + /** + * Seeders that have been called at least one time. + * + * @var array + */ + protected static $called = []; + /** * Run the given seeder class. * @@ -53,6 +60,8 @@ public function call($class, $silent = false, array $parameters = []) if ($silent === false && isset($this->command)) { $this->command->getOutput()->writeln("<info>Seeded:</info> {$name} ({$runTime}ms)"); } + + static::$called[] = $class; } return $this; @@ -82,6 +91,22 @@ public function callSilent($class, array $parameters = []) $this->call($class, true, $parameters); } + /** + * Run the given seeder class once. + * + * @param array|string $class + * @param bool $silent + * @return void + */ + public function callOnce($class, $silent = false, array $parameters = []) + { + if (in_array($class, static::$called)) { + return; + } + + $this->call($class, $silent, $parameters); + } + /** * Resolve an instance of the given seeder class. *
false
Other
laravel
framework
9d902d3581ac32549d02058b04b6a1944ff198ed.json
Update DispatchesJobs.php (#39767) rename "dispatch a command" to "dispatch a job" to be in sync with other docs
src/Illuminate/Foundation/Bus/DispatchesJobs.php
@@ -31,7 +31,7 @@ public function dispatchNow($job) } /** - * Dispatch a command to its appropriate handler in the current process. + * Dispatch a job to its appropriate handler in the current process. * * Queueable jobs will be dispatched to the "sync" queue. *
false
Other
laravel
framework
097ca1ac101622b3b0769a8970a0509aa898165e.json
Add aggregate method to Eloquent passthru (#39772)
src/Illuminate/Database/Eloquent/Builder.php
@@ -79,6 +79,7 @@ class Builder * @var string[] */ protected $passthru = [ + 'aggregate', 'average', 'avg', 'count',
false
Other
laravel
framework
e4b54ba7d3105e8966bade0080c8d9afe556376e.json
Apply fixes from StyleCI
src/Illuminate/Queue/QueueManager.php
@@ -148,7 +148,7 @@ public function connection($name = null) * * @param string $name * @return \Illuminate\Contracts\Queue\Queue - * + * * @throws \InvalidArgumentException */ protected function resolve($name)
false
Other
laravel
framework
d3c8c8ea83ad82c7bc13ef37fcb99f90b9d3fdee.json
Improve Tappable::tap() return type (#39685)
src/Illuminate/Support/Traits/Tappable.php
@@ -8,7 +8,7 @@ trait Tappable * Call the given Closure with this instance then return the instance. * * @param callable|null $callback - * @return mixed + * @return $this|\Illuminate\Support\HigherOrderTapProxy */ public function tap($callback = null) {
false
Other
laravel
framework
f647a24b918648c2b8a17c122b855bc0b2bf5b86.json
add phar to list
src/Illuminate/Validation/Concerns/ValidatesAttributes.php
@@ -1264,7 +1264,7 @@ protected function shouldBlockPhpUpload($value, $parameters) } $phpExtensions = [ - 'php', 'php3', 'php4', 'php5', 'phtml', + 'php', 'php3', 'php4', 'php5', 'phtml', 'phar' ]; return ($value instanceof UploadedFile)
false
Other
laravel
framework
417bfdb24d703fd75e256fc1f070ec12c526b215.json
Apply fixes from StyleCI
src/Illuminate/Validation/Concerns/ValidatesAttributes.php
@@ -1254,7 +1254,7 @@ protected function shouldBlockPhpUpload($value, $parameters) } $phpExtensions = [ - 'php', 'php3', 'php4', 'php5', 'phtml', 'phar' + 'php', 'php3', 'php4', 'php5', 'phtml', 'phar', ]; return ($value instanceof UploadedFile)
false
Other
laravel
framework
2d1f76ab752ced011da05cf139799eab2a36ef90.json
add phar to list
src/Illuminate/Validation/Concerns/ValidatesAttributes.php
@@ -1254,7 +1254,7 @@ protected function shouldBlockPhpUpload($value, $parameters) } $phpExtensions = [ - 'php', 'php3', 'php4', 'php5', 'phtml', + 'php', 'php3', 'php4', 'php5', 'phtml', 'phar' ]; return ($value instanceof UploadedFile)
false
Other
laravel
framework
030e9a886bfea56f90dc911471f55b5b4c36e3ce.json
Apply fixes from StyleCI
tests/Cache/CacheRepositoryTest.php
@@ -113,7 +113,7 @@ public function testRememberMethodCallsPutAndReturnsDefault() return 'qux'; }); $this->assertSame('qux', $result); - + /* * Use a callable... */
false
Other
laravel
framework
969f1014ec07efba803f887a33fde29e305c9cb1.json
fix breaking change
src/Illuminate/Auth/Notifications/ResetPassword.php
@@ -59,13 +59,11 @@ public function via($notifiable) */ public function toMail($notifiable) { - $resetUrl = $this->resetUrl($notifiable); - if (static::$toMailCallback) { - return call_user_func(static::$toMailCallback, $notifiable, $this->token, $resetUrl); + return call_user_func(static::$toMailCallback, $notifiable, $this->token); } - return $this->buildMailMessage($resetUrl); + return $this->buildMailMessage($this->resetUrl($notifiable)); } /**
false
Other
laravel
framework
ccea1bfcbb37cf923dc1bb30cdbf2effbfb1619c.json
Add .phar to blocked PHP extensions (#39666) By default Debian includes support for executing .phar files alongside .php and .phtml files, and should be included in the blocked list.
src/Illuminate/Validation/Concerns/ValidatesAttributes.php
@@ -1329,7 +1329,7 @@ protected function shouldBlockPhpUpload($value, $parameters) } $phpExtensions = [ - 'php', 'php3', 'php4', 'php5', 'phtml', + 'php', 'php3', 'php4', 'php5', 'phtml', 'phar', ]; return ($value instanceof UploadedFile)
false
Other
laravel
framework
5e0b273ae3012cbb1e959efe4627f03811b705cd.json
use jsonb type for pgsql whereJsonLength (#39619)
src/Illuminate/Database/Query/Grammars/PostgresGrammar.php
@@ -138,7 +138,7 @@ protected function compileJsonLength($column, $operator, $value) { $column = str_replace('->>', '->', $this->wrap($column)); - return 'json_array_length(('.$column.')::json) '.$operator.' '.$value; + return 'jsonb_array_length(('.$column.')::jsonb) '.$operator.' '.$value; } /**
true
Other
laravel
framework
5e0b273ae3012cbb1e959efe4627f03811b705cd.json
use jsonb type for pgsql whereJsonLength (#39619)
tests/Database/DatabaseQueryBuilderTest.php
@@ -4170,22 +4170,22 @@ public function testWhereJsonLengthPostgres() { $builder = $this->getPostgresBuilder(); $builder->select('*')->from('users')->whereJsonLength('options', 0); - $this->assertSame('select * from "users" where json_array_length(("options")::json) = ?', $builder->toSql()); + $this->assertSame('select * from "users" where jsonb_array_length(("options")::jsonb) = ?', $builder->toSql()); $this->assertEquals([0], $builder->getBindings()); $builder = $this->getPostgresBuilder(); $builder->select('*')->from('users')->whereJsonLength('users.options->languages', '>', 0); - $this->assertSame('select * from "users" where json_array_length(("users"."options"->\'languages\')::json) > ?', $builder->toSql()); + $this->assertSame('select * from "users" where jsonb_array_length(("users"."options"->\'languages\')::jsonb) > ?', $builder->toSql()); $this->assertEquals([0], $builder->getBindings()); $builder = $this->getPostgresBuilder(); $builder->select('*')->from('users')->where('id', '=', 1)->orWhereJsonLength('options->languages', new Raw('0')); - $this->assertSame('select * from "users" where "id" = ? or json_array_length(("options"->\'languages\')::json) = 0', $builder->toSql()); + $this->assertSame('select * from "users" where "id" = ? or jsonb_array_length(("options"->\'languages\')::jsonb) = 0', $builder->toSql()); $this->assertEquals([1], $builder->getBindings()); $builder = $this->getPostgresBuilder(); $builder->select('*')->from('users')->where('id', '=', 1)->orWhereJsonLength('options->languages', '>', new Raw('0')); - $this->assertSame('select * from "users" where "id" = ? or json_array_length(("options"->\'languages\')::json) > 0', $builder->toSql()); + $this->assertSame('select * from "users" where "id" = ? or jsonb_array_length(("options"->\'languages\')::jsonb) > 0', $builder->toSql()); $this->assertEquals([1], $builder->getBindings()); }
true