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
1b7608c781cd7f61ee7f9fdca182909d397088d1.json
Use Dotenv exception
src/Illuminate/Foundation/Bootstrap/DetectEnvironment.php
@@ -1,6 +1,7 @@ <?php namespace Illuminate\Foundation\Bootstrap; use Dotenv; +use InvalidArgumentException; use Illuminate\Contracts\Foundation\Application; class DetectEnvironment { @@ -13,10 +14,14 @@ class DetectEnvironment { */ public function bootstrap(Application $app) { - if (file_exists($app['path.base'].'/.env')) + try { Dotenv::load($app['path.base']); } + catch (InvalidArgumentException $e) + { + // + } $app->detectEnvironment(function() {
false
Other
laravel
framework
432c93783b1f137b2ab30d0a12e9b37d696c9ab4.json
Add missing tests for files and dir
tests/Filesystem/FilesystemTest.php
@@ -136,4 +136,33 @@ public function testCopyDirectoryMovesEntireDirectory() rmdir(__DIR__.'/tmp2'); } + + public function testGetFiles() + { + mkdir(__DIR__.'/tmp', 0777, true); + file_put_contents(__DIR__.'/tmp/foo.txt', ''); + file_put_contents(__DIR__.'/tmp/bar.txt', ''); + mkdir(__DIR__.'/tmp/nested', 0777, true); + file_put_contents(__DIR__.'/tmp/nested/baz.txt', ''); + + $fileSystem = new Filesystem; + + $directories = [ + __DIR__.'/tmp/nested', + ]; + $this->assertSame($directories, $fileSystem->directories(__DIR__.'/tmp')); + + $files = [ + __DIR__.'/tmp/bar.txt', + __DIR__.'/tmp/foo.txt', + ]; + $this->assertSame($files, $fileSystem->files(__DIR__.'/tmp')); + + unlink(__DIR__.'/tmp/nested/baz.txt'); + rmdir(__DIR__.'/tmp/nested'); + unlink(__DIR__.'/tmp/bar.txt'); + unlink(__DIR__.'/tmp/foo.txt'); + rmdir(__DIR__.'/tmp'); + } + }
false
Other
laravel
framework
0f5c01d88cde71ea16be9893d78ce35f46093ecb.json
Use array_sum instead of default callback
src/Illuminate/Support/Collection.php
@@ -623,7 +623,7 @@ public function sum($callback = null) { if (is_null($callback)) { - $callback = function($item) { return $item; }; + return array_sum($this->items); } if (is_string($callback))
false
Other
laravel
framework
7f08a725e0fdf34a7569bc62ec51220d8af9581f.json
Add route macro
src/Illuminate/Routing/Router.php
@@ -6,13 +6,16 @@ use Illuminate\Pipeline\Pipeline; use Illuminate\Support\Collection; use Illuminate\Container\Container; +use Illuminate\Support\Traits\Macroable; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Routing\Registrar as RegistrarContract; use Symfony\Component\HttpFoundation\Response as SymfonyResponse; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class Router implements RegistrarContract { + use Macroable; + /** * The event dispatcher instance. *
true
Other
laravel
framework
7f08a725e0fdf34a7569bc62ec51220d8af9581f.json
Add route macro
tests/Routing/RoutingRouteTest.php
@@ -82,6 +82,19 @@ public function testBasicDispatchingOfRoutes() } + public function testMacro() + { + $router = $this->getRouter(); + $router->macro('webhook', function() use ($router) + { + $router->match(['GET', 'POST'], 'webhook', function() { return 'OK'; }); + }); + $router->webhook(); + $this->assertEquals('OK', $router->dispatch(Request::create('webhook', 'GET'))->getContent()); + $this->assertEquals('OK', $router->dispatch(Request::create('webhook', 'POST'))->getContent()); + } + + public function testClassesCanBeInjectedIntoRoutes() { unset($_SERVER['__test.route_inject']);
true
Other
laravel
framework
2883c1688cb0bfc7f760d31e7b08bcc5d9dcb830.json
Add multiple cookies to a response Signed-off-by: Graham Campbell <graham@mineuk.com>
src/Illuminate/Http/RedirectResponse.php
@@ -70,6 +70,22 @@ public function withCookie(Cookie $cookie) return $this; } + /** + * Add multiple cookies to the response. + * + * @param array $cookie + * @return $this + */ + public function withCookies(array $cookies) + { + foreach ($cookies as $cookie) + { + $this->headers->setCookie($cookie); + } + + return $this; + } + /** * Flash an array of input to the session. *
false
Other
laravel
framework
6d9e7a608f731dd15ba7840a3bedff7659c2bf74.json
Tweak some code formatting.
src/Illuminate/Http/RedirectResponse.php
@@ -80,11 +80,10 @@ public function withInput(array $input = null) { $input = $input ?: $this->request->input(); - $input = array_filter($input, function ($value) { + $this->session->flashInput(array_filter($input, function ($value) + { return ! $value instanceof UploadedFile; - }); - - $this->session->flashInput($input); + })); return $this; }
false
Other
laravel
framework
33f4a611095812ebb8a8a2fda2870caf22789e9b.json
Return instance from foundation helpers
src/Illuminate/Foundation/helpers.php
@@ -137,8 +137,10 @@ function bcrypt($value, $options = array()) * @param mixed $default * @return mixed */ - function config($key, $default = null) + function config($key = null, $default = null) { + if (is_null($key)) return app('config'); + if (is_array($key)) { return app('config')->set($key); @@ -251,8 +253,10 @@ function info($message, $context = array()) * @param array $context * @return void */ - function logger($message, array $context = array()) + function logger($message = null, array $context = array()) { + if (is_null($message)) return app('log'); + return app('log')->debug($message, $context); } } @@ -344,14 +348,9 @@ function public_path($path = '') */ function redirect($to = null, $status = 302, $headers = array(), $secure = null) { - if ( ! is_null($to)) - { - return app('redirect')->to($to, $status, $headers, $secure); - } - else - { - return app('redirect'); - } + if (is_null($to)) return app('redirect'); + + return app('redirect')->to($to, $status, $headers, $secure); } } @@ -470,8 +469,10 @@ function storage_path($path = '') * @param string $locale * @return string */ - function trans($id, $parameters = array(), $domain = 'messages', $locale = null) + function trans($id = null, $parameters = array(), $domain = 'messages', $locale = null) { + if (is_null($id)) return app('translator'); + return app('translator')->trans($id, $parameters, $domain, $locale); } }
false
Other
laravel
framework
d6648e2f19ab4c9f8806968b077f7e36c4939730.json
Use exclusive lock on session write.
src/Illuminate/Session/FileSessionHandler.php
@@ -66,7 +66,7 @@ public function read($sessionId) */ public function write($sessionId, $data) { - $this->files->put($this->path.'/'.$sessionId, $data); + file_put_contents($this->path.'/'.$sessionId, $data, LOCK_EX); } /**
false
Other
laravel
framework
25c6a77749387b709b1ea270b76c200b68ddd706.json
Test queued handlers.
tests/Bus/BusDispatcherTest.php
@@ -39,6 +39,20 @@ public function testCommandsThatShouldBeQueuedAreQueued() } + public function testHandlersThatShouldBeQueuedAreQueued() + { + $container = new Container; + $dispatcher = new Dispatcher($container, function() { + $mock = m::mock('Illuminate\Contracts\Queue\Queue'); + $mock->shouldReceive('push')->once(); + return $mock; + }); + $dispatcher->mapUsing(function() { return 'BusDispatcherTestQueuedHandler@handle'; }); + + $dispatcher->dispatch(new BusDispatcherTestBasicCommand); + } + + public function testDispatchNowShouldNeverQueue() { $container = new Container; @@ -64,3 +78,7 @@ public function handle(BusDispatcherTestBasicCommand $command) } } + +class BusDispatcherTestQueuedHandler implements Illuminate\Contracts\Queue\ShouldBeQueued { + +}
false
Other
laravel
framework
78148251944be9a3da065954baa52691f5263ed0.json
Add a comment.
src/Illuminate/Foundation/Console/Kernel.php
@@ -122,6 +122,9 @@ public function call($command, array $parameters = array()) { $this->bootstrap(); + // If we are calling a arbitary command from within the application, we will load + // all of the available deferred providers which will make all of the commands + // available to an application. Otherwise the command will not be available. $this->app->loadDeferredProviders(); return $this->getArtisan()->call($command, $parameters);
false
Other
laravel
framework
75e1c61c5d59ac6801b0e3676036f6cbb18ffc11.json
Remove unnecessary code. The Console Kernel loads all deferred providers so there is no need for the provider repository to worry about this.
src/Illuminate/Foundation/ProviderRepository.php
@@ -59,14 +59,6 @@ public function load(array $providers) $manifest = $this->compileManifest($providers); } - // If the application is running in the console, we will not lazy load any of - // the service providers. This is mainly because it's not as necessary for - // performance and also so any provided Artisan commands get registered. - if ($this->app->runningInConsole()) - { - $manifest['eager'] = $manifest['providers']; - } - // Next, we will register events to load the providers for each of the events // that it has requested. This allows the service provider to defer itself // while still getting automatically loaded when a certain event occurs.
true
Other
laravel
framework
75e1c61c5d59ac6801b0e3676036f6cbb18ffc11.json
Remove unnecessary code. The Console Kernel loads all deferred providers so there is no need for the provider repository to worry about this.
tests/Foundation/FoundationProviderRepositoryTest.php
@@ -28,24 +28,6 @@ public function testServicesAreRegisteredWhenManifestIsNotRecompiled() } - public function testServicesAreNeverLazyLoadedWhenRunningInConsole() - { - $app = m::mock('Illuminate\Foundation\Application')->makePartial(); - - $repo = m::mock('Illuminate\Foundation\ProviderRepository[createProvider,loadManifest,shouldRecompile]', array($app, m::mock('Illuminate\Filesystem\Filesystem'), array(__DIR__.'/services.json'))); - $repo->shouldReceive('loadManifest')->once()->andReturn(array('eager' => array('foo'), 'deferred' => array('deferred'), 'providers' => array('providers'), 'when' => array())); - $repo->shouldReceive('shouldRecompile')->once()->andReturn(false); - $provider = m::mock('Illuminate\Support\ServiceProvider'); - $repo->shouldReceive('createProvider')->once()->with('providers')->andReturn($provider); - - $app->shouldReceive('register')->once()->with($provider); - $app->shouldReceive('runningInConsole')->andReturn(true); - $app->shouldReceive('setDeferredServices')->once()->with(array('deferred')); - - $repo->load(array()); - } - - public function testManifestIsProperlyRecompiled() { $app = m::mock('Illuminate\Foundation\Application');
true
Other
laravel
framework
2879d43c0fe9a8e3d78ead8e94eab343825a350e.json
Add the ability to register subscribers To use this you would simply add the class names you wish to register in the `$subscribe` property in the `App\Providers\EventServiceProvider` class. I've added the property to the class itself because I didn't want to make laravel/laravel dependent on this change. I also kept `$subscribe` singular to remain consistent with `$listen`. 
src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php
@@ -12,6 +12,13 @@ class EventServiceProvider extends ServiceProvider { * @var array */ protected $scan = []; + + /** + * The subscriber classes to register. + * + * @var array + */ + protected $subscribe = []; /** * Determines if we will auto-scan in the local environment. @@ -45,6 +52,11 @@ public function boot(DispatcherContract $events) $events->listen($event, $listener); } } + + foreach ($this->subscribe as $subscriber) + { + $events->subscribe($subscriber); + } } /**
false
Other
laravel
framework
46d7ce05617512b609dde4ca07d43f19413e5508.json
Tweak a few mapping things.
src/Illuminate/Bus/Dispatcher.php
@@ -219,14 +219,15 @@ public function mapUsing(Closure $mapper) * Map the command to a handler within a given root namespace. * * @param mixed $command - * @param string $rootNamespace + * @param string $commandNamespace + * @param string $handlerNamespace * @return string */ - public static function simpleMapping($command, $rootNamespace) + public static function simpleMapping($command, $commandNamespace, $handlerNamespace) { - $command = str_replace($rootNamespace.'\Commands', '', get_class($command)); + $command = str_replace($commandNamespace, '', get_class($command)); - return $rootNamespace.'\Handlers\Commands\\'.trim($command, '\\').'Handler@handle'; + return $handlerNamespace.'\\'.trim($command, '\\').'Handler@handle'; } }
false
Other
laravel
framework
78f00c6f1a80eb69052b7be0ce21130c2d7c4042.json
Use doctrine inflector
composer.json
@@ -16,6 +16,7 @@ "classpreloader/classpreloader": "~1.0.2", "d11wtq/boris": "~1.0", "doctrine/annotations": "~1.0", + "doctrine/inflector": "~1.0", "ircmaxell/password-compat": "~1.0", "jeremeamia/superclosure": "~1.0.1", "league/flysystem": "~1.0",
true
Other
laravel
framework
78f00c6f1a80eb69052b7be0ce21130c2d7c4042.json
Use doctrine inflector
src/Illuminate/Support/Pluralizer.php
@@ -1,102 +1,8 @@ <?php namespace Illuminate\Support; -class Pluralizer { - - /** - * Plural word form rules. - * - * @var array - */ - public static $plural = array( - '/(quiz)$/i' => "$1zes", - '/^(ox)$/i' => "$1en", - '/([m|l])ouse$/i' => "$1ice", - '/(matr|vert|ind)ix$|ex$/i' => "$1ices", - '/(stoma|epo|monar|matriar|patriar|oligar|eunu)ch$/i' => "$1chs", - '/(x|ch|ss|sh)$/i' => "$1es", - '/([^aeiouy]|qu)y$/i' => "$1ies", - '/(hive)$/i' => "$1s", - '/(?:([^f])fe|([lr])f)$/i' => "$1$2ves", - '/(shea|lea|loa|thie)f$/i' => "$1ves", - '/sis$/i' => "ses", - '/([ti])um$/i' => "$1a", - '/(torped|embarg|tomat|potat|ech|her|vet)o$/i' => "$1oes", - '/(bu)s$/i' => "$1ses", - '/(alias)$/i' => "$1es", - '/(fung)us$/i' => "$1i", - '/(ax|test)is$/i' => "$1es", - '/(us)$/i' => "$1es", - '/s$/i' => "s", - '/$/' => "s", - ); +use Doctrine\Common\Inflector\Inflector; - /** - * Singular word form rules. - * - * @var array - */ - public static $singular = array( - '/(quiz)zes$/i' => "$1", - '/(matr)ices$/i' => "$1ix", - '/(vert|vort|ind)ices$/i' => "$1ex", - '/^(ox)en$/i' => "$1", - '/(alias)es$/i' => "$1", - '/(octop|vir|fung)i$/i' => "$1us", - '/(cris|ax|test)es$/i' => "$1is", - '/(shoe)s$/i' => "$1", - '/(o)es$/i' => "$1", - '/(bus)es$/i' => "$1", - '/([m|l])ice$/i' => "$1ouse", - '/(x|ch|ss|sh)es$/i' => "$1", - '/(m)ovies$/i' => "$1ovie", - '/(s)eries$/i' => "$1eries", - '/([^aeiouy]|qu)ies$/i' => "$1y", - '/([lr])ves$/i' => "$1f", - '/(tive)s$/i' => "$1", - '/(hive)s$/i' => "$1", - '/(li|wi|kni)ves$/i' => "$1fe", - '/(shea|loa|lea|thie)ves$/i' => "$1f", - '/(^analy)ses$/i' => "$1sis", - '/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => "$1$2sis", - '/([ti])a$/i' => "$1um", - '/(n)ews$/i' => "$1ews", - '/(h|bl)ouses$/i' => "$1ouse", - '/(corpse)s$/i' => "$1", - '/(gallows|headquarters)$/i' => "$1", - '/(us)es$/i' => "$1", - '/(us|ss)$/i' => "$1", - '/s$/i' => "", - ); - - /** - * Irregular word forms. - * - * @var array - */ - public static $irregular = array( - 'child' => 'children', - 'corpus' => 'corpora', - 'criterion' => 'criteria', - 'foot' => 'feet', - 'freshman' => 'freshmen', - 'goose' => 'geese', - 'genus' => 'genera', - 'human' => 'humans', - 'man' => 'men', - 'move' => 'moves', - 'nucleus' => 'nuclei', - 'ovum' => 'ova', - 'person' => 'people', - 'phenomenon' => 'phenomena', - 'radius' => 'radii', - 'sex' => 'sexes', - 'stimulus' => 'stimuli', - 'syllabus' => 'syllabi', - 'tax' => 'taxes', - 'tech' => 'techs', - 'tooth' => 'teeth', - 'viscus' => 'viscera', - ); +class Pluralizer { /** * Uncountable word forms. @@ -130,107 +36,35 @@ class Pluralizer { ); /** - * The cached copies of the plural inflections. - * - * @var array - */ - protected static $pluralCache = array(); - - /** - * The cached copies of the singular inflections. - * - * @var array - */ - protected static $singularCache = array(); - - /** - * Get the singular form of the given word. - * - * @param string $value - * @return string - */ - public static function singular($value) - { - if (isset(static::$singularCache[$value])) - { - return static::$singularCache[$value]; - } - - $result = static::inflect($value, static::$singular, static::$irregular); - - return static::$singularCache[$value] = $result ?: $value; - } - - /** - * Get the plural form of the given word. + * Get the plural form of an English word. * * @param string $value * @param int $count * @return string */ public static function plural($value, $count = 2) { - if ($count == 1) return $value; - - if (in_array($value, static::$irregular)) return $value; - - // First we'll check the cache of inflected values. We cache each word that - // is inflected so we don't have to spin through the regular expressions - // on each subsequent method calls for this word by the app developer. - if (isset(static::$pluralCache[$value])) + if ($count === 1 || static::uncountable($value)) { - return static::$pluralCache[$value]; + return $value; } - $irregular = array_flip(static::$irregular); + $plural = Inflector::pluralize($value); - // When doing the singular to plural transformation, we'll flip the irregular - // array since we need to swap sides on the keys and values. After we have - // the transformed value we will cache it in memory for faster look-ups. - $plural = static::$plural; - - $result = static::inflect($value, $plural, $irregular); - - return static::$pluralCache[$value] = $result; + return static::matchCase($plural, $value); } /** - * Perform auto inflection on an English word. + * Get the singular form of an English word. * * @param string $value - * @param array $source - * @param array $irregular * @return string */ - protected static function inflect($value, $source, $irregular) + public static function singular($value) { - if (static::uncountable($value)) return $value; - - // Next, we will check the "irregular" patterns which contain words that are - // not easily summarized in regular expression rules, like "children" and - // "teeth", both of which cannot get inflected using our typical rules. - foreach ($irregular as $irregular => $pattern) - { - if (preg_match($pattern = '/'.$pattern.'$/i', $value)) - { - $irregular = static::matchCase($irregular, $value); - - return preg_replace($pattern, $irregular, $value); - } - } + $singular = Inflector::singularize($value); - // Finally, we'll spin through the array of regular expressions and look for - // matches for the word. If we find a match, we will cache and return the - // transformed value so we will quickly look it up on subsequent calls. - foreach ($source as $pattern => $inflected) - { - if (preg_match($pattern, $value)) - { - $inflected = preg_replace($pattern, $inflected, $value); - - return static::matchCase($inflected, $value); - } - } + return static::matchCase($singular, $value); } /**
true
Other
laravel
framework
78f00c6f1a80eb69052b7be0ce21130c2d7c4042.json
Use doctrine inflector
src/Illuminate/Support/composer.json
@@ -11,6 +11,7 @@ "require": { "php": ">=5.4.0", "illuminate/contracts": "5.0.*", + "doctrine/inflector": "~1.0", "patchwork/utf8": "~1.1" }, "require-dev": {
true
Other
laravel
framework
78f00c6f1a80eb69052b7be0ce21130c2d7c4042.json
Use doctrine inflector
tests/Support/SupportPluralizerTest.php
@@ -2,51 +2,55 @@ class SupportPluralizerTest extends PHPUnit_Framework_TestCase { - public function testBasicUsage() + + public function testBasicSingular() { - $this->assertEquals('children', str_plural('child')); - $this->assertEquals('tests', str_plural('test')); - $this->assertEquals('deer', str_plural('deer')); $this->assertEquals('child', str_singular('children')); $this->assertEquals('test', str_singular('tests')); $this->assertEquals('deer', str_singular('deer')); - $this->assertEquals('criterion', str_singular('criteria')); + $this->assertEquals('criterium', str_singular('criteria')); } - public function testCaseSensitiveUsage() + public function testBasicPlural() { - $this->assertEquals('Children', str_plural('Child')); - $this->assertEquals('CHILDREN', str_plural('CHILD')); - $this->assertEquals('Tests', str_plural('Test')); - $this->assertEquals('TESTS', str_plural('TEST')); + $this->assertEquals('children', str_plural('child')); $this->assertEquals('tests', str_plural('test')); - $this->assertEquals('Deer', str_plural('Deer')); - $this->assertEquals('DEER', str_plural('DEER')); + $this->assertEquals('deer', str_plural('deer')); + } + + + public function testCaseSensitiveSingularUsage() + { $this->assertEquals('Child', str_singular('Children')); $this->assertEquals('CHILD', str_singular('CHILDREN')); $this->assertEquals('Test', str_singular('Tests')); $this->assertEquals('TEST', str_singular('TESTS')); $this->assertEquals('Deer', str_singular('Deer')); $this->assertEquals('DEER', str_singular('DEER')); - $this->assertEquals('Criterion', str_singular('Criteria')); - $this->assertEquals('CRITERION', str_singular('CRITERIA')); + $this->assertEquals('Criterium', str_singular('Criteria')); + $this->assertEquals('CRITERIUM', str_singular('CRITERIA')); } - public function testIfEndOfWord() + public function testCaseSensitiveSingularPlural() + { + $this->assertEquals('Children', str_plural('Child')); + $this->assertEquals('CHILDREN', str_plural('CHILD')); + $this->assertEquals('Tests', str_plural('Test')); + $this->assertEquals('TESTS', str_plural('TEST')); + $this->assertEquals('tests', str_plural('test')); + $this->assertEquals('Deer', str_plural('Deer')); + $this->assertEquals('DEER', str_plural('DEER')); + } + + + public function testIfEndOfWordPlural() { $this->assertEquals('VortexFields', str_plural('VortexField')); $this->assertEquals('MatrixFields', str_plural('MatrixField')); $this->assertEquals('IndexFields', str_plural('IndexField')); $this->assertEquals('VertexFields', str_plural('VertexField')); } - public function testAlreadyPluralizedIrregularWords() - { - $this->assertEquals('children', str_plural('children')); - $this->assertEquals('radii', str_plural('radii')); - $this->assertEquals('teeth', str_plural('teeth')); - } - }
true
Other
laravel
framework
33ff51a81dbd16f62f903568fd8aab94762f34ae.json
Fix a few bugs.
src/Illuminate/Events/CallQueuedHandler.php
@@ -32,10 +32,10 @@ public function __construct(Container $container) */ public function call(Job $job, array $data) { - $event = $this->setJobIfNecessary(unserialize($data['data'])); + $event = $this->setJobIfNecessary($job, unserialize($data['data'])); $handler = $this->setJobInstanceIfNecessary( - $this->container->make($data['class']) + $job, $this->container->make($data['class']) ); call_user_func_array( @@ -51,12 +51,13 @@ public function call(Job $job, array $data) /** * Set the job instance of the given class if necessary. * + * @param \Illuminate\Contracts\Queue\Job $job * @param mixed $instance * @return mixed */ - protected function setJobInstanceIfNecessary($instance) + protected function setJobInstanceIfNecessary(Job $job, $instance) { - if (in_array('Illuminate\Queue\InteractsWithQueue', class_uses_recursive($instance))) + if (in_array('Illuminate\Queue\InteractsWithQueue', class_uses_recursive(get_class($instance)))) { $instance->setJob($job); }
true
Other
laravel
framework
33ff51a81dbd16f62f903568fd8aab94762f34ae.json
Fix a few bugs.
src/Illuminate/Queue/CallQueuedHandler.php
@@ -33,11 +33,11 @@ public function __construct(Dispatcher $dispatcher) public function call(Job $job, array $data) { $command = $this->setJobInstanceIfNecessary( - unserialize($data['command']) + $job, unserialize($data['command']) ); $handler = $this->setJobInstanceIfNecessary( - $this->dispatcher->resolveHandler($command) + $job, $this->dispatcher->resolveHandler($command) ); $method = $this->dispatcher->getHandlerMethod($command); @@ -53,12 +53,13 @@ public function call(Job $job, array $data) /** * Set the job instance of the given class if necessary. * + * @param \Illuminate\Contracts\Queue\Job $job * @param mixed $instance * @return mixed */ - protected function setJobInstanceIfNecessary($instance) + protected function setJobInstanceIfNecessary(Job $job, $instance) { - if (in_array('Illuminate\Queue\InteractsWithQueue', class_uses_recursive($instance))) + if (in_array('Illuminate\Queue\InteractsWithQueue', class_uses_recursive(get_class($instance)))) { $instance->setJob($job); }
true
Other
laravel
framework
d75eab8dbe04d5d01a8539b07a9e89071e52eecd.json
Put same methods that were in L4.
src/Illuminate/Pagination/AbstractPaginator.php
@@ -365,6 +365,16 @@ public function count() return $this->items->count(); } + /** + * Get the paginator's underlying collection. + * + * @return \Illuminate\Support\Collection + */ + public function getCollection() + { + return $this->items; + } + /** * Determine if the given item exists. * @@ -410,6 +420,18 @@ public function offsetUnset($key) unset($this->items[$key]); } + /** + * Make dynamic calls into the collection. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public function __call($method, $parameters) + { + return call_user_func_array([$this->getCollection(), $method], $parameters); + } + /** * Render the contents of the paginator when casting to string. *
false
Other
laravel
framework
472a93f8710c7783af89ee93b243439e6331eb5c.json
remove extra code
src/Illuminate/Container/Container.php
@@ -135,7 +135,7 @@ public function when($concrete) */ protected function resolvable($abstract) { - return $this->bound($abstract) || $this->isAlias($abstract); + return $this->bound($abstract); } /**
false
Other
laravel
framework
b493e47579abbc8e3d64aa03d2f5b153e960f980.json
Add MacroableTrait for Filesystem
src/Illuminate/Filesystem/Filesystem.php
@@ -2,10 +2,13 @@ use FilesystemIterator; use Symfony\Component\Finder\Finder; +use Illuminate\Support\Traits\MacroableTrait; use Illuminate\Contracts\Filesystem\FileNotFoundException; class Filesystem { + use MacroableTrait; + /** * Determine if a file exists. *
true
Other
laravel
framework
b493e47579abbc8e3d64aa03d2f5b153e960f980.json
Add MacroableTrait for Filesystem
tests/Filesystem/FilesystemTest.php
@@ -74,6 +74,16 @@ public function testCleanDirectory() } + public function testMacro() + { + file_put_contents(__DIR__.'/foo.txt', 'Hello World'); + $files = new Filesystem; + $files->macro('getFoo', function () use ($files) { return $files->get(__DIR__.'/foo.txt'); }); + $this->assertEquals('Hello World', $files->getFoo()); + @unlink(__DIR__.'/foo.txt'); + } + + public function testFilesMethod() { mkdir(__DIR__.'/foo');
true
Other
laravel
framework
b5e991d15f857ee86a4532a4249813f7c3dd779b.json
Fix docblock and typo
src/Illuminate/Database/Eloquent/Model.php
@@ -1982,7 +1982,7 @@ public function getKey() /** * Get the queueable identity for the entity. * - * @var mixed + * @return mixed */ public function getQueueableId() {
true
Other
laravel
framework
b5e991d15f857ee86a4532a4249813f7c3dd779b.json
Fix docblock and typo
src/Illuminate/Pipeline/Hub.php
@@ -61,12 +61,12 @@ public function pipeline($name, Closure $callback) * @param string|null $pipeline * @return mixed */ - public function pipe($object, $pipieline = null) + public function pipe($object, $pipeline = null) { - $pipieline = $pipieline ?: 'default'; + $pipeline = $pipeline ?: 'default'; return call_user_func( - $this->pipelines[$pipieline], new Pipeline($this->container), $object + $this->pipelines[$pipeline], new Pipeline($this->container), $object ); }
true
Other
laravel
framework
b5e991d15f857ee86a4532a4249813f7c3dd779b.json
Fix docblock and typo
src/Illuminate/Pipeline/Pipeline.php
@@ -37,7 +37,7 @@ class Pipeline implements PipelineContract { /** * Create a new class instance. * - * @param \Closure $app + * @param \Illuminate\Contracts\Container\Container $container * @return void */ public function __construct(Container $container)
true
Other
laravel
framework
ee349de4872179b0b91414776f75928b1ba573c6.json
Fix session driver in cached config.
src/Illuminate/Foundation/Console/ConfigCacheCommand.php
@@ -30,6 +30,8 @@ public function fire() $config = $this->getFreshConfiguration(); + $config = $this->setRealSessionDriver($config); + file_put_contents( $this->laravel->getCachedConfigPath(), '<?php return '.var_export($config, true).';'.PHP_EOL ); @@ -51,4 +53,21 @@ protected function getFreshConfiguration() return $app['config']->all(); } + /** + * Set the "real" session driver on the configuratoin array. + * + * Typically the SessionManager forces the driver to "array" in CLI environment. + * + * @param array $config + * @return array + */ + protected function setRealSessionDriver(array $config) + { + $session = require $this->laravel->configPath().'/session.php'; + + $config['session']['driver'] = $session['driver']; + + return $config; + } + }
false
Other
laravel
framework
a6c638b91c250a38f42536ad7123a45a2d8a9529.json
Fix cookie sessions.
src/Illuminate/Session/Middleware/StartSession.php
@@ -5,10 +5,11 @@ use Illuminate\Session\SessionManager; use Illuminate\Session\SessionInterface; use Symfony\Component\HttpFoundation\Cookie; +use Illuminate\Session\CookieSessionHandler; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Illuminate\Contracts\Routing\Middleware as MiddlewareContract; use Illuminate\Contracts\Routing\TerminableMiddleware; +use Illuminate\Contracts\Routing\Middleware as MiddlewareContract; class StartSession implements MiddlewareContract, TerminableMiddleware { @@ -75,7 +76,7 @@ public function handle($request, Closure $next) */ public function terminate($request, $response) { - if ($this->sessionConfigured()) + if ($this->sessionConfigured() && ! $this->usingCookieSessions()) { $this->manager->driver()->save(); } @@ -165,6 +166,11 @@ protected function configHitsLottery(array $config) */ protected function addCookieToResponse(Response $response, SessionInterface $session) { + if ($this->usingCookieSessions()) + { + $this->manager->driver()->save(); + } + if ($this->sessionIsPersistent($config = $this->manager->getSessionConfig())) { $response->headers->setCookie(new Cookie( @@ -219,4 +225,16 @@ protected function sessionIsPersistent(array $config = null) return ! in_array($config['driver'], array(null, 'array')); } + /** + * Determine if the session is using cookie sessions. + * + * @return bool + */ + protected function usingCookieSessions() + { + if ( ! $this->sessionConfigured()) return false; + + return $this->manager->driver()->getHandler() instanceof CookieSessionHandler; + } + }
false
Other
laravel
framework
8d6bff9fc0d923201b95fe6349af4adc129a7a5a.json
Implement styled dumper based on Symfony dumper.
src/Illuminate/Support/Debug/Dumper.php
@@ -0,0 +1,20 @@ +<?php namespace Illuminate\Support\Debug; + +use Symfony\Component\VarDumper\Cloner\VarCloner; +use Symfony\Component\VarDumper\Dumper\CliDumper; + +class Dumper { + + /** + * Var dump a value elegantly. + * + * @param mixed $value + * @return string + */ + public function dump($value) + { + $cloner = new VarCloner(); + $dumper = 'cli' === PHP_SAPI ? new CliDumper() : new HtmlDumper(); + $dumper->dump($cloner->cloneVar($value)); + } +}
true
Other
laravel
framework
8d6bff9fc0d923201b95fe6349af4adc129a7a5a.json
Implement styled dumper based on Symfony dumper.
src/Illuminate/Support/Debug/HtmlDumper.php
@@ -0,0 +1,28 @@ +<?php namespace Illuminate\Support\Debug; + +use Symfony\Component\VarDumper\Dumper\HtmlDumper as SymfonyHtmlDumper; + +class HtmlDumper extends SymfonyHtmlDumper { + + /** + * Colour definitions for output. + * + * @var array + */ + protected $styles = array( + 'default' => 'background-color:#fff; color:#222; line-height:1.2em; font-weight:normal; font:12px Monaco, Consolas, monospace', + 'num' => 'color:#a71d5d', + 'const' => 'color:#795da3', + 'str' => 'color:#df5000', + 'cchr' => 'color:#222', + 'note' => 'color:#a71d5d', + 'ref' => 'color:#A0A0A0', + 'public' => 'color:#795da3', + 'protected' => 'color:#795da3', + 'private' => 'color:#795da3', + 'meta' => 'color:#B729D9', + 'key' => 'color:#df5000', + 'index' => 'color:#a71d5d', + ); + +}
true
Other
laravel
framework
8d6bff9fc0d923201b95fe6349af4adc129a7a5a.json
Implement styled dumper based on Symfony dumper.
src/Illuminate/Support/helpers.php
@@ -455,7 +455,10 @@ function data_get($target, $key, $default = null) */ function dd() { - array_map(function($x) { dump($x); }, func_get_args()); die; + array_map(function($x) { + $dumper = new \Illuminate\Support\Debug\Dumper; + $dumper->dump($x); + }, func_get_args()); die; } }
true
Other
laravel
framework
432c478936ba363a09b28c6487c6b3e13c651f86.json
Add tests for Eloquent Model push method.
tests/Database/DatabaseEloquentModelTest.php
@@ -411,6 +411,127 @@ public function testDeleteProperlyDeletesModel() } + public function testPushNoRelations() + { + $model = $this->getMock('EloquentModelStub', array('newQuery', 'updateTimestamps')); + $query = m::mock('Illuminate\Database\Eloquent\Builder'); + $query->shouldReceive('insertGetId')->once()->with(array('name' => 'taylor'), 'id')->andReturn(1); + $model->expects($this->once())->method('newQuery')->will($this->returnValue($query)); + $model->expects($this->once())->method('updateTimestamps'); + + $model->name = 'taylor'; + $model->exists = false; + + $this->assertTrue($model->push()); + $this->assertEquals(1, $model->id); + $this->assertTrue($model->exists); + } + + + public function testPushEmptyOneRelation() + { + $model = $this->getMock('EloquentModelStub', array('newQuery', 'updateTimestamps')); + $query = m::mock('Illuminate\Database\Eloquent\Builder'); + $query->shouldReceive('insertGetId')->once()->with(array('name' => 'taylor'), 'id')->andReturn(1); + $model->expects($this->once())->method('newQuery')->will($this->returnValue($query)); + $model->expects($this->once())->method('updateTimestamps'); + + $model->name = 'taylor'; + $model->exists = false; + $model->setRelation('relationOne', null); + + $this->assertTrue($model->push()); + $this->assertEquals(1, $model->id); + $this->assertTrue($model->exists); + $this->assertNull($model->relationOne); + } + + + public function testPushOneRelation() + { + $related1 = $this->getMock('EloquentModelStub', array('newQuery', 'updateTimestamps')); + $query = m::mock('Illuminate\Database\Eloquent\Builder'); + $query->shouldReceive('insertGetId')->once()->with(array('name' => 'related1'), 'id')->andReturn(2); + $related1->expects($this->once())->method('newQuery')->will($this->returnValue($query)); + $related1->expects($this->once())->method('updateTimestamps'); + $related1->name = 'related1'; + $related1->exists = false; + + $model = $this->getMock('EloquentModelStub', array('newQuery', 'updateTimestamps')); + $query = m::mock('Illuminate\Database\Eloquent\Builder'); + $query->shouldReceive('insertGetId')->once()->with(array('name' => 'taylor'), 'id')->andReturn(1); + $model->expects($this->once())->method('newQuery')->will($this->returnValue($query)); + $model->expects($this->once())->method('updateTimestamps'); + + $model->name = 'taylor'; + $model->exists = false; + $model->setRelation('relationOne', $related1); + + $this->assertTrue($model->push()); + $this->assertEquals(1, $model->id); + $this->assertTrue($model->exists); + $this->assertEquals(2, $model->relationOne->id); + $this->assertTrue($model->relationOne->exists); + $this->assertEquals(2, $related1->id); + $this->assertTrue($related1->exists); + } + + + public function testPushEmptyManyRelation() + { + $model = $this->getMock('EloquentModelStub', array('newQuery', 'updateTimestamps')); + $query = m::mock('Illuminate\Database\Eloquent\Builder'); + $query->shouldReceive('insertGetId')->once()->with(array('name' => 'taylor'), 'id')->andReturn(1); + $model->expects($this->once())->method('newQuery')->will($this->returnValue($query)); + $model->expects($this->once())->method('updateTimestamps'); + + $model->name = 'taylor'; + $model->exists = false; + $model->setRelation('relationMany', new Illuminate\Database\Eloquent\Collection(array())); + + $this->assertTrue($model->push()); + $this->assertEquals(1, $model->id); + $this->assertTrue($model->exists); + $this->assertEquals(0, count($model->relationMany)); + } + + + public function testPushManyRelation() + { + $related1 = $this->getMock('EloquentModelStub', array('newQuery', 'updateTimestamps')); + $query = m::mock('Illuminate\Database\Eloquent\Builder'); + $query->shouldReceive('insertGetId')->once()->with(array('name' => 'related1'), 'id')->andReturn(2); + $related1->expects($this->once())->method('newQuery')->will($this->returnValue($query)); + $related1->expects($this->once())->method('updateTimestamps'); + $related1->name = 'related1'; + $related1->exists = false; + + $related2 = $this->getMock('EloquentModelStub', array('newQuery', 'updateTimestamps')); + $query = m::mock('Illuminate\Database\Eloquent\Builder'); + $query->shouldReceive('insertGetId')->once()->with(array('name' => 'related2'), 'id')->andReturn(3); + $related2->expects($this->once())->method('newQuery')->will($this->returnValue($query)); + $related2->expects($this->once())->method('updateTimestamps'); + $related2->name = 'related2'; + $related2->exists = false; + + $model = $this->getMock('EloquentModelStub', array('newQuery', 'updateTimestamps')); + $query = m::mock('Illuminate\Database\Eloquent\Builder'); + $query->shouldReceive('insertGetId')->once()->with(array('name' => 'taylor'), 'id')->andReturn(1); + $model->expects($this->once())->method('newQuery')->will($this->returnValue($query)); + $model->expects($this->once())->method('updateTimestamps'); + + $model->name = 'taylor'; + $model->exists = false; + $model->setRelation('relationMany', new Illuminate\Database\Eloquent\Collection(array($related1, $related2))); + + $this->assertTrue($model->push()); + $this->assertEquals(1, $model->id); + $this->assertTrue($model->exists); + $this->assertEquals(2, count($model->relationMany)); + $this->assertEquals([2, 3], $model->relationMany->lists('id')); + } + + public function testNewQueryReturnsEloquentQueryBuilder() { $conn = m::mock('Illuminate\Database\Connection');
false
Other
laravel
framework
00eebd513c8fa317438488080a6eb05767869a4c.json
Remove useless (array) cast
src/Illuminate/Console/AppNamespaceDetectorTrait.php
@@ -13,7 +13,7 @@ trait AppNamespaceDetectorTrait { */ protected function getAppNamespace() { - $composer = (array) json_decode(file_get_contents(base_path().'/composer.json', true)); + $composer = json_decode(file_get_contents(base_path().'/composer.json', true), true); foreach ((array) data_get($composer, 'autoload.psr-4') as $namespace => $path) {
false
Other
laravel
framework
f364f9988e77b2f9b50f7d90d90636b6cf564968.json
Use var-dumper in dd.
composer.json
@@ -34,6 +34,7 @@ "symfony/routing": "2.6.*", "symfony/security-core": "2.6.*", "symfony/translation": "2.6.*", + "symfony/var-dumper": "2.6.*", "vlucas/phpdotenv": "~1.0" }, "replace": {
true
Other
laravel
framework
f364f9988e77b2f9b50f7d90d90636b6cf564968.json
Use var-dumper in dd.
src/Illuminate/Support/helpers.php
@@ -455,7 +455,7 @@ function data_get($target, $key, $default = null) */ function dd() { - array_map(function($x) { var_dump($x); }, func_get_args()); die; + array_map(function($x) { dump($x); }, func_get_args()); die; } }
true
Other
laravel
framework
60065df712ec06aefdd2b6639318af2ae99d9104.json
Add a session helper.
src/Illuminate/Foundation/helpers.php
@@ -411,6 +411,21 @@ function secure_url($path, $parameters = array()) } } +if ( ! function_exists('session')) +{ + /** + * Get a value from the session. + * + * @param string $name + * @param mixed|null $default + * @return mixed + */ + function session($name, $default = null) + { + return app('session')->get($name, $default); + } +} + if ( ! function_exists('storage_path')) { /**
false
Other
laravel
framework
893d125acae49f859f8f37d54c429ef875cbf815.json
Tag a new version.
src/Illuminate/Foundation/Application.php
@@ -28,7 +28,7 @@ class Application extends Container implements HttpKernelInterface, TerminableIn * * @var string */ - const VERSION = '4.2.13'; + const VERSION = '4.2.14'; /** * Indicates if the application has "booted".
false
Other
laravel
framework
0b7974d0724e7a842cee7a19ccb6888e10269a8f.json
Remove old tests.
tests/Encryption/EncrypterTest.php
@@ -35,62 +35,6 @@ public function testExceptionThrownWhenPayloadIsInvalid() } - public function testCanStillBeConstructedWithInvalidKeys() - { - $e = new Encrypter(''); // should not throw an exception - - $e = new Encrypter('YourSecretKey!!!'); // should not throw an exception - } - - - /** - * @expectedException Illuminate\Encryption\InvalidKeyException - * @expectedExceptionMessage The encryption key must not be empty. - */ - public function testEncryptWithEmptyStringAsKey() - { - $e = new Encrypter(''); - - $e->encrypt('bar'); // throw the exception now that we tried to use the encrypter - } - - - /** - * @expectedException Illuminate\Encryption\InvalidKeyException - * @expectedExceptionMessage The encryption key must not be empty. - */ - public function testDecryptWithEmptyStringAsKey() - { - $e = new Encrypter(''); - - $e->decrypt('bar'); // throw the exception now that we tried to use the encrypter - } - - - /** - * @expectedException Illuminate\Encryption\InvalidKeyException - * @expectedExceptionMessage The encryption key must be a random string. - */ - public function testEncryptWithDefaultStringAsKey() - { - $e = new Encrypter('YourSecretKey!!!'); - - $e->encrypt('bar'); // throw the exception now that we tried to use the encrypter - } - - - /** - * @expectedException Illuminate\Encryption\InvalidKeyException - * @expectedExceptionMessage The encryption key must be a random string. - */ - public function testDecryptWithDefaultStringAsKey() - { - $e = new Encrypter('YourSecretKey!!!'); - - $e->decrypt('bar'); // throw the exception now that we tried to use the encrypter - } - - protected function getEncrypter() { return new Encrypter(str_repeat('a', 32));
false
Other
laravel
framework
a467c446e5b0d29cef196ae69a04a4f669fe9587.json
Use unsigned ints in the jobs table
src/Illuminate/Queue/Console/stubs/jobs.stub
@@ -17,11 +17,11 @@ class CreateJobsTable extends Migration { $table->bigIncrements('id'); $table->string('queue'); $table->text('payload'); - $table->tinyInteger('attempts'); - $table->tinyInteger('reserved'); - $table->integer('reserved_at')->nullable(); - $table->integer('available_at'); - $table->integer('created_at'); + $table->tinyInteger('attempts')->unsigned(); + $table->tinyInteger('reserved')->unsigned(); + $table->integer('reserved_at')->unsigned()->nullable(); + $table->integer('available_at')->unsigned(); + $table->integer('created_at')->unsigned(); }); }
false
Other
laravel
framework
60f82796778b828432dcae8b32a9cc8f12829c21.json
Add getGenericUser function
src/Illuminate/Auth/DatabaseUserProvider.php
@@ -52,10 +52,7 @@ public function retrieveById($identifier) { $user = $this->conn->table($this->table)->find($identifier); - if ( ! is_null($user)) - { - return new GenericUser((array) $user); - } + return $this->getGenericUser($user); } /** @@ -72,10 +69,7 @@ public function retrieveByToken($identifier, $token) ->where('remember_token', $token) ->first(); - if ( ! is_null($user)) - { - return new GenericUser((array) $user); - } + return $this->getGenericUser($user); } /** @@ -118,7 +112,18 @@ public function retrieveByCredentials(array $credentials) // that there are no matching users for these given credential arrays. $user = $query->first(); - if ( ! is_null($user)) + return $this->getGenericUser($user); + } + + /** + * Get the generic user. + * + * @param mixed $user + * @return \Illuminate\Auth\GenericUser|null + */ + protected function getGenericUser($user) + { + if ($user !== null) { return new GenericUser((array) $user); }
false
Other
laravel
framework
cb7efa7e1d265e2afc44ad375987ca093cea187a.json
Remove useless foreach
src/Illuminate/Session/Store.php
@@ -455,10 +455,7 @@ public function all() */ public function replace(array $attributes) { - foreach ($attributes as $key => $value) - { - $this->put($key, $value); - } + $this->put($attributes); } /**
false
Other
laravel
framework
3e2cd1dd40668c4e35ed5358e1f4dc4ffcf8ce99.json
Remove extra line.
src/Illuminate/Cache/CacheManager.php
@@ -1,6 +1,5 @@ <?php namespace Illuminate\Cache; - use Closure; use Illuminate\Support\Manager;
false
Other
laravel
framework
fb03b54b3c1b0020cfdb839b95877a419324f0ba.json
Make a start on database queue tests.
src/Illuminate/Queue/DatabaseQueue.php
@@ -126,7 +126,7 @@ protected function pushToDatabase($delay, $queue, $payload, $attempts = 0) 'reserved' => 0, 'reserved_at' => null, 'available_at' => $availableAt->getTimestamp(), - 'created_at' => time(), + 'created_at' => $this->getTime(), ]); } @@ -190,7 +190,7 @@ protected function getNextAvailableJob($queue) ->lockForUpdate() ->where('queue', $this->getQueue($queue)) ->where('reserved', 0) - ->where('available_at', '<=', time()) + ->where('available_at', '<=', $this->getTime()) ->orderBy('id', 'asc') ->first(); } @@ -204,7 +204,7 @@ protected function getNextAvailableJob($queue) protected function markJobAsReserved($id) { $this->database->table($this->table)->where('id', $id)->update([ - 'reserved' => 1, 'reserved_at' => time(), + 'reserved' => 1, 'reserved_at' => $this->getTime(), ]); $this->database->commit();
true
Other
laravel
framework
fb03b54b3c1b0020cfdb839b95877a419324f0ba.json
Make a start on database queue tests.
tests/Queue/QueueDatabaseQueueTest.php
@@ -0,0 +1,52 @@ +<?php + +use Mockery as m; + +class QueueDatabaseQueueTest extends PHPUnit_Framework_TestCase { + + public function tearDown() + { + m::close(); + } + + + public function testPushProperlyPushesJobOntoDatabase() + { + $queue = $this->getMock('Illuminate\Queue\DatabaseQueue', array('getTime'), array($database = m::mock('Illuminate\Database\Connection'), 'table', 'default')); + $queue->expects($this->any())->method('getTime')->will($this->returnValue('time')); + $database->shouldReceive('table')->with('table')->andReturn($query = m::mock('StdClass')); + $query->shouldReceive('insertGetId')->once()->andReturnUsing(function($array) { + $this->assertEquals('default', $array['queue']); + $this->assertEquals(json_encode(array('job' => 'foo', 'data' => array('data'))), $array['payload']); + $this->assertEquals(0, $array['attempts']); + $this->assertEquals(0, $array['reserved']); + $this->assertNull($array['reserved_at']); + $this->assertTrue(is_integer($array['available_at'])); + }); + + $queue->push('foo', array('data')); + } + + + public function testDelayedPushProperlyPushesJobOntoDatabase() + { + $queue = $this->getMock( + 'Illuminate\Queue\DatabaseQueue', + array('getTime'), + array($database = m::mock('Illuminate\Database\Connection'), 'table', 'default') + ); + $queue->expects($this->any())->method('getTime')->will($this->returnValue('time')); + $database->shouldReceive('table')->with('table')->andReturn($query = m::mock('StdClass')); + $query->shouldReceive('insertGetId')->once()->andReturnUsing(function($array) { + $this->assertEquals('default', $array['queue']); + $this->assertEquals(json_encode(array('job' => 'foo', 'data' => array('data'))), $array['payload']); + $this->assertEquals(0, $array['attempts']); + $this->assertEquals(0, $array['reserved']); + $this->assertNull($array['reserved_at']); + $this->assertTrue(is_integer($array['available_at'])); + }); + + $queue->later(10, 'foo', array('data')); + } + +}
true
Other
laravel
framework
347ea002c07ee25f599ae525c8c972307f33cea2.json
Remove useless check on $glue argument
src/Illuminate/Support/Collection.php
@@ -277,8 +277,6 @@ public function has($key) */ public function implode($value, $glue = null) { - if (is_null($glue)) return implode($this->lists($value)); - return implode($glue, $this->lists($value)); }
true
Other
laravel
framework
347ea002c07ee25f599ae525c8c972307f33cea2.json
Remove useless check on $glue argument
tests/Support/SupportCollectionTest.php
@@ -270,6 +270,8 @@ public function testImplode() { $data = new Collection(array(array('name' => 'taylor', 'email' => 'foo'), array('name' => 'dayle', 'email' => 'bar'))); $this->assertEquals('foobar', $data->implode('email')); + $this->assertEquals('foobar', $data->implode('email', '')); + $this->assertEquals('foobar', $data->implode('email', null)); $this->assertEquals('foo,bar', $data->implode('email', ',')); }
true
Other
laravel
framework
f7e9277d33b4efee11f4a8170c53f84c739876e1.json
Fix bug in AppNameCommand where it would rename App\Exceptions\* to Acme\Exceptionss\*
src/Illuminate/Foundation/Console/AppNameCommand.php
@@ -134,7 +134,7 @@ protected function setBootstrapNamespaces() $search = [ $this->currentRoot.'\\Http', $this->currentRoot.'\\Console', - $this->currentRoot.'\\Exception', + $this->currentRoot.'\\Exceptions', ]; $replace = [
false
Other
laravel
framework
3cfc4b2715f5781345c013bb7ec8e81979cc12cf.json
Remove old tests.
tests/View/ViewBladeCompilerTest.php
@@ -134,10 +134,6 @@ public function testEchosAreCompiled() $this->assertEquals('<?php echo e(myfunc(\'foo or bar\')); ?>', $compiler->compileString('{{ myfunc(\'foo or bar\') }}')); $this->assertEquals('<?php echo e(myfunc("foo or bar")); ?>', $compiler->compileString('{{ myfunc("foo or bar") }}')); $this->assertEquals('<?php echo e(myfunc("$name or \'foo\'")); ?>', $compiler->compileString('{{ myfunc("$name or \'foo\'") }}')); - - $this->assertEquals('<?php echo e($errors->has(\'email\') ? \'error or failure\' : \'\'); ?>', $compiler->compileString('{{ $errors->has(\'email\') ? \'error or failure\' : \'\' }}')); - $this->assertEquals('<?php echo e($errors->has("email") ? "error or failure" : ""); ?>', $compiler->compileString('{{ $errors->has("email") ? "error or failure" : "" }}')); - $this->assertEquals('<?php echo e($errors->has("email") ? "error \'or\' failure" : ""); ?>', $compiler->compileString('{{ $errors->has("email") ? "error \'or\' failure" : "" }}')); }
false
Other
laravel
framework
eac2c6d01a989e29e0c780a3425f3a1c8ddd8a01.json
Fix the docblock for constructor
src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php
@@ -32,6 +32,7 @@ class HasManyThrough extends Relation { * Create a new has many relationship instance. * * @param \Illuminate\Database\Eloquent\Builder $query + * @param \Illuminate\Database\Eloquent\Model $farParent * @param \Illuminate\Database\Eloquent\Model $parent * @param string $firstKey * @param string $secondKey
false
Other
laravel
framework
2af75c10a5cb8ef73bce708be0ec240a1b33780d.json
Limit backtrace frames to return
src/Illuminate/Database/Eloquent/Model.php
@@ -786,7 +786,7 @@ public function belongsTo($related, $foreignKey = null, $otherKey = null, $relat // of the time this will be what we desire to use for the relationships. if (is_null($relation)) { - list(, $caller) = debug_backtrace(false); + list(, $caller) = debug_backtrace(false, 2); $relation = $caller['function']; } @@ -826,7 +826,7 @@ public function morphTo($name = null, $type = null, $id = null) // use that to get both the class and foreign key that will be utilized. if (is_null($name)) { - list(, $caller) = debug_backtrace(false); + list(, $caller) = debug_backtrace(false, 2); $name = snake_case($caller['function']); }
false
Other
laravel
framework
cd2e3eb451d7da9c5df30f5febfdfbec6862792f.json
Correct a little spelling mistake
src/Illuminate/Log/Writer.php
@@ -126,7 +126,7 @@ public function useErrorLog($level = 'debug', $messageType = ErrorLogHandler::OP } /** - * Get a defaut Monolog formatter instance. + * Get a default Monolog formatter instance. * * @return \Monolog\Formatter\LineFormatter */
false
Other
laravel
framework
40277d71cc062697ab4697b2b296cf87186a84d1.json
Fix method name.
src/Illuminate/Database/Eloquent/Builder.php
@@ -642,7 +642,7 @@ public function whereHas($relation, Closure $callback, $operator = '>=', $count */ public function whereDoesntHave($relation, Closure $callback) { - return $this->hasNot($relation, 'and', $callback); + return $this->doesntHave($relation, 'and', $callback); } /**
false
Other
laravel
framework
c956a531f2668903a72f95e315f9759711af109c.json
Restore previous behavior.
src/Illuminate/Routing/UrlGenerator.php
@@ -114,7 +114,9 @@ public function previous() { $referrer = $this->request->headers->get('referer'); - return $referrer ? $this->to($referrer) : $this->getPreviousUrlFromSession(); + $url = $referrer ? $this->to($referrer) : $this->getPreviousUrlFromSession(); + + return $url ?: $this->to('/'); } /**
false
Other
laravel
framework
e8aef48810d5803c515f476e194092f0aa0e371b.json
Fix incorrect error message when using arrays
src/Illuminate/Validation/Validator.php
@@ -149,15 +149,21 @@ public function __construct(TranslatorInterface $translator, array $data, array /** * Parse the data and hydrate the files array. * - * @param array $data + * @param array $data + * @param string $arrayKey * @return array */ - protected function parseData(array $data) + protected function parseData(array $data, $arrayKey = null) { - $this->files = array(); + if (is_null($arrayKey)) + { + $this->files = array(); + } foreach ($data as $key => $value) { + $key = ($arrayKey) ? "$arrayKey.$key" : $key; + // If this value is an instance of the HttpFoundation File class we will // remove it from the data array and add it to the files array, which // we use to conveniently separate out these files from other data. @@ -167,6 +173,10 @@ protected function parseData(array $data) unset($data[$key]); } + elseif (is_array($value)) + { + $this->parseData($value, $key); + } } return $data;
false
Other
laravel
framework
426c1a17a39aced4f8a763b10acbb1b10a5eac28.json
Use mixed return type.
src/Illuminate/Mail/Mailer.php
@@ -142,7 +142,7 @@ public function plain($view, array $data, $callback) * @param string|array $view * @param array $data * @param \Closure|string $callback - * @return void + * @return mixed */ public function send($view, array $data, $callback) {
false
Other
laravel
framework
3615fa377dfab765b17e200566869a95502b2697.json
Rename some methods.
src/Illuminate/Database/Eloquent/Builder.php
@@ -614,7 +614,7 @@ public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', C * @param \Closure $callback * @return \Illuminate\Database\Eloquent\Builder|static */ - public function hasNot($relation, $boolean = 'and', Closure $callback = null) + public function doesntHave($relation, $boolean = 'and', Closure $callback = null) { return $this->has($relation, '<', 1, $boolean, $callback); } @@ -640,7 +640,7 @@ public function whereHas($relation, Closure $callback, $operator = '>=', $count * @param \Closure $callback * @return \Illuminate\Database\Eloquent\Builder|static */ - public function whereHasNot($relation, Closure $callback) + public function whereDoesntHave($relation, Closure $callback) { return $this->hasNot($relation, 'and', $callback); }
false
Other
laravel
framework
2808b6c83d454e082d50efc91cd2711d3f6d8dd0.json
Fix some formatting.
src/Illuminate/Filesystem/FilesystemManager.php
@@ -93,12 +93,7 @@ public function createLocalDriver(array $config) */ public function createS3Driver(array $config) { - $s3Config = ['key' => $config['key'], 'secret' => $config['secret']]; - - if (isset($config['region'])) - { - $s3Config['region'] = $config['region']; - } + $s3Config = array_only($config, ['key', 'region', 'secret', 'signature']); return $this->adapt( new Flysystem(new S3Adapter(S3Client::factory($s3Config), $config['bucket']))
false
Other
laravel
framework
8f0cb08d8ebd157cbfe9fdebb54d2b71b0afaabd.json
Add hasNot And whereHasNot Method
src/Illuminate/Database/Eloquent/Builder.php
@@ -26,14 +26,14 @@ class Builder { * * @var array */ - protected $eagerLoad = []; + protected $eagerLoad = array(); /** * All of the registered builder macros. * * @var array */ - protected $macros = []; + protected $macros = array(); /** * A replacement for the typical delete function. @@ -47,10 +47,10 @@ class Builder { * * @var array */ - protected $passthru = [ + protected $passthru = array( 'toSql', 'lists', 'insert', 'insertGetId', 'pluck', 'count', 'min', 'max', 'avg', 'sum', 'exists', 'getBindings', - ]; + ); /** * Create a new Eloquent query builder instance. @@ -70,7 +70,7 @@ public function __construct(QueryBuilder $query) * @param array $columns * @return \Illuminate\Database\Eloquent\Model|static|null */ - public function find($id, $columns = ['*']) + public function find($id, $columns = array('*')) { if (is_array($id)) { @@ -89,7 +89,7 @@ public function find($id, $columns = ['*']) * @param array $columns * @return \Illuminate\Database\Eloquent\Model|Collection|static */ - public function findMany($id, $columns = ['*']) + public function findMany($id, $columns = array('*')) { if (empty($id)) return $this->model->newCollection(); @@ -107,7 +107,7 @@ public function findMany($id, $columns = ['*']) * * @throws \Illuminate\Database\Eloquent\ModelNotFoundException */ - public function findOrFail($id, $columns = ['*']) + public function findOrFail($id, $columns = array('*')) { if ( ! is_null($model = $this->find($id, $columns))) return $model; @@ -120,7 +120,7 @@ public function findOrFail($id, $columns = ['*']) * @param array $columns * @return \Illuminate\Database\Eloquent\Model|static|null */ - public function first($columns = ['*']) + public function first($columns = array('*')) { return $this->take(1)->get($columns)->first(); } @@ -133,7 +133,7 @@ public function first($columns = ['*']) * * @throws \Illuminate\Database\Eloquent\ModelNotFoundException */ - public function firstOrFail($columns = ['*']) + public function firstOrFail($columns = array('*')) { if ( ! is_null($model = $this->first($columns))) return $model; @@ -146,7 +146,7 @@ public function firstOrFail($columns = ['*']) * @param array $columns * @return \Illuminate\Database\Eloquent\Collection|static[] */ - public function get($columns = ['*']) + public function get($columns = array('*')) { $models = $this->getModels($columns); @@ -169,7 +169,7 @@ public function get($columns = ['*']) */ public function pluck($column) { - $result = $this->first([$column]); + $result = $this->first(array($column)); if ($result) return $result->{$column}; } @@ -216,7 +216,7 @@ public function lists($column, $key = null) { foreach ($results as $key => &$value) { - $fill = [$column => $value]; + $fill = array($column => $value); $value = $this->model->newFromBuilder($fill)->$column; } @@ -232,7 +232,7 @@ public function lists($column, $key = null) * @param array $columns * @return \Illuminate\Pagination\Paginator */ - public function paginate($perPage = null, $columns = ['*']) + public function paginate($perPage = null, $columns = array('*')) { $perPage = $perPage ?: $this->model->getPerPage(); @@ -292,7 +292,7 @@ protected function ungroupedPaginate($paginator, $perPage, $columns) * @param array $columns * @return \Illuminate\Pagination\Paginator */ - public function simplePaginate($perPage = null, $columns = ['*']) + public function simplePaginate($perPage = null, $columns = array('*')) { $paginator = $this->query->getConnection()->getPaginator(); @@ -324,7 +324,7 @@ public function update(array $values) * @param array $extra * @return int */ - public function increment($column, $amount = 1, array $extra = []) + public function increment($column, $amount = 1, array $extra = array()) { $extra = $this->addUpdatedAtColumn($extra); @@ -339,7 +339,7 @@ public function increment($column, $amount = 1, array $extra = []) * @param array $extra * @return int */ - public function decrement($column, $amount = 1, array $extra = []) + public function decrement($column, $amount = 1, array $extra = array()) { $extra = $this->addUpdatedAtColumn($extra); @@ -403,7 +403,7 @@ public function onDelete(Closure $callback) * @param array $columns * @return \Illuminate\Database\Eloquent\Model[] */ - public function getModels($columns = ['*']) + public function getModels($columns = array('*')) { // First, we will simply get the raw results from the query builders which we // can use to populate an array with Eloquent models. We will pass columns @@ -412,7 +412,7 @@ public function getModels($columns = ['*']) $connection = $this->model->getConnectionName(); - $models = []; + $models = array(); // Once we have the results, we can spin through them and instantiate a fresh // model instance for each records we retrieved from the database. We will @@ -515,7 +515,7 @@ public function getRelation($relation) */ protected function nestedRelations($relation) { - $nested = []; + $nested = array(); // We are basically looking for any relationships that are nested deeper than // the given top-level relationship. We will just check for any relations @@ -566,7 +566,7 @@ public function where($column, $operator = null, $value = null, $boolean = 'and' } else { - call_user_func_array([$this->query, 'where'], func_get_args()); + call_user_func_array(array($this->query, 'where'), func_get_args()); } return $this; @@ -588,14 +588,14 @@ public function orWhere($column, $operator = null, $value = null) /** * Add a relationship count condition to the query. * - * @param string $relation - * @param string $operator - * @param int $count - * @param string $boolean - * @param \Closure $callback + * @param string $relation + * @param string $operator + * @param int $count + * @param string $boolean + * @param \Closure $callback * @return \Illuminate\Database\Eloquent\Builder|static */ - public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', $callback = null) + public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', Closure $callback = null) { $relation = $this->getHasRelationQuery($relation); @@ -606,16 +606,15 @@ public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', $ return $this->addHasWhere($query, $relation, $operator, $count, $boolean); } - /** - * Add a relationship count condition to the query + * Add a relationship count condition to the query. * * @param string $relation * @param string $boolean - * @param null $callback + * @param \Closure $callback * @return \Illuminate\Database\Eloquent\Builder|static */ - public function hasNot($relation, $boolean = 'and', $callback = null) + public function hasNot($relation, $boolean = 'and', Closure $callback = null) { return $this->has($relation, '<', 1, $boolean, $callback); } @@ -634,14 +633,13 @@ public function whereHas($relation, Closure $callback, $operator = '>=', $count return $this->has($relation, $operator, $count, 'and', $callback); } - /** * Add a relationship count condition to the query with where clauses. * - * @param string $relation + * @param string $relation * @param \Closure $callback * @return \Illuminate\Database\Eloquent\Builder|static - */ + */ public function whereHasNot($relation, Closure $callback) { return $this->hasNot($relation, 'and', $callback); @@ -758,7 +756,7 @@ public function with($relations) */ protected function parseRelations(array $relations) { - $results = []; + $results = array(); foreach ($relations as $name => $constraints) { @@ -769,7 +767,7 @@ protected function parseRelations(array $relations) { $f = function() {}; - list($name, $constraints) = [$constraints, $f]; + list($name, $constraints) = array($constraints, $f); } // We need to separate out any nested includes. Which allows the developers @@ -792,7 +790,7 @@ protected function parseRelations(array $relations) */ protected function parseNested($name, $results) { - $progress = []; + $progress = array(); // If the relation has already been set on the result array, we will not set it // again, since that would override any constraints that were already placed @@ -803,8 +801,8 @@ protected function parseNested($name, $results) if ( ! isset($results[$last = implode('.', $progress)])) { - $results[$last] = function() {}; - } + $results[$last] = function() {}; + } } return $results; @@ -821,7 +819,7 @@ protected function callScope($scope, $parameters) { array_unshift($parameters, $this); - return call_user_func_array([$this->model, $scope], $parameters) ?: $this; + return call_user_func_array(array($this->model, $scope), $parameters) ?: $this; } /** @@ -934,7 +932,7 @@ public function __call($method, $parameters) return $this->callScope($scope, $parameters); } - $result = call_user_func_array([$this->query, $method], $parameters); + $result = call_user_func_array(array($this->query, $method), $parameters); return in_array($method, $this->passthru) ? $result : $this; }
false
Other
laravel
framework
83a9eebab62897388de56f2bdceb03e844ba5d0a.json
Fix some formatting.
src/Illuminate/Validation/Validator.php
@@ -368,7 +368,7 @@ protected function getValue($attribute) protected function isValidatable($rule, $attribute, $value) { return $this->presentOrRuleIsImplicit($rule, $attribute, $value) && - $this->passesOptionalCheck($attribute); + $this->passesOptionalCheck($attribute); } /**
false
Other
laravel
framework
9da1c65818fa2c6542272f8cb7e52b540284c718.json
Remove useless line break
src/Illuminate/Database/Eloquent/Builder.php
@@ -633,7 +633,6 @@ public function whereHas($relation, Closure $callback, $operator = '>=', $count return $this->has($relation, $operator, $count, 'and', $callback); } - /** * Add a relationship count condition to the query with where clauses. *
false
Other
laravel
framework
511c5cf409526b9cb430396c4f3fe82c038b5d21.json
Add new line at the end of the file
src/Illuminate/Database/Eloquent/Builder.php
@@ -949,3 +949,4 @@ public function __clone() } } +
false
Other
laravel
framework
64b30a8c493547a9ae07090ee83450a486d3cd06.json
Use ConnectionInterface instead of implementation This will allow developers to use custom connection implementation.
src/Illuminate/Database/ConnectionResolver.php
@@ -34,7 +34,7 @@ public function __construct(array $connections = array()) * Get a database connection instance. * * @param string $name - * @return \Illuminate\Database\Connection + * @return \Illuminate\Database\ConnectionInterface */ public function connection($name = null) { @@ -47,10 +47,10 @@ public function connection($name = null) * Add a connection to the resolver. * * @param string $name - * @param \Illuminate\Database\Connection $connection + * @param \Illuminate\Database\ConnectionInterface $connection * @return void */ - public function addConnection($name, Connection $connection) + public function addConnection($name, ConnectionInterface $connection) { $this->connections[$name] = $connection; }
false
Other
laravel
framework
05539eb498087194f3e17e59fe38e72242564093.json
Add hasNot and whereHasNot method
src/Illuminate/Database/Eloquent/Builder.php
@@ -26,14 +26,14 @@ class Builder { * * @var array */ - protected $eagerLoad = []; + protected $eagerLoad = array(); /** * All of the registered builder macros. * * @var array */ - protected $macros = []; + protected $macros = array(); /** * A replacement for the typical delete function. @@ -47,10 +47,10 @@ class Builder { * * @var array */ - protected $passthru = [ + protected $passthru = array( 'toSql', 'lists', 'insert', 'insertGetId', 'pluck', 'count', 'min', 'max', 'avg', 'sum', 'exists', 'getBindings', - ]; + ); /** * Create a new Eloquent query builder instance. @@ -70,7 +70,7 @@ public function __construct(QueryBuilder $query) * @param array $columns * @return \Illuminate\Database\Eloquent\Model|static|null */ - public function find($id, $columns = ['*']) + public function find($id, $columns = array('*')) { if (is_array($id)) { @@ -89,7 +89,7 @@ public function find($id, $columns = ['*']) * @param array $columns * @return \Illuminate\Database\Eloquent\Model|Collection|static */ - public function findMany($id, $columns = ['*']) + public function findMany($id, $columns = array('*')) { if (empty($id)) return $this->model->newCollection(); @@ -107,7 +107,7 @@ public function findMany($id, $columns = ['*']) * * @throws \Illuminate\Database\Eloquent\ModelNotFoundException */ - public function findOrFail($id, $columns = ['*']) + public function findOrFail($id, $columns = array('*')) { if ( ! is_null($model = $this->find($id, $columns))) return $model; @@ -120,7 +120,7 @@ public function findOrFail($id, $columns = ['*']) * @param array $columns * @return \Illuminate\Database\Eloquent\Model|static|null */ - public function first($columns = ['*']) + public function first($columns = array('*')) { return $this->take(1)->get($columns)->first(); } @@ -133,7 +133,7 @@ public function first($columns = ['*']) * * @throws \Illuminate\Database\Eloquent\ModelNotFoundException */ - public function firstOrFail($columns = ['*']) + public function firstOrFail($columns = array('*')) { if ( ! is_null($model = $this->first($columns))) return $model; @@ -146,7 +146,7 @@ public function firstOrFail($columns = ['*']) * @param array $columns * @return \Illuminate\Database\Eloquent\Collection|static[] */ - public function get($columns = ['*']) + public function get($columns = array('*')) { $models = $this->getModels($columns); @@ -169,7 +169,7 @@ public function get($columns = ['*']) */ public function pluck($column) { - $result = $this->first([$column]); + $result = $this->first(array($column)); if ($result) return $result->{$column}; } @@ -216,7 +216,7 @@ public function lists($column, $key = null) { foreach ($results as $key => &$value) { - $fill = [$column => $value]; + $fill = array($column => $value); $value = $this->model->newFromBuilder($fill)->$column; } @@ -232,7 +232,7 @@ public function lists($column, $key = null) * @param array $columns * @return \Illuminate\Pagination\Paginator */ - public function paginate($perPage = null, $columns = ['*']) + public function paginate($perPage = null, $columns = array('*')) { $perPage = $perPage ?: $this->model->getPerPage(); @@ -292,7 +292,7 @@ protected function ungroupedPaginate($paginator, $perPage, $columns) * @param array $columns * @return \Illuminate\Pagination\Paginator */ - public function simplePaginate($perPage = null, $columns = ['*']) + public function simplePaginate($perPage = null, $columns = array('*')) { $paginator = $this->query->getConnection()->getPaginator(); @@ -324,7 +324,7 @@ public function update(array $values) * @param array $extra * @return int */ - public function increment($column, $amount = 1, array $extra = []) + public function increment($column, $amount = 1, array $extra = array()) { $extra = $this->addUpdatedAtColumn($extra); @@ -339,7 +339,7 @@ public function increment($column, $amount = 1, array $extra = []) * @param array $extra * @return int */ - public function decrement($column, $amount = 1, array $extra = []) + public function decrement($column, $amount = 1, array $extra = array()) { $extra = $this->addUpdatedAtColumn($extra); @@ -403,7 +403,7 @@ public function onDelete(Closure $callback) * @param array $columns * @return \Illuminate\Database\Eloquent\Model[] */ - public function getModels($columns = ['*']) + public function getModels($columns = array('*')) { // First, we will simply get the raw results from the query builders which we // can use to populate an array with Eloquent models. We will pass columns @@ -412,7 +412,7 @@ public function getModels($columns = ['*']) $connection = $this->model->getConnectionName(); - $models = []; + $models = array(); // Once we have the results, we can spin through them and instantiate a fresh // model instance for each records we retrieved from the database. We will @@ -515,7 +515,7 @@ public function getRelation($relation) */ protected function nestedRelations($relation) { - $nested = []; + $nested = array(); // We are basically looking for any relationships that are nested deeper than // the given top-level relationship. We will just check for any relations @@ -566,7 +566,7 @@ public function where($column, $operator = null, $value = null, $boolean = 'and' } else { - call_user_func_array([$this->query, 'where'], func_get_args()); + call_user_func_array(array($this->query, 'where'), func_get_args()); } return $this; @@ -588,11 +588,11 @@ public function orWhere($column, $operator = null, $value = null) /** * Add a relationship count condition to the query. * - * @param string $relation - * @param string $operator - * @param int $count - * @param string $boolean - * @param \Closure $callback + * @param string $relation + * @param string $operator + * @param int $count + * @param string $boolean + * @param \Closure $callback * @return \Illuminate\Database\Eloquent\Builder|static */ public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', $callback = null) @@ -606,7 +606,6 @@ public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', $ return $this->addHasWhere($query, $relation, $operator, $count, $boolean); } - /** * Add a relationship count condition to the query * @@ -623,10 +622,10 @@ public function hasNot($relation, $boolean = 'and', $callback = null) /** * Add a relationship count condition to the query with where clauses. * - * @param string $relation + * @param string $relation * @param \Closure $callback - * @param string $operator - * @param int $count + * @param string $operator + * @param int $count * @return \Illuminate\Database\Eloquent\Builder|static */ public function whereHas($relation, Closure $callback, $operator = '>=', $count = 1) @@ -641,7 +640,7 @@ public function whereHas($relation, Closure $callback, $operator = '>=', $count * @param string $relation * @param \Closure $callback * @return \Illuminate\Database\Eloquent\Builder|static - */ + */ public function whereHasNot($relation, Closure $callback) { return $this->hasNot($relation, 'and', $callback); @@ -758,7 +757,7 @@ public function with($relations) */ protected function parseRelations(array $relations) { - $results = []; + $results = array(); foreach ($relations as $name => $constraints) { @@ -769,7 +768,7 @@ protected function parseRelations(array $relations) { $f = function() {}; - list($name, $constraints) = [$constraints, $f]; + list($name, $constraints) = array($constraints, $f); } // We need to separate out any nested includes. Which allows the developers @@ -792,7 +791,7 @@ protected function parseRelations(array $relations) */ protected function parseNested($name, $results) { - $progress = []; + $progress = array(); // If the relation has already been set on the result array, we will not set it // again, since that would override any constraints that were already placed @@ -803,8 +802,8 @@ protected function parseNested($name, $results) if ( ! isset($results[$last = implode('.', $progress)])) { - $results[$last] = function() {}; - } + $results[$last] = function() {}; + } } return $results; @@ -821,7 +820,7 @@ protected function callScope($scope, $parameters) { array_unshift($parameters, $this); - return call_user_func_array([$this->model, $scope], $parameters) ?: $this; + return call_user_func_array(array($this->model, $scope), $parameters) ?: $this; } /** @@ -934,7 +933,7 @@ public function __call($method, $parameters) return $this->callScope($scope, $parameters); } - $result = call_user_func_array([$this->query, $method], $parameters); + $result = call_user_func_array(array($this->query, $method), $parameters); return in_array($method, $this->passthru) ? $result : $this; } @@ -949,4 +948,4 @@ public function __clone() $this->query = clone $this->query; } -} +} \ No newline at end of file
false
Other
laravel
framework
c7e15e9b652f4cbb3de46919ba9eb1f66b9b47cc.json
Add hasNot and whereHasNot method
src/Illuminate/Database/Eloquent/Builder.php
@@ -26,14 +26,14 @@ class Builder { * * @var array */ - protected $eagerLoad = array(); + protected $eagerLoad = []; /** * All of the registered builder macros. * * @var array */ - protected $macros = array(); + protected $macros = []; /** * A replacement for the typical delete function. @@ -47,10 +47,10 @@ class Builder { * * @var array */ - protected $passthru = array( + protected $passthru = [ 'toSql', 'lists', 'insert', 'insertGetId', 'pluck', 'count', 'min', 'max', 'avg', 'sum', 'exists', 'getBindings', - ); + ]; /** * Create a new Eloquent query builder instance. @@ -70,7 +70,7 @@ public function __construct(QueryBuilder $query) * @param array $columns * @return \Illuminate\Database\Eloquent\Model|static|null */ - public function find($id, $columns = array('*')) + public function find($id, $columns = ['*']) { if (is_array($id)) { @@ -89,7 +89,7 @@ public function find($id, $columns = array('*')) * @param array $columns * @return \Illuminate\Database\Eloquent\Model|Collection|static */ - public function findMany($id, $columns = array('*')) + public function findMany($id, $columns = ['*']) { if (empty($id)) return $this->model->newCollection(); @@ -107,7 +107,7 @@ public function findMany($id, $columns = array('*')) * * @throws \Illuminate\Database\Eloquent\ModelNotFoundException */ - public function findOrFail($id, $columns = array('*')) + public function findOrFail($id, $columns = ['*']) { if ( ! is_null($model = $this->find($id, $columns))) return $model; @@ -120,7 +120,7 @@ public function findOrFail($id, $columns = array('*')) * @param array $columns * @return \Illuminate\Database\Eloquent\Model|static|null */ - public function first($columns = array('*')) + public function first($columns = ['*']) { return $this->take(1)->get($columns)->first(); } @@ -133,7 +133,7 @@ public function first($columns = array('*')) * * @throws \Illuminate\Database\Eloquent\ModelNotFoundException */ - public function firstOrFail($columns = array('*')) + public function firstOrFail($columns = ['*']) { if ( ! is_null($model = $this->first($columns))) return $model; @@ -146,7 +146,7 @@ public function firstOrFail($columns = array('*')) * @param array $columns * @return \Illuminate\Database\Eloquent\Collection|static[] */ - public function get($columns = array('*')) + public function get($columns = ['*']) { $models = $this->getModels($columns); @@ -169,7 +169,7 @@ public function get($columns = array('*')) */ public function pluck($column) { - $result = $this->first(array($column)); + $result = $this->first([$column]); if ($result) return $result->{$column}; } @@ -216,7 +216,7 @@ public function lists($column, $key = null) { foreach ($results as $key => &$value) { - $fill = array($column => $value); + $fill = [$column => $value]; $value = $this->model->newFromBuilder($fill)->$column; } @@ -232,7 +232,7 @@ public function lists($column, $key = null) * @param array $columns * @return \Illuminate\Pagination\Paginator */ - public function paginate($perPage = null, $columns = array('*')) + public function paginate($perPage = null, $columns = ['*']) { $perPage = $perPage ?: $this->model->getPerPage(); @@ -292,7 +292,7 @@ protected function ungroupedPaginate($paginator, $perPage, $columns) * @param array $columns * @return \Illuminate\Pagination\Paginator */ - public function simplePaginate($perPage = null, $columns = array('*')) + public function simplePaginate($perPage = null, $columns = ['*']) { $paginator = $this->query->getConnection()->getPaginator(); @@ -324,7 +324,7 @@ public function update(array $values) * @param array $extra * @return int */ - public function increment($column, $amount = 1, array $extra = array()) + public function increment($column, $amount = 1, array $extra = []) { $extra = $this->addUpdatedAtColumn($extra); @@ -339,7 +339,7 @@ public function increment($column, $amount = 1, array $extra = array()) * @param array $extra * @return int */ - public function decrement($column, $amount = 1, array $extra = array()) + public function decrement($column, $amount = 1, array $extra = []) { $extra = $this->addUpdatedAtColumn($extra); @@ -403,7 +403,7 @@ public function onDelete(Closure $callback) * @param array $columns * @return \Illuminate\Database\Eloquent\Model[] */ - public function getModels($columns = array('*')) + public function getModels($columns = ['*']) { // First, we will simply get the raw results from the query builders which we // can use to populate an array with Eloquent models. We will pass columns @@ -412,7 +412,7 @@ public function getModels($columns = array('*')) $connection = $this->model->getConnectionName(); - $models = array(); + $models = []; // Once we have the results, we can spin through them and instantiate a fresh // model instance for each records we retrieved from the database. We will @@ -515,7 +515,7 @@ public function getRelation($relation) */ protected function nestedRelations($relation) { - $nested = array(); + $nested = []; // We are basically looking for any relationships that are nested deeper than // the given top-level relationship. We will just check for any relations @@ -566,7 +566,7 @@ public function where($column, $operator = null, $value = null, $boolean = 'and' } else { - call_user_func_array(array($this->query, 'where'), func_get_args()); + call_user_func_array([$this->query, 'where'], func_get_args()); } return $this; @@ -588,11 +588,11 @@ public function orWhere($column, $operator = null, $value = null) /** * Add a relationship count condition to the query. * - * @param string $relation - * @param string $operator - * @param int $count - * @param string $boolean - * @param \Closure $callback + * @param string $relation + * @param string $operator + * @param int $count + * @param string $boolean + * @param \Closure $callback * @return \Illuminate\Database\Eloquent\Builder|static */ public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', $callback = null) @@ -606,6 +606,20 @@ public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', $ return $this->addHasWhere($query, $relation, $operator, $count, $boolean); } + + /** + * Add a relationship count condition to the query + * + * @param string $relation + * @param string $boolean + * @param null $callback + * @return \Illuminate\Database\Eloquent\Builder|static + */ + public function hasNot($relation, $boolean = 'and', $callback = null) + { + return $this->has($relation, '<', 1, $boolean, $callback); + } + /** * Add a relationship count condition to the query with where clauses. * @@ -620,6 +634,19 @@ public function whereHas($relation, Closure $callback, $operator = '>=', $count return $this->has($relation, $operator, $count, 'and', $callback); } + + /** + * Add a relationship count condition to the query with where clauses. + * + * @param string $relation + * @param \Closure $callback + * @return \Illuminate\Database\Eloquent\Builder|static + */ + public function whereHasNot($relation, Closure $callback) + { + return $this->hasNot($relation, 'and', $callback); + } + /** * Add a relationship count condition to the query with an "or". * @@ -731,7 +758,7 @@ public function with($relations) */ protected function parseRelations(array $relations) { - $results = array(); + $results = []; foreach ($relations as $name => $constraints) { @@ -742,7 +769,7 @@ protected function parseRelations(array $relations) { $f = function() {}; - list($name, $constraints) = array($constraints, $f); + list($name, $constraints) = [$constraints, $f]; } // We need to separate out any nested includes. Which allows the developers @@ -765,7 +792,7 @@ protected function parseRelations(array $relations) */ protected function parseNested($name, $results) { - $progress = array(); + $progress = []; // If the relation has already been set on the result array, we will not set it // again, since that would override any constraints that were already placed @@ -794,7 +821,7 @@ protected function callScope($scope, $parameters) { array_unshift($parameters, $this); - return call_user_func_array(array($this->model, $scope), $parameters) ?: $this; + return call_user_func_array([$this->model, $scope], $parameters) ?: $this; } /** @@ -907,7 +934,7 @@ public function __call($method, $parameters) return $this->callScope($scope, $parameters); } - $result = call_user_func_array(array($this->query, $method), $parameters); + $result = call_user_func_array([$this->query, $method], $parameters); return in_array($method, $this->passthru) ? $result : $this; }
false
Other
laravel
framework
e098b2c19cacf52ade40bfd22d73ee7fa49d4455.json
use PHPUnit static assertions
src/Illuminate/Foundation/Testing/AssertionsTrait.php
@@ -1,6 +1,7 @@ <?php namespace Illuminate\Foundation\Testing; use Illuminate\View\View; +use PHPUnit_Framework_Assert as PHPUnit; trait AssertionsTrait { @@ -15,7 +16,7 @@ public function assertResponseOk() $actual = $response->getStatusCode(); - return $this->assertTrue($response->isOk(), 'Expected status code 200, got ' .$actual); + return PHPUnit::assertTrue($response->isOk(), 'Expected status code 200, got ' .$actual); } /** @@ -26,7 +27,7 @@ public function assertResponseOk() */ public function assertResponseStatus($code) { - return $this->assertEquals($code, $this->client->getResponse()->getStatusCode()); + return PHPUnit::assertEquals($code, $this->client->getResponse()->getStatusCode()); } /** @@ -44,16 +45,16 @@ public function assertViewHas($key, $value = null) if ( ! isset($response->original) || ! $response->original instanceof View) { - return $this->assertTrue(false, 'The response was not a view.'); + return PHPUnit::assertTrue(false, 'The response was not a view.'); } if (is_null($value)) { - $this->assertArrayHasKey($key, $response->original->getData()); + PHPUnit::assertArrayHasKey($key, $response->original->getData()); } else { - $this->assertEquals($value, $response->original->$key); + PHPUnit::assertEquals($value, $response->original->$key); } } @@ -90,10 +91,10 @@ public function assertViewMissing($key) if ( ! isset($response->original) || ! $response->original instanceof View) { - return $this->assertTrue(false, 'The response was not a view.'); + return PHPUnit::assertTrue(false, 'The response was not a view.'); } - $this->assertArrayNotHasKey($key, $response->original->getData()); + PHPUnit::assertArrayNotHasKey($key, $response->original->getData()); } /** @@ -107,9 +108,9 @@ public function assertRedirectedTo($uri, $with = array()) { $response = $this->client->getResponse(); - $this->assertInstanceOf('Illuminate\Http\RedirectResponse', $response); + PHPUnit::assertInstanceOf('Illuminate\Http\RedirectResponse', $response); - $this->assertEquals($this->app['url']->to($uri), $response->headers->get('Location')); + PHPUnit::assertEquals($this->app['url']->to($uri), $response->headers->get('Location')); $this->assertSessionHasAll($with); } @@ -153,11 +154,11 @@ public function assertSessionHas($key, $value = null) if (is_null($value)) { - $this->assertTrue($this->app['session.store']->has($key), "Session missing key: $key"); + PHPUnit::assertTrue($this->app['session.store']->has($key), "Session missing key: $key"); } else { - $this->assertEquals($value, $this->app['session.store']->get($key)); + PHPUnit::assertEquals($value, $this->app['session.store']->get($key)); } } @@ -201,11 +202,11 @@ public function assertSessionHasErrors($bindings = array(), $format = null) { if (is_int($key)) { - $this->assertTrue($errors->has($value), "Session missing error: $value"); + PHPUnit::assertTrue($errors->has($value), "Session missing error: $value"); } else { - $this->assertContains($value, $errors->get($key, $format)); + PHPUnit::assertContains($value, $errors->get($key, $format)); } } }
false
Other
laravel
framework
ca877782d63aa0ca440e09c1f87f9e1a9a514356.json
Fix stub order.
src/Illuminate/Foundation/Console/stubs/request.stub
@@ -4,6 +4,16 @@ use {{rootNamespace}}Http\Requests\Request; class {{class}} extends Request { + /** + * Determine if the user is authorized to make this request. + * + * @return bool + */ + public function authorize() + { + return false; + } + /** * Get the validation rules that apply to the request. * @@ -26,14 +36,4 @@ class {{class}} extends Request { return $this->all(); } - /** - * Determine if the user is authorized to make this request. - * - * @return bool - */ - public function authorize() - { - return false; - } - }
false
Other
laravel
framework
9e80174f4a055a34fa9c40da51b7ac73deedf0fb.json
Fix casing and conflicts.
src/Illuminate/Support/Collection.php
@@ -235,7 +235,7 @@ public function groupBy($groupBy) foreach ($this->items as $key => $value) { - $results[$this->getGroupbyKey($groupBy, $key, $value)][] = $value; + $results[$this->getGroupByKey($groupBy, $key, $value)][] = $value; } return new static($results); @@ -249,7 +249,7 @@ public function groupBy($groupBy) * @param mixed $value * @return string */ - protected function getGroupbyKey($groupBy, $key, $value) + protected function getGroupByKey($groupBy, $key, $value) { if ( ! is_string($groupBy) && is_callable($groupBy)) {
false
Other
laravel
framework
30c4e946033db1df58b2f11d4d8f6885a356c3b8.json
Fix code to not be a breaking chage.
src/Illuminate/Database/Query/Builder.php
@@ -1702,7 +1702,13 @@ protected function restoreFieldsForCount() */ public function exists() { - return $this->limit(1)->count() > 0; + $limit = $this->limit; + + $result = $this->limit(1)->count() > 0; + + $this->limit($limit); + + return $result; } /**
false
Other
laravel
framework
37ebc7ecc693405a717239ca30e0586d0a71e4d3.json
Remove "fresh" command.
src/Illuminate/Foundation/Console/FreshCommand.php
@@ -1,122 +0,0 @@ -<?php namespace Illuminate\Foundation\Console; - -use Illuminate\Console\Command; -use Illuminate\Filesystem\Filesystem; - -class FreshCommand extends Command { - - /** - * The console command name. - * - * @var string - */ - protected $name = 'fresh'; - - /** - * The console command description. - * - * @var string - */ - protected $description = "Remove some of Laravel's scaffolding"; - - /** - * The filesystem instance. - * - * @var \Illuminate\Filesystem\Filesystem - */ - protected $files; - - /** - * Create a new command instance. - * - * @param \Illuminate\Filesystem\Filesystem $files - * @return void - */ - public function __construct(Filesystem $files) - { - parent::__construct(); - - $this->files = $files; - } - - /** - * Execute the console command. - * - * @return void - */ - public function fire() - { - foreach ($this->getFiles() as $file) - { - $this->files->delete($file); - - $this->line('<info>Removed File:</info> '.$file); - } - - foreach ($this->getDirectories() as $directory) - { - $this->files->deleteDirectory($directory); - - $this->line('<comment>Removed Directory:</comment> '.$directory); - } - - foreach ($this->getStubs() as $stub => $path) - { - $this->files->put($path, $this->files->get(__DIR__.'/stubs/fresh/'.$stub)); - } - - $this->info('Scaffolding Removed!'); - } - - /** - * Get the files that should be deleted. - * - * @return array - */ - protected function getFiles() - { - return [ - base_path('.bowerrc'), - base_path('bower.json'), - base_path('gulpfile.js'), - base_path('package.json'), - base_path('views/dashboard.blade.php'), - app_path('Http/Controllers/HomeController.php'), - ]; - } - - /** - * Get the directories that should be deleted. - * - * @return array - */ - protected function getDirectories() - { - return [ - public_path('js'), - public_path('css'), - base_path('assets'), - base_path('views/auth'), - base_path('views/emails'), - base_path('views/layouts'), - base_path('views/partials'), - app_path('Http/Requests/Auth'), - app_path('Http/Controllers/Auth'), - ]; - } - - /** - * Get the stubs to copy. - * - * @return array - */ - protected function getStubs() - { - return [ - 'routes.stub' => app_path('Http/routes.php'), - 'view.stub' => base_path('views/welcome.blade.php'), - 'welcome.stub' => app_path('Http/Controllers/WelcomeController.php'), - ]; - } - -}
true
Other
laravel
framework
37ebc7ecc693405a717239ca30e0586d0a71e4d3.json
Remove "fresh" command.
src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php
@@ -3,7 +3,6 @@ use Illuminate\Support\ServiceProvider; use Illuminate\Foundation\Console\UpCommand; use Illuminate\Foundation\Console\DownCommand; -use Illuminate\Foundation\Console\FreshCommand; use Illuminate\Foundation\Console\TinkerCommand; use Illuminate\Foundation\Console\AppNameCommand; use Illuminate\Foundation\Console\OptimizeCommand; @@ -40,7 +39,6 @@ class ArtisanServiceProvider extends ServiceProvider { 'Down' => 'command.down', 'Environment' => 'command.environment', 'EventScan' => 'command.event.scan', - 'Fresh' => 'command.fresh', 'KeyGenerate' => 'command.key.generate', 'Optimize' => 'command.optimize', 'ProviderMake' => 'command.provider.make', @@ -148,19 +146,6 @@ protected function registerEventScanCommand() }); } - /** - * Register the command. - * - * @return void - */ - protected function registerFreshCommand() - { - $this->app->singleton('command.fresh', function($app) - { - return new FreshCommand($app['files']); - }); - } - /** * Register the command. *
true
Other
laravel
framework
0c57feea7c44a09fee1ccf600b3525e743e57b38.json
Add sanitization to form requests
src/Illuminate/Foundation/Console/stubs/request.stub
@@ -16,6 +16,16 @@ class {{class}} extends Request { ]; } + /** + * Get the sanitized input for the request. + * + * @return array + */ + public function sanitize() + { + return $this->all(); + } + /** * Determine if the user is authorized to make this request. *
true
Other
laravel
framework
0c57feea7c44a09fee1ccf600b3525e743e57b38.json
Add sanitization to form requests
src/Illuminate/Foundation/Http/FormRequest.php
@@ -29,6 +29,13 @@ class FormRequest extends Request implements ValidatesWhenResolved { */ protected $redirector; + /** + * The sanitized input. + * + * @var array + */ + protected $sanitized; + /** * The URI to redirect to if validation fails. * @@ -79,20 +86,39 @@ protected function getValidatorInstance() } return $factory->make( - $this->formatInput(), $this->container->call([$this, 'rules']), $this->messages() + $this->sanitizeInput(), $this->container->call([$this, 'rules']), $this->messages() ); } /** - * Get the input that should be fed to the validator. + * Sanitize the input. * * @return array */ - protected function formatInput() + protected function sanitizeInput() { + if (method_exists($this, 'sanitize')) + { + return $this->sanitized = $this->container->call([$this, 'sanitize']); + } + return $this->all(); } + /** + * Get sanitized input. + * + * @param string $key + * @param mixed $default + * @return mixed + */ + public function sanitized($key = null, $default = null) + { + $input = is_null($this->sanitized) ? $this->all() : $this->sanitized; + + return array_get($input, $key, $default); + } + /** * Handle a failed validation attempt. *
true
Other
laravel
framework
b8961bde2a4b3f760156e0d3e970fec795ebc4db.json
Tweak a few variables.
src/Illuminate/Foundation/Http/FormRequest.php
@@ -51,18 +51,18 @@ class FormRequest extends Request implements ValidatesWhenResolved { protected $redirectAction; /** - * The input keys that should not be flashed on redirect. + * The key to be used for the view error bag. * - * @var array + * @var string */ - protected $dontFlash = ['password', 'password_confirmation']; - + protected $errorBag = 'default'; + /** - * The key to be used on the withErrors method. + * The input keys that should not be flashed on redirect. * - * @var string + * @var array */ - protected $errorsKey = 'default'; + protected $dontFlash = ['password', 'password_confirmation']; /** * Get the validator instance for the request. @@ -146,7 +146,7 @@ public function response(array $errors) return $this->redirector->to($this->getRedirectUrl()) ->withInput($this->except($this->dontFlash)) - ->withErrors($errors, $this->errorsKey); + ->withErrors($errors, $this->errorBag); } /**
false
Other
laravel
framework
f3d3a654726a55d8b0959e136070ad80e4683a6f.json
Fix method name.
src/Illuminate/Database/Eloquent/Model.php
@@ -649,7 +649,7 @@ public static function find($id, $columns = array('*')) * * @return \Illuminate\Database\Query\Builder */ - public static function onWrite() + public static function onWriteConnection() { $instance = new static;
false
Other
laravel
framework
d4c32efcfef46c16dee9b8ee9fdc8d60071b723b.json
Change method order.
src/Illuminate/Support/helpers.php
@@ -464,6 +464,39 @@ function ends_with($haystack, $needles) } } +if ( ! function_exists('env')) +{ + /** + * Gets the value of an environment variable. Supports boolean, empty and null. + * + * @param string $key + * @return mixed + */ + function env($key) + { + $value = getenv($key); + + if ($value === 'true' || $value === '(true)') + { + $value = true; + } + elseif ($value === 'false' || $value === '(false)') + { + $value = false; + } + elseif ($value === '(null)') + { + $value = null; + } + elseif ($value === '(empty)') + { + $value = ''; + } + + return $value; + } +} + if ( ! function_exists('head')) { /** @@ -759,36 +792,3 @@ function with($object) return $object; } } - -if ( ! function_exists('env')) -{ - /** - * Gets the value of an environment variable. Supports boolean, empty and null. - * - * @param string $key - * @return mixed - */ - function env($key) - { - $value = getenv($key); - - if ($value === 'true' || $value === '(true)') - { - $value = true; - } - elseif ($value === 'false' || $value === '(false)') - { - $value = false; - } - elseif ($value === '(null)') - { - $value = null; - } - elseif ($value === '(empty)') - { - $value = ''; - } - - return $value; - } -}
false
Other
laravel
framework
55517bc37843ae70879a8ed3bb38a5e3f598fd66.json
Add cache events
src/Illuminate/Cache/CacheManager.php
@@ -155,7 +155,14 @@ public function setPrefix($name) */ protected function repository(StoreInterface $store) { - return new Repository($store); + $repository = new Repository($store); + + if ($this->app->bound('events')) + { + $repository->setEventDispatcher($this->app['events']); + } + + return $repository; } /**
true
Other
laravel
framework
55517bc37843ae70879a8ed3bb38a5e3f598fd66.json
Add cache events
src/Illuminate/Cache/Repository.php
@@ -4,6 +4,7 @@ use DateTime; use ArrayAccess; use Carbon\Carbon; +use Illuminate\Events\Dispatcher; use Illuminate\Support\Traits\MacroableTrait; use Illuminate\Contracts\Cache\Repository as CacheContract; @@ -20,6 +21,13 @@ class Repository implements CacheContract, ArrayAccess { */ protected $store; + /** + * The cache store implementation. + * + * @var \Illuminate\Events\Dispatcher + */ + protected $events; + /** * The default number of minutes to store items. * @@ -37,6 +45,32 @@ public function __construct(StoreInterface $store) $this->store = $store; } + /** + * Set the event dispatcher instance. + * + * @param \Illuminate\Events\Dispatcher + * @return void + */ + public function setEventDispatcher(Dispatcher $events) + { + $this->events = $events; + } + + /** + * Fire an event for this cache instance. + * + * @param string $event + * @param array $payload + * @return void + */ + protected function fireCacheEvent($event, $payload) + { + if (isset($this->events)) + { + $this->events->fire('cache.'.$event, $payload); + } + } + /** * Determine if an item exists in the cache. * @@ -59,7 +93,18 @@ public function get($key, $default = null) { $value = $this->store->get($key); - return ! is_null($value) ? $value : value($default); + if (is_null($value)) + { + $this->fireCacheEvent('missed', [$key]); + + $value = value($default); + } + else + { + $this->fireCacheEvent('hit', [$key, $value]); + } + + return $value; } /** @@ -93,6 +138,8 @@ public function put($key, $value, $minutes) if ( ! is_null($minutes)) { $this->store->put($key, $value, $minutes); + + $this->fireCacheEvent('write', [$key, $value, $minutes]); } } @@ -114,6 +161,20 @@ public function add($key, $value, $minutes) return false; } + /** + * Store an item in the cache indefinitely. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function forever($key, $value) + { + $this->store->forever($key, $value); + + $this->fireCacheEvent('write', [$key, $value, 0]); + } + /** * Get an item from the cache, or store the default value. * @@ -180,6 +241,8 @@ public function rememberForever($key, Closure $callback) public function forget($key) { return $this->store->forget($key); + + $this->fireCacheEvent('delete', [$key]); } /**
true
Other
laravel
framework
55517bc37843ae70879a8ed3bb38a5e3f598fd66.json
Add cache events
tests/Cache/CacheRepositoryTest.php
@@ -85,7 +85,12 @@ public function testRegisterMacroWithNonStaticCall() protected function getRepository() { - return new Illuminate\Cache\Repository(m::mock('Illuminate\Cache\StoreInterface')); + $dispatcher = new \Illuminate\Events\Dispatcher(m::mock('Illuminate\Container\Container')); + $repository = new Illuminate\Cache\Repository(m::mock('Illuminate\Cache\StoreInterface')); + + $repository->setEventDispatcher($dispatcher); + + return $repository; } }
true
Other
laravel
framework
eb9d915f3d3b0e01d784b5f844ceaf0625fa6c47.json
adjust coding style
src/Illuminate/Database/Query/Builder.php
@@ -1363,7 +1363,8 @@ public function getFresh($columns = array('*')) */ protected function runSelect() { - if ($this->useWritePdo) { + if ($this->useWritePdo) + { return $this->connection->select($this->toSql(), $this->getBindings(), false); }
true
Other
laravel
framework
eb9d915f3d3b0e01d784b5f844ceaf0625fa6c47.json
adjust coding style
tests/Database/DatabaseQueryBuilderTest.php
@@ -1267,6 +1267,7 @@ protected function getSqlServerBuilder() return new Builder(m::mock('Illuminate\Database\ConnectionInterface'), $grammar, $processor); } + protected function getMySqlBuilderWithProcessor() { $grammar = new Illuminate\Database\Query\Grammars\MySqlGrammar;
true
Other
laravel
framework
2cb7711ed9179d3bb34b3860a0ebc9319c610da7.json
Set $options as an empty array per default
src/Illuminate/Database/Eloquent/Model.php
@@ -1467,9 +1467,10 @@ protected function finishSave(array $options) * Perform a model update operation. * * @param \Illuminate\Database\Eloquent\Builder $query + * @param array $options * @return bool|null */ - protected function performUpdate(Builder $query, array $options) + protected function performUpdate(Builder $query, array $options = []) { $dirty = $this->getDirty(); @@ -1511,9 +1512,10 @@ protected function performUpdate(Builder $query, array $options) * Perform a model insert operation. * * @param \Illuminate\Database\Eloquent\Builder $query + * @param array $options * @return bool */ - protected function performInsert(Builder $query, array $options) + protected function performInsert(Builder $query, array $options = []) { if ($this->fireModelEvent('creating') === false) return false;
false
Other
laravel
framework
3f521ad09d4bb3fcfd2dd17b8ae801859c27066d.json
Add Caron to require-dev
src/Illuminate/Console/composer.json
@@ -15,7 +15,8 @@ }, "require-dev": { "mtdowling/cron-expression": "~1.0", - "symfony/process": "2.6.*" + "symfony/process": "2.6.*", + "nesbot/carbon": "~1.0" }, "autoload": { "psr-4": {
false
Other
laravel
framework
b0035ff17ea0fdd86997cc8ab4024a5b67377226.json
add test cases
tests/Database/DatabaseEloquentModelTest.php
@@ -105,6 +105,11 @@ public function testFindMethodCallsQueryBuilderCorrectly() $this->assertEquals('foo', $result); } + public function testFindMethodUseWritePdo() + { + $result = EloquentModelFindWithWritePdoStub::onWrite()->find(1); + } + /** * @expectedException Illuminate\Database\Eloquent\ModelNotFoundException */ @@ -1049,6 +1054,17 @@ public function newQuery() } } +class EloquentModelFindWithWritePdoStub extends Illuminate\Database\Eloquent\Model { + public function newQuery() + { + $mock = m::mock('Illuminate\Database\Eloquent\Builder'); + $mock->shouldReceive('useWritePdo')->once()->andReturnSelf(); + $mock->shouldReceive('find')->once()->with(1)->andReturn('foo'); + + return $mock; + } +} + class EloquentModelFindNotFoundStub extends Illuminate\Database\Eloquent\Model { public function newQuery() {
true
Other
laravel
framework
b0035ff17ea0fdd86997cc8ab4024a5b67377226.json
add test cases
tests/Database/DatabaseQueryBuilderTest.php
@@ -20,6 +20,20 @@ public function testBasicSelect() } + public function testBasicSelectUseWritePdo() + { + $builder = $this->getMySqlBuilderWithProcessor(); + $builder->getConnection()->shouldReceive('select')->once() + ->with('select * from `users`', array(), false); + $builder->useWritePdo()->select('*')->from('users')->get(); + + $builder = $this->getMySqlBuilderWithProcessor(); + $builder->getConnection()->shouldReceive('select')->once() + ->with('select * from `users`', array()); + $builder->select('*')->from('users')->get(); + } + + public function testBasicTableWrappingProtectsQuotationMarks() { $builder = $this->getBuilder(); @@ -1253,4 +1267,11 @@ protected function getSqlServerBuilder() return new Builder(m::mock('Illuminate\Database\ConnectionInterface'), $grammar, $processor); } + protected function getMySqlBuilderWithProcessor() + { + $grammar = new Illuminate\Database\Query\Grammars\MySqlGrammar; + $processor = new Illuminate\Database\Query\Processors\MySqlProcessor; + return new Builder(m::mock('Illuminate\Database\ConnectionInterface'), $grammar, $processor); + } + }
true
Other
laravel
framework
58ad8577c24886e4e6ef85554c4f598dada8a403.json
add useWritePdo for select query
src/Illuminate/Database/Query/Builder.php
@@ -180,6 +180,13 @@ class Builder { 'rlike', 'regexp', 'not regexp', ); + /** + * Whether use write pdo for select. + * + * @var bool + */ + protected $useWritePdo = false; + /** * Create a new query builder instance. * @@ -1356,6 +1363,10 @@ public function getFresh($columns = array('*')) */ protected function runSelect() { + if ($this->useWritePdo) { + return $this->connection->select($this->toSql(), $this->getBindings(), false); + } + return $this->connection->select($this->toSql(), $this->getBindings()); } @@ -2092,6 +2103,13 @@ public function getGrammar() return $this->grammar; } + public function useWritePdo() + { + $this->useWritePdo = true; + + return $this; + } + /** * Handle dynamic method calls into the method. *
false
Other
laravel
framework
f53b52c8a177e20e3947212a26798dedd1346be6.json
Change some paths.
src/Illuminate/Foundation/Application.php
@@ -231,7 +231,7 @@ public function databasePath() */ public function langPath() { - return $this->basePath.'/resources/lang'; + return $this->basePath.'/lang'; } /**
true
Other
laravel
framework
f53b52c8a177e20e3947212a26798dedd1346be6.json
Change some paths.
src/Illuminate/Foundation/Console/FreshCommand.php
@@ -80,8 +80,8 @@ protected function getFiles() base_path('bower.json'), base_path('gulpfile.js'), base_path('package.json'), + base_path('views/dashboard.blade.php'), app_path('Http/Controllers/HomeController.php'), - base_path('resources/views/dashboard.blade.php'), ]; } @@ -95,13 +95,13 @@ protected function getDirectories() return [ public_path('js'), public_path('css'), - base_path('resources/assets'), + base_path('assets'), + base_path('views/auth'), + base_path('views/emails'), + base_path('views/layouts'), + base_path('views/partials'), app_path('Http/Requests/Auth'), app_path('Http/Controllers/Auth'), - base_path('resources/views/auth'), - base_path('resources/views/emails'), - base_path('resources/views/layouts'), - base_path('resources/views/partials'), ]; } @@ -114,7 +114,7 @@ protected function getStubs() { return [ 'routes.stub' => app_path('Http/routes.php'), - 'view.stub' => base_path('resources/views/welcome.blade.php'), + 'view.stub' => base_path('views/welcome.blade.php'), 'welcome.stub' => app_path('Http/Controllers/WelcomeController.php'), ]; }
true
Other
laravel
framework
6bae9b5b2c60767d91ed18f198859998af4d81f4.json
Remove unneeded tests.
tests/Database/DatabaseMigrationMakeCommandTest.php
@@ -35,28 +35,6 @@ public function testBasicCreateGivesCreatorProperArgumentsWhenTableIsSet() } - public function testPackagePathsMayBeUsed() - { - $command = new DatabaseMigrationMakeCommandTestStub($creator = m::mock('Illuminate\Database\Migrations\MigrationCreator'), __DIR__.'/vendor'); - $app = new Illuminate\Container\Container; - $app['path.database'] = __DIR__; - $command->setLaravel($app); - $creator->shouldReceive('create')->once()->with('create_foo', __DIR__.'/vendor/bar/src/migrations', null, false); - - $this->runCommand($command, array('name' => 'create_foo', '--package' => 'bar')); - } - - - public function testPackageFallsBackToVendorDirWhenNotExplicit() - { - $command = new DatabaseMigrationMakeCommandTestStub($creator = m::mock('Illuminate\Database\Migrations\MigrationCreator'), __DIR__.'/vendor'); - $command->setLaravel(new Illuminate\Container\Container); - $creator->shouldReceive('create')->once()->with('create_foo', __DIR__.'/vendor/foo/bar/src/migrations', null, false); - - $this->runCommand($command, array('name' => 'create_foo', '--package' => 'foo/bar')); - } - - protected function runCommand($command, $input = array()) { return $command->run(new Symfony\Component\Console\Input\ArrayInput($input), new Symfony\Component\Console\Output\NullOutput);
true
Other
laravel
framework
6bae9b5b2c60767d91ed18f198859998af4d81f4.json
Remove unneeded tests.
tests/Database/DatabaseMigrationMigrateCommandTest.php
@@ -41,32 +41,6 @@ public function testMigrationRepositoryCreatedWhenNecessary() } - public function testPackageIsRespectedWhenMigrating() - { - $command = new MigrateCommand($migrator = m::mock('Illuminate\Database\Migrations\Migrator'), __DIR__.'/vendor'); - $command->setLaravel(new ApplicationDatabaseMigrationStub()); - $migrator->shouldReceive('setConnection')->once()->with(null); - $migrator->shouldReceive('run')->once()->with(__DIR__.'/vendor/bar/src/migrations', false); - $migrator->shouldReceive('getNotes')->andReturn(array()); - $migrator->shouldReceive('repositoryExists')->once()->andReturn(true); - - $this->runCommand($command, array('--package' => 'bar')); - } - - - public function testVendorPackageIsRespectedWhenMigrating() - { - $command = new MigrateCommand($migrator = m::mock('Illuminate\Database\Migrations\Migrator'), __DIR__.'/vendor'); - $command->setLaravel(new ApplicationDatabaseMigrationStub()); - $migrator->shouldReceive('setConnection')->once()->with(null); - $migrator->shouldReceive('run')->once()->with(__DIR__.'/vendor/foo/bar/src/migrations', false); - $migrator->shouldReceive('getNotes')->andReturn(array()); - $migrator->shouldReceive('repositoryExists')->once()->andReturn(true); - - $this->runCommand($command, array('--package' => 'foo/bar')); - } - - public function testTheCommandMayBePretended() { $command = new MigrateCommand($migrator = m::mock('Illuminate\Database\Migrations\Migrator'), __DIR__.'/vendor');
true
Other
laravel
framework
6bae9b5b2c60767d91ed18f198859998af4d81f4.json
Remove unneeded tests.
tests/Support/SupportServiceProviderTest.php
@@ -1,21 +0,0 @@ -<?php - -class SupportServiceProviderTest extends PHPUnit_Framework_TestCase { - - public static function setUpBeforeClass() - { - require_once __DIR__.'/stubs/providers/SuperProvider.php'; - require_once __DIR__.'/stubs/providers/SuperSuperProvider.php'; - } - - - public function testPackageNameCanBeGuessed() - { - $superProvider = new SuperProvider(null); - $this->assertEquals(realpath(__DIR__.'/'), $superProvider->guessPackagePath()); - - $superSuperProvider = new SuperSuperProvider(null); - $this->assertEquals(realpath(__DIR__.'/'), $superSuperProvider->guessPackagePath()); - } - -}
true
Other
laravel
framework
1b9562f0c5a8b9ad8287fa8c7350bf3f9802628d.json
Fix composer file.
composer.json
@@ -62,7 +62,7 @@ "illuminate/support": "self.version", "illuminate/translation": "self.version", "illuminate/validation": "self.version", - "illuminate/view": "self.version", + "illuminate/view": "self.version" }, "require-dev": { "aws/aws-sdk-php": "~2.7",
false
Other
laravel
framework
68cd74307e98aa7a41101d5b94e11158031e7261.json
Change Flysystem version.
composer.json
@@ -18,7 +18,7 @@ "doctrine/annotations": "~1.0", "ircmaxell/password-compat": "~1.0", "jeremeamia/superclosure": "~1.0.1", - "league/flysystem": "0.6.*", + "league/flysystem": "~1.0", "monolog/monolog": "~1.6", "mtdowling/cron-expression": "~1.0", "nesbot/carbon": "~1.0",
false
Other
laravel
framework
08c89f5124dac73e5283c11ff78f2b2dd9e9535f.json
Add ArrayAccess support to data_get
src/Illuminate/Support/helpers.php
@@ -402,6 +402,15 @@ function data_get($target, $key, $default = null) $target = $target[$segment]; } + elseif ($target instanceof ArrayAccess) + { + if ( ! isset($target[$segment])) + { + return value($default); + } + + $target = $target[$segment]; + } elseif (is_object($target)) { if ( ! isset($target->{$segment}))
true
Other
laravel
framework
08c89f5124dac73e5283c11ff78f2b2dd9e9535f.json
Add ArrayAccess support to data_get
tests/Support/SupportHelpersTest.php
@@ -230,12 +230,19 @@ public function testDataGet() { $object = (object) array('users' => array('name' => array('Taylor', 'Otwell'))); $array = array((object) array('users' => array((object) array('name' => 'Taylor')))); + $arrayAccess = new SupportTestArrayAccess(['price' => 56, 'user' => new SupportTestArrayAccess(['name' => 'John'])]); $this->assertEquals('Taylor', data_get($object, 'users.name.0')); $this->assertEquals('Taylor', data_get($array, '0.users.0.name')); $this->assertNull(data_get($array, '0.users.3')); $this->assertEquals('Not found', data_get($array, '0.users.3', 'Not found')); $this->assertEquals('Not found', data_get($array, '0.users.3', function (){ return 'Not found'; })); + $this->assertEquals(56, data_get($arrayAccess, 'price')); + $this->assertEquals('John', data_get($arrayAccess, 'user.name')); + $this->assertEquals('void', data_get($arrayAccess, 'foo', 'void')); + $this->assertEquals('void', data_get($arrayAccess, 'user.foo', 'void')); + $this->assertNull(data_get($arrayAccess, 'foo')); + $this->assertNull(data_get($arrayAccess, 'user.foo')); } @@ -292,3 +299,19 @@ class SupportTestClassOne { } class SupportTestClassTwo extends SupportTestClassOne {} + +class SupportTestArrayAccess implements ArrayAccess { + + protected $attributes = []; + + public function __construct ($attributes = []){ $this->attributes = $attributes; } + + public function offsetExists ($offset){ return isset($this->attributes[$offset]); } + + public function offsetGet ($offset){ return $this->attributes[$offset]; } + + public function offsetSet ($offset, $value){ $this->attributes[$offset] = $value; } + + public function offsetUnset ($offset){ unset($this->attributes[$offset]); } + +}
true
Other
laravel
framework
fbecdfb27afa2ab49e4e98a7e14edf9787f1ccad.json
Add some features to error handling.
src/Illuminate/Foundation/Exceptions/Handler.php
@@ -2,6 +2,7 @@ use Exception; use Psr\Log\LoggerInterface; +use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\Debug\ExceptionHandler as SymfonyDisplayer; use Illuminate\Contracts\Debug\ExceptionHandler as ExceptionHandlerContract; @@ -14,6 +15,13 @@ class Handler implements ExceptionHandlerContract { */ protected $log; + /** + * A list of the exception types that should not be reported. + * + * @var array + */ + protected $dontReport = []; + /** * Create a new exception handler instance. * @@ -33,6 +41,12 @@ public function __construct(LoggerInterface $log) */ public function report(Exception $e) { + foreach ($this->dontReport as $type) + { + if ($e instanceof $type) + return; + } + $this->log->error((string) $e); } @@ -60,4 +74,33 @@ public function renderForConsole($output, Exception $e) $output->writeln((string) $e); } + /** + * Render the given HttpException. + * + * @param \Symfony\Component\HttpKernel\Exception\HttpException $e + * @return \Symfony\Component\HttpFoundation\Response + */ + protected function renderHttpException(HttpException $e) + { + if (view()->exists('errors.'.$e->getStatusCode())) + { + return response()->view('errors.'.$e->getStatusCode(), [], $e->getStatusCode()); + } + else + { + return (new SymfonyDisplayer(config('app.debug')))->createResponse($e); + } + } + + /** + * Determine if the given exception is an HTTP exception. + * + * @param \Exception $e + * @return bool + */ + protected function isHttpException(Exception $e) + { + return $e instanceof HttpException; + } + }
true
Other
laravel
framework
fbecdfb27afa2ab49e4e98a7e14edf9787f1ccad.json
Add some features to error handling.
src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php
@@ -1,9 +1,9 @@ <?php namespace Illuminate\Foundation\Http\Middleware; use Closure; -use Illuminate\Http\Response; use Illuminate\Contracts\Routing\Middleware; use Illuminate\Contracts\Foundation\Application; +use Symfony\Component\HttpKernel\Exception\HttpException; class CheckForMaintenanceMode implements Middleware { @@ -36,7 +36,7 @@ public function handle($request, Closure $next) { if ($this->app->isDownForMaintenance()) { - return new Response(view('framework.maintenance'), 503); + throw new HttpException(503); } return $next($request);
true
Other
laravel
framework
d5c5f1306dd99c3cf606702b5b7ef51d6a73c752.json
Remove empty brackets from log files The current log files generated by Laravel all show empty brackets at the end of log files. We can remove these by using the $ignoreEmptyContextAndExtra parameter in the default Monolog LineFormatter. http://stackoverflow.com/questions/13968967/how-not-to-show-last-bracket-in-a-monolog-log-line
composer.json
@@ -19,7 +19,7 @@ "ircmaxell/password-compat": "~1.0", "jeremeamia/superclosure": "~1.0.1", "league/flysystem": "0.6.*", - "monolog/monolog": "~1.6", + "monolog/monolog": "~1.11", "mtdowling/cron-expression": "~1.0", "nesbot/carbon": "~1.0", "patchwork/utf8": "~1.1",
true
Other
laravel
framework
d5c5f1306dd99c3cf606702b5b7ef51d6a73c752.json
Remove empty brackets from log files The current log files generated by Laravel all show empty brackets at the end of log files. We can remove these by using the $ignoreEmptyContextAndExtra parameter in the default Monolog LineFormatter. http://stackoverflow.com/questions/13968967/how-not-to-show-last-bracket-in-a-monolog-log-line
src/Illuminate/Log/Writer.php
@@ -354,7 +354,7 @@ public function getMonolog() */ protected function getDefaultFormatter() { - return new LineFormatter(null, null, true); + return new LineFormatter(null, null, true, true); } /**
true