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
db36649acc738ddba3c107b2c513c9125a3380a5.json
Apply fixes from StyleCI (#32214)
src/Illuminate/Testing/Assert.php
@@ -10,7 +10,6 @@ use PHPUnit\Framework\Constraint\LogicalNot; use PHPUnit\Framework\Constraint\RegularExpression; use PHPUnit\Framework\InvalidArgumentException; -use PHPUnit\Runner\Version; use PHPUnit\Util\InvalidArgumentHelper; /**
true
Other
laravel
framework
db36649acc738ddba3c107b2c513c9125a3380a5.json
Apply fixes from StyleCI (#32214)
tests/Filesystem/FilesystemAdapterTest.php
@@ -6,8 +6,8 @@ use Illuminate\Contracts\Filesystem\FileExistsException; use Illuminate\Contracts\Filesystem\FileNotFoundException; use Illuminate\Filesystem\FilesystemAdapter; -use Illuminate\Testing\Assert; use Illuminate\Http\UploadedFile; +use Illuminate\Testing\Assert; use InvalidArgumentException; use League\Flysystem\Adapter\Local; use League\Flysystem\Filesystem;
true
Other
laravel
framework
db36649acc738ddba3c107b2c513c9125a3380a5.json
Apply fixes from StyleCI (#32214)
tests/Integration/Mail/SendingMailWithLocaleTest.php
@@ -5,12 +5,12 @@ use Illuminate\Contracts\Translation\HasLocalePreference; use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Events\LocaleUpdated; -use Illuminate\Testing\Assert; use Illuminate\Mail\Mailable; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\View; +use Illuminate\Testing\Assert; use Mockery as m; use Orchestra\Testbench\TestCase;
true
Other
laravel
framework
db36649acc738ddba3c107b2c513c9125a3380a5.json
Apply fixes from StyleCI (#32214)
tests/Integration/Notifications/SendingNotificationsWithLocaleTest.php
@@ -6,7 +6,6 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Foundation\Events\LocaleUpdated; -use Illuminate\Testing\Assert; use Illuminate\Mail\Mailable; use Illuminate\Notifications\Channels\MailChannel; use Illuminate\Notifications\Messages\MailMessage; @@ -17,6 +16,7 @@ use Illuminate\Support\Facades\Notification as NotificationFacade; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\View; +use Illuminate\Testing\Assert; use Orchestra\Testbench\TestCase; /**
true
Other
laravel
framework
70249eff5becbcab8d924bc825252fd946f7f3a4.json
Fix failing test
tests/Database/DatabaseConnectionTest.php
@@ -259,10 +259,9 @@ public function testTransactionRetriesOnSerializationFailure() $pdo = $this->getMockBuilder(DatabaseConnectionTestMockPDO::class)->setMethods(['beginTransaction', 'commit', 'rollBack'])->getMock(); $mock = $this->getMockConnection([], $pdo); - $pdo->method('commit')->will($this->throwException(new DatabaseConnectionTestMockPDOException('Serialization failure', '40001'))); + $pdo->expects($this->exactly(3))->method('commit')->will($this->throwException(new DatabaseConnectionTestMockPDOException('Serialization failure', '40001'))); $pdo->expects($this->exactly(3))->method('beginTransaction'); $pdo->expects($this->never())->method('rollBack'); - $pdo->expects($this->exactly(3))->method('commit'); $mock->transaction(function () { }, 3); }
false
Other
laravel
framework
ffb812c44502a2f19293c47cbf28b992f1f8ceec.json
Fix failing test
tests/Database/DatabaseConnectionTest.php
@@ -260,10 +260,9 @@ public function testTransactionRetriesOnSerializationFailure() $pdo = $this->getMockBuilder(DatabaseConnectionTestMockPDO::class)->setMethods(['beginTransaction', 'commit', 'rollBack'])->getMock(); $mock = $this->getMockConnection([], $pdo); - $pdo->method('commit')->will($this->throwException(new DatabaseConnectionTestMockPDOException('Serialization failure', '40001'))); + $pdo->expects($this->exactly(3))->method('commit')->will($this->throwException(new DatabaseConnectionTestMockPDOException('Serialization failure', '40001'))); $pdo->expects($this->exactly(3))->method('beginTransaction'); $pdo->expects($this->never())->method('rollBack'); - $pdo->expects($this->exactly(3))->method('commit'); $mock->transaction(function () { }, 3); }
false
Other
laravel
framework
c1d7da92a92f7f297c98bfa9b86a1cc3b37209f8.json
Fix failing test
tests/Database/DatabaseConnectionTest.php
@@ -260,10 +260,8 @@ public function testTransactionRetriesOnSerializationFailure() $pdo = $this->getMockBuilder(DatabaseConnectionTestMockPDO::class)->setMethods(['beginTransaction', 'commit', 'rollBack'])->getMock(); $mock = $this->getMockConnection([], $pdo); - $pdo->method('commit')->will($this->throwException(new DatabaseConnectionTestMockPDOException('Serialization failure', '40001'))); + $pdo->expects($this->exactly(3))->method('commit')->will($this->throwException(new DatabaseConnectionTestMockPDOException('Serialization failure', '40001'))); $pdo->expects($this->exactly(3))->method('beginTransaction'); - $pdo->expects($this->never())->method('rollBack'); - $pdo->expects($this->exactly(3))->method('commit'); $mock->transaction(function () { }, 3); }
false
Other
laravel
framework
4d228d6e9dbcbd4d97c45665980d8b8c685b27e6.json
pass arguments to castUsing
src/Illuminate/Contracts/Database/Eloquent/Castable.php
@@ -7,7 +7,8 @@ interface Castable /** * Get the name of the caster class to use when casting from / to this cast target. * + * @param array $arguments * @return string */ - public static function castUsing(); + public static function castUsing(array $arguments); }
true
Other
laravel
framework
4d228d6e9dbcbd4d97c45665980d8b8c685b27e6.json
pass arguments to castUsing
src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php
@@ -1074,7 +1074,7 @@ protected function resolveCasterClass($key) } if (is_subclass_of($castType, Castable::class)) { - $castType = $castType::castUsing(); + $castType = $castType::castUsing($arguments); } return new $castType(...$arguments);
true
Other
laravel
framework
4d228d6e9dbcbd4d97c45665980d8b8c685b27e6.json
pass arguments to castUsing
tests/Integration/Database/DatabaseEloquentModelCustomCastingTest.php
@@ -243,7 +243,7 @@ public function __construct(string $name) $this->name = $name; } - public static function castUsing() + public static function castUsing(array $arguments) { return ValueObjectCaster::class; }
true
Other
laravel
framework
8ca157bcc1c426db45a3088f971f6d962ee5d09b.json
Apply fixes from StyleCI (#32202)
src/Illuminate/Container/Container.php
@@ -662,7 +662,7 @@ public function get($id) protected function resolve($abstract, $parameters = [], $raiseEvents = true) { $abstract = $this->getAlias($abstract); - + $concrete = $this->getContextualConcrete($abstract); $needsContextualBuild = ! empty($parameters) || ! is_null($concrete);
false
Other
laravel
framework
054cf92493f565de4e0bada75393c50691d06da5.json
Apply fixes from StyleCI (#32185)
tests/Integration/Database/DatabaseEloquentModelCustomCastingTest.php
@@ -5,7 +5,6 @@ use Illuminate\Contracts\Database\Eloquent\Castable; use Illuminate\Contracts\Database\Eloquent\CastsAttributes; use Illuminate\Contracts\Database\Eloquent\CastsInboundAttributes; -use Illuminate\Contracts\Database\Eloquent\HasCasterClass; use Illuminate\Database\Eloquent\Model; /** @@ -121,13 +120,13 @@ public function testWithCastableInterface() $model = new TestEloquentModelWithCustomCast; $model->setRawAttributes([ - 'value_object_with_caster' => serialize(new ValueObject('hello')) + 'value_object_with_caster' => serialize(new ValueObject('hello')), ]); $this->assertInstanceOf(ValueObject::class, $model->value_object_with_caster); $model->setRawAttributes([ - 'value_object_caster_with_argument' => null + 'value_object_caster_with_argument' => null, ]); $this->assertEquals('argument', $model->value_object_caster_with_argument);
false
Other
laravel
framework
af6cc0bf54642a676756f7a2e4cfd0305f00e8db.json
Add support for default values for the props tag We use `array_filter($expression, 'is_string', ARRAY_FILTER_USE_KEY)` to extract properties with string keys, and set the corresponding variable to the default value if unset
src/Illuminate/View/Compilers/Concerns/CompilesComponents.php
@@ -148,6 +148,9 @@ protected function compileEndComponentFirst() protected function compileProps($expression) { return "<?php \$attributes = \$attributes->exceptProps{$expression}; ?> +<?php foreach (array_filter({$expression}, 'is_string', ARRAY_FILTER_USE_KEY) as \$__key => \$__value) { + \$\$__key = \$\$__key ?? \$__value; +} ?> <?php \$__defined_vars = get_defined_vars(); ?> <?php foreach (\$attributes as \$__key => \$__value) { if (array_key_exists(\$__key, \$__defined_vars)) unset(\$\$__key);
false
Other
laravel
framework
8d921630680d887293edc8cbedfdace41c9ad45a.json
Accommodate default values for props tag
src/Illuminate/View/ComponentAttributeBag.php
@@ -90,7 +90,11 @@ public function exceptProps($keys) { $props = []; - foreach ($keys as $key) { + foreach ($keys as $key => $defaultValue) { + // If the "key" value is a numeric key, we assume that no default value + // has been specified, and use the "default value" as the key. + $key = is_numeric($key) ? $defaultValue : $key; + $props[] = $key; $props[] = Str::kebab($key); }
false
Other
laravel
framework
a5af1c60c90e1d933b818fd0c7233f238b5348b6.json
Apply fixes from StyleCI (#32169)
src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php
@@ -35,7 +35,7 @@ trait InteractsWithConsole * * @var array */ - public $expectedChoices = []; + public $expectedChoices = []; /** * Call artisan command and return code.
false
Other
laravel
framework
65a92309e971031f853b4d3aaf2b394afecb9e2a.json
Update workflow name
.github/workflows/tests.yml
@@ -30,7 +30,7 @@ jobs: php: [7.2, 7.3, 7.4] stability: [prefer-lowest, prefer-stable] - name: P${{ matrix.php }} - S${{ matrix.stability }} + name: PHP ${{ matrix.php }} - ${{ matrix.stability }} steps: - name: Checkout code
false
Other
laravel
framework
b0609f429193d7a856816f7cdb8bdc81199c7004.json
Remove swift mailer bindings (#32165)
src/Illuminate/Mail/MailServiceProvider.php
@@ -67,8 +67,6 @@ public function provides() return [ 'mail.manager', 'mailer', - 'swift.mailer', - 'swift.transport', Markdown::class, ]; }
false
Other
laravel
framework
36baff397d6ef4cb0f3980cdfeacc90fe3661b67.json
Fix a phpdoc typo (#32160)
src/Illuminate/Support/Facades/Blade.php
@@ -14,7 +14,7 @@ * @method static bool check(string $name, array ...$parameters) * @method static void component(string $class, string|null $alias = null, string $prefix = '') * @method static void components(array $components, string $prefix = '') - * @method statuc array getClassComponentAliases() + * @method static array getClassComponentAliases() * @method static void aliasComponent(string $path, string|null $alias = null) * @method static void include(string $path, string|null $alias = null) * @method static void aliasInclude(string $path, string|null $alias = null)
false
Other
laravel
framework
aece7d78f3d28b2cdb63185dcc4a9b6092841310.json
Add missing docblocks in Blade facade (#32152)
src/Illuminate/Support/Facades/Blade.php
@@ -12,10 +12,15 @@ * @method static array getExtensions() * @method static void if(string $name, callable $callback) * @method static bool check(string $name, array ...$parameters) - * @method static void component(string $path, string|null $alias = null) + * @method static void component(string $class, string|null $alias = null, string $prefix = '') + * @method static void components(array $components, string $prefix = '') + * @method statuc array getClassComponentAliases() + * @method static void aliasComponent(string $path, string|null $alias = null) * @method static void include(string $path, string|null $alias = null) + * @method static void aliasInclude(string $path, string|null $alias = null) * @method static void directive(string $name, callable $handler) * @method static array getCustomDirectives() + * @method static void precompiler(callable $precompiler) * @method static void setEchoFormat(string $format) * @method static void withDoubleEncoding() * @method static void withoutDoubleEncoding()
false
Other
laravel
framework
490a21c03ccbaea730cfb77d0982cf2670124f28.json
Add missing var and return. (#32150)
src/Illuminate/Auth/SessionGuard.php
@@ -632,7 +632,8 @@ protected function fireAttemptEvent(array $credentials, $remember = false) /** * Fires the validated event if the dispatcher is set. * - * @param $user + * @param \Illuminate\Contracts\Auth\Authenticatable $user + * @return void */ protected function fireValidatedEvent($user) {
true
Other
laravel
framework
490a21c03ccbaea730cfb77d0982cf2670124f28.json
Add missing var and return. (#32150)
src/Illuminate/Database/Eloquent/Collection.php
@@ -446,7 +446,7 @@ public function keys() /** * Zip the collection together with one or more arrays. * - * @param mixed ...$items + * @param mixed ...$items * @return \Illuminate\Support\Collection */ public function zip($items)
true
Other
laravel
framework
490a21c03ccbaea730cfb77d0982cf2670124f28.json
Add missing var and return. (#32150)
src/Illuminate/Database/Eloquent/HigherOrderBuilderProxy.php
@@ -26,6 +26,7 @@ class HigherOrderBuilderProxy * * @param \Illuminate\Database\Eloquent\Builder $builder * @param string $method + * @return void */ public function __construct(Builder $builder, $method) {
true
Other
laravel
framework
490a21c03ccbaea730cfb77d0982cf2670124f28.json
Add missing var and return. (#32150)
src/Illuminate/Database/Eloquent/Relations/BelongsTo.php
@@ -13,6 +13,8 @@ class BelongsTo extends Relation /** * The child model instance of the relation. + * + * @var \Illuminate\Database\Eloquent\Model */ protected $child;
true
Other
laravel
framework
490a21c03ccbaea730cfb77d0982cf2670124f28.json
Add missing var and return. (#32150)
src/Illuminate/Database/Schema/Blueprint.php
@@ -51,11 +51,15 @@ class Blueprint /** * The default character set that should be used for the table. + * + * @var string */ public $charset; /** * The collation that should be used for the table. + * + * @var string */ public $collation;
true
Other
laravel
framework
490a21c03ccbaea730cfb77d0982cf2670124f28.json
Add missing var and return. (#32150)
src/Illuminate/Http/Client/ResponseSequence.php
@@ -89,7 +89,7 @@ public function pushFile(string $filePath, int $status = 200, array $headers = [ /** * Push a response to the sequence. * - * @param mixed $response + * @param mixed $response * @return $this */ public function pushResponse($response)
true
Other
laravel
framework
490a21c03ccbaea730cfb77d0982cf2670124f28.json
Add missing var and return. (#32150)
src/Illuminate/Support/Collection.php
@@ -1214,7 +1214,7 @@ public function values() * e.g. new Collection([1, 2, 3])->zip([4, 5, 6]); * => [[1, 4], [2, 5], [3, 6]] * - * @param mixed ...$items + * @param mixed ...$items * @return static */ public function zip($items)
true
Other
laravel
framework
490a21c03ccbaea730cfb77d0982cf2670124f28.json
Add missing var and return. (#32150)
src/Illuminate/Support/LazyCollection.php
@@ -1151,7 +1151,7 @@ public function values() * e.g. new LazyCollection([1, 2, 3])->zip([4, 5, 6]); * => [[1, 4], [2, 5], [3, 6]] * - * @param mixed ...$items + * @param mixed ...$items * @return static */ public function zip($items)
true
Other
laravel
framework
490a21c03ccbaea730cfb77d0982cf2670124f28.json
Add missing var and return. (#32150)
tests/Auth/AuthAccessGateTest.php
@@ -760,9 +760,9 @@ public function testEveryAbilityCheckFailsIfNonePass() /** * @dataProvider hasAbilitiesTestDataProvider * - * @param array $abilitiesToSet - * @param array|string $abilitiesToCheck - * @param bool $expectedHasValue + * @param array $abilitiesToSet + * @param array|string $abilitiesToCheck + * @param bool $expectedHasValue */ public function testHasAbilities($abilitiesToSet, $abilitiesToCheck, $expectedHasValue) {
true
Other
laravel
framework
490a21c03ccbaea730cfb77d0982cf2670124f28.json
Add missing var and return. (#32150)
tests/Cache/CacheRepositoryTest.php
@@ -223,7 +223,7 @@ public function dataProviderTestGetSeconds() /** * @dataProvider dataProviderTestGetSeconds - * @param mixed $duration + * @param mixed $duration */ public function testGetSeconds($duration) {
true
Other
laravel
framework
490a21c03ccbaea730cfb77d0982cf2670124f28.json
Add missing var and return. (#32150)
tests/Cache/RedisCacheIntegrationTest.php
@@ -28,7 +28,7 @@ protected function tearDown(): void /** * @dataProvider redisDriverProvider * - * @param string $driver + * @param string $driver */ public function testRedisCacheAddTwice($driver) { @@ -44,7 +44,7 @@ public function testRedisCacheAddTwice($driver) * * @dataProvider redisDriverProvider * - * @param string $driver + * @param string $driver */ public function testRedisCacheAddFalse($driver) { @@ -60,7 +60,7 @@ public function testRedisCacheAddFalse($driver) * * @dataProvider redisDriverProvider * - * @param string $driver + * @param string $driver */ public function testRedisCacheAddNull($driver) {
true
Other
laravel
framework
490a21c03ccbaea730cfb77d0982cf2670124f28.json
Add missing var and return. (#32150)
tests/Database/DatabaseEloquentModelTest.php
@@ -1991,12 +1991,6 @@ public function testNotTouchingModelWithoutTimestamps() ); } - /** - * Test that the getOriginal method on an Eloquent model also uses the casts array. - * - * @param void - * @return void - */ public function testGetOriginalCastsAttributes() { $model = new EloquentModelCastingStub();
true
Other
laravel
framework
490a21c03ccbaea730cfb77d0982cf2670124f28.json
Add missing var and return. (#32150)
tests/Filesystem/FilesystemTest.php
@@ -547,7 +547,7 @@ public function testHash() } /** - * @param string $file + * @param string $file * @return int */ private function getFilePermissions($file)
true
Other
laravel
framework
490a21c03ccbaea730cfb77d0982cf2670124f28.json
Add missing var and return. (#32150)
tests/Http/HttpJsonResponseTest.php
@@ -79,7 +79,7 @@ public function testInvalidArgumentExceptionOnJsonError($data) } /** - * @param mixed $data + * @param mixed $data * * @dataProvider jsonErrorDataProvider */
true
Other
laravel
framework
490a21c03ccbaea730cfb77d0982cf2670124f28.json
Add missing var and return. (#32150)
tests/Integration/Database/DatabaseMySqlConnectionTest.php
@@ -47,9 +47,9 @@ protected function tearDown(): void /** * @dataProvider floatComparisonsDataProvider * - * @param float $value the value to compare against the JSON value - * @param string $operator the comparison operator to use. e.g. '<', '>', '=' - * @param bool $shouldMatch true if the comparison should match, false if not + * @param float $value the value to compare against the JSON value + * @param string $operator the comparison operator to use. e.g. '<', '>', '=' + * @param bool $shouldMatch true if the comparison should match, false if not */ public function testJsonFloatComparison(float $value, string $operator, bool $shouldMatch): void {
true
Other
laravel
framework
490a21c03ccbaea730cfb77d0982cf2670124f28.json
Add missing var and return. (#32150)
tests/Mail/MailSesTransportTest.php
@@ -78,11 +78,6 @@ public function __construct($responseValue) $this->getResponse = $responseValue; } - /** - * Mock the get() call for the sendRawEmail response. - * @param [type] $key [description] - * @return [type] [description] - */ public function get($key) { return $this->getResponse;
true
Other
laravel
framework
490a21c03ccbaea730cfb77d0982cf2670124f28.json
Add missing var and return. (#32150)
tests/Queue/RedisQueueIntegrationTest.php
@@ -39,7 +39,7 @@ protected function tearDown(): void /** * @dataProvider redisDriverProvider * - * @param string $driver + * @param string $driver */ public function testExpiredJobsArePopped($driver) { @@ -111,7 +111,7 @@ public function testMigrateMoreThan100Jobs($driver) /** * @dataProvider redisDriverProvider * - * @param string $driver + * @param string $driver */ public function testPopProperlyPopsJobOffOfRedis($driver) { @@ -146,7 +146,7 @@ public function testPopProperlyPopsJobOffOfRedis($driver) /** * @dataProvider redisDriverProvider * - * @param string $driver + * @param string $driver */ public function testPopProperlyPopsDelayedJobOffOfRedis($driver) { @@ -173,7 +173,7 @@ public function testPopProperlyPopsDelayedJobOffOfRedis($driver) /** * @dataProvider redisDriverProvider * - * @param string $driver + * @param string $driver */ public function testPopPopsDelayedJobOffOfRedisWhenExpireNull($driver) { @@ -202,7 +202,7 @@ public function testPopPopsDelayedJobOffOfRedisWhenExpireNull($driver) /** * @dataProvider redisDriverProvider * - * @param string $driver + * @param string $driver */ public function testBlockingPopProperlyPopsJobOffOfRedis($driver) { @@ -223,7 +223,7 @@ public function testBlockingPopProperlyPopsJobOffOfRedis($driver) /** * @dataProvider redisDriverProvider * - * @param string $driver + * @param string $driver */ public function testBlockingPopProperlyPopsExpiredJobs($driver) { @@ -254,7 +254,7 @@ public function testBlockingPopProperlyPopsExpiredJobs($driver) /** * @dataProvider redisDriverProvider * - * @param string $driver + * @param string $driver */ public function testNotExpireJobsWhenExpireNull($driver) { @@ -299,7 +299,7 @@ public function testNotExpireJobsWhenExpireNull($driver) /** * @dataProvider redisDriverProvider * - * @param string $driver + * @param string $driver */ public function testExpireJobsWhenExpireSet($driver) { @@ -328,7 +328,7 @@ public function testExpireJobsWhenExpireSet($driver) /** * @dataProvider redisDriverProvider * - * @param string $driver + * @param string $driver */ public function testRelease($driver) { @@ -369,7 +369,7 @@ public function testRelease($driver) /** * @dataProvider redisDriverProvider * - * @param string $driver + * @param string $driver */ public function testReleaseInThePast($driver) { @@ -387,7 +387,7 @@ public function testReleaseInThePast($driver) /** * @dataProvider redisDriverProvider * - * @param string $driver + * @param string $driver */ public function testDelete($driver) { @@ -411,7 +411,7 @@ public function testDelete($driver) /** * @dataProvider redisDriverProvider * - * @param string $driver + * @param string $driver */ public function testSize($driver) { @@ -430,7 +430,7 @@ public function testSize($driver) } /** - * @param string $driver + * @param string $driver * @param string $default * @param string $connection * @param int $retryAfter
true
Other
laravel
framework
490a21c03ccbaea730cfb77d0982cf2670124f28.json
Add missing var and return. (#32150)
tests/Redis/RedisManagerExtensionTest.php
@@ -96,8 +96,8 @@ class FakeRedisConnnector implements Connector /** * Create a new clustered Predis connection. * - * @param array $config - * @param array $options + * @param array $config + * @param array $options * @return \Illuminate\Contracts\Redis\Connection */ public function connect(array $config, array $options) @@ -108,9 +108,9 @@ public function connect(array $config, array $options) /** * Create a new clustered Predis connection. * - * @param array $config - * @param array $clusterOptions - * @param array $options + * @param array $config + * @param array $clusterOptions + * @param array $options * @return \Illuminate\Contracts\Redis\Connection */ public function connectToCluster(array $config, array $clusterOptions, array $options)
true
Other
laravel
framework
0574295121ae6c86266cb2e7d398bc7722904236.json
improve readability (#32146)
src/Illuminate/Database/Connection.php
@@ -327,8 +327,9 @@ public function select($query, $bindings = [], $useReadPdo = true) // For select statements, we'll simply execute the query and return an array // of the database result set. Each element in the array will be a single // row from the database table, and will either be an array or objects. - $statement = $this->prepared($this->getPdoForSelect($useReadPdo) - ->prepare($query)); + $statement = $this->prepared( + $this->getPdoForSelect($useReadPdo)->prepare($query) + ); $this->bindValues($statement, $this->prepareBindings($bindings));
false
Other
laravel
framework
3dc382c5a71b180d3b848b02a71e0d7efc973222.json
remove an unnecessary checking (#32142)
src/Illuminate/Database/Query/Grammars/Grammar.php
@@ -85,7 +85,7 @@ protected function compileComponents(Builder $query) $sql = []; foreach ($this->selectComponents as $component) { - if (isset($query->$component) && ! is_null($query->$component)) { + if (isset($query->$component)) { $method = 'compile'.ucfirst($component); $sql[$component] = $this->$method($query, $query->$component);
false
Other
laravel
framework
252c2cc648035a16e545147542d5b62ef58ca6f4.json
Remove useless imports.
tests/Filesystem/FilesystemTest.php
@@ -6,7 +6,6 @@ use Illuminate\Filesystem\Filesystem; use Illuminate\Filesystem\FilesystemManager; use Illuminate\Foundation\Application; -use League\Flysystem\Adapter\Ftp; use Mockery as m; use PHPUnit\Framework\TestCase; use SplFileInfo;
true
Other
laravel
framework
252c2cc648035a16e545147542d5b62ef58ca6f4.json
Remove useless imports.
tests/Http/HttpClientTest.php
@@ -3,7 +3,6 @@ namespace Illuminate\Tests\Http; use Illuminate\Http\Client\Factory; -use Illuminate\Http\Client\PendingRequest; use Illuminate\Http\Client\Request; use Illuminate\Support\Str; use OutOfBoundsException;
true
Other
laravel
framework
caf562f8e2d165898d6e8abe0549a5fb7384d92d.json
remove duplicate comment (#32138)
src/Illuminate/Database/Query/Grammars/Grammar.php
@@ -85,9 +85,6 @@ protected function compileComponents(Builder $query) $sql = []; foreach ($this->selectComponents as $component) { - // To compile the query, we'll spin through each component of the query and - // see if that component exists. If it does we'll just call the compiler - // function for the component which is responsible for making the SQL. if (isset($query->$component) && ! is_null($query->$component)) { $method = 'compile'.ucfirst($component);
false
Other
laravel
framework
327a1cefc07e8f307b5de1a0d6abf27d42cdbc15.json
Add HasCasterClass interface
src/Illuminate/Contracts/Database/Eloquent/HasCasterClass.php
@@ -0,0 +1,13 @@ +<?php + +namespace Illuminate\Contracts\Database\Eloquent; + +interface HasCasterClass +{ + /** + * Get the caster class for this class + * + * @return string + */ + public static function getCasterClass(); +}
true
Other
laravel
framework
327a1cefc07e8f307b5de1a0d6abf27d42cdbc15.json
Add HasCasterClass interface
src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php
@@ -5,6 +5,7 @@ use Carbon\CarbonInterface; use DateTimeInterface; use Illuminate\Contracts\Database\Eloquent\CastsInboundAttributes; +use Illuminate\Contracts\Database\Eloquent\HasCasterClass; use Illuminate\Contracts\Support\Arrayable; use Illuminate\Database\Eloquent\JsonEncodingException; use Illuminate\Database\Eloquent\Relations\Relation; @@ -1061,7 +1062,13 @@ class_exists($class = $this->parseCasterClass($this->getCasts()[$key])) && */ protected function resolveCasterClass($key) { - if (strpos($castType = $this->getCasts()[$key], ':') === false) { + $castType = $this->getCasts()[$key]; + + if (is_subclass_of($castType, HasCasterClass::class)) { + $castType = $castType::getCasterClass(); + } + + if (strpos($castType, ':') === false) { return new $castType; }
true
Other
laravel
framework
327a1cefc07e8f307b5de1a0d6abf27d42cdbc15.json
Add HasCasterClass interface
tests/Integration/Database/DatabaseEloquentModelCustomCastingTest.php
@@ -4,6 +4,7 @@ use Illuminate\Contracts\Database\Eloquent\CastsAttributes; use Illuminate\Contracts\Database\Eloquent\CastsInboundAttributes; +use Illuminate\Contracts\Database\Eloquent\HasCasterClass; use Illuminate\Database\Eloquent\Model; /** @@ -73,6 +74,33 @@ public function testBasicCustomCasting() $model->syncOriginal(); $model->options = ['foo' => 'bar']; $this->assertTrue($model->isDirty('options')); + + $model = new TestEloquentModelWithCustomCast; + + $model->setRawAttributes([ + 'address_line_one' => '110 Kingsbrook St.', + 'address_line_two' => 'My Childhood House', + ]); + + $this->assertSame('110 Kingsbrook St.', $model->address_with_caster->lineOne); + $this->assertSame('My Childhood House', $model->address_with_caster->lineTwo); + + $this->assertSame('110 Kingsbrook St.', $model->toArray()['address_line_one']); + $this->assertSame('My Childhood House', $model->toArray()['address_line_two']); + + $model->address_with_caster->lineOne = '117 Spencer St.'; + + $this->assertFalse(isset($model->toArray()['address'])); + $this->assertSame('117 Spencer St.', $model->toArray()['address_line_one']); + $this->assertSame('My Childhood House', $model->toArray()['address_line_two']); + + $this->assertSame('117 Spencer St.', json_decode($model->toJson(), true)['address_line_one']); + $this->assertSame('My Childhood House', json_decode($model->toJson(), true)['address_line_two']); + + $model->address_with_caster = null; + + $this->assertNull($model->toArray()['address_line_one']); + $this->assertNull($model->toArray()['address_line_two']); } public function testOneWayCasting() @@ -135,6 +163,7 @@ class TestEloquentModelWithCustomCast extends Model 'other_password' => HashCaster::class.':md5', 'uppercase' => UppercaseCaster::class, 'options' => JsonCaster::class, + 'address_with_caster' => AddressWithCaster::class, ]; } @@ -201,3 +230,11 @@ public function __construct($lineOne, $lineTwo) $this->lineTwo = $lineTwo; } } + +class AddressWithCaster extends Address implements HasCasterClass +{ + public static function getCasterClass() + { + return AddressCaster::class; + } +}
true
Other
laravel
framework
7d387b910cf7d1e7871b43bc199537b90694ba69.json
publish seeder stub (#32122)
src/Illuminate/Database/Console/Seeds/SeederMakeCommand.php
@@ -69,7 +69,20 @@ public function handle() */ protected function getStub() { - return __DIR__.'/stubs/seeder.stub'; + return $this->resolveStubPath('/stubs/seeder.stub'); + } + + /** + * Resolve the fully-qualified path to the stub. + * + * @param string $stub + * @return string + */ + protected function resolveStubPath($stub) + { + return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) + ? $customPath + : __DIR__.$stub; } /**
true
Other
laravel
framework
7d387b910cf7d1e7871b43bc199537b90694ba69.json
publish seeder stub (#32122)
src/Illuminate/Database/Console/Seeds/stubs/seeder.stub
@@ -2,7 +2,7 @@ use Illuminate\Database\Seeder; -class DummyClass extends Seeder +class {{ class }} extends Seeder { /** * Run the database seeds.
true
Other
laravel
framework
7d387b910cf7d1e7871b43bc199537b90694ba69.json
publish seeder stub (#32122)
src/Illuminate/Foundation/Console/StubPublishCommand.php
@@ -41,6 +41,7 @@ public function handle() __DIR__.'/stubs/test.stub' => $stubsPath.'/test.stub', __DIR__.'/stubs/test.unit.stub' => $stubsPath.'/test.unit.stub', realpath(__DIR__.'/../../Database/Console/Factories/stubs/factory.stub') => $stubsPath.'/factory.stub', + realpath(__DIR__.'/../../Database/Console/Seeds/stubs/seeder.stub') => $stubsPath.'/seeder.stub', realpath(__DIR__.'/../../Database/Migrations/stubs/migration.create.stub') => $stubsPath.'/migration.create.stub', realpath(__DIR__.'/../../Database/Migrations/stubs/migration.stub') => $stubsPath.'/migration.stub', realpath(__DIR__.'/../../Database/Migrations/stubs/migration.update.stub') => $stubsPath.'/migration.update.stub',
true
Other
laravel
framework
39056ae4cb6172ef7d86dbc2b1a54c0bf97f0c04.json
add missing periods (#32121)
src/Illuminate/Database/Connectors/ConnectionFactory.php
@@ -250,7 +250,7 @@ public function createConnector(array $config) return new SqlServerConnector; } - throw new InvalidArgumentException("Unsupported driver [{$config['driver']}]"); + throw new InvalidArgumentException("Unsupported driver [{$config['driver']}]."); } /** @@ -282,6 +282,6 @@ protected function createConnection($driver, $connection, $database, $prefix = ' return new SqlServerConnection($connection, $database, $prefix, $config); } - throw new InvalidArgumentException("Unsupported driver [{$driver}]"); + throw new InvalidArgumentException("Unsupported driver [{$driver}]."); } }
true
Other
laravel
framework
39056ae4cb6172ef7d86dbc2b1a54c0bf97f0c04.json
add missing periods (#32121)
src/Illuminate/Filesystem/Filesystem.php
@@ -49,7 +49,7 @@ public function get($path, $lock = false) return $lock ? $this->sharedGet($path) : file_get_contents($path); } - throw new FileNotFoundException("File does not exist at path {$path}"); + throw new FileNotFoundException("File does not exist at path {$path}."); } /** @@ -95,7 +95,7 @@ public function getRequire($path) return require $path; } - throw new FileNotFoundException("File does not exist at path {$path}"); + throw new FileNotFoundException("File does not exist at path {$path}."); } /**
true
Other
laravel
framework
39056ae4cb6172ef7d86dbc2b1a54c0bf97f0c04.json
add missing periods (#32121)
src/Illuminate/Filesystem/FilesystemAdapter.php
@@ -725,7 +725,7 @@ protected function parseVisibility($visibility) return AdapterInterface::VISIBILITY_PRIVATE; } - throw new InvalidArgumentException("Unknown visibility: {$visibility}"); + throw new InvalidArgumentException("Unknown visibility: {$visibility}."); } /**
true
Other
laravel
framework
39056ae4cb6172ef7d86dbc2b1a54c0bf97f0c04.json
add missing periods (#32121)
src/Illuminate/Http/UploadedFile.php
@@ -98,7 +98,7 @@ public function storeAs($path, $name, $options = []) public function get() { if (! $this->isValid()) { - throw new FileNotFoundException("File does not exist at path {$this->getPathname()}"); + throw new FileNotFoundException("File does not exist at path {$this->getPathname()}."); } return file_get_contents($this->getPathname());
true
Other
laravel
framework
39056ae4cb6172ef7d86dbc2b1a54c0bf97f0c04.json
add missing periods (#32121)
src/Illuminate/Queue/QueueManager.php
@@ -169,7 +169,7 @@ protected function resolve($name) protected function getConnector($driver) { if (! isset($this->connectors[$driver])) { - throw new InvalidArgumentException("No connector for [$driver]"); + throw new InvalidArgumentException("No connector for [$driver]."); } return call_user_func($this->connectors[$driver]);
true
Other
laravel
framework
39056ae4cb6172ef7d86dbc2b1a54c0bf97f0c04.json
add missing periods (#32121)
src/Illuminate/View/Factory.php
@@ -281,7 +281,7 @@ public function exists($view) public function getEngineFromPath($path) { if (! $extension = $this->getExtension($path)) { - throw new InvalidArgumentException("Unrecognized extension in file: {$path}"); + throw new InvalidArgumentException("Unrecognized extension in file: {$path}."); } $engine = $this->extensions[$extension];
true
Other
laravel
framework
39056ae4cb6172ef7d86dbc2b1a54c0bf97f0c04.json
add missing periods (#32121)
tests/Foundation/FoundationFormRequestTest.php
@@ -134,7 +134,7 @@ protected function catchException($class, $excecutor) throw $e; } - throw new Exception("No exception thrown. Expected exception {$class}"); + throw new Exception("No exception thrown. Expected exception {$class}."); } /**
true
Other
laravel
framework
62b1f8d7af46cc288ab95a5ecf087d1f736f4922.json
Fix custom cast (#32118)
src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php
@@ -559,7 +559,7 @@ protected function getClassCastableAttributeValue($key) $caster = $this->resolveCasterClass($key); return $this->classCastCache[$key] = $caster instanceof CastsInboundAttributes - ? $this->attributes[$key] + ? ($this->attributes[$key] ?? null) : $caster->get($this, $key, $this->attributes[$key] ?? null, $this->attributes); } }
true
Other
laravel
framework
62b1f8d7af46cc288ab95a5ecf087d1f736f4922.json
Fix custom cast (#32118)
tests/Database/DatabaseEloquentModelTest.php
@@ -7,6 +7,7 @@ use DateTimeInterface; use Exception; use Foo\Bar\EloquentModelNamespacedStub; +use Illuminate\Contracts\Database\Eloquent\CastsInboundAttributes; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Database\Connection; use Illuminate\Database\ConnectionResolverInterface; @@ -2068,6 +2069,14 @@ public function testGetOriginalCastsAttributes() $this->assertEquals(['foo' => 'bar'], $model->getOriginal('collectionAttribute')->toArray()); $this->assertEquals(['foo' => 'bar2'], $model->getAttribute('collectionAttribute')->toArray()); } + + public function testUnsavedModel() + { + $user = new UnsavedModel; + $user->name = null; + + $this->assertNull($user->name); + } } class EloquentTestObserverStub @@ -2493,3 +2502,16 @@ class EloquentModelWithUpdatedAtNull extends Model protected $table = 'stub'; const UPDATED_AT = null; } + +class UnsavedModel extends Model +{ + protected $casts = ['name' => Uppercase::class]; +} + +class Uppercase implements CastsInboundAttributes +{ + public function set($model, string $key, $value, array $attributes) + { + return is_string($value) ? strtoupper($value) : $value; + } +}
true
Other
laravel
framework
1e72ab2eab7f1720dfb5596898ab7bf5d7f80383.json
Publish middleware stub (#32099)
src/Illuminate/Foundation/Console/StubPublishCommand.php
@@ -56,6 +56,7 @@ public function handle() realpath(__DIR__.'/../../Routing/Console/stubs/controller.nested.stub') => $stubsPath.'/controller.nested.stub', realpath(__DIR__.'/../../Routing/Console/stubs/controller.plain.stub') => $stubsPath.'/controller.plain.stub', realpath(__DIR__.'/../../Routing/Console/stubs/controller.stub') => $stubsPath.'/controller.stub', + realpath(__DIR__.'/../../Routing/Console/stubs/middleware.stub') => $stubsPath.'/middleware.stub', ]; foreach ($files as $from => $to) {
true
Other
laravel
framework
1e72ab2eab7f1720dfb5596898ab7bf5d7f80383.json
Publish middleware stub (#32099)
src/Illuminate/Routing/Console/MiddlewareMakeCommand.php
@@ -34,7 +34,20 @@ class MiddlewareMakeCommand extends GeneratorCommand */ protected function getStub() { - return __DIR__.'/stubs/middleware.stub'; + return $this->resolveStubPath('/stubs/middleware.stub'); + } + + /** + * Resolve the fully-qualified path to the stub. + * + * @param string $stub + * @return string + */ + protected function resolveStubPath($stub) + { + return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) + ? $customPath + : __DIR__.$stub; } /**
true
Other
laravel
framework
1e72ab2eab7f1720dfb5596898ab7bf5d7f80383.json
Publish middleware stub (#32099)
src/Illuminate/Routing/Console/stubs/middleware.stub
@@ -1,10 +1,10 @@ <?php -namespace DummyNamespace; +namespace {{ namespace }}; use Closure; -class DummyClass +class {{ class }} { /** * Handle an incoming request.
true
Other
laravel
framework
2e88a66fc3a96504d2bc38b44b0168dd4f1430cb.json
Publish factory stub (#32100)
src/Illuminate/Database/Console/Factories/FactoryMakeCommand.php
@@ -35,7 +35,20 @@ class FactoryMakeCommand extends GeneratorCommand */ protected function getStub() { - return __DIR__.'/stubs/factory.stub'; + return $this->resolveStubPath('/stubs/factory.stub'); + } + + /** + * Resolve the fully-qualified path to the stub. + * + * @param string $stub + * @return string + */ + protected function resolveStubPath($stub) + { + return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) + ? $customPath + : __DIR__.$stub; } /** @@ -52,16 +65,17 @@ protected function buildClass($name) $model = class_basename($namespaceModel); + $replace = [ + 'NamespacedDummyModel' => $namespaceModel, + '{{ namespacedModel }}' => $namespaceModel, + '{{namespacedModel}}' => $namespaceModel, + 'DummyModel' => $model, + '{{ model }}' => $model, + '{{model}}' => $model, + ]; + return str_replace( - [ - 'NamespacedDummyModel', - 'DummyModel', - ], - [ - $namespaceModel, - $model, - ], - parent::buildClass($name) + array_keys($replace), array_values($replace), parent::buildClass($name) ); }
true
Other
laravel
framework
2e88a66fc3a96504d2bc38b44b0168dd4f1430cb.json
Publish factory stub (#32100)
src/Illuminate/Database/Console/Factories/stubs/factory.stub
@@ -3,9 +3,9 @@ /** @var \Illuminate\Database\Eloquent\Factory $factory */ use Faker\Generator as Faker; -use NamespacedDummyModel; +use {{ namespacedModel }}; -$factory->define(DummyModel::class, function (Faker $faker) { +$factory->define({{ model }}::class, function (Faker $faker) { return [ // ];
true
Other
laravel
framework
2e88a66fc3a96504d2bc38b44b0168dd4f1430cb.json
Publish factory stub (#32100)
src/Illuminate/Foundation/Console/StubPublishCommand.php
@@ -43,6 +43,7 @@ public function handle() realpath(__DIR__.'/../../Database/Migrations/stubs/migration.create.stub') => $stubsPath.'/migration.create.stub', realpath(__DIR__.'/../../Database/Migrations/stubs/migration.stub') => $stubsPath.'/migration.stub', realpath(__DIR__.'/../../Database/Migrations/stubs/migration.update.stub') => $stubsPath.'/migration.update.stub', + realpath(__DIR__.'/../../Database/Console/Factories/stubs/factory.stub') => $stubsPath.'/factory.stub', realpath(__DIR__.'/../../Foundation/Console/stubs/policy.plain.stub') => $stubsPath.'/policy.plain.stub', realpath(__DIR__.'/../../Foundation/Console/stubs/policy.stub') => $stubsPath.'/policy.stub', realpath(__DIR__.'/../../Foundation/Console/stubs/rule.stub') => $stubsPath.'/rule.stub',
true
Other
laravel
framework
ce33b09cc7574427b4dd4709fce2213c406f2160.json
Update ramsey/uuid lib (#32086) Update to version 4.0
composer.json
@@ -29,7 +29,7 @@ "opis/closure": "^3.1", "psr/container": "^1.0", "psr/simple-cache": "^1.0", - "ramsey/uuid": "^3.7", + "ramsey/uuid": "^3.7|^4.0", "swiftmailer/swiftmailer": "^6.0", "symfony/console": "^5.0", "symfony/error-handler": "^5.0",
true
Other
laravel
framework
ce33b09cc7574427b4dd4709fce2213c406f2160.json
Update ramsey/uuid lib (#32086) Update to version 4.0
src/Illuminate/Queue/composer.json
@@ -24,7 +24,7 @@ "illuminate/pipeline": "^7.0", "illuminate/support": "^7.0", "opis/closure": "^3.1", - "ramsey/uuid": "^3.7", + "ramsey/uuid": "^3.7|^4.0", "symfony/process": "^5.0" }, "autoload": {
true
Other
laravel
framework
ce33b09cc7574427b4dd4709fce2213c406f2160.json
Update ramsey/uuid lib (#32086) Update to version 4.0
src/Illuminate/Support/composer.json
@@ -41,7 +41,7 @@ "suggest": { "illuminate/filesystem": "Required to use the composer class (^7.0).", "moontoast/math": "Required to use ordered UUIDs (^1.1).", - "ramsey/uuid": "Required to use Str::uuid() (^3.7).", + "ramsey/uuid": "Required to use Str::uuid() (^3.7|^4.0).", "symfony/process": "Required to use the composer class (^5.0).", "symfony/var-dumper": "Required to use the dd function (^5.0).", "vlucas/phpdotenv": "Required to use the Env class and env helper (^4.0)."
true
Other
laravel
framework
3b267932d4666e56bf5fe74c6e735497d6fd6039.json
Improve issue templates (#32087)
.github/ISSUE_TEMPLATE/1_Bug_report.md
@@ -1,8 +1,11 @@ --- name: "Bug report" -about: 'Report a general framework issue. Please ensure your Laravel version is still supported: https://laravel.com/docs/releases#support-policy' +about: 'Report something that's broken. Please ensure your Laravel version is still supported: https://laravel.com/docs/releases#support-policy' --- +<!-- DO NOT THROW THIS AWAY --> +<!-- Fill out the FULL versions with patch versions --> + - Laravel Version: #.#.# - PHP Version: #.#.# - Database Driver & Version:
true
Other
laravel
framework
3b267932d4666e56bf5fe74c6e735497d6fd6039.json
Improve issue templates (#32087)
.github/ISSUE_TEMPLATE/config.yml
@@ -3,9 +3,9 @@ contact_links: - name: Feature request url: https://github.com/laravel/ideas/issues about: 'For ideas or feature requests, open up an issue on the Laravel ideas repository' - - name: Support question + - name: Questions & Other url: https://laravel.com/docs/contributions#support-questions - about: 'This repository is only for reporting bugs. If you need help using the library, click:' + about: 'This repository is only for reporting bugs. If you have a question or need help using the library, click:' - name: Documentation issue url: https://github.com/laravel/docs about: For documentation issues, open a pull request at the laravel/docs repository
true
Other
laravel
framework
e128a9a579eba3a06e9e73040a568b447c091fee.json
Apply special wrapping logic to notifiable models
src/Illuminate/Notifications/SendQueuedNotifications.php
@@ -4,6 +4,8 @@ use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Database\Eloquent\Collection as EloquentCollection; +use Illuminate\Database\Eloquent\Model; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Collection; @@ -50,7 +52,7 @@ class SendQueuedNotifications implements ShouldQueue /** * Create a new job instance. * - * @param \Illuminate\Support\Collection $notifiables + * @param mixed $notifiables * @param \Illuminate\Notifications\Notification $notification * @param array|null $channels * @return void @@ -59,7 +61,7 @@ public function __construct($notifiables, $notification, array $channels = null) { $this->channels = $channels; $this->notification = $notification; - $this->notifiables = Collection::wrap($notifiables); + $this->notifiables = $this->wrapNotifiables($notifiables); $this->tries = property_exists($notification, 'tries') ? $notification->tries : null; $this->timeout = property_exists($notification, 'timeout') ? $notification->timeout : null; } @@ -136,4 +138,27 @@ public function __clone() $this->notifiables = clone $this->notifiables; $this->notification = clone $this->notification; } + + /** + * Wrap the notifiable(s) in a collection. + * + * @param mixed $notifiables + * @return \Illuminate\Support\Collection + */ + protected function wrapNotifiables($notifiables) + { + if ($notifiables instanceof Collection) { + // If the notifiable(s) are already wrapped, pass them as is. + // This prevents any custom queueable collections from being re-wrapped + return $notifiables; + } + + if ($notifiables instanceof Model) { + // In the case of a model we want to wrap it in an eloquent collection + // This way the job can take advantage of model serialization + return EloquentCollection::wrap($notifiables); + } + + return Collection::wrap($notifiables); + } }
true
Other
laravel
framework
e128a9a579eba3a06e9e73040a568b447c091fee.json
Apply special wrapping logic to notifiable models
tests/Notifications/NotificationSendQueuedNotificationTest.php
@@ -2,9 +2,12 @@ namespace Illuminate\Tests\Notifications; +use Illuminate\Contracts\Database\ModelIdentifier; +use Illuminate\Notifications\AnonymousNotifiable; use Illuminate\Notifications\ChannelManager; use Illuminate\Notifications\SendQueuedNotifications; use Illuminate\Support\Collection; +use Illuminate\Tests\Integration\Notifications\NotifiableUser; use Mockery as m; use PHPUnit\Framework\TestCase; @@ -26,4 +29,26 @@ public function testNotificationsCanBeSent() }); $job->handle($manager); } + + public function testSerializationOfNotifiableModel() + { + $identifier = new ModelIdentifier(NotifiableUser::class, [null], [], null); + $serializedIdentifier = serialize($identifier); + + $job = new SendQueuedNotifications(new NotifiableUser(), 'notification'); + $serialized = serialize($job); + + $this->assertStringContainsString($serializedIdentifier, $serialized); + } + + public function testSerializationOfNormalNotifiable() + { + $notifiable = new AnonymousNotifiable(); + $serializedNotifiable = serialize($notifiable); + + $job = new SendQueuedNotifications($notifiable, 'notification'); + $serialized = serialize($job); + + $this->assertStringContainsString($serializedNotifiable, $serialized); + } }
true
Other
laravel
framework
f5119062ab054aba21c2fbd55e9f7363b8c7b814.json
Fix empty data for components (#32032)
src/Illuminate/View/Compilers/Concerns/CompilesComponents.php
@@ -23,7 +23,7 @@ protected function compileComponent($expression) { [$component, $data] = strpos($expression, ',') !== false ? array_map('trim', explode(',', trim($expression, '()'), 2)) - : [trim($expression, '()'), null]; + : [trim($expression, '()'), '']; $component = trim($component, '\'"');
false
Other
laravel
framework
68cde6fbab28a369f7f090af1aeb1837f053f088.json
Fix route naming issue (#32028)
src/Illuminate/Routing/AbstractRouteCollection.php
@@ -210,7 +210,7 @@ protected function addToSymfonyRoutesCollection(SymfonyRouteCollection $symfonyR throw new LogicException("Unable to prepare route [{$route->uri}] for serialization. Another route has already been assigned name [{$name}]."); } - $symfonyRoutes->add($name, $route->toSymfonyRoute()); + $symfonyRoutes->add($route->getName(), $route->toSymfonyRoute()); return $symfonyRoutes; }
true
Other
laravel
framework
68cde6fbab28a369f7f090af1aeb1837f053f088.json
Fix route naming issue (#32028)
tests/Integration/Routing/CompiledRouteCollectionTest.php
@@ -417,6 +417,16 @@ public function testGroupPrefixAndRoutePrefixAreProperlyHandled() $this->assertSame('pre/{locale}', $route->getPrefix()); } + public function testGroupGenerateNameForDuplicateRouteNamesThatEndWithDot() + { + $this->routeCollection->add($this->newRoute('GET', 'foo', ['uses' => 'FooController@index'])->name('foo.')); + $this->routeCollection->add($route = $this->newRoute('GET', 'bar', ['uses' => 'BarController@index'])->name('foo.')); + + $routes = $this->collection(); + + $this->assertSame('BarController@index', $routes->match(Request::create('/bar', 'GET'))->getAction()['uses']); + } + public function testRouteBindingsAreProperlySaved() { $this->routeCollection->add($this->newRoute('GET', 'posts/{post:slug}/show', [
true
Other
laravel
framework
4e0f4734bea5898df31f558eaf43222d09020d23.json
add throws doc block (#32014)
src/Illuminate/Container/Container.php
@@ -611,6 +611,8 @@ public function factory($abstract) * @param string $abstract * @param array $parameters * @return mixed + * + * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function makeWith($abstract, array $parameters = []) {
false
Other
laravel
framework
725d63d4ef3254d298fc0f2dda357d735976c7da.json
improve doc block for app()->call() (#32016)
src/Illuminate/Container/Container.php
@@ -581,9 +581,11 @@ public function wrap(Closure $callback, array $parameters = []) * Call the given Closure / class@method and inject its dependencies. * * @param callable|string $callback - * @param array $parameters + * @param array<string, mixed> $parameters * @param string|null $defaultMethod * @return mixed + * + * @throws \InvalidArgumentException */ public function call($callback, array $parameters = [], $defaultMethod = null) {
false
Other
laravel
framework
48d1c194375edd024edacd918d17ef0cce587842.json
Add space after component closing tag (#32005)
src/Illuminate/View/Compilers/ComponentTagCompiler.php
@@ -149,7 +149,7 @@ protected function compileSelfClosingTags(string $value) $attributes = $this->getAttributesFromAttributeString($matches['attributes']); - return $this->componentString($matches[1], $attributes)."\n@endcomponentClass"; + return $this->componentString($matches[1], $attributes)."\n@endcomponentClass "; }, $value); } @@ -270,7 +270,7 @@ protected function partitionDataAndAttributes($class, array $attributes) */ protected function compileClosingTags(string $value) { - return preg_replace("/<\/\s*x[-\:][\w\-\:\.]*\s*>/", ' @endcomponentClass', $value); + return preg_replace("/<\/\s*x[-\:][\w\-\:\.]*\s*>/", ' @endcomponentClass ', $value); } /**
true
Other
laravel
framework
48d1c194375edd024edacd918d17ef0cce587842.json
Add space after component closing tag (#32005)
tests/View/Blade/BladeComponentTagCompilerTest.php
@@ -31,9 +31,9 @@ public function testBasicComponentParsing() $this->assertSame("<div> @component('Illuminate\Tests\View\Blade\TestAlertComponent', []) <?php \$component->withAttributes(['type' => 'foo','limit' => '5','@click' => 'foo','required' => true]); ?> -@endcomponentClass @component('Illuminate\Tests\View\Blade\TestAlertComponent', []) +@endcomponentClass @component('Illuminate\Tests\View\Blade\TestAlertComponent', []) <?php \$component->withAttributes([]); ?> -@endcomponentClass</div>", trim($result)); +@endcomponentClass </div>", trim($result)); } public function testBasicComponentWithEmptyAttributesParsing() @@ -42,7 +42,7 @@ public function testBasicComponentWithEmptyAttributesParsing() $this->assertSame("<div> @component('Illuminate\Tests\View\Blade\TestAlertComponent', []) <?php \$component->withAttributes(['type' => '','limit' => '','@click' => '','required' => true]); ?> -@endcomponentClass</div>", trim($result)); +@endcomponentClass </div>", trim($result)); } public function testDataCamelCasing() @@ -91,7 +91,7 @@ public function testSelfClosingComponentsCanBeCompiled() $this->assertSame("<div> @component('Illuminate\Tests\View\Blade\TestAlertComponent', []) <?php \$component->withAttributes([]); ?> -@endcomponentClass</div>", trim($result)); +@endcomponentClass </div>", trim($result)); } public function testClassNamesCanBeGuessed() @@ -140,6 +140,23 @@ public function testSelfClosingComponentsCanBeCompiledWithDataAndAttributes() @endcomponentClass", trim($result)); } + public function testComponentsCanHaveAttachedWord() + { + $result = (new ComponentTagCompiler(['profile' => TestProfileComponent::class]))->compileTags('<x-profile></x-profile>Words'); + + $this->assertSame("@component('Illuminate\Tests\View\Blade\TestProfileComponent', []) +<?php \$component->withAttributes([]); ?> @endcomponentClass Words", trim($result)); + } + + public function testSelfClosingComponentsCanHaveAttachedWord() + { + $result = (new ComponentTagCompiler(['alert' => TestAlertComponent::class]))->compileTags('<x-alert/>Words'); + + $this->assertSame("@component('Illuminate\Tests\View\Blade\TestAlertComponent', []) +<?php \$component->withAttributes([]); ?> +@endcomponentClass Words", trim($result)); + } + public function testSelfClosingComponentsCanBeCompiledWithBoundData() { $result = (new ComponentTagCompiler(['alert' => TestAlertComponent::class]))->compileTags('<x-alert :title="$title" class="bar" />');
true
Other
laravel
framework
ec7d5b8ce77009757c04cbdc0f0c8bc81b277dbc.json
Ensure queues are only suffixed once (#31925)
src/Illuminate/Queue/SqsQueue.php
@@ -5,6 +5,7 @@ use Aws\Sqs\SqsClient; use Illuminate\Contracts\Queue\Queue as QueueContract; use Illuminate\Queue\Jobs\SqsJob; +use Illuminate\Support\Str; class SqsQueue extends Queue implements QueueContract { @@ -149,7 +150,7 @@ public function getQueue($queue) $queue = $queue ?: $this->default; return filter_var($queue, FILTER_VALIDATE_URL) === false - ? rtrim($this->prefix, '/').'/'.$queue.$this->suffix + ? rtrim($this->prefix, '/').'/'.Str::finish($queue, $this->suffix) : $queue; }
true
Other
laravel
framework
ec7d5b8ce77009757c04cbdc0f0c8bc81b277dbc.json
Ensure queues are only suffixed once (#31925)
tests/Queue/QueueSqsQueueTest.php
@@ -153,4 +153,12 @@ public function testGetQueueProperlyResolvesUrlWithSuffix() $queueUrl = $this->baseUrl.'/'.$this->account.'/test'.$suffix; $this->assertEquals($queueUrl, $queue->getQueue('test')); } + + public function testGetQueueEnsuresTheQueueIsOnlySuffixedOnce() + { + $queue = new SqsQueue($this->sqs, "{$this->queueName}-staging", $this->prefix, $suffix = '-staging'); + $this->assertEquals($this->queueUrl.$suffix, $queue->getQueue(null)); + $queueUrl = $this->baseUrl.'/'.$this->account.'/test'.$suffix; + $this->assertEquals($queueUrl, $queue->getQueue('test-staging')); + } }
true
Other
laravel
framework
e2b0963018c00b2a55754a0bd0f23c3436c88ed6.json
fix windows tests (#32002)
tests/Foundation/FoundationApplicationTest.php
@@ -359,11 +359,12 @@ public function testCachePathsResolveToBootstrapCacheDirectory() { $app = new Application('/base/path'); - $this->assertSame('/base/path/bootstrap/cache/services.php', $app->getCachedServicesPath()); - $this->assertSame('/base/path/bootstrap/cache/packages.php', $app->getCachedPackagesPath()); - $this->assertSame('/base/path/bootstrap/cache/config.php', $app->getCachedConfigPath()); - $this->assertSame('/base/path/bootstrap/cache/routes-v7.php', $app->getCachedRoutesPath()); - $this->assertSame('/base/path/bootstrap/cache/events.php', $app->getCachedEventsPath()); + $ds = DIRECTORY_SEPARATOR; + $this->assertSame('/base/path'.$ds.'bootstrap'.$ds.'cache/services.php', $app->getCachedServicesPath()); + $this->assertSame('/base/path'.$ds.'bootstrap'.$ds.'cache/packages.php', $app->getCachedPackagesPath()); + $this->assertSame('/base/path'.$ds.'bootstrap'.$ds.'cache/config.php', $app->getCachedConfigPath()); + $this->assertSame('/base/path'.$ds.'bootstrap'.$ds.'cache/routes-v7.php', $app->getCachedRoutesPath()); + $this->assertSame('/base/path'.$ds.'bootstrap'.$ds.'cache/events.php', $app->getCachedEventsPath()); } public function testEnvPathsAreUsedForCachePathsWhenSpecified() @@ -399,11 +400,12 @@ public function testEnvPathsAreUsedAndMadeAbsoluteForCachePathsWhenSpecifiedAsRe $_SERVER['APP_ROUTES_CACHE'] = 'relative/path/routes.php'; $_SERVER['APP_EVENTS_CACHE'] = 'relative/path/events.php'; - $this->assertSame('/base/path/relative/path/services.php', $app->getCachedServicesPath()); - $this->assertSame('/base/path/relative/path/packages.php', $app->getCachedPackagesPath()); - $this->assertSame('/base/path/relative/path/config.php', $app->getCachedConfigPath()); - $this->assertSame('/base/path/relative/path/routes.php', $app->getCachedRoutesPath()); - $this->assertSame('/base/path/relative/path/events.php', $app->getCachedEventsPath()); + $ds = DIRECTORY_SEPARATOR; + $this->assertSame('/base/path'.$ds.'relative/path/services.php', $app->getCachedServicesPath()); + $this->assertSame('/base/path'.$ds.'relative/path/packages.php', $app->getCachedPackagesPath()); + $this->assertSame('/base/path'.$ds.'relative/path/config.php', $app->getCachedConfigPath()); + $this->assertSame('/base/path'.$ds.'relative/path/routes.php', $app->getCachedRoutesPath()); + $this->assertSame('/base/path'.$ds.'relative/path/events.php', $app->getCachedEventsPath()); unset( $_SERVER['APP_SERVICES_CACHE'], @@ -423,11 +425,12 @@ public function testEnvPathsAreUsedAndMadeAbsoluteForCachePathsWhenSpecifiedAsRe $_SERVER['APP_ROUTES_CACHE'] = 'relative/path/routes.php'; $_SERVER['APP_EVENTS_CACHE'] = 'relative/path/events.php'; - $this->assertSame('/relative/path/services.php', $app->getCachedServicesPath()); - $this->assertSame('/relative/path/packages.php', $app->getCachedPackagesPath()); - $this->assertSame('/relative/path/config.php', $app->getCachedConfigPath()); - $this->assertSame('/relative/path/routes.php', $app->getCachedRoutesPath()); - $this->assertSame('/relative/path/events.php', $app->getCachedEventsPath()); + $ds = DIRECTORY_SEPARATOR; + $this->assertSame($ds.'relative/path/services.php', $app->getCachedServicesPath()); + $this->assertSame($ds.'relative/path/packages.php', $app->getCachedPackagesPath()); + $this->assertSame($ds.'relative/path/config.php', $app->getCachedConfigPath()); + $this->assertSame($ds.'relative/path/routes.php', $app->getCachedRoutesPath()); + $this->assertSame($ds.'relative/path/events.php', $app->getCachedEventsPath()); unset( $_SERVER['APP_SERVICES_CACHE'],
false
Other
laravel
framework
449c8056cc0f13e7e20428700045339bae6bdca2.json
handle prefix update on route level prefix
src/Illuminate/Routing/Route.php
@@ -146,13 +146,13 @@ public function __construct($methods, $uri, $action) { $this->uri = $uri; $this->methods = (array) $methods; - $this->action = $this->parseAction($action); + $this->action = Arr::except($this->parseAction($action), ['prefix']); if (in_array('GET', $this->methods) && ! in_array('HEAD', $this->methods)) { $this->methods[] = 'HEAD'; } - $this->prefix($this->action['prefix'] ?? ''); + $this->prefix(is_array($action) ? Arr::get($action, 'prefix') : ''); } /** @@ -709,11 +709,26 @@ public function getPrefix() */ public function prefix($prefix) { + $this->updatePrefixOnAction($prefix); + $uri = rtrim($prefix, '/').'/'.ltrim($this->uri, '/'); return $this->setUri($uri !== '/' ? trim($uri, '/') : $uri); } + /** + * Update the "prefix" attribute on the action array. + * + * @param string $prefix + * @return void + */ + protected function updatePrefixOnAction($prefix) + { + if (! empty($newPrefix = trim(rtrim($prefix, '/').'/'.ltrim($this->action['prefix'] ?? '', '/'), '/'))) { + $this->action['prefix'] = $newPrefix; + } + } + /** * Get the URI associated with the route. *
true
Other
laravel
framework
449c8056cc0f13e7e20428700045339bae6bdca2.json
handle prefix update on route level prefix
tests/Integration/Routing/CompiledRouteCollectionTest.php
@@ -408,6 +408,15 @@ public function testSlashPrefixIsProperlyHandled() $this->assertSame('foo/bar', $route->uri()); } + public function testGroupPrefixAndRoutePrefixAreProperlyHandled() + { + $this->routeCollection->add($this->newRoute('GET', 'foo/bar', ['uses' => 'FooController@index', 'prefix' => '{locale}'])->prefix('pre')); + + $route = $this->collection()->getByAction('FooController@index'); + + $this->assertSame('pre/{locale}', $route->getPrefix()); + } + public function testRouteBindingsAreProperlySaved() { $this->routeCollection->add($this->newRoute('GET', 'posts/{post:slug}/show', [
true
Other
laravel
framework
3a4ba41752327656702de1a30fc4cd48073f05ab.json
remove dead code from event tests (#31966)
tests/Events/EventsDispatcherTest.php
@@ -455,19 +455,6 @@ public function handle() } } -class TestDispatcherQueuedHandlerCustomQueue implements ShouldQueue -{ - public function handle() - { - // - } - - public function queue($queue, $handler, array $payload) - { - $queue->push($handler, $payload); - } -} - class ExampleEvent { //
false
Other
laravel
framework
83c8e6e6b575d0029ea164ba4b44f4c4895dbb3d.json
escape merged attributes by default
src/Illuminate/View/ComponentAttributeBag.php
@@ -108,6 +108,10 @@ public function merge(array $attributeDefaults = []) { $attributes = []; + $attributeDefaults = array_map(function ($value) { + return e($value); + }, $attributeDefaults); + foreach ($this->attributes as $key => $value) { if ($value === true) { $attributes[$key] = $key;
false
Other
laravel
framework
c00a8e7d1ed48b1a4c9303aad4aceea6cea87c14.json
Apply fixes from StyleCI (#31940)
tests/Routing/RoutingRouteTest.php
@@ -449,8 +449,7 @@ public function testNullValuesCanBeInjectedIntoRoutes() return $router; }); - $container->bind(RoutingTestUserModel::class, function() { - return null; + $container->bind(RoutingTestUserModel::class, function () { }); $router->get('foo/{team}/{post}', [
false
Other
laravel
framework
14b4a4331a547dc21608e3f3e18006bfb0317add.json
Add dispatchToQueue to BusFake (#31935)
src/Illuminate/Support/Testing/Fakes/BusFake.php
@@ -3,16 +3,16 @@ namespace Illuminate\Support\Testing\Fakes; use Closure; -use Illuminate\Contracts\Bus\Dispatcher; +use Illuminate\Contracts\Bus\QueueingDispatcher; use Illuminate\Support\Arr; use PHPUnit\Framework\Assert as PHPUnit; -class BusFake implements Dispatcher +class BusFake implements QueueingDispatcher { /** * The original Bus dispatcher implementation. * - * @var \Illuminate\Contracts\Bus\Dispatcher + * @var \Illuminate\Contracts\Bus\QueueingDispatcher */ protected $dispatcher; @@ -40,11 +40,11 @@ class BusFake implements Dispatcher /** * Create a new bus fake instance. * - * @param \Illuminate\Contracts\Bus\Dispatcher $dispatcher + * @param \Illuminate\Contracts\Bus\QueueingDispatcher $dispatcher * @param array|string $jobsToFake * @return void */ - public function __construct(Dispatcher $dispatcher, $jobsToFake = []) + public function __construct(QueueingDispatcher $dispatcher, $jobsToFake = []) { $this->dispatcher = $dispatcher; @@ -251,6 +251,21 @@ public function dispatchNow($command, $handler = null) } } + /** + * Dispatch a command to its appropriate handler behind a queue. + * + * @param mixed $command + * @return mixed + */ + public function dispatchToQueue($command) + { + if ($this->shouldFakeJob($command)) { + $this->commands[get_class($command)][] = $command; + } else { + return $this->dispatcher->dispatchToQueue($command); + } + } + /** * Dispatch a command to its appropriate handler. *
true
Other
laravel
framework
14b4a4331a547dc21608e3f3e18006bfb0317add.json
Add dispatchToQueue to BusFake (#31935)
tests/Support/SupportTestingBusFakeTest.php
@@ -2,7 +2,7 @@ namespace Illuminate\Tests\Support; -use Illuminate\Contracts\Bus\Dispatcher; +use Illuminate\Contracts\Bus\QueueingDispatcher; use Illuminate\Support\Testing\Fakes\BusFake; use Mockery as m; use PHPUnit\Framework\Constraint\ExceptionMessage; @@ -17,7 +17,7 @@ class SupportTestingBusFakeTest extends TestCase protected function setUp(): void { parent::setUp(); - $this->fake = new BusFake(m::mock(Dispatcher::class)); + $this->fake = new BusFake(m::mock(QueueingDispatcher::class)); } protected function tearDown(): void @@ -198,7 +198,7 @@ public function testAssertNotDispatchedAfterResponse() public function testAssertDispatchedWithIgnoreClass() { - $dispatcher = m::mock(Dispatcher::class); + $dispatcher = m::mock(QueueingDispatcher::class); $job = new BusJobStub; $dispatcher->shouldReceive('dispatch')->once()->with($job); @@ -222,7 +222,7 @@ public function testAssertDispatchedWithIgnoreClass() public function testAssertDispatchedWithIgnoreCallback() { - $dispatcher = m::mock(Dispatcher::class); + $dispatcher = m::mock(QueueingDispatcher::class); $job = new BusJobStub; $dispatcher->shouldReceive('dispatch')->once()->with($job);
true
Other
laravel
framework
47b8f327ea9ef6462103aa802cd48a6f739f76a1.json
remove duplicate comment (#31900)
src/Illuminate/Routing/RouteParameterBinder.php
@@ -32,9 +32,6 @@ public function __construct($route) */ public function parameters($request) { - // If the route has a regular expression for the host part of the URI, we will - // compile that and get the parameter matches for this domain. We will then - // merge them into this parameters array so that this array is completed. $parameters = $this->bindPathParameters($request); // If the route has a regular expression for the host part of the URI, we will
false
Other
laravel
framework
36c0af67504504a2df5398aeffce0da9ec58b1a8.json
Remove useless setUp() method. (#31874)
tests/Integration/Mail/SendingMailWithLocaleTest.php
@@ -46,11 +46,6 @@ protected function getEnvironmentSetUp($app) ]); } - protected function setUp(): void - { - parent::setUp(); - } - public function testMailIsSentWithDefaultLocale() { Mail::to('test@mail.com')->send(new TestMail);
false
Other
laravel
framework
5de9d278da53bf3547cc9b5883dbd641f39608dc.json
Use assertCount when possible. (#31877)
tests/Integration/Database/EloquentBelongsToTest.php
@@ -32,14 +32,14 @@ public function testHasSelf() { $users = User::has('parent')->get(); - $this->assertEquals(1, $users->count()); + $this->assertCount(1, $users); } public function testHasSelfCustomOwnerKey() { $users = User::has('parentBySlug')->get(); - $this->assertEquals(1, $users->count()); + $this->assertCount(1, $users); } public function testAssociateWithModel()
true
Other
laravel
framework
5de9d278da53bf3547cc9b5883dbd641f39608dc.json
Use assertCount when possible. (#31877)
tests/Integration/Database/EloquentHasManyThroughTest.php
@@ -82,7 +82,7 @@ public function testHasSelf() $users = User::has('teamMates')->get(); - $this->assertEquals(1, $users->count()); + $this->assertCount(1, $users); } public function testHasSelfCustomOwnerKey() @@ -95,7 +95,7 @@ public function testHasSelfCustomOwnerKey() $users = User::has('teamMatesBySlug')->get(); - $this->assertEquals(1, $users->count()); + $this->assertCount(1, $users); } public function testHasSameParentAndThroughParentTable()
true
Other
laravel
framework
662d69c27311b2ed5e754e6c8a8a053f975fe0c7.json
Add tests. (#31871)
src/Illuminate/Support/Stringable.php
@@ -416,9 +416,9 @@ public function replaceMatches($pattern, $replace, $limit = -1) { if ($replace instanceof Closure) { return new static(preg_replace_callback($pattern, $replace, $this->value, $limit)); - } else { - return new static(preg_replace($pattern, $replace, $this->value, $limit)); } + + return new static(preg_replace($pattern, $replace, $this->value, $limit)); } /**
true
Other
laravel
framework
662d69c27311b2ed5e754e6c8a8a053f975fe0c7.json
Add tests. (#31871)
tests/Support/SupportStringableTest.php
@@ -11,11 +11,25 @@ class SupportStringableTest extends TestCase * @param string $string * @return \Illuminate\Support\Stringable */ - protected function stringable($string) + protected function stringable($string = '') { return new Stringable($string); } + public function testIsAscii() + { + $this->assertTrue($this->stringable('A')->isAscii()); + $this->assertFalse($this->stringable('ù')->isAscii()); + } + + public function testPluralStudly() + { + $this->assertSame('LaraCon', (string) $this->stringable('LaraCon')->pluralStudly(1)); + $this->assertSame('LaraCons', (string) $this->stringable('LaraCon')->pluralStudly(2)); + $this->assertSame('LaraCon', (string) $this->stringable('LaraCon')->pluralStudly(-1)); + $this->assertSame('LaraCons', (string) $this->stringable('LaraCon')->pluralStudly(-2)); + } + public function testMatch() { $stringable = $this->stringable('foo bar'); @@ -37,39 +51,50 @@ public function testTrim() $this->assertSame('foo', (string) $this->stringable(' foo ')->trim()); } - public function testingCanBeLimitedByWords() + public function testCanBeLimitedByWords() { $this->assertSame('Taylor...', (string) $this->stringable('Taylor Otwell')->words(1)); $this->assertSame('Taylor___', (string) $this->stringable('Taylor Otwell')->words(1, '___')); $this->assertSame('Taylor Otwell', (string) $this->stringable('Taylor Otwell')->words(3)); } - public function testingTrimmedOnlyWhereNecessary() + public function testWhenEmpty() + { + $this->assertSame('empty', (string) $this->stringable()->whenEmpty(function () { + return 'empty'; + })); + + $this->assertSame('not-empty', (string) $this->stringable('not-empty')->whenEmpty(function () { + return 'empty'; + })); + } + + public function testTrimmedOnlyWhereNecessary() { $this->assertSame(' Taylor Otwell ', (string) $this->stringable(' Taylor Otwell ')->words(3)); $this->assertSame(' Taylor...', (string) $this->stringable(' Taylor Otwell ')->words(1)); } - public function testingTitle() + public function testTitle() { $this->assertSame('Jefferson Costella', (string) $this->stringable('jefferson costella')->title()); $this->assertSame('Jefferson Costella', (string) $this->stringable('jefFErson coSTella')->title()); } - public function testingWithoutWordsDoesntProduceError() + public function testWithoutWordsDoesntProduceError() { $nbsp = chr(0xC2).chr(0xA0); $this->assertSame(' ', (string) $this->stringable(' ')->words()); $this->assertEquals($nbsp, (string) $this->stringable($nbsp)->words()); } - public function testingAscii() + public function testAscii() { $this->assertSame('@', (string) $this->stringable('@')->ascii()); $this->assertSame('u', (string) $this->stringable('ü')->ascii()); } - public function testingAsciiWithSpecificLocale() + public function testAsciiWithSpecificLocale() { $this->assertSame('h H sht Sht a A ia yo', (string) $this->stringable('х Х щ Щ ъ Ъ иа йо')->ascii('bg')); $this->assertSame('ae oe ue Ae Oe Ue', (string) $this->stringable('ä ö ü Ä Ö Ü')->ascii('de'));
true
Other
laravel
framework
0b3da44c4d176655852c72008795cbe5d94801bf.json
Remove useless import. (#31872)
src/Illuminate/Testing/PendingCommand.php
@@ -10,7 +10,6 @@ use PHPUnit\Framework\TestCase as PHPUnitTestCase; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\BufferedOutput; -use Symfony\Component\Console\Output\Output; class PendingCommand {
false
Other
laravel
framework
a3eedeed2dc86c95ab7ce6e7b888a8007fd2b2cc.json
Use Arr::pull (#31870)
src/Illuminate/Support/ConfigurationUrlParser.php
@@ -31,9 +31,7 @@ public function parseConfiguration($config) $config = ['url' => $config]; } - $url = $config['url'] ?? null; - - $config = Arr::except($config, 'url'); + $url = Arr::pull($config, 'url'); if (! $url) { return $config;
false
Other
laravel
framework
3d58cd91d6ec483a43a4c23af9b75ecdd4a358de.json
fix trailing slash and add test
src/Illuminate/Routing/CompiledRouteCollection.php
@@ -109,14 +109,20 @@ public function refreshActionLookups() */ public function match(Request $request) { + $trimmedRequest = clone $request; + + $trimmedRequest->server->set( + 'REQUEST_URI', rtrim($request->server->get('REQUEST_URI'), '/') + ); + $matcher = new CompiledUrlMatcher( - $this->compiled, (new RequestContext)->fromRequest($request) + $this->compiled, (new RequestContext)->fromRequest($trimmedRequest) ); $route = null; try { - if ($result = $matcher->matchRequest($request)) { + if ($result = $matcher->matchRequest($trimmedRequest)) { $route = $this->getByName($result['_route']); } } catch (ResourceNotFoundException | MethodNotAllowedException $e) {
true
Other
laravel
framework
3d58cd91d6ec483a43a4c23af9b75ecdd4a358de.json
fix trailing slash and add test
tests/Integration/Routing/CompiledRouteCollectionTest.php
@@ -422,6 +422,15 @@ public function testRouteBindingsAreProperlySaved() $this->assertSame(['user' => 'username', 'post' => 'slug'], $route->bindingFields()); } + public function testMatchingSlashedRoutes() + { + $this->routeCollection->add( + $route = $this->newRoute('GET', 'foo/bar', ['uses' => 'FooController@index', 'as' => 'foo']) + ); + + $this->assertSame('foo', $this->collection()->match(Request::create('/foo/bar/'))->getName()); + } + /** * Create a new Route object. *
true
Other
laravel
framework
60027c4a1a0fd42fe00f38993167fc6e26fde694.json
Fix null value injected from container in routes.
src/Illuminate/Routing/RouteDependencyResolverTrait.php
@@ -41,12 +41,12 @@ public function resolveMethodDependencies(array $parameters, ReflectionFunctionA $values = array_values($parameters); + $shouldSkipValue = new \StdClass; + foreach ($reflector->getParameters() as $key => $parameter) { - $instance = $this->transformDependency( - $parameter, $parameters - ); + $instance = $this->transformDependency($parameter, $parameters, $shouldSkipValue); - if (! is_null($instance)) { + if ($instance !== $shouldSkipValue) { $instanceCount++; $this->spliceIntoParameters($parameters, $key, $instance); @@ -64,20 +64,23 @@ public function resolveMethodDependencies(array $parameters, ReflectionFunctionA * * @param \ReflectionParameter $parameter * @param array $parameters + * @param object $shouldSkipValue * @return mixed */ - protected function transformDependency(ReflectionParameter $parameter, $parameters) + protected function transformDependency(ReflectionParameter $parameter, $parameters, $shouldSkipValue) { $class = $parameter->getClass(); // If the parameter has a type-hinted class, we will check to see if it is already in // the list of parameters. If it is we will just skip it as it is probably a model // binding and we do not want to mess with those; otherwise, we resolve it here. if ($class && ! $this->alreadyInParameters($class->name, $parameters)) { - return $parameter->isDefaultValueAvailable() - ? $parameter->getDefaultValue() - : $this->container->make($class->name); + // If it has a default value and is not already resolved, it's + // probably an optional model binding not present in the url. + return $parameter->isDefaultValueAvailable() ? null : $this->container->make($class->name); } + + return $shouldSkipValue; } /**
true
Other
laravel
framework
60027c4a1a0fd42fe00f38993167fc6e26fde694.json
Fix null value injected from container in routes.
tests/Routing/RoutingRouteTest.php
@@ -441,6 +441,30 @@ public function testClassesCanBeInjectedIntoRoutes() unset($_SERVER['__test.route_inject']); } + public function testNullValuesCanBeInjectedIntoRoutes() + { + $container = new Container; + $router = new Router(new Dispatcher, $container); + $container->singleton(Registrar::class, function () use ($router) { + return $router; + }); + + $container->bind(RoutingTestUserModel::class, function() { + return null; + }); + + $router->get('foo/{team}/{post}', [ + 'middleware' => SubstituteBindings::class, + 'uses' => function (?RoutingTestUserModel $userFromContainer, RoutingTestTeamModel $team, $postId) { + $this->assertSame(null, $userFromContainer); + $this->assertInstanceOf(RoutingTestTeamModel::class, $team); + $this->assertSame('bar', $team->value); + $this->assertSame('baz', $postId); + }, + ]); + $router->dispatch(Request::create('foo/bar/baz', 'GET'))->getContent(); + } + public function testOptionsResponsesAreGeneratedByDefault() { $router = $this->getRouter();
true
Other
laravel
framework
2e9d90bad11dbaf33e4a7cedcdcbb60419f85a25.json
fix srid mysql schema (#31852)
src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php
@@ -16,7 +16,7 @@ class MySqlGrammar extends Grammar */ protected $modifiers = [ 'Unsigned', 'Charset', 'Collate', 'VirtualAs', 'StoredAs', 'Nullable', - 'Default', 'Increment', 'Comment', 'After', 'First', 'Srid', + 'Srid', 'Default', 'Increment', 'Comment', 'After', 'First', ]; /**
true