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 | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Support/SupportCollectionTest.php | @@ -98,7 +98,7 @@ public function testShiftReturnsAndRemovesFirstItemInCollection()
public function testEmptyCollectionIsEmpty()
{
- $c = new Collection();
+ $c = new Collection;
$this->assertTrue($c->isEmpty());
}
@@ -1014,7 +1014,7 @@ public function testTimesMethod()
public function testConstructMakeFromObject()
{
- $object = new stdClass();
+ $object = new stdClass;
$object->foo = 'bar';
$collection = Collection::make($object);
$this->assertEquals(['foo' => 'bar'], $collection->all());
@@ -1031,7 +1031,7 @@ public function testConstructMethodFromNull()
$collection = new Collection(null);
$this->assertEquals([], $collection->all());
- $collection = new Collection();
+ $collection = new Collection;
$this->assertEquals([], $collection->all());
}
@@ -1050,7 +1050,7 @@ public function testConstructMethodFromArray()
public function testConstructMethodFromObject()
{
- $object = new stdClass();
+ $object = new stdClass;
$object->foo = 'bar';
$collection = new Collection($object);
$this->assertEquals(['foo' => 'bar'], $collection->all());
@@ -1481,7 +1481,7 @@ public function testCanSumValuesWithoutACallback()
public function testGettingSumFromEmptyCollection()
{
- $c = new Collection();
+ $c = new Collection;
$this->assertEquals(0, $c->sum('foo'));
}
@@ -1636,7 +1636,7 @@ public function testGettingMaxItemsFromCollection()
$c = new Collection([1, 2, 3, 4, 5]);
$this->assertEquals(5, $c->max());
- $c = new Collection();
+ $c = new Collection;
$this->assertNull($c->max());
}
@@ -1660,7 +1660,7 @@ public function testGettingMinItemsFromCollection()
$c = new Collection([0, 1, 2, 3, 4]);
$this->assertEquals(0, $c->min());
- $c = new Collection();
+ $c = new Collection;
$this->assertNull($c->min());
}
@@ -1692,16 +1692,16 @@ public function testGettingAvgItemsFromCollection()
$c = new Collection([1, 2, 3, 4, 5]);
$this->assertEquals(3, $c->avg());
- $c = new Collection();
+ $c = new Collection;
$this->assertNull($c->avg());
}
public function testJsonSerialize()
{
$c = new Collection([
- new TestArrayableObject(),
- new TestJsonableObject(),
- new TestJsonSerializeObject(),
+ new TestArrayableObject,
+ new TestJsonableObject,
+ new TestJsonSerializeObject,
'baz',
]);
@@ -1859,13 +1859,13 @@ public function testMedianOutOfOrderCollection()
public function testMedianOnEmptyCollectionReturnsNull()
{
- $collection = new Collection();
+ $collection = new Collection;
$this->assertNull($collection->median());
}
public function testModeOnNullCollection()
{
- $collection = new Collection();
+ $collection = new Collection;
$this->assertNull($collection->mode());
}
@@ -1978,7 +1978,7 @@ public function testSplitCollectionWithCountLessThenDivisor()
public function testSplitEmptyCollection()
{
- $collection = new Collection();
+ $collection = new Collection;
$this->assertEquals(
[],
@@ -2056,7 +2056,7 @@ public function testPartitionPreservesKeys()
public function testPartitionEmptyCollection()
{
- $collection = new Collection();
+ $collection = new Collection;
$this->assertCount(2, $collection->partition(function () {
return true; | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Translation/TranslationMessageSelectorTest.php | @@ -12,7 +12,7 @@ class TranslationMessageSelectorTest extends TestCase
*/
public function testChoose($expected, $id, $number)
{
- $selector = new MessageSelector();
+ $selector = new MessageSelector;
$this->assertEquals($expected, $selector->choose($id, $number, 'en'));
} | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Validation/ValidationValidatorTest.php | @@ -2270,7 +2270,7 @@ public function testValidateDateAndFormat()
$v = new Validator($trans, ['x' => ['Not', 'a', 'date']], ['x' => 'date']);
$this->assertTrue($v->fails());
- $v = new Validator($trans, ['x' => new DateTime()], ['x' => 'date']);
+ $v = new Validator($trans, ['x' => new DateTime], ['x' => 'date']);
$this->assertTrue($v->passes());
$v = new Validator($trans, ['x' => '2000-01-01'], ['x' => 'date_format:Y-m-d']); | true |
Other | laravel | framework | f2dbf9cef960b5f21b02686324f2a1a39a64bbf5.json | Fix many docblocks. (#19676) | src/Illuminate/Mail/Markdown.php | @@ -13,7 +13,7 @@ class Markdown
/**
* The view factory implementation.
*
- * @var \Illuminate\View\Factory
+ * @var \Illuminate\Contracts\View\Factory
*/
protected $view;
| true |
Other | laravel | framework | f2dbf9cef960b5f21b02686324f2a1a39a64bbf5.json | Fix many docblocks. (#19676) | src/Illuminate/Mail/Message.php | @@ -205,7 +205,7 @@ public function attach($file, array $options = [])
* Create a Swift Attachment instance.
*
* @param string $file
- * @return \Swift_Attachment
+ * @return \Swift_Mime_Attachment
*/
protected function createAttachmentFromPath($file)
{ | true |
Other | laravel | framework | f2dbf9cef960b5f21b02686324f2a1a39a64bbf5.json | Fix many docblocks. (#19676) | src/Illuminate/Pagination/LengthAwarePaginator.php | @@ -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 = [])
{ | true |
Other | laravel | framework | f2dbf9cef960b5f21b02686324f2a1a39a64bbf5.json | Fix many docblocks. (#19676) | src/Illuminate/Pagination/Paginator.php | @@ -100,7 +100,7 @@ public function links($view = null, $data = [])
*
* @param string|null $view
* @param array $data
- * @return string
+ * @return \Illuminate\Support\HtmlString
*/
public function render($view = null, $data = [])
{ | true |
Other | laravel | framework | f2dbf9cef960b5f21b02686324f2a1a39a64bbf5.json | Fix many docblocks. (#19676) | src/Illuminate/Queue/RedisQueue.php | @@ -261,7 +261,7 @@ public function getQueue($queue)
/**
* Get the connection for the queue.
*
- * @return \Predis\ClientInterface
+ * @return \Illuminate\Redis\Connections\Connection
*/
protected function getConnection()
{ | true |
Other | laravel | framework | f2dbf9cef960b5f21b02686324f2a1a39a64bbf5.json | Fix many docblocks. (#19676) | src/Illuminate/Redis/Connectors/PhpRedisConnector.php | @@ -15,7 +15,7 @@ class PhpRedisConnector
*
* @param array $config
* @param array $options
- * @return \Illuminate\Redis\PhpRedisConnection
+ * @return \Illuminate\Redis\Connections\PhpRedisConnection
*/
public function connect(array $config, array $options)
{ | true |
Other | laravel | framework | f2dbf9cef960b5f21b02686324f2a1a39a64bbf5.json | Fix many docblocks. (#19676) | src/Illuminate/Routing/MiddlewareNameResolver.php | @@ -12,7 +12,7 @@ class MiddlewareNameResolver
* @param string $name
* @param array $map
* @param array $middlewareGroups
- * @return string|array
+ * @return \Closure|string|array
*/
public static function resolve($name, $map, $middlewareGroups)
{ | true |
Other | laravel | framework | f2dbf9cef960b5f21b02686324f2a1a39a64bbf5.json | Fix many docblocks. (#19676) | src/Illuminate/Routing/Route.php | @@ -526,7 +526,7 @@ public function secure()
* Get or set the domain for the route.
*
* @param string|null $domain
- * @return $this
+ * @return $this|string|null
*/
public function domain($domain = null)
{ | true |
Other | laravel | framework | f2dbf9cef960b5f21b02686324f2a1a39a64bbf5.json | Fix many docblocks. (#19676) | src/Illuminate/Routing/UrlGenerator.php | @@ -88,7 +88,7 @@ class UrlGenerator implements UrlGeneratorContract
/**
* The route URL generator instance.
*
- * @var \Illuminate\Routing\RouteUrlGenerator
+ * @var \Illuminate\Routing\RouteUrlGenerator|null
*/
protected $routeGenerator;
| true |
Other | laravel | framework | f2dbf9cef960b5f21b02686324f2a1a39a64bbf5.json | Fix many docblocks. (#19676) | src/Illuminate/Session/DatabaseSessionHandler.php | @@ -137,7 +137,7 @@ public function write($sessionId, $data)
*
* @param string $sessionId
* @param string $payload
- * @return void
+ * @return bool|null
*/
protected function performInsert($sessionId, $payload)
{ | true |
Other | laravel | framework | 05060b183dd09cee6dce498da5afde9e66fd1a29.json | Apply fixes from StyleCI (#19659) | tests/Database/DatabaseEloquentIntegrationTest.php | @@ -7,8 +7,8 @@
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Capsule\Manager as DB;
use Illuminate\Database\Eloquent\Relations\Pivot;
-use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Database\Eloquent\Model as Eloquent;
+use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Pagination\AbstractPaginator as Paginator;
| false |
Other | laravel | framework | d895ac833e81e860f9e2671e891ba57f985f2db5.json | Add missing dependency. (#19623) | src/Illuminate/Auth/composer.json | @@ -17,6 +17,7 @@
"php": ">=5.6.4",
"illuminate/contracts": "5.4.*",
"illuminate/http": "5.4.*",
+ "illuminate/queue": "5.4.*",
"illuminate/support": "5.4.*",
"nesbot/carbon": "~1.20"
}, | false |
Other | laravel | framework | 9b6f69be67ef03977aa2d25469b3853796529817.json | Change 419 error title (#19607) | src/Illuminate/Foundation/Exceptions/views/419.blade.php | @@ -1,6 +1,6 @@
@extends('errors::layout')
-@section('title', 'Logged out')
+@section('title', 'Page Expired')
@section('message')
The page has expired due to inactivity. | false |
Other | laravel | framework | 3644e861ef9cbf6529e0e9f54e1636f403070ff2.json | Add missing exceptions docblocks. (#19598) | src/Illuminate/Broadcasting/Broadcasters/Broadcaster.php | @@ -47,6 +47,7 @@ public function channel($channel, callable $callback)
* @param \Illuminate\Http\Request $request
* @param string $channel
* @return mixed
+ * @throws \Symfony\Component\HttpKernel\Exception\HttpException
*/
protected function verifyUserCanAccessChannel($request, $channel)
{
@@ -140,6 +141,7 @@ protected function resolveExplicitBindingIfPossible($key, $value)
* @param mixed $value
* @param array $callbackParameters
* @return mixed
+ * @throws \Symfony\Component\HttpKernel\Exception\HttpException
*/
protected function resolveImplicitBindingIfPossible($key, $value, $callbackParameters)
{ | true |
Other | laravel | framework | 3644e861ef9cbf6529e0e9f54e1636f403070ff2.json | Add missing exceptions docblocks. (#19598) | src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php | @@ -33,6 +33,7 @@ public function __construct(Pusher $pusher)
*
* @param \Illuminate\Http\Request $request
* @return mixed
+ * @throws \Symfony\Component\HttpKernel\Exception\HttpException
*/
public function auth($request)
{ | true |
Other | laravel | framework | 3644e861ef9cbf6529e0e9f54e1636f403070ff2.json | Add missing exceptions docblocks. (#19598) | src/Illuminate/Broadcasting/Broadcasters/RedisBroadcaster.php | @@ -41,6 +41,7 @@ public function __construct(Redis $redis, $connection = null)
*
* @param \Illuminate\Http\Request $request
* @return mixed
+ * @throws \Symfony\Component\HttpKernel\Exception\HttpException
*/
public function auth($request)
{ | true |
Other | laravel | framework | 045e6f25a860763942c928c4e6d8857d59741486.json | remove indefinite block | src/Illuminate/Cache/Lock.php | @@ -33,35 +33,14 @@ public function get($callback = null)
return $result;
}
- /**
- * Attempt to acquire the lock while blocking indefinitely.
- *
- * @param callable|null $calback
- * @return bool
- */
- public function block($callback = null)
- {
- while (! $this->acquire()) {
- usleep(250 * 1000);
- }
-
- if (is_callable($callback)) {
- return tap($callback(), function () {
- $this->release();
- });
- }
-
- return true;
- }
-
/**
* Attempt to acquire the lock for the given number of seconds.
*
* @param int $seconds
* @param callable|null $callback
* @return bool
*/
- public function blockFor($seconds, $callback = null)
+ public function block($seconds, $callback = null)
{
$starting = Carbon::now();
| true |
Other | laravel | framework | 045e6f25a860763942c928c4e6d8857d59741486.json | remove indefinite block | src/Illuminate/Contracts/Cache/Lock.php | @@ -12,22 +12,14 @@ interface Lock
*/
public function get($callback = null);
- /**
- * Attempt to acquire the lock while blocking indefinitely.
- *
- * @param callable|null $calback
- * @return bool
- */
- public function block($callback = null);
-
/**
* Attempt to acquire the lock for the given number of seconds.
*
* @param int $seconds
* @param callable|null $callback
* @return bool
*/
- public function blockFor($seconds, $callback = null);
+ public function block($seconds, $callback = null);
/**
* Release the lock. | true |
Other | laravel | framework | 045e6f25a860763942c928c4e6d8857d59741486.json | remove indefinite block | tests/Integration/Cache/CacheLockTest.php | @@ -40,51 +40,26 @@ public function test_locks_can_run_callbacks()
}
- public function test_locks_can_block()
- {
- Cache::store('memcached')->lock('foo')->release();
- Cache::store('memcached')->lock('foo', 1)->get();
- $this->assertEquals('taylor', Cache::store('memcached')->lock('foo', 10)->block(function () {
- return 'taylor';
- }));
-
- Cache::store('memcached')->lock('foo')->release();
- Cache::store('memcached')->lock('foo', 1)->get();
- $this->assertTrue(Cache::store('memcached')->lock('foo', 10)->block());
-
-
- Cache::store('redis')->lock('foo')->release();
- Cache::store('redis')->lock('foo', 1)->get();
- $this->assertEquals('taylor', Cache::store('redis')->lock('foo', 10)->block(function () {
- return 'taylor';
- }));
-
- Cache::store('redis')->lock('foo')->release();
- Cache::store('redis')->lock('foo', 1)->get();
- $this->assertTrue(Cache::store('redis')->lock('foo', 10)->block());
- }
-
-
public function test_locks_can_block_for_seconds()
{
Carbon::setTestNow();
Cache::store('memcached')->lock('foo')->release();
- $this->assertEquals('taylor', Cache::store('memcached')->lock('foo', 10)->blockFor(1, function () {
+ $this->assertEquals('taylor', Cache::store('memcached')->lock('foo', 10)->block(1, function () {
return 'taylor';
}));
Cache::store('memcached')->lock('foo')->release();
- $this->assertTrue(Cache::store('memcached')->lock('foo', 10)->blockFor(1));
+ $this->assertTrue(Cache::store('memcached')->lock('foo', 10)->block(1));
Cache::store('redis')->lock('foo')->release();
- $this->assertEquals('taylor', Cache::store('redis')->lock('foo', 10)->blockFor(1, function () {
+ $this->assertEquals('taylor', Cache::store('redis')->lock('foo', 10)->block(1, function () {
return 'taylor';
}));
Cache::store('redis')->lock('foo')->release();
- $this->assertTrue(Cache::store('redis')->lock('foo', 10)->blockFor(1));
+ $this->assertTrue(Cache::store('redis')->lock('foo', 10)->block(1));
}
@@ -97,7 +72,7 @@ public function test_locks_throw_timeout_if_block_expires()
Cache::store('memcached')->lock('foo')->release();
Cache::store('memcached')->lock('foo', 5)->get();
- $this->assertEquals('taylor', Cache::store('memcached')->lock('foo', 10)->blockFor(1, function () {
+ $this->assertEquals('taylor', Cache::store('memcached')->lock('foo', 10)->block(1, function () {
return 'taylor';
}));
} | true |
Other | laravel | framework | 531c8dda902e0b9351e1004f06b49f81c3694337.json | Apply fixes from StyleCI (#19602) | src/Illuminate/Cache/MemcachedLock.php | @@ -2,7 +2,6 @@
namespace Illuminate\Cache;
-use Carbon\Carbon;
use Illuminate\Contracts\Cache\Lock as LockContract;
class MemcachedLock extends Lock implements LockContract | true |
Other | laravel | framework | 531c8dda902e0b9351e1004f06b49f81c3694337.json | Apply fixes from StyleCI (#19602) | src/Illuminate/Cache/RedisLock.php | @@ -2,7 +2,6 @@
namespace Illuminate\Cache;
-use Carbon\Carbon;
use Illuminate\Contracts\Cache\Lock as LockContract;
class RedisLock extends Lock implements LockContract | true |
Other | laravel | framework | 531c8dda902e0b9351e1004f06b49f81c3694337.json | Apply fixes from StyleCI (#19602) | tests/Integration/Cache/CacheLockTest.php | @@ -30,7 +30,6 @@ public function test_locks_can_be_acquired_and_released()
Cache::store('redis')->lock('foo')->release();
}
-
public function test_locks_can_run_callbacks()
{
Cache::store('memcached')->lock('foo')->release();
@@ -39,7 +38,6 @@ public function test_locks_can_run_callbacks()
}));
}
-
public function test_locks_can_block()
{
Cache::store('memcached')->lock('foo')->release();
@@ -52,7 +50,6 @@ public function test_locks_can_block()
Cache::store('memcached')->lock('foo', 1)->get();
$this->assertTrue(Cache::store('memcached')->lock('foo', 10)->block());
-
Cache::store('redis')->lock('foo')->release();
Cache::store('redis')->lock('foo', 1)->get();
$this->assertEquals('taylor', Cache::store('redis')->lock('foo', 10)->block(function () {
@@ -64,7 +61,6 @@ public function test_locks_can_block()
$this->assertTrue(Cache::store('redis')->lock('foo', 10)->block());
}
-
public function test_locks_can_block_for_seconds()
{
Carbon::setTestNow();
@@ -77,7 +73,6 @@ public function test_locks_can_block_for_seconds()
Cache::store('memcached')->lock('foo')->release();
$this->assertTrue(Cache::store('memcached')->lock('foo', 10)->blockFor(1));
-
Cache::store('redis')->lock('foo')->release();
$this->assertEquals('taylor', Cache::store('redis')->lock('foo', 10)->blockFor(1, function () {
return 'taylor';
@@ -87,7 +82,6 @@ public function test_locks_can_block_for_seconds()
$this->assertTrue(Cache::store('redis')->lock('foo', 10)->blockFor(1));
}
-
/**
* @expectedException \Illuminate\Contracts\Cache\LockTimeoutException
*/ | true |
Other | laravel | framework | fcbc27782447c2baf938b808bc4bc49b5e45ccd3.json | Apply fixes from StyleCI (#19597) | src/Illuminate/Foundation/Console/Presets/Preset.php | @@ -41,7 +41,7 @@ protected static function updatePackages()
file_put_contents(
base_path('package.json'),
- json_encode($packages, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) . PHP_EOL
+ json_encode($packages, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT).PHP_EOL
);
}
| false |
Other | laravel | framework | 5ec0641b2945705120a3bc8f84ee7d1713caaf16.json | Maintain package.json formatting
Preserve the Node.js formatting of 2 space indent and end of file new line when modifying the `package.json` file from PHP | src/Illuminate/Foundation/Console/Presets/Preset.php | @@ -41,7 +41,11 @@ protected static function updatePackages()
file_put_contents(
base_path('package.json'),
- json_encode($packages, JSON_PRETTY_PRINT)
+ preg_replace(
+ '/^( +?)\\1(?=[^ ])/m',
+ '$1',
+ json_encode($packages, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) . PHP_EOL
+ )
);
}
| false |
Other | laravel | framework | c46eee10b3faf980e96e1d1647c7b7b8d81f304b.json | fix phpDoc return type on RouteRegistrar (#19579)
* fix phpDoc return type on RouteRegistrar
* partial revert due to comment | src/Illuminate/Routing/RouteRegistrar.php | @@ -96,7 +96,7 @@ public function resource($name, $controller, array $options = [])
/**
* Create a route group with shared attributes.
*
- * @param \Closure $callback
+ * @param \Closure|string $callback
* @return void
*/
public function group($callback) | false |
Other | laravel | framework | fe928fbc651c2a436346e5b540e6f8fbaf052fa8.json | Apply fixes from StyleCI (#19541) | src/Illuminate/Console/Scheduling/Event.php | @@ -3,7 +3,6 @@
namespace Illuminate\Console\Scheduling;
use Closure;
-use DateTime;
use Carbon\Carbon;
use Cron\CronExpression;
use GuzzleHttp\Client as HttpClient; | false |
Other | laravel | framework | 89a4318365b39b5d2cce25356ecd4f50bfc51e0b.json | Apply fixes from StyleCI (#19540) | src/Illuminate/Database/Eloquent/SoftDeletes.php | @@ -67,7 +67,7 @@ protected function runSoftDelete()
$query->update([
$this->getDeletedAtColumn() => $this->fromDateTime($time),
- $this->getUpdatedAtColumn() => $this->fromDateTime($time)
+ $this->getUpdatedAtColumn() => $this->fromDateTime($time),
]);
}
| true |
Other | laravel | framework | 89a4318365b39b5d2cce25356ecd4f50bfc51e0b.json | Apply fixes from StyleCI (#19540) | tests/Database/DatabaseSoftDeletingTraitTest.php | @@ -21,7 +21,7 @@ public function testDeleteSetsSoftDeletedColumn()
$query->shouldReceive('where')->once()->with('id', 1)->andReturn($query);
$query->shouldReceive('update')->once()->with([
'deleted_at' => 'date-time',
- 'updated_at' => 'date-time'
+ 'updated_at' => 'date-time',
]);
$model->delete();
| true |
Other | laravel | framework | e045e7df6e407428534a914caa8ae58db53ca5b9.json | Apply fixes from StyleCI (#19514) | src/Illuminate/Console/Scheduling/CallbackEvent.php | @@ -60,7 +60,7 @@ public function run(Container $container)
return;
}
- register_shutdown_function(function() {
+ register_shutdown_function(function () {
$this->removeMutex();
});
| false |
Other | laravel | framework | f16eb62f70d25e1a8ed85e35d486615d8d245a19.json | Apply fixes from StyleCI (#19513) | src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php | @@ -884,7 +884,7 @@ public function getOriginal($key = null, $default = null)
/**
* Get a subset of the model's attributes.
- *
+ *
* @param array|mixed $attributes
* @return array
*/ | false |
Other | laravel | framework | 12272dd2024795800c69b1643a4d3f0be056e28e.json | FIX phpDoc comment (#19501)
* Add/Fix @throws phpDoc comment
* Fix parameter type in phpDoc
* Add a missing backslash character
* Use fully qualified name in phpDoc | src/Illuminate/Database/Connection.php | @@ -688,6 +688,7 @@ protected function getElapsedTime($start)
* @param array $bindings
* @param \Closure $callback
* @return mixed
+ * @throws \Exception
*/
protected function handleQueryException($e, $query, $bindings, Closure $callback)
{ | true |
Other | laravel | framework | 12272dd2024795800c69b1643a4d3f0be056e28e.json | FIX phpDoc comment (#19501)
* Add/Fix @throws phpDoc comment
* Fix parameter type in phpDoc
* Add a missing backslash character
* Use fully qualified name in phpDoc | src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php | @@ -57,6 +57,7 @@ public function bootstrap(Application $app)
* @param \Illuminate\Contracts\Foundation\Application $app
* @param \Illuminate\Contracts\Config\Repository $repository
* @return void
+ * @throws \Exception
*/
protected function loadConfigurationFiles(Application $app, RepositoryContract $repository)
{ | true |
Other | laravel | framework | 12272dd2024795800c69b1643a4d3f0be056e28e.json | FIX phpDoc comment (#19501)
* Add/Fix @throws phpDoc comment
* Fix parameter type in phpDoc
* Add a missing backslash character
* Use fully qualified name in phpDoc | src/Illuminate/Mail/Markdown.php | @@ -34,7 +34,7 @@ class Markdown
/**
* Create a new Markdown renderer instance.
*
- * @param \Illuminate\View\Factory $view
+ * @param \Illuminate\Contracts\View\Factory $view
* @param array $options
* @return void
*/ | true |
Other | laravel | framework | 12272dd2024795800c69b1643a4d3f0be056e28e.json | FIX phpDoc comment (#19501)
* Add/Fix @throws phpDoc comment
* Fix parameter type in phpDoc
* Add a missing backslash character
* Use fully qualified name in phpDoc | src/Illuminate/View/Engines/CompilerEngine.php | @@ -70,7 +70,7 @@ public function get($path, array $data = [])
* @param int $obLevel
* @return void
*
- * @throws $e
+ * @throws \Exception
*/
protected function handleViewException(Exception $e, $obLevel)
{ | true |
Other | laravel | framework | 12272dd2024795800c69b1643a4d3f0be056e28e.json | FIX phpDoc comment (#19501)
* Add/Fix @throws phpDoc comment
* Fix parameter type in phpDoc
* Add a missing backslash character
* Use fully qualified name in phpDoc | src/Illuminate/View/Engines/PhpEngine.php | @@ -56,7 +56,7 @@ protected function evaluatePath($__path, $__data)
* @param int $obLevel
* @return void
*
- * @throws $e
+ * @throws \Exception
*/
protected function handleViewException(Exception $e, $obLevel)
{ | true |
Other | laravel | framework | e09d045e77189342e93d14674808d76a6ffc8ea3.json | Fix PHP Notice when collation not set (#19507)
Fix PHP Notice when `collation` not set in config/database.php | src/Illuminate/Database/Connectors/MySqlConnector.php | @@ -65,7 +65,7 @@ protected function configureEncoding($connection, array $config)
*/
protected function getCollation(array $config)
{
- return ! is_null($config['collation']) ? " collate '{$config['collation']}'" : '';
+ return isset($config['collation']) ? " collate '{$config['collation']}'" : '';
}
/** | false |
Other | laravel | framework | 107fb475f35f0691fe08facb697eda47f6cc7f3b.json | Use Collection count() function (#19491) | src/Illuminate/Pagination/Paginator.php | @@ -66,7 +66,7 @@ protected function setItems($items)
{
$this->items = $items instanceof Collection ? $items : Collection::make($items);
- $this->hasMore = count($this->items) > ($this->perPage);
+ $this->hasMore = $this->items->count() > $this->perPage;
$this->items = $this->items->slice(0, $this->perPage);
} | false |
Other | laravel | framework | 7488657f6d48bfd62120da7945c9204ad37666d7.json | Apply fixes from StyleCI (#19487) | src/Illuminate/Foundation/Testing/TestCase.php | @@ -113,7 +113,7 @@ protected function setUpTraits()
if (isset($uses[WithoutEvents::class])) {
$this->disableEventsForAllTests();
}
-
+
return $uses;
}
| false |
Other | laravel | framework | 4586bb74015791dffda1ae6275c94db8a651f498.json | Return the used traits from setUpTraits (#19486) | src/Illuminate/Foundation/Testing/TestCase.php | @@ -92,7 +92,7 @@ protected function refreshApplication()
/**
* Boot the testing helper traits.
*
- * @return void
+ * @return array
*/
protected function setUpTraits()
{
@@ -113,6 +113,8 @@ protected function setUpTraits()
if (isset($uses[WithoutEvents::class])) {
$this->disableEventsForAllTests();
}
+
+ return $uses;
}
/** | false |
Other | laravel | framework | 34af980c3e9668c98d48025634ab0d18bc964367.json | Apply fixes from StyleCI (#19473) | src/Illuminate/Foundation/Exceptions/Handler.php | @@ -276,7 +276,8 @@ protected function renderExceptionWithWhoops(Exception $e)
$whoops->writeToOutput(false);
$whoops->allowQuit(false);
- })->handleException($e);
+ }
+ )->handleException($e);
}
/** | false |
Other | laravel | framework | f2cd3c3396590944db2d789bf496f875a2bff0aa.json | Use Symfony as a last resort exception handler
This prevents white screens if something goes wrong with Whoops setup. | src/Illuminate/Foundation/Exceptions/Handler.php | @@ -248,15 +248,19 @@ protected function convertExceptionToResponse(Exception $e)
$headers = $this->isHttpException($e) ? $e->getHeaders() : [];
$statusCode = $this->isHttpException($e) ? $e->getStatusCode() : 500;
- if (config('app.debug')) {
- return SymfonyResponse::create(
- $this->renderExceptionWithWhoops($e), $statusCode, $headers
- );
- } else {
- return SymfonyResponse::create(
- $this->renderExceptionWithSymfony($e), $statusCode, $headers
- );
+ $showStackTraces = config('app.debug');
+
+ try {
+ $content = $showStackTraces
+ ? $this->renderExceptionWithWhoops($e)
+ : $this->renderExceptionWithSymfony($e, $showStackTraces);
+ } finally {
+ $content = $content ?? $this->renderExceptionWithSymfony($e, $showStackTraces);
}
+
+ return SymfonyResponse::create(
+ $content, $statusCode, $headers
+ );
}
/**
@@ -282,11 +286,11 @@ protected function renderExceptionWithWhoops(Exception $e)
* @param \Exception $e
* @return string
*/
- protected function renderExceptionWithSymfony(Exception $e)
+ protected function renderExceptionWithSymfony(Exception $e, $showStackTraces)
{
$e = FlattenException::create($e);
- return (new SymfonyExceptionHandler(false))->getHtml($e);
+ return (new SymfonyExceptionHandler($showStackTraces))->getHtml($e);
}
/** | false |
Other | laravel | framework | 4feb715752d9d2e99c46a4e338145c36d9eac08f.json | Return response from Whoops
Whoops will, by default, write directly to stdout and call exit. This prevents integration testing of whoops handled exceptions because phpunit will just stop.
The PrettyPageHandler is additionally setup to not return data in the CLI. Fix this by turning on unconditional handling. | src/Illuminate/Foundation/Exceptions/Handler.php | @@ -270,6 +270,8 @@ protected function renderExceptionWithWhoops(Exception $e)
{
$whoops = tap(new Whoops, function ($whoops) {
$whoops->pushHandler($this->whoopsHandler());
+ $whoops->writeToOutput(false);
+ $whoops->allowQuit(false);
});
return $whoops->handleException($e);
@@ -285,6 +287,7 @@ protected function whoopsHandler()
return tap(new PrettyPageHandler, function ($handler) {
$files = new Filesystem;
+ $handler->handleUnconditionally(true);
$handler->setApplicationPaths(
array_flip(array_except(
array_flip($files->directories(base_path())), [base_path('vendor')] | false |
Other | laravel | framework | 2642ac73cc5718a8aebe3d009b143b0fa43be085.json | add mapInto method | src/Illuminate/Support/Collection.php | @@ -821,6 +821,19 @@ public function flatMap(callable $callback)
return $this->map($callback)->collapse();
}
+ /**
+ * Map the values into a new class.
+ *
+ * @param string $class
+ * @return static
+ */
+ public function mapInto($class)
+ {
+ return $this->map(function ($value, $key) use ($class) {
+ return new $class($value, $key);
+ });
+ }
+
/**
* Get the max value of a given key.
* | true |
Other | laravel | framework | 2642ac73cc5718a8aebe3d009b143b0fa43be085.json | add mapInto method | tests/Support/SupportCollectionTest.php | @@ -1209,6 +1209,18 @@ public function testMapWithKeysCallbackKey()
);
}
+ public function testMapInto()
+ {
+ $data = new Collection([
+ 'first', 'second',
+ ]);
+
+ $data = $data->mapInto(TestCollectionMapIntoObject::class);
+
+ $this->assertEquals('first', $data[0]->value);
+ $this->assertEquals('second', $data[1]->value);
+ }
+
public function testNth()
{
$data = new Collection([
@@ -2200,3 +2212,13 @@ public function jsonSerialize()
return ['foo' => 'bar'];
}
}
+
+class TestCollectionMapIntoObject
+{
+ public $value;
+
+ public function __construct($value)
+ {
+ $this->value = $value;
+ }
+} | true |
Other | laravel | framework | 8e6e0deb44da8a7fa934d0bff4871dfd8f007931.json | Fix docblcks. (#19463) | src/Illuminate/Foundation/PackageManifest.php | @@ -45,7 +45,7 @@ class PackageManifest
/**
* Create a new package manifest instance.
*
- * @param \Illuminate\Foundation\Filesystem $files
+ * @param \Illuminate\Filesystem\Filesystem $files
* @param string $basePath
* @param string $manifestPath
* @return void
@@ -160,8 +160,9 @@ protected function packagesToIgnore()
/**
* Write the given manifest array to disk.
*
- * @param arary $manifest
+ * @param array $manifest
* @return void
+ * @throws \Exception
*/
protected function write(array $manifest)
{ | false |
Other | laravel | framework | 5f82c995f8163cea04ccffa813da5cccf8916152.json | Apply fixes from StyleCI (#19461) | src/Illuminate/Foundation/Exceptions/Handler.php | @@ -9,9 +9,9 @@
use Illuminate\Routing\Router;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Auth;
+use Illuminate\Filesystem\Filesystem;
use Illuminate\Http\RedirectResponse;
use Whoops\Handler\PrettyPageHandler;
-use Illuminate\Filesystem\Filesystem;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Contracts\Container\Container;
use Illuminate\Session\TokenMismatchException; | false |
Other | laravel | framework | 3ac37c04aa9dfff00f07c2663150e7235c5862aa.json | Fix typo in Docblock (#19453) | src/Illuminate/Foundation/Bus/DispatchesJobs.php | @@ -18,7 +18,7 @@ protected function dispatch($job)
}
/**
- * Dispatch a command to its appropriate handler in the current process.
+ * Dispatch a job to its appropriate handler in the current process.
*
* @param mixed $job
* @return mixed | false |
Other | laravel | framework | e19f2cd1bfc1f2574791462e812c6881e4629d06.json | Use installed.json for extra discovery | src/Illuminate/Foundation/PackageManifest.php | @@ -115,18 +115,12 @@ protected function ensureManifestIsLoaded()
*/
public function build()
{
- $vendors = $this->files->directories($this->vendorPath);
+ $installed = $this->files->get($this->vendorPath . '/composer/installed.json');
$ignore = $this->packagesToIgnore();
- $this->write(collect($vendors)->flatMap(function ($vendor) {
- return $this->files->directories($vendor);
- })->filter(function ($package) {
- return $this->files->exists($package.'/composer.json');
- })->mapWithKeys(function ($package) {
- return [$this->format($package) => json_decode(
- $this->files->get($package.'/composer.json'), true
- )['extra']['laravel'] ?? []];
+ $this->write(collect(json_decode($installed, true))->mapWithKeys(function ($package) {
+ return [$this->format($package['name']) => $package['extra']['laravel'] ?? []];
})->reject(function ($configuration, $package) use ($ignore) {
return in_array($package, $ignore);
})->filter()->all()); | true |
Other | laravel | framework | e19f2cd1bfc1f2574791462e812c6881e4629d06.json | Use installed.json for extra discovery | tests/Foundation/FoundationPackageManifestTest.php | @@ -6,12 +6,14 @@
use Illuminate\Filesystem\Filesystem;
use Illuminate\Foundation\PackageManifest;
-class FoundationPackageAssetsTest extends TestCase
+class FoundationPackageManifestTest extends TestCase
{
public function testAssetLoading()
{
+ @unlink(__DIR__.'/fixtures/packages.php');
$manifest = new PackageManifest(new Filesystem, __DIR__.'/fixtures', __DIR__.'/fixtures/packages.php');
- $this->assertEquals($manifest->providers(), ['foo', 'bar', 'baz']);
+ $this->assertEquals(['foo', 'bar', 'baz'], $manifest->providers());
+ $this->assertEquals(['Foo' => 'Foo\\Facade'], $manifest->aliases());
unlink(__DIR__.'/fixtures/packages.php');
}
} | true |
Other | laravel | framework | e19f2cd1bfc1f2574791462e812c6881e4629d06.json | Use installed.json for extra discovery | tests/Foundation/fixtures/vendor/composer/installed.json | @@ -0,0 +1,33 @@
+[
+ {
+ "name": "vendor_a/package_a",
+ "version": "v1.0.1",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0-dev"
+ },
+ "laravel": {
+ "providers": "foo",
+ "aliases": {
+ "Foo": "Foo\\Facade"
+ }
+ }
+ }
+ },
+ {
+ "name": "vendor_a/package_b",
+ "extra": {
+ "laravel": {
+ "providers": [
+ "bar",
+ "baz"
+ ]
+ }
+ }
+ },
+ {
+ "name": "vendor_a/package_c",
+ "type": "library"
+ }
+] | true |
Other | laravel | framework | e19f2cd1bfc1f2574791462e812c6881e4629d06.json | Use installed.json for extra discovery | tests/Foundation/fixtures/vendor/package_a/package_a/composer.json | @@ -1,7 +0,0 @@
-{
- "extra": {
- "laravel": {
- "providers": "foo"
- }
- }
-} | true |
Other | laravel | framework | e19f2cd1bfc1f2574791462e812c6881e4629d06.json | Use installed.json for extra discovery | tests/Foundation/fixtures/vendor/package_b/package_b/composer.json | @@ -1,10 +0,0 @@
-{
- "extra": {
- "laravel": {
- "providers": [
- "bar",
- "baz"
- ]
- }
- }
-} | true |
Other | laravel | framework | b69727243305e0ffa4a68819450716f26396c5e6.json | use whoops for errors | composer.json | @@ -20,6 +20,7 @@
"ext-openssl": "*",
"doctrine/inflector": "~1.0",
"erusev/parsedown": "~1.6",
+ "filp/whoops": "~2.0",
"league/flysystem": "~1.0",
"monolog/monolog": "~1.11",
"mtdowling/cron-expression": "~1.0", | true |
Other | laravel | framework | b69727243305e0ffa4a68819450716f26396c5e6.json | use whoops for errors | src/Illuminate/Foundation/Exceptions/Handler.php | @@ -3,12 +3,14 @@
namespace Illuminate\Foundation\Exceptions;
use Exception;
+use Whoops\Run as Whoops;
use Psr\Log\LoggerInterface;
use Illuminate\Http\Response;
use Illuminate\Routing\Router;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\RedirectResponse;
+use Whoops\Handler\PrettyPageHandler;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Contracts\Container\Container;
use Illuminate\Session\TokenMismatchException;
@@ -220,7 +222,9 @@ protected function convertValidationExceptionToResponse(ValidationException $e,
protected function prepareResponse($request, Exception $e)
{
if (! $this->isHttpException($e) && config('app.debug')) {
- return $this->toIlluminateResponse($this->convertExceptionToResponse($e), $e);
+ return $this->toIlluminateResponse(
+ $this->convertExceptionToResponse($e), $e
+ );
}
if (! $this->isHttpException($e)) {
@@ -233,39 +237,52 @@ protected function prepareResponse($request, Exception $e)
}
/**
- * Prepare a JSON response for the given exception.
+ * Create a Symfony response for the given exception.
*
- * @param \Illuminate\Http\Request $request
- * @param \Exception $e
- * @return \Illuminate\Http\JsonResponse
+ * @param \Exception $e
+ * @return \Symfony\Component\HttpFoundation\Response
*/
- protected function prepareJsonResponse($request, Exception $e)
+ protected function convertExceptionToResponse(Exception $e)
{
- $status = $this->isHttpException($e) ? $e->getStatusCode() : 500;
-
- $headers = $this->isHttpException($e) ? $e->getHeaders() : [];
+ if (config('app.debug')) {
+ return SymfonyResponse::create(
+ $this->renderExceptionWithWhoops($e), $e->getStatusCode(), $e->getHeaders()
+ );
+ } else {
+ $e = FlattenException::create($e);
- return new JsonResponse(
- $this->convertExceptionToArray($e), $status, $headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
- );
+ return SymfonyResponse::create(
+ (new SymfonyExceptionHandler(false))->getHtml($e),
+ $e->getStatusCode(),
+ $e->getHeaders()
+ );
+ }
}
/**
- * Convert the given exception to an array.
+ * Render an exception to a string using "Whoops".
*
* @param \Exception $e
- * @return array
+ * @return string
*/
- protected function convertExceptionToArray(Exception $e)
+ protected function renderExceptionWithWhoops(Exception $e)
{
- return config('app.debug') ? [
- 'message' => $e->getMessage(),
- 'file' => $e->getFile(),
- 'line' => $e->getLine(),
- 'trace' => $e->getTrace(),
- ] : [
- 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error',
- ];
+ return tap(
+ (new Whoops)->pushHandler($this->whoopsHandler())
+ )->handleException($e);
+ }
+
+ /**
+ * Get the Whoops handler for the application.
+ *
+ * @return \Whoops\Handler\Handler
+ */
+ protected function whoopsHandler()
+ {
+ return tap(new PrettyPageHandler)->setApplicationPaths([
+ app_path(), base_path('bootstrap'), config_path(), database_path(),
+ public_path(), resource_path(), base_path('routes'), storage_path(),
+ ]);
}
/**
@@ -290,21 +307,6 @@ protected function renderHttpException(HttpException $e)
}
}
- /**
- * Create a Symfony response for the given exception.
- *
- * @param \Exception $e
- * @return \Symfony\Component\HttpFoundation\Response
- */
- protected function convertExceptionToResponse(Exception $e)
- {
- $e = FlattenException::create($e);
-
- $handler = new SymfonyExceptionHandler(config('app.debug', false));
-
- return SymfonyResponse::create($handler->getHtml($e), $e->getStatusCode(), $e->getHeaders());
- }
-
/**
* Map the given exception into an Illuminate response.
*
@@ -315,14 +317,55 @@ protected function convertExceptionToResponse(Exception $e)
protected function toIlluminateResponse($response, Exception $e)
{
if ($response instanceof SymfonyRedirectResponse) {
- $response = new RedirectResponse($response->getTargetUrl(), $response->getStatusCode(), $response->headers->all());
+ $response = new RedirectResponse(
+ $response->getTargetUrl(), $response->getStatusCode(), $response->headers->all()
+ );
} else {
- $response = new Response($response->getContent(), $response->getStatusCode(), $response->headers->all());
+ $response = new Response(
+ $response->getContent(), $response->getStatusCode(), $response->headers->all()
+ );
}
return $response->withException($e);
}
+ /**
+ * Prepare a JSON response for the given exception.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param \Exception $e
+ * @return \Illuminate\Http\JsonResponse
+ */
+ protected function prepareJsonResponse($request, Exception $e)
+ {
+ $status = $this->isHttpException($e) ? $e->getStatusCode() : 500;
+
+ $headers = $this->isHttpException($e) ? $e->getHeaders() : [];
+
+ return new JsonResponse(
+ $this->convertExceptionToArray($e), $status, $headers,
+ JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
+ );
+ }
+
+ /**
+ * Convert the given exception to an array.
+ *
+ * @param \Exception $e
+ * @return array
+ */
+ protected function convertExceptionToArray(Exception $e)
+ {
+ return config('app.debug') ? [
+ 'message' => $e->getMessage(),
+ 'file' => $e->getFile(),
+ 'line' => $e->getLine(),
+ 'trace' => $e->getTrace(),
+ ] : [
+ 'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error',
+ ];
+ }
+
/**
* Render an exception to the console.
* | true |
Other | laravel | framework | b69727243305e0ffa4a68819450716f26396c5e6.json | use whoops for errors | tests/Foundation/FoundationExceptionsHandlerTest.php | @@ -47,19 +47,6 @@ public function tearDown()
m::close();
}
- public function testReturnsHtmlPageWithStackTraceWhenHtmlRequestAndDebugTrue()
- {
- $this->config->shouldReceive('get')->with('app.debug', null)->twice()->andReturn(true);
- $this->request->shouldReceive('expectsJson')->once()->andReturn(false);
-
- $response = $this->handler->render($this->request, new Exception('My custom error message'))->getContent();
-
- $this->assertContains('<!DOCTYPE html>', $response);
- $this->assertContains('Whoops, looks like something went wrong.', $response);
- $this->assertContains('My custom error message', $response);
- $this->assertNotContains('"message":', $response);
- }
-
public function testReturnsJsonWithStackTraceWhenAjaxRequestAndDebugTrue()
{
$this->config->shouldReceive('get')->with('app.debug', null)->once()->andReturn(true); | true |
Other | laravel | framework | df341e01848027ae9e1e2fb79bf3ae1fca50cad6.json | Apply fixes from StyleCI (#19448) | tests/Integration/Routing/ResponsableTest.php | @@ -23,7 +23,6 @@ public function test_responsable_objects_are_rendered()
}
}
-
class TestResponsableResponse implements Responsable
{
public function toResponse() | false |
Other | laravel | framework | c0c89fd73cebf9ed56e6c5e69ad35106df03d9db.json | Support Responsable objects.
This is the foundation for allowing objects to be converted into full
HTTP responses, allowing more fluent API packages to be built in the
future. | src/Illuminate/Contracts/Support/Responsable.php | @@ -0,0 +1,13 @@
+<?php
+
+namespace Illuminate\Contracts\Support;
+
+interface Responsable
+{
+ /**
+ * Create an HTTP response that represents the object.
+ *
+ * @return \Illuminate\Http\Response
+ */
+ public function toResponse();
+} | true |
Other | laravel | framework | c0c89fd73cebf9ed56e6c5e69ad35106df03d9db.json | Support Responsable objects.
This is the foundation for allowing objects to be converted into full
HTTP responses, allowing more fluent API packages to be built in the
future. | src/Illuminate/Routing/Pipeline.php | @@ -71,7 +71,8 @@ protected function carry()
*/
protected function handleException($passable, Exception $e)
{
- if (! $this->container->bound(ExceptionHandler::class) || ! $passable instanceof Request) {
+ if (! $this->container->bound(ExceptionHandler::class) ||
+ ! $passable instanceof Request) {
throw $e;
}
| true |
Other | laravel | framework | c0c89fd73cebf9ed56e6c5e69ad35106df03d9db.json | Support Responsable objects.
This is the foundation for allowing objects to be converted into full
HTTP responses, allowing more fluent API packages to be built in the
future. | src/Illuminate/Routing/Router.php | @@ -15,6 +15,7 @@
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Contracts\Support\Arrayable;
+use Illuminate\Contracts\Support\Responsable;
use Illuminate\Contracts\Routing\BindingRegistrar;
use Psr\Http\Message\ResponseInterface as PsrResponseInterface;
use Illuminate\Contracts\Routing\Registrar as RegistrarContract;
@@ -620,6 +621,8 @@ public static function prepareResponse($request, $response)
{
if ($response instanceof PsrResponseInterface) {
$response = (new HttpFoundationFactory)->createResponse($response);
+ } elseif ($response instanceof Responsable) {
+ $response = $response->toResponse();
} elseif (! $response instanceof SymfonyResponse &&
($response instanceof Arrayable ||
$response instanceof Jsonable || | true |
Other | laravel | framework | c0c89fd73cebf9ed56e6c5e69ad35106df03d9db.json | Support Responsable objects.
This is the foundation for allowing objects to be converted into full
HTTP responses, allowing more fluent API packages to be built in the
future. | tests/Integration/Routing/ResponsableTest.php | @@ -0,0 +1,33 @@
+<?php
+
+use Orchestra\Testbench\TestCase;
+use Illuminate\Support\Facades\Route;
+use Illuminate\Contracts\Support\Responsable;
+
+/**
+ * @group integration
+ */
+class ResponsableTest extends TestCase
+{
+ public function test_responsable_objects_are_rendered()
+ {
+ Route::get('/responsable', function () {
+ return new TestResponsableResponse;
+ });
+
+ $response = $this->get('/responsable');
+
+ $this->assertEquals(201, $response->status());
+ $this->assertEquals('Taylor', $response->headers->get('X-Test-Header'));
+ $this->assertEquals('hello world', $response->getContent());
+ }
+}
+
+
+class TestResponsableResponse implements Responsable
+{
+ public function toResponse()
+ {
+ return response('hello world', 201, ['X-Test-Header' => 'Taylor']);
+ }
+} | true |
Other | laravel | framework | 1d8ea077a93e7152be1f8d05dcdde7c4a0776cae.json | Apply fixes from StyleCI (#19446) | src/Illuminate/Foundation/Application.php | @@ -11,7 +11,6 @@
use Illuminate\Filesystem\Filesystem;
use Illuminate\Log\LogServiceProvider;
use Illuminate\Support\ServiceProvider;
-use Illuminate\Foundation\PackageManifest;
use Illuminate\Events\EventServiceProvider;
use Illuminate\Routing\RoutingServiceProvider;
use Symfony\Component\HttpKernel\HttpKernelInterface; | false |
Other | laravel | framework | a5a0f3e7b82a1a4dc00037c5463a31d42c94903a.json | rewrite package auto-discovery | src/Illuminate/Foundation/Application.php | @@ -11,6 +11,7 @@
use Illuminate\Filesystem\Filesystem;
use Illuminate\Log\LogServiceProvider;
use Illuminate\Support\ServiceProvider;
+use Illuminate\Foundation\PackageManifest;
use Illuminate\Events\EventServiceProvider;
use Illuminate\Routing\RoutingServiceProvider;
use Symfony\Component\HttpKernel\HttpKernelInterface;
@@ -176,6 +177,10 @@ protected function registerBaseBindings()
$this->instance('app', $this);
$this->instance(Container::class, $this);
+
+ $this->instance(PackageManifest::class, new PackageManifest(
+ new Filesystem, $this->basePath(), $this->getCachedPackagesPath()
+ ));
}
/**
@@ -545,8 +550,10 @@ public function runningUnitTests()
*/
public function registerConfiguredProviders()
{
+ $providers = $this->make(PackageManifest::class)->providers();
+
(new ProviderRepository($this, new Filesystem, $this->getCachedServicesPath()))
- ->load($this->config['app.providers']);
+ ->load(array_merge($this->config['app.providers'], $providers));
}
/** | true |
Other | laravel | framework | a5a0f3e7b82a1a4dc00037c5463a31d42c94903a.json | rewrite package auto-discovery | src/Illuminate/Foundation/Bootstrap/RegisterFacades.php | @@ -4,6 +4,7 @@
use Illuminate\Foundation\AliasLoader;
use Illuminate\Support\Facades\Facade;
+use Illuminate\Foundation\PackageManifest;
use Illuminate\Contracts\Foundation\Application;
class RegisterFacades
@@ -20,6 +21,9 @@ public function bootstrap(Application $app)
Facade::setFacadeApplication($app);
- AliasLoader::getInstance($app->make('config')->get('app.aliases', []))->register();
+ AliasLoader::getInstance(array_merge(
+ $app->make('config')->get('app.aliases', []),
+ $app->make(PackageManifest::class)->aliases()
+ ))->register();
}
} | true |
Other | laravel | framework | a5a0f3e7b82a1a4dc00037c5463a31d42c94903a.json | rewrite package auto-discovery | src/Illuminate/Foundation/Bootstrap/RegisterPackageProviders.php | @@ -1,31 +0,0 @@
-<?php
-
-namespace Illuminate\Foundation\Bootstrap;
-
-use Illuminate\Filesystem\Filesystem;
-use Illuminate\Foundation\PackageAssetLoader;
-use Illuminate\Contracts\Foundation\Application;
-
-class RegisterPackageProviders
-{
- /**
- * Bootstrap the given application.
- *
- * @param \Illuminate\Contracts\Foundation\Application $app
- * @return void
- */
- public function bootstrap(Application $app)
- {
- if (! $app->make('config')->get('app.autoload_package_providers', true)) {
- return;
- }
-
- $assetLoader = new PackageAssetLoader(new Filesystem, base_path('vendor'), $app->getCachedPackagesPath());
-
- foreach ($assetLoader->get('providers') as $provider) {
- if (class_exists($provider)) {
- $app->register($provider);
- }
- }
- }
-} | true |
Other | laravel | framework | a5a0f3e7b82a1a4dc00037c5463a31d42c94903a.json | rewrite package auto-discovery | src/Illuminate/Foundation/ComposerScripts.php | @@ -32,6 +32,19 @@ public static function postUpdate(Event $event)
static::clearCompiled();
}
+ /**
+ * Handle the post-autoload-dump Composer event.
+ *
+ * @param \Composer\Script\Event $event
+ * @return void
+ */
+ public static function postAutoloadDump(Event $event)
+ {
+ require_once $event->getComposer()->getConfig()->get('vendor-dir').'/autoload.php';
+
+ static::clearCompiled();
+ }
+
/**
* Clear the cached Laravel bootstrapping files.
* | true |
Other | laravel | framework | a5a0f3e7b82a1a4dc00037c5463a31d42c94903a.json | rewrite package auto-discovery | src/Illuminate/Foundation/Console/Kernel.php | @@ -63,7 +63,6 @@ class Kernel implements KernelContract
\Illuminate\Foundation\Bootstrap\RegisterFacades::class,
\Illuminate\Foundation\Bootstrap\SetRequestForConsole::class,
\Illuminate\Foundation\Bootstrap\RegisterProviders::class,
- \Illuminate\Foundation\Bootstrap\RegisterPackageProviders::class,
\Illuminate\Foundation\Bootstrap\BootProviders::class,
];
| true |
Other | laravel | framework | a5a0f3e7b82a1a4dc00037c5463a31d42c94903a.json | rewrite package auto-discovery | src/Illuminate/Foundation/Console/OptimizeCommand.php | @@ -20,27 +20,7 @@ class OptimizeCommand extends Command
*
* @var string
*/
- protected $description = 'Optimize the framework for better performance';
-
- /**
- * The composer instance.
- *
- * @var \Illuminate\Support\Composer
- */
- protected $composer;
-
- /**
- * Create a new optimize command instance.
- *
- * @param \Illuminate\Support\Composer $composer
- * @return void
- */
- public function __construct(Composer $composer)
- {
- parent::__construct();
-
- $this->composer = $composer;
- }
+ protected $description = 'Optimize the framework for better performance (deprecated)';
/**
* Execute the console command.
@@ -49,15 +29,7 @@ public function __construct(Composer $composer)
*/
public function fire()
{
- $this->info('Generating optimized class loader');
-
- if ($this->option('psr')) {
- $this->composer->dumpAutoloads();
- } else {
- $this->composer->dumpOptimized();
- }
-
- $this->call('clear-compiled');
+ //
}
/** | true |
Other | laravel | framework | a5a0f3e7b82a1a4dc00037c5463a31d42c94903a.json | rewrite package auto-discovery | src/Illuminate/Foundation/Exceptions/Handler.php | @@ -127,10 +127,14 @@ protected function shouldntReport(Exception $e)
*/
protected function context()
{
- return array_filter([
- 'userId' => Auth::id(),
- 'email' => Auth::user()->email ?? null,
- ]);
+ try {
+ return array_filter([
+ 'userId' => Auth::id(),
+ 'email' => Auth::user() ? Auth::user()->email : null,
+ ]);
+ } catch (Exception $e) {
+ return [];
+ }
}
/** | true |
Other | laravel | framework | a5a0f3e7b82a1a4dc00037c5463a31d42c94903a.json | rewrite package auto-discovery | src/Illuminate/Foundation/Http/Kernel.php | @@ -39,7 +39,6 @@ class Kernel implements KernelContract
\Illuminate\Foundation\Bootstrap\HandleExceptions::class,
\Illuminate\Foundation\Bootstrap\RegisterFacades::class,
\Illuminate\Foundation\Bootstrap\RegisterProviders::class,
- \Illuminate\Foundation\Bootstrap\RegisterPackageProviders::class,
\Illuminate\Foundation\Bootstrap\BootProviders::class,
];
| true |
Other | laravel | framework | a5a0f3e7b82a1a4dc00037c5463a31d42c94903a.json | rewrite package auto-discovery | src/Illuminate/Foundation/PackageAssetLoader.php | @@ -1,81 +0,0 @@
-<?php
-
-namespace Illuminate\Foundation;
-
-use Exception;
-use Illuminate\Filesystem\Filesystem;
-
-class PackageAssetLoader
-{
- /**
- * @var \Illuminate\Filesystem\Filesystem
- */
- private $files;
-
- /**
- * @var string
- */
- private $vendorPath;
-
- /**
- * @var string|null
- */
- private $manifestPath;
-
- public function __construct(Filesystem $files, string $vendorPath, string $manifestPath = null)
- {
- $this->files = $files;
- $this->vendorPath = $vendorPath;
- $this->manifestPath = $manifestPath;
- }
-
- public function get(string $key): array
- {
- $manifest = [];
-
- if (file_exists($this->manifestPath)) {
- $manifest = $this->files->getRequire($this->manifestPath);
-
- // If the manifest has a key for the given asset type,
- // we'll simply return the assets without loading
- // all of the assets again from the packages.
- if (isset($manifest[$key])) {
- return $manifest[$key];
- }
- }
-
- $manifest[$key] = $this->retrieveAssets($key);
-
- if ($this->manifestPath) {
- $this->writeManifest($manifest);
- }
-
- return $manifest[$key];
- }
-
- private function retrieveAssets(string $key)
- {
- $assets = [];
-
- foreach ($this->files->directories($this->vendorPath) as $vendor) {
- foreach ($this->files->directories($vendor) as $package) {
- $config = json_decode($this->files->get($package.'/composer.json'), true);
-
- $assets = array_merge($assets, (array) ($config['extra'][$key] ?? []));
- }
- }
-
- return array_unique($assets);
- }
-
- private function writeManifest(array $manifest)
- {
- if (! is_writable(dirname($this->manifestPath))) {
- throw new Exception('The bootstrap/cache directory must be present and writable.');
- }
-
- $this->files->put(
- $this->manifestPath, '<?php return '.var_export($manifest, true).';'
- );
- }
-} | true |
Other | laravel | framework | a5a0f3e7b82a1a4dc00037c5463a31d42c94903a.json | rewrite package auto-discovery | src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php | @@ -43,6 +43,7 @@
use Illuminate\Foundation\Console\VendorPublishCommand;
use Illuminate\Console\Scheduling\ScheduleFinishCommand;
use Illuminate\Database\Console\Seeds\SeederMakeCommand;
+use Illuminate\Foundation\Console\PackageDiscoverCommand;
use Illuminate\Database\Console\Migrations\MigrateCommand;
use Illuminate\Foundation\Console\NotificationMakeCommand;
use Illuminate\Database\Console\Factories\FactoryMakeCommand;
@@ -96,6 +97,7 @@ class ArtisanServiceProvider extends ServiceProvider
'MigrateRollback' => 'command.migrate.rollback',
'MigrateStatus' => 'command.migrate.status',
'Optimize' => 'command.optimize',
+ 'PackageDiscover' => 'command.package.discover',
'Preset' => 'command.preset',
'QueueFailed' => 'command.queue.failed',
'QueueFlush' => 'command.queue.flush',
@@ -567,6 +569,18 @@ protected function registerOptimizeCommand()
});
}
+ /**
+ * Register the command.
+ *
+ * @return void
+ */
+ protected function registerPackageDiscoverCommand()
+ {
+ $this->app->singleton('command.package.discover', function ($app) {
+ return new PackageDiscoverCommand;
+ });
+ }
+
/**
* Register the command.
* | true |
Other | laravel | framework | 4074394582767906b2e7b5939d34e1eb78e28ff4.json | Apply fixes from StyleCI (#19440) | src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php | @@ -370,7 +370,7 @@ public function supportsSavepoints()
{
return true;
}
-
+
/**
* Compile the SQL statement to define a savepoint.
* | false |
Other | laravel | framework | 0f49665023a17b1c1127fc62fb5abb1ed7d709fd.json | Fix StyleCI warnings | src/Illuminate/Foundation/PackageAssetLoader.php | @@ -59,7 +59,7 @@ private function retrieveAssets(string $key)
foreach ($this->files->directories($this->vendorPath) as $vendor) {
foreach ($this->files->directories($vendor) as $package) {
- $config = json_decode($this->files->get($package . '/composer.json'), true);
+ $config = json_decode($this->files->get($package.'/composer.json'), true);
$assets = array_merge($assets, (array) ($config['extra'][$key] ?? []));
} | true |
Other | laravel | framework | 0f49665023a17b1c1127fc62fb5abb1ed7d709fd.json | Fix StyleCI warnings | tests/Foundation/FoundationPackageAssetsTest.php | @@ -10,7 +10,7 @@ class FoundationPackageAssetsTest extends TestCase
{
public function testAssetLoading()
{
- $assetLoader = new PackageAssetLoader(new Filesystem, __DIR__ . '/fixtures/vendor');
+ $assetLoader = new PackageAssetLoader(new Filesystem, __DIR__.'/fixtures/vendor');
$this->assertEquals($assetLoader->get('providers'), ['foo', 'bar', 'baz']);
} | true |
Other | laravel | framework | 67de1d6568160df2a36ffa328accf47bcd3ea5a6.json | add macroable trait (#19425) | src/Illuminate/Database/Eloquent/FactoryBuilder.php | @@ -5,9 +5,12 @@
use Closure;
use Faker\Generator as Faker;
use InvalidArgumentException;
+use Illuminate\Support\Traits\Macroable;
class FactoryBuilder
{
+ use Macroable;
+
/**
* The model definitions in the container.
* | false |
Other | laravel | framework | 1fbc7cf6e89fe2cf720ecfe26b4912fb1bea2347.json | Apply fixes from StyleCI (#19410) | src/Illuminate/Foundation/helpers.php | @@ -1,6 +1,5 @@
<?php
-use Illuminate\Support\Str;
use Illuminate\Support\HtmlString;
use Illuminate\Container\Container;
use Illuminate\Contracts\Bus\Dispatcher; | false |
Other | laravel | framework | 7cbb6d96a8605463704a1c10e61aa201de27a050.json | Move env function to Support component (#19409) | src/Illuminate/Foundation/helpers.php | @@ -433,45 +433,6 @@ function encrypt($value)
}
}
-if (! function_exists('env')) {
- /**
- * Gets the value of an environment variable.
- *
- * @param string $key
- * @param mixed $default
- * @return mixed
- */
- function env($key, $default = null)
- {
- $value = getenv($key);
-
- if ($value === false) {
- return value($default);
- }
-
- switch (strtolower($value)) {
- case 'true':
- case '(true)':
- return true;
- case 'false':
- case '(false)':
- return false;
- case 'empty':
- case '(empty)':
- return '';
- case 'null':
- case '(null)':
- return;
- }
-
- if (strlen($value) > 1 && Str::startsWith($value, '"') && Str::endsWith($value, '"')) {
- return substr($value, 1, -1);
- }
-
- return $value;
- }
-}
-
if (! function_exists('event')) {
/**
* Dispatch an event and call the listeners. | true |
Other | laravel | framework | 7cbb6d96a8605463704a1c10e61aa201de27a050.json | Move env function to Support component (#19409) | src/Illuminate/Support/helpers.php | @@ -548,6 +548,45 @@ function ends_with($haystack, $needles)
}
}
+if (! function_exists('env')) {
+ /**
+ * Gets the value of an environment variable.
+ *
+ * @param string $key
+ * @param mixed $default
+ * @return mixed
+ */
+ function env($key, $default = null)
+ {
+ $value = getenv($key);
+
+ if ($value === false) {
+ return value($default);
+ }
+
+ switch (strtolower($value)) {
+ case 'true':
+ case '(true)':
+ return true;
+ case 'false':
+ case '(false)':
+ return false;
+ case 'empty':
+ case '(empty)':
+ return '';
+ case 'null':
+ case '(null)':
+ return;
+ }
+
+ if (strlen($value) > 1 && Str::startsWith($value, '"') && Str::endsWith($value, '"')) {
+ return substr($value, 1, -1);
+ }
+
+ return $value;
+ }
+}
+
if (! function_exists('head')) {
/**
* Get the first element of an array. Useful for method chaining. | true |
Other | laravel | framework | 9475cb4a99e88723f192f645cc4dbcd15b6796e1.json | Add missing docblocks (#19401) | src/Illuminate/Container/BoundMethod.php | @@ -103,7 +103,7 @@ protected static function normalizeMethod($callback)
/**
* Get all dependencies for a given method.
*
- * @param \Illuminate\Container\Container
+ * @param \Illuminate\Container\Container $container
* @param callable|string $callback
* @param array $parameters
* @return array | true |
Other | laravel | framework | 9475cb4a99e88723f192f645cc4dbcd15b6796e1.json | Add missing docblocks (#19401) | src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php | @@ -113,7 +113,7 @@ class BelongsToMany extends Relation
* @param string $foreignPivotKey
* @param string $relatedPivotKey
* @param string $parentKey
- * @param string $localKey
+ * @param string $relatedKey
* @param string $relationName
* @return void
*/ | true |
Other | laravel | framework | 9475cb4a99e88723f192f645cc4dbcd15b6796e1.json | Add missing docblocks (#19401) | src/Illuminate/Database/Events/QueryExecuted.php | @@ -45,7 +45,8 @@ class QueryExecuted
* @param string $sql
* @param array $bindings
* @param float $time
- * @param
+ * @param string $connection
+ * @return void
*/
public function __construct($sql, $bindings, $time, $connection)
{ | true |
Other | laravel | framework | 9475cb4a99e88723f192f645cc4dbcd15b6796e1.json | Add missing docblocks (#19401) | src/Illuminate/Notifications/Messages/SlackMessage.php | @@ -223,6 +223,7 @@ public function linkNames()
/**
* Find and link channel names and usernames.
*
+ * @param string $unfurl
* @return $this
*/
public function unfurlLinks($unfurl)
@@ -235,6 +236,7 @@ public function unfurlLinks($unfurl)
/**
* Find and link channel names and usernames.
*
+ * @param string $unfurl
* @return $this
*/
public function unfurlMedia($unfurl) | true |
Other | laravel | framework | 60478992946c71cb7067b84b0118cf9c86d49ab1.json | Use assertCount (#19402) | tests/Database/DatabaseEloquentIntegrationTest.php | @@ -675,7 +675,7 @@ public function testBelongsToManyRelationshipModelsAreProperlyHydratedOverChunke
$friend = $user->friends()->create(['email' => 'abigailotwell@gmail.com']);
EloquentTestUser::first()->friends()->chunk(2, function ($friends) use ($user, $friend) {
- $this->assertEquals(1, count($friends));
+ $this->assertCount(1, $friends);
$this->assertEquals('abigailotwell@gmail.com', $friends->first()->email);
$this->assertEquals($user->id, $friends->first()->pivot->user_id);
$this->assertEquals($friend->id, $friends->first()->pivot->friend_id); | true |
Other | laravel | framework | 60478992946c71cb7067b84b0118cf9c86d49ab1.json | Use assertCount (#19402) | tests/Database/DatabaseEloquentModelTest.php | @@ -583,7 +583,7 @@ public function testPushEmptyManyRelation()
$this->assertTrue($model->push());
$this->assertEquals(1, $model->id);
$this->assertTrue($model->exists);
- $this->assertEquals(0, count($model->relationMany));
+ $this->assertCount(0, $model->relationMany);
}
public function testPushManyRelation() | true |
Other | laravel | framework | 11006d82153c9dea3386566e32c5feec8298995b.json | Remove mockery call in test | tests/Foundation/FoundationPackageAssetsTest.php | @@ -2,18 +2,12 @@
namespace Illuminate\Tests\Foundation;
-use Mockery as m;
use PHPUnit\Framework\TestCase;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Foundation\PackageAssetLoader;
class FoundationPackageAssetsTest extends TestCase
{
- public function tearDown()
- {
- m::close();
- }
-
public function testAssetLoading()
{
$assetLoader = new PackageAssetLoader(new Filesystem, __DIR__ . '/fixtures/vendor'); | false |
Other | laravel | framework | f483ed4b0d8aceb4e52849e1a4cc7bd121f8ffdf.json | Allow users to disable package autoloading | src/Illuminate/Foundation/Bootstrap/RegisterPackageProviders.php | @@ -16,6 +16,10 @@ class RegisterPackageProviders
*/
public function bootstrap(Application $app)
{
+ if (! $app->make('config')->get('app.autoload_package_providers', true)) {
+ return;
+ }
+
$assetLoader = new PackageAssetLoader(new Filesystem, base_path('vendor'), $app->getCachedPackagesPath());
foreach ($assetLoader->get('providers') as $provider) { | false |
Other | laravel | framework | f3894d09f6ed1fea4e97f6c4e4b11e0b2fdbd8d9.json | Use packages file to cache package providers | src/Illuminate/Contracts/Foundation/Application.php | @@ -96,4 +96,11 @@ public function booted($callback);
* @return string
*/
public function getCachedServicesPath();
+
+ /**
+ * Get the path to the cached packages.php file.
+ *
+ * @return string
+ */
+ public function getCachedPackagesPath();
} | true |
Other | laravel | framework | f3894d09f6ed1fea4e97f6c4e4b11e0b2fdbd8d9.json | Use packages file to cache package providers | src/Illuminate/Foundation/Application.php | @@ -838,6 +838,16 @@ public function getCachedServicesPath()
return $this->bootstrapPath().'/cache/services.php';
}
+ /**
+ * Get the path to the cached services.php file.
+ *
+ * @return string
+ */
+ public function getCachedPackagesPath()
+ {
+ return $this->bootstrapPath().'/cache/packages.php';
+ }
+
/**
* Determine if the application configuration is cached.
* | true |
Other | laravel | framework | f3894d09f6ed1fea4e97f6c4e4b11e0b2fdbd8d9.json | Use packages file to cache package providers | src/Illuminate/Foundation/Bootstrap/RegisterPackageProviders.php | @@ -3,11 +3,10 @@
namespace Illuminate\Foundation\Bootstrap;
use Illuminate\Filesystem\Filesystem;
-use Illuminate\Foundation\AliasLoader;
use Illuminate\Foundation\PackageAssetLoader;
use Illuminate\Contracts\Foundation\Application;
-class LoadPackageAssets
+class RegisterPackageProviders
{
/**
* Bootstrap the given application.
@@ -17,12 +16,10 @@ class LoadPackageAssets
*/
public function bootstrap(Application $app)
{
- $assetLoader = new PackageAssetLoader(new Filesystem, base_path('vendor'));
+ $assetLoader = new PackageAssetLoader(new Filesystem, base_path('vendor'), $app->getCachedPackagesPath());
foreach ($assetLoader->get('providers') as $provider) {
$app->register($provider);
}
-
- AliasLoader::getInstance($assetLoader->get('facades'))->register();
}
} | true |
Other | laravel | framework | f3894d09f6ed1fea4e97f6c4e4b11e0b2fdbd8d9.json | Use packages file to cache package providers | src/Illuminate/Foundation/ComposerScripts.php | @@ -44,5 +44,9 @@ protected static function clearCompiled()
if (file_exists($servicesPath = $laravel->getCachedServicesPath())) {
@unlink($servicesPath);
}
+
+ if (file_exists($packagesPath = $laravel->getCachedPackagesPath())) {
+ @unlink($packagesPath);
+ }
}
} | true |
Other | laravel | framework | f3894d09f6ed1fea4e97f6c4e4b11e0b2fdbd8d9.json | Use packages file to cache package providers | src/Illuminate/Foundation/Console/ClearCompiledCommand.php | @@ -27,12 +27,14 @@ class ClearCompiledCommand extends Command
*/
public function fire()
{
- $servicesPath = $this->laravel->getCachedServicesPath();
-
- if (file_exists($servicesPath)) {
+ if (file_exists($servicesPath = $this->laravel->getCachedServicesPath())) {
@unlink($servicesPath);
}
- $this->info('The compiled services file has been removed.');
+ if (file_exists($packagesPath = $this->laravel->getCachedPackagesPath())) {
+ @unlink($packagesPath);
+ }
+
+ $this->info('The compiled services & packages file have been removed.');
}
} | true |
Other | laravel | framework | f3894d09f6ed1fea4e97f6c4e4b11e0b2fdbd8d9.json | Use packages file to cache package providers | src/Illuminate/Foundation/Console/Kernel.php | @@ -63,7 +63,7 @@ class Kernel implements KernelContract
\Illuminate\Foundation\Bootstrap\RegisterFacades::class,
\Illuminate\Foundation\Bootstrap\SetRequestForConsole::class,
\Illuminate\Foundation\Bootstrap\RegisterProviders::class,
- \Illuminate\Foundation\Bootstrap\LoadPackageAssets::class,
+ \Illuminate\Foundation\Bootstrap\RegisterPackageProviders::class,
\Illuminate\Foundation\Bootstrap\BootProviders::class,
];
| true |
Other | laravel | framework | f3894d09f6ed1fea4e97f6c4e4b11e0b2fdbd8d9.json | Use packages file to cache package providers | src/Illuminate/Foundation/Http/Kernel.php | @@ -39,7 +39,7 @@ class Kernel implements KernelContract
\Illuminate\Foundation\Bootstrap\HandleExceptions::class,
\Illuminate\Foundation\Bootstrap\RegisterFacades::class,
\Illuminate\Foundation\Bootstrap\RegisterProviders::class,
- \Illuminate\Foundation\Bootstrap\LoadPackageAssets::class,
+ \Illuminate\Foundation\Bootstrap\RegisterPackageProviders::class,
\Illuminate\Foundation\Bootstrap\BootProviders::class,
];
| true |
Other | laravel | framework | f3894d09f6ed1fea4e97f6c4e4b11e0b2fdbd8d9.json | Use packages file to cache package providers | src/Illuminate/Foundation/PackageAssetLoader.php | @@ -2,38 +2,80 @@
namespace Illuminate\Foundation;
+use Exception;
use Illuminate\Filesystem\Filesystem;
class PackageAssetLoader
{
/**
* @var \Illuminate\Filesystem\Filesystem
*/
- private $filesystem;
+ private $files;
/**
* @var string
*/
- private $directory;
+ private $vendorPath;
- public function __construct(Filesystem $filesystem, string $directory)
+ /**
+ * @var string|null
+ */
+ private $manifestPath;
+
+ public function __construct(Filesystem $files, string $vendorPath, string $manifestPath = null)
{
- $this->filesystem = $filesystem;
- $this->directory = $directory;
+ $this->files = $files;
+ $this->vendorPath = $vendorPath;
+ $this->manifestPath = $manifestPath;
}
- public function get($key)
+ public function get(string $key): array
+ {
+ $manifest = [];
+
+ if (file_exists($this->manifestPath)) {
+ $manifest = json_decode($this->manifestPath, true);
+
+ // If the manifest has a key for the given asset type,
+ // we'll simply return the assets without loading
+ // all of the assets again from the packages.
+ if (isset($manifest[$key])) {
+ return $manifest[$key];
+ }
+ }
+
+ $manifest[$key] = $this->retrieveAssets($key);
+
+ if ($this->manifestPath) {
+ $this->writeManifest($manifest);
+ }
+
+ return $manifest[$key];
+ }
+
+ private function retrieveAssets(string $key)
{
$assets = [];
- foreach ($this->filesystem->directories($this->directory) as $vendor) {
- foreach ($this->filesystem->directories($vendor) as $package) {
- $config = json_decode($this->filesystem->get($package . '/composer.json'), true);
+ foreach ($this->files->directories($this->vendorPath) as $vendor) {
+ foreach ($this->files->directories($vendor) as $package) {
+ $config = json_decode($this->files->get($package . '/composer.json'), true);
$assets = array_merge($assets, (array) ($config['extra'][$key] ?? []));
}
}
return array_unique($assets);
}
+
+ private function writeManifest(array $manifest)
+ {
+ if (! is_writable(dirname($this->manifestPath))) {
+ throw new Exception('The bootstrap/cache directory must be present and writable.');
+ }
+
+ $this->files->put(
+ $this->manifestPath, '<?php return '.var_export($manifest, true).';'
+ );
+ }
} | true |
Other | laravel | framework | f3894d09f6ed1fea4e97f6c4e4b11e0b2fdbd8d9.json | Use packages file to cache package providers | tests/Foundation/FoundationPackageAssetsTest.php | @@ -16,12 +16,8 @@ public function tearDown()
public function testAssetLoading()
{
- $discovery = new PackageAssetLoader(new Filesystem, __DIR__ . '/fixtures/vendor');
+ $assetLoader = new PackageAssetLoader(new Filesystem, __DIR__ . '/fixtures/vendor');
- $this->assertEquals($discovery->get('providers'), ['foo', 'bar', 'baz']);
- $this->assertEquals($discovery->get('facades'), [
- 'Foo' => 'FooClass',
- 'Bar' => 'BarClass',
- ]);
+ $this->assertEquals($assetLoader->get('providers'), ['foo', 'bar', 'baz']);
}
} | true |
Other | laravel | framework | f3894d09f6ed1fea4e97f6c4e4b11e0b2fdbd8d9.json | Use packages file to cache package providers | tests/Foundation/fixtures/vendor/package_a/package_a/composer.json | @@ -1,9 +1,5 @@
{
"extra": {
- "providers": "foo",
- "facades": {
- "Foo": "FooClass",
- "Bar": "BarClass"
- }
+ "providers": "foo"
}
} | true |
Other | laravel | framework | f3894d09f6ed1fea4e97f6c4e4b11e0b2fdbd8d9.json | Use packages file to cache package providers | tests/Foundation/fixtures/vendor/package_b/package_b/composer.json | @@ -1,7 +1,8 @@
{
"extra": {
- "facades": {
- "Foo": "FooClass"
- }
+ "providers": [
+ "bar",
+ "baz"
+ ]
}
} | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.