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
a1a50bd612c71338fb9be6da8445e2ba6838a5b6.json
use message object
tests/Notifications/NotificationDatabaseChannelTest.php
@@ -1,5 +1,6 @@ <?php +use Illuminate\Notifications\Message; use Illuminate\Notifications\Notification; use Illuminate\Notifications\Channels\DatabaseChannel; @@ -12,7 +13,7 @@ public function tearDown() public function testDatabaseChannelCreatesDatabaseRecordWithProperData() { - $notification = new Notification; + $notification = new NotificationDatabaseChannelTestNotification; $notifiables = collect([$notifiable = Mockery::mock()]); $notifiable->shouldReceive('routeNotificationFor->create')->with([ @@ -29,3 +30,11 @@ public function testDatabaseChannelCreatesDatabaseRecordWithProperData() $channel->send($notifiables, $notification); } } + +class NotificationDatabaseChannelTestNotification extends Notification +{ + public function message($notifiable) + { + return new Message; + } +}
true
Other
laravel
framework
a1a50bd612c71338fb9be6da8445e2ba6838a5b6.json
use message object
tests/Notifications/NotificationMailChannelTest.php
@@ -1,5 +1,6 @@ <?php +use Illuminate\Notifications\Message; use Illuminate\Notifications\Notification; class NotificationMailChannelTest extends PHPUnit_Framework_TestCase @@ -11,12 +12,12 @@ public function tearDown() public function testMailIsSentByChannel() { - $notification = new Notification; + $notification = new NotificationMailChannelTestNotification; $notifiables = collect([ $notifiable = new NotificationMailChannelTestNotifiable, ]); - $array = $notification->toArray(); + $array = $notification->toArray($notifiable); $array['actionColor'] = 'blue'; $channel = new Illuminate\Notifications\Channels\MailChannel( @@ -35,3 +36,11 @@ class NotificationMailChannelTestNotifiable public $email = 'taylor@laravel.com'; } + +class NotificationMailChannelTestNotification extends Notification +{ + public function message($notifiable) + { + return new Message; + } +}
true
Other
laravel
framework
a1a50bd612c71338fb9be6da8445e2ba6838a5b6.json
use message object
tests/Notifications/NotificationMessageTest.php
@@ -0,0 +1,36 @@ +<?php + +use Illuminate\Notifications\Message; +use Illuminate\Notifications\Notification; + +class NotificationMessageTest extends PHPUnit_Framework_TestCase +{ + public function testLevelCanBeRetrieved() + { + $message = new Message; + $this->assertEquals('info', $message->level); + + $message = new Message; + $message->level('error'); + $this->assertEquals('error', $message->level); + } + + public function testMessageFormatsMultiLineText() + { + $message = new Message; + $message->with(' + This is a + single line of text. + '); + + $this->assertEquals('This is a single line of text.', $message->introLines[0]); + + $message = new Message; + $message->with([ + 'This is a', + 'single line of text.', + ]); + + $this->assertEquals('This is a single line of text.', $message->introLines[0]); + } +}
true
Other
laravel
framework
a1a50bd612c71338fb9be6da8445e2ba6838a5b6.json
use message object
tests/Notifications/NotificationNexmoChannelTest.php
@@ -11,7 +11,7 @@ public function tearDown() public function testSmsIsSentViaNexmo() { - $notification = new Notification; + $notification = new NotificationNexmoChannelTestNotification; $notifiables = collect([ $notifiable = new NotificationNexmoChannelTestNotifiable, ]); @@ -44,3 +44,13 @@ class NotificationNexmoChannelTestNotifiable use Illuminate\Notifications\Notifiable; public $phone_number = '5555555555'; } + +class NotificationNexmoChannelTestNotification extends Notification +{ + public function message($notifiable) + { + return $this->line('line 1') + ->action('Text', 'url') + ->line('line 2'); + } +}
true
Other
laravel
framework
a1a50bd612c71338fb9be6da8445e2ba6838a5b6.json
use message object
tests/Notifications/NotificationNotificationTest.php
@@ -1,46 +0,0 @@ -<?php - -use Illuminate\Notifications\Notification; - -class NotificationNotificationTest extends PHPUnit_Framework_TestCase -{ - public function testLevelCanBeRetrieved() - { - $notification = new Notification; - $this->assertEquals('info', $notification->level); - - $notification = new NotificationTestNotification; - $notification->level('error'); - $this->assertEquals('error', $notification->level); - } - - public function testChannelNotificationFormatsMultiLineText() - { - $notification = new Notification([]); - $notification->with(' - This is a - single line of text. - '); - - $this->assertEquals('This is a single line of text.', $notification->introLines[0]); - - $notification = new Notification([]); - $notification->with([ - 'This is a', - 'single line of text.', - ]); - - $this->assertEquals('This is a single line of text.', $notification->introLines[0]); - } -} - - -class NotificationTestNotification extends Notification -{ - public $level = 'error'; -} - -class NotificationTestNotificationWithSubject extends Notification -{ - public $subject = 'Zonda'; -}
true
Other
laravel
framework
a1a50bd612c71338fb9be6da8445e2ba6838a5b6.json
use message object
tests/Notifications/NotificationSlackChannelTest.php
@@ -11,18 +11,11 @@ public function tearDown() public function testCorrectPayloadIsSentToSlack() { - $notification = new Notification; + $notification = new NotificationSlackChannelTestNotification; $notifiables = collect([ $notifiable = new NotificationSlackChannelTestNotifiable, ]); - $notification->subject = 'Subject'; - $notification->level = 'success'; - $notification->introLines = ['line 1']; - $notification->actionText = 'Text'; - $notification->actionUrl = 'url'; - $notification->outroLines = ['line 2']; - $channel = new Illuminate\Notifications\Channels\SlackWebhookChannel( $http = Mockery::mock('GuzzleHttp\Client') ); @@ -59,3 +52,15 @@ public function routeNotificationForSlack() return 'url'; } } + +class NotificationSlackChannelTestNotification extends Notification +{ + public function message($notifiable) + { + return $this->subject('Subject') + ->success() + ->line('line 1') + ->action('Text', 'url') + ->line('line 2'); + } +}
true
Other
laravel
framework
bd9cd7703fe5d745af764ba1c5ac25bd70ed99e2.json
get router in function
src/Illuminate/Broadcasting/BroadcastManager.php
@@ -59,7 +59,7 @@ public function routes() $router = $this->app['router']; - $router->group(['middleware' => ['web']], function () { + $router->group(['middleware' => ['web']], function ($router) { $router->post('/broadcasting/auth', BroadcastController::class.'@authenticate'); $router->post('/broadcasting/socket', BroadcastController::class.'@rememberSocket'); });
false
Other
laravel
framework
e6a430b486490e908115052771c020b921254b63.json
Add missing docblock
src/Illuminate/Mail/Mailable.php
@@ -345,6 +345,7 @@ public function replyTo($address, $name = null) * * @param object|array|string $address * @param string|null $name + * @param string $property * @return $this */ protected function setAddress($address, $name = null, $property = 'to')
false
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
CONTRIBUTING.md
@@ -1,3 +1,3 @@ # Laravel Contribution Guide -Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](http://laravel.com/docs/contributions). Please review the entire guide before sending a pull request. +Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). Please review the entire guide before sending a pull request.
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
composer.json
@@ -3,7 +3,7 @@ "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
readme.md
@@ -17,11 +17,11 @@ Laravel is accessible, yet powerful, providing powerful tools needed for large, ## Official Documentation -Documentation for the framework can be found on the [Laravel website](http://laravel.com/docs). +Documentation for the framework can be found on the [Laravel website](https://laravel.com/docs). ## Contributing -Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](http://laravel.com/docs/contributions). +Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). ## Security Vulnerabilities
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Auth/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/auth", "description": "The Illuminate Auth package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Broadcasting/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/broadcasting", "description": "The Illuminate Broadcasting package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Bus/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/bus", "description": "The Illuminate Bus package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Cache/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/cache", "description": "The Illuminate Cache package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Config/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/config", "description": "The Illuminate Config package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Console/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/console", "description": "The Illuminate Console package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Container/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/container", "description": "The Illuminate Container package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Contracts/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/contracts", "description": "The Illuminate Contracts package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Cookie/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/cookie", "description": "The Illuminate Cookie package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Database/README.md
@@ -67,4 +67,4 @@ class User extends Illuminate\Database\Eloquent\Model {} $users = User::where('votes', '>', 1)->get(); ``` -For further documentation on using the various database facilities this library provides, consult the [Laravel framework documentation](http://laravel.com/docs). +For further documentation on using the various database facilities this library provides, consult the [Laravel framework documentation](https://laravel.com/docs).
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Database/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/database", "description": "The Illuminate Database package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Encryption/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/encryption", "description": "The Illuminate Encryption package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Events/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/events", "description": "The Illuminate Events package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Filesystem/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/filesystem", "description": "The Illuminate Filesystem package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Hashing/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/hashing", "description": "The Illuminate Hashing package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Http/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/http", "description": "The Illuminate Http package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Log/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/log", "description": "The Illuminate Log package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Mail/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/mail", "description": "The Illuminate Mail package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Notifications/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/notifications", "description": "The Illuminate Notifications package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Pagination/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/pagination", "description": "The Illuminate Pagination package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Pipeline/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/pipeline", "description": "The Illuminate Pipeline package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Queue/README.md
@@ -31,4 +31,4 @@ $queue->push('SendEmail', array('message' => $message)); Queue::push('SendEmail', array('message' => $message)); ``` -For further documentation on using the queue, consult the [Laravel framework documentation](http://laravel.com/docs). +For further documentation on using the queue, consult the [Laravel framework documentation](https://laravel.com/docs).
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Queue/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/queue", "description": "The Illuminate Queue package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Redis/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/redis", "description": "The Illuminate Redis package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Routing/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/routing", "description": "The Illuminate Routing package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Session/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/session", "description": "The Illuminate Session package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Support/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/support", "description": "The Illuminate Support package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Translation/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/translation", "description": "The Illuminate Translation package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/Validation/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/validation", "description": "The Illuminate Validation package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
src/Illuminate/View/composer.json
@@ -2,7 +2,7 @@ "name": "illuminate/view", "description": "The Illuminate View package.", "license": "MIT", - "homepage": "http://laravel.com", + "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework"
true
Other
laravel
framework
f017f119925999145d4596582edacb1fa45e809d.json
Update laravel urls with https (#14629)
tests/Validation/ValidationValidatorTest.php
@@ -1663,16 +1663,16 @@ public function validUrls() ['https://google.com'], ['http://illuminate.dev'], ['http://localhost'], - ['http://laravel.com/?'], + ['https://laravel.com/?'], ['http://президент.рф/'], ['http://스타벅스코리아.com'], ['http://xn--d1abbgf6aiiy.xn--p1ai/'], - ['http://laravel.com?'], - ['http://laravel.com?q=1'], - ['http://laravel.com/?q=1'], - ['http://laravel.com#'], - ['http://laravel.com#fragment'], - ['http://laravel.com/#fragment'], + ['https://laravel.com?'], + ['https://laravel.com?q=1'], + ['https://laravel.com/?q=1'], + ['https://laravel.com#'], + ['https://laravel.com#fragment'], + ['https://laravel.com/#fragment'], ]; }
true
Other
laravel
framework
4dc53d79d700caeac51d043bb82e2a2cd83e4858.json
remove updateAny from stub
src/Illuminate/Foundation/Console/stubs/policy.stub
@@ -44,17 +44,6 @@ class DummyClass // } - /** - * Determine whether the user can update dummyPluralModelName. - * - * @param DummyRootNamespaceUser $user - * @return mixed - */ - public function updateAny(User $user) - { - // - } - /** * Determine whether the user can update the dummyModelName. *
false
Other
laravel
framework
9c48671932c6ee631b5c2a6ee6513582062c5b92.json
remove old property
src/Illuminate/Notifications/Notification.php
@@ -15,11 +15,6 @@ class Notification */ public $notifiables; - /** - * The channels that the notification should be sent through. - */ - public $via = []; - /** * The name of the application sending the notification. *
false
Other
laravel
framework
73c64077b223181d7c47ff6358e3df71af183ec8.json
Remove unused code. (#14610) Signed-off-by: crynobone <crynobone@gmail.com>
src/Illuminate/Notifications/ChannelManager.php
@@ -197,17 +197,4 @@ public function deliverVia($channels) { $this->defaultChannels = (array) $channels; } - - /** - * Build a new channel notification from the given object. - * - * @param mixed $notifiable - * @param mixed $notification - * @param array|null $channels - * @return array - */ - public function notificationsFromInstance($notifiable, $notification, $channels = null) - { - return Channels\Notification::notificationsFromInstance($notifiable, $notification, $channels); - } }
false
Other
laravel
framework
b44ad4df64620b042b83f51ff34f10222e923e13.json
add option for bc
src/Illuminate/Queue/Console/WorkCommand.php
@@ -191,6 +191,8 @@ protected function getOptions() return [ ['queue', null, InputOption::VALUE_OPTIONAL, 'The queue to listen on'], + ['daemon', null, InputOption::VALUE_NONE, 'Run the worker in daemon mode (Deprecated)'], + ['once', null, InputOption::VALUE_NONE, 'Only process the next job on the queue'], ['delay', null, InputOption::VALUE_OPTIONAL, 'Amount of time to delay failed jobs', 0],
false
Other
laravel
framework
8ac01ded45adaf88519d65285e009d8826e82964.json
adjust type hint
src/Illuminate/Foundation/helpers.php
@@ -589,7 +589,7 @@ function redirect($to = null, $status = 302, $headers = [], $secure = null) /** * Get an instance of the current request or an input item from the request. * - * @param string $key + * @param array|string $key * @param mixed $default * @return \Illuminate\Http\Request|string|array */
false
Other
laravel
framework
192332a89620e3f6db4a13627d0b2f6868b56513.json
Add missed import (#14595)
src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php
@@ -2,6 +2,7 @@ namespace Illuminate\Foundation\Support\Providers; +use Illuminate\Routing\Router; use Illuminate\Support\Facades\Route; use Illuminate\Support\ServiceProvider; use Illuminate\Contracts\Routing\UrlGenerator;
false
Other
laravel
framework
2e10175326bbdaeca2fdc9ad1b49dda62031bb65.json
Fix typo on docblock
src/Illuminate/Cache/Console/CacheTableCommand.php
@@ -35,7 +35,7 @@ class CacheTableCommand extends Command protected $composer; /** - * Create a new session table command instance. + * Create a new cache table command instance. * * @param \Illuminate\Filesystem\Filesystem $files * @param \Illuminate\Foundation\Composer $composer
false
Other
laravel
framework
3a3dea2e1623dfc62d7d900cd764a2b4ffb4c535.json
Add the opposite method of isDirty, the isClean
src/Illuminate/Database/Eloquent/Model.php
@@ -3139,6 +3139,17 @@ public function isDirty($attributes = null) return false; } + /** + * Determine if the model or given attribute(s) have been remained the same. + * + * @param array|string|null $attributes + * @return bool + */ + public function isClean($attributes = null) + { + return ! $this->isDirty(...func_get_args()); + } + /** * Get the attributes that have been changed since last sync. *
true
Other
laravel
framework
3a3dea2e1623dfc62d7d900cd764a2b4ffb4c535.json
Add the opposite method of isDirty, the isClean
tests/Database/DatabaseEloquentModelTest.php
@@ -46,6 +46,21 @@ public function testDirtyAttributes() $this->assertTrue($model->isDirty(['foo', 'bar'])); } + public function testCleanAttributes() + { + $model = new EloquentModelStub(['foo' => '1', 'bar' => 2, 'baz' => 3]); + $model->syncOriginal(); + $model->foo = 1; + $model->bar = 20; + $model->baz = 30; + + $this->assertFalse($model->isClean()); + $this->assertTrue($model->isClean('foo')); + $this->assertFalse($model->isClean('bar')); + $this->assertFalse($model->isClean('foo', 'bar')); + $this->assertFalse($model->isClean(['foo', 'bar'])); + } + public function testCalculatedAttributes() { $model = new EloquentModelStub;
true
Other
laravel
framework
5c170ad2b9560344cf7b7ab76e800c1c31dfc8b9.json
Add toggle() method to BelongsToMany relation
src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php
@@ -817,7 +817,7 @@ public function sync($ids, $detaching = true) // if they exist in the array of current ones, and if not we will insert. $current = $this->newPivotQuery()->pluck($this->otherKey)->all(); - $records = $this->formatSyncList($ids); + $records = $this->formatRecordsList($ids); $detach = array_diff($current, array_keys($records)); @@ -847,12 +847,12 @@ public function sync($ids, $detaching = true) } /** - * Format the sync list so that it is keyed by ID. + * Format the sync/toggle list so that it is keyed by ID. * * @param array $records * @return array */ - protected function formatSyncList(array $records) + protected function formatRecordsList(array $records) { $results = []; @@ -1124,6 +1124,63 @@ protected function touchingParent() return $this->getRelated()->touches($this->guessInverseRelation()); } + /** + * Toggles a model (or models) from the parent. + * + * Each existing model is detached, and non existing ones are attached. + * + * @param mixed $ids + * @return array + */ + public function toggle($ids) + { + $changes = [ + 'attached' => [], 'detached' => [], + ]; + + if ($ids instanceof Model) { + $ids = $ids->getKey(); + } + + if ($ids instanceof Collection) { + $ids = $ids->modelKeys(); + } + + // First, we need to know which are the currently associated models. + $current = $this->newPivotQuery()->pluck($this->otherKey)->all(); + + $records = $this->formatRecordsList((array) $ids); + + // Next, we will take the intersection of the currents and given records, + // and detach all of the entities that are in the common in "current" + // array and in the array of the new records. + $detach = array_values(array_intersect($current, array_keys($records))); + + if (count($detach) > 0) { + $this->detach($detach, false); + + $changes['detached'] = (array) array_map(function ($v) { + return is_numeric($v) ? (int) $v : (string) $v; + }, $detach); + } + + // Finally, we attach the remaining records (those have not been detached + // and not are in the "current" array) + $attach = array_diff_key($records, array_flip($detach)); + + if (count($attach) > 0) { + $this->attach($attach, [], false); + + $changes['attached'] = array_keys($attach); + } + + if (count($changes['attached']) || count($changes['detached'])) { + $this->touchIfTouching(); + } + + return $changes; + } + /** * Attempt to guess the name of the inverse of the relation. *
true
Other
laravel
framework
5c170ad2b9560344cf7b7ab76e800c1c31dfc8b9.json
Add toggle() method to BelongsToMany relation
tests/Database/DatabaseEloquentBelongsToManyTest.php
@@ -554,6 +554,50 @@ public function testTouchMethodSyncsTimestamps() $relation->touch(); } + /** + * @dataProvider toggleMethodListProvider + */ + public function testToggleMethodTogglesIntermediateTableWithGivenArray($list) + { + $relation = $this->getMockBuilder('Illuminate\Database\Eloquent\Relations\BelongsToMany')->setMethods(['attach', 'detach'])->setConstructorArgs($this->getRelationArguments())->getMock(); + $query = m::mock('stdClass'); + $query->shouldReceive('from')->once()->with('user_role')->andReturn($query); + $query->shouldReceive('where')->once()->with('user_id', 1)->andReturn($query); + $relation->getQuery()->shouldReceive('getQuery')->andReturn($mockQueryBuilder = m::mock('StdClass')); + $mockQueryBuilder->shouldReceive('newQuery')->once()->andReturn($query); + $query->shouldReceive('pluck')->once()->with('role_id')->andReturn(new BaseCollection([1, 2, 3])); + $relation->expects($this->once())->method('attach')->with($this->equalTo(['x' => []]), $this->equalTo([]), $this->equalTo(false)); + $relation->expects($this->once())->method('detach')->with($this->equalTo([2, 3])); + $relation->getRelated()->shouldReceive('touches')->andReturn(false); + $relation->getParent()->shouldReceive('touches')->andReturn(false); + + $this->assertEquals(['attached' => ['x'], 'detached' => [2, 3]], $relation->toggle($list)); + } + + public function toggleMethodListProvider() + { + return [ + [[2, 3, 'x']], + [['2', '3', 'x']], + ]; + } + + public function testToggleMethodTogglesIntermediateTableWithGivenArrayAndAttributes() + { + $relation = $this->getMockBuilder('Illuminate\Database\Eloquent\Relations\BelongsToMany')->setMethods(['attach', 'detach', 'touchIfTouching', 'updateExistingPivot'])->setConstructorArgs($this->getRelationArguments())->getMock(); + $query = m::mock('stdClass'); + $query->shouldReceive('from')->once()->with('user_role')->andReturn($query); + $query->shouldReceive('where')->once()->with('user_id', 1)->andReturn($query); + $relation->getQuery()->shouldReceive('getQuery')->andReturn($mockQueryBuilder = m::mock('StdClass')); + $mockQueryBuilder->shouldReceive('newQuery')->once()->andReturn($query); + $query->shouldReceive('pluck')->once()->with('role_id')->andReturn(new BaseCollection([1, 2, 3])); + $relation->expects($this->once())->method('attach')->with($this->equalTo([4 => ['foo' => 'bar']]), [], $this->equalTo(false)); + $relation->expects($this->once())->method('detach')->with($this->equalTo([2, 3])); + $relation->expects($this->once())->method('touchIfTouching'); + + $this->assertEquals(['attached' => [4], 'detached' => [2, 3]], $relation->toggle([2, 3, 4 => ['foo' => 'bar']])); + } + public function testTouchIfTouching() { $relation = $this->getMockBuilder('Illuminate\Database\Eloquent\Relations\BelongsToMany')->setMethods(['touch', 'touchingParent'])->setConstructorArgs($this->getRelationArguments())->getMock(); @@ -567,7 +611,7 @@ public function testTouchIfTouching() public function testSyncMethodConvertsCollectionToArrayOfKeys() { - $relation = $this->getMockBuilder('Illuminate\Database\Eloquent\Relations\BelongsToMany')->setMethods(['attach', 'detach', 'touchIfTouching', 'formatSyncList'])->setConstructorArgs($this->getRelationArguments())->getMock(); + $relation = $this->getMockBuilder('Illuminate\Database\Eloquent\Relations\BelongsToMany')->setMethods(['attach', 'detach', 'touchIfTouching', 'formatRecordsList'])->setConstructorArgs($this->getRelationArguments())->getMock(); $query = m::mock('stdClass'); $query->shouldReceive('from')->once()->with('user_role')->andReturn($query); $query->shouldReceive('where')->once()->with('user_id', 1)->andReturn($query); @@ -580,13 +624,13 @@ public function testSyncMethodConvertsCollectionToArrayOfKeys() m::mock(['getKey' => 2]), m::mock(['getKey' => 3]), ]); - $relation->expects($this->once())->method('formatSyncList')->with([1, 2, 3])->will($this->returnValue([1 => [], 2 => [], 3 => []])); + $relation->expects($this->once())->method('formatRecordsList')->with([1, 2, 3])->will($this->returnValue([1 => [], 2 => [], 3 => []])); $relation->sync($collection); } public function testWherePivotParamsUsedForNewQueries() { - $relation = $this->getMockBuilder('Illuminate\Database\Eloquent\Relations\BelongsToMany')->setMethods(['attach', 'detach', 'touchIfTouching', 'formatSyncList'])->setConstructorArgs($this->getRelationArguments())->getMock(); + $relation = $this->getMockBuilder('Illuminate\Database\Eloquent\Relations\BelongsToMany')->setMethods(['attach', 'detach', 'touchIfTouching', 'formatRecordsList'])->setConstructorArgs($this->getRelationArguments())->getMock(); // we expect to call $relation->wherePivot() $relation->getQuery()->shouldReceive('where')->once()->andReturn($relation); @@ -608,7 +652,7 @@ public function testWherePivotParamsUsedForNewQueries() // This is so $relation->sync() works $query->shouldReceive('pluck')->once()->with('role_id')->andReturn(new BaseCollection([1, 2, 3])); - $relation->expects($this->once())->method('formatSyncList')->with([1, 2, 3])->will($this->returnValue([1 => [], 2 => [], 3 => []])); + $relation->expects($this->once())->method('formatRecordsList')->with([1, 2, 3])->will($this->returnValue([1 => [], 2 => [], 3 => []])); $relation = $relation->wherePivot('foo', '=', 'bar'); // these params are to be stored $relation->sync([1, 2, 3]); // triggers the whole process above
true
Other
laravel
framework
b8c2b869f36dc730c4eaf563614d9d7f1a69ab9f.json
remove legacy non-breaking code
src/Illuminate/Support/Collection.php
@@ -1094,16 +1094,6 @@ public function zip($items) return new static(call_user_func_array('array_map', $params)); } - /** - * Return self to allow compatibility with Illuminate\Database\Eloquent\Collection. - * - * @return \Illuminate\Support\Collection - */ - public function toBase() - { - return $this; - } - /** * Get the collection of items as a plain array. *
true
Other
laravel
framework
b8c2b869f36dc730c4eaf563614d9d7f1a69ab9f.json
remove legacy non-breaking code
tests/Support/SupportCollectionTest.php
@@ -1457,12 +1457,6 @@ public function testSliceNegativeOffsetAndNegativeLength() $collection = new Collection([1, 2, 3, 4, 5, 6, 7, 8]); $this->assertEquals([3, 4, 5, 6], $collection->slice(-6, -2)->values()->toArray()); } - - public function testToBase() - { - $collection = new Collection([1, 2, 3]); - $this->assertSame($collection, $collection->toBase()); - } } class TestAccessorEloquentTestStub
true
Other
laravel
framework
456f1f3d197069baa7bad8de4b78df1db98def30.json
remove old test
tests/Encryption/EncrypterTest.php
@@ -91,25 +91,4 @@ public function testExceptionThrownWithDifferentKey() $b = new Encrypter(str_repeat('b', 16)); $b->decrypt($a->encrypt('baz')); } -<<<<<<< HEAD -======= - - public function testOpenSslEncrypterCanDecryptMcryptedData() - { - if (! extension_loaded('mcrypt')) { - $this->markTestSkipped('Mcrypt module not installed'); - } - - if (version_compare(PHP_VERSION, '7.1') > 0) { - $this->markTestSkipped('Not compatable with PHP 7.1+'); - } - - $key = Str::random(32); - $encrypter = new McryptEncrypter($key); - $encrypted = $encrypter->encrypt('foo'); - $openSslEncrypter = new Encrypter($key, 'AES-256-CBC'); - - $this->assertEquals('foo', $openSslEncrypter->decrypt($encrypted)); - } ->>>>>>> 5.2 }
false
Other
laravel
framework
0024fc2228ac4c223fccb3696b170e3c23f74084.json
Add missing return statement (#14580)
src/Illuminate/Mail/Mailable.php
@@ -289,7 +289,7 @@ protected function runCallbacks($message) */ public function from($address, $name = null) { - $this->setAddress($address, $name, 'from'); + return $this->setAddress($address, $name, 'from'); } /**
false
Other
laravel
framework
4591d90f6de700a7b67dedb0147d2c9dcf6acd51.json
Ignore case in blade foreach compiler (#14581)
src/Illuminate/View/Compilers/BladeCompiler.php
@@ -579,7 +579,7 @@ protected function compileFor($expression) */ protected function compileForeach($expression) { - preg_match('/\( *(.*) +as *([^\)]*)/', $expression, $matches); + preg_match('/\( *(.*) +as *([^\)]*)/i', $expression, $matches); $iteratee = trim($matches[1]);
true
Other
laravel
framework
4591d90f6de700a7b67dedb0147d2c9dcf6acd51.json
Ignore case in blade foreach compiler (#14581)
tests/View/ViewBladeCompilerTest.php
@@ -439,6 +439,18 @@ public function testForeachStatementsAreCompiled() $this->assertEquals($expected, $compiler->compileString($string)); } + public function testForeachStatementsAreCompileWithUppercaseSyntax() + { + $compiler = new BladeCompiler($this->getFiles(), __DIR__); + $string = '@foreach ($this->getUsers() AS $user) +test +@endforeach'; + $expected = '<?php $__currentLoopData = $this->getUsers(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getFirstLoop(); ?> +test +<?php endforeach; $__env->popLoop(); $loop = $__env->getFirstLoop(); ?>'; + $this->assertEquals($expected, $compiler->compileString($string)); + } + public function testNestedForeachStatementsAreCompiled() { $compiler = new BladeCompiler($this->getFiles(), __DIR__);
true
Other
laravel
framework
ed86dcda3078d0cd470199b7cf4853d8b2cde808.json
Fix some docblocks.
src/Illuminate/Mail/Mailable.php
@@ -100,7 +100,7 @@ class Mailable implements MailableContract /** * Send the message using the given mailer. * - * @param MailerContract $mailer + * @param \Illuminate\Contracts\Mail\Mailer $mailer * @return void */ public function send(MailerContract $mailer) @@ -119,7 +119,7 @@ public function send(MailerContract $mailer) /** * Queue the message for sending. * - * @param Queue $queue + * @param \Illuminate\Contracts\Queue\Factory $queue * @return mixed */ public function queue(Queue $queue) @@ -395,7 +395,7 @@ public function view($view, array $data = []) /** * Set the plain text view for the message. * - * @param string $view + * @param string $textView * @param array $data * @return $this */
false
Other
laravel
framework
d4a4c802a4d57800af2f980ecee1d1ebcc318235.json
Change exception message to actual model path
src/Illuminate/Database/Eloquent/Builder.php
@@ -681,7 +681,8 @@ public function getRelation($name) try { return $this->getModel()->$name(); } catch (BadMethodCallException $e) { - throw new RelationNotFoundException("Call to undefined relationship {$name} on Model {$this->getModel()}"); + $className = get_class($this->getModel()); + throw new RelationNotFoundException("Call to undefined relationship {$name} on Model {$className}"); } });
false
Other
laravel
framework
9b6b257e0818cd32f9ad64d017cac8650bba1686.json
Fix pokemon plural form (#14525) As with the words deer and sheep, the singular and plural forms of the word "Pokémon" do not differ, nor does each individual species name; in short, it is grammatically correct to say both "one Pokémon" and "many Pokémon"
src/Illuminate/Support/Pluralizer.php
@@ -32,6 +32,7 @@ class Pluralizer 'nutrition', 'offspring', 'plankton', + 'pokemon', 'police', 'rice', 'series',
false
Other
laravel
framework
a01a102f1522da0d617ff53cc399f2e476cc6569.json
Remove duplicate interface implementation (#14515) Because the interface `QueueingDispatcher` inherits from the interface `Illuminate\Contracts\Bus\Dispatcher`, there is no need to implement the interface `Illuminate\Contracts\Bus\Dispatcher` again.
src/Illuminate/Bus/Dispatcher.php
@@ -9,9 +9,8 @@ use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Container\Container; use Illuminate\Contracts\Bus\QueueingDispatcher; -use Illuminate\Contracts\Bus\Dispatcher as DispatcherContract; -class Dispatcher implements DispatcherContract, QueueingDispatcher +class Dispatcher implements QueueingDispatcher { /** * The container implementation.
false
Other
laravel
framework
afec9cda4cd292dc8a2294e72627fcb25f591d93.json
Fix #14506 (#14510) Shorten too broad PhpDoc @return tag from `@return \Illuminate\Database\Query\Builder|static` to `@return \Illuminate\Database\Query\Builder`.
src/Illuminate/Database/Eloquent/Builder.php
@@ -1299,7 +1299,7 @@ protected function nestWhereSlice($whereSlice) /** * Get the underlying query builder instance. * - * @return \Illuminate\Database\Query\Builder|static + * @return \Illuminate\Database\Query\Builder */ public function getQuery() {
false
Other
laravel
framework
2db8ff33e92ff0d2dad4d71f1e08e5029418eb17.json
fix build order
src/Illuminate/Notifications/Channels/Notification.php
@@ -296,16 +296,16 @@ protected static function buildNotification($notifiable, $instance, $channel) { $notification = new static([$notifiable]); - $notification->via($channel) - ->subject($instance->subject()) - ->level($instance->level()); - $method = static::messageMethod($instance, $channel); foreach ($instance->{$method}($notifiable)->elements as $element) { $notification->with($element); } + $notification->via($channel) + ->subject($instance->subject()) + ->level($instance->level()); + $method = static::optionsMethod($instance, $channel); $notification->options($instance->{$method}($notifiable));
false
Other
laravel
framework
244a0a90c3e015aead0b49f871618fba95ccec58.json
remove the morphclass (#14477)
src/Illuminate/Database/Eloquent/Model.php
@@ -182,13 +182,6 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab */ protected $with = []; - /** - * The class name to be used in polymorphic relations. - * - * @var string - */ - protected $morphClass; - /** * Indicates if the model exists. * @@ -2036,7 +2029,7 @@ public function getMorphClass() return array_search($class, $morphMap, true); } - return $this->morphClass ?: $class; + return $class; } /**
false
Other
laravel
framework
802f42fe8d3b6a106251ce53a3d41845d980a253.json
Fix a docblock (#14489)
src/Illuminate/Auth/RequestGuard.php
@@ -27,11 +27,10 @@ class RequestGuard implements Guard * Create a new authentication guard. * * @param callable $callback - * @param \Symfony\Component\HttpFoundation\Request $request + * @param \Illuminate\Http\Request $request * @return void */ - public function __construct(callable $callback, - Request $request) + public function __construct(callable $callback, Request $request) { $this->request = $request; $this->callback = $callback;
false
Other
laravel
framework
01fcf8c1576d9b765143b93cf0e6d0a2204da27a.json
Use Macroable trait in Message Builder (#14469)
src/Illuminate/Notifications/MessageBuilder.php
@@ -2,8 +2,12 @@ namespace Illuminate\Notifications; +use Illuminate\Support\Traits\Macroable; + class MessageBuilder { + use Macroable; + /** * All of the message elements. *
false
Other
laravel
framework
30f9a32bde4ac95c59fd028548872205d8ba894c.json
Handle dynamic channels.
src/Illuminate/Notifications/Channels/Notification.php
@@ -235,7 +235,7 @@ public function action($text, $url) */ public function via($channels) { - $this->via = (array) $channels; + $this->via = is_string($channels) ? func_get_args() : (array) $channels; return $this; }
false
Other
laravel
framework
30f78490a4546bc9a91d0b846ad120306968ef6c.json
add notification facade
src/Illuminate/Support/Facades/Notification.php
@@ -0,0 +1,19 @@ +<?php + +namespace Illuminate\Support\Facades; + +/** + * @see \Illuminate\Notifications\ChannelManager + */ +class Notification extends Facade +{ + /** + * Get the registered name of the component. + * + * @return string + */ + protected static function getFacadeAccessor() + { + return 'Illuminate\Notifications\ChannelManager'; + } +}
false
Other
laravel
framework
dc278125ff1b5f4f62440aef85bcec9929703508.json
Add constructor to notification stub.
src/Illuminate/Foundation/Console/stubs/notification.stub
@@ -10,6 +10,16 @@ class DummyClass extends Notification { use Queueable; + /** + * Create a new notification instance. + * + * @return void + */ + public function __construct() + { + // + } + /** * Get the notification channels. *
false
Other
laravel
framework
a305c41c330c16c9b2a0e89f268e51b7f6fcc38b.json
remove duplicate method
src/Illuminate/Support/Collection.php
@@ -564,20 +564,6 @@ public function map(callable $callback) return new static(array_combine($keys, $items)); } - /** - * Run a map over each key of the items. - * - * @param callable $callback - * @return static - */ - public function mapKeys(callable $callback) - { - return new static(array_combine( - array_map($callback, array_keys($this->items), $this->items), - array_values($this->items) - )); - } - /** * Map a collection and flatten the result by a single level. *
true
Other
laravel
framework
a305c41c330c16c9b2a0e89f268e51b7f6fcc38b.json
remove duplicate method
tests/Support/SupportCollectionTest.php
@@ -1354,24 +1354,6 @@ public function testWithMultipleModeValues() $collection = new Collection([1, 2, 2, 1]); $this->assertEquals([1, 2], $collection->mode()); } - - public function testKeyMapUsingKeysOnly() - { - $data = new Collection(['foo' => 'something', 'bar' => 'else']); - $data = $data->mapKeys(function ($key) { - return '-'.$key.'-'; - }); - $this->assertEquals(['-foo-' => 'something', '-bar-' => 'else'], $data->all()); - } - - public function testKeyMapUsingKeysAndValues() - { - $data = new Collection(['foo' => 'something', 'bar' => 'else']); - $data = $data->mapKeys(function ($key, $item) { - return $key.'-'.$item; - }); - $this->assertEquals(['foo-something' => 'something', 'bar-else' => 'else'], $data->all()); - } } class TestAccessorEloquentTestStub
true
Other
laravel
framework
f8ead240b1c9af58365ee885807cf950ca5f66d5.json
Add relation not found exception
src/Illuminate/Database/Eloquent/Builder.php
@@ -2,6 +2,7 @@ namespace Illuminate\Database\Eloquent; +use BadMethodCallException; use Closure; use Illuminate\Support\Arr; use Illuminate\Support\Str; @@ -677,7 +678,11 @@ public function getRelation($name) // not have to remove these where clauses manually which gets really hacky // and is error prone while we remove the developer's own where clauses. $relation = Relation::noConstraints(function () use ($name) { - return $this->getModel()->$name(); + try { + return $this->getModel()->$name(); + } catch (BadMethodCallException $e) { + throw new RelationNotFoundException("Call to undefined relationship {$name} on Model {$this->getModel()}"); + } }); $nested = $this->nestedRelations($name);
true
Other
laravel
framework
f8ead240b1c9af58365ee885807cf950ca5f66d5.json
Add relation not found exception
src/Illuminate/Database/Eloquent/RelationNotFoundException.php
@@ -0,0 +1,10 @@ +<?php + +namespace Illuminate\Database\Eloquent; + +use RuntimeException; + +class RelationNotFoundException extends RuntimeException +{ + // +} \ No newline at end of file
true
Other
laravel
framework
f8ead240b1c9af58365ee885807cf950ca5f66d5.json
Add relation not found exception
tests/Database/DatabaseEloquentBuilderTest.php
@@ -365,6 +365,17 @@ public function testGetRelationProperlySetsNestedRelationshipsWithSimilarNames() $relation = $builder->getRelation('ordersGroups'); } + /** + * @expectedException Illuminate\Database\Eloquent\RelationNotFoundException + */ + public function testGetRelationThrowsException() + { + $builder = $this->getBuilder(); + $builder->setModel($this->getMockModel()); + + $builder->getRelation( 'invalid' ); + } + public function testEagerLoadParsingSetsProperRelationships() { $builder = $this->getBuilder();
true
Other
laravel
framework
af21db5a47b856306243bd8045d5de0d990ad868.json
make the make:auth command less noisy
src/Illuminate/Auth/Console/MakeAuthCommand.php
@@ -49,23 +49,19 @@ public function fire() $this->exportViews(); if (! $this->option('views')) { - $this->info('Installed HomeController.'); - file_put_contents( app_path('Http/Controllers/HomeController.php'), $this->compileControllerStub() ); - $this->info('Updated Routes File.'); - file_put_contents( base_path('routes/web.php'), file_get_contents(__DIR__.'/stubs/make/routes.stub'), FILE_APPEND ); } - $this->comment('Authentication scaffolding generated successfully!'); + $this->info('Authentication scaffolding generated successfully.'); } /** @@ -96,11 +92,10 @@ protected function createDirectories() protected function exportViews() { foreach ($this->views as $key => $value) { - $path = base_path('resources/views/'.$value); - - $this->line('<info>Created View:</info> '.$path); - - copy(__DIR__.'/stubs/make/views/'.$key, $path); + copy( + __DIR__.'/stubs/make/views/'.$key, + base_path('resources/views/'.$value) + ); } }
false
Other
laravel
framework
406a2bb9ed65472a3671f9c9b55cccbda96c6033.json
Remove things that can be compiled.
src/Illuminate/Auth/Console/stubs/make/views/layouts/app.stub
@@ -7,9 +7,6 @@ <title>Laravel</title> - <!-- Fonts --> - <link href='https://fonts.googleapis.com/css?family=Open+Sans:300,400,600' rel='stylesheet' type='text/css'> - <!-- Styles --> @if (file_exists(public_path('css/app.css'))) <link href="/css/app.css" rel="stylesheet"> @@ -75,8 +72,6 @@ @yield('content') <!-- JavaScripts --> - <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.min.js" integrity="sha384-I6F5OKECLVtK/BL+8iSLDEHowSAfUo76ZL9+kGAgTRdiByINKJaqTPH/QVNS1VDb" crossorigin="anonymous"></script> - <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script> - <!-- <script src="/js/app.js"></script> --> + <script src="/js/app.js"></script> </body> </html>
false
Other
laravel
framework
9b56f12f6c1541ed19f89cfd0beb949eb3dd77c0.json
remove useless getter / setter
src/Illuminate/Queue/DatabaseQueue.php
@@ -315,25 +315,4 @@ public function getDatabase() { return $this->database; } - - /** - * Get the expiration time in seconds. - * - * @return int|null - */ - public function getExpire() - { - return $this->expire; - } - - /** - * Set the expiration time in seconds. - * - * @param int|null $seconds - * @return void - */ - public function setExpire($seconds) - { - $this->expire = $seconds; - } }
false
Other
laravel
framework
c5acf79cc86275f45018056cb3c1e95f32619af1.json
Add keyMap method to collection
src/Illuminate/Support/Collection.php
@@ -564,6 +564,21 @@ public function map(callable $callback) return new static(array_combine($keys, $items)); } + /** + * Run a map over each key of the items. + * + * @param callable $callback + * @return static + */ + public function keyMap(callable $callback) + { + $values = array_values($this->items); + + $keys = array_map($callback, array_keys($this->items), $this->items); + + return new static(array_combine($keys, $values)); + } + /** * Map a collection and flatten the result by a single level. *
true
Other
laravel
framework
c5acf79cc86275f45018056cb3c1e95f32619af1.json
Add keyMap method to collection
tests/Support/SupportCollectionTest.php
@@ -1354,6 +1354,24 @@ public function testWithMultipleModeValues() $collection = new Collection([1, 2, 2, 1]); $this->assertEquals([1, 2], $collection->mode()); } + + public function testKeyMapUsingKeysOnly() + { + $data = new Collection(['foo' => 'something', 'bar' => 'else']); + $data = $data->keyMap(function ($key) { + return '-'.$key.'-'; + }); + $this->assertEquals(['-foo-' => 'something', '-bar-' => 'else'], $data->all()); + } + + public function testKeyMapUsingKeysAndValues() + { + $data = new Collection(['foo' => 'something', 'bar' => 'else']); + $data = $data->keyMap(function ($key, $item) { + return $key.'-'.$item; + }); + $this->assertEquals(['foo-something' => 'something', 'bar-else' => 'else'], $data->all()); + } } class TestAccessorEloquentTestStub
true
Other
laravel
framework
8021540aaf020f1a2e2fafccba89a4783a9fc262.json
fix tests for php 7
tests/Queue/QueueBeanstalkdJobTest.php
@@ -24,7 +24,7 @@ public function testFailedProperlyCallsTheJobHandler() $job = $this->getJob(); $job->getPheanstalkJob()->shouldReceive('getData')->once()->andReturn(json_encode(['job' => 'foo', 'data' => ['data']])); $job->getContainer()->shouldReceive('make')->once()->with('foo')->andReturn($handler = m::mock('BeanstalkdJobTestFailedTest')); - $handler->shouldReceive('failed')->once()->with(['data'], m::type('Throwable')); + $handler->shouldReceive('failed')->once()->with(['data'], m::type('Exception')); $job->failed(new Exception); }
true
Other
laravel
framework
8021540aaf020f1a2e2fafccba89a4783a9fc262.json
fix tests for php 7
tests/Queue/QueueWorkerTest.php
@@ -61,19 +61,6 @@ public function test_exception_is_reported_if_connection_throws_exception_on_job $this->exceptionHandler->shouldHaveReceived('report')->with($e); } - public function test_exception_is_reported_if_connection_throws_fatal_throwable_on_job_pop() - { - $worker = new InsomniacWorker( - new WorkerFakeManager('default', new BrokenQueueConnection($e = new Error('something'))), - $this->events, - $this->exceptionHandler - ); - - $worker->runNextJob('default', 'queue', $this->workerOptions()); - - $this->exceptionHandler->shouldHaveReceived('report')->with(Mockery::type(FatalThrowableError::class)); - } - public function test_worker_sleeps_when_queue_is_empty() { $worker = $this->getWorker('default', ['queue' => []]);
true
Other
laravel
framework
a5b537b3624e228cecd255341edc4314ebceb416.json
remove throwable type hints
src/Illuminate/Contracts/Queue/Job.php
@@ -2,8 +2,6 @@ namespace Illuminate\Contracts\Queue; -use Throwable; - interface Job { /** @@ -62,7 +60,7 @@ public function getName(); * @param \Throwable $e * @return void */ - public function failed(Throwable $e); + public function failed($e); /** * Get the name of the queue the job belongs to.
true
Other
laravel
framework
a5b537b3624e228cecd255341edc4314ebceb416.json
remove throwable type hints
src/Illuminate/Queue/CallQueuedHandler.php
@@ -71,7 +71,7 @@ protected function setJobInstanceIfNecessary(Job $job, $instance) * @param \Throwable $e * @return void */ - public function failed(array $data, Throwable $e) + public function failed(array $data, $e) { $command = unserialize($data['command']);
true
Other
laravel
framework
a5b537b3624e228cecd255341edc4314ebceb416.json
remove throwable type hints
src/Illuminate/Queue/Events/JobFailed.php
@@ -2,8 +2,6 @@ namespace Illuminate\Queue\Events; -use Throwable; - class JobFailed { /** @@ -35,7 +33,7 @@ class JobFailed * @param \Throwable $throwable * @return void */ - public function __construct($connectionName, $job, Throwable $throwable) + public function __construct($connectionName, $job, $throwable) { $this->job = $job; $this->throwable = $throwable;
true
Other
laravel
framework
a5b537b3624e228cecd255341edc4314ebceb416.json
remove throwable type hints
src/Illuminate/Queue/Failed/DatabaseFailedJobProvider.php
@@ -2,7 +2,6 @@ namespace Illuminate\Queue\Failed; -use Throwable; use Carbon\Carbon; use Illuminate\Database\ConnectionResolverInterface; @@ -53,7 +52,7 @@ public function __construct(ConnectionResolverInterface $resolver, $database, $t * @param \Throwable $exception * @return int|null */ - public function log($connection, $queue, $payload, Throwable $exception) + public function log($connection, $queue, $payload, $exception) { $failed_at = Carbon::now();
true
Other
laravel
framework
a5b537b3624e228cecd255341edc4314ebceb416.json
remove throwable type hints
src/Illuminate/Queue/Failed/FailedJobProviderInterface.php
@@ -2,8 +2,6 @@ namespace Illuminate\Queue\Failed; -use Throwable; - interface FailedJobProviderInterface { /** @@ -15,7 +13,7 @@ interface FailedJobProviderInterface * @param \Throwable $exception * @return int|null */ - public function log($connection, $queue, $payload, Throwable $exception); + public function log($connection, $queue, $payload, $exception); /** * Get a list of all of the failed jobs.
true
Other
laravel
framework
a5b537b3624e228cecd255341edc4314ebceb416.json
remove throwable type hints
src/Illuminate/Queue/Failed/NullFailedJobProvider.php
@@ -2,8 +2,6 @@ namespace Illuminate\Queue\Failed; -use Throwable; - class NullFailedJobProvider implements FailedJobProviderInterface { /** @@ -15,7 +13,7 @@ class NullFailedJobProvider implements FailedJobProviderInterface * @param \Throwable $exception * @return int|null */ - public function log($connection, $queue, $payload, Throwable $exception) + public function log($connection, $queue, $payload, $exception) { // }
true
Other
laravel
framework
a5b537b3624e228cecd255341edc4314ebceb416.json
remove throwable type hints
src/Illuminate/Queue/Jobs/Job.php
@@ -3,7 +3,6 @@ namespace Illuminate\Queue\Jobs; use DateTime; -use Throwable; use Illuminate\Support\Arr; abstract class Job @@ -141,7 +140,7 @@ public function isDeletedOrReleased() * @param \Throwable $e * @return void */ - public function failed(Throwable $e) + public function failed($e) { $payload = $this->payload();
true
Other
laravel
framework
a5b537b3624e228cecd255341edc4314ebceb416.json
remove throwable type hints
src/Illuminate/Queue/SyncQueue.php
@@ -46,7 +46,7 @@ public function push($job, $data = '', $queue = null) * @param \Throwable $e * @return void */ - protected function handleSyncException($queueJob, Throwable $e) + protected function handleSyncException($queueJob, $e) { $this->raiseExceptionOccurredJobEvent($queueJob, $e); @@ -137,7 +137,7 @@ protected function raiseAfterJobEvent(Job $job) * @param \Throwable $e * @return void */ - protected function raiseExceptionOccurredJobEvent(Job $job, Throwable $e) + protected function raiseExceptionOccurredJobEvent(Job $job, $e) { if ($this->container->bound('events')) { $this->container['events']->fire(new Events\JobExceptionOccurred('sync', $job, $e)); @@ -151,7 +151,7 @@ protected function raiseExceptionOccurredJobEvent(Job $job, Throwable $e) * @param \Throwable $e * @return array */ - protected function handleFailedJob(Job $job, Throwable $e) + protected function handleFailedJob(Job $job, $e) { $job->failed($e); @@ -165,7 +165,7 @@ protected function handleFailedJob(Job $job, Throwable $e) * @param \Throwable $e * @return void */ - protected function raiseFailedJobEvent(Job $job, Throwable $e) + protected function raiseFailedJobEvent(Job $job, $e) { if ($this->container->bound('events')) { $this->container['events']->fire(new Events\JobFailed('sync', $job, $e));
true
Other
laravel
framework
a5b537b3624e228cecd255341edc4314ebceb416.json
remove throwable type hints
src/Illuminate/Queue/Worker.php
@@ -222,10 +222,10 @@ public function process($connectionName, $job, WorkerOptions $options) * @param WorkerOptions $options * @param \Throwable $e * @return void - * - * @throws \Throwable + *Throwable + * @throws \ */ - protected function handleJobException($connectionName, $job, WorkerOptions $options, Throwable $e) + protected function handleJobException($connectionName, $job, WorkerOptions $options, $e) { // If we catch an exception, we will attempt to release the job back onto the queue // so it is not lost entirely. This'll let the job be retried at a later time by @@ -257,7 +257,7 @@ protected function handleJobException($connectionName, $job, WorkerOptions $opti * @return void */ protected function markJobAsFailedIfHasExceededMaxAttempts( - $connectionName, $job, $maxTries, Throwable $e + $connectionName, $job, $maxTries, $e ) { if ($maxTries === 0 || $job->attempts() < $maxTries) { return; @@ -309,7 +309,7 @@ protected function raiseAfterJobEvent($connectionName, $job) * @param \Throwable $e * @return void */ - protected function raiseExceptionOccurredJobEvent($connectionName, $job, Throwable $e) + protected function raiseExceptionOccurredJobEvent($connectionName, $job, $e) { $this->events->fire(new Events\JobExceptionOccurred( $connectionName, $job, $e @@ -324,7 +324,7 @@ protected function raiseExceptionOccurredJobEvent($connectionName, $job, Throwab * @param \Throwable $e * @return void */ - protected function raiseFailedJobEvent($connectionName, $job, Throwable $e) + protected function raiseFailedJobEvent($connectionName, $job, $e) { $this->events->fire(new Events\JobFailed( $connectionName, $job, $e
true
Other
laravel
framework
f1e43d1e55453126bc21747762a7e528a1e1a23b.json
Remove unneeded code.
src/Illuminate/Queue/QueueManager.php
@@ -135,8 +135,6 @@ public function connection($name = null) $this->connections[$name] = $this->resolve($name); $this->connections[$name]->setContainer($this->app); - - $this->connections[$name]->setEncrypter($this->app['encrypter']); } return $this->connections[$name];
true
Other
laravel
framework
f1e43d1e55453126bc21747762a7e528a1e1a23b.json
Remove unneeded code.
tests/Queue/QueueManagerTest.php
@@ -28,7 +28,6 @@ public function testDefaultConnectionCanBeResolved() return $connector; }); $queue->shouldReceive('setContainer')->once()->with($app); - $queue->shouldReceive('setEncrypter')->once()->with($encrypter); $this->assertSame($queue, $manager->connection('sync')); } @@ -51,7 +50,6 @@ public function testOtherConnectionCanBeResolved() return $connector; }); $queue->shouldReceive('setContainer')->once()->with($app); - $queue->shouldReceive('setEncrypter')->once()->with($encrypter); $this->assertSame($queue, $manager->connection('foo')); } @@ -73,7 +71,6 @@ public function testNullConnectionCanBeResolved() return $connector; }); $queue->shouldReceive('setContainer')->once()->with($app); - $queue->shouldReceive('setEncrypter')->once()->with($encrypter); $this->assertSame($queue, $manager->connection('null')); }
true
Other
laravel
framework
880107fa8c24d4b31f155bd1b92fd4bfa1a1ac52.json
Use "expire" to be consistent with other drivers.
src/Illuminate/Queue/Connectors/BeanstalkdConnector.php
@@ -20,7 +20,7 @@ public function connect(array $config) $pheanstalk = new Pheanstalk($config['host'], Arr::get($config, 'port', PheanstalkInterface::DEFAULT_PORT)); return new BeanstalkdQueue( - $pheanstalk, $config['queue'], Arr::get($config, 'ttr', Pheanstalk::DEFAULT_TTR) + $pheanstalk, $config['queue'], Arr::get($config, 'expire', Pheanstalk::DEFAULT_TTR) ); } }
false
Other
laravel
framework
ab8fb62485c27611746e8336add504afc6e16373.json
simplify mailable stub even further
src/Illuminate/Foundation/Console/stubs/mail.stub
@@ -27,8 +27,6 @@ class DummyClass extends Mailable */ public function build() { - return $this->to('example@example.com') - ->subject('Message Subject') - ->view('view.name'); + return $this->view('view.name'); } }
false
Other
laravel
framework
c6eff0f8dcd480985ca7788afa1d98bf5d62983c.json
Use cleaner API for mocking model events
src/Illuminate/Foundation/Testing/Concerns/MocksApplicationServices.php
@@ -142,14 +142,15 @@ protected function withoutModelEvents() * * These events will be mocked, so that handlers will not actually be executed. * + * @param string $model * @param array|string $events * @return $this * * @throws \Exception */ - public function expectsModelEvents($events) + public function expectsModelEvents($model, $events) { - $events = is_array($events) ? $events : func_get_args(); + $events = $this->formatModelEvents($model, $events); $this->withoutModelEvents(); @@ -171,12 +172,15 @@ public function expectsModelEvents($events) * * These events will be mocked, so that handlers will not actually be executed. * + * @param string $model * @param array|string $events * @return $this + * + * @throws \Exception */ - public function doesntExpectModelEvents($events) + public function doesntExpectModelEvents($model, $events) { - $events = is_array($events) ? $events : func_get_args(); + $events = $this->formatModelEvents($model, $events); $this->withoutModelEvents(); @@ -191,6 +195,24 @@ public function doesntExpectModelEvents($events) return $this; } + /** + * Turn a model and a list of events into the format used by eloquent + * + * @param string $model + * @param array|string $events + * @return string[] + * + * @throws \Exception + */ + private function formatModelEvents($model, $events) + { + $events = (array) $events; + + return array_map(function ($event) use ($model) { + return "eloquent.{$event}: {$model}"; + }, (array) $events); + } + /** * Specify a list of observers that will not run for the given operation. *
true
Other
laravel
framework
c6eff0f8dcd480985ca7788afa1d98bf5d62983c.json
Use cleaner API for mocking model events
tests/Foundation/FoundationExpectsModelEventsTest.php
@@ -12,6 +12,8 @@ class FoundationExpectsModelEventsTest extends TestCase { public function createApplication() { + Model::clearBootedModels(); + $app = new Application; $db = new DB; @@ -36,7 +38,7 @@ public function a_mock_replaces_the_event_dispatcher_when_calling_expects_model_ $this->assertNotInstanceOf(Mock::class, Model::getEventDispatcher()); - $this->expectsModelEvents([]); + $this->expectsModelEvents(EloquentTestModel::class, []); $this->assertNotInstanceOf(Dispatcher::class, Model::getEventDispatcher()); $this->assertInstanceOf(Mock::class, Model::getEventDispatcher()); @@ -53,21 +55,40 @@ public function a_mock_does_not_carry_over_between_tests() /** @test */ public function fired_events_can_be_checked_for() { - $this->expectsModelEvents([ - 'eloquent.booting: EloquentTestModel', - 'eloquent.booted: EloquentTestModel', + $this->expectsModelEvents(EloquentTestModel::class, [ + 'booting', + 'booted', + + 'creating', + 'created', - 'eloquent.creating: EloquentTestModel', - 'eloquent.created: EloquentTestModel', + 'saving', + 'saved', - 'eloquent.saving: EloquentTestModel', - 'eloquent.saved: EloquentTestModel', + 'updating', + 'updated', + + 'deleting', + 'deleted', + ]); - 'eloquent.updating: EloquentTestModel', - 'eloquent.updated: EloquentTestModel', + $model = EloquentTestModel::create(['field' => 1]); + $model->field = 2; + $model->save(); + $model->delete(); + } + + /** @test */ + public function using_expects_model_events_multiple_times_works() + { + $this->expectsModelEvents(EloquentTestModel::class, [ + 'booting', + 'booted', + ]); - 'eloquent.deleting: EloquentTestModel', - 'eloquent.deleted: EloquentTestModel', + $this->expectsModelEvents(EloquentTestModel::class, [ + 'creating', + 'created', ]); $model = EloquentTestModel::create(['field' => 1]); @@ -76,12 +97,63 @@ public function fired_events_can_be_checked_for() $model->delete(); } + /** @test */ + public function expects_model_events_can_take_a_string_as_the_event_name() + { + $this->expectsModelEvents(EloquentTestModel::class, "booting"); + + EloquentTestModel::create(['field' => 1]); + } + + /** @test */ + public function unfired_events_can_be_checked_for() + { + $this->doesntExpectModelEvents(EloquentTestModel::class, [ + 'updating', + 'updated', + + 'deleting', + 'deleted', + ]); + + EloquentTestModel::create(['field' => 1]); + } + + /** @test */ + public function using_doesnt_expect_model_events_multiple_times_works() + { + $this->doesntExpectModelEvents(EloquentTestModel::class, [ + 'updating', + 'updated', + ]); + + $this->doesntExpectModelEvents(EloquentTestModel::class, [ + 'deleting', + 'deleted', + ]); + + EloquentTestModel::create(['field' => 1]); + } + + /** @test */ + public function doesnt_expect_model_events_can_take_a_string_as_the_event_name() + { + $this->doesntExpectModelEvents(EloquentTestModel::class, "deleting"); + + EloquentTestModel::create(['field' => 1]); + } + /** @test */ public function observers_do_not_fire_when_mocking_events() { - $this->expectsModelEvents([ - 'eloquent.saving: EloquentTestModel', - 'eloquent.saved: EloquentTestModel', + $this->expectsModelEvents(EloquentTestModel::class, [ + 'saving', + 'saved', + ]); + + $this->doesntExpectModelEvents(EloquentTestModel::class, [ + 'deleting', + 'deleted', ]); EloquentTestModel::observe(new EloquentTestModelFailingObserver); @@ -136,4 +208,14 @@ public function saved() { PHPUnit_Framework_Assert::fail('The [saved] method should not be called on '.static::class); } + + public function deleting() + { + PHPUnit_Framework_Assert::fail('The [deleting] method should not be called on '.static::class); + } + + public function deleted() + { + PHPUnit_Framework_Assert::fail('The [deleted] method should not be called on '.static::class); + } }
true
Other
laravel
framework
ac6aec3e5e78fd99ac992991e9e924da72a977bc.json
Shorten a few lines.
src/Illuminate/Mail/Mailer.php
@@ -184,7 +184,9 @@ public function queue($view, array $data, $callback, $queue = null) { $callback = $this->buildQueueCallable($callback); - return $this->queue->push('mailer@handleQueuedMessage', compact('view', 'data', 'callback'), $queue); + return $this->queue->push( + 'mailer@handleQueuedMessage', compact('view', 'data', 'callback'), $queue + ); } /** @@ -231,7 +233,10 @@ public function later($delay, $view, array $data, $callback, $queue = null) { $callback = $this->buildQueueCallable($callback); - return $this->queue->later($delay, 'mailer@handleQueuedMessage', compact('view', 'data', 'callback'), $queue); + return $this->queue->later( + $delay, 'mailer@handleQueuedMessage', + compact('view', 'data', 'callback'), $queue + ); } /**
false
Other
laravel
framework
75e8cf11296c8754fc16ed118ef7aac7dbbdfcf9.json
Handle array keys with dots, fixes #14384 (#14388)
src/Illuminate/Validation/Validator.php
@@ -191,21 +191,46 @@ public function __construct(TranslatorInterface $translator, array $data, array { $this->translator = $translator; $this->customMessages = $messages; - $this->data = $this->parseData($data); + $this->data = $this->hydrateFiles($this->parseData($data)); $this->customAttributes = $customAttributes; $this->initialRules = $rules; $this->setRules($rules); } /** - * Parse the data and hydrate the files array. + * Parse the data array. + * + * @param array $data + * @return array + */ + public function parseData(array $data) + { + $newData = []; + + foreach ($data as $key => $value) { + if (is_array($value)) { + $value = $this->parseData($value); + } + + if (Str::contains($key, '.')) { + $newData[str_replace('.', '->', $key)] = $value; + } else { + $newData[$key] = $value; + } + } + + return $newData; + } + + /** + * Hydrate the files array. * * @param array $data * @param string $arrayKey * @return array */ - protected function parseData(array $data, $arrayKey = null) + protected function hydrateFiles(array $data, $arrayKey = null) { if (is_null($arrayKey)) { $this->files = []; @@ -222,7 +247,7 @@ protected function parseData(array $data, $arrayKey = null) unset($data[$key]); } elseif (is_array($value)) { - $this->parseData($value, $key); + $this->hydrateFiles($value, $key); } } @@ -420,6 +445,8 @@ public function passes() // rule. Any error messages will be added to the containers with each of // the other error messages, returning true if we don't have messages. foreach ($this->rules as $attribute => $rules) { + $attribute = str_replace('\.', '->', $attribute); + foreach ($rules as $rule) { $this->validateAttribute($attribute, $rule);
true