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 | 99da7163fa53631b0449b11569fddc660e4806a7.json | Add missing throws docblocks. | src/Illuminate/Queue/SyncQueue.php | @@ -17,7 +17,8 @@ class SyncQueue extends Queue implements QueueContract
* @param mixed $data
* @param string $queue
* @return mixed
- * @throws \Throwable
+ *
+ * @throws \Exception|\Throwable
*/
public function push($job, $data = '', $queue = null)
{ | true |
Other | laravel | framework | 99da7163fa53631b0449b11569fddc660e4806a7.json | Add missing throws docblocks. | src/Illuminate/Routing/UrlGenerator.php | @@ -314,6 +314,8 @@ public function route($name, $parameters = [], $absolute = true)
* @param mixed $parameters
* @param bool $absolute
* @return string
+ *
+ * @throws \Illuminate\Routing\Exceptions\UrlGenerationException
*/
protected function toRoute($route, $parameters, $absolute)
{ | true |
Other | laravel | framework | 99da7163fa53631b0449b11569fddc660e4806a7.json | Add missing throws docblocks. | src/Illuminate/Support/Facades/Facade.php | @@ -199,6 +199,8 @@ public static function setFacadeApplication($app)
* @param string $method
* @param array $args
* @return mixed
+ *
+ * @throws \RuntimeException
*/
public static function __callStatic($method, $args)
{ | true |
Other | laravel | framework | 99da7163fa53631b0449b11569fddc660e4806a7.json | Add missing throws docblocks. | src/Illuminate/Support/ServiceProvider.php | @@ -225,6 +225,8 @@ public static function compiles()
* @param string $method
* @param array $parameters
* @return mixed
+ *
+ * @throws \BadMethodCallException
*/
public function __call($method, $parameters)
{ | true |
Other | laravel | framework | 99da7163fa53631b0449b11569fddc660e4806a7.json | Add missing throws docblocks. | src/Illuminate/Validation/ValidatesWhenResolvedTrait.php | @@ -41,6 +41,8 @@ protected function getValidatorInstance()
*
* @param \Illuminate\Validation\Validator $validator
* @return mixed
+ *
+ * @throws \Illuminate\Contracts\Validation\ValidationExceptio
*/
protected function failedValidation(Validator $validator)
{
@@ -64,7 +66,7 @@ protected function passesAuthorization()
/**
* Handle a failed authorization attempt.
*
- * @return mixed
+ * @throws \Illuminate\Contracts\Validation\UnauthorizedException
*/
protected function failedAuthorization()
{ | true |
Other | laravel | framework | 99da7163fa53631b0449b11569fddc660e4806a7.json | Add missing throws docblocks. | src/Illuminate/Validation/Validator.php | @@ -2728,6 +2728,7 @@ protected function callClassBasedReplacer($callback, $message, $attribute, $rule
* @param array $parameters
* @param string $rule
* @return void
+ *
* @throws \InvalidArgumentException
*/
protected function requireParameterCount($count, $parameters, $rule) | true |
Other | laravel | framework | 1a770409bedf0b0e4370257732f22ef88c472edc.json | Update docblock with correct return type | src/Illuminate/Auth/Console/stubs/make/controllers/HomeController.stub | @@ -20,7 +20,7 @@ class HomeController extends Controller
/**
* Show the application dashboard.
*
- * @return Response
+ * @return \Illuminate\Http\Response
*/
public function index()
{ | false |
Other | laravel | framework | 8fede3aa56c7b5b0544a70ef90302075d585ba3d.json | Add method for getting the column type
Add method for getting the database agnostic datatype of a column. | src/Illuminate/Database/Schema/Builder.php | @@ -89,6 +89,19 @@ public function hasColumns($table, array $columns)
return true;
}
+ /**
+ * Return the data type for the passed column name.
+ *
+ * @param string $table
+ * @param string $column
+ *
+ * @return string
+ */
+ public function getColumnType($table, $column)
+ {
+ return $this->connection->getDoctrineColumn($table, $column)->getType()->getName();
+ }
+
/**
* Get the column listing for a given table.
* | false |
Other | laravel | framework | bbfc14b60b50d2b9f327479cbbb0918dd4c6fc94.json | Use $fillable and $guarded accessor methods | src/Illuminate/Database/Eloquent/Model.php | @@ -478,8 +478,8 @@ public function forceFill(array $attributes)
*/
protected function fillableFromArray(array $attributes)
{
- if (count($this->fillable) > 0 && ! static::$unguarded) {
- return array_intersect_key($attributes, array_flip($this->fillable));
+ if (count($this->getFillable()) > 0 && ! static::$unguarded) {
+ return array_intersect_key($attributes, array_flip($this->getFillable()));
}
return $attributes;
@@ -2363,15 +2363,15 @@ public function isFillable($key)
// If the key is in the "fillable" array, we can of course assume that it's
// a fillable attribute. Otherwise, we will check the guarded array when
// we need to determine if the attribute is black-listed on the model.
- if (in_array($key, $this->fillable)) {
+ if (in_array($key, $this->getFillable())) {
return true;
}
if ($this->isGuarded($key)) {
return false;
}
- return empty($this->fillable) && ! Str::startsWith($key, '_');
+ return empty($this->getFillable()) && ! Str::startsWith($key, '_');
}
/**
@@ -2382,7 +2382,7 @@ public function isFillable($key)
*/
public function isGuarded($key)
{
- return in_array($key, $this->guarded) || $this->guarded == ['*'];
+ return in_array($key, $this->getGuarded()) || $this->getGuarded() == ['*'];
}
/**
@@ -2392,7 +2392,7 @@ public function isGuarded($key)
*/
public function totallyGuarded()
{
- return count($this->fillable) == 0 && $this->guarded == ['*'];
+ return count($this->getFillable()) == 0 && $this->getGuarded() == ['*'];
}
/** | false |
Other | laravel | framework | 9cce184103e6ef40d90dd601224efa11e30884b2.json | Fix eager loading within global scope | src/Illuminate/Database/Eloquent/Builder.php | @@ -232,16 +232,18 @@ public function firstOrFail($columns = ['*'])
*/
public function get($columns = ['*'])
{
- $models = $this->getModels($columns);
+ $builder = $this->applyScopes();
+
+ $models = $builder->getModels($columns);
// If we actually found models we will also eager load any relationships that
// have been specified as needing to be eager loaded, which will solve the
// n+1 query issue for the developers to avoid running a lot of queries.
if (count($models) > 0) {
- $models = $this->eagerLoadRelations($models);
+ $models = $builder->eagerLoadRelations($models);
}
- return $this->model->newCollection($models);
+ return $builder->getModel()->newCollection($models);
}
/**
@@ -498,7 +500,7 @@ public function onDelete(Closure $callback)
*/
public function getModels($columns = ['*'])
{
- $results = $this->toBase()->get($columns);
+ $results = $this->query->get($columns);
$connection = $this->model->getConnectionName();
| true |
Other | laravel | framework | 9cce184103e6ef40d90dd601224efa11e30884b2.json | Fix eager loading within global scope | src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php | @@ -173,15 +173,17 @@ public function get($columns = ['*'])
$select = $this->getSelectColumns($columns);
- $models = $this->query->addSelect($select)->getModels();
+ $builder = $this->query->applyScopes();
+
+ $models = $builder->addSelect($select)->getModels();
$this->hydratePivotRelation($models);
// If we actually found models we will also eager load any relationships that
// have been specified as needing to be eager loaded. This will solve the
// n + 1 query problem for the developer and also increase performance.
if (count($models) > 0) {
- $models = $this->query->eagerLoadRelations($models);
+ $models = $builder->eagerLoadRelations($models);
}
return $this->related->newCollection($models); | true |
Other | laravel | framework | 9cce184103e6ef40d90dd601224efa11e30884b2.json | Fix eager loading within global scope | src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php | @@ -322,13 +322,15 @@ public function get($columns = ['*'])
$select = $this->getSelectColumns($columns);
- $models = $this->query->addSelect($select)->getModels();
+ $builder = $this->query->applyScopes();
+
+ $models = $builder->addSelect($select)->getModels();
// If we actually found models we will also eager load any relationships that
// have been specified as needing to be eager loaded. This will solve the
// n + 1 query problem for the developer and also increase performance.
if (count($models) > 0) {
- $models = $this->query->eagerLoadRelations($models);
+ $models = $builder->eagerLoadRelations($models);
}
return $this->related->newCollection($models); | true |
Other | laravel | framework | 9cce184103e6ef40d90dd601224efa11e30884b2.json | Fix eager loading within global scope | tests/Database/DatabaseEloquentBelongsToManyTest.php | @@ -24,6 +24,7 @@ public function testModelsAreProperlyHydrated()
$relation = $this->getRelation();
$relation->getParent()->shouldReceive('getConnectionName')->andReturn('foo.connection');
$relation->getQuery()->shouldReceive('addSelect')->once()->with(['roles.*', 'user_role.user_id as pivot_user_id', 'user_role.role_id as pivot_role_id'])->andReturn($relation->getQuery());
+ $relation->getQuery()->shouldReceive('applyScopes')->once()->andReturnSelf();
$relation->getQuery()->shouldReceive('getModels')->once()->andReturn($models);
$relation->getQuery()->shouldReceive('eagerLoadRelations')->once()->with($models)->andReturn($models);
$relation->getRelated()->shouldReceive('newCollection')->andReturnUsing(function ($array) { return new Collection($array); });
@@ -67,6 +68,7 @@ public function testTimestampsCanBeRetrievedProperly()
'user_role.created_at as pivot_created_at',
'user_role.updated_at as pivot_updated_at',
])->andReturn($relation->getQuery());
+ $relation->getQuery()->shouldReceive('applyScopes')->once()->andReturnSelf();
$relation->getQuery()->shouldReceive('getModels')->once()->andReturn($models);
$relation->getQuery()->shouldReceive('eagerLoadRelations')->once()->with($models)->andReturn($models);
$relation->getRelated()->shouldReceive('newCollection')->andReturnUsing(function ($array) { return new Collection($array); }); | true |
Other | laravel | framework | 9cce184103e6ef40d90dd601224efa11e30884b2.json | Fix eager loading within global scope | tests/Database/DatabaseEloquentBuilderTest.php | @@ -112,6 +112,7 @@ public function testFirstMethod()
public function testGetMethodLoadsModelsAndHydratesEagerRelations()
{
$builder = m::mock('Illuminate\Database\Eloquent\Builder[getModels,eagerLoadRelations]', [$this->getMockQueryBuilder()]);
+ $builder->shouldReceive('applyScopes')->andReturnSelf();
$builder->shouldReceive('getModels')->with(['foo'])->andReturn(['bar']);
$builder->shouldReceive('eagerLoadRelations')->with(['bar'])->andReturn(['bar', 'baz']);
$builder->setModel($this->getMockModel());
@@ -124,6 +125,7 @@ public function testGetMethodLoadsModelsAndHydratesEagerRelations()
public function testGetMethodDoesntHydrateEagerRelationsWhenNoResultsAreReturned()
{
$builder = m::mock('Illuminate\Database\Eloquent\Builder[getModels,eagerLoadRelations]', [$this->getMockQueryBuilder()]);
+ $builder->shouldReceive('applyScopes')->andReturnSelf();
$builder->shouldReceive('getModels')->with(['foo'])->andReturn([]);
$builder->shouldReceive('eagerLoadRelations')->never();
$builder->setModel($this->getMockModel()); | true |
Other | laravel | framework | 9cce184103e6ef40d90dd601224efa11e30884b2.json | Fix eager loading within global scope | tests/Database/DatabaseEloquentHasManyThroughTest.php | @@ -102,6 +102,7 @@ public function testAllColumnsAreSelectedByDefault()
$relation->getRelated()->shouldReceive('newCollection')->once();
$builder = $relation->getQuery();
+ $builder->shouldReceive('applyScopes')->andReturnSelf();
$builder->shouldReceive('getQuery')->andReturn($baseBuilder);
$builder->shouldReceive('addSelect')->once()->with($select)->andReturn($builder);
$builder->shouldReceive('getModels')->once()->andReturn([]);
@@ -120,6 +121,7 @@ public function testOnlyProperColumnsAreSelectedIfProvided()
$relation->getRelated()->shouldReceive('newCollection')->once();
$builder = $relation->getQuery();
+ $builder->shouldReceive('applyScopes')->andReturnSelf();
$builder->shouldReceive('getQuery')->andReturn($baseBuilder);
$builder->shouldReceive('addSelect')->once()->with($select)->andReturn($builder);
$builder->shouldReceive('getModels')->once()->andReturn([]); | true |
Other | laravel | framework | 9cce184103e6ef40d90dd601224efa11e30884b2.json | Fix eager loading within global scope | tests/Database/DatabaseEloquentIntegrationTest.php | @@ -598,6 +598,16 @@ public function testDefaultIncrementingPrimaryKeyIntegerCastCanBeOverwritten()
$this->assertInternalType('string', $user->id);
}
+ public function testRelationsArePreloadedInGlobalScope()
+ {
+ $user = EloquentTestUserWithGlobalScope::create(['email' => 'taylorotwell@gmail.com']);
+ $user->posts()->create(['name' => 'My Post']);
+
+ $result = EloquentTestUserWithGlobalScope::first();
+
+ $this->assertCount(1, $result->getRelations());
+ }
+
/**
* Helpers...
*/
@@ -652,6 +662,18 @@ public function photos()
}
}
+class EloquentTestUserWithGlobalScope extends EloquentTestUser
+{
+ public static function boot()
+ {
+ parent::boot();
+
+ static::addGlobalScope(function ($builder) {
+ $builder->with('posts');
+ });
+ }
+}
+
class EloquentTestPost extends Eloquent
{
protected $table = 'posts'; | true |
Other | laravel | framework | 1a7ee5a96754304df0c798969b96a2617a45a168.json | set exception on response | src/Illuminate/Http/Response.php | @@ -2,6 +2,7 @@
namespace Illuminate\Http;
+use Exception;
use ArrayObject;
use JsonSerializable;
use Illuminate\Contracts\Support\Jsonable;
@@ -93,4 +94,17 @@ public function getOriginalContent()
{
return $this->original;
}
+
+ /**
+ * Set the exception to attach to the response.
+ *
+ * @param \Exception $e
+ * @return $this
+ */
+ public function withException(Exception $e)
+ {
+ $this->exception = $e;
+
+ return $this;
+ }
} | true |
Other | laravel | framework | 1a7ee5a96754304df0c798969b96a2617a45a168.json | set exception on response | src/Illuminate/Routing/Pipeline.php | @@ -77,6 +77,12 @@ protected function handleException($passable, Exception $e)
$handler->report($e);
- return $handler->render($passable, $e);
+ $response = $handler->render($passable, $e);
+
+ if (method_exists($response, 'withException')) {
+ $response->withException($e);
+ }
+
+ return $response;
}
} | true |
Other | laravel | framework | 29198f4c1f5bbf0c800e760436e9d13ce5c9fe89.json | fix some formatting issues | src/Illuminate/Foundation/Auth/ResetsPasswords.php | @@ -11,26 +11,6 @@ trait ResetsPasswords
{
use RedirectsUsers;
- /**
- * Get the broker to be used during resetting the password.
- *
- * @return string|null
- */
- public function getBroker()
- {
- return property_exists($this, 'broker') ? $this->broker : null;
- }
-
- /**
- * Get the guard to be used during authentication.
- *
- * @return string|null
- */
- protected function getGuard()
- {
- return property_exists($this, 'guard') ? $this->guard : null;
- }
-
/**
* Display the form to request a password reset link.
*
@@ -76,7 +56,9 @@ public function sendResetLinkEmail(Request $request)
{
$this->validate($request, ['email' => 'required|email']);
- $response = Password::broker($this->getBroker())->sendResetLink($request->only('email'), function (Message $message) {
+ $broker = $this->getBroker();
+
+ $response = Password::broker($broker)->sendResetLink($request->only('email'), function (Message $message) {
$message->subject($this->getEmailSubject());
});
@@ -189,7 +171,9 @@ public function reset(Request $request)
'email', 'password', 'password_confirmation', 'token'
);
- $response = Password::broker($this->getBroker())->reset($credentials, function ($user, $password) {
+ $broker = $this->getBroker();
+
+ $response = Password::broker($broker)->reset($credentials, function ($user, $password) {
$this->resetPassword($user, $password);
});
@@ -242,4 +226,24 @@ protected function getResetFailureResponse(Request $request, $response)
->withInput($request->only('email'))
->withErrors(['email' => trans($response)]);
}
+
+ /**
+ * Get the broker to be used during password reset.
+ *
+ * @return string|null
+ */
+ public function getBroker()
+ {
+ return property_exists($this, 'broker') ? $this->broker : null;
+ }
+
+ /**
+ * Get the guard to be used during password reset.
+ *
+ * @return string|null
+ */
+ protected function getGuard()
+ {
+ return property_exists($this, 'guard') ? $this->guard : null;
+ }
} | false |
Other | laravel | framework | f322d52ce9b41b6b543a49ad0196a7599e1c2f28.json | Fix FormRequest tests. | tests/Foundation/FoundationFormRequestTest.php | @@ -3,27 +3,25 @@
use Mockery as m;
use Illuminate\Container\Container;
-class FoundationFormRequestTestCase extends PHPUnit_Framework_TestCase
+class FoundationFormRequestTest extends PHPUnit_Framework_TestCase
{
public function tearDown()
{
m::close();
- unset($_SERVER['__request.validated']);
}
public function testValidateFunctionRunsValidatorOnSpecifiedRules()
{
$request = FoundationTestFormRequestStub::create('/', 'GET', ['name' => 'abigail']);
- $request->setContainer(new Container);
+ $request->setContainer($container = new Container);
$factory = m::mock('Illuminate\Validation\Factory');
- $factory->shouldReceive('make')->once()->with(['name' => 'abigail'], ['name' => 'required'])->andReturn(
+ $factory->shouldReceive('make')->once()->with(['name' => 'abigail'], ['name' => 'required'], [], [])->andReturn(
$validator = m::mock('Illuminate\Validation\Validator')
);
- $validator->shouldReceive('fails')->once()->andReturn(false);
+ $container->instance('Illuminate\Contracts\Validation\Factory', $factory);
+ $validator->shouldReceive('passes')->once()->andReturn(true);
$request->validate($factory);
-
- $this->assertTrue($_SERVER['__request.validated']);
}
/**
@@ -33,14 +31,15 @@ public function testValidateFunctionThrowsHttpResponseExceptionIfValidationFails
{
$request = m::mock('FoundationTestFormRequestStub[response]');
$request->initialize(['name' => null]);
- $request->setContainer(new Container);
+ $request->setContainer($container = new Container);
$factory = m::mock('Illuminate\Validation\Factory');
- $factory->shouldReceive('make')->once()->with(['name' => null], ['name' => 'required'])->andReturn(
+ $factory->shouldReceive('make')->once()->with(['name' => null], ['name' => 'required'], [], [])->andReturn(
$validator = m::mock('Illuminate\Validation\Validator')
);
- $validator->shouldReceive('fails')->once()->andReturn(true);
- $validator->shouldReceive('errors')->once()->andReturn($messages = m::mock('StdClass'));
- $messages->shouldReceive('all')->once()->andReturn([]);
+ $container->instance('Illuminate\Contracts\Validation\Factory', $factory);
+ $validator->shouldReceive('passes')->once()->andReturn(false);
+ $validator->shouldReceive('getMessageBag')->once()->andReturn($messages = m::mock('Illuminate\Support\MessageBag'));
+ $messages->shouldReceive('toArray')->once()->andReturn(['name' => ['Name required']]);
$request->shouldReceive('response')->once()->andReturn(new Illuminate\Http\Response);
$request->validate($factory);
@@ -53,12 +52,13 @@ public function testValidateFunctionThrowsHttpResponseExceptionIfAuthorizationFa
{
$request = m::mock('FoundationTestFormRequestForbiddenStub[forbiddenResponse]');
$request->initialize(['name' => null]);
- $request->setContainer(new Container);
+ $request->setContainer($container = new Container);
$factory = m::mock('Illuminate\Validation\Factory');
- $factory->shouldReceive('make')->once()->with(['name' => null], ['name' => 'required'])->andReturn(
+ $factory->shouldReceive('make')->once()->with(['name' => null], ['name' => 'required'], [], [])->andReturn(
$validator = m::mock('Illuminate\Validation\Validator')
);
- $validator->shouldReceive('fails')->once()->andReturn(false);
+ $container->instance('Illuminate\Contracts\Validation\Factory', $factory);
+ $validator->shouldReceive('passes')->never();
$request->shouldReceive('forbiddenResponse')->once()->andReturn(new Illuminate\Http\Response);
$request->validate($factory);
@@ -72,28 +72,23 @@ public function testRedirectResponseIsProperlyCreatedWithGivenErrors()
$redirector->shouldReceive('getUrlGenerator')->andReturn($url = m::mock('StdClass'));
$url->shouldReceive('previous')->once()->andReturn('previous');
$response->shouldReceive('withInput')->andReturn($response);
- $response->shouldReceive('withErrors')->with(['errors'])->andReturn($response);
+ $response->shouldReceive('withErrors')->with(['errors'], 'default')->andReturn($response);
$request->response(['errors']);
}
}
class FoundationTestFormRequestStub extends Illuminate\Foundation\Http\FormRequest
{
- public function rules(StdClass $dep)
+ public function rules()
{
return ['name' => 'required'];
}
- public function authorize(StdClass $dep)
+ public function authorize()
{
return true;
}
-
- public function validated(StdClass $dep)
- {
- $_SERVER['__request.validated'] = true;
- }
}
class FoundationTestFormRequestForbiddenStub extends Illuminate\Foundation\Http\FormRequest | false |
Other | laravel | framework | cadee788ab41d6f6122a1caff79a067ed38aebde.json | Add key to collection reject | src/Illuminate/Support/Collection.php | @@ -652,8 +652,8 @@ public function reduce(callable $callback, $initial = null)
public function reject($callback)
{
if ($this->useAsCallable($callback)) {
- return $this->filter(function ($item) use ($callback) {
- return ! $callback($item);
+ return $this->filter(function ($value, $key) use ($callback) {
+ return ! $callback($value, $key);
});
}
| true |
Other | laravel | framework | cadee788ab41d6f6122a1caff79a067ed38aebde.json | Add key to collection reject | tests/Support/SupportCollectionTest.php | @@ -883,6 +883,11 @@ public function testRejectRemovesElementsPassingTruthTest()
$c = new Collection(['foo', 'bar']);
$this->assertEquals(['foo', 'bar'], $c->reject(function ($v) { return $v == 'baz'; })->values()->all());
+
+ $c = new Collection(['id' => 1, 'primary' => 'foo', 'secondary' => 'bar']);
+ $this->assertEquals(['primary' => 'foo', 'secondary' => 'bar'], $c->reject(function ($item, $key) {
+ return $key == 'id';
+ })->all());
}
public function testSearchReturnsIndexOfFirstFoundItem() | true |
Other | laravel | framework | 491feeb82ac27542c6a5512f26735451a2d9c09f.json | allow passing of conditions to where with arrays. | src/Illuminate/Database/Query/Builder.php | @@ -450,11 +450,7 @@ public function where($column, $operator = null, $value = null, $boolean = 'and'
// and can add them each as a where clause. We will maintain the boolean we
// received when the method was called and pass it into the nested where.
if (is_array($column)) {
- return $this->whereNested(function ($query) use ($column) {
- foreach ($column as $key => $value) {
- $query->where($key, '=', $value);
- }
- }, $boolean);
+ return $this->addArrayOfWheres($column, $boolean);
}
// Here we will make some assumptions about the operator. If only 2 values are
@@ -508,6 +504,26 @@ public function where($column, $operator = null, $value = null, $boolean = 'and'
return $this;
}
+ /**
+ * Add an array of where clauses to the query.
+ *
+ * @param array $column
+ * @param string $boolean
+ * @return $this
+ */
+ protected function addArrayOfWheres($column, $boolean)
+ {
+ return $this->whereNested(function ($query) use ($column) {
+ foreach ($column as $key => $value) {
+ if (is_numeric($key) && is_array($value)) {
+ call_user_func_array([$query, 'where'], $value);
+ } else {
+ $query->where($key, '=', $value);
+ }
+ }
+ }, $boolean);
+ }
+
/**
* Add an "or where" clause to the query.
* | true |
Other | laravel | framework | 491feeb82ac27542c6a5512f26735451a2d9c09f.json | allow passing of conditions to where with arrays. | tests/Database/DatabaseQueryBuilderTest.php | @@ -610,6 +610,24 @@ public function testWhereShortcut()
$this->assertEquals([0 => 1, 1 => 'foo'], $builder->getBindings());
}
+ public function testWhereWithArrayConditions()
+ {
+ $builder = $this->getBuilder();
+ $builder->select('*')->from('users')->where([['foo', 1], ['bar', 2]]);
+ $this->assertEquals('select * from "users" where ("foo" = ? and "bar" = ?)', $builder->toSql());
+ $this->assertEquals([0 => 1, 1 => 2], $builder->getBindings());
+
+ $builder = $this->getBuilder();
+ $builder->select('*')->from('users')->where(['foo' => 1, 'bar' => 2]);
+ $this->assertEquals('select * from "users" where ("foo" = ? and "bar" = ?)', $builder->toSql());
+ $this->assertEquals([0 => 1, 1 => 2], $builder->getBindings());
+
+ $builder = $this->getBuilder();
+ $builder->select('*')->from('users')->where([['foo', 1], ['bar', '<', 2]]);
+ $this->assertEquals('select * from "users" where ("foo" = ? and "bar" < ?)', $builder->toSql());
+ $this->assertEquals([0 => 1, 1 => 2], $builder->getBindings());
+ }
+
public function testNestedWheres()
{
$builder = $this->getBuilder(); | true |
Other | laravel | framework | a38141968d3ce58f9b54b31ee970c14c7d48edbe.json | Add missing methods to the Job contract. | src/Illuminate/Contracts/Queue/Job.php | @@ -46,4 +46,32 @@ public function getName();
* @return string
*/
public function getQueue();
+
+ /**
+ * Determine if the job has been deleted or released.
+ *
+ * @return bool
+ */
+ public function isDeletedOrReleased();
+
+ /**
+ * Determine if the job has been deleted.
+ *
+ * @return bool
+ */
+ public function isDeleted();
+
+ /**
+ * Get the raw body string for the job.
+ *
+ * @return string
+ */
+ public function getRawBody();
+
+ /**
+ * Call the failed method on the job instance.
+ *
+ * @return void
+ */
+ public function failed();
} | false |
Other | laravel | framework | c09af03f61e6b67c1c0625ab0cc170d2a88ca7bc.json | Add hasParameters to Route
Route->parameters() throws an exception if the route has none, this helper function allows developers to check the presence of parameters and avoid the exception where none are set.
A personal preference would to be remove the "Route not bound" exception but this is an inbetween work around. | src/Illuminate/Routing/Route.php | @@ -279,6 +279,10 @@ public function signatureParameters($subClass = null)
*/
public function hasParameter($name)
{
+ if(! $this->hasParameters()) {
+ return false;
+ }
+
return array_key_exists($name, $this->parameters());
}
@@ -333,6 +337,16 @@ public function forgetParameter($name)
unset($this->parameters[$name]);
}
+ /**
+ * Determine if the route has parameters
+ *
+ * @return bool
+ */
+ public function hasParameters()
+ {
+ return isset($this->parameters);
+ }
+
/**
* Get the key / value list of parameters for the route.
* | false |
Other | laravel | framework | 0c2b7da2635f7bbbaf63d1b93fa817232bdd9d65.json | Use the current timestamp as a default. | src/Illuminate/Database/Schema/Blueprint.php | @@ -791,9 +791,9 @@ public function nullableTimestamps()
*/
public function timestamps()
{
- $this->timestamp('created_at');
+ $this->timestamp('created_at')->useCurrent();
- $this->timestamp('updated_at');
+ $this->timestamp('updated_at')->useCurrent();
}
/** | false |
Other | laravel | framework | bf902a261296ee3f9344badf871e4f28e547a411.json | Move exception to validation component. | src/Illuminate/Foundation/Exceptions/Handler.php | @@ -5,12 +5,12 @@
use Exception;
use Psr\Log\LoggerInterface;
use Illuminate\Http\Response;
+use Illuminate\Validation\ValidationException;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Http\Exception\HttpResponseException;
use Symfony\Component\Debug\Exception\FlattenException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpKernel\Exception\HttpException;
-use Illuminate\Foundation\Validation\ValidationException;
use Symfony\Component\Console\Application as ConsoleApplication;
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | true |
Other | laravel | framework | bf902a261296ee3f9344badf871e4f28e547a411.json | Move exception to validation component. | src/Illuminate/Foundation/Validation/ValidationException.php | @@ -3,45 +3,11 @@
namespace Illuminate\Foundation\Validation;
use Exception;
+use Illuminate\Validation\ValidationException as BaseException;
-class ValidationException extends Exception
+/**
+ * @deprecated since 5.3. Use Illuminate\Validation\ValidationException.
+ */
+class ValidationException extends BaseException
{
- /**
- * The validator instance.
- *
- * @var \Illuminate\Validation\Validator
- */
- public $validator;
-
- /**
- * The recommended response to send to the client.
- *
- * @var \Illuminate\Http\Response|null
- */
- public $response;
-
- /**
- * Create a new exception instance.
- *
- * @param \Illuminate\Validation\Validator $validator
- * @param \Illuminate\Http\Response $response
- * @return void
- */
- public function __construct($validator, $response = null)
- {
- parent::__construct('The given data failed to pass validation.');
-
- $this->response = $response;
- $this->validator = $validator;
- }
-
- /**
- * Get the underlying response instance.
- *
- * @return \Symfony\Component\HttpFoundation\Response
- */
- public function getResponse()
- {
- return $this->response;
- }
} | true |
Other | laravel | framework | bf902a261296ee3f9344badf871e4f28e547a411.json | Move exception to validation component. | src/Illuminate/Validation/ValidationException.php | @@ -0,0 +1,47 @@
+<?php
+
+namespace Illuminate\Validation;
+
+use Exception;
+
+class ValidationException extends Exception
+{
+ /**
+ * The validator instance.
+ *
+ * @var \Illuminate\Validation\Validator
+ */
+ public $validator;
+
+ /**
+ * The recommended response to send to the client.
+ *
+ * @var \Illuminate\Http\Response|null
+ */
+ public $response;
+
+ /**
+ * Create a new exception instance.
+ *
+ * @param \Illuminate\Validation\Validator $validator
+ * @param \Illuminate\Http\Response $response
+ * @return void
+ */
+ public function __construct($validator, $response = null)
+ {
+ parent::__construct('The given data failed to pass validation.');
+
+ $this->response = $response;
+ $this->validator = $validator;
+ }
+
+ /**
+ * Get the underlying response instance.
+ *
+ * @return \Symfony\Component\HttpFoundation\Response
+ */
+ public function getResponse()
+ {
+ return $this->response;
+ }
+} | true |
Other | laravel | framework | 7dc8d71494f186478fce8d65b725b5b7f5104a08.json | Declare $selector property. | src/Illuminate/Translation/Translator.php | @@ -39,6 +39,13 @@ class Translator extends NamespacedItemResolver implements TranslatorInterface
*/
protected $loaded = [];
+ /**
+ * The message selector.
+ *
+ * @var \Symfony\Component\Translation\MessageSelector
+ */
+ protected $selector;
+
/**
* Create a new translator instance.
* | false |
Other | laravel | framework | 3213f88d9738e952d519b927f3389c72a1b2bb53.json | Fix wrong DocBlocks Parameter name | src/Illuminate/Foundation/Auth/AuthenticatesUsers.php | @@ -105,7 +105,7 @@ protected function handleUserWasAuthenticated(Request $request, $throttles)
/**
* Get the failed login response instance.
*
- * @param \Illuminate\Http\Request $response
+ * @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
protected function sendFailedLoginResponse(Request $request) | false |
Other | laravel | framework | b55592a57eeac8d76c27f343c159e63ebc65c5d2.json | Allow extra conditions using HTTP basic auth | src/Illuminate/Auth/SessionGuard.php | @@ -260,9 +260,10 @@ public function validate(array $credentials = [])
* Attempt to authenticate using HTTP Basic Auth.
*
* @param string $field
+ * @param array $extraConditions
* @return \Symfony\Component\HttpFoundation\Response|null
*/
- public function basic($field = 'email')
+ public function basic($field = 'email', $extraConditions = [])
{
if ($this->check()) {
return;
@@ -271,7 +272,7 @@ public function basic($field = 'email')
// If a username is set on the HTTP basic request, we will return out without
// interrupting the request lifecycle. Otherwise, we'll need to generate a
// request indicating that the given credentials were invalid for login.
- if ($this->attemptBasic($this->getRequest(), $field)) {
+ if ($this->attemptBasic($this->getRequest(), $field, $extraConditions)) {
return;
}
@@ -282,11 +283,14 @@ public function basic($field = 'email')
* Perform a stateless HTTP Basic login attempt.
*
* @param string $field
+ * @param array $extraConditions
* @return \Symfony\Component\HttpFoundation\Response|null
*/
- public function onceBasic($field = 'email')
+ public function onceBasic($field = 'email', $extraConditions = [])
{
- if (! $this->once($this->getBasicCredentials($this->getRequest(), $field))) {
+ $credentials = $this->getBasicCredentials($this->getRequest(), $field);
+
+ if (! $this->once(array_merge($credentials, $extraConditions))) {
return $this->getBasicResponse();
}
}
@@ -296,15 +300,18 @@ public function onceBasic($field = 'email')
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @param string $field
+ * @param array $extraConditions
* @return bool
*/
- protected function attemptBasic(Request $request, $field)
+ protected function attemptBasic(Request $request, $field, $extraConditions = [])
{
if (! $request->getUser()) {
return false;
}
- return $this->attempt($this->getBasicCredentials($request, $field));
+ $credentials = $this->getBasicCredentials($request, $field);
+
+ return $this->attempt(array_merge($credentials, $extraConditions));
}
/** | true |
Other | laravel | framework | b55592a57eeac8d76c27f343c159e63ebc65c5d2.json | Allow extra conditions using HTTP basic auth | src/Illuminate/Contracts/Auth/SupportsBasicAuth.php | @@ -8,15 +8,17 @@ interface SupportsBasicAuth
* Attempt to authenticate using HTTP Basic Auth.
*
* @param string $field
+ * @param array $extraConditions
* @return \Symfony\Component\HttpFoundation\Response|null
*/
- public function basic($field = 'email');
+ public function basic($field = 'email', $extraConditions = []);
/**
* Perform a stateless HTTP Basic login attempt.
*
* @param string $field
+ * @param array $extraConditions
* @return \Symfony\Component\HttpFoundation\Response|null
*/
- public function onceBasic($field = 'email');
+ public function onceBasic($field = 'email', $extraConditions = []);
} | true |
Other | laravel | framework | b55592a57eeac8d76c27f343c159e63ebc65c5d2.json | Allow extra conditions using HTTP basic auth | tests/Auth/AuthGuardTest.php | @@ -49,6 +49,18 @@ public function testBasicReturnsResponseOnFailure()
$this->assertEquals(401, $response->getStatusCode());
}
+ public function testBasicWithExtraConditions()
+ {
+ list($session, $provider, $request, $cookie) = $this->getMocks();
+ $guard = m::mock('Illuminate\Auth\SessionGuard[check,attempt]', ['default', $provider, $session]);
+ $guard->shouldReceive('check')->once()->andReturn(false);
+ $guard->shouldReceive('attempt')->once()->with(['email' => 'foo@bar.com', 'password' => 'secret', 'active' => 1])->andReturn(true);
+ $request = Symfony\Component\HttpFoundation\Request::create('/', 'GET', [], [], [], ['PHP_AUTH_USER' => 'foo@bar.com', 'PHP_AUTH_PW' => 'secret']);
+ $guard->setRequest($request);
+
+ $guard->basic('email', ['active' => 1]);
+ }
+
public function testAttemptCallsRetrieveByCredentials()
{
$guard = $this->getGuard(); | true |
Other | laravel | framework | d56e23f0838644c10ebb9ad3fa31412891a2886e.json | Add support for using keys in Collection filter | src/Illuminate/Support/Collection.php | @@ -186,7 +186,15 @@ public function except($keys)
public function filter(callable $callback = null)
{
if ($callback) {
- return new static(array_filter($this->items, $callback));
+ $return = [];
+
+ foreach ($this->items as $key => $value) {
+ if ($callback($value, $key)) {
+ $return[$key] = $value;
+ }
+ }
+
+ return new static($return);
}
return new static(array_filter($this->items)); | true |
Other | laravel | framework | d56e23f0838644c10ebb9ad3fa31412891a2886e.json | Add support for using keys in Collection filter | tests/Support/SupportCollectionTest.php | @@ -254,6 +254,11 @@ public function testFilter()
$c = new Collection(['', 'Hello', '', 'World']);
$this->assertEquals(['Hello', 'World'], $c->filter()->values()->toArray());
+
+ $c = new Collection(['id' => 1, 'first' => 'Hello', 'second' => 'World']);
+ $this->assertEquals(['first' => 'Hello', 'second' => 'World'], $c->filter(function ($item, $key) {
+ return $key != 'id';
+ })->all());
}
public function testWhere() | true |
Other | laravel | framework | 18eb5caa48888e3e21228a652c97490ecfea01cd.json | fix method order | src/Illuminate/Console/Scheduling/Event.php | @@ -498,23 +498,23 @@ public function monthly()
}
/**
- * Schedule the event to run yearly.
+ * Schedule the event to run quarterly.
*
* @return $this
*/
- public function yearly()
+ public function quarterly()
{
- return $this->cron('0 0 1 1 * *');
+ return $this->cron('0 0 1 */3 *');
}
/**
- * Schedule the event to run quarterly.
+ * Schedule the event to run yearly.
*
* @return $this
*/
- public function quarterly()
+ public function yearly()
{
- return $this->cron('0 0 1 */3 *');
+ return $this->cron('0 0 1 1 * *');
}
/** | false |
Other | laravel | framework | 3f1c412034d6d3ef233afcb514f65c05a4a2e5b6.json | Add getBroker() and getGuard() | src/Illuminate/Foundation/Auth/ResetsPasswords.php | @@ -11,6 +11,25 @@ trait ResetsPasswords
{
use RedirectsUsers;
+ /**
+ * Get the broker to be used during resetting the password
+ * @return string|null
+ */
+ public function getBroker()
+ {
+ return property_exists($this, 'broker') ? $this->broker : null;
+ }
+
+ /**
+ * Get the guard to be used during authentication.
+ *
+ * @return string|null
+ */
+ protected function getGuard()
+ {
+ return property_exists($this, 'guard') ? $this->guard : null;
+ }
+
/**
* Display the form to request a password reset link.
*
@@ -56,7 +75,7 @@ public function sendResetLinkEmail(Request $request)
{
$this->validate($request, ['email' => 'required|email']);
- $response = Password::sendResetLink($request->only('email'), function (Message $message) {
+ $response = Password::broker($this->getBroker())->sendResetLink($request->only('email'), function (Message $message) {
$message->subject($this->getEmailSubject());
});
@@ -169,7 +188,7 @@ public function reset(Request $request)
'email', 'password', 'password_confirmation', 'token'
);
- $response = Password::reset($credentials, function ($user, $password) {
+ $response = Password::broker($this->getBroker())->reset($credentials, function ($user, $password) {
$this->resetPassword($user, $password);
});
@@ -195,7 +214,7 @@ protected function resetPassword($user, $password)
$user->save();
- Auth::login($user);
+ Auth::guard($this->getGuard())->login($user);
}
/** | false |
Other | laravel | framework | e53d12ae28536d42f93e6a5c7327eefd05c6b2cf.json | Allow quarterly Scheduling | src/Illuminate/Console/Scheduling/Event.php | @@ -507,6 +507,16 @@ public function yearly()
return $this->cron('0 0 1 1 * *');
}
+ /**
+ * Schedule the event to run quarterly.
+ *
+ * @return $this
+ */
+ public function quarterly()
+ {
+ return $this->cron('0 0 1 */3 *');
+ }
+
/**
* Schedule the event to run every minute.
* | false |
Other | laravel | framework | c4f8f492731756ca53a13e656af7f9f2e3574396.json | Use early return | src/Illuminate/Console/Scheduling/Event.php | @@ -702,7 +702,7 @@ public function emailOutputTo($addresses)
/**
* E-mail the results of the scheduled operation only when it produces output.
*
- * @param array|mixed $addresses
+ * @param array|mixed $addresses
* @return $this
*
* @throws \LogicException
@@ -732,15 +732,17 @@ protected function emailOutput(Mailer $mailer, $addresses, $includeEmpty = true)
{
$text = file_get_contents($this->output);
- if ($includeEmpty || ! empty($text)) {
- $mailer->raw($text, function ($m) use ($addresses) {
- $m->subject($this->getEmailSubject());
-
- foreach ($addresses as $address) {
- $m->to($address);
- }
- });
+ if (! $includeEmpty && empty($text)) {
+ return;
}
+
+ $mailer->raw($text, function ($m) use ($addresses) {
+ $m->subject($this->getEmailSubject());
+
+ foreach ($addresses as $address) {
+ $m->to($address);
+ }
+ });
}
/** | false |
Other | laravel | framework | 2f158e113506130561c484bcd0ea5a8f959393cb.json | Allow listener for core event | src/Illuminate/Foundation/Console/ListenerMakeCommand.php | @@ -55,7 +55,7 @@ protected function buildClass($name)
$event = $this->option('event');
- if (! Str::startsWith($event, $this->laravel->getNamespace())) {
+ if (! Str::startsWith($event, $this->laravel->getNamespace()) && ! Str::startsWith($event, 'Illuminate')) {
$event = $this->laravel->getNamespace().'Events\\'.$event;
}
| false |
Other | laravel | framework | 378104e1cdf07ad606482f9b12fddcbd9dadbcda.json | fix docblock CS | src/Illuminate/Foundation/Auth/ResetsPasswords.php | @@ -84,7 +84,7 @@ protected function getEmailSubject()
*
* If no token is present, display the link request form.
*
- * @param Request $request
+ * @param \Illuminate\Http\Request $request
* @param string|null $token
* @return \Illuminate\Http\Response
*/ | false |
Other | laravel | framework | e05d13023bfa2c265ef504eba85993d79fa9b27e.json | Add guard to Auth::logout() | src/Illuminate/Foundation/Auth/AuthenticatesUsers.php | @@ -157,7 +157,7 @@ public function getLogout()
*/
public function logout()
{
- Auth::logout();
+ Auth::guard($this->getGuard())->logout();
return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/');
} | false |
Other | laravel | framework | 9f4b0260f322517cbb1ee71ca916e908a9a9ff55.json | Add more tests | tests/Database/DatabaseEloquentBuilderTest.php | @@ -457,6 +457,19 @@ public function testHasWithContraintsAndJoinAndHavingInSubquery()
$this->assertEquals(['baz', 'quuuuuux', 'qux', 'quuux'], $builder->getBindings());
}
+ public function testHasWithContraintsAndHavingInSubqueryWithCount()
+ {
+ $model = new EloquentBuilderTestModelParentStub;
+
+ $builder = $model->where('bar', 'baz');
+ $builder->whereHas('foo', function ($q) {
+ $q->having('bam', '>', 'qux');
+ }, '>=', 2)->where('quux', 'quuux');
+
+ $this->assertEquals('select * from "eloquent_builder_test_model_parent_stubs" where "bar" = ? and (select count(*) from "eloquent_builder_test_model_close_related_stubs" where "eloquent_builder_test_model_parent_stubs"."foo_id" = "eloquent_builder_test_model_close_related_stubs"."id" having "bam" > ?) >= 2 and "quux" = ?', $builder->toSql());
+ $this->assertEquals(['baz', 'qux', 'quuux'], $builder->getBindings());
+ }
+
public function testHasNestedWithConstraints()
{
$model = new EloquentBuilderTestModelParentStub; | false |
Other | laravel | framework | f5f843396c2c3cd244334029847fee2c7809123d.json | Fix routing pipeline. | src/Illuminate/Routing/Pipeline.php | @@ -2,6 +2,8 @@
namespace Illuminate\Routing;
+use Closure;
+use Throwable;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Contracts\Debug\ExceptionHandler;
@@ -37,6 +39,25 @@ protected function getSlice()
};
}
+ /**
+ * Get the initial slice to begin the stack call.
+ *
+ * @param \Closure $destination
+ * @return \Closure
+ */
+ protected function getInitialSlice(Closure $destination)
+ {
+ return function ($passable) use ($destination) {
+ try {
+ return call_user_func($destination, $passable);
+ } catch (Exception $e) {
+ return $this->handleException($passable, $e);
+ } catch (Throwable $e) {
+ return $this->handleException($passable, new FatalThrowableError($e));
+ }
+ };
+ }
+
/**
* Handle the given exception.
* | false |
Other | laravel | framework | f9f658aa0b83eabe9d7edc1d88ae195ed8ca0b0f.json | Use extended Routing Pipeline in Kernel | src/Illuminate/Foundation/Http/Kernel.php | @@ -5,7 +5,7 @@
use Exception;
use Throwable;
use Illuminate\Routing\Router;
-use Illuminate\Pipeline\Pipeline;
+use Illuminate\Routing\Pipeline;
use Illuminate\Support\Facades\Facade;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Debug\ExceptionHandler; | false |
Other | laravel | framework | 74910637b1c0389ab57f136721dc09404fa470dc.json | Remove some AJAX handling. | src/Illuminate/Foundation/Auth/AuthenticatesUsers.php | @@ -99,10 +99,6 @@ protected function handleUserWasAuthenticated(Request $request, $throttles)
return $this->authenticated($request, Auth::user());
}
- if ($request->ajax() || $request->wantsJson()) {
- return response()->json(['url' => $request->session()->pull('url.intended')]);
- }
-
return redirect()->intended($this->redirectPath());
}
@@ -114,15 +110,6 @@ protected function handleUserWasAuthenticated(Request $request, $throttles)
*/
protected function sendFailedLoginResponse(Request $request)
{
- // If the request is an AJAX request or is asking for JSON, we will return the errors
- // in JSON format so the developers can build JavaScript applications for handling
- // authentication instead of being forced to use old forms for these situations.
- if ($request->ajax() || $request->wantsJson()) {
- return response()->json([
- $this->loginUsername() => [$this->getFailedLoginMessage()],
- ], 422);
- }
-
return redirect()->back()
->withInput($request->only($this->loginUsername(), 'remember'))
->withErrors([ | true |
Other | laravel | framework | 74910637b1c0389ab57f136721dc09404fa470dc.json | Remove some AJAX handling. | src/Illuminate/Foundation/Auth/ThrottlesLogins.php | @@ -62,12 +62,6 @@ protected function sendLockoutResponse(Request $request)
$this->getThrottleKey($request)
);
- if ($request->ajax() || $request->wantsJson()) {
- return response()->json([
- $this->loginUsername() => [$this->getLockoutErrorMessage($seconds)],
- ], 429);
- }
-
return redirect()->back()
->withInput($request->only($this->loginUsername(), 'remember'))
->withErrors([ | true |
Other | laravel | framework | 7af396e528dad506c4121f97fe4c3bfe41fde7b2.json | remove url prefixes from resource route names. | src/Illuminate/Routing/ResourceRegistrar.php | @@ -211,13 +211,7 @@ protected function getResourceName($resource, $method, $options)
*/
protected function getGroupResourceName($prefix, $resource, $method)
{
- $group = trim(str_replace('/', '.', $this->router->getLastGroupPrefix()), '.');
-
- if (empty($group)) {
- return trim("{$prefix}{$resource}.{$method}", '.');
- }
-
- return trim("{$prefix}{$group}.{$resource}.{$method}", '.');
+ return trim("{$prefix}{$resource}.{$method}", '.');
}
/** | true |
Other | laravel | framework | 7af396e528dad506c4121f97fe4c3bfe41fde7b2.json | remove url prefixes from resource route names. | tests/Routing/RoutingRouteTest.php | @@ -693,6 +693,17 @@ public function testResourceRouteNaming()
$this->assertTrue($router->getRoutes()->hasNamedRoute('foo.bar.update'));
$this->assertTrue($router->getRoutes()->hasNamedRoute('foo.bar.destroy'));
+ $router = $this->getRouter();
+ $router->resource('prefix/foo.bar', 'FooController');
+
+ $this->assertTrue($router->getRoutes()->hasNamedRoute('foo.bar.index'));
+ $this->assertTrue($router->getRoutes()->hasNamedRoute('foo.bar.show'));
+ $this->assertTrue($router->getRoutes()->hasNamedRoute('foo.bar.create'));
+ $this->assertTrue($router->getRoutes()->hasNamedRoute('foo.bar.store'));
+ $this->assertTrue($router->getRoutes()->hasNamedRoute('foo.bar.edit'));
+ $this->assertTrue($router->getRoutes()->hasNamedRoute('foo.bar.update'));
+ $this->assertTrue($router->getRoutes()->hasNamedRoute('foo.bar.destroy'));
+
$router = $this->getRouter();
$router->resource('foo', 'FooController', ['names' => [
'index' => 'foo', | true |
Other | laravel | framework | 408aba4ec776e0a8bf016bb090eaa354d3725abc.json | Fix each when there's no order by | src/Illuminate/Database/Eloquent/Builder.php | @@ -295,6 +295,10 @@ public function chunk($count, callable $callback)
*/
public function each(callable $callback, $count = 1000)
{
+ if (is_null($this->getOrderBys())) {
+ $this->orderBy('id', 'asc');
+ }
+
return $this->chunk($count, function ($results) use ($callback) {
foreach ($results as $key => $value) {
if ($callback($item, $key) === false) { | true |
Other | laravel | framework | 408aba4ec776e0a8bf016bb090eaa354d3725abc.json | Fix each when there's no order by | src/Illuminate/Database/Query/Builder.php | @@ -1575,6 +1575,10 @@ public function chunk($count, callable $callback)
*/
public function each(callable $callback, $count = 1000)
{
+ if (is_null($this->getOrderBys())) {
+ $this->orderBy('id', 'asc');
+ }
+
return $this->chunk($count, function ($results) use ($callback) {
foreach ($results as $key => $value) {
if ($callback($item, $key) === false) {
@@ -1584,6 +1588,18 @@ public function each(callable $callback, $count = 1000)
});
}
+ /**
+ * Returns the currently set ordering.
+ *
+ * @return array|null
+ */
+ public function getOrderBys()
+ {
+ $property = $this->unions ? 'unionOrders' : 'orders';
+
+ return $this->{$property};
+ }
+
/**
* Get an array with the values of a given column.
* | true |
Other | laravel | framework | 66ce56a6605136110aeac3946020c8f55fbd4b65.json | use facade so we dont break the signature | src/Illuminate/Foundation/Auth/ResetsPasswords.php | @@ -97,11 +97,11 @@ public function getReset($token = null)
*
* If no token is present, display the link request form.
*
- * @param string|null $token
* @param \Illuminate\Http\Request $request
+ * @param string|null $token
* @return \Illuminate\Http\Response
*/
- public function showResetForm($token = null, Request $request)
+ public function showResetForm(Request $request, $token = null)
{
if (is_null($token)) {
return $this->getEmail(); | false |
Other | laravel | framework | 9990a46cfeb6f25ab55f0e59cf9f91fef02aeee5.json | Ignore non-existent .env files only | composer.json | @@ -38,7 +38,7 @@
"symfony/routing": "2.8.*|3.0.*",
"symfony/translation": "2.8.*|3.0.*",
"symfony/var-dumper": "2.8.*|3.0.*",
- "vlucas/phpdotenv": "~2.0"
+ "vlucas/phpdotenv": "~2.2"
},
"replace": {
"illuminate/auth": "self.version", | true |
Other | laravel | framework | 9990a46cfeb6f25ab55f0e59cf9f91fef02aeee5.json | Ignore non-existent .env files only | src/Illuminate/Foundation/Bootstrap/DetectEnvironment.php | @@ -3,7 +3,7 @@
namespace Illuminate\Foundation\Bootstrap;
use Dotenv\Dotenv;
-use InvalidArgumentException;
+use Dotenv\Exception\InvalidPathException;
use Illuminate\Contracts\Foundation\Application;
class DetectEnvironment
@@ -19,7 +19,7 @@ public function bootstrap(Application $app)
if (! $app->configurationIsCached()) {
try {
(new Dotenv($app->environmentPath(), $app->environmentFile()))->load();
- } catch (InvalidArgumentException $e) {
+ } catch (InvalidPathException $e) {
//
}
} | true |
Other | laravel | framework | fd3056cb55b0f39d21640567f1f277777657bbb6.json | Change elixir helper order for the Javascript
I changed the order of the elixir helper at the Javascript section to avoid problems when one tries to ask if a library such as jQuery is available to use. | src/Illuminate/Auth/Console/stubs/make/views/layouts/app.stub | @@ -75,8 +75,8 @@
@yield('content')
<!-- JavaScripts -->
- {{-- <script src="{{ elixir('js/app.js') }}"></script> --}}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
+ {{-- <script src="{{ elixir('js/app.js') }}"></script> --}}
</body>
</html> | false |
Other | laravel | framework | 57d8251b26e994f428e3cc0630f90b2b14d2fc1f.json | remove restriction that caused some BC issues | src/Illuminate/Queue/Console/ListenCommand.php | @@ -2,7 +2,6 @@
namespace Illuminate\Queue\Console;
-use InvalidArgumentException;
use Illuminate\Queue\Listener;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
@@ -64,12 +63,6 @@ public function fire()
$timeout = $this->input->getOption('timeout');
- if ($timeout <= $this->input->getOption('sleep')) {
- throw new InvalidArgumentException(
- "Job timeout must be greater than 'sleep' option value."
- );
- }
-
// We need to get the right queue for the connection which is set in the queue
// configuration file for the application. We will pull it based on the set
// connection being run for the queue operation currently being executed. | false |
Other | laravel | framework | 5744ca139d686c21169cacdaaddbbaf726ed5553.json | Pass array validation rules as array
Updated tests | src/Illuminate/Validation/Validator.php | @@ -216,7 +216,7 @@ protected function explodeRules($rules)
{
foreach ($rules as $key => $rule) {
if (Str::contains($key, '*')) {
- $this->each($key, $rule);
+ $this->each($key, [$rule]);
unset($rules[$key]);
} else { | true |
Other | laravel | framework | 5744ca139d686c21169cacdaaddbbaf726ed5553.json | Pass array validation rules as array
Updated tests | tests/Validation/ValidationValidatorTest.php | @@ -1804,6 +1804,14 @@ public function testValidateEach()
$v = new Validator($trans, $data, ['foo' => 'Array']);
$v->each('foo', 'numeric|min:4|max:16');
$this->assertTrue($v->passes());
+
+ $v = new Validator($trans, $data, ['foo' => 'Array']);
+ $v->each('foo', ['numeric','min:6','max:14']);
+ $this->assertFalse($v->passes());
+
+ $v = new Validator($trans, $data, ['foo' => 'Array']);
+ $v->each('foo', ['numeric','min:4','max:16']);
+ $this->assertTrue($v->passes());
}
public function testValidateImplicitEachWithAsterisks()
@@ -1817,6 +1825,12 @@ public function testValidateImplicitEachWithAsterisks()
$v = new Validator($trans, $data, ['foo' => 'Array', 'foo.*' => 'Numeric|Min:4|Max:16']);
$this->assertTrue($v->passes());
+ $v = new Validator($trans, $data, ['foo' => 'Array', 'foo.*' => ['Numeric','Min:6','Max:16']]);
+ $this->assertFalse($v->passes());
+
+ $v = new Validator($trans, $data, ['foo' => 'Array', 'foo.*' => ['Numeric','Min:4','Max:16']]);
+ $this->assertTrue($v->passes());
+
$v = new Validator($trans, ['foo' => [['name' => 'first'], ['name' => 'second']]],
['foo' => 'Array', 'foo.*.name' => 'Required|String']);
$this->assertTrue($v->passes());
@@ -1828,6 +1842,18 @@ public function testValidateImplicitEachWithAsterisks()
$v = new Validator($trans, ['foo' => [['name' => 'first', 'votes' => [1, 2]], ['name' => 'second', 'votes' => ['something', 2]]]],
['foo' => 'Array', 'foo.*.name' => 'Required|String', 'foo.*.votes.*' => 'Required|Integer']);
$this->assertFalse($v->passes());
+
+ $v = new Validator($trans, ['foo' => [['name' => 'first'], ['name' => 'second']]],
+ ['foo' => 'Array', 'foo.*.name' => ['Required','String']]);
+ $this->assertTrue($v->passes());
+
+ $v = new Validator($trans, ['foo' => [['name' => 'first'], ['name' => 'second']]],
+ ['foo' => 'Array', 'foo.*.name' => ['Required','Numeric']]);
+ $this->assertFalse($v->passes());
+
+ $v = new Validator($trans, ['foo' => [['name' => 'first', 'votes' => [1, 2]], ['name' => 'second', 'votes' => ['something', 2]]]],
+ ['foo' => 'Array', 'foo.*.name' => ['Required','String'], 'foo.*.votes.*' => ['Required','Integer']]);
+ $this->assertFalse($v->passes());
}
public function testValidateEachWithNonIndexedArray() | true |
Other | laravel | framework | 3789a96ec84fdc94685c90eb12e378dedb97411d.json | use illuminate response | src/Illuminate/Auth/SessionGuard.php | @@ -4,11 +4,11 @@
use RuntimeException;
use Illuminate\Support\Str;
+use Illuminate\Http\Response;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Contracts\Auth\UserProvider;
use Illuminate\Contracts\Auth\StatefulGuard;
use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpFoundation\Response;
use Illuminate\Contracts\Auth\SupportsBasicAuth;
use Illuminate\Contracts\Cookie\QueueingFactory as CookieJar;
use Symfony\Component\HttpFoundation\Session\SessionInterface; | false |
Other | laravel | framework | b742179af9124cadd8eca3000eca0b5b50ed256f.json | Improve char coverage | src/Illuminate/Support/Str.php | @@ -459,84 +459,108 @@ protected static function charsArray()
}
return $charsArray = [
- 'a' => ['à', 'á', 'ả', 'ã', 'ạ', 'ă', 'ắ', 'ằ', 'ẳ', 'ẵ', 'ặ', 'â', 'ấ', 'ầ', 'ẩ', 'ẫ', 'ậ', 'ā', 'ą', 'å', 'α', 'ά', 'ἀ', 'ἁ', 'ἂ', 'ἃ', 'ἄ', 'ἅ', 'ἆ', 'ἇ', 'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ὰ', 'ά', 'ᾰ', 'ᾱ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'а', 'أ'],
- 'b' => ['б', 'β', 'Ъ', 'Ь', 'ب'],
+ '0' => ['°', '₀'],
+ '1' => ['¹', '₁'],
+ '2' => ['²', '₂'],
+ '3' => ['³', '₃'],
+ '4' => ['⁴', '₄'],
+ '5' => ['⁵', '₅'],
+ '6' => ['⁶', '₆'],
+ '7' => ['⁷', '₇'],
+ '8' => ['⁸', '₈'],
+ '9' => ['⁹', '₉'],
+ 'a' => ['à', 'á', 'ả', 'ã', 'ạ', 'ă', 'ắ', 'ằ', 'ẳ', 'ẵ', 'ặ', 'â', 'ấ', 'ầ', 'ẩ', 'ẫ', 'ậ', 'ā', 'ą', 'å', 'α', 'ά', 'ἀ', 'ἁ', 'ἂ', 'ἃ', 'ἄ', 'ἅ', 'ἆ', 'ἇ', 'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ὰ', 'ά', 'ᾰ', 'ᾱ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'а', 'أ', 'အ', 'ာ', 'ါ', 'ǻ', 'ǎ', 'ª', 'ა', 'अ'],
+ 'b' => ['б', 'β', 'Ъ', 'Ь', 'ب', 'ဗ', 'ბ'],
'c' => ['ç', 'ć', 'č', 'ĉ', 'ċ'],
- 'd' => ['ď', 'ð', 'đ', 'ƌ', 'ȡ', 'ɖ', 'ɗ', 'ᵭ', 'ᶁ', 'ᶑ', 'д', 'δ', 'د', 'ض'],
- 'e' => ['é', 'è', 'ẻ', 'ẽ', 'ẹ', 'ê', 'ế', 'ề', 'ể', 'ễ', 'ệ', 'ë', 'ē', 'ę', 'ě', 'ĕ', 'ė', 'ε', 'έ', 'ἐ', 'ἑ', 'ἒ', 'ἓ', 'ἔ', 'ἕ', 'ὲ', 'έ', 'е', 'ё', 'э', 'є', 'ə'],
- 'f' => ['ф', 'φ', 'ف'],
- 'g' => ['ĝ', 'ğ', 'ġ', 'ģ', 'г', 'ґ', 'γ', 'ج'],
- 'h' => ['ĥ', 'ħ', 'η', 'ή', 'ح', 'ه'],
- 'i' => ['í', 'ì', 'ỉ', 'ĩ', 'ị', 'î', 'ï', 'ī', 'ĭ', 'į', 'ı', 'ι', 'ί', 'ϊ', 'ΐ', 'ἰ', 'ἱ', 'ἲ', 'ἳ', 'ἴ', 'ἵ', 'ἶ', 'ἷ', 'ὶ', 'ί', 'ῐ', 'ῑ', 'ῒ', 'ΐ', 'ῖ', 'ῗ', 'і', 'ї', 'и'],
- 'j' => ['ĵ', 'ј', 'Ј'],
- 'k' => ['ķ', 'ĸ', 'к', 'κ', 'Ķ', 'ق', 'ك'],
- 'l' => ['ł', 'ľ', 'ĺ', 'ļ', 'ŀ', 'л', 'λ', 'ل'],
- 'm' => ['м', 'μ', 'م'],
- 'n' => ['ñ', 'ń', 'ň', 'ņ', 'ʼn', 'ŋ', 'ν', 'н', 'ن'],
- 'o' => ['ó', 'ò', 'ỏ', 'õ', 'ọ', 'ô', 'ố', 'ồ', 'ổ', 'ỗ', 'ộ', 'ơ', 'ớ', 'ờ', 'ở', 'ỡ', 'ợ', 'ø', 'ō', 'ő', 'ŏ', 'ο', 'ὀ', 'ὁ', 'ὂ', 'ὃ', 'ὄ', 'ὅ', 'ὸ', 'ό', 'о', 'و', 'θ'],
- 'p' => ['п', 'π'],
- 'r' => ['ŕ', 'ř', 'ŗ', 'р', 'ρ', 'ر'],
- 's' => ['ś', 'š', 'ş', 'с', 'σ', 'ș', 'ς', 'س', 'ص'],
- 't' => ['ť', 'ţ', 'т', 'τ', 'ț', 'ت', 'ط'],
- 'u' => ['ú', 'ù', 'ủ', 'ũ', 'ụ', 'ư', 'ứ', 'ừ', 'ử', 'ữ', 'ự', 'û', 'ū', 'ů', 'ű', 'ŭ', 'ų', 'µ', 'у'],
- 'v' => ['в'],
- 'w' => ['ŵ', 'ω', 'ώ'],
- 'x' => ['χ'],
- 'y' => ['ý', 'ỳ', 'ỷ', 'ỹ', 'ỵ', 'ÿ', 'ŷ', 'й', 'ы', 'υ', 'ϋ', 'ύ', 'ΰ', 'ي'],
- 'z' => ['ź', 'ž', 'ż', 'з', 'ζ', 'ز'],
- 'aa' => ['ع'],
- 'ae' => ['ä', 'æ'],
- 'ch' => ['ч'],
+ 'd' => ['ď', 'ð', 'đ', 'ƌ', 'ȡ', 'ɖ', 'ɗ', 'ᵭ', 'ᶁ', 'ᶑ', 'д', 'δ', 'د', 'ض', 'ဍ', 'ဒ', 'დ'],
+ 'e' => ['é', 'è', 'ẻ', 'ẽ', 'ẹ', 'ê', 'ế', 'ề', 'ể', 'ễ', 'ệ', 'ë', 'ē', 'ę', 'ě', 'ĕ', 'ė', 'ε', 'έ', 'ἐ', 'ἑ', 'ἒ', 'ἓ', 'ἔ', 'ἕ', 'ὲ', 'έ', 'е', 'ё', 'э', 'є', 'ə', 'ဧ', 'ေ', 'ဲ', 'ე', 'ए'],
+ 'f' => ['ф', 'φ', 'ف', 'ƒ', 'ფ'],
+ 'g' => ['ĝ', 'ğ', 'ġ', 'ģ', 'г', 'ґ', 'γ', 'ج', 'ဂ', 'გ'],
+ 'h' => ['ĥ', 'ħ', 'η', 'ή', 'ح', 'ه', 'ဟ', 'ှ', 'ჰ'],
+ 'i' => ['í', 'ì', 'ỉ', 'ĩ', 'ị', 'î', 'ï', 'ī', 'ĭ', 'į', 'ı', 'ι', 'ί', 'ϊ', 'ΐ', 'ἰ', 'ἱ', 'ἲ', 'ἳ', 'ἴ', 'ἵ', 'ἶ', 'ἷ', 'ὶ', 'ί', 'ῐ', 'ῑ', 'ῒ', 'ΐ', 'ῖ', 'ῗ', 'і', 'ї', 'и', 'ဣ', 'ိ', 'ီ', 'ည်', 'ǐ', 'ი', 'इ'],
+ 'j' => ['ĵ', 'ј', 'Ј', 'ჯ'],
+ 'k' => ['ķ', 'ĸ', 'к', 'κ', 'Ķ', 'ق', 'ك', 'က', 'კ', 'ქ'],
+ 'l' => ['ł', 'ľ', 'ĺ', 'ļ', 'ŀ', 'л', 'λ', 'ل', 'လ', 'ლ'],
+ 'm' => ['м', 'μ', 'م', 'မ', 'მ'],
+ 'n' => ['ñ', 'ń', 'ň', 'ņ', 'ʼn', 'ŋ', 'ν', 'н', 'ن', 'န', 'ნ'],
+ 'o' => ['ó', 'ò', 'ỏ', 'õ', 'ọ', 'ô', 'ố', 'ồ', 'ổ', 'ỗ', 'ộ', 'ơ', 'ớ', 'ờ', 'ở', 'ỡ', 'ợ', 'ø', 'ō', 'ő', 'ŏ', 'ο', 'ὀ', 'ὁ', 'ὂ', 'ὃ', 'ὄ', 'ὅ', 'ὸ', 'ό', 'о', 'و', 'θ', 'ို', 'ǒ', 'ǿ', 'º', 'ო', 'ओ'],
+ 'p' => ['п', 'π', 'ပ', 'პ'],
+ 'q' => ['ყ'],
+ 'r' => ['ŕ', 'ř', 'ŗ', 'р', 'ρ', 'ر', 'რ'],
+ 's' => ['ś', 'š', 'ş', 'с', 'σ', 'ș', 'ς', 'س', 'ص', 'စ', 'ſ', 'ს'],
+ 't' => ['ť', 'ţ', 'т', 'τ', 'ț', 'ت', 'ط', 'ဋ', 'တ', 'ŧ', 'თ', 'ტ'],
+ 'u' => ['ú', 'ù', 'ủ', 'ũ', 'ụ', 'ư', 'ứ', 'ừ', 'ử', 'ữ', 'ự', 'û', 'ū', 'ů', 'ű', 'ŭ', 'ų', 'µ', 'у', 'ဉ', 'ု', 'ူ', 'ǔ', 'ǖ', 'ǘ', 'ǚ', 'ǜ', 'უ', 'उ'],
+ 'v' => ['в', 'ვ', 'ϐ'],
+ 'w' => ['ŵ', 'ω', 'ώ', 'ဝ', 'ွ'],
+ 'x' => ['χ', 'ξ'],
+ 'y' => ['ý', 'ỳ', 'ỷ', 'ỹ', 'ỵ', 'ÿ', 'ŷ', 'й', 'ы', 'υ', 'ϋ', 'ύ', 'ΰ', 'ي', 'ယ'],
+ 'z' => ['ź', 'ž', 'ż', 'з', 'ζ', 'ز', 'ဇ', 'ზ'],
+ 'aa' => ['ع', 'आ'],
+ 'ae' => ['ä', 'æ', 'ǽ'],
+ 'ai' => ['ऐ'],
+ 'at' => ['@'],
+ 'ch' => ['ч', 'ჩ', 'ჭ'],
'dj' => ['ђ', 'đ'],
- 'dz' => ['џ'],
- 'gh' => ['غ'],
- 'kh' => ['х', 'خ'],
+ 'dz' => ['џ', 'ძ'],
+ 'ei' => ['ऍ'],
+ 'gh' => ['غ', 'ღ'],
+ 'ii' => ['ई'],
+ 'ij' => ['ij'],
+ 'kh' => ['х', 'خ', 'ხ'],
'lj' => ['љ'],
'nj' => ['њ'],
'oe' => ['ö', 'œ'],
+ 'oi' => ['ऑ'],
+ 'oii' => ['ऒ'],
'ps' => ['ψ'],
- 'sh' => ['ш'],
+ 'sh' => ['ш', 'შ'],
'shch' => ['щ'],
'ss' => ['ß'],
- 'th' => ['þ', 'ث', 'ذ', 'ظ'],
- 'ts' => ['ц'],
+ 'sx' => ['ŝ'],
+ 'th' => ['þ', 'ϑ', 'ث', 'ذ', 'ظ'],
+ 'ts' => ['ц', 'ც', 'წ'],
'ue' => ['ü'],
+ 'uu' => ['ऊ'],
'ya' => ['я'],
'yu' => ['ю'],
- 'zh' => ['ж'],
+ 'zh' => ['ж', 'ჟ'],
'(c)' => ['©'],
- 'A' => ['Á', 'À', 'Ả', 'Ã', 'Ạ', 'Ă', 'Ắ', 'Ằ', 'Ẳ', 'Ẵ', 'Ặ', 'Â', 'Ấ', 'Ầ', 'Ẩ', 'Ẫ', 'Ậ', 'Å', 'Ā', 'Ą', 'Α', 'Ά', 'Ἀ', 'Ἁ', 'Ἂ', 'Ἃ', 'Ἄ', 'Ἅ', 'Ἆ', 'Ἇ', 'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ', 'ᾍ', 'ᾎ', 'ᾏ', 'Ᾰ', 'Ᾱ', 'Ὰ', 'Ά', 'ᾼ', 'А'],
- 'B' => ['Б', 'Β'],
+ 'A' => ['Á', 'À', 'Ả', 'Ã', 'Ạ', 'Ă', 'Ắ', 'Ằ', 'Ẳ', 'Ẵ', 'Ặ', 'Â', 'Ấ', 'Ầ', 'Ẩ', 'Ẫ', 'Ậ', 'Å', 'Ā', 'Ą', 'Α', 'Ά', 'Ἀ', 'Ἁ', 'Ἂ', 'Ἃ', 'Ἄ', 'Ἅ', 'Ἆ', 'Ἇ', 'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ', 'ᾍ', 'ᾎ', 'ᾏ', 'Ᾰ', 'Ᾱ', 'Ὰ', 'Ά', 'ᾼ', 'А', 'Ǻ', 'Ǎ'],
+ 'B' => ['Б', 'Β', 'ब'],
'C' => ['Ç', 'Ć', 'Č', 'Ĉ', 'Ċ'],
'D' => ['Ď', 'Ð', 'Đ', 'Ɖ', 'Ɗ', 'Ƌ', 'ᴅ', 'ᴆ', 'Д', 'Δ'],
'E' => ['É', 'È', 'Ẻ', 'Ẽ', 'Ẹ', 'Ê', 'Ế', 'Ề', 'Ể', 'Ễ', 'Ệ', 'Ë', 'Ē', 'Ę', 'Ě', 'Ĕ', 'Ė', 'Ε', 'Έ', 'Ἐ', 'Ἑ', 'Ἒ', 'Ἓ', 'Ἔ', 'Ἕ', 'Έ', 'Ὲ', 'Е', 'Ё', 'Э', 'Є', 'Ə'],
'F' => ['Ф', 'Φ'],
'G' => ['Ğ', 'Ġ', 'Ģ', 'Г', 'Ґ', 'Γ'],
- 'H' => ['Η', 'Ή'],
- 'I' => ['Í', 'Ì', 'Ỉ', 'Ĩ', 'Ị', 'Î', 'Ï', 'Ī', 'Ĭ', 'Į', 'İ', 'Ι', 'Ί', 'Ϊ', 'Ἰ', 'Ἱ', 'Ἳ', 'Ἴ', 'Ἵ', 'Ἶ', 'Ἷ', 'Ῐ', 'Ῑ', 'Ὶ', 'Ί', 'И', 'І', 'Ї'],
+ 'H' => ['Η', 'Ή', 'Ħ'],
+ 'I' => ['Í', 'Ì', 'Ỉ', 'Ĩ', 'Ị', 'Î', 'Ï', 'Ī', 'Ĭ', 'Į', 'İ', 'Ι', 'Ί', 'Ϊ', 'Ἰ', 'Ἱ', 'Ἳ', 'Ἴ', 'Ἵ', 'Ἶ', 'Ἷ', 'Ῐ', 'Ῑ', 'Ὶ', 'Ί', 'И', 'І', 'Ї', 'Ǐ', 'ϒ'],
'K' => ['К', 'Κ'],
- 'L' => ['Ĺ', 'Ł', 'Л', 'Λ', 'Ļ'],
+ 'L' => ['Ĺ', 'Ł', 'Л', 'Λ', 'Ļ', 'Ľ', 'Ŀ', 'ल'],
'M' => ['М', 'Μ'],
'N' => ['Ń', 'Ñ', 'Ň', 'Ņ', 'Ŋ', 'Н', 'Ν'],
- 'O' => ['Ó', 'Ò', 'Ỏ', 'Õ', 'Ọ', 'Ô', 'Ố', 'Ồ', 'Ổ', 'Ỗ', 'Ộ', 'Ơ', 'Ớ', 'Ờ', 'Ở', 'Ỡ', 'Ợ', 'Ø', 'Ō', 'Ő', 'Ŏ', 'Ο', 'Ό', 'Ὀ', 'Ὁ', 'Ὂ', 'Ὃ', 'Ὄ', 'Ὅ', 'Ὸ', 'Ό', 'О', 'Θ', 'Ө'],
+ 'O' => ['Ó', 'Ò', 'Ỏ', 'Õ', 'Ọ', 'Ô', 'Ố', 'Ồ', 'Ổ', 'Ỗ', 'Ộ', 'Ơ', 'Ớ', 'Ờ', 'Ở', 'Ỡ', 'Ợ', 'Ø', 'Ō', 'Ő', 'Ŏ', 'Ο', 'Ό', 'Ὀ', 'Ὁ', 'Ὂ', 'Ὃ', 'Ὄ', 'Ὅ', 'Ὸ', 'Ό', 'О', 'Θ', 'Ө', 'Ǒ', 'Ǿ'],
'P' => ['П', 'Π'],
- 'R' => ['Ř', 'Ŕ', 'Р', 'Ρ'],
+ 'R' => ['Ř', 'Ŕ', 'Р', 'Ρ', 'Ŗ'],
'S' => ['Ş', 'Ŝ', 'Ș', 'Š', 'Ś', 'С', 'Σ'],
'T' => ['Ť', 'Ţ', 'Ŧ', 'Ț', 'Т', 'Τ'],
- 'U' => ['Ú', 'Ù', 'Ủ', 'Ũ', 'Ụ', 'Ư', 'Ứ', 'Ừ', 'Ử', 'Ữ', 'Ự', 'Û', 'Ū', 'Ů', 'Ű', 'Ŭ', 'Ų', 'У'],
+ 'U' => ['Ú', 'Ù', 'Ủ', 'Ũ', 'Ụ', 'Ư', 'Ứ', 'Ừ', 'Ử', 'Ữ', 'Ự', 'Û', 'Ū', 'Ů', 'Ű', 'Ŭ', 'Ų', 'У', 'Ǔ', 'Ǖ', 'Ǘ', 'Ǚ', 'Ǜ'],
'V' => ['В'],
- 'W' => ['Ω', 'Ώ'],
- 'X' => ['Χ'],
- 'Y' => ['Ý', 'Ỳ', 'Ỷ', 'Ỹ', 'Ỵ', 'Ÿ', 'Ῠ', 'Ῡ', 'Ὺ', 'Ύ', 'Ы', 'Й', 'Υ', 'Ϋ'],
+ 'W' => ['Ω', 'Ώ', 'Ŵ'],
+ 'X' => ['Χ', 'Ξ'],
+ 'Y' => ['Ý', 'Ỳ', 'Ỷ', 'Ỹ', 'Ỵ', 'Ÿ', 'Ῠ', 'Ῡ', 'Ὺ', 'Ύ', 'Ы', 'Й', 'Υ', 'Ϋ', 'Ŷ'],
'Z' => ['Ź', 'Ž', 'Ż', 'З', 'Ζ'],
- 'AE' => ['Ä', 'Æ'],
+ 'AE' => ['Ä', 'Æ', 'Ǽ'],
'CH' => ['Ч'],
'DJ' => ['Ђ'],
'DZ' => ['Џ'],
+ 'GX' => ['Ĝ'],
+ 'HX' => ['Ĥ'],
+ 'IJ' => ['IJ'],
+ 'JX' => ['Ĵ'],
'KH' => ['Х'],
'LJ' => ['Љ'],
'NJ' => ['Њ'],
- 'OE' => ['Ö'],
+ 'OE' => ['Ö', 'Œ'],
'PS' => ['Ψ'],
'SH' => ['Ш'],
'SHCH' => ['Щ'], | false |
Other | laravel | framework | 55259e5178a61dc3393df33a6dd4d8bcbf2c3e59.json | Unify database chunk methods, and add each methods | src/Illuminate/Database/Eloquent/Builder.php | @@ -264,7 +264,7 @@ public function value($column)
*
* @param int $count
* @param callable $callback
- * @return void
+ * @return bool
*/
public function chunk($count, callable $callback)
{
@@ -275,13 +275,35 @@ public function chunk($count, callable $callback)
// developer take care of everything within the callback, which allows us to
// keep the memory low for spinning through large result sets for working.
if (call_user_func($callback, $results) === false) {
- break;
+ return false;
}
$page++;
$results = $this->forPage($page, $count)->get();
}
+
+ return true;
+ }
+
+ /**
+ * Execute a callback over each item.
+ *
+ * We're also saving memory by chunking the results into memory.
+ *
+ * @param callable $callback
+ * @param int $count
+ * @return bool
+ */
+ public function each(callable $callback, $count = 1000)
+ {
+ return $this->chunk($count, function ($results) use ($callback) {
+ foreach ($results as $key => $value) {
+ if ($callback($item, $key) === false) {
+ return false;
+ }
+ }
+ });
}
/** | true |
Other | laravel | framework | 55259e5178a61dc3393df33a6dd4d8bcbf2c3e59.json | Unify database chunk methods, and add each methods | src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php | @@ -229,16 +229,16 @@ public function simplePaginate($perPage = null, $columns = ['*'])
*
* @param int $count
* @param callable $callback
- * @return void
+ * @return bool
*/
public function chunk($count, callable $callback)
{
$this->query->addSelect($this->getSelectColumns());
- $this->query->chunk($count, function ($results) use ($callback) {
+ return $this->query->chunk($count, function ($results) use ($callback) {
$this->hydratePivotRelation($results->all());
- call_user_func($callback, $results);
+ return $callback($results);
});
}
| true |
Other | laravel | framework | 55259e5178a61dc3393df33a6dd4d8bcbf2c3e59.json | Unify database chunk methods, and add each methods | src/Illuminate/Database/Query/Builder.php | @@ -1566,6 +1566,26 @@ public function chunk($count, callable $callback)
return true;
}
+ /**
+ * Execute a callback over each item.
+ *
+ * We're also saving memory by chunking the results into memory.
+ *
+ * @param callable $callback
+ * @param int $count
+ * @return bool
+ */
+ public function each(callable $callback, $count = 1000)
+ {
+ return $this->chunk($count, function ($results) use ($callback) {
+ foreach ($results as $key => $value) {
+ if ($callback($item, $key) === false) {
+ return false;
+ }
+ }
+ });
+ }
+
/**
* Get an array with the values of a given column.
* | true |
Other | laravel | framework | 964f69f66e2c9b4e3e0557ee26417dfe2936cf3d.json | Add knowledge, love and rain to uncountable array | src/Illuminate/Support/Pluralizer.php | @@ -24,6 +24,9 @@ class Pluralizer
'fish',
'gold',
'information',
+ 'knowledge',
+ 'love',
+ 'rain',
'money',
'moose',
'offspring', | false |
Other | laravel | framework | 06922ce6c041770e3b0a18453d3b992a488bd69b.json | Add tag property to the cache events | src/Illuminate/Cache/Events/CacheHit.php | @@ -18,16 +18,25 @@ class CacheHit
*/
public $value;
+ /**
+ * Any tags that were used.
+ *
+ * @var array
+ */
+ public $tags;
+
/**
* Create a new event instance.
*
* @param string $key
* @param mixed $value
+ * @param array $tags
* @return void
*/
- public function __construct($key, $value)
+ public function __construct($key, $value, array $tags = [])
{
$this->key = $key;
$this->value = $value;
+ $this->tags = $tags;
}
} | true |
Other | laravel | framework | 06922ce6c041770e3b0a18453d3b992a488bd69b.json | Add tag property to the cache events | src/Illuminate/Cache/Events/CacheMissed.php | @@ -11,14 +11,23 @@ class CacheMissed
*/
public $key;
+ /**
+ * Any tags that were used.
+ *
+ * @var array
+ */
+ public $tags;
+
/**
* Create a new event instance.
*
* @param string $event
+ * @param array $tags
* @return void
*/
- public function __construct($key)
+ public function __construct($key, array $tags = [])
{
$this->key = $key;
+ $this->tags = $tags;
}
} | true |
Other | laravel | framework | 06922ce6c041770e3b0a18453d3b992a488bd69b.json | Add tag property to the cache events | src/Illuminate/Cache/Events/KeyForgotten.php | @@ -11,14 +11,23 @@ class KeyForgotten
*/
public $key;
+ /**
+ * Any tags that were used.
+ *
+ * @var array
+ */
+ public $tags;
+
/**
* Create a new event instance.
*
* @param string $key
+ * @param array $tags
* @return void
*/
- public function __construct($key)
+ public function __construct($key, $tags = [])
{
$this->key = $key;
+ $this->tags = $tags;
}
} | true |
Other | laravel | framework | 06922ce6c041770e3b0a18453d3b992a488bd69b.json | Add tag property to the cache events | src/Illuminate/Cache/Events/KeyWritten.php | @@ -25,18 +25,27 @@ class KeyWritten
*/
public $minutes;
+ /**
+ * Any tags that were used.
+ *
+ * @var array
+ */
+ public $tags;
+
/**
* Create a new event instance.
*
* @param string $key
* @param mixed $value
* @param int $minutes
+ * @param array $tags
* @return void
*/
- public function __construct($key, $value, $minutes)
+ public function __construct($key, $value, $minutes, $tags = [])
{
$this->key = $key;
$this->value = $value;
$this->minutes = $minutes;
+ $this->tags = $tags;
}
} | true |
Other | laravel | framework | 06922ce6c041770e3b0a18453d3b992a488bd69b.json | Add tag property to the cache events | src/Illuminate/Cache/Repository.php | @@ -76,13 +76,29 @@ protected function fireCacheEvent($event, $payload)
switch ($event) {
case 'hit':
- return $this->events->fire(new Events\CacheHit($payload[0], $payload[1]));
+ if (count($payload) == 2) {
+ $payload[] = [];
+ }
+
+ return $this->events->fire(new Events\CacheHit($payload[0], $payload[1], $payload[2]));
case 'missed':
- return $this->events->fire(new Events\CacheMissed($payload[0]));
+ if (count($payload) == 1) {
+ $payload[] = [];
+ }
+
+ return $this->events->fire(new Events\CacheMissed($payload[0], $payload[1]));
case 'delete':
- return $this->events->fire(new Events\KeyForgotten($payload[0]));
+ if (count($payload) == 1) {
+ $payload[] = [];
+ }
+
+ return $this->events->fire(new Events\KeyForgotten($payload[0], $payload[1]));
case 'write':
- return $this->events->fire(new Events\KeyWritten($payload[0], $payload[1], $payload[2]));
+ if (count($payload) == 3) {
+ $payload[] = [];
+ }
+
+ return $this->events->fire(new Events\KeyWritten($payload[0], $payload[1], $payload[2], $payload[3]));
}
}
| true |
Other | laravel | framework | 06922ce6c041770e3b0a18453d3b992a488bd69b.json | Add tag property to the cache events | tests/Cache/CacheEventsTest.php | @@ -1,6 +1,10 @@
<?php
use Mockery as m;
+use Illuminate\Cache\Events\CacheHit;
+use Illuminate\Cache\Events\KeyWritten;
+use Illuminate\Cache\Events\CacheMissed;
+use Illuminate\Cache\Events\KeyForgotten;
class CacheEventTest extends PHPUnit_Framework_TestCase
{
@@ -14,17 +18,16 @@ public function testHasTriggersEvents()
$dispatcher = $this->getDispatcher();
$repository = $this->getRepository($dispatcher);
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\CacheMissed'));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(CacheMissed::class, ['key' => 'foo']));
$this->assertFalse($repository->has('foo'));
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\CacheHit'));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(CacheHit::class, ['key' => 'baz', 'value' => 'qux']));
$this->assertTrue($repository->has('baz'));
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\CacheMissed'));
- $dispatcher->shouldReceive('fire')->never();
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(CacheMissed::class, ['key' => 'foo', 'tags' => ['taylor']]));
$this->assertFalse($repository->tags('taylor')->has('foo'));
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\CacheHit'));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(CacheHit::class, ['key' => 'baz', 'value' => 'qux', 'tags' => ['taylor']]));
$this->assertTrue($repository->tags('taylor')->has('baz'));
}
@@ -33,16 +36,16 @@ public function testGetTriggersEvents()
$dispatcher = $this->getDispatcher();
$repository = $this->getRepository($dispatcher);
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\CacheMissed'));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(CacheMissed::class, ['key' => 'foo']));
$this->assertNull($repository->get('foo'));
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\CacheHit'));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(CacheHit::class, ['key' => 'baz', 'value' => 'qux']));
$this->assertEquals('qux', $repository->get('baz'));
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\CacheMissed'));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(CacheMissed::class, ['key' => 'foo', 'tags' => ['taylor']]));
$this->assertNull($repository->tags('taylor')->get('foo'));
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\CacheHit'));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(CacheHit::class, ['key' => 'baz', 'value' => 'qux', 'tags' => ['taylor']]));
$this->assertEquals('qux', $repository->tags('taylor')->get('baz'));
}
@@ -51,8 +54,8 @@ public function testPullTriggersEvents()
$dispatcher = $this->getDispatcher();
$repository = $this->getRepository($dispatcher);
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\CacheHit'));
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\KeyForgotten'));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(CacheHit::class, ['key' => 'baz', 'value' => 'qux']));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(KeyForgotten::class, ['key' => 'baz']));
$this->assertEquals('qux', $repository->pull('baz'));
}
@@ -61,8 +64,8 @@ public function testPullTriggersEventsUsingTags()
$dispatcher = $this->getDispatcher();
$repository = $this->getRepository($dispatcher);
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\CacheHit'));
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\KeyForgotten'));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(CacheHit::class, ['key' => 'baz', 'value' => 'qux', 'tags' => ['taylor']]));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(KeyForgotten::class, ['key' => 'baz', 'tags' => ['taylor']]));
$this->assertEquals('qux', $repository->tags('taylor')->pull('baz'));
}
@@ -71,10 +74,10 @@ public function testPutTriggersEvents()
$dispatcher = $this->getDispatcher();
$repository = $this->getRepository($dispatcher);
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\KeyWritten'));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(KeyWritten::class, ['key' => 'foo', 'value' => 'bar']));
$repository->put('foo', 'bar', 99);
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\KeyWritten'));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(KeyWritten::class, ['key' => 'foo', 'value' => 'bar', 'tags' => ['taylor']]));
$repository->tags('taylor')->put('foo', 'bar', 99);
}
@@ -83,12 +86,12 @@ public function testAddTriggersEvents()
$dispatcher = $this->getDispatcher();
$repository = $this->getRepository($dispatcher);
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\CacheMissed'));
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\KeyWritten'));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(CacheMissed::class, ['key' => 'foo']));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(KeyWritten::class, ['key' => 'foo', 'value' => 'bar']));
$this->assertTrue($repository->add('foo', 'bar', 99));
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\CacheMissed'));
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\KeyWritten'));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(CacheMissed::class, ['key' => 'foo', 'tags' => ['taylor']]));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(KeyWritten::class, ['key' => 'foo', 'value' => 'bar', 'tags' => ['taylor']]));
$this->assertTrue($repository->tags('taylor')->add('foo', 'bar', 99));
}
@@ -97,10 +100,10 @@ public function testForeverTriggersEvents()
$dispatcher = $this->getDispatcher();
$repository = $this->getRepository($dispatcher);
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\KeyWritten'));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(KeyWritten::class, ['key' => 'foo', 'value' => 'bar']));
$repository->forever('foo', 'bar');
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\KeyWritten'));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(KeyWritten::class, ['key' => 'foo', 'value' => 'bar', 'tags' => ['taylor']]));
$repository->tags('taylor')->forever('foo', 'bar');
}
@@ -109,14 +112,14 @@ public function testRememberTriggersEvents()
$dispatcher = $this->getDispatcher();
$repository = $this->getRepository($dispatcher);
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\CacheMissed'));
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\KeyWritten'));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(CacheMissed::class, ['key' => 'foo']));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(KeyWritten::class, ['key' => 'foo', 'value' => 'bar']));
$this->assertEquals('bar', $repository->remember('foo', 99, function () {
return 'bar';
}));
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\CacheMissed'));
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\KeyWritten'));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(CacheMissed::class, ['key' => 'foo', 'tags' => ['taylor']]));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(KeyWritten::class, ['key' => 'foo', 'value' => 'bar', 'tags' => ['taylor']]));
$this->assertEquals('bar', $repository->tags('taylor')->remember('foo', 99, function () {
return 'bar';
}));
@@ -127,14 +130,14 @@ public function testRememberForeverTriggersEvents()
$dispatcher = $this->getDispatcher();
$repository = $this->getRepository($dispatcher);
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\CacheMissed'));
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\KeyWritten'));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(CacheMissed::class, ['key' => 'foo']));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(KeyWritten::class, ['key' => 'foo', 'value' => 'bar']));
$this->assertEquals('bar', $repository->rememberForever('foo', function () {
return 'bar';
}));
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\CacheMissed'));
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\KeyWritten'));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(CacheMissed::class, ['key' => 'foo', 'tags' => ['taylor']]));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(KeyWritten::class, ['key' => 'foo', 'value' => 'bar', 'tags' => ['taylor']]));
$this->assertEquals('bar', $repository->tags('taylor')->rememberForever('foo', function () {
return 'bar';
}));
@@ -145,11 +148,28 @@ public function testForgetTriggersEvents()
$dispatcher = $this->getDispatcher();
$repository = $this->getRepository($dispatcher);
- $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\KeyForgotten'));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(KeyForgotten::class, ['key' => 'baz']));
$this->assertTrue($repository->forget('baz'));
- // $dispatcher->shouldReceive('fire')->once()->with(m::type('Illuminate\Cache\Events\CacheMissed'));
- // $this->assertTrue($repository->tags('taylor')->forget('baz'));
+ $dispatcher->shouldReceive('fire')->once()->with($this->assertEventMatches(KeyForgotten::class, ['key' => 'baz', 'tags' => ['taylor']]));
+ $this->assertTrue($repository->tags('taylor')->forget('baz'));
+ }
+
+ protected function assertEventMatches($eventClass, $properties = [])
+ {
+ return m::on(function ($event) use ($eventClass, $properties) {
+ if (! $event instanceof $eventClass) {
+ return false;
+ }
+
+ foreach ($properties as $name => $value) {
+ if ($event->$name != $value) {
+ return false;
+ }
+ }
+
+ return true;
+ });
}
protected function getDispatcher() | true |
Other | laravel | framework | 4f9192ffc410c5bf976f0ea6093f37fd0745283a.json | Escape path directly in build command | src/Illuminate/Console/Scheduling/Event.php | @@ -212,12 +212,13 @@ protected function callAfterCallbacks(Container $container)
*/
public function buildCommand()
{
+ $output = ProcessUtils::escapeArgument($this->output);
$redirect = $this->shouldAppendOutput ? ' >> ' : ' > ';
if ($this->withoutOverlapping) {
- $command = '(touch '.$this->mutexPath().'; '.$this->command.'; rm '.$this->mutexPath().')'.$redirect.$this->output.' 2>&1 &';
+ $command = '(touch '.$this->mutexPath().'; '.$this->command.'; rm '.$this->mutexPath().')'.$redirect.$output.' 2>&1 &';
} else {
- $command = $this->command.$redirect.$this->output.' 2>&1 &';
+ $command = $this->command.$redirect.$output.' 2>&1 &';
}
return $this->user ? 'sudo -u '.$this->user.' '.$command : $command;
@@ -653,7 +654,7 @@ public function skip(Closure $callback)
*/
public function sendOutputTo($location, $append = false)
{
- $this->output = ProcessUtils::escapeArgument($location);
+ $this->output = $location;
$this->shouldAppendOutput = $append;
| true |
Other | laravel | framework | 4f9192ffc410c5bf976f0ea6093f37fd0745283a.json | Escape path directly in build command | tests/Console/Scheduling/EventTest.php | @@ -9,7 +9,7 @@ public function testBuildCommand()
$event = new Event('php -i');
$defaultOutput = (DIRECTORY_SEPARATOR == '\\') ? 'NUL' : '/dev/null';
- $this->assertSame("php -i > {$defaultOutput} 2>&1 &", $event->buildCommand());
+ $this->assertSame("php -i > '{$defaultOutput}' 2>&1 &", $event->buildCommand());
}
public function testBuildCommandSendOutputTo()
@@ -32,4 +32,15 @@ public function testBuildCommandAppendOutput()
$event->appendOutputTo('/dev/null');
$this->assertSame("php -i >> '/dev/null' 2>&1 &", $event->buildCommand());
}
+
+ /**
+ * @expectedException LogicException
+ */
+ public function testEmailOutputToThrowsExceptionIfOutputFileWasNotSpecified()
+ {
+ $event = new Event('php -i');
+ $event->emailOutputTo('foo@example.com');
+
+ $event->buildCommand();
+ }
} | true |
Other | laravel | framework | 5be7f261e8a2f03d6fa6be99eb79e261a880421d.json | change method order | src/Illuminate/Cache/TaggedCache.php | @@ -71,6 +71,14 @@ public function flush()
$this->tags->reset();
}
+ /**
+ * {@inheritdoc}
+ */
+ protected function itemKey($key)
+ {
+ return $this->taggedItemKey($key);
+ }
+
/**
* Get a fully qualified key for a tagged item.
*
@@ -81,12 +89,4 @@ public function taggedItemKey($key)
{
return sha1($this->tags->getNamespace()).':'.$key;
}
-
- /**
- * {@inheritdoc}
- */
- protected function itemKey($key)
- {
- return $this->taggedItemKey($key);
- }
} | false |
Other | laravel | framework | 5317cb529989e73793a64bbfc3ae9b6ed55ed3fd.json | fix method order. | src/Illuminate/Database/Query/Grammars/PostgresGrammar.php | @@ -33,6 +33,71 @@ protected function compileLock(Builder $query, $value)
return $value ? 'for update' : 'for share';
}
+ /**
+ * Compile a "where date" clause.
+ *
+ * @param \Illuminate\Database\Query\Builder $query
+ * @param array $where
+ * @return string
+ */
+ protected function whereDate(Builder $query, $where)
+ {
+ $value = $this->parameter($where['value']);
+
+ return $this->wrap($where['column']).' '.$where['operator'].' '.$value.'::date';
+ }
+
+ /**
+ * Compile a "where day" clause.
+ *
+ * @param \Illuminate\Database\Query\Builder $query
+ * @param array $where
+ * @return string
+ */
+ protected function whereDay(Builder $query, $where)
+ {
+ return $this->dateBasedWhere('day', $query, $where);
+ }
+
+ /**
+ * Compile a "where month" clause.
+ *
+ * @param \Illuminate\Database\Query\Builder $query
+ * @param array $where
+ * @return string
+ */
+ protected function whereMonth(Builder $query, $where)
+ {
+ return $this->dateBasedWhere('month', $query, $where);
+ }
+
+ /**
+ * Compile a "where year" clause.
+ *
+ * @param \Illuminate\Database\Query\Builder $query
+ * @param array $where
+ * @return string
+ */
+ protected function whereYear(Builder $query, $where)
+ {
+ return $this->dateBasedWhere('year', $query, $where);
+ }
+
+ /**
+ * Compile a date based where clause.
+ *
+ * @param string $type
+ * @param \Illuminate\Database\Query\Builder $query
+ * @param array $where
+ * @return string
+ */
+ protected function dateBasedWhere($type, Builder $query, $where)
+ {
+ $value = $this->parameter($where['value']);
+
+ return 'extract('.$type.' from '.$this->wrap($where['column']).') '.$where['operator'].' '.$value;
+ }
+
/**
* Compile an update statement into SQL.
*
@@ -177,69 +242,4 @@ public function compileTruncate(Builder $query)
{
return ['truncate '.$this->wrapTable($query->from).' restart identity' => []];
}
-
- /**
- * Compile a "where date" clause.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function whereDate(Builder $query, $where)
- {
- $value = $this->parameter($where['value']);
-
- return $this->wrap($where['column']).' '.$where['operator'].' '.$value.'::date';
- }
-
- /**
- * Compile a "where day" clause.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function whereDay(Builder $query, $where)
- {
- return $this->dateBasedWhere('day', $query, $where);
- }
-
- /**
- * Compile a "where month" clause.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function whereMonth(Builder $query, $where)
- {
- return $this->dateBasedWhere('month', $query, $where);
- }
-
- /**
- * Compile a "where year" clause.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function whereYear(Builder $query, $where)
- {
- return $this->dateBasedWhere('year', $query, $where);
- }
-
- /**
- * Compile a date based where clause.
- *
- * @param string $type
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function dateBasedWhere($type, Builder $query, $where)
- {
- $value = $this->parameter($where['value']);
-
- return 'extract('.$type.' from '.$this->wrap($where['column']).') '.$where['operator'].' '.$value;
- }
} | false |
Other | laravel | framework | 7f92e438efee87203f018f82beb6aed6e5c1f995.json | Fix typo on closing tag | src/Illuminate/Auth/Console/stubs/make/views/layouts/app.stub | @@ -65,7 +65,7 @@
<ul class="dropdown-menu" role="menu">
<li><a href="{{ url('/logout') }}"><i class="fa fa-btn fa-sign-out"></i>Logout</a></li>
</ul>
- <li>
+ </li>
@endif
</ul>
</div> | false |
Other | laravel | framework | bad938609f113c7af6863bedd67076ff8b8cf996.json | Fix closing tag | src/Illuminate/Auth/Console/stubs/make/views/layouts/app.stub | @@ -65,7 +65,7 @@
<ul class="dropdown-menu" role="menu">
<li><a href="{{ url('/logout') }}"><i class="fa fa-btn fa-sign-out"></i>Logout</a></li>
</ul>
- <li>
+ </li>
@endif
</ul>
</div> | false |
Other | laravel | framework | 92a3b24ba8fea8cb0342c8efbf0b7025ec98496b.json | update validation logic | src/Illuminate/Foundation/Application.php | @@ -25,7 +25,7 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
*
* @var string
*/
- const VERSION = '5.2.1';
+ const VERSION = '5.2.2';
/**
* The base path for the Laravel installation. | true |
Other | laravel | framework | 92a3b24ba8fea8cb0342c8efbf0b7025ec98496b.json | update validation logic | src/Illuminate/Validation/Validator.php | @@ -806,7 +806,7 @@ protected function validateArray($attribute, $value)
return true;
}
- return is_array($value);
+ return is_null($value) || is_array($value);
}
/**
@@ -824,7 +824,7 @@ protected function validateBoolean($attribute, $value)
$acceptable = [true, false, 0, 1, '0', '1'];
- return in_array($value, $acceptable, true);
+ return is_null($value) || in_array($value, $acceptable, true);
}
/**
@@ -840,7 +840,7 @@ protected function validateInteger($attribute, $value)
return true;
}
- return filter_var($value, FILTER_VALIDATE_INT) !== false;
+ return is_null($value) || filter_var($value, FILTER_VALIDATE_INT) !== false;
}
/**
@@ -856,7 +856,7 @@ protected function validateNumeric($attribute, $value)
return true;
}
- return is_numeric($value);
+ return is_null($value) || is_numeric($value);
}
/**
@@ -872,7 +872,7 @@ protected function validateString($attribute, $value)
return true;
}
- return is_string($value);
+ return is_null($value) || is_string($value);
}
/** | true |
Other | laravel | framework | 92a3b24ba8fea8cb0342c8efbf0b7025ec98496b.json | update validation logic | tests/Validation/ValidationValidatorTest.php | @@ -1874,8 +1874,14 @@ public function testThatPrimitiveTypesAreImplicitAndMustBeCorrectIfDataIsPresent
$v = new Validator($trans, [], ['foo' => 'numeric']);
$this->assertTrue($v->passes());
+ // Allow null on these rules unless required
$trans = $this->getRealTranslator();
$v = new Validator($trans, ['foo' => null], ['foo' => 'numeric']);
+ $this->assertFalse($v->fails());
+
+ // Allow null on these rules unless required
+ $trans = $this->getRealTranslator();
+ $v = new Validator($trans, ['foo' => null], ['foo' => 'required|numeric']);
$this->assertTrue($v->fails());
$trans = $this->getRealTranslator(); | true |
Other | laravel | framework | acf0fb9bbf24972defafc2844b9a524e0855306e.json | fix bug in soft delete scope application. | src/Illuminate/Database/Eloquent/Builder.php | @@ -87,6 +87,10 @@ public function withGlobalScope($identifier, $scope)
{
$this->scopes[$identifier] = $scope;
+ if (method_exists($scope, 'extend')) {
+ $scope->extend($this);
+ }
+
return $this;
}
| true |
Other | laravel | framework | acf0fb9bbf24972defafc2844b9a524e0855306e.json | fix bug in soft delete scope application. | src/Illuminate/Database/Eloquent/SoftDeletingScope.php | @@ -21,8 +21,6 @@ class SoftDeletingScope implements Scope
public function apply(Builder $builder, Model $model)
{
$builder->whereNull($model->getQualifiedDeletedAtColumn());
-
- $this->extend($builder);
}
/** | true |
Other | laravel | framework | acf0fb9bbf24972defafc2844b9a524e0855306e.json | fix bug in soft delete scope application. | tests/Database/DatabaseSoftDeletingScopeTest.php | @@ -16,7 +16,6 @@ public function testApplyingScopeToABuilder()
$model = m::mock('Illuminate\Database\Eloquent\Model');
$model->shouldReceive('getQualifiedDeletedAtColumn')->once()->andReturn('table.deleted_at');
$builder->shouldReceive('whereNull')->once()->with('table.deleted_at');
- $scope->shouldReceive('extend')->once();
$scope->apply($builder, $model);
} | true |
Other | laravel | framework | e5255cd7b57c5e5d3fb04d5512bcc9ce2c4401cf.json | Remove unnecessary in foreach. | src/Illuminate/Support/Collection.php | @@ -153,7 +153,7 @@ public function every($step, $offset = 0)
$position = 0;
- foreach ($this->items as $key => $item) {
+ foreach ($this->items as $item) {
if ($position % $step === $offset) {
$new[] = $item;
} | false |
Other | laravel | framework | d43f114b02133269e9c2571169e11deb1c456921.json | Remove unnecessary $key in foreach | src/Illuminate/Container/Container.php | @@ -533,7 +533,7 @@ protected function getMethodDependencies($callback, array $parameters = [])
{
$dependencies = [];
- foreach ($this->getCallReflector($callback)->getParameters() as $key => $parameter) {
+ foreach ($this->getCallReflector($callback)->getParameters() as $parameter) {
$this->addDependencyForCallParameter($parameter, $parameters, $dependencies);
}
| false |
Other | laravel | framework | 6547088dbd7ec931761737cfbb5e55a17165f99f.json | Fix bug in validation message retrieval. | src/Illuminate/Validation/Validator.php | @@ -1663,9 +1663,9 @@ protected function getInlineMessage($attribute, $lowerRule, $source = null)
// message for the fields, then we will check for a general custom line
// that is not attribute specific. If we find either we'll return it.
foreach ($keys as $key) {
- foreach (array_flip($source) as $value => $sourceKey) {
+ foreach (array_keys($source) as $sourceKey) {
if (Str::is($sourceKey, $key)) {
- return $value;
+ return $source[$sourceKey];
}
}
} | false |
Other | laravel | framework | 8b6c5e6a7c4f00169b217b659ec3d307d2fa81c0.json | fix pagination bug | src/Illuminate/Database/Eloquent/Builder.php | @@ -336,7 +336,7 @@ public function paginate($perPage = null, $columns = ['*'], $pageName = 'page',
$total = $query->getCountForPagination();
- $query->forPage(
+ $this->forPage(
$page = $page ?: Paginator::resolveCurrentPage($pageName),
$perPage = $perPage ?: $this->model->getPerPage()
); | false |
Other | laravel | framework | b17da439be7248cf9fad565982541348de6f90b6.json | Use the new makeVisible method in the tests | tests/Database/DatabaseEloquentCollectionTest.php | @@ -226,7 +226,7 @@ public function testExceptReturnsCollectionWithoutGivenModelKeys()
public function testWithHiddenSetsHiddenOnEntireCollection()
{
$c = new Collection([new TestEloquentCollectionModel]);
- $c = $c->withHidden(['hidden']);
+ $c = $c->makeVisible(['hidden']);
$this->assertEquals([], $c[0]->getHidden());
} | true |
Other | laravel | framework | b17da439be7248cf9fad565982541348de6f90b6.json | Use the new makeVisible method in the tests | tests/Database/DatabaseEloquentModelTest.php | @@ -698,7 +698,7 @@ public function testWithHidden()
{
$model = new EloquentModelStub(['name' => 'foo', 'age' => 'bar', 'id' => 'baz']);
$model->setHidden(['age', 'id']);
- $model->withHidden('age');
+ $model->makeVisible('age');
$array = $model->toArray();
$this->assertArrayHasKey('name', $array);
$this->assertArrayHasKey('age', $array); | true |
Other | laravel | framework | e5853da9a0484d54aa28a9a2e4ed774bb4f954a4.json | Remove unused variable $declaringClass | src/Illuminate/Container/Container.php | @@ -814,8 +814,6 @@ protected function getDependencies(array $parameters, array $primitives = [])
*/
protected function resolveNonClass(ReflectionParameter $parameter)
{
- $declaringClass = $parameter->getDeclaringClass();
-
if (! is_null($concrete = $this->getContextualConcrete('$'.$parameter->name))) {
if ($concrete instanceof Closure) {
return call_user_func($concrete, $this); | false |
Other | laravel | framework | 172ef6a271af0776f9f587671d0da7ec18a25d95.json | Fix RequestGuard::user() returning void
Broken since f8a8e775c79f012806c9bef4d0302b14d9e14a1f | src/Illuminate/Auth/RequestGuard.php | @@ -51,7 +51,7 @@ public function user()
return $this->user;
}
- $this->user = call_user_func($this->callback, $this->request);
+ return $this->user = call_user_func($this->callback, $this->request);
}
/** | false |
Other | laravel | framework | 84bd1731c43a941758e486e68b890d5b6dbde73c.json | reset global scopes when booted models get cleared | src/Illuminate/Database/Eloquent/Model.php | @@ -332,6 +332,7 @@ protected static function bootTraits()
public static function clearBootedModels()
{
static::$booted = [];
+ static::$globalScopes = [];
}
/** | false |
Other | laravel | framework | 3586d080ea048cf1fa4430dc85e707bb9b0e7473.json | Use data_get in request. | src/Illuminate/Http/Request.php | @@ -290,7 +290,7 @@ public function input($key = null, $default = null)
{
$input = $this->getInputSource()->all() + $this->query->all();
- return Arr::get($input, $key, $default);
+ return data_get($input, $key, $default);
}
/**
@@ -308,7 +308,7 @@ public function only($keys)
$input = $this->all();
foreach ($keys as $key) {
- Arr::set($results, $key, Arr::get($input, $key));
+ Arr::set($results, $key, data_get($input, $key));
}
return $results;
@@ -375,7 +375,7 @@ public function cookie($key = null, $default = null)
*/
public function file($key = null, $default = null)
{
- return Arr::get($this->files->all(), $key, $default);
+ return data_get($this->files->all(), $key, $default);
}
/**
@@ -552,7 +552,7 @@ public function json($key = null, $default = null)
return $this->json;
}
- return Arr::get($this->json->all(), $key, $default);
+ return data_get($this->json->all(), $key, $default);
}
/**
@@ -900,7 +900,7 @@ public function offsetExists($offset)
*/
public function offsetGet($offset)
{
- return Arr::get($this->all(), $offset);
+ return data_get($this->all(), $offset);
}
/** | false |
Other | laravel | framework | 8e6ac01b4a311ec4740ab2bced01fbdf6f1241c5.json | make resource opt in | src/Illuminate/Routing/Console/ControllerMakeCommand.php | @@ -19,7 +19,7 @@ class ControllerMakeCommand extends GeneratorCommand
*
* @var string
*/
- protected $description = 'Create a new resource controller class';
+ protected $description = 'Create a new controller class';
/**
* The type of class being generated.
@@ -35,11 +35,11 @@ class ControllerMakeCommand extends GeneratorCommand
*/
protected function getStub()
{
- if ($this->option('plain')) {
- return __DIR__.'/stubs/controller.plain.stub';
+ if ($this->option('resource')) {
+ return __DIR__.'/stubs/controller.stub';
}
- return __DIR__.'/stubs/controller.stub';
+ return __DIR__.'/stubs/controller.plain.stub';
}
/**
@@ -61,7 +61,7 @@ protected function getDefaultNamespace($rootNamespace)
protected function getOptions()
{
return [
- ['plain', null, InputOption::VALUE_NONE, 'Generate an empty controller class.'],
+ ['resource', null, InputOption::VALUE_NONE, 'Generate a resource controller class.'],
];
}
} | false |
Other | laravel | framework | cee00096f03e223967a689fdebeca657d5a9c675.json | Add tests for array access implementation. | tests/Support/SupportCollectionTest.php | @@ -142,6 +142,52 @@ public function testOffsetAccess()
$this->assertEquals('jason', $c[0]);
}
+ public function testArrayAccessOffsetExists()
+ {
+ $c = new Collection(['foo', 'bar']);
+ $this->assertTrue($c->offsetExists(0));
+ $this->assertTrue($c->offsetExists(1));
+ $this->assertFalse($c->offsetExists(1000));
+ }
+
+ public function testArrayAccessOffsetGet()
+ {
+ $c = new Collection(['foo', 'bar']);
+ $this->assertEquals('foo', $c->offsetGet(0));
+ $this->assertEquals('bar', $c->offsetGet(1));
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error_Notice
+ */
+ public function testArrayAccessOffsetGetOnNonExist()
+ {
+ $c = new Collection(['foo', 'bar']);
+ $c->offsetGet(1000);
+ }
+
+ public function testArrayAccessOffsetSet()
+ {
+ $c = new Collection(['foo', 'foo']);
+
+ $c->offsetSet(1, 'bar');
+ $this->assertEquals('bar', $c[1]);
+
+ $c->offsetSet(null, 'qux');
+ $this->assertEquals('qux', $c[2]);
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error_Notice
+ */
+ public function testArrayAccessOffsetUnset()
+ {
+ $c = new Collection(['foo', 'bar']);
+
+ $c->offsetUnset(1);
+ $c[1];
+ }
+
public function testForgetSingleKey()
{
$c = new Collection(['foo', 'bar']); | false |
Other | laravel | framework | 29031cb70a60932e40b317ad4c9e693b82564afc.json | Fix a long line. | src/Illuminate/Auth/Console/MakeAuthCommand.php | @@ -50,7 +50,10 @@ public function fire()
if (! $this->option('views')) {
$this->info('Installed HomeController.');
- copy(__DIR__.'/stubs/make/controllers/HomeController.stub', app_path('Http/Controllers/HomeController.php'));
+ copy(
+ __DIR__.'/stubs/make/controllers/HomeController.stub',
+ app_path('Http/Controllers/HomeController.php')
+ );
$this->info('Updated Routes File.');
| false |
Other | laravel | framework | 3616c2d43a22df8f6d87d788918a05b22c5c29e4.json | Use provider for consistent language. | src/Illuminate/Auth/AuthManager.php | @@ -99,7 +99,7 @@ protected function callCustomCreator($name, array $config)
*/
public function createSessionDriver($name, $config)
{
- $provider = $this->createUserProvider($config['source']);
+ $provider = $this->createUserProvider($config['provider']);
$guard = new SessionGuard($name, $provider, $this->app['session.store']);
@@ -134,7 +134,7 @@ public function createTokenDriver($name, $config)
// that takes an API token field from the request and matches it to the
// user in the database or another persistence layer where users are.
$guard = new TokenGuard(
- $this->createUserProvider($config['source']),
+ $this->createUserProvider($config['provider']),
$this->app['request']
);
| true |
Other | laravel | framework | 3616c2d43a22df8f6d87d788918a05b22c5c29e4.json | Use provider for consistent language. | src/Illuminate/Auth/CreatesUserProviders.php | @@ -23,7 +23,7 @@ trait CreatesUserProviders
*/
protected function createUserProvider($provider)
{
- $config = $this->app['config']['auth.sources.'.$provider];
+ $config = $this->app['config']['auth.providers.'.$provider];
if (isset($this->customProviderCreators[$provider])) {
return call_user_func(
@@ -37,7 +37,7 @@ protected function createUserProvider($provider)
case 'eloquent':
return $this->createEloquentProvider($config);
default:
- throw new InvalidArgumentException("Authentication user source [{$config['driver']}] is not defined.");
+ throw new InvalidArgumentException("Authentication user provider [{$config['driver']}] is not defined.");
}
}
| true |
Other | laravel | framework | 3616c2d43a22df8f6d87d788918a05b22c5c29e4.json | Use provider for consistent language. | src/Illuminate/Auth/Passwords/PasswordBrokerManager.php | @@ -69,7 +69,7 @@ protected function resolve($name)
// aggregate service of sorts providing a convenient interface for resets.
return new PasswordBroker(
$this->createTokenRepository($config),
- $this->createUserProvider($config['source']),
+ $this->createUserProvider($config['provider']),
$this->app['mailer'],
$config['email']
); | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.