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
b18c7258f7ae8ba3a01a41c272cbf2f7e0b75005.json
Set incremented value on model.
tests/Database/DatabaseEloquentModelTest.php
@@ -831,6 +831,25 @@ public function testReplicateCreatesANewModelInstanceWithSameAttributeValues() } + public function testIncrementOnExistingModelCallsQueryAndSetsAttribute() + { + $model = m::mock('EloquentModelStub[newQuery]'); + $model->exists = true; + $model->id = 1; + $model->syncOriginalAttribute('id'); + $model->foo = 2; + + $model->shouldReceive('newQuery')->andReturn($query = m::mock('StdClass')); + $query->shouldReceive('where')->andReturn($query); + $query->shouldReceive('increment'); + + $model->publicIncrement('foo'); + + $this->assertEquals(3, $model->foo); + $this->assertFalse($model->isDirty()); + } + + protected function addMockConnection($model) { $model->setConnectionResolver($resolver = m::mock('Illuminate\Database\ConnectionResolverInterface')); @@ -866,6 +885,10 @@ public function setPasswordAttribute($value) { $this->attributes['password_hash'] = md5($value); } + public function publicIncrement($column, $amount = 1) + { + return $this->increment($column, $amount); + } public function belongsToStub() { return $this->belongsTo('EloquentModelSaveStub');
true
Other
laravel
framework
07b9f6c9acb9ae0c1284aff688342c7cfd321967.json
Fix property order.
src/Illuminate/Session/Store.php
@@ -73,10 +73,10 @@ class Store implements SessionInterface { */ public function __construct($name, SessionHandlerInterface $handler, $id = null) { + $this->setId($id); $this->name = $name; $this->handler = $handler; $this->metaBag = new MetadataBag; - $this->setId($id); } /**
false
Other
laravel
framework
66fdf12f0d9f5558f9b4274f36aa2872fd972a5a.json
Remove duplicate id check
src/Illuminate/Session/Store.php
@@ -76,7 +76,7 @@ public function __construct($name, SessionHandlerInterface $handler, $id = null) $this->name = $name; $this->handler = $handler; $this->metaBag = new MetadataBag; - $this->setId($id ?: $this->generateSessionId()); + $this->setId($id); } /**
false
Other
laravel
framework
76e4be8628d695aa3e1e683fb32c06addf0fa28d.json
Use array_pull for session pull
src/Illuminate/Session/Store.php
@@ -276,11 +276,7 @@ public function get($name, $default = null) */ public function pull($key, $default = null) { - $value = $this->get($key, $default); - - $this->forget($key); - - return $value; + return array_pull($this->attributes, $key, $default); } /**
false
Other
laravel
framework
c81ee6a0522fda78a12da6a0e1ef15c673dab338.json
Use cache get default value
src/Illuminate/Session/CookieSessionHandler.php
@@ -53,7 +53,7 @@ public function close() */ public function read($sessionId) { - return $this->request->cookies->get($sessionId, ''); + return $this->request->cookies->get($sessionId) ?: ''; } /**
false
Other
laravel
framework
b6407420475599f997cd0102f588de3a22a1dc7b.json
Use cache get default value
src/Illuminate/Session/CacheBasedSessionHandler.php
@@ -52,7 +52,7 @@ public function close() */ public function read($sessionId) { - return $this->cache->get($sessionId) ?: ''; + return $this->cache->get($sessionId, ''); } /**
true
Other
laravel
framework
b6407420475599f997cd0102f588de3a22a1dc7b.json
Use cache get default value
src/Illuminate/Session/CookieSessionHandler.php
@@ -53,7 +53,7 @@ public function close() */ public function read($sessionId) { - return $this->request->cookies->get($sessionId) ?: ''; + return $this->request->cookies->get($sessionId, ''); } /**
true
Other
laravel
framework
71647bb8b9f2a0ac9e98cde496751f52a660fb00.json
Remove useless space
src/Illuminate/Html/FormBuilder.php
@@ -719,7 +719,7 @@ public function submit($value = null, $options = array()) */ public function button($value = null, $options = array()) { - if ( ! array_key_exists('type', $options) ) + if ( ! array_key_exists('type', $options)) { $options['type'] = 'button'; }
false
Other
laravel
framework
bf2d81458d18579443ffd2557298ef1e8aaf7fe3.json
Fix variable name
src/Illuminate/Mail/Transport/LogTransport.php
@@ -70,7 +70,7 @@ protected function getMimeEntityString(Swift_Mime_MimeEntity $entity) foreach ($entity->getChildren() as $children) { - $string .= PHP_EOL.PHP_EOL.$this->getMimeEntityString($entity); + $string .= PHP_EOL.PHP_EOL.$this->getMimeEntityString($children); } return $string;
false
Other
laravel
framework
ad5f533d1818816a366d88ab8a1f2c47931f8284.json
Add Carbon dependencies to Queue
src/Illuminate/Queue/composer.json
@@ -13,7 +13,8 @@ "illuminate/container": "4.2.*", "illuminate/http": "4.2.*", "illuminate/support": "4.2.*", - "symfony/process": "2.5.*" + "symfony/process": "2.5.*", + "nesbot/carbon": "~1.0" }, "require-dev": { "illuminate/cache": "4.2.*",
false
Other
laravel
framework
691ae2fafe66f8acb404eb8325efdfba2f353675.json
Remove duplicate EOL
src/Illuminate/Auth/AuthServiceProvider.php
@@ -29,7 +29,6 @@ public function register() }); } - /** * Get the services provided by the provider. *
true
Other
laravel
framework
691ae2fafe66f8acb404eb8325efdfba2f353675.json
Remove duplicate EOL
src/Illuminate/Console/Command.php
@@ -221,7 +221,6 @@ public function askWithCompletion($question, array $choices, $default = null) return $helper->ask($this->input, $this->output, $question); } - /** * Prompt the user for input but hide the answer from the console. *
true
Other
laravel
framework
691ae2fafe66f8acb404eb8325efdfba2f353675.json
Remove duplicate EOL
src/Illuminate/Database/Connectors/PostgresConnector.php
@@ -16,7 +16,6 @@ class PostgresConnector extends Connector implements ConnectorInterface { PDO::ATTR_STRINGIFY_FETCHES => false, ); - /** * Establish a database connection. *
true
Other
laravel
framework
691ae2fafe66f8acb404eb8325efdfba2f353675.json
Remove duplicate EOL
src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php
@@ -231,7 +231,6 @@ protected function typeChar(Fluent $column) return "nchar({$column->length})"; } - /** * Create the column definition for a string type. *
true
Other
laravel
framework
691ae2fafe66f8acb404eb8325efdfba2f353675.json
Remove duplicate EOL
src/Illuminate/Routing/Console/MakeControllerCommand.php
@@ -160,7 +160,6 @@ protected function getArguments() ); } - /** * Get the console command options. *
true
Other
laravel
framework
691ae2fafe66f8acb404eb8325efdfba2f353675.json
Remove duplicate EOL
src/Illuminate/Session/SessionManager.php
@@ -130,7 +130,6 @@ protected function createRedisDriver() return $this->buildSession($handler); } - /** * Create an instance of a cache driven driver. *
true
Other
laravel
framework
cdef186931e8137370f11ddf06ae1a5a9eb4aeab.json
Remove duplicate code
src/Illuminate/Validation/Validator.php
@@ -913,7 +913,7 @@ protected function validateIn($attribute, $value, $parameters) */ protected function validateNotIn($attribute, $value, $parameters) { - return ! in_array((string) $value, $parameters); + return ! $this->validateIn($attribute, $value, $parameters); } /** @@ -1722,12 +1722,7 @@ protected function replaceIn($message, $attribute, $rule, $parameters) */ protected function replaceNotIn($message, $attribute, $rule, $parameters) { - foreach ($parameters as &$parameter) - { - $parameter = $this->getDisplayableValue($attribute, $parameter); - } - - return str_replace(':values', implode(', ', $parameters), $message); + return $this->replaceIn($message, $attribute, $rule, $parameters); } /** @@ -1771,9 +1766,7 @@ protected function replaceRequiredWith($message, $attribute, $rule, $parameters) */ protected function replaceRequiredWithout($message, $attribute, $rule, $parameters) { - $parameters = $this->getAttributeList($parameters); - - return str_replace(':values', implode(' / ', $parameters), $message); + return $this->replaceRequiredWith($message, $attribute, $rule, $parameters); } /** @@ -1787,9 +1780,7 @@ protected function replaceRequiredWithout($message, $attribute, $rule, $paramete */ protected function replaceRequiredWithoutAll($message, $attribute, $rule, $parameters) { - $parameters = $this->getAttributeList($parameters); - - return str_replace(':values', implode(' / ', $parameters), $message); + return $this->replaceRequiredWith($message, $attribute, $rule, $parameters); } /** @@ -1835,7 +1826,7 @@ protected function replaceSame($message, $attribute, $rule, $parameters) */ protected function replaceDifferent($message, $attribute, $rule, $parameters) { - return str_replace(':other', $this->getAttribute($parameters[0]), $message); + return $this->replaceSame($message, $attribute, $rule, $parameters); } /** @@ -1884,14 +1875,7 @@ protected function replaceBefore($message, $attribute, $rule, $parameters) */ protected function replaceAfter($message, $attribute, $rule, $parameters) { - if ( ! (strtotime($parameters[0]))) - { - return str_replace(':date', $this->getAttribute($parameters[0]), $message); - } - else - { - return str_replace(':date', $parameters[0], $message); - } + return $this->replaceBefore($message, $attribute, $rule, $parameters); } /** @@ -2277,9 +2261,7 @@ public function messages() */ public function errors() { - if ( ! $this->messages) $this->passes(); - - return $this->messages; + return $this->messages(); } /**
false
Other
laravel
framework
2d7c8c8bc29ca32c0fd474f82be3f48b97e6d153.json
Fix docblock for MetadataBag namespace
src/Illuminate/Session/Store.php
@@ -38,7 +38,7 @@ class Store implements SessionInterface { /** * The meta-data bag instance. * - * @var \Symfony\Component\Session\Storage\MetadataBag + * @var \Symfony\Component\HttpFoundation\Session\Storage\MetadataBag */ protected $metaBag;
false
Other
laravel
framework
031bb63c55b685c65d99c2590e60f6d1d690584b.json
Add ability to add and remove observable events
src/Illuminate/Database/Eloquent/Model.php
@@ -1261,6 +1261,54 @@ public function getObservableEvents() ); } + /** + * Set the observable event names. + * + * @return void + */ + public function setObservableEvents(array $observables) + { + $this->observables = $observables; + } + + /** + * Add an observable event name. + * + * @param mixed $observables + * @return void + */ + public function addObservableEvents($observables) + { + $observables = is_array($observables) ? $observables : func_get_args(); + + foreach ($observables as $observable) + { + if ( ! in_array($observable, $this->observables)) + { + $this->observables[] = $observable; + } + } + } + + /** + * Remove an observable event name. + * + * @param mixed $observables + * @return void + */ + public function removeObservableEvents($observables) + { + $observables = is_array($observables) ? $observables : func_get_args(); + + foreach ($observables as $observable) + { + if ($index = array_search($observable, $this->observables) !== false) + { + unset($this->observables[$index]); + } + } + } + /** * Increment a column's value by a given amount. *
true
Other
laravel
framework
031bb63c55b685c65d99c2590e60f6d1d690584b.json
Add ability to add and remove observable events
tests/Database/DatabaseEloquentModelTest.php
@@ -774,6 +774,32 @@ public function testModelObserversCanBeAttachedToModels() } + public function testSetObservableEvents() + { + $class = new EloquentModelStub; + $class->setObservableEvents(array('foo')); + + $this->assertContains('foo', $class->getObservableEvents()); + } + + public function testAddObservableEvent() + { + $class = new EloquentModelStub; + $class->addObservableEvents('foo'); + + $this->assertContains('foo', $class->getObservableEvents()); + } + + public function testRemoveObservableEvent() + { + $class = new EloquentModelStub; + $class->setObservableEvents(array('foo', 'bar')); + $class->removeObservableEvents('bar'); + + $this->assertNotContains('bar', $class->getObservableEvents()); + } + + /** * @expectedException LogicException */
true
Other
laravel
framework
7bac330c68a5ad23f24918d310fd55722d5f1d00.json
Fix method order.
src/Illuminate/Pagination/Paginator.php
@@ -103,8 +103,8 @@ public function __construct(Factory $factory, array $items, $total, $perPage = n if (is_null($perPage)) { $this->perPage = (int) $total; - $this->items = array_slice($items, 0, $this->perPage); $this->hasMore = count($items) > $this->perPage; + $this->items = array_slice($items, 0, $this->perPage); } else {
false
Other
laravel
framework
4e5a70019d22e7415d512c3ef5df2f29bd587419.json
Fix method order.
src/Illuminate/Support/Collection.php
@@ -409,18 +409,6 @@ public function random($amount = 1) return is_array($keys) ? array_intersect_key($this->items, array_flip($keys)) : $this->items[$keys]; } - - /** - * Shuffle the items in the collection. - * - * @return \Illuminate\Support\Collection - */ - public function shuffle() - { - shuffle($this->items); - - return $this; - } /** * Reduce the collection to a single value. @@ -494,6 +482,18 @@ public function shift() return array_shift($this->items); } + /** + * Shuffle the items in the collection. + * + * @return \Illuminate\Support\Collection + */ + public function shuffle() + { + shuffle($this->items); + + return $this; + } + /** * Slice the underlying collection array. *
false
Other
laravel
framework
36eec89228d87667607ed25aede5b1d25a4f61de.json
Remove unneeded calls to with
src/Illuminate/Cookie/CookieServiceProvider.php
@@ -15,7 +15,7 @@ public function register() { $config = $app['config']['session']; - return with(new CookieJar)->setDefaultPathAndDomain($config['path'], $config['domain']); + return (new CookieJar)->setDefaultPathAndDomain($config['path'], $config['domain']); }); } }
true
Other
laravel
framework
36eec89228d87667607ed25aede5b1d25a4f61de.json
Remove unneeded calls to with
src/Illuminate/Database/Eloquent/Builder.php
@@ -111,7 +111,7 @@ public function findOrFail($id, $columns = array('*')) { if ( ! is_null($model = $this->find($id, $columns))) return $model; - throw with(new ModelNotFoundException)->setModel(get_class($this->model)); + throw (new ModelNotFoundException)->setModel(get_class($this->model)); } /** @@ -137,7 +137,7 @@ public function firstOrFail($columns = array('*')) { if ( ! is_null($model = $this->first($columns))) return $model; - throw with(new ModelNotFoundException)->setModel(get_class($this->model)); + throw (new ModelNotFoundException)->setModel(get_class($this->model)); } /**
true
Other
laravel
framework
36eec89228d87667607ed25aede5b1d25a4f61de.json
Remove unneeded calls to with
src/Illuminate/Database/Eloquent/Model.php
@@ -594,7 +594,7 @@ protected static function firstByAttributes($attributes) */ public static function query() { - return with(new static)->newQuery(); + return (new static)->newQuery(); } /** @@ -671,7 +671,7 @@ public static function findOrFail($id, $columns = array('*')) { if ( ! is_null($model = static::find($id, $columns))) return $model; - throw with(new ModelNotFoundException)->setModel(get_called_class()); + throw (new ModelNotFoundException)->setModel(get_called_class()); } /**
true
Other
laravel
framework
36eec89228d87667607ed25aede5b1d25a4f61de.json
Remove unneeded calls to with
src/Illuminate/Database/Eloquent/SoftDeletingTrait.php
@@ -110,7 +110,7 @@ public function trashed() */ public static function withTrashed() { - return with(new static)->newQueryWithoutScope(new SoftDeletingScope); + return (new static)->newQueryWithoutScope(new SoftDeletingScope); } /**
true
Other
laravel
framework
36eec89228d87667607ed25aede5b1d25a4f61de.json
Remove unneeded calls to with
src/Illuminate/Encryption/Encrypter.php
@@ -155,7 +155,7 @@ protected function getJsonPayload($payload) */ protected function validMac(array $payload) { - $bytes = with(new SecureRandom)->nextBytes(16); + $bytes = (new SecureRandom)->nextBytes(16); $calcMac = hash_hmac('sha256', $this->hash($payload['iv'], $payload['value']), $bytes, true);
true
Other
laravel
framework
36eec89228d87667607ed25aede5b1d25a4f61de.json
Remove unneeded calls to with
src/Illuminate/Foundation/Application.php
@@ -259,7 +259,7 @@ public function detectEnvironment($envs) { $args = isset($_SERVER['argv']) ? $_SERVER['argv'] : null; - return $this['env'] = with(new EnvironmentDetector())->detect($envs, $args); + return $this['env'] = (new EnvironmentDetector())->detect($envs, $args); } /** @@ -619,10 +619,10 @@ protected function getStackedClient() { $sessionReject = $this->bound('session.reject') ? $this['session.reject'] : null; - $client = with(new \Stack\Builder) - ->push('Illuminate\Cookie\Guard', $this['encrypter']) - ->push('Illuminate\Cookie\Queue', $this['cookie']) - ->push('Illuminate\Session\Middleware', $this['session'], $sessionReject); + $client = (new \Stack\Builder) + ->push('Illuminate\Cookie\Guard', $this['encrypter']) + ->push('Illuminate\Cookie\Queue', $this['cookie']) + ->push('Illuminate\Session\Middleware', $this['session'], $sessionReject); $this->mergeCustomMiddlewares($client);
true
Other
laravel
framework
36eec89228d87667607ed25aede5b1d25a4f61de.json
Remove unneeded calls to with
src/Illuminate/Foundation/Composer.php
@@ -79,7 +79,7 @@ protected function findComposer() */ protected function getProcess() { - return with(new Process('', $this->workingPath))->setTimeout(null); + return (new Process('', $this->workingPath))->setTimeout(null); } /**
true
Other
laravel
framework
36eec89228d87667607ed25aede5b1d25a4f61de.json
Remove unneeded calls to with
src/Illuminate/Http/Request.php
@@ -536,7 +536,7 @@ public static function createFromBase(SymfonyRequest $request) { if ($request instanceof static) return $request; - return with(new static)->duplicate( + return (new static)->duplicate( $request->query->all(), $request->request->all(), $request->attributes->all(),
true
Other
laravel
framework
36eec89228d87667607ed25aede5b1d25a4f61de.json
Remove unneeded calls to with
src/Illuminate/Routing/RouteCollection.php
@@ -185,7 +185,7 @@ protected function getOtherMethodsRoute($request, array $others) { if ($request->method() == 'OPTIONS') { - return with(new Route('OPTIONS', $request->path(), function() use ($others) + return (new Route('OPTIONS', $request->path(), function() use ($others) { return new Response('', 200, array('Allow' => implode(',', $others)));
true
Other
laravel
framework
36eec89228d87667607ed25aede5b1d25a4f61de.json
Remove unneeded calls to with
src/Illuminate/Routing/Router.php
@@ -1188,7 +1188,7 @@ public function model($key, $class, Closure $callback = null) // For model binders, we will attempt to retrieve the models using the find // method on the model instance. If we cannot retrieve the models we'll // throw a not found exception otherwise we will return the instance. - if ($model = with(new $class)->find($value)) + if ($model = (new $class)->find($value)) { return $model; }
true
Other
laravel
framework
36eec89228d87667607ed25aede5b1d25a4f61de.json
Remove unneeded calls to with
src/Illuminate/Support/ServiceProvider.php
@@ -105,7 +105,7 @@ public function package($package, $namespace = null, $path = null) */ public function guessPackagePath() { - $path = with(new ReflectionClass($this))->getFileName(); + $path = (new ReflectionClass($this))->getFileName(); return realpath(dirname($path).'/../../'); }
true
Other
laravel
framework
36eec89228d87667607ed25aede5b1d25a4f61de.json
Remove unneeded calls to with
src/Illuminate/Translation/Translator.php
@@ -145,7 +145,7 @@ protected function makeReplacements($line, array $replace) */ protected function sortReplacements(array $replace) { - return with(new Collection($replace))->sortBy(function($r) + return (new Collection($replace))->sortBy(function($r) { return mb_strlen($r) * -1; });
true
Other
laravel
framework
8fb5c0a01f757ec3345c1e570ffafc8b04fd3e98.json
use getRememberTokenName() in UserTrait
src/Illuminate/Auth/UserTrait.php
@@ -29,7 +29,7 @@ public function getAuthPassword() */ public function getRememberToken() { - return $this->remember_token; + return $this->{$this->getRememberTokenName()}; } /** @@ -40,7 +40,7 @@ public function getRememberToken() */ public function setRememberToken($value) { - $this->remember_token = $value; + $this->{$this->getRememberTokenName()} = $value; } /**
false
Other
laravel
framework
e48f572ceec687a32c7955e69882ec5cc6539413.json
Add contains to changes
src/Illuminate/Foundation/changes.json
@@ -26,7 +26,8 @@ {"message": "Added convenient traits for authentication and password reminding.", "backport": null}, {"message": "Added 'reject' method to Collection.", "backport": null}, {"message": "Added 'updateOrCreate' method to Eloquent model.", "backport": null}, - {"message": "Added 'keyBy' method to Collection.", "backport": null} + {"message": "Added 'keyBy' method to Collection.", "backport": null}, + {"message": "Added 'contains' method to base Collection.", "backport": null} ], "4.1.*": [ {"message": "Added new SSH task runner tools.", "backport": null},
false
Other
laravel
framework
29d0a968019bff40baccac21f6bde2f243cee083.json
Remove duplicate rows from simple pagination
src/Illuminate/Pagination/Paginator.php
@@ -103,8 +103,8 @@ public function __construct(Factory $factory, array $items, $total, $perPage = n if (is_null($perPage)) { $this->perPage = (int) $total; - $this->items = array_slice($items, 0, $perPage); - $this->hasMore = count(array_slice($items, $this->perPage, 1)) > 0; + $this->items = array_slice($items, 0, $this->perPage); + $this->hasMore = count($items) > $this->perPage; } else {
true
Other
laravel
framework
29d0a968019bff40baccac21f6bde2f243cee083.json
Remove duplicate rows from simple pagination
tests/Pagination/PaginationPaginatorTest.php
@@ -21,6 +21,29 @@ public function testPaginationContextIsSetupCorrectly() $this->assertEquals(1, $p->getCurrentPage()); } + public function testSimplePagination() + { + $p = new Paginator($factory = m::mock('Illuminate\Pagination\Factory'), ['foo', 'bar', 'baz'], 2); + $factory->shouldReceive('getCurrentPage')->once()->andReturn(1); + $p->setupPaginationContext(); + + $this->assertEquals(2, $p->getLastPage()); + $this->assertEquals(1, $p->getCurrentPage()); + $this->assertEquals(['foo', 'bar'], $p->getItems()); + } + + + public function testSimplePaginationLastPage() + { + $p = new Paginator($factory = m::mock('Illuminate\Pagination\Factory'), ['foo', 'bar', 'baz'], 3); + $factory->shouldReceive('getCurrentPage')->once()->andReturn(1); + $p->setupPaginationContext(); + + $this->assertEquals(1, $p->getLastPage()); + $this->assertEquals(1, $p->getCurrentPage()); + $this->assertEquals(3, count($p->getItems())); + } + public function testPaginationContextIsSetupCorrectlyInCursorMode() {
true
Other
laravel
framework
d17b2c1a462273606438f3a42b16747d75e8d7f1.json
Fix logic around marking services resolved or not If you app->extend an object after it's been bound but before it's been resolved, it will be initialized right away. The solution is to just check if an object has actually been resolved rather than if it's bound. A related issue that can also be solved as a part of this is that you can't extend deferred services. This has also been fixed.
src/Illuminate/Container/Container.php
@@ -80,6 +80,17 @@ public function bound($abstract) return isset($this[$abstract]) || isset($this->instances[$abstract]); } + /** + * Determine if the given abstract type has been resolved. + * + * @param string $abstract + * @return bool + */ + public function resolved($abstract) + { + return isset($this->resolved[$abstract]) || isset($this->instances[$abstract]); + } + /** * Determine if a given string is an alias. * @@ -129,14 +140,12 @@ public function bind($abstract, $concrete = null, $shared = false) $concrete = $this->getClosure($abstract, $concrete); } - $bound = $this->bound($abstract); - $this->bindings[$abstract] = compact('concrete', 'shared'); - // If the abstract type was already bound in this container, we will fire the + // If the abstract type was already resolved in this container, we will fire the // rebound listener so that any objects which have already gotten resolved // can have their copy of the object updated via the listener callbacks. - if ($bound) + if ($this->resolved($abstract)) { $this->rebound($abstract); } @@ -405,8 +414,6 @@ public function make($abstract, $parameters = array()) { $abstract = $this->getAlias($abstract); - $this->resolved[$abstract] = true; - // If an instance of the type is currently being managed as a singleton we'll // just return an existing instance instead of instantiating new instances // so the developer can keep using the same objects instance every time. @@ -439,6 +446,8 @@ public function make($abstract, $parameters = array()) $this->fireResolvingCallbacks($abstract, $object); + $this->resolved[$abstract] = true; + return $object; }
true
Other
laravel
framework
d17b2c1a462273606438f3a42b16747d75e8d7f1.json
Fix logic around marking services resolved or not If you app->extend an object after it's been bound but before it's been resolved, it will be initialized right away. The solution is to just check if an object has actually been resolved rather than if it's bound. A related issue that can also be solved as a part of this is that you can't extend deferred services. This has also been fixed.
src/Illuminate/Foundation/Application.php
@@ -463,6 +463,42 @@ public function make($abstract, $parameters = array()) return parent::make($abstract, $parameters); } + /** + * Determine if the given abstract type has been bound. + * + * (Overriding Container::bound) + * + * @param string $abstract + * @return bool + */ + public function bound($abstract) + { + return isset($this->deferredServices[$abstract]) || parent::bound($abstract); + } + + /** + * "Extend" an abstract type in the container. + * + * (Overriding Container::extend) + * + * @param string $abstract + * @param Closure $closure + * @return void + * + * @throws \InvalidArgumentException + */ + public function extend($abstract, Closure $closure) + { + $abstract = $this->getAlias($abstract); + + if (isset($this->deferredServices[$abstract])) + { + $this->loadDeferredProvider($abstract); + } + + return parent::extend($abstract, $closure); + } + /** * Register a "before" application filter. *
true
Other
laravel
framework
84eacdbefe410cec9966443ed8aebbdb67861d2d.json
add Passes method to run validation
src/Illuminate/Validation/Validator.php
@@ -318,7 +318,10 @@ protected function validate($attribute, $rule) * * @return array */ - public function passed(){ + public function passed() + { + if ( ! $this->messages) $this->passes(); + return array_diff_key($this->data, $this->messages()->toArray()); }
false
Other
laravel
framework
fcb9642d475f08d462a0522eb0111d0e6963bf54.json
Remove unneeded calls to with
src/Illuminate/Database/Eloquent/Model.php
@@ -829,7 +829,7 @@ public function morphTo($name = null, $type = null, $id = null) $instance = new $class; return new MorphTo( - with($instance)->newQuery(), $this, $id, $instance->getKeyName(), $type, $name + $instance->newQuery(), $this, $id, $instance->getKeyName(), $type, $name ); } } @@ -870,7 +870,7 @@ public function hasManyThrough($related, $through, $firstKey = null, $secondKey $secondKey = $secondKey ?: $through->getForeignKey(); - return new HasManyThrough(with(new $related)->newQuery(), $this, $through, $firstKey, $secondKey); + return new HasManyThrough((new $related)->newQuery(), $this, $through, $firstKey, $secondKey); } /**
true
Other
laravel
framework
fcb9642d475f08d462a0522eb0111d0e6963bf54.json
Remove unneeded calls to with
src/Illuminate/Foundation/Console/TailCommand.php
@@ -71,7 +71,7 @@ protected function tailLocalLogs($path) $lines = $this->option('lines'); - with(new Process('tail -f -n '.$lines.' '.escapeshellarg($path)))->setTimeout(null)->run(function($type, $line) use ($output) + (new Process('tail -f -n '.$lines.' '.escapeshellarg($path)))->setTimeout(null)->run(function($type, $line) use ($output) { $output->write($line); });
true
Other
laravel
framework
fcb9642d475f08d462a0522eb0111d0e6963bf54.json
Remove unneeded calls to with
src/Illuminate/Foundation/Console/TinkerCommand.php
@@ -46,7 +46,7 @@ protected function runBorisShell() { $this->setupBorisErrorHandling(); - with(new \Boris\Boris('> '))->start(); + (new \Boris\Boris('> '))->start(); } /**
true
Other
laravel
framework
591eb4f283abe1a41b4bc73aadee17cadfbde914.json
Replace spaces with tabs
src/Illuminate/Console/ConfirmableTrait.php
@@ -22,9 +22,9 @@ public function confirmToProceed() if ( ! $confirmed) { - $this->comment('Command Cancelled!'); + $this->comment('Command Cancelled!'); - return false; + return false; } }
false
Other
laravel
framework
a5b876d2d4b20d1957c8661d9c01be312e7a4ef4.json
Add keyBy to changes
src/Illuminate/Foundation/changes.json
@@ -25,7 +25,8 @@ {"message": "Added --daemon option to the queue:work command.", "backport": null}, {"message": "Added convenient traits for authentication and password reminding.", "backport": null}, {"message": "Added 'reject' method to Collection.", "backport": null}, - {"message": "Added 'updateOrCreate' method to Eloquent model.", "backport": null} + {"message": "Added 'updateOrCreate' method to Eloquent model.", "backport": null}, + {"message": "Added 'keyBy' method to Collection.", "backport": null} ], "4.1.*": [ {"message": "Added new SSH task runner tools.", "backport": null},
false
Other
laravel
framework
f42a0244951ef71719839a5863847b8eadeca504.json
Use negated filter for reject
src/Illuminate/Support/Collection.php
@@ -407,31 +407,25 @@ public function reduce($callback, $initial = null) } /** - * Create a colleciton of all elements that do not pass a given truth test. + * Create a collection of all elements that do not pass a given truth test. * * @param \Closure|mixed $callback * @return \Illuminate\Support\Collection */ public function reject($callback) { - $results = []; - - foreach ($this->items as $key => $value) + if ($callback instanceof Closure) { - if ($callback instanceof Closure) + return $this->filter(function($item) use ($callback) { - if ( ! $callback($value)) - { - $results[$key] = $value; - } - } - elseif ($callback != $value) - { - $results[$key] = $value; - } + return ! $callback($item); + }); } - return new static($results); + return $this->filter(function($item) use ($callback) + { + return $item != $callback; + }); } /**
false
Other
laravel
framework
c0f90d36fd4a828eb44d01b9a7a3add89fc69231.json
Fix DocBlock and variable names
src/Illuminate/Database/Eloquent/Collection.php
@@ -73,7 +73,7 @@ public function contains($key) * Fetch a nested element of the collection. * * @param string $key - * @return \Illuminate\Support\Collection + * @return \Illuminate\Database\Eloquent\Collection */ public function fetch($key) { @@ -121,14 +121,14 @@ public function modelKeys() /** * Merge the collection with the given items. * - * @param \Illuminate\Support\Collection|\Illuminate\Support\Contracts\ArrayableInterface|array $items - * @return \Illuminate\Support\Collection + * @param \ArrayAccess|array $items + * @return \Illuminate\Database\Eloquent\Collection */ - public function merge($collection) + public function merge($items) { $dictionary = $this->getDictionary(); - foreach ($collection as $item) + foreach ($items as $item) { $dictionary[$item->getKey()] = $item; } @@ -139,14 +139,14 @@ public function merge($collection) /** * Diff the collection with the given items. * - * @param \Illuminate\Support\Collection|\Illuminate\Support\Contracts\ArrayableInterface|array $items - * @return \Illuminate\Support\Collection + * @param \ArrayAccess|array $items + * @return \Illuminate\Database\Eloquent\Collection */ - public function diff($collection) + public function diff($items) { $diff = new static; - $dictionary = $this->getDictionary($collection); + $dictionary = $this->getDictionary($items); foreach ($this->items as $item) { @@ -162,14 +162,14 @@ public function diff($collection) /** * Intersect the collection with the given items. * - * @param \Illuminate\Support\Collection|\Illuminate\Support\Contracts\ArrayableInterface|array $items - * @return \Illuminate\Support\Collection + * @param \ArrayAccess|array $items + * @return \Illuminate\Database\Eloquent\Collection */ - public function intersect($collection) + public function intersect($items) { $intersect = new static; - $dictionary = $this->getDictionary($collection); + $dictionary = $this->getDictionary($items); foreach ($this->items as $item) { @@ -185,7 +185,7 @@ public function intersect($collection) /** * Return only unique items from the collection. * - * @return \Illuminate\Support\Collection + * @return \Illuminate\Database\Eloquent\Collection */ public function unique() { @@ -198,7 +198,7 @@ public function unique() * Returns only the models from the collection with the specified keys. * * @param mixed $keys - * @return \Illuminate\Support\Collection + * @return \Illuminate\Database\Eloquent\Collection */ public function only($keys) { @@ -211,7 +211,7 @@ public function only($keys) * Returns all models in the collection except the models with specified keys. * * @param mixed $keys - * @return \Illuminate\Support\Collection + * @return \Illuminate\Database\Eloquent\Collection */ public function except($keys) { @@ -223,16 +223,16 @@ public function except($keys) /** * Get a dictionary keyed by primary keys. * - * @param \Illuminate\Support\Collection $collection + * @param \ArrayAccess|array $items * @return array */ - public function getDictionary($collection = null) + public function getDictionary($items = null) { - $collection = $collection ?: $this; + $items = is_null($items) ? $this->items : $items; $dictionary = array(); - foreach ($collection as $value) + foreach ($items as $value) { $dictionary[$value->getKey()] = $value; }
false
Other
laravel
framework
773e2f20f8941f965407778345ecd4c3a33921b1.json
Fix return type.
src/Illuminate/Support/Collection.php
@@ -140,7 +140,7 @@ public function first(Closure $callback = null, $default = null) /** * Get a flattened array of the items in the collection. * - * @return array + * @return \Illuminate\Support\Collection */ public function flatten() {
false
Other
laravel
framework
0f4bcc0340a82fc9ed8592f608037c86d47de369.json
Add back array set on get.
src/Illuminate/Routing/Router.php
@@ -142,7 +142,7 @@ public function __construct(Dispatcher $events, Container $container = null) */ public function get($uri, $action) { - return $this->addRoute('GET', $uri, $action); + return $this->addRoute(['GET', 'HEAD'], $uri, $action); } /**
false
Other
laravel
framework
b82b72bc16a48c22cc3650adc326df4e4e018729.json
Add HEAD when GET is set in Route::macth()
src/Illuminate/Routing/Route.php
@@ -680,6 +680,11 @@ public function getMethods() */ public function methods() { + if (in_array('GET', $this->methods) && ! in_array('HEAD', $this->methods)) + { + $this->methods[] = 'HEAD'; + } + return $this->methods; }
true
Other
laravel
framework
b82b72bc16a48c22cc3650adc326df4e4e018729.json
Add HEAD when GET is set in Route::macth()
src/Illuminate/Routing/Router.php
@@ -142,7 +142,7 @@ public function __construct(Dispatcher $events, Container $container = null) */ public function get($uri, $action) { - return $this->addRoute(array('GET', 'HEAD'), $uri, $action); + return $this->addRoute('GET', $uri, $action); } /**
true
Other
laravel
framework
b82b72bc16a48c22cc3650adc326df4e4e018729.json
Add HEAD when GET is set in Route::macth()
tests/Routing/RoutingRouteTest.php
@@ -89,6 +89,35 @@ public function testOptionsResponsesAreGeneratedByDefault() } + public function testHeadDispatcher() + { + $router = $this->getRouter(); + $router->match(['GET', 'POST'], 'foo', function () { return 'bar'; }); + + $response = $router->dispatch(Request::create('foo', 'OPTIONS')); + $this->assertEquals(200, $response->getStatusCode()); + $this->assertEquals('GET,HEAD,POST', $response->headers->get('Allow')); + + $response = $router->dispatch(Request::create('foo', 'HEAD')); + $this->assertEquals(200, $response->getStatusCode()); + $this->assertEquals('', $response->getContent()); + + $router = $this->getRouter(); + $router->match(['GET'], 'foo', function () { return 'bar'; }); + + $response = $router->dispatch(Request::create('foo', 'OPTIONS')); + $this->assertEquals(200, $response->getStatusCode()); + $this->assertEquals('GET,HEAD', $response->headers->get('Allow')); + + $router = $this->getRouter(); + $router->match(['POST'], 'foo', function () { return 'bar'; }); + + $response = $router->dispatch(Request::create('foo', 'OPTIONS')); + $this->assertEquals(200, $response->getStatusCode()); + $this->assertEquals('POST', $response->headers->get('Allow')); + } + + public function testNonGreedyMatches() { $route = new Route('GET', 'images/{id}.{ext}', function() {});
true
Other
laravel
framework
edccb7c6cd8cb668b7303cdbcf73e0d0a6235d03.json
make code a little cleaner
src/Illuminate/Queue/BeanstalkdQueue.php
@@ -1,7 +1,7 @@ <?php namespace Illuminate\Queue; -use Pheanstalk\Job as Pheanstalk_Job; -use Pheanstalk\Pheanstalk as Pheanstalk; +use Pheanstalk\Job as PheanstalkJob; +use Pheanstalk\Pheanstalk; use Illuminate\Queue\Jobs\BeanstalkdJob; class BeanstalkdQueue extends Queue implements QueueInterface { @@ -100,7 +100,7 @@ public function pop($queue = null) $job = $this->pheanstalk->watchOnly($queue)->reserve(0); - if ($job instanceof Pheanstalk_Job) + if ($job instanceof PheanstalkJob) { return new BeanstalkdJob($this->container, $this->pheanstalk, $job, $queue); }
true
Other
laravel
framework
edccb7c6cd8cb668b7303cdbcf73e0d0a6235d03.json
make code a little cleaner
src/Illuminate/Queue/Connectors/BeanstalkdConnector.php
@@ -1,7 +1,7 @@ <?php namespace Illuminate\Queue\Connectors; use Illuminate\Queue\BeanstalkdQueue; -use Pheanstalk\Pheanstalk as Pheanstalk; +use Pheanstalk\Pheanstalk; class BeanstalkdConnector implements ConnectorInterface {
true
Other
laravel
framework
27d50a2f5548765df136ccd9bf77059bbe73d093.json
Add keyBy method to Collection
src/Illuminate/Support/Collection.php
@@ -205,6 +205,26 @@ public function groupBy($groupBy) return new static($results); } + /** + * Key an associative array by a field. + * + * @param string $keyBy + * @return \Illuminate\Support\Collection + */ + public function keyBy($keyBy) + { + $results = []; + + foreach ($this->items as $item) + { + $key = data_get($item, $keyBy); + + $results[$key] = $item; + } + + return new static($results); + } + /** * Determine if an item exists in the collection by key. *
true
Other
laravel
framework
27d50a2f5548765df136ccd9bf77059bbe73d093.json
Add keyBy method to Collection
tests/Support/SupportCollectionTest.php
@@ -368,6 +368,14 @@ public function testGroupByAttribute() } + public function testKeyByAttribute() + { + $data = new Collection([['rating' => 1, 'name' => '1'], ['rating' => 2, 'name' => '2'], ['rating' => 3, 'name' => '3']]); + $result = $data->keyBy('rating'); + $this->assertEquals([1 => ['rating' => 1, 'name' => '1'], 2 => ['rating' => 2, 'name' => '2'], 3 => ['rating' => 3, 'name' => '3']], $result->all()); + } + + public function testGettingSumFromCollection() { $c = new Collection(array((object) array('foo' => 50), (object) array('foo' => 50)));
true
Other
laravel
framework
469d429d62ec43d4bb8a5b88b9203e31afc17eaf.json
Remove broken community tests.
tests/Queue/QueueSqsJobTest.php
@@ -1,89 +0,0 @@ -<?php - -use Mockery as m; - -use Aws\Sqs\SqsClient; -use Aws\Common\Credentials\Credentials; -use Aws\Common\Credentials\CredentialsInterface; -use Aws\Common\Signature\SignatureInterface; -use Aws\Common\Signature\SignatureV4; - -use Guzzle\Common\Collection; -use Guzzle\Service\Resource\Model; - -class QueueSqsJobTest extends PHPUnit_Framework_TestCase { - - public function setUp() { - - $this->key = 'AMAZONSQSKEY'; - $this->secret = 'AmAz0n+SqSsEcReT+aLpHaNuM3R1CsTr1nG'; - $this->service = 'sqs'; - $this->region = 'someregion'; - $this->account = '1234567891011'; - $this->queueName = 'emails'; - $this->baseUrl = 'https://sqs.someregion.amazonaws.com'; - - // The Aws\Common\AbstractClient needs these three constructor parameters - $this->credentials = new Credentials( $this->key, $this->secret ); - $this->signature = new SignatureV4( $this->service, $this->region ); - $this->config = new Collection(); - - // This is how the modified getQueue builds the queueUrl - $this->queueUrl = $this->baseUrl . '/' . $this->account . '/' . $this->queueName; - - // Get a mock of the SqsClient - $this->mockedSqsClient = $this->getMock('Aws\Sqs\SqsClient', array('deleteMessage'), array($this->credentials, $this->signature, $this->config)); - - // Use Mockery to mock the IoC Container - $this->mockedContainer = m::mock('Illuminate\Container\Container'); - - $this->mockedJob = 'foo'; - $this->mockedData = array('data'); - $this->mockedPayload = json_encode(array('job' => $this->mockedJob, 'data' => $this->mockedData, 'attempts' => 1)); - $this->mockedMessageId = 'e3cd03ee-59a3-4ad8-b0aa-ee2e3808ac81'; - $this->mockedReceiptHandle = '0NNAq8PwvXuWv5gMtS9DJ8qEdyiUwbAjpp45w2m6M4SJ1Y+PxCh7R930NRB8ylSacEmoSnW18bgd4nK\/O6ctE+VFVul4eD23mA07vVoSnPI4F\/voI1eNCp6Iax0ktGmhlNVzBwaZHEr91BRtqTRM3QKd2ASF8u+IQaSwyl\/DGK+P1+dqUOodvOVtExJwdyDLy1glZVgm85Yw9Jf5yZEEErqRwzYz\/qSigdvW4sm2l7e4phRol\/+IjMtovOyH\/ukueYdlVbQ4OshQLENhUKe7RNN5i6bE\/e5x9bnPhfj2gbM'; - - $this->mockedJobData = array('Body' => $this->mockedPayload, - 'MD5OfBody' => md5($this->mockedPayload), - 'ReceiptHandle' => $this->mockedReceiptHandle, - 'MessageId' => $this->mockedMessageId, - 'Attributes' => array('ApproximateReceiveCount' => 1)); - - } - - public function tearDown() - { - m::close(); - } - - - public function testFireProperlyCallsTheJobHandler() - { - $job = $this->getJob(); - $job->getContainer()->shouldReceive('make')->once()->with('foo')->andReturn($handler = m::mock('StdClass')); - $handler->shouldReceive('fire')->once()->with($job, array('data')); - $job->fire(); - } - - - public function testDeleteRemovesTheJobFromSqs() - { - $this->mockedSqsClient = $this->getMock('Aws\Sqs\SqsClient', array('deleteMessage'), array($this->credentials, $this->signature, $this->config)); - $queue = $this->getMock('Illuminate\Queue\SqsQueue', array('getQueue'), array($this->mockedSqsClient, $this->queueName, $this->account)); - $queue->setContainer($this->mockedContainer); - $job = $this->getJob(); - $job->getSqs()->expects($this->once())->method('deleteMessage')->with(array('QueueUrl' => $this->queueUrl, 'ReceiptHandle' => $this->mockedReceiptHandle)); - $job->delete(); - } - - protected function getJob() - { - return new Illuminate\Queue\Jobs\SqsJob( - $this->mockedContainer, - $this->mockedSqsClient, - $this->queueUrl, - $this->mockedJobData - ); - } - -}
true
Other
laravel
framework
469d429d62ec43d4bb8a5b88b9203e31afc17eaf.json
Remove broken community tests.
tests/Queue/QueueSqsQueueTest.php
@@ -1,89 +0,0 @@ -<?php - -use Mockery as m; - -use Aws\Sqs\SqsClient; -use Guzzle\Service\Resource\Model; - -class QueueSqsQueueTest extends PHPUnit_Framework_TestCase { - - public function tearDown() - { - m::close(); - } - - public function setUp() { - - // Use Mockery to mock the SqsClient - $this->sqs = m::mock('Aws\Sqs\SqsClient'); - - $this->account = '1234567891011'; - $this->queueName = 'emails'; - $this->baseUrl = 'https://sqs.someregion.amazonaws.com'; - - // This is how the modified getQueue builds the queueUrl - $this->queueUrl = $this->baseUrl . '/' . $this->account . '/' . $this->queueName; - - $this->mockedJob = 'foo'; - $this->mockedData = array('data'); - $this->mockedPayload = json_encode(array('job' => $this->mockedJob, 'data' => $this->mockedData)); - $this->mockedDelay = 10; - $this->mockedDateTime = m::mock('DateTime'); - $this->mockedMessageId = 'e3cd03ee-59a3-4ad8-b0aa-ee2e3808ac81'; - $this->mockedReceiptHandle = '0NNAq8PwvXuWv5gMtS9DJ8qEdyiUwbAjpp45w2m6M4SJ1Y+PxCh7R930NRB8ylSacEmoSnW18bgd4nK\/O6ctE+VFVul4eD23mA07vVoSnPI4F\/voI1eNCp6Iax0ktGmhlNVzBwaZHEr91BRtqTRM3QKd2ASF8u+IQaSwyl\/DGK+P1+dqUOodvOVtExJwdyDLy1glZVgm85Yw9Jf5yZEEErqRwzYz\/qSigdvW4sm2l7e4phRol\/+IjMtovOyH\/ukueYdlVbQ4OshQLENhUKe7RNN5i6bE\/e5x9bnPhfj2gbM'; - - $this->mockedSendMessageResponseModel = new Model(array('Body' => $this->mockedPayload, - 'MD5OfBody' => md5($this->mockedPayload), - 'ReceiptHandle' => $this->mockedReceiptHandle, - 'MessageId' => $this->mockedMessageId, - 'Attributes' => array('ApproximateReceiveCount' => 1))); - - $this->mockedReceiveMessageResponseModel = new Model(array('Messages' => array( 0 => array( - 'Body' => $this->mockedPayload, - 'MD5OfBody' => md5($this->mockedPayload), - 'ReceiptHandle' => $this->mockedReceiptHandle, - 'MessageId' => $this->mockedMessageId)))); - } - - public function testPopProperlyPopsJobOffOfSqs() - { - $queue = $this->getMock('Illuminate\Queue\SqsQueue', array('getQueue'), array($this->sqs, $this->queueName, $this->account)); - $queue->setContainer(m::mock('Illuminate\Container\Container')); - $queue->expects($this->once())->method('getQueue')->with($this->queueName)->will($this->returnValue($this->queueUrl)); - $this->sqs->shouldReceive('receiveMessage')->once()->with(array('QueueUrl' => $this->queueUrl, 'AttributeNames' => array('ApproximateReceiveCount')))->andReturn($this->mockedReceiveMessageResponseModel); - $result = $queue->pop($this->queueName); - $this->assertInstanceOf('Illuminate\Queue\Jobs\SqsJob', $result); - } - - public function testDelayedPushWithDateTimeProperlyPushesJobOntoSqs() - { - $queue = $this->getMock('Illuminate\Queue\SqsQueue', array('createPayload', 'getSeconds', 'getQueue'), array($this->sqs, $this->queueName, $this->account)); - $queue->expects($this->once())->method('createPayload')->with($this->mockedJob, $this->mockedData)->will($this->returnValue($this->mockedPayload)); - $queue->expects($this->once())->method('getSeconds')->with($this->mockedDateTime)->will($this->returnValue($this->mockedDateTime)); - $queue->expects($this->once())->method('getQueue')->with($this->queueName)->will($this->returnValue($this->queueUrl)); - $this->sqs->shouldReceive('sendMessage')->once()->with(array('QueueUrl' => $this->queueUrl, 'MessageBody' => $this->mockedPayload, 'DelaySeconds' => $this->mockedDateTime))->andReturn($this->mockedSendMessageResponseModel); - $id = $queue->later($this->mockedDateTime, $this->mockedJob, $this->mockedData, $this->queueName); - $this->assertEquals($this->mockedMessageId, $id); - } - - public function testDelayedPushProperlyPushesJobOntoSqs() - { - $queue = $this->getMock('Illuminate\Queue\SqsQueue', array('createPayload', 'getSeconds', 'getQueue'), array($this->sqs, $this->queueName, $this->account)); - $queue->expects($this->once())->method('createPayload')->with($this->mockedJob, $this->mockedData)->will($this->returnValue($this->mockedPayload)); - $queue->expects($this->once())->method('getSeconds')->with($this->mockedDelay)->will($this->returnValue($this->mockedDelay)); - $queue->expects($this->once())->method('getQueue')->with($this->queueName)->will($this->returnValue($this->queueUrl)); - $this->sqs->shouldReceive('sendMessage')->once()->with(array('QueueUrl' => $this->queueUrl, 'MessageBody' => $this->mockedPayload, 'DelaySeconds' => $this->mockedDelay))->andReturn($this->mockedSendMessageResponseModel); - $id = $queue->later($this->mockedDelay, $this->mockedJob, $this->mockedData, $this->queueName); - $this->assertEquals($this->mockedMessageId, $id); - } - - public function testPushProperlyPushesJobOntoSqs() - { - $queue = $this->getMock('Illuminate\Queue\SqsQueue', array('createPayload', 'getQueue'), array($this->sqs, $this->queueName, $this->account)); - $queue->expects($this->once())->method('createPayload')->with($this->mockedJob, $this->mockedData)->will($this->returnValue($this->mockedPayload)); - $queue->expects($this->once())->method('getQueue')->with($this->queueName)->will($this->returnValue($this->queueUrl)); - $this->sqs->shouldReceive('sendMessage')->once()->with(array('QueueUrl' => $this->queueUrl, 'MessageBody' => $this->mockedPayload))->andReturn($this->mockedSendMessageResponseModel); - $id = $queue->push($this->mockedJob, $this->mockedData, $this->queueName); - $this->assertEquals($this->mockedMessageId, $id); - } -}
true
Other
laravel
framework
a77c6f40a2e2aa2b5eee9d4df64b4c8625012f0e.json
Prevent a fatal error if Router->current is empty Prevents a fatal error ("Call to a member function getAction() on a non-object") if currentRouteAction() is called and there is no current route.
src/Illuminate/Routing/Router.php
@@ -1554,6 +1554,8 @@ public function currentRouteNamed($name) */ public function currentRouteAction() { + if (!$this->current()) return null; + $action = $this->current()->getAction(); return isset($action['controller']) ? $action['controller'] : null;
false
Other
laravel
framework
40e2cf765ba603d03f7c37c8f3edde537d4b22d6.json
Fix merge conflicts.
src/Illuminate/Http/Request.php
@@ -241,7 +241,16 @@ public function only($keys) { $keys = is_array($keys) ? $keys : func_get_args(); - return array_only($this->all(), $keys) + array_fill_keys($keys, null); + $results = []; + + $input = $this->all(); + + foreach ($keys as $key) + { + array_set($results, $key, array_get($input, $key, null)); + } + + return $results; } /**
true
Other
laravel
framework
40e2cf765ba603d03f7c37c8f3edde537d4b22d6.json
Fix merge conflicts.
tests/Http/HttpRequestTest.php
@@ -169,6 +169,10 @@ public function testOnlyMethod() $request = Request::create('/', 'GET', array('name' => 'Taylor', 'age' => 25)); $this->assertEquals(array('age' => 25), $request->only('age')); $this->assertEquals(array('name' => 'Taylor', 'age' => 25), $request->only('name', 'age')); + + $request = Request::create('/', 'GET', array('developer' => array('name' => 'Taylor', 'age' => 25))); + $this->assertEquals(array('developer' => array('age' => 25)), $request->only('developer.age')); + $this->assertEquals(array('developer' => array('name' => 'Taylor'), 'test' => null), $request->only('developer.name', 'test')); }
true
Other
laravel
framework
13a55dec52b1f6a9aeb5ec029d051e713e4ed1e7.json
Use input:all for only and except.
src/Illuminate/Http/Request.php
@@ -241,7 +241,7 @@ public function only($keys) { $keys = is_array($keys) ? $keys : func_get_args(); - return array_only($this->input(), $keys) + array_fill_keys($keys, null); + return array_only($this->all(), $keys) + array_fill_keys($keys, null); } /** @@ -254,7 +254,7 @@ public function except($keys) { $keys = is_array($keys) ? $keys : func_get_args(); - $results = $this->input(); + $results = $this->all(); foreach ($keys as $key) array_forget($results, $key);
false
Other
laravel
framework
72ef9387185a7e6e74240e8854c623b24e056d2b.json
return null when forgetting
src/Illuminate/Cache/DatabaseStore.php
@@ -71,7 +71,9 @@ public function get($key) if (time() >= $cache->expiration) { - return $this->forget($key); + $this->forget($key); + + return null; } return $this->encrypter->decrypt($cache->value);
true
Other
laravel
framework
72ef9387185a7e6e74240e8854c623b24e056d2b.json
return null when forgetting
src/Illuminate/Cache/FileStore.php
@@ -63,7 +63,9 @@ public function get($key) // this directory much cleaner for us as old files aren't hanging out. if (time() >= $expire) { - return $this->forget($key); + $this->forget($key); + + return null; } return unserialize(substr($contents, 10));
true
Other
laravel
framework
ebe243b596c2e56508c0ef28c6bce94abbc2b6b9.json
fix tests for PR #4766
tests/Database/DatabaseEloquentModelTest.php
@@ -766,8 +766,8 @@ public function testCloneModelMakesAFreshCopyOfTheModel() public function testModelObserversCanBeAttachedToModels() { EloquentModelStub::setEventDispatcher($events = m::mock('Illuminate\Events\Dispatcher')); - $events->shouldReceive('listen')->once()->with('eloquent.creating: EloquentModelStub', 'EloquentTestObserverStub@creating'); - $events->shouldReceive('listen')->once()->with('eloquent.saved: EloquentModelStub', 'EloquentTestObserverStub@saved'); + $events->shouldReceive('listen')->once()->with('eloquent.creating: EloquentModelStub', 'EloquentTestObserverStub@creating', 0); + $events->shouldReceive('listen')->once()->with('eloquent.saved: EloquentModelStub', 'EloquentTestObserverStub@saved', 0); $events->shouldReceive('forget'); EloquentModelStub::observe(new EloquentTestObserverStub); EloquentModelStub::flushEventListeners();
false
Other
laravel
framework
1aca4bbde671a1f25bffc9859af34eecc98002f5.json
Add comment in MySQLGrammar
src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php
@@ -11,7 +11,7 @@ class MySqlGrammar extends Grammar { * * @var array */ - protected $modifiers = array('Unsigned', 'Nullable', 'Default', 'Increment', 'After'); + protected $modifiers = array('Unsigned', 'Nullable', 'Default', 'Increment', 'After', 'Comment'); /** * The possible column serials @@ -567,6 +567,21 @@ protected function modifyAfter(Blueprint $blueprint, Fluent $column) } } + /** + * Get the SQL for an "comment" column modifier. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $column + * @return string|null + */ + protected function modifyComment(Blueprint $blueprint, Fluent $column) + { + if ( ! is_null($column->comment)) + { + return ' comment "' . $column->comment . '"'; + } + } + /** * Wrap a single string in keyword identifiers. *
false
Other
laravel
framework
3ef0926153aaa9ab814c87977a1fbad66823dd50.json
Enable array_forget to unset one or many keys
src/Illuminate/Http/Request.php
@@ -256,7 +256,7 @@ public function except($keys) $results = $this->input(); - foreach ($keys as $key) array_forget($results, $key); + array_forget($results, $keys); return $results; }
true
Other
laravel
framework
3ef0926153aaa9ab814c87977a1fbad66823dd50.json
Enable array_forget to unset one or many keys
src/Illuminate/Support/helpers.php
@@ -266,29 +266,30 @@ function array_flatten($array) if ( ! function_exists('array_forget')) { /** - * Remove an array item from a given array using "dot" notation. + * Remove one or many array items from a given array using "dot" notation. * - * @param array $array - * @param string $key + * @param array $array + * @param array|string $keys * @return void */ - function array_forget(&$array, $key) + function array_forget(&$array, $keys) { - $keys = explode('.', $key); - - while (count($keys) > 1) + foreach ((array) $keys as $key) { - $key = array_shift($keys); + $parts = explode('.', $key); - if ( ! isset($array[$key]) || ! is_array($array[$key])) + while (count($parts) > 1) { - return; + $part = array_shift($parts); + + if (isset($array[$part]) && is_array($array[$part])) + { + $array =& $array[$part]; + } } - $array =& $array[$key]; + unset($array[array_shift($parts)]); } - - unset($array[array_shift($keys)]); } }
true
Other
laravel
framework
3ef0926153aaa9ab814c87977a1fbad66823dd50.json
Enable array_forget to unset one or many keys
tests/Support/SupportHelpersTest.php
@@ -41,6 +41,12 @@ public function testArrayForget() array_forget($array, 'names.developer'); $this->assertFalse(isset($array['names']['developer'])); $this->assertTrue(isset($array['names']['otherDeveloper'])); + + $array = ['names' => ['developer' => 'taylor', 'otherDeveloper' => 'dayle', 'thirdDeveloper' => 'Lucas']]; + array_forget($array, ['names.developer', 'names.otherDeveloper']); + $this->assertFalse(isset($array['names']['developer'])); + $this->assertFalse(isset($array['names']['otherDeveloper'])); + $this->assertTrue(isset($array['names']['thirdDeveloper'])); }
true
Other
laravel
framework
388c3a81b9aed8b936e5821a6141daa619954814.json
Use cache repository.
src/Illuminate/Queue/Worker.php
@@ -2,7 +2,7 @@ use Illuminate\Queue\Jobs\Job; use Illuminate\Events\Dispatcher; -use Illuminate\Cache\StoreInterface; +use Illuminate\Cache\Repository as CacheRepository; use Illuminate\Queue\Failed\FailedJobProviderInterface; class Worker { @@ -28,6 +28,13 @@ class Worker { */ protected $events; + /** + * The cache repository implementation. + * + * @var \Illuminate\Cache\Repository + */ + protected $cache; + /** * The exception handler instance. * @@ -318,12 +325,12 @@ public function setDaemonExceptionHandler($handler) } /** - * Set the cache store implementation. + * Set the cache repository implementation. * - * @param \Illuminate\Cache\StoreInterface $cache + * @param \Illuminate\Cache\Repository $cache * @return void */ - public function setCache(StoreInterface $cache) + public function setCache(CacheRepository $cache) { $this->cache = $cache; }
false
Other
laravel
framework
897bb4e22986b7d9dfaa1adb890b2e59810fc9f6.json
Update typo in docblock for Worker.php *cough* I am going to be that guy... there is a typo in your docblock, bro. =). Targets 4.1 branch as per comment in pull request #4664
src/Illuminate/Queue/Worker.php
@@ -7,7 +7,7 @@ class Worker { /** - * THe queue manager instance. + * The queue manager instance. * * @var \Illuminate\Queue\QueueManager */
false
Other
laravel
framework
1d4265dbfb4da567943c196b4e7162002ed54bde.json
Add use ...\Str to helpers.php
src/Illuminate/Support/helpers.php
@@ -1,5 +1,7 @@ <?php +use Illuminate\Support\Str; + if ( ! function_exists('action')) { /** @@ -507,7 +509,7 @@ function base_path($path = '') */ function camel_case($value) { - return Illuminate\Support\Str::camel($value); + return Str::camel($value); } } @@ -634,7 +636,7 @@ function e($value) */ function ends_with($haystack, $needle) { - return Illuminate\Support\Str::endsWith($haystack, $needle); + return Str::endsWith($haystack, $needle); } } @@ -851,7 +853,7 @@ function secure_url($path, $parameters = array()) */ function snake_case($value, $delimiter = '_') { - return Illuminate\Support\Str::snake($value, $delimiter); + return Str::snake($value, $delimiter); } } @@ -866,7 +868,7 @@ function snake_case($value, $delimiter = '_') */ function starts_with($haystack, $needle) { - return Illuminate\Support\Str::startsWith($haystack, $needle); + return Str::startsWith($haystack, $needle); } } @@ -895,7 +897,7 @@ function storage_path($path = '') */ function str_contains($haystack, $needle) { - return Illuminate\Support\Str::contains($haystack, $needle); + return Str::contains($haystack, $needle); } } @@ -910,7 +912,7 @@ function str_contains($haystack, $needle) */ function str_finish($value, $cap) { - return Illuminate\Support\Str::finish($value, $cap); + return Str::finish($value, $cap); } } @@ -925,7 +927,7 @@ function str_finish($value, $cap) */ function str_is($pattern, $value) { - return Illuminate\Support\Str::is($pattern, $value); + return Str::is($pattern, $value); } } @@ -941,7 +943,7 @@ function str_is($pattern, $value) */ function str_limit($value, $limit = 100, $end = '...') { - return Illuminate\Support\Str::limit($value, $limit, $end); + return Str::limit($value, $limit, $end); } } @@ -956,7 +958,7 @@ function str_limit($value, $limit = 100, $end = '...') */ function str_plural($value, $count = 2) { - return Illuminate\Support\Str::plural($value, $count); + return Str::plural($value, $count); } } @@ -972,7 +974,7 @@ function str_plural($value, $count = 2) */ function str_random($length = 16) { - return Illuminate\Support\Str::random($length); + return Str::random($length); } } @@ -1007,7 +1009,7 @@ function str_replace_array($search, array $replace, $subject) */ function str_singular($value) { - return Illuminate\Support\Str::singular($value); + return Str::singular($value); } } @@ -1021,7 +1023,7 @@ function str_singular($value) */ function studly_case($value) { - return Illuminate\Support\Str::studly($value); + return Str::studly($value); } }
false
Other
laravel
framework
38f435e2aec6d03fd37c30f17a8bf126847fec3d.json
Intend $app->booted closure code
src/Illuminate/Foundation/start.php
@@ -223,49 +223,49 @@ $app->booted(function() use ($app, $env) { -/* -|-------------------------------------------------------------------------- -| Load The Application Start Script -|-------------------------------------------------------------------------- -| -| The start scripts gives this application the opportunity to override -| any of the existing IoC bindings, as well as register its own new -| bindings for things like repositories, etc. We'll load it here. -| -*/ - -$path = $app['path'].'/start/global.php'; - -if (file_exists($path)) require $path; - -/* -|-------------------------------------------------------------------------- -| Load The Environment Start Script -|-------------------------------------------------------------------------- -| -| The environment start script is only loaded if it exists for the app -| environment currently active, which allows some actions to happen -| in one environment while not in the other, keeping things clean. -| -*/ - -$path = $app['path']."/start/{$env}.php"; - -if (file_exists($path)) require $path; - -/* -|-------------------------------------------------------------------------- -| Load The Application Routes -|-------------------------------------------------------------------------- -| -| The Application routes are kept separate from the application starting -| just to keep the file a little cleaner. We'll go ahead and load in -| all of the routes now and return the application to the callers. -| -*/ - -$routes = $app['path'].'/routes.php'; - -if (file_exists($routes)) require $routes; + /* + |-------------------------------------------------------------------------- + | Load The Application Start Script + |-------------------------------------------------------------------------- + | + | The start scripts gives this application the opportunity to override + | any of the existing IoC bindings, as well as register its own new + | bindings for things like repositories, etc. We'll load it here. + | + */ + + $path = $app['path'].'/start/global.php'; + + if (file_exists($path)) require $path; + + /* + |-------------------------------------------------------------------------- + | Load The Environment Start Script + |-------------------------------------------------------------------------- + | + | The environment start script is only loaded if it exists for the app + | environment currently active, which allows some actions to happen + | in one environment while not in the other, keeping things clean. + | + */ + + $path = $app['path']."/start/{$env}.php"; + + if (file_exists($path)) require $path; + + /* + |-------------------------------------------------------------------------- + | Load The Application Routes + |-------------------------------------------------------------------------- + | + | The Application routes are kept separate from the application starting + | just to keep the file a little cleaner. We'll go ahead and load in + | all of the routes now and return the application to the callers. + | + */ + + $routes = $app['path'].'/routes.php'; + + if (file_exists($routes)) require $routes; });
false
Other
laravel
framework
74c1b8027b5128026905bb9e49b7e77667b7ba34.json
Add updateOrCreate() function
src/Illuminate/Database/Eloquent/Model.php
@@ -558,6 +558,21 @@ public static function firstOrNew(array $attributes) return new static($attributes); } + /** + * Create or update a record matching the attributes, and fill it with values. + * + * @param array $attributes + * @param array $values + * @return \Illuminate\Database\Eloquent\Model + */ + public static function updateOrCreate(array $attributes, array $values = []) + { + $instance = static::firstOrNew($attributes); + $instance->fill($values)->save(); + + return $instance; + } + /** * Get the first model for the given attributes. *
false
Other
laravel
framework
208d1b04fab8b07f911c78de020398c9f18b9bdd.json
Fix code formatting.
src/Illuminate/Console/Command.php
@@ -63,6 +63,13 @@ public function __construct() $this->specifyParameters(); } + /** + * Execute the console command. + * + * @return void + */ + abstract public function fire(); + /** * Specify the arguments and options on the command. * @@ -382,5 +389,4 @@ public function setLaravel($laravel) $this->laravel = $laravel; } - abstract public function fire(); }
false
Other
laravel
framework
95aaa4de97bdddd4156b06afdad0a66196086565.json
Add boolean validation option
src/Illuminate/Validation/Validator.php
@@ -695,6 +695,20 @@ protected function validateAccepted($attribute, $value) return ($this->validateRequired($attribute, $value) && in_array($value, $acceptable, true)); } + /** + * Validate that an attribute is a boolean. + * + * @param string $attribute + * @param mixed $value + * @return bool + */ + protected function validateBoolean($attribute, $value) + { + $acceptable = array(true, false, 0, 1, '0', '1'); + + return in_array($value, $acceptable, true); + } + /** * Validate that an attribute is an array. *
true
Other
laravel
framework
95aaa4de97bdddd4156b06afdad0a66196086565.json
Add boolean validation option
tests/Validation/ValidationValidatorTest.php
@@ -460,6 +460,44 @@ public function testValidateAccepted() } + public function testValidateBoolean() + { + $trans = $this->getRealTranslator(); + $v = new Validator($trans, array('foo' => 'no'), array('foo' => 'Boolean')); + $this->assertFalse($v->passes()); + + $v = new Validator($trans, array('foo' => 'yes'), array('foo' => 'Boolean')); + $this->assertFalse($v->passes()); + + $v = new Validator($trans, array('foo' => 'false'), array('foo' => 'Boolean')); + $this->assertFalse($v->passes()); + + $v = new Validator($trans, array('foo' => 'true'), array('foo' => 'Boolean')); + $this->assertFalse($v->passes()); + + $v = new Validator($trans, array(), array('foo' => 'Boolean')); + $this->assertTrue($v->passes()); + + $v = new Validator($trans, array('foo' => false), array('foo' => 'Boolean')); + $this->assertTrue($v->passes()); + + $v = new Validator($trans, array('foo' => true), array('foo' => 'Boolean')); + $this->assertTrue($v->passes()); + + $v = new Validator($trans, array('foo' => '1'), array('foo' => 'Boolean')); + $this->assertTrue($v->passes()); + + $v = new Validator($trans, array('foo' => 1), array('foo' => 'Boolean')); + $this->assertTrue($v->passes()); + + $v = new Validator($trans, array('foo' => '0'), array('foo' => 'Boolean')); + $this->assertTrue($v->passes()); + + $v = new Validator($trans, array('foo' => 0), array('foo' => 'Boolean')); + $this->assertTrue($v->passes()); + } + + public function testValidateNumeric() { $trans = $this->getRealTranslator();
true
Other
laravel
framework
7cd65764ae0cd6759353cb1231c421319141caf8.json
Continue loop on wildcards.
src/Illuminate/Events/Dispatcher.php
@@ -64,12 +64,14 @@ public function listen($events, $listener, $priority = 0) { if (str_contains($event, '*')) { - return $this->setupWildcardListen($event, $listener); + $this->setupWildcardListen($event, $listener); } + else + { + $this->listeners[$event][$priority][] = $this->makeListener($listener); - $this->listeners[$event][$priority][] = $this->makeListener($listener); - - unset($this->sorted[$event]); + unset($this->sorted[$event]); + } } }
false
Other
laravel
framework
4ce3061980c116dd51dd5eaf07e2a163fba2e3f8.json
Fix usage of uniqid.
src/Illuminate/Session/Store.php
@@ -156,7 +156,7 @@ public function setId($id) */ protected function generateSessionId() { - return sha1(uniqid(true).str_random(25).microtime(true)); + return sha1(uniqid('', true).str_random(25).microtime(true)); } /**
false
Other
laravel
framework
8d0e7b1281fc6cfc005484547ca95a15fa1eb4e4.json
Throw DecryptException on error, for consistency
src/Illuminate/Encryption/Encrypter.php
@@ -109,7 +109,12 @@ public function decrypt($payload) */ protected function mcryptDecrypt($value, $iv) { - return mcrypt_decrypt($this->cipher, $this->key, $value, $this->mode, $iv); + try { + return mcrypt_decrypt($this->cipher, $this->key, $value, $this->mode, $iv); + } + catch (\Exception $e) { + throw new DecryptException($e->getMessage()); + } } /**
false
Other
laravel
framework
27d42308ed3c370b943b7c9db27dd4f4eaf685a6.json
make OptimizeCommand compile views
src/Illuminate/Foundation/Console/OptimizeCommand.php
@@ -2,6 +2,7 @@ use Illuminate\Console\Command; use Illuminate\Foundation\Composer; +use Illuminate\View\Engines\CompilerEngine; use ClassPreloader\Command\PreCompileCommand; use Symfony\Component\Console\Input\InputOption; @@ -64,6 +65,10 @@ public function fire() $this->info('Compiling common classes'); $this->compileClasses(); + + $this->info('Compiling views'); + + $this->compileViews(); } else { @@ -113,6 +118,32 @@ protected function registerClassPreloaderCommand() $this->getApplication()->add(new PreCompileCommand); } + /** + * Compile all view files. + * + * @return void + */ + protected function compileViews() + { + $paths = $this->laravel['view']->getFinder() + ->getPaths(); + + foreach ($paths as $dir) + { + $files = $this->laravel['files']->allFiles($dir); + + foreach ($files as $path) + { + $engine = $this->laravel['view']->getEngineFromPath($path); + + if ($engine instanceof CompilerEngine) + { + $engine->getCompiler()->compile($path); + } + } + } + } + /** * Get the console command options. *
true
Other
laravel
framework
27d42308ed3c370b943b7c9db27dd4f4eaf685a6.json
make OptimizeCommand compile views
src/Illuminate/View/Factory.php
@@ -247,7 +247,7 @@ public function renderEach($view, $data, $iterator, $empty = 'raw|') * @param string $path * @return \Illuminate\View\Engines\EngineInterface */ - protected function getEngineFromPath($path) + public function getEngineFromPath($path) { $engine = $this->extensions[$this->getExtension($path)];
true
Other
laravel
framework
1bbb6f16aa03c1de6d89ccbf4ca81bf98e1330ab.json
Increment 4.1 version.
src/Illuminate/Foundation/Application.php
@@ -27,7 +27,7 @@ class Application extends Container implements HttpKernelInterface, TerminableIn * * @var string */ - const VERSION = '4.1.29'; + const VERSION = '4.1.30'; /** * Indicates if the application has "booted".
false
Other
laravel
framework
80cc5fd606afc2afd3d89f6e1636c5fc2e0dd296.json
Remove unneeded test.
tests/Database/DatabaseQueryBuilderTest.php
@@ -736,27 +736,6 @@ public function testQuickPaginateCorrectlyCreatesPaginatorInstance() } - public function testGetPaginationCountGetsResultCountWithSelectDistinct() - { - unset($_SERVER['orders']); - $builder = $this->getBuilder(); - $builder->getConnection()->shouldReceive('select')->once()->with('select count(distinct "foo", "bar") as aggregate from "users"', array())->andReturn(array(array('aggregate' => 1))); - $builder->getProcessor()->shouldReceive('processSelect')->once()->andReturnUsing(function($query, $results) - { - $_SERVER['orders'] = $query->orders; - return $results; - }); - $results = $builder->distinct()->select('foo', 'bar')->from('users')->orderBy('foo', 'desc')->getPaginationCount(); - - $this->assertNull($_SERVER['orders']); - unset($_SERVER['orders']); - - $this->assertEquals(array('foo', 'bar'), $builder->columns); - $this->assertEquals(array(0 => array('column' => 'foo', 'direction' => 'desc')), $builder->orders); - $this->assertEquals(1, $results); - } - - public function testPluckMethodReturnsSingleColumn() { $builder = $this->getBuilder();
false
Other
laravel
framework
f6106c4095f2b26833db6b600ff7ead88c2edb43.json
Remove unneeded test.
tests/Database/DatabaseQueryBuilderTest.php
@@ -718,27 +718,6 @@ public function testGetPaginationCountGetsResultCount() } - public function testGetPaginationCountGetsResultCountWithSelectDistinct() - { - unset($_SERVER['orders']); - $builder = $this->getBuilder(); - $builder->getConnection()->shouldReceive('select')->once()->with('select count(distinct "foo", "bar") as aggregate from "users"', array())->andReturn(array(array('aggregate' => 1))); - $builder->getProcessor()->shouldReceive('processSelect')->once()->andReturnUsing(function($query, $results) - { - $_SERVER['orders'] = $query->orders; - return $results; - }); - $results = $builder->distinct()->select('foo', 'bar')->from('users')->orderBy('foo', 'desc')->getPaginationCount(); - - $this->assertNull($_SERVER['orders']); - unset($_SERVER['orders']); - - $this->assertEquals(array('foo', 'bar'), $builder->columns); - $this->assertEquals(array(0 => array('column' => 'foo', 'direction' => 'desc')), $builder->orders); - $this->assertEquals(1, $results); - } - - public function testPluckMethodReturnsSingleColumn() { $builder = $this->getBuilder();
false
Other
laravel
framework
240fc43029f30bc3291673d7894b47607547ab34.json
Fix broken PR.
src/Illuminate/Database/Query/Builder.php
@@ -1558,27 +1558,13 @@ public function getPaginationCount() { $this->backupFieldsForCount(); - $columns = $this->columns; - - // We have to check if the value is "null" so that the count function does - // not attempt to count an invalid string. Checking the value is better - // here because the count function already has an optional parameter. - if (is_null($columns)) - { - $total = $this->count(); - } - else - { - $total = $this->count($columns); - } + // Because some database engines may throw errors if we leave the ordering + // statements on the query, we will "back them up" and remove them from + // the query. Once we have the count we will put them back onto this. + $total = $this->count(); $this->restoreFieldsForCount(); - // Once the query is run we need to put the old select columns back on the - // instance so that the select query will run properly. Otherwise, they - // will be cleared, then the query will fire with all of the columns. - $this->columns = $columns; - return $total; }
false
Other
laravel
framework
3201b00272251c4878b705cddb7d49f736500880.json
Use isset instead of array_key_exists.
src/Illuminate/Database/Eloquent/Model.php
@@ -2205,7 +2205,7 @@ public function attributesToArray() // formatting while accessing attributes vs. arraying / JSONing a model. foreach ($this->getDates() as $key) { - if ( ! array_key_exists($key, $attributes)) continue; + if ( ! isset($attributes[$key])) continue; $attributes[$key] = (string) $this->asDateTime($attributes[$key]); }
false
Other
laravel
framework
eec8a73e8ea13c7ca9a98942ec2a07aa84ffaf6d.json
fix buildSession call for database handler
src/Illuminate/Session/SessionManager.php
@@ -72,7 +72,7 @@ protected function createDatabaseDriver() $table = $connection->getTablePrefix().$this->app['config']['session.table']; - return $this->buildSession($connection, $table); + return $this->buildSession(new DatabaseSessionHandler($connection, $table)); } /**
false
Other
laravel
framework
39bcf2b439aa2966d4d5be1f53447a2347f7f4c9.json
Improve Collection extensibility Make the only `private` method `protected` so it can be used in other implementations.
src/Illuminate/Support/Collection.php
@@ -723,7 +723,7 @@ public function __toString() * @param \Illuminate\Support\Collection|\Illuminate\Support\Contracts\ArrayableInterface|array $items * @return array */ - private function getArrayableItems($items) + protected function getArrayableItems($items) { if ($items instanceof Collection) {
false
Other
laravel
framework
3f0269f97344deed0b7b5279d368a099837c7483.json
Limit repeated queries when token is not valid.
src/Illuminate/Auth/Guard.php
@@ -71,6 +71,13 @@ class Guard { */ protected $loggedOut = false; + /** + * Indicates if a token user retrieval has been attempted. + * + * @var bool + */ + protected $tokenRetrievalAttempted = false; + /** * Create a new authentication guard. * @@ -169,8 +176,10 @@ public function id() */ protected function getUserByRecaller($recaller) { - if ($this->validRecaller($recaller)) + if ($this->validRecaller($recaller) && ! $this->tokenRetrievalAttempted) { + $this->tokenRetrievalAttempted = true; + list($id, $token) = explode('|', $recaller, 2); $this->viaRemember = ! is_null($user = $this->provider->retrieveByToken($id, $token));
false
Other
laravel
framework
ce9b24fd47791d2b92233e236a82f61c96f78070.json
Add array_search to Support\Collection Add the ability to perform array_search on Support\Collection.
src/Illuminate/Support/Collection.php
@@ -376,6 +376,18 @@ public function reverse() return new static(array_reverse($this->items)); } + /** + * Search the collection for a given item and returns the corresponding key if successful + * + * @param mixed $value + * @param bool $strict + * @return mixed + */ + public function search($value, $strict = false) + { + return array_search($value, $this->items, $strict); + } + /** * Get and remove the first item from the collection. *
false
Other
laravel
framework
2a5604bdcdbcd8b533d49fe743c2efbe04ceabc1.json
Bring more in line with request::is.
src/Illuminate/Routing/Router.php
@@ -1510,12 +1510,20 @@ public function currentRouteName() /** * Alias for the "currentRouteNamed" method. * - * @param string $name + * @param dynamic string * @return bool */ - public function is($name) + public function is() { - return $this->currentRouteNamed($name); + foreach (func_get_args() as $pattern) + { + if (str_is($pattern, $this->currentRouteName())) + { + return true; + } + } + + return false; } /** @@ -1544,12 +1552,20 @@ public function currentRouteAction() /** * Alias for the "currentRouteUses" method. * - * @param string $action + * @param dynamic string * @return bool */ - public function isAction($action) + public function isAction() { - return $this->currentRouteUses($action); + foreach (func_get_args() as $pattern) + { + if (str_is($pattern, $this->currentRouteAction())) + { + return true; + } + } + + return false; } /**
false
Other
laravel
framework
5b0593b168d8d0422fd72320407f2e94fb71d525.json
Fix return type of docblock comment for bindIf
src/Illuminate/Container/Container.php
@@ -165,7 +165,7 @@ protected function getClosure($abstract, $concrete) * @param string $abstract * @param Closure|string|null $concrete * @param bool $shared - * @return bool + * @return void */ public function bindIf($abstract, $concrete = null, $shared = false) {
false
Other
laravel
framework
00249a5f379c2e94644bea9698a87105eeb00ca4.json
Add failing test Signed-off-by: Daniel Bøndergaard <danielboendergaard@gmail.com>
tests/Routing/RoutingRouteTest.php
@@ -608,6 +608,20 @@ public function testMergingControllerUses() $action = $routes[0]->getAction(); $this->assertEquals('Namespace\\Nested\\Controller', $action['controller']); + + + $router = $this->getRouter(); + $router->group(array('prefix' => 'baz'), function() use ($router) + { + $router->group(array('namespace' => 'Namespace'), function() use ($router) + { + $router->get('foo/bar', 'Controller'); + }); + }); + $routes = $router->getRoutes()->getRoutes(); + $action = $routes[0]->getAction(); + + $this->assertEquals('Namespace\\Controller', $action['controller']); }
false
Other
laravel
framework
c0eaab9554bc2971d8eb92261d36944f7657349b.json
Pull makes now use of array_pull
src/Illuminate/Support/Collection.php
@@ -325,11 +325,7 @@ public function push($value) */ public function pull($key, $default = null) { - $value = $this->get($key, $default); - - $this->forget($key); - - return $value; + return array_pull($this->items, $key, $default); } /**
false
Other
laravel
framework
8e96ccd6c78ca68c1d8e44f48fbab9ac0537229c.json
move remindabletrait into reminders namespace.
src/Illuminate/Auth/Reminders/RemindableTrait.php
@@ -1,4 +1,4 @@ -<?php namespace Illuminate\Auth; +<?php namespace Illuminate\Auth\Reminders; trait RemindableTrait {
false
Other
laravel
framework
05c8aa20962f2c20f0b5013bac35f70ae6298f7e.json
add helper method for using error_log
src/Illuminate/Log/Writer.php
@@ -5,6 +5,7 @@ use Monolog\Handler\StreamHandler; use Monolog\Logger as MonologLogger; use Monolog\Formatter\LineFormatter; +use Monolog\Handler\ErrorLogHandler; use Monolog\Handler\RotatingFileHandler; use Illuminate\Support\Contracts\JsonableInterface; use Illuminate\Support\Contracts\ArrayableInterface; @@ -88,7 +89,7 @@ public function useFiles($path, $level = 'debug') $this->monolog->pushHandler($handler = new StreamHandler($path, $level)); - $handler->setFormatter(new LineFormatter(null, null, true)); + $handler->setFormatter($this->getDefaultFormatter()); } /** @@ -105,7 +106,33 @@ public function useDailyFiles($path, $days = 0, $level = 'debug') $this->monolog->pushHandler($handler = new RotatingFileHandler($path, $days, $level)); - $handler->setFormatter(new LineFormatter(null, null, true)); + $handler->setFormatter($this->getDefaultFormatter()); + } + + /** + * Register an error_log handler. + * + * @param integer $messageType + * @param string $level + * @return void + */ + public function useErrorLog($level = 'debug', $messageType = ErrorLogHandler::OPERATING_SYSTEM) + { + $level = $this->parseLevel($level); + + $this->monolog->pushHandler($handler = new ErrorLogHandler($messageType, $level)); + + $handler->setFormatter($this->getDefaultFormatter()); + } + + /** + * Get a defaut Monolog formatter instance. + * + * @return \Monolog\Formatters\LineFormatter + */ + protected function getDefaultFormatter() + { + return new LineFormatter(null, null, true); } /**
true
Other
laravel
framework
05c8aa20962f2c20f0b5013bac35f70ae6298f7e.json
add helper method for using error_log
tests/Log/LogWriterTest.php
@@ -27,6 +27,14 @@ public function testRotatingFileHandlerCanBeAdded() } + public function testErrorLogHandlerCanBeAdded() + { + $writer = new Writer($monolog = m::mock('Monolog\Logger')); + $monolog->shouldReceive('pushHandler')->once()->with(m::type('Monolog\Handler\ErrorLogHandler')); + $writer->useErrorLog(); + } + + public function testMagicMethodsPassErrorAdditionsToMonolog() { $writer = new Writer($monolog = m::mock('Monolog\Logger'));
true
Other
laravel
framework
ef8a2da67113ddea36f30b38646c1ad5cf52f159.json
Prepare Query Bindings for Exception Prepare query bindings (format DateTime etc.) before passing them to Illuminate\Database\QueryException, this will prevent the "Object of class DateTime could not be converted to string" error that occurs when query errors are encountered.
src/Illuminate/Database/Connection.php
@@ -552,7 +552,7 @@ protected function run($query, $bindings, Closure $callback) // lot more helpful to the developer instead of just the database's errors. catch (\Exception $e) { - throw new QueryException($query, $bindings, $e); + throw new QueryException($query, $this->prepareBindings($bindings), $e); } // Once we have run the query we will calculate the time that it took to run and
false