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
47b934e6b8c8306e4813590b8d390f0ba5e196b9.json
Ensure return null are consistent. (#20884)
src/Illuminate/Auth/Access/Gate.php
@@ -398,7 +398,7 @@ public function getPolicyFor($class) } if (! is_string($class)) { - return null; + return; } if (isset($this->policies[$class])) {
true
Other
laravel
framework
47b934e6b8c8306e4813590b8d390f0ba5e196b9.json
Ensure return null are consistent. (#20884)
tests/Broadcasting/BroadcasterTest.php
@@ -126,6 +126,6 @@ public function where($key, $value) public function first() { - return null; + // } }
true
Other
laravel
framework
47b934e6b8c8306e4813590b8d390f0ba5e196b9.json
Ensure return null are consistent. (#20884)
tests/Queue/QueueSyncQueueTest.php
@@ -59,7 +59,7 @@ public function getQueueableId() public function getQueueableConnection() { - return null; + // } }
true
Other
laravel
framework
47b934e6b8c8306e4813590b8d390f0ba5e196b9.json
Ensure return null are consistent. (#20884)
tests/Routing/RoutingUrlGeneratorTest.php
@@ -468,7 +468,7 @@ public function getRouteKeyName() public function resolveRouteBinding($routeKey) { - return null; + // } }
true
Other
laravel
framework
5f40dc6e547043d5fd9b8f7d1baaaeec4d953c53.json
Fix LengthAwarePaginator docblocks (#20899)
src/Illuminate/Pagination/LengthAwarePaginator.php
@@ -71,7 +71,7 @@ protected function setCurrentPage($currentPage, $pageName) * * @param string $view * @param array $data - * @return string + * @return \Illuminate\Support\HtmlString */ public function links($view = null, $data = []) { @@ -83,7 +83,7 @@ public function links($view = null, $data = []) * * @param string $view * @param array $data - * @return string + * @return \Illuminate\Support\HtmlString */ public function render($view = null, $data = []) {
false
Other
laravel
framework
add68eafe262955a587c181ecfc85598d6467402.json
Fix typos and add missing docblocks
src/Illuminate/Redis/Limiters/ConcurrencyLimiterBuilder.php
@@ -47,7 +47,7 @@ class ConcurrencyLimiterBuilder /** * Create a new builder instance. * - * @param \Illuminate\Redis\Connetions\Connection $connection + * @param \Illuminate\Redis\Connections\Connection $connection * @param string $name * @return void */ @@ -100,8 +100,10 @@ public function block($timeout) * Execute the given callback if a lock is obtained, otherise call the failure callback. * * @param callable $callback - * @param callable $failure + * @param callable|null $failure * @return mixed + * + * @throws \Illuminate\Contracts\Redis\LimiterTimeoutException */ public function then(callable $callback, callable $failure = null) {
true
Other
laravel
framework
add68eafe262955a587c181ecfc85598d6467402.json
Fix typos and add missing docblocks
src/Illuminate/Redis/Limiters/DurationLimiterBuilder.php
@@ -47,7 +47,7 @@ class DurationLimiterBuilder /** * Create a new builder instance. * - * @param \Illuminate\Redis\Connetions\Connection $connection + * @param \Illuminate\Redis\Connections\Connection $connection * @param string $name * @return void */ @@ -100,8 +100,10 @@ public function block($timeout) * Execute the given callback if a lock is obtained, otherise call the failure callback. * * @param callable $callback - * @param callable $failure + * @param callable|null $failure * @return mixed + * + * @throws \Illuminate\Contracts\Redis\LimiterTimeoutException */ public function then(callable $callback, callable $failure = null) {
true
Other
laravel
framework
53564916cd38cd7b67d4f966b17ba2f96f929eda.json
Remove unused imports
src/Illuminate/Broadcasting/BroadcastEvent.php
@@ -6,7 +6,6 @@ use ReflectionProperty; use Illuminate\Support\Arr; use Illuminate\Bus\Queueable; -use Illuminate\Contracts\Queue\Job; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Support\Arrayable; use Illuminate\Contracts\Broadcasting\Broadcaster;
true
Other
laravel
framework
53564916cd38cd7b67d4f966b17ba2f96f929eda.json
Remove unused imports
src/Illuminate/Broadcasting/Broadcasters/Broadcaster.php
@@ -5,7 +5,6 @@ use ReflectionFunction; use Illuminate\Support\Str; use Illuminate\Container\Container; -use Illuminate\Database\Eloquent\Model; use Illuminate\Contracts\Routing\UrlRoutable; use Illuminate\Contracts\Routing\BindingRegistrar; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
true
Other
laravel
framework
53564916cd38cd7b67d4f966b17ba2f96f929eda.json
Remove unused imports
src/Illuminate/Cache/DatabaseStore.php
@@ -4,7 +4,6 @@ use Closure; use Exception; -use Illuminate\Support\Carbon; use Illuminate\Contracts\Cache\Store; use Illuminate\Support\InteractsWithTime; use Illuminate\Database\ConnectionInterface;
true
Other
laravel
framework
53564916cd38cd7b67d4f966b17ba2f96f929eda.json
Remove unused imports
src/Illuminate/Foundation/Console/OptimizeCommand.php
@@ -3,7 +3,6 @@ namespace Illuminate\Foundation\Console; use Illuminate\Console\Command; -use Illuminate\Support\Composer; use Symfony\Component\Console\Input\InputOption; class OptimizeCommand extends Command
true
Other
laravel
framework
53564916cd38cd7b67d4f966b17ba2f96f929eda.json
Remove unused imports
src/Illuminate/Foundation/Testing/TestResponse.php
@@ -8,7 +8,6 @@ use Illuminate\Contracts\View\View; use Illuminate\Support\Traits\Macroable; use PHPUnit\Framework\Assert as PHPUnit; -use Symfony\Component\HttpFoundation\Cookie; /** * @mixin \Illuminate\Http\Response
true
Other
laravel
framework
53564916cd38cd7b67d4f966b17ba2f96f929eda.json
Remove unused imports
src/Illuminate/Http/Resources/CollectsResources.php
@@ -3,7 +3,6 @@ namespace Illuminate\Http\Resources; use Illuminate\Support\Str; -use Illuminate\Support\Collection; use Illuminate\Pagination\AbstractPaginator; trait CollectsResources
true
Other
laravel
framework
53564916cd38cd7b67d4f966b17ba2f96f929eda.json
Remove unused imports
src/Illuminate/Http/Resources/Json/ResourceCollection.php
@@ -3,7 +3,6 @@ namespace Illuminate\Http\Resources\Json; use IteratorAggregate; -use Illuminate\Support\Collection; use Illuminate\Pagination\AbstractPaginator; use Illuminate\Http\Resources\CollectsResources;
true
Other
laravel
framework
740064803568a62ab7c0514d821727947bab7fdd.json
Fix Auth docblocks
src/Illuminate/Auth/SessionGuard.php
@@ -696,7 +696,7 @@ public function setDispatcher(Dispatcher $events) /** * Get the session store used by the guard. * - * @return \Illuminate\Session\Store + * @return \Illuminate\Contracts\Session\Session. */ public function getSession() {
false
Other
laravel
framework
08100578cb467d359f5f0ef8efa7765bdde127f8.json
Ensure Carbon is reset after rate tests.
src/Illuminate/Cache/RateLimiter.php
@@ -40,11 +40,9 @@ public function tooManyAttempts($key, $maxAttempts, $decayMinutes = 1) if ($this->attempts($key) >= $maxAttempts) { if ($this->cache->has($key.':timer')) { return true; - } else { - $this->resetAttempts($key); - - return false; } + + $this->resetAttempts($key); } return false;
true
Other
laravel
framework
08100578cb467d359f5f0ef8efa7765bdde127f8.json
Ensure Carbon is reset after rate tests.
tests/Integration/Http/ThrottleRequestsTest.php
@@ -2,6 +2,7 @@ namespace Illuminate\Tests\Integration\Http; +use Throwable; use Illuminate\Support\Carbon; use Orchestra\Testbench\TestCase; use Illuminate\Support\Facades\Route; @@ -20,10 +21,15 @@ protected function getEnvironmentSetUp($app) public function setup() { parent::setup(); - resolve('redis')->flushall(); } + public function tearDown() + { + parent::tearDown(); + Carbon::setTestNow(null); + } + public function test_lock_opens_immediately_after_decay() { Carbon::setTestNow(null); @@ -47,8 +53,8 @@ public function test_lock_opens_immediately_after_decay() ); try { - $response = $this->withoutExceptionHandling()->get('/'); - } catch (\Throwable $e) { + $this->withoutExceptionHandling()->get('/'); + } catch (Throwable $e) { $this->assertEquals(429, $e->getStatusCode()); $this->assertEquals(2, $e->getHeaders()['X-RateLimit-Limit']); $this->assertEquals(0, $e->getHeaders()['X-RateLimit-Remaining']);
true
Other
laravel
framework
08100578cb467d359f5f0ef8efa7765bdde127f8.json
Ensure Carbon is reset after rate tests.
tests/Integration/Http/ThrottleRequestsWithRedisTest.php
@@ -2,6 +2,7 @@ namespace Illuminate\Tests\Integration\Http; +use Throwable; use Illuminate\Support\Carbon; use Orchestra\Testbench\TestCase; use Illuminate\Support\Facades\Route; @@ -12,6 +13,12 @@ */ class ThrottleRequestsWithRedisTest extends TestCase { + public function tearDown() + { + parent::tearDown(); + Carbon::setTestNow(null); + } + public function test_lock_opens_immediately_after_decay() { Carbon::setTestNow(null); @@ -37,13 +44,13 @@ public function test_lock_opens_immediately_after_decay() ); try { - $response = $this->withoutExceptionHandling()->get('/'); - } catch (\Throwable $e) { + $this->withoutExceptionHandling()->get('/'); + } catch (Throwable $e) { $this->assertEquals(429, $e->getStatusCode()); $this->assertEquals(2, $e->getHeaders()['X-RateLimit-Limit']); $this->assertEquals(0, $e->getHeaders()['X-RateLimit-Remaining']); $this->assertTrue(in_array($e->getHeaders()['Retry-After'], [2, 3])); - $this->assertTrue(in_array($e->getHeaders()['X-RateLimit-Reset'], [Carbon::now()->getTimestamp() + 2, Carbon::now()->timestamp + 3])); + $this->assertTrue(in_array($e->getHeaders()['X-RateLimit-Reset'], [Carbon::now()->getTimestamp() + 2, Carbon::now()->getTimestamp() + 3])); } } }
true
Other
laravel
framework
2cc93b3b631cbc3d211a3304a2878388ea2770f0.json
Add Request::validate() method tag (#20866)
src/Illuminate/Http/Request.php
@@ -12,6 +12,9 @@ use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\Request as SymfonyRequest; +/** + * @method array validate(array $rules, array $messages = [], array $customAttributes = []) + */ class Request extends SymfonyRequest implements Arrayable, ArrayAccess { use Concerns\InteractsWithContentTypes,
false
Other
laravel
framework
6b7dbc7144b6a1e6d5ff5490e8769b071ea0fb23.json
Remove unnecessary else (#20846)
src/Illuminate/Queue/Console/ListFailedCommand.php
@@ -100,9 +100,9 @@ protected function matchJobName($payload) if (isset($matches[1])) { return $matches[1]; - } else { - return $payload['job'] ?? null; } + + return $payload['job'] ?? null; } /**
false
Other
laravel
framework
2f8376e74dd4bb28ce786e1873823eedc6b0c4c5.json
Recommend stable psr http bridge (#20850)
composer.json
@@ -119,7 +119,7 @@ "pusher/pusher-php-server": "Required to use the Pusher broadcast driver (~2.0).", "symfony/css-selector": "Required to use some of the crawler integration testing tools (~3.3).", "symfony/dom-crawler": "Required to use most of the crawler integration testing tools (~3.3).", - "symfony/psr-http-message-bridge": "Required to psr7 bridging features (0.2.*)." + "symfony/psr-http-message-bridge": "Required to psr7 bridging features (~1.0)." }, "config": { "sort-packages": true
true
Other
laravel
framework
2f8376e74dd4bb28ce786e1873823eedc6b0c4c5.json
Recommend stable psr http bridge (#20850)
src/Illuminate/Routing/composer.json
@@ -38,7 +38,7 @@ }, "suggest": { "illuminate/console": "Required to use the make commands (5.5.*).", - "symfony/psr-http-message-bridge": "Required to psr7 bridging features (0.2.*)." + "symfony/psr-http-message-bridge": "Required to psr7 bridging features (~1.0)." }, "config": { "sort-packages": true
true
Other
laravel
framework
7e8a6e5115bd128fa83ffa5a22f6a5dc6da44323.json
remove @author docblocks (#20848) is this something we're doing now? otherwise I think we should stay consistent and omit them.
src/Illuminate/Support/helpers.php
@@ -335,8 +335,6 @@ function array_wrap($value) /** * Determine if the given value is "blank". * - * @author Derek MacDonald (https://github.com/derekmd) - * * @param mixed $value * @return bool */ @@ -637,8 +635,6 @@ function env($key, $default = null) /** * Determine if a value is "filled". * - * @author Derek MacDonald (https://github.com/derekmd) - * * @param mixed $value * @return bool */ @@ -1112,8 +1108,6 @@ function trait_uses_recursive($trait) /** * Transform the given value if it is present. * - * @author Derek MacDonald (https://github.com/derekmd) - * * @param mixed $value * @param callable $callback * @param mixed $default
false
Other
laravel
framework
2af7339b956d22db98ec0b018942fc626bd1c8c1.json
Add 'retrieved' to the list of observable events
src/Illuminate/Database/Eloquent/Concerns/HasEvents.php
@@ -57,7 +57,7 @@ public function getObservableEvents() [ 'creating', 'created', 'updating', 'updated', 'deleting', 'deleted', 'saving', 'saved', - 'restoring', 'restored', + 'restoring', 'restored', 'retrieved', ], $this->observables );
false
Other
laravel
framework
e00feed421ab788a593e3a19a41fc0b342c03c07.json
Add method to register a 'retrieved' model event
src/Illuminate/Database/Eloquent/Concerns/HasEvents.php
@@ -274,6 +274,17 @@ public static function deleted($callback) static::registerModelEvent('deleted', $callback); } + /** + * Register a retrieved model event with the dispatcher. + * + * @param \Closure|string $callback + * @return void + */ + public static function retrieved($callback) + { + static::registerModelEvent('retrieved', $callback); + } + /** * Remove all of the event listeners for the model. *
false
Other
laravel
framework
42765659c16f5327c1d5c826b82b71a3c3cef4ee.json
Use end to get last element of array (#20844)
src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php
@@ -404,7 +404,7 @@ public function getForeignKeyName() { $segments = explode('.', $this->getQualifiedForeignKeyName()); - return $segments[count($segments) - 1]; + return end($segments); } /**
false
Other
laravel
framework
c60cf5e029bedf83ee19a2e2a6388c0de374e155.json
Add whereKeyNot to changelog
CHANGELOG-5.5.md
@@ -135,6 +135,7 @@ - ⚠️ Call `setConnection()` in `Model::save()` ([#20466](https://github.com/laravel/framework/pull/20466)) - ⚠️ Touch parent timestamp only if the model is dirty ([#20489](https://github.com/laravel/framework/pull/20489)) - Added `Model::loadMissing()` method ([#20630](https://github.com/laravel/framework/pull/20630), [4166c12](https://github.com/laravel/framework/commit/4166c12492ce7b1112911299caf4cdb17efc9364)) +- Added `whereKeyNot()` method ([#20817](https://github.com/laravel/framework/pull/20817)) ### Encryption - Use `openssl_cipher_iv_length()` in `Encrypter` ([#18684](https://github.com/laravel/framework/pull/18684))
false
Other
laravel
framework
21f4d19c8413a6688603a73ca341c1de162ec1ee.json
Add whereKeyNot to Eloquent Builder (#20817)
src/Illuminate/Database/Eloquent/Builder.php
@@ -190,6 +190,23 @@ public function whereKey($id) return $this->where($this->model->getQualifiedKeyName(), '=', $id); } + /** + * Add a where clause on the primary key to the query. + * + * @param mixed $id + * @return $this + */ + public function whereKeyNot($id) + { + if (is_array($id) || $id instanceof Arrayable) { + $this->query->whereNotIn($this->model->getQualifiedKeyName(), $id); + + return $this; + } + + return $this->where($this->model->getQualifiedKeyName(), '!=', $id); + } + /** * Add a basic where clause to the query. *
true
Other
laravel
framework
21f4d19c8413a6688603a73ca341c1de162ec1ee.json
Add whereKeyNot to Eloquent Builder (#20817)
tests/Database/DatabaseEloquentBuilderTest.php
@@ -914,6 +914,45 @@ public function testWhereKeyMethodWithCollection() $builder->whereKey($collection); } + public function testWhereKeyNotMethodWithInt() + { + $model = $this->getMockModel(); + $builder = $this->getBuilder()->setModel($model); + $keyName = $model->getQualifiedKeyName(); + + $int = 1; + + $builder->getQuery()->shouldReceive('where')->once()->with($keyName, '!=', $int); + + $builder->whereKeyNot($int); + } + + public function testWhereKeyNotMethodWithArray() + { + $model = $this->getMockModel(); + $builder = $this->getBuilder()->setModel($model); + $keyName = $model->getQualifiedKeyName(); + + $array = [1, 2, 3]; + + $builder->getQuery()->shouldReceive('whereNotIn')->once()->with($keyName, $array); + + $builder->whereKeyNot($array); + } + + public function testWhereKeyNotMethodWithCollection() + { + $model = $this->getMockModel(); + $builder = $this->getBuilder()->setModel($model); + $keyName = $model->getQualifiedKeyName(); + + $collection = new Collection([1, 2, 3]); + + $builder->getQuery()->shouldReceive('whereNotIn')->once()->with($keyName, $collection); + + $builder->whereKeyNot($collection); + } + protected function mockConnectionForModel($model, $database) { $grammarClass = 'Illuminate\Database\Query\Grammars\\'.$database.'Grammar';
true
Other
laravel
framework
1e1b4c5b0681141f0219dbf938d117d7239acd88.json
Use getKey (#20811)
src/Illuminate/Database/Eloquent/Model.php
@@ -644,7 +644,7 @@ protected function setKeysForSaveQuery(Builder $query) protected function getKeyForSaveQuery() { return $this->original[$this->getKeyName()] - ?? $this->getAttribute($this->getKeyName()); + ?? $this->getKey(); } /**
false
Other
laravel
framework
3d8ae049e84f5ed06107bd0bbf9a68538576f5d2.json
Apply fixes from StyleCI (#20792)
tests/Support/SupportCollectionTest.php
@@ -2140,7 +2140,7 @@ public function testPartition() public function testPartitionCallbackWithKey() { - $collection = new Collection(['zero', 'one','two', 'three']); + $collection = new Collection(['zero', 'one', 'two', 'three']); list($even, $odd) = $collection->partition(function ($item, $index) { return $index % 2 === 0;
false
Other
laravel
framework
73de18e32a7d04ed61c1a37b724732a23aad259c.json
allow meta data from response building
src/Illuminate/Http/Resources/Json/PaginatedResourceResponse.php
@@ -19,7 +19,8 @@ public function toResponse($request) $this->resource->resolve($request), array_merge_recursive( $this->paginationInformation($request), - $this->resource->with($request) + $this->resource->with($request), + $this->resource->additional ) ), $this->calculateStatus()
true
Other
laravel
framework
73de18e32a7d04ed61c1a37b724732a23aad259c.json
allow meta data from response building
src/Illuminate/Http/Resources/Json/Resource.php
@@ -31,6 +31,15 @@ class Resource implements ArrayAccess, JsonSerializable, Responsable, UrlRoutabl */ public $with = []; + /** + * The additional meta data that should be added to the resource response. + * + * Added during response constuction by the developer. + * + * @var array + */ + public $additional = []; + /** * The "data" wrapper that should be applied. * @@ -185,6 +194,19 @@ public function with($request) return $this->with; } + /** + * Add additional meta data to the resource response. + * + * @param array $data + * @return $this + */ + public function additional(array $data) + { + $this->additional = $data; + + return $this; + } + /** * Customize the response for a request. *
true
Other
laravel
framework
73de18e32a7d04ed61c1a37b724732a23aad259c.json
allow meta data from response building
src/Illuminate/Http/Resources/Json/ResourceResponse.php
@@ -37,7 +37,8 @@ public function toResponse($request) return tap(response()->json( $this->wrap( $this->resource->resolve($request), - $this->resource->with($request) + $this->resource->with($request), + $this->resource->additional ), $this->calculateStatus() ), function ($response) use ($request) { @@ -50,21 +51,22 @@ public function toResponse($request) * * @param array $data * @param array $with + * @param array $additional * @return array */ - protected function wrap($data, $with = []) + protected function wrap($data, $with = [], $additional = []) { if ($data instanceof Collection) { $data = $data->all(); } if ($this->haveDefaultWrapperAndDataIsUnwrapped($data)) { $data = [$this->wrapper() => $data]; - } elseif ($this->haveAdditionalInformationAndDataIsUnwrapped($data, $with)) { + } elseif ($this->haveAdditionalInformationAndDataIsUnwrapped($data, $with, $additional)) { $data = [($this->wrapper() ?? 'data') => $data]; } - return array_merge_recursive($data, $with); + return array_merge_recursive($data, $with, $additional); } /** @@ -83,13 +85,14 @@ protected function haveDefaultWrapperAndDataIsUnwrapped($data) * * @param array $data * @param array $with + * @param array $additional * @return bool */ - protected function haveAdditionalInformationAndDataIsUnwrapped($data, $with) + protected function haveAdditionalInformationAndDataIsUnwrapped($data, $with, $additional) { - return ! empty($with) && - (! $this->wrapper() || - ! array_key_exists($this->wrapper(), $data)); + return (! empty($with) || ! empty($additional)) && + (! $this->wrapper() || + ! array_key_exists($this->wrapper(), $data)); } /**
true
Other
laravel
framework
73de18e32a7d04ed61c1a37b724732a23aad259c.json
allow meta data from response building
tests/Integration/Http/ResourceTest.php
@@ -214,6 +214,29 @@ public function test_resources_may_customize_extra_data() ]); } + public function test_resources_may_customize_extra_data_when_building_response() + { + Route::get('/', function () { + return (new PostResourceWithExtraData(new Post([ + 'id' => 5, + 'title' => 'Test Title', + ])))->additional(['baz' => 'qux']); + }); + + $response = $this->withoutExceptionHandling()->get( + '/', ['Accept' => 'application/json'] + ); + + $response->assertJson([ + 'data' => [ + 'id' => 5, + 'title' => 'Test Title', + ], + 'foo' => 'bar', + 'baz' => 'qux', + ]); + } + public function test_custom_headers_may_be_set_on_responses() { Route::get('/', function () {
true
Other
laravel
framework
603ed4a73f926e2a94fb39a01ac1d1dbaf5255d1.json
Fix docblock on argument type (#20779)
src/Illuminate/Contracts/Foundation/Application.php
@@ -55,7 +55,7 @@ public function register($provider, $options = [], $force = false); * Register a deferred provider and service. * * @param string $provider - * @param string $service + * @param string|null $service * @return void */ public function registerDeferredProvider($provider, $service = null);
true
Other
laravel
framework
603ed4a73f926e2a94fb39a01ac1d1dbaf5255d1.json
Fix docblock on argument type (#20779)
src/Illuminate/Foundation/Application.php
@@ -668,7 +668,7 @@ public function loadDeferredProvider($service) * Register a deferred provider and service. * * @param string $provider - * @param string $service + * @param string|null $service * @return void */ public function registerDeferredProvider($provider, $service = null)
true
Other
laravel
framework
87e71db68fbf0d34fa1b1a729360b90f92806a2a.json
Fix docblock on argument type (#20777)
src/Illuminate/Validation/Concerns/FormatsMessages.php
@@ -68,7 +68,7 @@ protected function getMessage($attribute, $rule) * * @param string $attribute * @param string $lowerRule - * @param array $source + * @param array|null $source * @return string|null */ protected function getFromLocalArray($attribute, $lowerRule, $source = null)
false
Other
laravel
framework
69e09253ad45eb2b15646d6aaab4c4668bef1c6e.json
relax type hint
src/Illuminate/Http/Resources/Json/Resource.php
@@ -244,11 +244,11 @@ protected function whenLoaded($relationship) * Execute a callback if the given pivot table has been loaded. * * @param string $table - * @param callable $value + * @param mixed $value * @param mixed $default * @return \Illuminate\Http\Resources\MissingValue|mixed */ - protected function whenPivotLoaded($table, callable $value, $default = null) + protected function whenPivotLoaded($table, $value, $default = null) { return $this->when( $this->pivot && ($this->pivot instanceof $table || $this->pivot->getTable() === $table),
false
Other
laravel
framework
27e8438d7a781074a70bda7e4845716063ec56da.json
Apply fixes from StyleCI (#20764)
src/Illuminate/Routing/Middleware/ThrottleRequestsWithRedis.php
@@ -211,6 +211,6 @@ protected function tooManyAttempts($key, $maxAttempts, $decayMinutes) $this->remaining = $limiter->remaining; - return !$attempt; + return ! $attempt; } }
true
Other
laravel
framework
27e8438d7a781074a70bda7e4845716063ec56da.json
Apply fixes from StyleCI (#20764)
tests/Integration/Http/ThrottleRequestsTest.php
@@ -27,7 +27,7 @@ public function setup() public function test_lock_opens_immediately_after_decay() { Carbon::setTestNow(null); - + Route::get('/', function () { return 'yes'; })->middleware(ThrottleRequests::class.':2,1');
true
Other
laravel
framework
92aff02c1f023f333a4ad5e91955e67c8efbe32a.json
Apply fixes from StyleCI (#20763)
src/Illuminate/Http/Resources/MergeValue.php
@@ -23,5 +23,4 @@ public function __construct($data) { $this->data = $data instanceof Collection ? $data->all() : $data; } - }
false
Other
laravel
framework
8842846e815498f982e83ba44c370143522e0d37.json
Apply fixes from StyleCI (#20758)
tests/Integration/Http/ThrottleRequestsTest.php
@@ -44,9 +44,9 @@ public function test_lock_opens_immediately_after_decay() Carbon::now()->addSeconds(58) ); - try{ + try { $response = $this->withoutExceptionHandling()->get('/'); - }catch(\Throwable $e){ + } catch (\Throwable $e) { $this->assertEquals(429, $e->getStatusCode()); $this->assertEquals(2, $e->getHeaders()['X-RateLimit-Limit']); $this->assertEquals(0, $e->getHeaders()['X-RateLimit-Remaining']);
false
Other
laravel
framework
315baf73daac7fb005d2135f37dc4bbf96e1062c.json
Apply fixes from StyleCI (#20753)
src/Illuminate/View/Factory.php
@@ -153,7 +153,7 @@ public function first(array $views, $data = [], $mergeData = []) }); if (! $view) { - throw new InvalidArgumentException("None of the views in the given array exist."); + throw new InvalidArgumentException('None of the views in the given array exist.'); } return $this->make($view, $data, $mergeData);
false
Other
laravel
framework
4580cc9580162e9393081ee983cda18880a5e94b.json
add test_resources_may_have_no_wrap test (#20736)
tests/Integration/Http/ResourceTest.php
@@ -38,6 +38,25 @@ public function test_resources_may_be_converted_to_json() ]); } + public function test_resources_may_have_no_wrap() + { + Route::get('/', function () { + return new PostResourceWithoutWrap(new Post([ + 'id' => 5, + 'title' => 'Test Title', + ])); + }); + + $response = $this->withoutExceptionHandling()->get( + '/', ['Accept' => 'application/json'] + ); + + $response->assertJson([ + 'id' => 5, + 'title' => 'Test Title', + ]); + } + public function test_resources_may_have_optional_values() { Route::get('/', function () { @@ -387,6 +406,11 @@ public function withResponse($request, $response) } } +class PostResourceWithoutWrap extends PostResource +{ + public static $wrap = null; +} + class PostResourceWithOptionalData extends Resource { public function toArray($request)
false
Other
laravel
framework
8f209d59cdc7e3991bac712b7fcf36c1f0d63fce.json
Apply fixes from StyleCI (#20733)
src/Illuminate/Http/Resources/Json/Resource.php
@@ -6,8 +6,8 @@ use JsonSerializable; use Illuminate\Support\Collection; use Illuminate\Container\Container; -use Illuminate\Http\Resources\MissingValue; use Illuminate\Contracts\Support\Arrayable; +use Illuminate\Http\Resources\MissingValue; use Illuminate\Contracts\Routing\UrlRoutable; use Illuminate\Contracts\Support\Responsable; use Illuminate\Http\Resources\DelegatesToResource; @@ -123,7 +123,7 @@ protected function filter($data) } if ($value instanceof MissingValue || - ($value instanceof Resource && + ($value instanceof self && $value->resource instanceof MissingValue)) { unset($data[$key]); }
true
Other
laravel
framework
8f209d59cdc7e3991bac712b7fcf36c1f0d63fce.json
Apply fixes from StyleCI (#20733)
tests/Integration/Http/ResourceTest.php
@@ -428,7 +428,9 @@ public function toArray($request) } } -class Subscription {} +class Subscription +{ +} class CommentCollection extends ResourceCollection {
true
Other
laravel
framework
06de9b2beb9e3c13758d93cee86a1657545cb435.json
add various optional helpers
src/Illuminate/Http/Resources/Json/Resource.php
@@ -173,13 +173,13 @@ public function withResponse($request, $response) * @param mixed $value * @return \Illuminate\Http\Resources\MissingValue|mixed */ - protected function when($condition, $value) + protected function when($condition, $value, $default = null) { if ($condition) { return value($value); } - return new MissingValue; + return func_num_args() === 3 ? value($default) : new MissingValue; } /** @@ -188,7 +188,7 @@ protected function when($condition, $value) * @param string $relationship * @return \Illuminate\Http\Resources\MissingValue|mixed */ - protected function optional($relationship) + protected function whenLoaded($relationship) { if ($this->resource->relationLoaded($relationship)) { return $this->resource->{$relationship}; @@ -197,6 +197,37 @@ protected function optional($relationship) return new MissingValue; } + /** + * Execute a callback if the given pivot table has been loaded. + * + * @param string $table + * @param callable $value + * @param mixed $default + * @return \Illuminate\Http\Resources\MissingValue|mixed + */ + protected function whenPivotLoaded($table, callable $value, $default = null) + { + return $this->when( + $this->pivot && ($this->pivot instanceof $table || $this->pivot->getTable() === $table), + ...array_filter([$value, $default]) + ); + } + + /** + * Transform the given value if it is present. + * + * @param mixed $value + * @param callable $callback + * @param mixed $default + * @return mixed + */ + protected function transform($value, callable $callback, $default = null) + { + return transform( + $value, $callback, func_num_args() === 3 ? $default : new MissingValue + ); + } + /** * Set the string that should wrap the outer-most resource array. *
true
Other
laravel
framework
06de9b2beb9e3c13758d93cee86a1657545cb435.json
add various optional helpers
src/Illuminate/Support/Optional.php
@@ -0,0 +1,53 @@ +<?php + +namespace Illuminate\Support; + +class Optional +{ + use Traits\Macroable; + + /** + * The underlying object. + * + * @var mixed + */ + protected $value; + + /** + * Create a new optional instance. + * + * @param mixed $value + * @return void + */ + public function __construct($value) + { + $this->value = $value; + } + + /** + * Dynamically access a property on the underlying object. + * + * @param string $key + * @return mixed + */ + public function __get($key) + { + if (is_object($this->value)) { + return $this->value->{$key}; + } + } + + /** + * Dynamically pass a method to the underlying object. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public function __call($method, $parameters) + { + if (is_object($this->value)) { + return $this->value->{$method}(...$parameters); + } + } +}
true
Other
laravel
framework
06de9b2beb9e3c13758d93cee86a1657545cb435.json
add various optional helpers
src/Illuminate/Support/helpers.php
@@ -2,6 +2,7 @@ use Illuminate\Support\Arr; use Illuminate\Support\Str; +use Illuminate\Support\Optional; use Illuminate\Support\Collection; use Illuminate\Support\Debug\Dumper; use Illuminate\Contracts\Support\Htmlable; @@ -330,6 +331,37 @@ function array_wrap($value) } } +if (! function_exists('blank')) { + /** + * Determine if the given value is "blank". + * + * @author Derek MacDonald (https://github.com/derekmd) + * + * @param mixed $value + * @return bool + */ + function blank($value) + { + if (is_null($value)) { + return true; + } + + if (is_string($value)) { + return trim($value) === ''; + } + + if (is_numeric($value) || is_bool($value)) { + return false; + } + + if ($value instanceof Countable) { + return count($value) === 0; + } + + return empty($value); + } +} + if (! function_exists('camel_case')) { /** * Convert a value to camel case. @@ -667,6 +699,19 @@ function object_get($object, $key, $default = null) } } +if (! function_exists('optional')) { + /** + * Provide access to optional objects. + * + * @param mixed $value + * @return mixed + */ + function optional($value) + { + return new Optional($value); + } +} + if (! function_exists('preg_replace_array')) { /** * Replace a given pattern with each value in the array in sequentially. @@ -686,6 +731,21 @@ function preg_replace_array($pattern, array $replacements, $subject) } } +if (! function_exists('present')) { + /** + * Determine if a value is "present". + * + * @author Derek MacDonald (https://github.com/derekmd) + * + * @param mixed $value + * @return bool + */ + function present($value) + { + return ! blank($value); + } +} + if (! function_exists('retry')) { /** * Retry an operation a given number of times. @@ -1048,6 +1108,31 @@ function trait_uses_recursive($trait) } } +if (! function_exists('transform')) { + /** + * Transform the given value if it is present. + * + * @author Derek MacDonald (https://github.com/derekmd) + * + * @param mixed $value + * @param callable $callback + * @param mixed $default + * @return mixed|null + */ + function transform($value, callable $callback, $default = null) + { + if (present($value)) { + return $callback($value); + } + + if (is_callable($default)) { + return $default($value); + } + + return $default; + } +} + if (! function_exists('value')) { /** * Return the default value of the given value.
true
Other
laravel
framework
06de9b2beb9e3c13758d93cee86a1657545cb435.json
add various optional helpers
tests/Integration/Http/ResourceTest.php
@@ -38,6 +38,29 @@ public function test_resources_may_be_converted_to_json() ]); } + public function test_resources_may_have_optional_values() + { + Route::get('/', function () { + return new PostResourceWithOptionalData(new Post([ + 'id' => 5, + ])); + }); + + $response = $this->withoutExceptionHandling()->get( + '/', ['Accept' => 'application/json'] + ); + + $response->assertStatus(200); + + $response->assertJson([ + 'data' => [ + 'id' => 5, + 'second' => 'value', + 'third' => 'value', + ], + ]); + } + public function test_resources_may_have_optional_relationships() { Route::get('/', function () { @@ -60,6 +83,31 @@ public function test_resources_may_have_optional_relationships() ]); } + public function test_resources_may_have_optional_pivot_relationships() + { + Route::get('/', function () { + $post = new Post(['id' => 5]); + $post->setRelation('pivot', new Subscription); + + return new PostResourceWithOptionalPivotRelationship($post); + }); + + $response = $this->withoutExceptionHandling()->get( + '/', ['Accept' => 'application/json'] + ); + + $response->assertStatus(200); + + $response->assertExactJson([ + 'data' => [ + 'id' => 5, + 'subscription' => [ + 'foo' => 'bar', + ], + ], + ]); + } + public function test_resource_is_url_routable() { $post = new PostResource(new Post([ @@ -339,17 +387,49 @@ public function withResponse($request, $response) } } +class PostResourceWithOptionalData extends Resource +{ + public function toArray($request) + { + return [ + 'id' => $this->id, + 'first' => $this->when(false, 'value'), + 'second' => $this->when(true, 'value'), + 'third' => $this->when(true, function () { + return 'value'; + }), + ]; + } +} + class PostResourceWithOptionalRelationship extends PostResource { public function toArray($request) { return [ 'id' => $this->id, - 'comments' => new CommentCollection($this->optional('comments')), + 'comments' => new CommentCollection($this->whenLoaded('comments')), + ]; + } +} + +class PostResourceWithOptionalPivotRelationship extends PostResource +{ + public function toArray($request) + { + return [ + 'id' => $this->id, + 'subscription' => $this->whenPivotLoaded(Subscription::class, function () { + return [ + 'foo' => 'bar', + ]; + }), ]; } } +class Subscription {} + class CommentCollection extends ResourceCollection { //
true
Other
laravel
framework
06de9b2beb9e3c13758d93cee86a1657545cb435.json
add various optional helpers
tests/Support/SupportHelpersTest.php
@@ -755,6 +755,29 @@ public function testThrowWithString() { throw_if(true, RuntimeException::class, 'Test Message'); } + + public function testOptional() + { + $this->assertNull(optional(null)->something()); + + $this->assertEquals(10, optional(new class { + public function something() + { + return 10; + } + })->something()); + } + + public function testTransform() + { + $this->assertEquals(10, transform(5, function ($value) { + return $value * 2; + })); + + $this->assertNull(transform(null, function () { + return 10; + })); + } } trait SupportTestTraitOne
true
Other
laravel
framework
a64407c9f37c2a927a39dd8a2cb0ab5a09d5f567.json
Apply fixes from StyleCI (#20730)
src/Illuminate/Http/Resources/Json/Resource.php
@@ -122,7 +122,7 @@ protected function filter($data) continue; } - if ($value instanceof Resource && + if ($value instanceof self && $value->resource instanceof MissingResource) { unset($data[$key]); } @@ -177,7 +177,7 @@ public function optional($relationship) return $this->resource->{$relationship}; } - return new MissingResource;; + return new MissingResource; } /**
false
Other
laravel
framework
a07d028d732780249539dc6c33396dafc3bfa173.json
remove merge method
src/Illuminate/Http/Resources/Json/Resource.php
@@ -115,19 +115,6 @@ public function toArray($request) return $this->resource->toArray(); } - /** - * Merge additional data into the resource array. - * - * @param array $data - * @return $this - */ - public function merge(array $data) - { - $this->with = $data; - - return $this; - } - /** * Get any additional data that should be returned with the resource array. *
true
Other
laravel
framework
a07d028d732780249539dc6c33396dafc3bfa173.json
remove merge method
tests/Integration/Http/ResourceTest.php
@@ -125,28 +125,6 @@ public function test_resources_may_customize_extra_data() ]); } - public function test_resources_may_customize_adhoc_extra_data() - { - Route::get('/', function () { - return PostResource::make(new Post([ - 'id' => 5, - 'title' => 'Test Title', - ]))->merge(['foo' => 'bar']); - }); - - $response = $this->withoutExceptionHandling()->get( - '/', ['Accept' => 'application/json'] - ); - - $response->assertJson([ - 'data' => [ - 'id' => 5, - 'title' => 'Test Title', - ], - 'foo' => 'bar', - ]); - } - public function test_custom_headers_may_be_set_on_responses() { Route::get('/', function () {
true
Other
laravel
framework
1e717ace337b4e0257b3ff74b62dc2a6fc45d72a.json
Apply fixes from StyleCI (#20712)
src/Illuminate/Database/Eloquent/DetectsResource.php
@@ -51,7 +51,7 @@ public function detectResourceName($suffix = '') } throw new Exception( - "Unable to detect the resource for the [".get_class($this)."] model." + 'Unable to detect the resource for the ['.get_class($this).'] model.' ); } }
true
Other
laravel
framework
1e717ace337b4e0257b3ff74b62dc2a6fc45d72a.json
Apply fixes from StyleCI (#20712)
src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php
@@ -37,9 +37,9 @@ use Illuminate\Foundation\Console\StorageLinkCommand; use Illuminate\Routing\Console\ControllerMakeCommand; use Illuminate\Routing\Console\MiddlewareMakeCommand; -use Illuminate\Foundation\Console\ResourceMakeCommand; use Illuminate\Foundation\Console\ListenerMakeCommand; use Illuminate\Foundation\Console\ProviderMakeCommand; +use Illuminate\Foundation\Console\ResourceMakeCommand; use Illuminate\Foundation\Console\ClearCompiledCommand; use Illuminate\Foundation\Console\EventGenerateCommand; use Illuminate\Foundation\Console\VendorPublishCommand;
true
Other
laravel
framework
1e717ace337b4e0257b3ff74b62dc2a6fc45d72a.json
Apply fixes from StyleCI (#20712)
src/Illuminate/Http/Resources/CollectsResources.php
@@ -4,9 +4,7 @@ use Illuminate\Support\Str; use Illuminate\Support\Collection; -use Illuminate\Database\Eloquent\Model; use Illuminate\Pagination\AbstractPaginator; -use Illuminate\Database\Eloquent\Collection as EloquentCollection; trait CollectsResources {
true
Other
laravel
framework
1e717ace337b4e0257b3ff74b62dc2a6fc45d72a.json
Apply fixes from StyleCI (#20712)
src/Illuminate/Http/Resources/DelegatesToResource.php
@@ -34,7 +34,7 @@ public function getRouteKeyName() */ public function resolveRouteBinding($value) { - throw new Exception("Resources may not be implicitly resolved from route bindings."); + throw new Exception('Resources may not be implicitly resolved from route bindings.'); } /**
true
Other
laravel
framework
1e717ace337b4e0257b3ff74b62dc2a6fc45d72a.json
Apply fixes from StyleCI (#20712)
src/Illuminate/Http/Resources/Json/ResourceCollection.php
@@ -6,7 +6,6 @@ use Illuminate\Support\Collection; use Illuminate\Pagination\AbstractPaginator; use Illuminate\Http\Resources\CollectsResources; -use Illuminate\Database\Eloquent\Collection as EloquentCollection; class ResourceCollection extends Resource implements IteratorAggregate {
true
Other
laravel
framework
1e717ace337b4e0257b3ff74b62dc2a6fc45d72a.json
Apply fixes from StyleCI (#20712)
tests/Integration/Http/ResourceTest.php
@@ -7,8 +7,6 @@ use Illuminate\Support\Facades\Route; use Illuminate\Database\Eloquent\Model; use Illuminate\Http\Resources\Json\Resource; -use Illuminate\Database\Eloquent\Collection; -use Illuminate\Contracts\Support\Responsable; use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Http\Resources\Json\ResourceCollection; @@ -36,7 +34,7 @@ public function test_resources_may_be_converted_to_json() 'data' => [ 'id' => 5, 'title' => 'Test Title', - ] + ], ]); } @@ -84,7 +82,7 @@ public function test_resources_may_be_serializable() $response->assertJson([ 'data' => [ 'id' => 5, - ] + ], ]); } @@ -313,7 +311,7 @@ public function test_to_json_may_be_left_off_of_single_resource() 'data' => [ 'id' => 5, 'title' => 'Test Title', - ] + ], ]); } } @@ -328,7 +326,6 @@ class Post extends Model protected $guarded = []; } - class PostResource extends Resource { public function toArray($request) @@ -358,7 +355,6 @@ public function toArray($request) } } - class PostCollectionResource extends ResourceCollection { public $collects = PostResource::class;
true
Other
laravel
framework
60860f3fdb277154606a1f3584104ed97d24d16a.json
Use Support\Carbon. (#20693)
src/Illuminate/Foundation/helpers.php
@@ -1,6 +1,6 @@ <?php -use Carbon\Carbon; +use Illuminate\Support\Carbon; use Illuminate\Support\HtmlString; use Illuminate\Container\Container; use Illuminate\Contracts\Bus\Dispatcher; @@ -586,7 +586,7 @@ function mix($path, $manifestDirectory = '') /** * Create a new Carbon instance for the current time. * - * @return \Carbon\Carbon + * @return \Illuminate\Support\Carbon */ function now() { @@ -823,7 +823,7 @@ function storage_path($path = '') /** * Create a new Carbon instance for the current date. * - * @return \Carbon\Carbon + * @return \Illuminate\Support\Carbon */ function today() {
false
Other
laravel
framework
5dcf584865cceef9f9690673d6a6bd6241e3834a.json
Add View::either method
src/Illuminate/View/Factory.php
@@ -244,6 +244,23 @@ public function exists($view) return true; } + /** + * Get the evaluated view contents for the given view, or for a fallback + * view if the given view doesn't exist. + * + * @param string $view + * @param string $fallback + * @param array $data + * @param array $mergeData + * @return \Illuminate\Contracts\View\View + */ + public function either($view, $fallback, $data = [], $mergeData = []) + { + $view = $this->exists($view) ? $view : $fallback; + + return $this->make($view, $data, $mergeData); + } + /** * Get the appropriate view engine for the given path. *
true
Other
laravel
framework
5dcf584865cceef9f9690673d6a6bd6241e3834a.json
Add View::either method
tests/View/ViewFactoryTest.php
@@ -45,6 +45,28 @@ public function testExistsPassesAndFailsViews() $this->assertTrue($factory->exists('bar')); } + public function testEitherCreatesNewViewInstanceWithProperPath() + { + unset($_SERVER['__test.view']); + + $factory = $this->getFactory(); + $factory->getFinder()->shouldReceive('find')->once()->with('view')->andReturn('path.php'); + $factory->getFinder()->shouldReceive('find')->once()->with('bar')->andThrow('InvalidArgumentException'); + $factory->getEngineResolver()->shouldReceive('resolve')->once()->with('php')->andReturn($engine = m::mock(\Illuminate\Contracts\View\Engine::class)); + $factory->getFinder()->shouldReceive('addExtension')->once()->with('php'); + $factory->setDispatcher(new \Illuminate\Events\Dispatcher); + $factory->creator('view', function ($view) { + $_SERVER['__test.view'] = $view; + }); + $factory->addExtension('php', 'php'); + $view = $factory->either('bar', 'view', ['foo' => 'bar'], ['baz' => 'boom']); + + $this->assertSame($engine, $view->getEngine()); + $this->assertSame($_SERVER['__test.view'], $view); + + unset($_SERVER['__test.view']); + } + public function testRenderEachCreatesViewForEachItemInArray() { $factory = m::mock('Illuminate\View\Factory[make]', $this->getFactoryArgs());
true
Other
laravel
framework
ef11aee425a0973b2ccef485eb579802fd7d45f9.json
Add orDoesntHave and orWhereDoesntHave (#20685)
src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php
@@ -107,6 +107,17 @@ public function doesntHave($relation, $boolean = 'and', Closure $callback = null return $this->has($relation, '<', 1, $boolean, $callback); } + /** + * Add a relationship count / exists condition to the query with an "or". + * + * @param string $relation + * @return \Illuminate\Database\Eloquent\Builder|static + */ + public function orDoesntHave($relation) + { + return $this->doesntHave($relation, 'or'); + } + /** * Add a relationship count / exists condition to the query with where clauses. * @@ -147,6 +158,18 @@ public function whereDoesntHave($relation, Closure $callback = null) return $this->doesntHave($relation, 'and', $callback); } + /** + * Add a relationship count / exists condition to the query with where clauses and an "or". + * + * @param string $relation + * @param \Closure $callback + * @return \Illuminate\Database\Eloquent\Builder|static + */ + public function orWhereDoesntHave($relation, Closure $callback = null) + { + return $this->doesntHave($relation, 'or', $callback); + } + /** * Add subselect queries to count the relations. *
true
Other
laravel
framework
ef11aee425a0973b2ccef485eb579802fd7d45f9.json
Add orDoesntHave and orWhereDoesntHave (#20685)
tests/Database/DatabaseEloquentBuilderTest.php
@@ -832,6 +832,49 @@ public function testSelfHasNestedUsesAlias() $this->assertContains('"self_alias_hash"."id" = "self_related_stubs"."parent_id"', $sql); } + public function testDoesntHave() + { + $model = new EloquentBuilderTestModelParentStub; + + $builder = $model->doesntHave('foo'); + + $this->assertEquals('select * from "eloquent_builder_test_model_parent_stubs" where not exists (select * 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")', $builder->toSql()); + } + + public function testOrDoesntHave() + { + $model = new EloquentBuilderTestModelParentStub; + + $builder = $model->where('bar', 'baz')->orDoesntHave('foo'); + + $this->assertEquals('select * from "eloquent_builder_test_model_parent_stubs" where "bar" = ? or not exists (select * 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")', $builder->toSql()); + $this->assertEquals(['baz'], $builder->getBindings()); + } + + public function testWhereDoesntHave() + { + $model = new EloquentBuilderTestModelParentStub; + + $builder = $model->whereDoesntHave('foo', function ($query) { + $query->where('bar', 'baz'); + }); + + $this->assertEquals('select * from "eloquent_builder_test_model_parent_stubs" where not exists (select * 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" and "bar" = ?)', $builder->toSql()); + $this->assertEquals(['baz'], $builder->getBindings()); + } + + public function testOrWhereDoesntHave() + { + $model = new EloquentBuilderTestModelParentStub; + + $builder = $model->where('bar', 'baz')->orWhereDoesntHave('foo', function ($query) { + $query->where('qux', 'quux'); + }); + + $this->assertEquals('select * from "eloquent_builder_test_model_parent_stubs" where "bar" = ? or not exists (select * 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" and "qux" = ?)', $builder->toSql()); + $this->assertEquals(['baz', 'quux'], $builder->getBindings()); + } + public function testWhereKeyMethodWithInt() { $model = $this->getMockModel();
true
Other
laravel
framework
f90f5e25b665336fef3a91e219b0ce73c139ab9e.json
Fix whoops version (#20681) * fix whoops version * update version
composer.json
@@ -74,7 +74,7 @@ "require-dev": { "aws/aws-sdk-php": "~3.0", "doctrine/dbal": "~2.5", - "filp/whoops": "~2.0", + "filp/whoops": "^2.1.4", "mockery/mockery": "~0.9.4", "orchestra/testbench-core": "3.5.*", "pda/pheanstalk": "~3.0",
false
Other
laravel
framework
0684c9c7c3f4312e0290c2b179f3a30719e81892.json
update v5.4 changelog
CHANGELOG-5.4.md
@@ -1,5 +1,18 @@ # Release Notes for 5.4.x +## [Unreleased] + +### Added +- Added `Str::start()` and `str_start()` helper ([#20569](https://github.com/laravel/framework/pull/20569)) + +### Changed +- Return the model instance from `Model::refresh()` ([#20657](https://github.com/laravel/framework/pull/20657)) + +### Fixed +- Fix duplicate user model import in `make:policy` ([#20645](https://github.com/laravel/framework/pull/20645), [48f5f23](https://github.com/laravel/framework/commit/48f5f23fd8615f48f2aee27a301c1f2f1505bdfb)) +- Fix PHP 7.2 incompatibility in `Builder::mergeWheres()` ([#20635](https://github.com/laravel/framework/pull/20635)) + + ## v5.4.33 (2017-08-14) ### Added
false
Other
laravel
framework
6b692b327d667610ed22265c8de8291551e2d749.json
update v5.5 changelog (fix)
CHANGELOG-5.5.md
@@ -130,7 +130,6 @@ - ⚠️ Call `setConnection()` in `Model::save()` ([#20466](https://github.com/laravel/framework/pull/20466)) - ⚠️ Touch parent timestamp only if the model is dirty ([#20489](https://github.com/laravel/framework/pull/20489)) - Added `Model::loadMissing()` method ([#20630](https://github.com/laravel/framework/pull/20630), [4166c12](https://github.com/laravel/framework/commit/4166c12492ce7b1112911299caf4cdb17efc9364)) -- Return the model instance from `Model::refresh()` ([#20657](https://github.com/laravel/framework/pull/20657)) ### Encryption - Use `openssl_cipher_iv_length()` in `Encrypter` ([#18684](https://github.com/laravel/framework/pull/18684))
false
Other
laravel
framework
9352d1edc22747417209adb4c314b7ec81120b4c.json
Apply fixes from StyleCI (#20662)
tests/Support/SupportTestingNotificationFakeTest.php
@@ -4,8 +4,8 @@ use PHPUnit\Framework\TestCase; use Illuminate\Foundation\Auth\User; -use Illuminate\Support\Testing\Fakes\NotificationFake; use Illuminate\Notifications\Notification; +use Illuminate\Support\Testing\Fakes\NotificationFake; class NotificationFakeTest extends TestCase { @@ -54,5 +54,4 @@ public function via($notifiable) class UserStub extends User { - }
false
Other
laravel
framework
331850ecb54c140358cba5f5e9141e830491812c.json
add assertNothingPushed method to QueueFake
src/Illuminate/Support/Testing/Fakes/QueueFake.php
@@ -83,6 +83,16 @@ public function assertNotPushed($job, $callback = null) ); } + /** + * Assert that no jobs were pushed. + * + * @return void + */ + public function assertNothingPushed() + { + PHPUnit::assertEmpty($this->jobs, 'Jobs were pushed unexpectedly.'); + } + /** * Get all of the jobs matching a truth-test callback. *
true
Other
laravel
framework
331850ecb54c140358cba5f5e9141e830491812c.json
add assertNothingPushed method to QueueFake
tests/Support/SupportTestingQueueFakeTest.php
@@ -67,6 +67,19 @@ public function testAssertPushedTimes() $this->fake->assertPushed(JobStub::class, 2); } + + /** + * @expectedException PHPUnit\Framework\ExpectationFailedException + * @expectedExceptionMessage Jobs were pushed unexpectedly. + */ + public function testAssertNothingPushed() + { + $this->fake->assertNothingPushed(); + + $this->fake->push($this->job); + + $this->fake->assertNothingPushed(); + } } class JobStub
true
Other
laravel
framework
f3a556927621bd745a6ca90e3a22063971c3d8c1.json
Apply fixes from StyleCI (#20644)
src/Illuminate/Routing/ImplicitRouteBinding.php
@@ -3,7 +3,6 @@ namespace Illuminate\Routing; use Illuminate\Support\Str; -use Illuminate\Database\Eloquent\Model; use Illuminate\Contracts\Routing\UrlRoutable; use Illuminate\Database\Eloquent\ModelNotFoundException;
false
Other
laravel
framework
774e5cf990caee75cec678b655d009f811d92ed6.json
Fix exception in tests (#20623)
tests/Database/DatabaseEloquentBuilderTest.php
@@ -475,7 +475,6 @@ public function testGetRelationProperlySetsNestedRelationshipsWithSimilarNames() /** * @expectedException \Illuminate\Database\Eloquent\RelationNotFoundException - * @expectedExceptionMessage Call to undefined relationship [invalid] on model [Mockery_18_Illuminate_Database_Eloquent_Model]. */ public function testGetRelationThrowsException() {
false
Other
laravel
framework
1e2dbe02b40aaf94c2dd776f2530213ab2084ccc.json
Add Request::keys method (#20611)
src/Illuminate/Http/Concerns/InteractsWithInput.php
@@ -165,6 +165,16 @@ public function all($keys = null) return $results; } + /** + * Get the keys for all input and files for the request. + * + * @return array + */ + public function keys() + { + return array_merge(array_keys($this->input()), $this->files->keys()); + } + /** * Retrieve an input item from the request. *
true
Other
laravel
framework
1e2dbe02b40aaf94c2dd776f2530213ab2084ccc.json
Add Request::keys method (#20611)
tests/Http/HttpRequestTest.php
@@ -308,6 +308,27 @@ public function testAllMethod() $this->assertEquals(['developer' => ['name' => 'Taylor', 'age' => null]], $request->all()); } + public function testKeysMethod() + { + $request = Request::create('/', 'GET', ['name' => 'Taylor', 'age' => null]); + $this->assertEquals(['name', 'age'], $request->keys()); + + $files = [ + 'foo' => [ + 'size' => 500, + 'name' => 'foo.jpg', + 'tmp_name' => __FILE__, + 'type' => 'blah', + 'error' => null, + ], + ]; + $request = Request::create('/', 'GET', [], [], $files); + $this->assertEquals(['foo'], $request->keys()); + + $request = Request::create('/', 'GET', ['name' => 'Taylor'], [], $files); + $this->assertEquals(['name', 'foo'], $request->keys()); + } + public function testOnlyMethod() { $request = Request::create('/', 'GET', ['name' => 'Taylor', 'age' => null]);
true
Other
laravel
framework
28107d2f40eb5d2baa88af89e065ea211c312f19.json
add withHeader method
src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php
@@ -77,6 +77,20 @@ public function withHeaders(array $headers) return $this; } + /** + * Adds a header to be sent with the requests. + * + * @param string $name + * @param string $value + * @return $this + */ + public function withHeader(string $name, string $value) + { + $this->defaultHeaders[$name] = $value; + + return $this; + } + /** * Removes all the predefined headers to be sent with the requests. *
false
Other
laravel
framework
76cb5505845665a93816f05df980fc4a6533212c.json
make methods protected (#20582) + fix some docblocks
src/Illuminate/Foundation/Console/PresetCommand.php
@@ -55,7 +55,7 @@ protected function none() } /** - * Install the "fresh" preset. + * Install the "bootstrap" preset. * * @return void */ @@ -72,7 +72,7 @@ protected function bootstrap() * * @return void */ - public function vue() + protected function vue() { Presets\Vue::install(); @@ -85,7 +85,7 @@ public function vue() * * @return void */ - public function react() + protected function react() { Presets\React::install();
false
Other
laravel
framework
9ab8919723f8ec13813278d4d7b77170e3894392.json
Use Support Carbon (#20568)
src/Illuminate/Foundation/Testing/TestCase.php
@@ -3,7 +3,7 @@ namespace Illuminate\Foundation\Testing; use Mockery; -use Carbon\Carbon; +use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Facade; use Illuminate\Database\Eloquent\Model; use Illuminate\Console\Application as Artisan;
true
Other
laravel
framework
9ab8919723f8ec13813278d4d7b77170e3894392.json
Use Support Carbon (#20568)
tests/Integration/Database/EloquentBelongsToManyTest.php
@@ -2,7 +2,7 @@ namespace Illuminate\Tests\Integration\Database\EloquentBelongsToManyTest; -use Carbon\Carbon; +use Illuminate\Support\Carbon; use Orchestra\Testbench\TestCase; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema;
true
Other
laravel
framework
9ab8919723f8ec13813278d4d7b77170e3894392.json
Use Support Carbon (#20568)
tests/Support/SupportArrTest.php
@@ -4,8 +4,8 @@ use stdClass; use ArrayObject; -use Carbon\Carbon; use Illuminate\Support\Arr; +use Illuminate\Support\Carbon; use PHPUnit\Framework\TestCase; use Illuminate\Support\Collection;
true
Other
laravel
framework
87a29a2fa2d7a3df8594d0b45ebe3f6093fb8a09.json
Update Builder.php (#20553)
src/Illuminate/Database/Query/Builder.php
@@ -561,12 +561,12 @@ public function where($column, $operator = null, $value = null, $boolean = 'and' */ protected function addArrayOfWheres($column, $boolean, $method = 'where') { - return $this->whereNested(function ($query) use ($column, $method) { + return $this->whereNested(function ($query) use ($column, $method, $boolean) { foreach ($column as $key => $value) { if (is_numeric($key) && is_array($value)) { $query->{$method}(...array_values($value)); } else { - $query->$method($key, '=', $value); + $query->$method($key, '=', $value, $boolean); } } }, $boolean);
false
Other
laravel
framework
e6995b8a07985c4eb116624c13ccb10eb12e3c58.json
accept string (#20529)
src/Illuminate/Routing/PendingResourceRegistration.php
@@ -78,10 +78,10 @@ public function except($methods) /** * Set the route names for controller actions. * - * @param array $names + * @param array|string $names * @return \Illuminate\Routing\PendingResourceRegistration */ - public function names(array $names) + public function names($names) { $this->options['names'] = $names;
true
Other
laravel
framework
e6995b8a07985c4eb116624c13ccb10eb12e3c58.json
accept string (#20529)
tests/Routing/RouteRegistrarTest.php
@@ -223,6 +223,9 @@ public function testUserCanRegisterApiResource() public function testCanNameRoutesOnRegisteredResource() { + $this->router->resource('comments', 'Illuminate\Tests\Routing\RouteRegistrarControllerStub') + ->only('create', 'store')->names('reply'); + $this->router->resource('users', 'Illuminate\Tests\Routing\RouteRegistrarControllerStub') ->only('create', 'store')->names([ 'create' => 'user.build', @@ -234,6 +237,8 @@ public function testCanNameRoutesOnRegisteredResource() ->name('create', 'posts.make') ->name('destroy', 'posts.remove'); + $this->assertTrue($this->router->getRoutes()->hasNamedRoute('reply.create')); + $this->assertTrue($this->router->getRoutes()->hasNamedRoute('reply.store')); $this->assertTrue($this->router->getRoutes()->hasNamedRoute('user.build')); $this->assertTrue($this->router->getRoutes()->hasNamedRoute('user.save')); $this->assertTrue($this->router->getRoutes()->hasNamedRoute('posts.make'));
true
Other
laravel
framework
e44933af48548502f79d6b8049824205fa229b91.json
allow string for parameters (#20531)
src/Illuminate/Routing/PendingResourceRegistration.php
@@ -105,10 +105,10 @@ public function name($method, $name) /** * Override the route parameter names. * - * @param array $parameters + * @param array|string $parameters * @return \Illuminate\Routing\PendingResourceRegistration */ - public function parameters(array $parameters) + public function parameters($parameters) { $this->options['parameters'] = $parameters;
true
Other
laravel
framework
e44933af48548502f79d6b8049824205fa229b91.json
allow string for parameters (#20531)
tests/Routing/RoutingRouteTest.php
@@ -1118,7 +1118,7 @@ public function testResourceRoutingParameters() $router = $this->getRouter(); $router->resource('foos', 'FooController', ['parameters' => 'singular']); - $router->resource('foos.bars', 'FooController', ['parameters' => 'singular']); + $router->resource('foos.bars', 'FooController')->parameters('singular'); $routes = $router->getRoutes(); $routes = $routes->getRoutes(); @@ -1131,6 +1131,13 @@ public function testResourceRoutingParameters() $routes = $routes->getRoutes(); $this->assertEquals('foos/{foo}/bars/{bar}', $routes[3]->uri()); + + $router = $this->getRouter(); + $router->resource('foos.bars', 'FooController')->parameter('foos', 'foo')->parameter('bars', 'bar'); + $routes = $router->getRoutes(); + $routes = $routes->getRoutes(); + + $this->assertEquals('foos/{foo}/bars/{bar}', $routes[3]->uri()); } public function testResourceRouteNaming()
true
Other
laravel
framework
7f887c2fa74ae67887fbc9beb93d5ad0818b2dae.json
Apply fixes from StyleCI (#20533)
tests/Support/SupportTestingMailFakeTest.php
@@ -74,7 +74,6 @@ public function testAssertNothingSent() } } - class MailableStub extends Mailable { public $framework = 'Laravel';
false
Other
laravel
framework
94e8cb36af27c4e85b5e30cd0501b8448ed34909.json
Apply fixes from StyleCI (#20526)
src/Illuminate/Contracts/Queue/Job.php
@@ -99,10 +99,10 @@ public function getConnectionName(); */ public function getQueue(); - /** - * Get the raw body string for the job. - * - * @return string - */ - public function getRawBody(); + /** + * Get the raw body string for the job. + * + * @return string + */ + public function getRawBody(); }
true
Other
laravel
framework
94e8cb36af27c4e85b5e30cd0501b8448ed34909.json
Apply fixes from StyleCI (#20526)
src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php
@@ -679,9 +679,9 @@ protected function asDateTime($value) return $value; } - // If the value is already a DateTime instance, we will just skip the rest of - // these checks since they will be a waste of time, and hinder performance - // when checking the field. We will just return the DateTime right away. + // If the value is already a DateTime instance, we will just skip the rest of + // these checks since they will be a waste of time, and hinder performance + // when checking the field. We will just return the DateTime right away. if ($value instanceof DateTimeInterface) { return new Carbon( $value->format('Y-m-d H:i:s.u'), $value->getTimezone()
true
Other
laravel
framework
94e8cb36af27c4e85b5e30cd0501b8448ed34909.json
Apply fixes from StyleCI (#20526)
src/Illuminate/Routing/MiddlewareNameResolver.php
@@ -24,15 +24,15 @@ public static function resolve($name, $map, $middlewareGroups) } elseif (isset($map[$name]) && $map[$name] instanceof Closure) { return $map[$name]; - // If the middleware is the name of a middleware group, we will return the array + // If the middleware is the name of a middleware group, we will return the array // of middlewares that belong to the group. This allows developers to group a // set of middleware under single keys that can be conveniently referenced. } elseif (isset($middlewareGroups[$name])) { return static::parseMiddlewareGroup( $name, $map, $middlewareGroups ); - // Finally, when the middleware is simply a string mapped to a class name the + // Finally, when the middleware is simply a string mapped to a class name the // middleware name will get parsed into the full class name and parameters // which may be run using the Pipeline which accepts this string format. } else {
true
Other
laravel
framework
94e8cb36af27c4e85b5e30cd0501b8448ed34909.json
Apply fixes from StyleCI (#20526)
src/Illuminate/Routing/SortedMiddleware.php
@@ -55,7 +55,7 @@ protected function sortMiddleware($priorityMap, $middlewares) ) ); - // This middleware is in the priority map; but, this is the first middleware we have + // This middleware is in the priority map; but, this is the first middleware we have // encountered from the map thus far. We'll save its current index plus its index // from the priority map so we can compare against them on the next iterations. } else {
true
Other
laravel
framework
15c81645788be437fd7079e50e97e90b7972fd40.json
Apply fixes from StyleCI (#20518)
src/Illuminate/Routing/Route.php
@@ -212,9 +212,9 @@ protected function runController() */ public function getController() { - if (! $this->controller) { + if (! $this->controller) { $class = $this->parseControllerCallback()[0]; - + $this->controller = $this->container->make($class); }
false
Other
laravel
framework
26903b7781664748d3fa8f273d010d9d4ef38953.json
Remove unnecessary parsing (#20517) * Execute only one time the Controller computing class. * Remove empty line * Update Route.php
src/Illuminate/Routing/Route.php
@@ -212,9 +212,9 @@ protected function runController() */ public function getController() { - $class = $this->parseControllerCallback()[0]; - - if (! $this->controller) { + if (! $this->controller) { + $class = $this->parseControllerCallback()[0]; + $this->controller = $this->container->make($class); }
false
Other
laravel
framework
be7f51ac647af34d75fb857ee683dc3374292373.json
Apply fixes from StyleCI (#20514)
src/Illuminate/Support/Collection.php
@@ -10,7 +10,6 @@ use CachingIterator; use JsonSerializable; use IteratorAggregate; -use InvalidArgumentException; use Illuminate\Support\Debug\Dumper; use Illuminate\Support\Traits\Macroable; use Illuminate\Contracts\Support\Jsonable;
false
Other
laravel
framework
a4c781ac40695051b2559d127e3d7595dcc5f904.json
remove stupid test
CHANGELOG-5.4.md
@@ -1,5 +1,32 @@ # Release Notes for 5.4.x +## [Unreleased] + +### Changed +- Moved `tap()` method from `Builder` to `BuildsQueries` ([#20384](https://github.com/laravel/framework/pull/20384)) +- Made Blade `or` operator case-insensitive ([#20425](https://github.com/laravel/framework/pull/20425)) +- Support `$amount = 0` in `Arr::random()` ([#20439](https://github.com/laravel/framework/pull/20439)) + +### Fixed +- Fixed bug when using empty values in `SQLiteGrammar::compileInsert()` ([#20424](https://github.com/laravel/framework/pull/20424)) + + +## v5.4.32 (2017-08-03) + +### Added +- Added `FilesystemAdapter::path()` method ([#20395](https://github.com/laravel/framework/pull/20395)) + +### Changed +- Allow `Collection::random()` to return `0` items ([#20396](https://github.com/laravel/framework/pull/20396), [#20402](https://github.com/laravel/framework/pull/20402)) +- Accept options on `FilesystemAdapter::temporaryUrl()` ([#20394](https://github.com/laravel/framework/pull/20394)) +- Sync `withoutOverlapping` method on `Event` and `CallbackEvent` ([#20389](https://github.com/laravel/framework/pull/20389)) +- Prevent PHP file uploads by default unless explicitly allowed ([#20392](https://github.com/laravel/framework/pull/20392), [#20400](https://github.com/laravel/framework/pull/20400)) +- Allow other filesystem adapter to implement `temporaryUrl()` ([#20398](https://github.com/laravel/framework/pull/20398)) + +### Fixed +- Reverted breaking change on `BelongsToMany::create()` ([#20407](https://github.com/laravel/framework/pull/20407)) + + ## v5.4.31 (2017-08-02) ### Added
true
Other
laravel
framework
a4c781ac40695051b2559d127e3d7595dcc5f904.json
remove stupid test
src/Illuminate/Database/Concerns/BuildsQueries.php
@@ -96,6 +96,17 @@ public function when($value, $callback, $default = null) return $this; } + /** + * Pass the query to a given callback. + * + * @param \Closure $callback + * @return \Illuminate\Database\Query\Builder + */ + public function tap($callback) + { + return $this->when(true, $callback); + } + /** * Apply the callback's query changes if the given "value" is false. *
true
Other
laravel
framework
a4c781ac40695051b2559d127e3d7595dcc5f904.json
remove stupid test
src/Illuminate/Database/Eloquent/Builder.php
@@ -217,7 +217,7 @@ public function where($column, $operator = null, $value = null, $boolean = 'and' /** * Add an "or where" clause to the query. * - * @param \Closure|string $column + * @param \Closure|array|string $column * @param string $operator * @param mixed $value * @return \Illuminate\Database\Eloquent\Builder|static
true
Other
laravel
framework
a4c781ac40695051b2559d127e3d7595dcc5f904.json
remove stupid test
src/Illuminate/Database/Migrations/Migrator.php
@@ -245,6 +245,8 @@ protected function rollbackMigrations(array $migrations, $paths, array $options) $migration = (object) $migration; if (! $file = Arr::get($files, $migration->migration)) { + $this->note("<fg=red>Migration not found:</> {$migration->migration}"); + continue; }
true
Other
laravel
framework
a4c781ac40695051b2559d127e3d7595dcc5f904.json
remove stupid test
src/Illuminate/Database/Query/Builder.php
@@ -459,17 +459,6 @@ public function crossJoin($table, $first = null, $operator = null, $second = nul return $this; } - /** - * Pass the query to a given callback. - * - * @param \Closure $callback - * @return \Illuminate\Database\Query\Builder - */ - public function tap($callback) - { - return $this->when(true, $callback); - } - /** * Merge an array of where clauses and bindings. *
true
Other
laravel
framework
a4c781ac40695051b2559d127e3d7595dcc5f904.json
remove stupid test
src/Illuminate/Database/Query/Grammars/SQLiteGrammar.php
@@ -153,7 +153,9 @@ public function compileInsert(Builder $query, array $values) // grammar insert builder because no special syntax is needed for the single // row inserts in SQLite. However, if there are multiples, we'll continue. if (count($values) == 1) { - return parent::compileInsert($query, reset($values)); + return empty(reset($values)) + ? "insert into $table default values" + : parent::compileInsert($query, reset($values)); } $names = $this->columnize(array_keys(reset($values)));
true