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
df01d9e85140e898f20f6ba8566ba052f80d5c5c.json
Add keys to transfrom
tests/Support/SupportCollectionTest.php
@@ -495,9 +495,9 @@ public function testGetListValueWithAccessors() public function testTransform() { - $data = new Collection(array('taylor', 'colin', 'shawn')); - $data->transform(function($item) { return strrev($item); }); - $this->assertEquals(array('rolyat', 'niloc', 'nwahs'), array_values($data->all())); + $data = new Collection(['first' => 'taylor', 'last' => 'otwell']); + $data->transform(function($item, $key) { return $key.'-'.strrev($item); }); + $this->assertEquals(['first' => 'first-rolyat', 'last' => 'last-llewto'], $data->all()); }
true
Other
laravel
framework
27474ee6013a96a8a6acef5b16bf92c51ed6eadb.json
Combine sort tests
tests/Support/SupportCollectionTest.php
@@ -237,16 +237,10 @@ public function testCollapseWithNestedCollactions() public function testSort() { $data = (new Collection([5, 3, 1, 2, 4]))->sort(); + $this->assertEquals([1, 2, 3, 4, 5], $data->values()->all()); - $this->assertEquals(range(1, 5), array_values($data->all())); - } - - - public function testSortWithStrings() - { $data = (new Collection(['foo', 'bar-10', 'bar-1']))->sort(); - - $this->assertEquals(['bar-1', 'bar-10', 'foo'], array_values($data->all())); + $this->assertEquals(['bar-1', 'bar-10', 'foo'], $data->values()->all()); }
false
Other
laravel
framework
1232e5e7baf7d6faeed139ff6014bb5b5bc66e10.json
Add keys to transform
src/Illuminate/Support/Collection.php
@@ -740,7 +740,7 @@ public function take($limit = null) */ public function transform(callable $callback) { - $this->items = array_map($callback, $this->items); + $this->items = array_map($callback, $this->items, array_keys($this->items)); return $this; }
true
Other
laravel
framework
1232e5e7baf7d6faeed139ff6014bb5b5bc66e10.json
Add keys to transform
tests/Support/SupportCollectionTest.php
@@ -494,8 +494,8 @@ public function testGetListValueWithAccessors() public function testTransform() { $data = new Collection(array('taylor', 'colin', 'shawn')); - $data->transform(function($item) { return strrev($item); }); - $this->assertEquals(array('rolyat', 'niloc', 'nwahs'), array_values($data->all())); + $data->transform(function($item, $key) { return strrev($item).$key; }); + $this->assertEquals(array('rolyat0', 'niloc1', 'nwahs2'), array_values($data->all())); }
true
Other
laravel
framework
e57cb0d968841bd67bf2b8eb589d4479de924ee1.json
Return a new instance from sortBy and sortByDesc
src/Illuminate/Support/Collection.php
@@ -636,7 +636,7 @@ public function sort(callable $callback) * @param callable|string $callback * @param int $options * @param bool $descending - * @return $this + * @return static */ public function sortBy($callback, $options = SORT_REGULAR, $descending = false) { @@ -663,17 +663,15 @@ public function sortBy($callback, $options = SORT_REGULAR, $descending = false) $results[$key] = $this->items[$key]; } - $this->items = $results; - - return $this; + return new static($results); } /** * Sort the collection in descending order using the given callback. * * @param callable|string $callback * @param int $options - * @return $this + * @return static */ public function sortByDesc($callback, $options = SORT_REGULAR) {
true
Other
laravel
framework
e57cb0d968841bd67bf2b8eb589d4479de924ee1.json
Return a new instance from sortBy and sortByDesc
tests/Support/SupportCollectionTest.php
@@ -257,7 +257,7 @@ public function testSortBy() $this->assertEquals(array('dayle', 'taylor'), array_values($data->all())); $data = new Collection(array('dayle', 'taylor')); - $data->sortByDesc(function($x) { return $x; }); + $data = $data->sortByDesc(function($x) { return $x; }); $this->assertEquals(array('taylor', 'dayle'), array_values($data->all())); }
true
Other
laravel
framework
a0b12ce1357348f849fb00020b39e0b924dc8e73.json
Return a new collection from sort
src/Illuminate/Support/Collection.php
@@ -619,13 +619,15 @@ public function chunk($size, $preserveKeys = false) * Sort through each item with a callback. * * @param callable $callback - * @return $this + * @return static */ public function sort(callable $callback) { - uasort($this->items, $callback); + $items = $this->items; - return $this; + uasort($items, $callback); + + return new static($items); } /**
true
Other
laravel
framework
a0b12ce1357348f849fb00020b39e0b924dc8e73.json
Return a new collection from sort
tests/Support/SupportCollectionTest.php
@@ -236,8 +236,7 @@ public function testCollapseWithNestedCollactions() public function testSort() { - $data = new Collection(array(5, 3, 1, 2, 4)); - $data->sort(function($a, $b) + $data = (new Collection([5, 3, 1, 2, 4]))->sort(function($a, $b) { if ($a === $b) {
true
Other
laravel
framework
238f638b08428a86a5fb6ee06715620bcbcf8532.json
Return a new collection from shuffle
src/Illuminate/Support/Collection.php
@@ -572,13 +572,15 @@ public function shift() /** * Shuffle the items in the collection. * - * @return $this + * @return static */ public function shuffle() { - shuffle($this->items); + $items = $this->items; - return $this; + array_shuffle($items); + + return new static($items); } /**
false
Other
laravel
framework
6c5d82c76fc50d930191217f53f9c32d0dd1c0e6.json
Seperate Auth and Registration traits. Simplifies opting out of Registration.
src/Illuminate/Foundation/Auth/AuthenticatesAndRegistersUsers.php
@@ -1,134 +1,9 @@ <?php namespace Illuminate\Foundation\Auth; -use Illuminate\Http\Request; -use Illuminate\Support\Facades\Auth; - trait AuthenticatesAndRegistersUsers { - /** - * Show the application registration form. - * - * @return \Illuminate\Http\Response - */ - public function getRegister() - { - return view('auth.register'); - } - - /** - * Handle a registration request for the application. - * - * @param \Illuminate\Http\Request $request - * @return \Illuminate\Http\Response - */ - public function postRegister(Request $request) - { - $validator = $this->validator($request->all()); - - if ($validator->fails()) - { - $this->throwValidationException( - $request, $validator - ); - } - - Auth::login($this->create($request->all())); - - return redirect($this->redirectPath()); - } - - /** - * Show the application login form. - * - * @return \Illuminate\Http\Response - */ - public function getLogin() - { - return view('auth.login'); - } - - /** - * Handle a login request to the application. - * - * @param \Illuminate\Http\Request $request - * @return \Illuminate\Http\Response - */ - public function postLogin(Request $request) - { - $this->validate($request, [ - 'email' => 'required|email', 'password' => 'required', - ]); - - $credentials = $this->getCredentials($request); - - if (Auth::attempt($credentials, $request->has('remember'))) - { - return redirect()->intended($this->redirectPath()); - } - - return redirect($this->loginPath()) - ->withInput($request->only('email', 'remember')) - ->withErrors([ - 'email' => $this->getFailedLoginMessage(), - ]); - } - - /** - * Get the needed authorization credentials from the request. - * - * @param \Illuminate\Http\Request $request - * @return array - */ - protected function getCredentials(Request $request) - { - return $request->only('email', 'password'); - } - - /** - * Get the failed login message. - * - * @return string - */ - protected function getFailedLoginMessage() - { - return 'These credentials do not match our records.'; - } - - /** - * Log the user out of the application. - * - * @return \Illuminate\Http\Response - */ - public function getLogout() - { - Auth::logout(); - - return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/'); - } - - /** - * Get the post register / login redirect path. - * - * @return string - */ - public function redirectPath() - { - if (property_exists($this, 'redirectPath')) - { - return $this->redirectPath; - } - - return property_exists($this, 'redirectTo') ? $this->redirectTo : '/home'; - } - - /** - * Get the path to the login route. - * - * @return string - */ - public function loginPath() - { - return property_exists($this, 'loginPath') ? $this->loginPath : '/auth/login'; + use AuthenticatesUsers, RegistersUsers { + AuthenticatesUsers::redirectPath insteadof RegistersUsers; } }
true
Other
laravel
framework
6c5d82c76fc50d930191217f53f9c32d0dd1c0e6.json
Seperate Auth and Registration traits. Simplifies opting out of Registration.
src/Illuminate/Foundation/Auth/AuthenticatesUsers.php
@@ -0,0 +1,89 @@ +<?php namespace Illuminate\Foundation\Auth; + +use Illuminate\Http\Request; +use Illuminate\Support\Facades\Auth; + +trait AuthenticatesUsers { + + use Redirectable; + + /** + * Show the application login form. + * + * @return \Illuminate\Http\Response + */ + public function getLogin() + { + return view('auth.login'); + } + + /** + * Handle a login request to the application. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function postLogin(Request $request) + { + $this->validate($request, [ + 'email' => 'required|email', 'password' => 'required', + ]); + + $credentials = $this->getCredentials($request); + + if (Auth::attempt($credentials, $request->has('remember'))) + { + return redirect()->intended($this->redirectPath()); + } + + return redirect($this->loginPath()) + ->withInput($request->only('email', 'remember')) + ->withErrors([ + 'email' => $this->getFailedLoginMessage(), + ]); + } + + /** + * Get the needed authorization credentials from the request. + * + * @param \Illuminate\Http\Request $request + * @return array + */ + protected function getCredentials(Request $request) + { + return $request->only('email', 'password'); + } + + /** + * Get the failed login message. + * + * @return string + */ + protected function getFailedLoginMessage() + { + return 'These credentials do not match our records.'; + } + + /** + * Log the user out of the application. + * + * @return \Illuminate\Http\Response + */ + public function getLogout() + { + Auth::logout(); + + return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/'); + } + + /** + * Get the path to the login route. + * + * @return string + */ + public function loginPath() + { + return property_exists($this, 'loginPath') ? $this->loginPath : '/auth/login'; + } + +}
true
Other
laravel
framework
6c5d82c76fc50d930191217f53f9c32d0dd1c0e6.json
Seperate Auth and Registration traits. Simplifies opting out of Registration.
src/Illuminate/Foundation/Auth/Redirectable.php
@@ -0,0 +1,20 @@ +<?php namespace Illuminate\Foundation\Auth; + +trait Redirectable { + + /** + * Get the post register / login redirect path. + * + * @return string + */ + public function redirectPath() + { + if (property_exists($this, 'redirectPath')) + { + return $this->redirectPath; + } + + return property_exists($this, 'redirectTo') ? $this->redirectTo : '/home'; + } + +}
true
Other
laravel
framework
6c5d82c76fc50d930191217f53f9c32d0dd1c0e6.json
Seperate Auth and Registration traits. Simplifies opting out of Registration.
src/Illuminate/Foundation/Auth/RegistersUsers.php
@@ -0,0 +1,42 @@ +<?php namespace Illuminate\Foundation\Auth; + +use Illuminate\Http\Request; +use Illuminate\Support\Facades\Auth; + +trait RegistersUsers { + + use Redirectable; + + /** + * Show the application registration form. + * + * @return \Illuminate\Http\Response + */ + public function getRegister() + { + return view('auth.register'); + } + + /** + * Handle a registration request for the application. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function postRegister(Request $request) + { + $validator = $this->validator($request->all()); + + if ($validator->fails()) + { + $this->throwValidationException( + $request, $validator + ); + } + + Auth::login($this->create($request->all())); + + return redirect($this->redirectPath()); + } + +}
true
Other
laravel
framework
ce821c04a0fe042892629217701307253626cf72.json
Use self and static
src/Illuminate/Database/Eloquent/Model.php
@@ -1613,7 +1613,7 @@ public function touchOwners() { $this->$relation()->touch(); - if ($this->$relation instanceof Model) + if ($this->$relation instanceof self) { $this->$relation->touchOwners(); }
true
Other
laravel
framework
ce821c04a0fe042892629217701307253626cf72.json
Use self and static
src/Illuminate/Database/Query/Builder.php
@@ -251,7 +251,7 @@ public function selectSub($query, $as) $callback($query = $this->newQuery()); } - if ($query instanceof Builder) + if ($query instanceof self) { $bindings = $query->getBindings(); @@ -1816,7 +1816,7 @@ public function truncate() */ public function newQuery() { - return new Builder($this->connection, $this->grammar, $this->processor); + return new static($this->connection, $this->grammar, $this->processor); } /**
true
Other
laravel
framework
ce821c04a0fe042892629217701307253626cf72.json
Use self and static
src/Illuminate/Support/Collection.php
@@ -925,7 +925,7 @@ public function __toString() */ protected function getArrayableItems($items) { - if ($items instanceof Collection) + if ($items instanceof self) { $items = $items->all(); }
true
Other
laravel
framework
b4c81de41528e65d61e12b5959a6b24921e4c497.json
Remove duplicate linebreks
src/Illuminate/Console/Scheduling/Event.php
@@ -182,7 +182,6 @@ public function buildCommand() $command = $this->command.' > '.$this->output.' 2>&1 &'; } - return $this->user ? 'sudo -u '.$this->user.' '.$command : $command; }
true
Other
laravel
framework
b4c81de41528e65d61e12b5959a6b24921e4c497.json
Remove duplicate linebreks
src/Illuminate/Database/Eloquent/Model.php
@@ -3046,7 +3046,6 @@ public function getRelation($relation) return $this->relations[$relation]; } - /** * Determine if the given relation is loaded. *
true
Other
laravel
framework
b4c81de41528e65d61e12b5959a6b24921e4c497.json
Remove duplicate linebreks
src/Illuminate/Foundation/helpers.php
@@ -293,7 +293,6 @@ function factory() } } - if ( ! function_exists('get')) { /**
true
Other
laravel
framework
b4c81de41528e65d61e12b5959a6b24921e4c497.json
Remove duplicate linebreks
src/Illuminate/Support/helpers.php
@@ -588,7 +588,6 @@ function array_sort_recursive($array) { } } - if ( ! function_exists('snake_case')) { /**
true
Other
laravel
framework
7bd077e01692c04329c26148c54f648c3151d5d4.json
Remove unused use
src/Illuminate/Broadcasting/BroadcastEvent.php
@@ -1,6 +1,5 @@ <?php namespace Illuminate\Broadcasting; -use Pusher; use ReflectionClass; use ReflectionProperty; use Illuminate\Contracts\Queue\Job;
true
Other
laravel
framework
7bd077e01692c04329c26148c54f648c3151d5d4.json
Remove unused use
src/Illuminate/Console/Command.php
@@ -8,7 +8,6 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ChoiceQuestion; -use Symfony\Component\Console\Question\ConfirmationQuestion; use Illuminate\Contracts\Foundation\Application as LaravelApplication; class Command extends \Symfony\Component\Console\Command\Command {
true
Other
laravel
framework
7bd077e01692c04329c26148c54f648c3151d5d4.json
Remove unused use
src/Illuminate/Foundation/Auth/AuthenticatesAndRegistersUsers.php
@@ -2,8 +2,6 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; -use Illuminate\Contracts\Auth\Guard; -use Illuminate\Contracts\Auth\Registrar; trait AuthenticatesAndRegistersUsers {
true
Other
laravel
framework
7bd077e01692c04329c26148c54f648c3151d5d4.json
Remove unused use
src/Illuminate/Session/SessionManager.php
@@ -1,6 +1,5 @@ <?php namespace Illuminate\Session; -use InvalidArgumentException; use Illuminate\Support\Manager; use Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSessionHandler;
true
Other
laravel
framework
7bd077e01692c04329c26148c54f648c3151d5d4.json
Remove unused use
src/Illuminate/Support/Collection.php
@@ -1,6 +1,5 @@ <?php namespace Illuminate\Support; -use Closure; use Countable; use ArrayAccess; use ArrayIterator;
true
Other
laravel
framework
83167a14ad2a378eaf9bc8b21acc14d0f9ceb445.json
Add docblock to toIlluminateResponse
src/Illuminate/Foundation/Exceptions/Handler.php
@@ -2,6 +2,7 @@ use Exception; use Psr\Log\LoggerInterface; +use Illuminate\Http\Response; use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\Console\Application as ConsoleApplication; use Symfony\Component\Debug\ExceptionHandler as SymfonyDisplayer; @@ -93,9 +94,16 @@ public function render($request, Exception $e) } } - protected function toIlluminateResponse($response, $e) + /** + * Map exception into an illuminate response. + * + * @param \Symfony\Component\HttpFoundation\Response $response + * @param \Exception $e + * @return \Illuminate\Http\Response + */ + protected function toIlluminateResponse($response, Exception $e) { - $response = new \Illuminate\Http\Response($response->getContent(), $response->getStatusCode(), $response->headers->all()); + $response = new Response($response->getContent(), $response->getStatusCode(), $response->headers->all()); $response->exception = $e;
false
Other
laravel
framework
17ee7b365145d4e75ecc695159ff6e68a8e2e262.json
Fix BelongsToMany::firstOrNew logic
src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php
@@ -629,7 +629,7 @@ public function firstOrNew(array $attributes) { if (is_null($instance = $this->where($attributes)->first())) { - $instance = $this->related->newInstance(); + $instance = $this->related->newInstance($attributes); } return $instance;
false
Other
laravel
framework
0b94f5c6df65b31d0cd238b8ebe17554a0131290.json
Fix MorphOneOrMany::firstOrNew logic
src/Illuminate/Database/Eloquent/Relations/MorphOneOrMany.php
@@ -125,7 +125,7 @@ public function firstOrNew(array $attributes) { if (is_null($instance = $this->where($attributes)->first())) { - $instance = $this->related->newInstance(); + $instance = $this->related->newInstance($attributes); // When saving a polymorphic relationship, we need to set not only the foreign // key, but also the foreign key type, which is typically the class name of
true
Other
laravel
framework
0b94f5c6df65b31d0cd238b8ebe17554a0131290.json
Fix MorphOneOrMany::firstOrNew logic
tests/Database/DatabaseEloquentMorphTest.php
@@ -110,7 +110,7 @@ public function testFirstOrNewMethodReturnsNewModelWithMorphKeysSet() $relation = $this->getOneRelation(); $relation->getQuery()->shouldReceive('where')->once()->with(array('foo'))->andReturn($relation->getQuery()); $relation->getQuery()->shouldReceive('first')->once()->with()->andReturn(null); - $relation->getRelated()->shouldReceive('newInstance')->once()->with()->andReturn($model = m::mock('Illuminate\Database\Eloquent\Model')); + $relation->getRelated()->shouldReceive('newInstance')->once()->with(array('foo'))->andReturn($model = m::mock('Illuminate\Database\Eloquent\Model')); $model->shouldReceive('setAttribute')->once()->with('morph_id', 1); $model->shouldReceive('setAttribute')->once()->with('morph_type', get_class($relation->getParent())); $model->shouldReceive('save')->never(); @@ -161,7 +161,7 @@ public function testUpdateOrCreateMethodCreatesNewMorphModel() $relation = $this->getOneRelation(); $relation->getQuery()->shouldReceive('where')->once()->with(array('foo'))->andReturn($relation->getQuery()); $relation->getQuery()->shouldReceive('first')->once()->with()->andReturn(null); - $relation->getRelated()->shouldReceive('newInstance')->once()->with()->andReturn($model = m::mock('Illuminate\Database\Eloquent\Model')); + $relation->getRelated()->shouldReceive('newInstance')->once()->with(array('foo'))->andReturn($model = m::mock('Illuminate\Database\Eloquent\Model')); $model->shouldReceive('setAttribute')->once()->with('morph_id', 1); $model->shouldReceive('setAttribute')->once()->with('morph_type', get_class($relation->getParent())); $model->shouldReceive('save')->once()->andReturn(true);
true
Other
laravel
framework
6641ac81c635afc34111dc74e20319e62198f542.json
Add route callable test
tests/Routing/RoutingRouteTest.php
@@ -79,6 +79,10 @@ public function testBasicDispatchingOfRoutes() $router = $this->getRouter(); $router->get('foo/bar/åαф', function() { return 'hello'; }); $this->assertEquals('hello', $router->dispatch(Request::create('foo/bar/%C3%A5%CE%B1%D1%84', 'GET'))->getContent()); + + $router = $this->getRouter(); + $router->get('foo/bar', ['boom' => 'auth', function() { return 'closure'; }]); + $this->assertEquals('closure', $router->dispatch(Request::create('foo/bar', 'GET'))->getContent()); }
false
Other
laravel
framework
81b73380617307adb055c1ac2062da22b2007e8d.json
Use php 7 random_bytes if available
src/Illuminate/Support/Str.php
@@ -213,12 +213,18 @@ public static function plural($value, $count = 2) */ public static function random($length = 16) { - if ( ! function_exists('openssl_random_pseudo_bytes')) + if (function_exists('random_bytes')) { - throw new RuntimeException('OpenSSL extension is required.'); + $bytes = random_bytes($length * 2); + } + elseif (function_exists('openssl_random_pseudo_bytes')) + { + $bytes = openssl_random_pseudo_bytes($length * 2); + } + else + { + throw new RuntimeException('OpenSSL extension is required for PHP 5 users.'); } - - $bytes = openssl_random_pseudo_bytes($length * 2); if ($bytes === false) {
false
Other
laravel
framework
e057f68d5f3672ab4b63cc58b1c2d6ffd7adc4e6.json
fix method name.
src/Illuminate/Foundation/Auth/ResetsPasswords.php
@@ -89,7 +89,7 @@ public function postReset(Request $request) $response = Password::reset($credentials, function($user, $password) { - $this->passwordReset($user, $password); + $this->resetPassword($user, $password); }); switch ($response) @@ -105,12 +105,13 @@ public function postReset(Request $request) } /** - * Actually reset user's password + * Reset the given user's password. * * @param \Illuminate\Contracts\Auth\CanResetPassword $user * @param string $password + * @return void */ - protected function passwordReset($user, $password) + protected function resetPassword($user, $password) { $user->password = bcrypt($password);
false
Other
laravel
framework
6f4ca0ab18290f55edcba9ae16496af2dcd97b86.json
Allow specification of queue and delay.
src/Illuminate/Bus/Dispatcher.php
@@ -254,10 +254,34 @@ public function dispatchToQueue($command) } else { - $queue->push($command); + $this->pushCommandToQueue($queue, $command); } } + /** + * Push the command onto the given queue instance. + * + * @param \Illuminate\Contracts\Queue\Queue $queue + * @param mixed $command + * @return void + */ + protected function pushCommandToQueue($queue, $command) + { + if (isset($command->queue) && isset($command->delay)) { + return $queue->laterOn($command->queue, $command->delay, $command); + } + + if (isset($command->queue)) { + return $queue->pushOn($command->queue, $command); + } + + if (isset($command->delay)) { + return $queue->later($command->delay, $command); + } + + $queue->push($command); + } + /** * Get the handler instance for the given command. *
true
Other
laravel
framework
6f4ca0ab18290f55edcba9ae16496af2dcd97b86.json
Allow specification of queue and delay.
tests/Bus/BusDispatcherTest.php
@@ -52,6 +52,19 @@ public function testCommandsThatShouldBeQueuedAreQueuedUsingCustomHandler() } + public function testCommandsThatShouldBeQueuedAreQueuedUsingCustomQueueAndDelay() + { + $container = new Container; + $dispatcher = new Dispatcher($container, function() { + $mock = m::mock('Illuminate\Contracts\Queue\Queue'); + $mock->shouldReceive('laterOn')->once()->with('foo', 10, m::type('BusDispatcherTestSpecificQueueAndDelayCommand')); + return $mock; + }); + + $dispatcher->dispatch(new BusDispatcherTestSpecificQueueAndDelayCommand); + } + + public function testHandlersThatShouldBeQueuedAreQueued() { $container = new Container; @@ -150,3 +163,8 @@ public function queue($queue, $command) $queue->push($command); } } + +class BusDispatcherTestSpecificQueueAndDelayCommand implements Illuminate\Contracts\Queue\ShouldBeQueued { + public $queue = 'foo'; + public $delay = 10; +}
true
Other
laravel
framework
fab6b0a6410158eee1d9b8939464441eea5488aa.json
Change trait name.
src/Illuminate/Foundation/Bus/DispatchesCommands.php
@@ -2,6 +2,9 @@ use ArrayAccess; +/** + * This trait is deprecated. Use the DispatchesJobs trait. + */ trait DispatchesCommands { /**
true
Other
laravel
framework
fab6b0a6410158eee1d9b8939464441eea5488aa.json
Change trait name.
src/Illuminate/Foundation/Bus/DispatchesJobs.php
@@ -0,0 +1,43 @@ +<?php namespace Illuminate\Foundation\Bus; + +use ArrayAccess; + +trait DispatchesJobs { + + /** + * Dispatch a job to its appropriate handler. + * + * @param mixed $job + * @return mixed + */ + protected function dispatch($job) + { + return app('Illuminate\Contracts\Bus\Dispatcher')->dispatch($job); + } + + /** + * Marshal a job and dispatch it to its appropriate handler. + * + * @param mixed $job + * @param array $array + * @return mixed + */ + protected function dispatchFromArray($job, array $array) + { + return app('Illuminate\Contracts\Bus\Dispatcher')->dispatchFromArray($job, $array); + } + + /** + * Marshal a job and dispatch it to its appropriate handler. + * + * @param mixed $job + * @param \ArrayAccess $source + * @param array $extras + * @return mixed + */ + protected function dispatchFrom($job, ArrayAccess $source, $extras = []) + { + return app('Illuminate\Contracts\Bus\Dispatcher')->dispatchFrom($job, $source, $extras); + } + +}
true
Other
laravel
framework
f75dd781e2f174e936cf900f1ebf601631c3ab5a.json
Allow easily mocking of expected jobs.
src/Illuminate/Foundation/Testing/ApplicationTrait.php
@@ -87,6 +87,32 @@ protected function withoutEvents() return $this; } + /** + * Specify a list of jobs that should be dispatched for the given operation. + * + * These jobs will be mocked, so that handlers will not actually be executed. + * + * @param array|dynamic $jobs + * @return $this + */ + protected function expectsJobs($jobs) + { + $jobs = is_array($jobs) ? $jobs : func_get_args(); + + $mock = Mockery::mock('Illuminate\Bus\Dispatcher[dispatch]', [$this->app]); + + foreach ($jobs as $job) { + $mock->shouldReceive('dispatch')->atLeast()->once() + ->with(Mockery::type($job)); + } + + $this->app->instance( + 'Illuminate\Contracts\Bus\Dispatcher', $mock + ); + + return $this; + } + /** * Set the session to the given array. *
false
Other
laravel
framework
90779e6318a7e115d19416da17f1440194d66f59.json
Remove unused code
src/Illuminate/Auth/Passwords/DatabaseTokenRepository.php
@@ -66,7 +66,7 @@ public function create(CanResetPasswordContract $user) // We will create a new, random token for the user so that we can e-mail them // a safe link to the password reset form. Then we will insert a record in // the database so that we can verify the token within the actual reset. - $token = $this->createNewToken($user); + $token = $this->createNewToken(); $this->getTable()->insert($this->getPayload($email, $token)); @@ -161,10 +161,9 @@ public function deleteExpired() /** * Create a new token for the user. * - * @param \Illuminate\Contracts\Auth\CanResetPassword $user * @return string */ - public function createNewToken(CanResetPasswordContract $user) + public function createNewToken() { return hash_hmac('sha256', str_random(40), $this->hashKey); }
false
Other
laravel
framework
181810cfdacdc50d47a80eb88ae441b38ae16dc8.json
Add withSession helper.
src/Illuminate/Foundation/Testing/ApplicationTrait.php
@@ -87,6 +87,19 @@ protected function withoutEvents() return $this; } + /** + * Set the session to the given array. + * + * @param array $data + * @return void + */ + public function withSession(array $data) + { + $this->session($data); + + return $this; + } + /** * Set the session to the given array. *
false
Other
laravel
framework
aa0d0ac1fd87ded7095c34c0c4c63a93459022f5.json
Fix wrong contribution.
src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php
@@ -45,7 +45,7 @@ public function __construct(Resolver $resolver, $table) */ public function getRan() { - return $this->table()->orderBy('migration', 'asc')->lists('migration'); + return $this->table()->lists('migration'); } /**
true
Other
laravel
framework
aa0d0ac1fd87ded7095c34c0c4c63a93459022f5.json
Fix wrong contribution.
tests/Database/DatabaseMigrationRepositoryTest.php
@@ -18,7 +18,6 @@ public function testGetRanMigrationsListMigrationsByPackage() $connectionMock = m::mock('Illuminate\Database\Connection'); $repo->getConnectionResolver()->shouldReceive('connection')->with(null)->andReturn($connectionMock); $repo->getConnection()->shouldReceive('table')->once()->with('migrations')->andReturn($query); - $query->shouldReceive('orderBy')->once()->with('migration', 'asc')->andReturn($query); $query->shouldReceive('lists')->once()->with('migration')->andReturn('bar'); $this->assertEquals('bar', $repo->getRan());
true
Other
laravel
framework
0fdd6241f236508d24b3c09d11d054056b45254f.json
Make an Eloquent collection.
src/Illuminate/Database/Eloquent/FactoryBuilder.php
@@ -104,7 +104,7 @@ public function make(array $attributes = array()) $results[] = $this->makeInstance($attributes); } - return collect($results); + return new Collection($results); } }
false
Other
laravel
framework
a8be30e6411cdfe97d13abd497cc267ba911aae7.json
Add expectEvents method.
src/Illuminate/Foundation/Testing/ApplicationTrait.php
@@ -31,6 +31,32 @@ protected function refreshApplication() $this->app = $this->createApplication(); } + /** + * Specify a list of events that should be fired for the given operation. + * + * These events will be mocked, so that handlers will not actually be executed. + * + * @param array|dynamic $events + * @return $this + */ + public function expectEvents($events) + { + $events = is_array($events) ? $events : func_get_args(); + + $mock = Mockery::mock('Illuminate\Contracts\Events\Dispatcher'); + + $mock->shouldIgnoreMissing(); + + foreach ($events as $event) { + $mock->shouldReceive('fire')->atLeast()->once() + ->with(Mockery::type($event), [], false); + } + + $this->app->instance('events', $mock); + + return $this; + } + /** * Mock the event dispatcher so all events are silenced. *
false
Other
laravel
framework
cbda6e1d86b57751ee7dab99ee1d4c32d4abd32a.json
Remove un-used classes from import.
src/Illuminate/Foundation/Testing/ApplicationTrait.php
@@ -1,11 +1,6 @@ <?php namespace Illuminate\Foundation\Testing; -use Illuminate\Http\Request; -use InvalidArgumentException; -use Symfony\Component\DomCrawler\Form; -use Symfony\Component\DomCrawler\Crawler; use Illuminate\Contracts\Auth\Authenticatable as UserContract; -use PHPUnit_Framework_ExpectationFailedException as PHPUnitException; trait ApplicationTrait {
false
Other
laravel
framework
8efd39e5b6d5e74928a40709ee54d7ef3c591b89.json
Commit application trait.
src/Illuminate/Foundation/Testing/ApplicationTrait.php
@@ -0,0 +1,111 @@ +<?php namespace Illuminate\Foundation\Testing; + +use Illuminate\Http\Request; +use InvalidArgumentException; +use Symfony\Component\DomCrawler\Form; +use Symfony\Component\DomCrawler\Crawler; +use Illuminate\Contracts\Auth\Authenticatable as UserContract; +use PHPUnit_Framework_ExpectationFailedException as PHPUnitException; + +trait ApplicationTrait +{ + /** + * The Illuminate application instance. + * + * @var \Illuminate\Foundation\Application + */ + protected $app; + + /** + * The last code returned by Artisan CLI. + * + * @var int + */ + protected $code; + + /** + * Refresh the application instance. + * + * @return void + */ + protected function refreshApplication() + { + putenv('APP_ENV=testing'); + + $this->app = $this->createApplication(); + } + + /** + * Set the session to the given array. + * + * @param array $data + * @return void + */ + public function session(array $data) + { + $this->startSession(); + + foreach ($data as $key => $value) { + $this->app['session']->put($key, $value); + } + } + + /** + * Start the session for the application. + * + * @return void + */ + protected function startSession() + { + if (! $this->app['session']->isStarted()) { + $this->app['session']->start(); + } + } + + /** + * Flush all of the current session data. + * + * @return void + */ + public function flushSession() + { + $this->startSession(); + + $this->app['session']->flush(); + } + + /** + * Set the currently logged in user for the application. + * + * @param \Illuminate\Contracts\Auth\Authenticatable $user + * @param string $driver + * @return void + */ + public function be(UserContract $user, $driver = null) + { + $this->app['auth']->driver($driver)->setUser($user); + } + + /** + * Seed a given database connection. + * + * @param string $class + * @return void + */ + public function seed($class = 'DatabaseSeeder') + { + $this->artisan('db:seed', ['--class' => $class]); + } + + /** + * Call artisan command and return code. + * + * @param string $command + * @param array $parameters + * @return int + */ + public function artisan($command, $parameters = []) + { + return $this->code = $this->app['Illuminate\Contracts\Console\Kernel']->call($command, $parameters); + } +}
false
Other
laravel
framework
2eed3b634937971edaf6df41c66bb799e3a7961a.json
Break crawler logic into Crawler trait.
src/Illuminate/Foundation/Testing/CrawlerTrait.php
@@ -4,32 +4,17 @@ use InvalidArgumentException; use Symfony\Component\DomCrawler\Form; use Symfony\Component\DomCrawler\Crawler; -use Illuminate\Contracts\Auth\Authenticatable as UserContract; use PHPUnit_Framework_ExpectationFailedException as PHPUnitException; -trait ApplicationTrait +trait CrawlerTrait { - /** - * The Illuminate application instance. - * - * @var \Illuminate\Foundation\Application - */ - protected $app; - /** * The last response returned by the application. * * @var \Illuminate\Http\Response */ protected $response; - /** - * The last code returned by artisan cli. - * - * @var int - */ - protected $code; - /** * The DomCrawler instance. * @@ -51,18 +36,6 @@ trait ApplicationTrait */ protected $inputs = []; - /** - * Refresh the application instance. - * - * @return void - */ - protected function refreshApplication() - { - putenv('APP_ENV=testing'); - - $this->app = $this->createApplication(); - } - /** * Visit the given URI with a GET request. * @@ -648,78 +621,4 @@ public function withoutMiddleware() return $this; } - - /** - * Set the session to the given array. - * - * @param array $data - * @return void - */ - public function session(array $data) - { - $this->startSession(); - - foreach ($data as $key => $value) { - $this->app['session']->put($key, $value); - } - } - - /** - * Start the session for the application. - * - * @return void - */ - protected function startSession() - { - if (! $this->app['session']->isStarted()) { - $this->app['session']->start(); - } - } - - /** - * Flush all of the current session data. - * - * @return void - */ - public function flushSession() - { - $this->startSession(); - - $this->app['session']->flush(); - } - - /** - * Set the currently logged in user for the application. - * - * @param \Illuminate\Contracts\Auth\Authenticatable $user - * @param string $driver - * @return void - */ - public function be(UserContract $user, $driver = null) - { - $this->app['auth']->driver($driver)->setUser($user); - } - - /** - * Seed a given database connection. - * - * @param string $class - * @return void - */ - public function seed($class = 'DatabaseSeeder') - { - $this->artisan('db:seed', ['--class' => $class]); - } - - /** - * Call artisan command and return code. - * - * @param string $command - * @param array $parameters - * @return int - */ - public function artisan($command, $parameters = []) - { - return $this->code = $this->app['Illuminate\Contracts\Console\Kernel']->call($command, $parameters); - } }
true
Other
laravel
framework
2eed3b634937971edaf6df41c66bb799e3a7961a.json
Break crawler logic into Crawler trait.
src/Illuminate/Foundation/Testing/TestCase.php
@@ -5,7 +5,7 @@ abstract class TestCase extends PHPUnit_Framework_TestCase { - use ApplicationTrait, AssertionsTrait; + use ApplicationTrait, AssertionsTrait, CrawlerTrait; /** * The callbacks that should be run before the application is destroyed.
true
Other
laravel
framework
a4ec4a183492b351ee1e67c2902dbe8c2b1a98a2.json
Fix method name.
src/Illuminate/Foundation/Testing/ApplicationTrait.php
@@ -116,6 +116,18 @@ public function route($method, $name, $routeParameters = [], $parameters = [], $ return $this->response = $this->call($method, $uri, $parameters, $cookies, $files, $server, $content); } + /** + * Disable middleware for the test. + * + * @return $this + */ + public function withoutMiddleware() + { + $this->app->instance('middleware.disable', true); + + return $this; + } + /** * Set the session to the given array. *
true
Other
laravel
framework
a4ec4a183492b351ee1e67c2902dbe8c2b1a98a2.json
Fix method name.
src/Illuminate/Foundation/Testing/WithoutMiddleware.php
@@ -0,0 +1,18 @@ +<?php namespace Illuminate\Foundation\Testing; + +use Exception; + +trait WithoutMiddleware +{ + /** + * @before + */ + public function disableMiddlewareForAllTests() + { + if (method_exists($this, 'withoutMiddleware')) { + $this->withoutMiddleware(); + } else { + throw new Exception("Unable to disable middleware. ApplicationTrait not used."); + } + } +}
true
Other
laravel
framework
0f67cf19abc74ba5ee2bdc9c946b2bf62d85149c.json
Allow disabling of middleware (for test reasons).
src/Illuminate/Foundation/Http/Kernel.php
@@ -111,9 +111,12 @@ protected function sendRequestThroughRouter($request) $this->verifySessionConfigurationIsValid(); + $shouldSkipMiddleware = $this->app->bound('middleware.disable') && + $this->app->make('middleware.disable') === true; + return (new Pipeline($this->app)) ->send($request) - ->through($this->middleware) + ->through($shouldSkipMiddleware ? [] : $this->middleware) ->then($this->dispatchToRouter()); }
true
Other
laravel
framework
0f67cf19abc74ba5ee2bdc9c946b2bf62d85149c.json
Allow disabling of middleware (for test reasons).
src/Illuminate/Routing/ControllerDispatcher.php
@@ -96,12 +96,15 @@ protected function callWithinStack($instance, $route, $request, $method) { $middleware = $this->getMiddleware($instance, $method); + $shouldSkipMiddleware = $this->container->bound('middleware.disable') && + $this->container->make('middleware.disable') === true; + // Here we will make a stack onion instance to execute this request in, which gives // us the ability to define middlewares on controllers. We will return the given // response back out so that "after" filters can be run after the middlewares. return (new Pipeline($this->container)) ->send($request) - ->through($middleware) + ->through($shouldSkipMiddleware ? [] : $middleware) ->then(function($request) use ($instance, $route, $method) { return $this->router->prepareResponse(
true
Other
laravel
framework
0f67cf19abc74ba5ee2bdc9c946b2bf62d85149c.json
Allow disabling of middleware (for test reasons).
src/Illuminate/Routing/Router.php
@@ -691,9 +691,12 @@ protected function runRouteWithinStack(Route $route, Request $request) { $middleware = $this->gatherRouteMiddlewares($route); + $shouldSkipMiddleware = $this->container->bound('middleware.disable') && + $this->container->make('middleware.disable') === true; + return (new Pipeline($this->container)) ->send($request) - ->through($middleware) + ->through($shouldSkipMiddleware ? [] : $middleware) ->then(function($request) use ($route) { return $this->prepareResponse(
true
Other
laravel
framework
55f7981c51a658bcdfb3ab66b1a3c63998fc998e.json
Simplify resets password trait.
src/Illuminate/Foundation/Auth/ResetsPasswords.php
@@ -2,26 +2,12 @@ use Illuminate\Http\Request; use Illuminate\Mail\Message; -use Illuminate\Contracts\Auth\Guard; -use Illuminate\Contracts\Auth\PasswordBroker; +use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Password; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; trait ResetsPasswords { - /** - * The Guard implementation. - * - * @var Guard - */ - protected $auth; - - /** - * The password broker implementation. - * - * @var PasswordBroker - */ - protected $passwords; - /** * Display the form to request a password reset link. * @@ -42,17 +28,17 @@ public function postEmail(Request $request) { $this->validate($request, ['email' => 'required|email']); - $response = $this->passwords->sendResetLink($request->only('email'), function(Message $message) + $response = Password::sendResetLink($request->only('email'), function(Message $message) { $message->subject($this->getEmailSubject()); }); switch ($response) { - case PasswordBroker::RESET_LINK_SENT: + case Password::RESET_LINK_SENT: return redirect()->back()->with('status', trans($response)); - case PasswordBroker::INVALID_USER: + case Password::INVALID_USER: return redirect()->back()->withErrors(['email' => trans($response)]); } } @@ -101,18 +87,18 @@ public function postReset(Request $request) 'email', 'password', 'password_confirmation', 'token' ); - $response = $this->passwords->reset($credentials, function($user, $password) + $response = Password::reset($credentials, function($user, $password) { $user->password = bcrypt($password); $user->save(); - $this->auth->login($user); + Auth::login($user); }); switch ($response) { - case PasswordBroker::PASSWORD_RESET: + case Password::PASSWORD_RESET: return redirect($this->redirectPath()); default:
false
Other
laravel
framework
5c77de1cc2ea9ecfbcf77c53643aabc3e1ca6da3.json
Add support for broadcastAs.
src/Illuminate/Broadcasting/BroadcastEvent.php
@@ -39,8 +39,11 @@ public function fire(Job $job, array $data) { $event = unserialize($data['event']); + $name = method_exists($event, 'broadcastAs') + ? $event->broadcastAs() : get_class($event); + $this->broadcaster->broadcast( - $event->broadcastOn(), get_class($event), $this->getPayloadFromEvent($event) + $event->broadcastOn(), $name, $this->getPayloadFromEvent($event) ); $job->delete();
false
Other
laravel
framework
791dcdbf9c250ad064cad5264bf29069406cfc5d.json
Remove Echo :)
src/Illuminate/Redis/Database.php
@@ -116,7 +116,6 @@ public function subscribe($channels, Closure $callback, $connection = null, $met call_user_func_array([$loop, $method], (array) $channels); foreach ($loop as $message) { - echo $message->kind.PHP_EOL; if ($message->kind === 'message' || $message->kind === 'pmessage') { call_user_func($callback, $message->payload, $message->channel); }
false
Other
laravel
framework
5b03efd7958274b43b3a41811f94025ec77843a0.json
Unserialize the data key within the data parameter The serialized job information is held within the data parameter's 'data' key, not the parameter itself.
src/Illuminate/Events/CallQueuedHandler.php
@@ -75,7 +75,7 @@ public function failed(array $data) if (method_exists($handler, 'failed')) { - call_user_func_array([$handler, 'failed'], unserialize($data)); + call_user_func_array([$handler, 'failed'], unserialize($data['data'])); } }
false
Other
laravel
framework
fa36872d817112c72d96ad5d5f45c901d262fe5f.json
Filter public properties
src/Illuminate/Broadcasting/BroadcastEvent.php
@@ -2,6 +2,7 @@ use Pusher; use ReflectionClass; +use ReflectionProperty; use Illuminate\Contracts\Queue\Job; use Illuminate\Contracts\Support\Arrayable; use Illuminate\Contracts\Broadcasting\Broadcaster; @@ -59,10 +60,8 @@ protected function getPayloadFromEvent($event) $payload = []; - foreach ((new ReflectionClass($event))->getProperties() as $property) { - if ($property->isPublic()) { - $payload[$property->getName()] = $this->formatProperty($property->getValue($event)); - } + foreach ((new ReflectionClass($event))->getProperties(ReflectionProperty::IS_PUBLIC) as $property) { + $payload[$property->getName()] = $this->formatProperty($property->getValue($event)); } return $payload;
false
Other
laravel
framework
becb439ce4a85e54979feff29886276ad180c232.json
Add support for easy SUBSCRIBE.
src/Illuminate/Redis/Database.php
@@ -106,23 +106,38 @@ public function command($method, array $parameters = array()) * @param array|string $channels * @param \Closure $callback * @param string $connection + * @param string $method * @return void */ - public function subscribe($channels, Closure $callback, $connection = null) + public function subscribe($channels, Closure $callback, $connection = null, $method = 'subscribe') { $loop = $this->connection($connection)->pubSubLoop(); - call_user_func_array([$loop, 'subscribe'], (array) $channels); + call_user_func_array([$loop, $method], (array) $channels); foreach ($loop as $message) { - if ($message->kind === 'message') { + echo $message->kind.PHP_EOL; + if ($message->kind === 'message' || $message->kind === 'pmessage') { call_user_func($callback, $message->payload, $message->channel); } } unset($loop); } + /** + * Subscribe to a set of given channels with wildcards. + * + * @param array|string $channels + * @param \Closure $callback + * @param string $connection + * @return void + */ + public function psubscribe($channels, Closure $callback, $connection = null) + { + return $this->subscribe($channels, $callback, $connection, __FUNCTION__); + } + /** * Dynamically make a Redis command. *
false
Other
laravel
framework
fcf13f69ae2b6331b6780e495fe09cf88ebedc6d.json
Pass exception variable.
src/Illuminate/Foundation/Exceptions/Handler.php
@@ -117,7 +117,7 @@ protected function renderHttpException(HttpException $e) if (view()->exists("errors.{$status}")) { - return response()->view("errors.{$status}", ['e' => $e], $status); + return response()->view("errors.{$status}", ['exception' => $e], $status); } else {
false
Other
laravel
framework
a021cf29b8cfdceb28b37e36425acf8067297eae.json
Pass Exception object to view Sometimes when making a custom error view you'd like to be able to show the very error message thrown by the framework. Or sometimes you yourself break the application with a App::abort(404, 'User not found'), rather than just a default 404. By passing the Exception object, you allow for custom 404's, or 500's to better explain to the user what happened. NB: You can override this very framework handler method in the app Handler class. But that's complicating things too much I think.
src/Illuminate/Foundation/Exceptions/Handler.php
@@ -117,7 +117,7 @@ protected function renderHttpException(HttpException $e) if (view()->exists("errors.{$status}")) { - return response()->view("errors.{$status}", [], $status); + return response()->view("errors.{$status}", ['e' => $e], $status); } else {
false
Other
laravel
framework
378a4bff5f38f670a0c1a5978be523d70b00e0e3.json
Throw exception on Cookie session driver.
src/Illuminate/Session/SessionManager.php
@@ -1,5 +1,6 @@ <?php namespace Illuminate\Session; +use InvalidArgumentException; use Illuminate\Support\Manager; use Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSessionHandler; @@ -33,9 +34,9 @@ protected function createArrayDriver() */ protected function createCookieDriver() { - $lifetime = $this->app['config']['session.lifetime']; - - return $this->buildSession(new CookieSessionHandler($this->app['cookie'], $lifetime)); + throw new InvalidArgumentException( + "The cookie session driver has been removed. Please use an alternative driver." + ); } /**
false
Other
laravel
framework
78c3357578dc83984f82bb88d0c15d23311f3d28.json
Batch insert correction No longer uses the first element to define the values of all inserting records. This was a bug because if one of the parameters was an expression then the same expression value would be inserted for all records. Test included.
src/Illuminate/Database/Query/Grammars/Grammar.php
@@ -624,12 +624,12 @@ public function compileInsert(Builder $query, array $values) $columns = $this->columnize(array_keys(reset($values))); - // We need to build a list of parameter place-holders of values that are bound - // to the query. Each insert should have the exact same amount of parameter - // bindings so we can just go off the first list of values in this array. - $parameters = $this->parameterize(reset($values)); + $value = array(); - $value = array_fill(0, count($values), "($parameters)"); + foreach($values as $record) + { + $value[] = '('.$this->parameterize($record).')'; + } $parameters = implode(', ', $value);
true
Other
laravel
framework
78c3357578dc83984f82bb88d0c15d23311f3d28.json
Batch insert correction No longer uses the first element to define the values of all inserting records. This was a bug because if one of the parameters was an expression then the same expression value would be inserted for all records. Test included.
tests/Database/DatabaseQueryBuilderTest.php
@@ -926,6 +926,15 @@ public function testInsertMethodRespectsRawBindings() } + public function testMultipleInsertsWithExpressionValues() + { + $builder = $this->getBuilder(); + $builder->getConnection()->shouldReceive('insert')->once()->with('insert into "users" ("email") values (UPPER(\'Foo\')), (LOWER(\'Foo\'))', array())->andReturn(true); + $result = $builder->from('users')->insert(array(array('email' => new Raw("UPPER('Foo')")), array('email' => new Raw("LOWER('Foo')")))); + $this->assertTrue($result); + } + + public function testUpdateMethod() { $builder = $this->getBuilder();
true
Other
laravel
framework
7dca817417ef3db4812814b61e480563bb45cf0d.json
Fix empty morph to relationship
src/Illuminate/Database/Eloquent/Relations/MorphTo.php
@@ -53,6 +53,18 @@ public function __construct(Builder $query, Model $parent, $foreignKey, $otherKe parent::__construct($query, $parent, $foreignKey, $otherKey, $relation); } + /** + * Get the results of the relationship. + * + * @return mixed + */ + public function getResults() + { + if ( ! $this->otherKey) return; + + return $this->query->first(); + } + /** * Set the constraints for an eager load of the relation. *
true
Other
laravel
framework
7dca817417ef3db4812814b61e480563bb45cf0d.json
Fix empty morph to relationship
tests/Database/DatabaseEloquentIntegrationTest.php
@@ -324,6 +324,14 @@ public function testBasicMorphManyRelationship() } + public function testEmptyMorphToRelationship() + { + $photo = EloquentTestPhoto::create(['name' => 'Avatar 1']); + + $this->assertNull($photo->imageable); + } + + public function testMultiInsertsWithDifferentValues() { $date = '1970-01-01';
true
Other
laravel
framework
2e8d837e72375e6c2c1b4cb91cd65bb16dd6e0af.json
Add short-cuts for status and content.
src/Illuminate/Http/ResponseTrait.php
@@ -4,6 +4,26 @@ trait ResponseTrait { + /** + * Get the status code for the response. + * + * @return int + */ + public function status() + { + return $this->getStatusCode(); + } + + /** + * Get the content of the response. + * + * @return string + */ + public function content() + { + return $this->getContent(); + } + /** * Set a header on the Response. *
false
Other
laravel
framework
4fd9aafa15c85a36eb4e61b873ef1188d11a769d.json
Add check for migration table in reset command
src/Illuminate/Database/Console/Migrations/ResetCommand.php
@@ -54,6 +54,13 @@ public function fire() $this->migrator->setConnection($this->input->getOption('database')); + if ( ! $this->migrator->repositoryExists()) + { + $this->output->writeln('<comment>Migration table not found.</comment>'); + + return; + } + $pretend = $this->input->getOption('pretend'); $this->migrator->reset($pretend);
true
Other
laravel
framework
4fd9aafa15c85a36eb4e61b873ef1188d11a769d.json
Add check for migration table in reset command
tests/Database/DatabaseMigrationResetCommandTest.php
@@ -16,6 +16,7 @@ public function testResetCommandCallsMigratorWithProperArguments() $command = new ResetCommand($migrator = m::mock('Illuminate\Database\Migrations\Migrator')); $command->setLaravel(new AppDatabaseMigrationStub()); $migrator->shouldReceive('setConnection')->once()->with(null); + $migrator->shouldReceive('repositoryExists')->once()->andReturn(true); $migrator->shouldReceive('reset')->once()->with(false); $migrator->shouldReceive('getNotes')->andReturn([]); @@ -28,6 +29,7 @@ public function testResetCommandCanBePretended() $command = new ResetCommand($migrator = m::mock('Illuminate\Database\Migrations\Migrator')); $command->setLaravel(new AppDatabaseMigrationStub()); $migrator->shouldReceive('setConnection')->once()->with('foo'); + $migrator->shouldReceive('repositoryExists')->once()->andReturn(true); $migrator->shouldReceive('reset')->once()->with(true); $migrator->shouldReceive('getNotes')->andReturn([]);
true
Other
laravel
framework
81bc3da45d44230ee1cfeab27e9d080df0f41313.json
Tweak some stubs.
src/Illuminate/Foundation/Console/stubs/command-queued-with-handler.stub
@@ -3,9 +3,9 @@ use DummyRootNamespaceCommands\Command; use Illuminate\Queue\SerializesModels; use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Contracts\Queue\ShouldBeQueued; +use Illuminate\Contracts\Queue\ShouldQueue; -class DummyClass extends Command implements ShouldBeQueued +class DummyClass extends Command implements ShouldQueue { use InteractsWithQueue, SerializesModels;
true
Other
laravel
framework
81bc3da45d44230ee1cfeab27e9d080df0f41313.json
Tweak some stubs.
src/Illuminate/Foundation/Console/stubs/command-queued.stub
@@ -4,9 +4,9 @@ use DummyRootNamespaceCommands\Command; use Illuminate\Queue\SerializesModels; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Bus\SelfHandling; -use Illuminate\Contracts\Queue\ShouldBeQueued; +use Illuminate\Contracts\Queue\ShouldQueue; -class DummyClass extends Command implements SelfHandling, ShouldBeQueued +class DummyClass extends Command implements SelfHandling, ShouldQueue { use InteractsWithQueue, SerializesModels;
true
Other
laravel
framework
81bc3da45d44230ee1cfeab27e9d080df0f41313.json
Tweak some stubs.
src/Illuminate/Foundation/Console/stubs/event-handler-queued.stub
@@ -2,9 +2,9 @@ use DummyFullEvent; use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Contracts\Queue\ShouldBeQueued; +use Illuminate\Contracts\Queue\ShouldQueue; -class DummyClass implements ShouldBeQueued +class DummyClass implements ShouldQueue { use InteractsWithQueue;
true
Other
laravel
framework
81bc3da45d44230ee1cfeab27e9d080df0f41313.json
Tweak some stubs.
src/Illuminate/Foundation/Console/stubs/event-handler.stub
@@ -2,7 +2,7 @@ use DummyFullEvent; use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Contracts\Queue\ShouldBeQueued; +use Illuminate\Contracts\Queue\ShouldQueue; class DummyClass {
true
Other
laravel
framework
81bc3da45d44230ee1cfeab27e9d080df0f41313.json
Tweak some stubs.
src/Illuminate/Foundation/Console/stubs/event.stub
@@ -2,6 +2,7 @@ use DummyRootNamespaceEvents\Event; use Illuminate\Queue\SerializesModels; +use Illuminate\Contracts\Broadcasting\ShouldBroadcast; class DummyClass extends Event { @@ -16,4 +17,14 @@ class DummyClass extends Event { // } + + /** + * Get the channels the event should be broadcast on. + * + * @return array + */ + public function broadcastOn() + { + return []; + } }
true
Other
laravel
framework
81bc3da45d44230ee1cfeab27e9d080df0f41313.json
Tweak some stubs.
src/Illuminate/Foundation/Console/stubs/job-queued.stub
@@ -4,9 +4,9 @@ use DummyRootNamespaceJobs\Job; use Illuminate\Queue\SerializesModels; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Bus\SelfHandling; -use Illuminate\Contracts\Queue\ShouldBeQueued; +use Illuminate\Contracts\Queue\ShouldQueue; -class DummyClass extends Job implements SelfHandling, ShouldBeQueued +class DummyClass extends Job implements SelfHandling, ShouldQueue { use InteractsWithQueue, SerializesModels;
true
Other
laravel
framework
81bc3da45d44230ee1cfeab27e9d080df0f41313.json
Tweak some stubs.
src/Illuminate/Foundation/Console/stubs/listener-queued.stub
@@ -2,9 +2,9 @@ use DummyFullEvent; use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Contracts\Queue\ShouldBeQueued; +use Illuminate\Contracts\Queue\ShouldQueue; -class DummyClass implements ShouldBeQueued +class DummyClass implements ShouldQueue { use InteractsWithQueue;
true
Other
laravel
framework
81bc3da45d44230ee1cfeab27e9d080df0f41313.json
Tweak some stubs.
src/Illuminate/Foundation/Console/stubs/listener.stub
@@ -2,7 +2,7 @@ use DummyFullEvent; use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Contracts\Queue\ShouldBeQueued; +use Illuminate\Contracts\Queue\ShouldQueue; class DummyClass {
true
Other
laravel
framework
bb8d3755184246a91b22b270dd61631ae8c27228.json
add typehint and remove no need new line add typehint and remove no need new line
src/Illuminate/Redis/Database.php
@@ -40,7 +40,7 @@ public function __construct(array $servers = array()) * @param array $options * @return array */ - protected function createAggregateClient(array $servers, $options = []) + protected function createAggregateClient(array $servers, array $options = []) { return array('default' => new Client(array_values($servers), $options)); } @@ -52,7 +52,7 @@ protected function createAggregateClient(array $servers, $options = []) * @param array $options * @return array */ - protected function createSingleClients(array $servers, $options = []) + protected function createSingleClients(array $servers, array $options = []) { $clients = array();
true
Other
laravel
framework
bb8d3755184246a91b22b270dd61631ae8c27228.json
add typehint and remove no need new line add typehint and remove no need new line
tests/Redis/RedisConnectionTest.php
@@ -1,6 +1,5 @@ <?php - class RedisConnectionTest extends PHPUnit_Framework_TestCase { public function testRedisNotCreateClusterAndOptionsServer()
true
Other
laravel
framework
fde58c362d2f736040d3601920c711a9ae1555a7.json
Use SymfonyStyle in Command
src/Illuminate/Console/Command.php
@@ -4,6 +4,7 @@ use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\NullOutput; use Symfony\Component\Console\Question\Question; +use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ChoiceQuestion; @@ -29,7 +30,7 @@ class Command extends \Symfony\Component\Console\Command\Command { /** * The output interface implementation. * - * @var \Symfony\Component\Console\Output\OutputInterface + * @var \Symfony\Component\Console\Style\SymfonyStyle */ protected $output; @@ -96,7 +97,7 @@ public function run(InputInterface $input, OutputInterface $output) { $this->input = $input; - $this->output = $output; + $this->output = new SymfonyStyle($input, $output); return parent::run($input, $output); } @@ -182,11 +183,7 @@ public function option($key = null) */ public function confirm($question, $default = false) { - $helper = $this->getHelperSet()->get('question'); - - $question = new ConfirmationQuestion("<question>{$question}</question> ", $default); - - return $helper->ask($this->input, $this->output, $question); + return $this->output->confirm($question, $default); } /** @@ -198,11 +195,7 @@ public function confirm($question, $default = false) */ public function ask($question, $default = null) { - $helper = $this->getHelperSet()->get('question'); - - $question = new Question("<question>$question</question> ", $default); - - return $helper->ask($this->input, $this->output, $question); + return $this->output->ask($question, $default); } /** @@ -215,13 +208,11 @@ public function ask($question, $default = null) */ public function askWithCompletion($question, array $choices, $default = null) { - $helper = $this->getHelperSet()->get('question'); - - $question = new Question("<question>$question</question> ", $default); + $question = new Question($question, $default); $question->setAutocompleterValues($choices); - return $helper->ask($this->input, $this->output, $question); + return $this->output->askQuestion($question); } /** @@ -233,13 +224,11 @@ public function askWithCompletion($question, array $choices, $default = null) */ public function secret($question, $fallback = true) { - $helper = $this->getHelperSet()->get('question'); - - $question = new Question("<question>$question</question> "); + $question = new Question($question); $question->setHidden(true)->setHiddenFallback($fallback); - return $helper->ask($this->input, $this->output, $question); + return $this->output->askQuestion($question); } /** @@ -254,13 +243,11 @@ public function secret($question, $fallback = true) */ public function choice($question, array $choices, $default = null, $attempts = null, $multiple = null) { - $helper = $this->getHelperSet()->get('question'); - - $question = new ChoiceQuestion("<question>$question</question> ", $choices, $default); + $question = new ChoiceQuestion($question, $choices, $default); $question->setMaxAttempts($attempts)->setMultiselect($multiple); - return $helper->ask($this->input, $this->output, $question); + return $this->output->askQuestion($question); } /**
false
Other
laravel
framework
9f9a692f724c538e30701877f9073297856c5763.json
Fix Total Downloads url
readme.md
@@ -1,7 +1,7 @@ ## Laravel Framework (Kernel) [![Build Status](https://travis-ci.org/laravel/framework.svg)](https://travis-ci.org/laravel/framework) -[![Total Downloads](https://poser.pugx.org/laravel/framework/downloads.svg)](https://packagist.org/packages/laravel/framework) +[![Total Downloads](https://poser.pugx.org/laravel/framework/d/total.svg)](https://packagist.org/packages/laravel/framework) [![Latest Stable Version](https://poser.pugx.org/laravel/framework/v/stable.svg)](https://packagist.org/packages/laravel/framework) [![Latest Unstable Version](https://poser.pugx.org/laravel/framework/v/unstable.svg)](https://packagist.org/packages/laravel/framework) [![License](https://poser.pugx.org/laravel/framework/license.svg)](https://packagist.org/packages/laravel/framework)
false
Other
laravel
framework
f1e45c60628da3340afc77b2b425870db7fb60b9.json
Return a collection from lists()
src/Illuminate/Database/Query/Builder.php
@@ -1503,7 +1503,7 @@ public function lists($column, $key = null) $results = new Collection($this->get($columns)); - return $results->lists($columns[0], array_get($columns, 1)); + return $results->lists($columns[0], array_get($columns, 1))->all(); } /**
true
Other
laravel
framework
f1e45c60628da3340afc77b2b425870db7fb60b9.json
Return a collection from lists()
src/Illuminate/Support/Collection.php
@@ -311,7 +311,7 @@ public function implode($value, $glue = null) if (is_array($first) || is_object($first)) { - return implode($glue, $this->lists($value)); + return implode($glue, $this->lists($value)->all()); } return implode($value, $this->items); @@ -374,11 +374,11 @@ public function last() * * @param string $value * @param string $key - * @return array + * @return static */ public function lists($value, $key = null) { - return array_pluck($this->items, $value, $key); + return new static(array_pluck($this->items, $value, $key)); } /**
true
Other
laravel
framework
f1e45c60628da3340afc77b2b425870db7fb60b9.json
Return a collection from lists()
tests/Database/DatabaseEloquentCollectionTest.php
@@ -205,8 +205,8 @@ public function testCollectionReturnsUniqueItems() public function testLists() { $data = new Collection(array((object) array('name' => 'taylor', 'email' => 'foo'), (object) array('name' => 'dayle', 'email' => 'bar'))); - $this->assertEquals(array('taylor' => 'foo', 'dayle' => 'bar'), $data->lists('email', 'name')); - $this->assertEquals(array('foo', 'bar'), $data->lists('email')); + $this->assertEquals(array('taylor' => 'foo', 'dayle' => 'bar'), $data->lists('email', 'name')->all()); + $this->assertEquals(array('foo', 'bar'), $data->lists('email')->all()); }
true
Other
laravel
framework
f1e45c60628da3340afc77b2b425870db7fb60b9.json
Return a collection from lists()
tests/Database/DatabaseEloquentModelTest.php
@@ -559,7 +559,7 @@ public function testPushManyRelation() $this->assertEquals(1, $model->id); $this->assertTrue($model->exists); $this->assertEquals(2, count($model->relationMany)); - $this->assertEquals([2, 3], $model->relationMany->lists('id')); + $this->assertEquals([2, 3], $model->relationMany->lists('id')->all()); }
true
Other
laravel
framework
f1e45c60628da3340afc77b2b425870db7fb60b9.json
Return a collection from lists()
tests/Support/SupportCollectionTest.php
@@ -305,8 +305,8 @@ public function testChunk() public function testListsWithArrayAndObjectValues() { $data = new Collection(array((object) array('name' => 'taylor', 'email' => 'foo'), array('name' => 'dayle', 'email' => 'bar'))); - $this->assertEquals(array('taylor' => 'foo', 'dayle' => 'bar'), $data->lists('email', 'name')); - $this->assertEquals(array('foo', 'bar'), $data->lists('email')); + $this->assertEquals(array('taylor' => 'foo', 'dayle' => 'bar'), $data->lists('email', 'name')->all()); + $this->assertEquals(array('foo', 'bar'), $data->lists('email')->all()); } @@ -317,8 +317,8 @@ public function testListsWithArrayAccessValues() new TestArrayAccessImplementation(array('name' => 'dayle', 'email' => 'bar')) )); - $this->assertEquals(array('taylor' => 'foo', 'dayle' => 'bar'), $data->lists('email', 'name')); - $this->assertEquals(array('foo', 'bar'), $data->lists('email')); + $this->assertEquals(array('taylor' => 'foo', 'dayle' => 'bar'), $data->lists('email', 'name')->all()); + $this->assertEquals(array('foo', 'bar'), $data->lists('email')->all()); } @@ -481,7 +481,7 @@ public function testGetListValueWithAccessors() $modelTwo = new TestAccessorEloquentTestStub(array('some' => 'bar')); $data = new Collection(array($model, $modelTwo)); - $this->assertEquals(array('foo', 'bar'), $data->lists('some')); + $this->assertEquals(array('foo', 'bar'), $data->lists('some')->all()); } @@ -603,7 +603,7 @@ public function testValueRetrieverAcceptsDotNotation() )); $c = $c->sortBy('foo.bar'); - $this->assertEquals(array(2, 1), $c->lists('id')); + $this->assertEquals(array(2, 1), $c->lists('id')->all()); }
true
Other
laravel
framework
588f28290c0c4b7948d8ec69d1c7611a99258f2b.json
Add support for parameters to middleware
src/Illuminate/Pipeline/Pipeline.php
@@ -121,8 +121,10 @@ protected function getSlice() } else { - return $this->container->make($pipe) - ->{$this->method}($passable, $stack); + list($name, $parameters) = $this->parsePipeString($pipe); + + return call_user_func_array([$this->container->make($name), $this->method], + array_merge([$passable, $stack], $parameters)); } }; }; @@ -142,4 +144,22 @@ protected function getInitialSlice(Closure $destination) }; } + /** + * Parse full pipe string to get name and parameters + * + * @param string $pipe + * @return array + */ + protected function parsePipeString($pipe) + { + list($name, $parameters) = array_pad(explode(':', $pipe, 2), 2, []); + + if (is_string($parameters)) + { + $parameters = explode(',', $parameters); + } + + return [$name, $parameters]; + } + }
true
Other
laravel
framework
588f28290c0c4b7948d8ec69d1c7611a99258f2b.json
Add support for parameters to middleware
src/Illuminate/Routing/ControllerDispatcher.php
@@ -117,15 +117,13 @@ protected function callWithinStack($instance, $route, $request, $method) */ protected function getMiddleware($instance, $method) { - $middleware = $this->router->getMiddleware(); - $results = []; foreach ($instance->getMiddleware() as $name => $options) { if ( ! $this->methodExcludedByOptions($method, $options)) { - $results[] = array_get($middleware, $name, $name); + $results[] = $this->router->resolveMiddlewareClassName($name); } }
true
Other
laravel
framework
588f28290c0c4b7948d8ec69d1c7611a99258f2b.json
Add support for parameters to middleware
src/Illuminate/Routing/Router.php
@@ -711,11 +711,26 @@ protected function runRouteWithinStack(Route $route, Request $request) */ public function gatherRouteMiddlewares(Route $route) { - return Collection::make($route->middleware())->map(function($m) + return Collection::make($route->middleware())->map(function($name) { - return Collection::make(array_get($this->middleware, $m, $m)); + return Collection::make($this->resolveMiddlewareClassName($name)); + }) + ->collapse()->all(); + } + + /** + * Resolve the middleware name to a class name preserving passed parameters + * + * @param $name + * @return string + */ + public function resolveMiddlewareClassName($name) + { + $map = $this->middleware; + + list($name, $parameters) = array_pad(explode(':', $name, 2), 2, null); - })->collapse()->all(); + return array_get($map, $name, $name).($parameters ? ':'.$parameters : ''); } /**
true
Other
laravel
framework
588f28290c0c4b7948d8ec69d1c7611a99258f2b.json
Add support for parameters to middleware
tests/Pipeline/PipelineTest.php
@@ -26,6 +26,23 @@ public function testPipelineBasicUsage() unset($_SERVER['__test.pipe.two']); } + public function testPipelineUsageWithParameters() + { + $parameters = ['one','two']; + + $result = (new Pipeline(new Illuminate\Container\Container)) + ->send('foo') + ->through('PipelineTestParameterPipe:'.implode(',', $parameters)) + ->then(function($piped) { + return $piped; + }); + + $this->assertEquals('foo', $result); + $this->assertEquals($parameters, $_SERVER['__test.pipe.parameters']); + + unset($_SERVER['__test.pipe.parameters']); + } + } class PipelineTestPipeOne { @@ -34,3 +51,11 @@ public function handle($piped, $next) { return $next($piped); } } + +class PipelineTestParameterPipe { + public function handle($piped, $next, $parameter1 = null, $parameter2 = null) + { + $_SERVER['__test.pipe.parameters'] = [$parameter1, $parameter2]; + return $next($piped); + } +}
true
Other
laravel
framework
588f28290c0c4b7948d8ec69d1c7611a99258f2b.json
Add support for parameters to middleware
tests/Routing/RoutingRouteTest.php
@@ -804,7 +804,8 @@ public function testControllerRouting() { unset( $_SERVER['route.test.controller.before.filter'], $_SERVER['route.test.controller.after.filter'], - $_SERVER['route.test.controller.middleware'], $_SERVER['route.test.controller.except.middleware'] + $_SERVER['route.test.controller.middleware'], $_SERVER['route.test.controller.except.middleware'], + $_SERVER['route.test.controller.middleware.parameters'] ); $router = new Router(new Illuminate\Events\Dispatcher, $container = new Illuminate\Container\Container); $router->filter('route.test.controller.before.filter', function() @@ -825,6 +826,7 @@ public function testControllerRouting() $this->assertTrue($_SERVER['route.test.controller.before.filter']); $this->assertTrue($_SERVER['route.test.controller.after.filter']); $this->assertTrue($_SERVER['route.test.controller.middleware']); + $this->assertEquals(['foo', 'bar'], $_SERVER['route.test.controller.middleware.parameters']); $this->assertFalse(isset($_SERVER['route.test.controller.except.middleware'])); } @@ -848,6 +850,7 @@ class RouteTestControllerStub extends Illuminate\Routing\Controller { public function __construct() { $this->middleware('RouteTestControllerMiddleware'); + $this->middleware('RouteTestControllerParameterizedMiddleware:foo,bar'); $this->middleware('RouteTestControllerExceptMiddleware', ['except' => 'index']); $this->beforeFilter('route.test.controller.before.filter'); $this->afterFilter('route.test.controller.after.filter'); @@ -866,6 +869,14 @@ public function handle($request, $next) } } +class RouteTestControllerParameterizedMiddleware { + public function handle($request, $next, $parameter1, $parameter2) + { + $_SERVER['route.test.controller.middleware.parameters'] = [$parameter1, $parameter2]; + return $next($request); + } +} + class RouteTestInspectedControllerStub extends Illuminate\Routing\Controller { public function getFoo() {
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
composer.json
@@ -98,7 +98,7 @@ } }, "suggest": { - "aws/aws-sdk-php": "Required to use the SQS queue driver (~2.4).", + "aws/aws-sdk-php": "Required to use the SQS queue driver and SES mail driver (~2.4).", "doctrine/dbal": "Required to rename columns and drop SQLite columns (~2.4).", "guzzlehttp/guzzle": "Required to use the Mailgun and Mandrill mail drivers (~5.0).", "iron-io/iron_mq": "Required to use the iron queue driver (~2.0).",
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
readme.md
@@ -22,6 +22,10 @@ Documentation for the framework can be found on the [Laravel website](http://lar Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](http://laravel.com/docs/contributions). +## Security Vulnerabilities + +If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed. + ### License The Laravel framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
src/Illuminate/Database/Connectors/SqlServerConnector.php
@@ -58,9 +58,16 @@ protected function getDsn(array $config) */ protected function getDblibDsn(array $config) { - $port = isset($config['port']) ? ':'.$config['port'] : ''; + $arguments = array( + 'host' => $this->buildHostString($config, ':'), + 'dbname' => $config['database'] + ); - return "dblib:host={$config['host']}{$port};dbname={$config['database']}"; + $arguments = array_merge( + $arguments, array_only($config, ['appname', 'charset']) + ); + + return $this->buildConnectString('dblib', $arguments); } /** @@ -71,11 +78,55 @@ protected function getDblibDsn(array $config) */ protected function getSqlSrvDsn(array $config) { - $port = isset($config['port']) ? ','.$config['port'] : ''; + $arguments = array( + 'Server' => $this->buildHostString($config, ',') + ); + + if (isset($config['database'])) { + $arguments['Database'] = $config['database']; + } + + if (isset($config['appname'])) { + $arguments['APP'] = $config['appname']; + } + + return $this->buildConnectString('sqlsrv', $arguments); + } + + /** + * Build a connection string from the given arguments. + * + * @param string $driver + * @param array $arguments + * @return string + */ + protected function buildConnectString($driver, array $arguments) + { + $options = array_map(function($key) use ($arguments) + { + return sprintf("%s=%s", $key, $arguments[$key]); + }, array_keys($arguments)); - $dbName = $config['database'] != '' ? ";Database={$config['database']}" : ''; + return $driver.":".implode(';', $options); + } - return "sqlsrv:Server={$config['host']}{$port}{$dbName}"; + /** + * Build a host string from the given configuration. + * + * @param array $config + * @param string $separator + * @return string + */ + protected function buildHostString(array $config, $separator) + { + if(isset($config['port'])) + { + return $config['host'].$separator.$config['port']; + } + else + { + return $config['host']; + } } /**
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
src/Illuminate/Database/Eloquent/Model.php
@@ -491,12 +491,12 @@ public static function hydrate(array $items, $connection = null) { $instance = (new static)->setConnection($connection); - $collection = $instance->newCollection($items); - - return $collection->map(function ($item) use ($instance) + $items = array_map(function ($item) use ($instance) { return $instance->newFromBuilder($item); - }); + }, $items); + + return $instance->newCollection($items); } /**
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
src/Illuminate/Database/Eloquent/Relations/BelongsTo.php
@@ -84,13 +84,48 @@ public function addConstraints() */ public function getRelationCountQuery(Builder $query, Builder $parent) { + if ($parent->getQuery()->from == $query->getQuery()->from) + { + return $this->getRelationCountQueryForSelfRelation($query, $parent); + } + $query->select(new Expression('count(*)')); $otherKey = $this->wrap($query->getModel()->getTable().'.'.$this->otherKey); return $query->where($this->getQualifiedForeignKey(), '=', new Expression($otherKey)); } + /** + * Add the constraints for a relationship count query on the same table. + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @param \Illuminate\Database\Eloquent\Builder $parent + * @return \Illuminate\Database\Eloquent\Builder + */ + public function getRelationCountQueryForSelfRelation(Builder $query, Builder $parent) + { + $query->select(new Expression('count(*)')); + + $tablePrefix = $this->query->getQuery()->getConnection()->getTablePrefix(); + + $query->from($query->getModel()->getTable().' as '.$tablePrefix.$hash = $this->getRelationCountHash()); + + $key = $this->wrap($this->getQualifiedForeignKey()); + + return $query->where($hash.'.'.$query->getModel()->getKeyName(), '=', new Expression($key)); + } + + /** + * Get a relationship join table hash. + * + * @return string + */ + public function getRelationCountHash() + { + return 'self_'.md5(microtime(true)); + } + /** * Set the constraints for an eager load of the relation. *
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php
@@ -2,6 +2,7 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Database\Query\Expression; use Illuminate\Database\Eloquent\Collection; abstract class HasOneOrMany extends Relation { @@ -52,6 +53,53 @@ public function addConstraints() } } + /** + * Add the constraints for a relationship count query. + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @param \Illuminate\Database\Eloquent\Builder $parent + * @return \Illuminate\Database\Eloquent\Builder + */ + public function getRelationCountQuery(Builder $query, Builder $parent) + { + if ($parent->getQuery()->from == $query->getQuery()->from) + { + return $this->getRelationCountQueryForSelfRelation($query, $parent); + } + + return parent::getRelationCountQuery($query, $parent); + } + + /** + * Add the constraints for a relationship count query on the same table. + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @param \Illuminate\Database\Eloquent\Builder $parent + * @return \Illuminate\Database\Eloquent\Builder + */ + public function getRelationCountQueryForSelfRelation(Builder $query, Builder $parent) + { + $query->select(new Expression('count(*)')); + + $tablePrefix = $this->query->getQuery()->getConnection()->getTablePrefix(); + + $query->from($query->getModel()->getTable().' as '.$tablePrefix.$hash = $this->getRelationCountHash()); + + $key = $this->wrap($this->getQualifiedParentKeyName()); + + return $query->where($hash.'.'.$this->getPlainForeignKey(), '=', new Expression($key)); + } + + /** + * Get a relationship join table hash. + * + * @return string + */ + public function getRelationCountHash() + { + return 'self_'.md5(microtime(true)); + } + /** * Set the constraints for an eager load of the relation. *
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
src/Illuminate/Database/Query/Builder.php
@@ -421,7 +421,7 @@ public function rightJoinWhere($table, $one, $operator, $two) /** * Add a basic where clause to the query. * - * @param string $column + * @param string|array|\Closure $column * @param string $operator * @param mixed $value * @param string $boolean
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
src/Illuminate/Database/Schema/Blueprint.php
@@ -627,6 +627,17 @@ public function dateTime($column) return $this->addColumn('dateTime', $column); } + /** + * Create a new date-time column (with time zone) on the table. + * + * @param string $column + * @return \Illuminate\Support\Fluent + */ + public function dateTimeTz($column) + { + return $this->addColumn('dateTimeTz', $column); + } + /** * Create a new time column on the table. * @@ -638,6 +649,17 @@ public function time($column) return $this->addColumn('time', $column); } + /** + * Create a new time column (with time zone) on the table. + * + * @param string $column + * @return \Illuminate\Support\Fluent + */ + public function timeTz($column) + { + return $this->addColumn('timeTz', $column); + } + /** * Create a new timestamp column on the table. * @@ -649,6 +671,17 @@ public function timestamp($column) return $this->addColumn('timestamp', $column); } + /** + * Create a new timestamp (with time zone) column on the table. + * + * @param string $column + * @return \Illuminate\Support\Fluent + */ + public function timestampTz($column) + { + return $this->addColumn('timestampTz', $column); + } + /** * Add nullable creation and update timestamps to the table. *
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php
@@ -491,6 +491,17 @@ protected function typeDateTime(Fluent $column) return 'datetime'; } + /** + * Create the column definition for a date-time type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeDateTimeTz(Fluent $column) + { + return 'datetime'; + } + /** * Create the column definition for a time type. * @@ -502,6 +513,17 @@ protected function typeTime(Fluent $column) return 'time'; } + /** + * Create the column definition for a time type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeTimeTz(Fluent $column) + { + return 'time'; + } + /** * Create the column definition for a timestamp type. * @@ -515,6 +537,19 @@ protected function typeTimestamp(Fluent $column) return 'timestamp'; } + /** + * Create the column definition for a timestamp type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeTimestampTz(Fluent $column) + { + if ( ! $column->nullable) return 'timestamp default 0'; + + return 'timestamp'; + } + /** * Create the column definition for a binary type. *
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php
@@ -433,6 +433,17 @@ protected function typeDateTime(Fluent $column) return 'timestamp(0) without time zone'; } + /** + * Create the column definition for a date-time type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeDateTimeTz(Fluent $column) + { + return 'timestamp(0) with time zone'; + } + /** * Create the column definition for a time type. * @@ -444,6 +455,17 @@ protected function typeTime(Fluent $column) return 'time(0) without time zone'; } + /** + * Create the column definition for a time type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeTimeTz(Fluent $column) + { + return 'time(0) with time zone'; + } + /** * Create the column definition for a timestamp type. * @@ -455,6 +477,17 @@ protected function typeTimestamp(Fluent $column) return 'timestamp(0) without time zone'; } + /** + * Create the column definition for a timestamp type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeTimestampTz(Fluent $column) + { + return 'timestamp(0) with time zone'; + } + /** * Create the column definition for a binary type. *
true