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 | 1ef8b9c3f156c7d4debc6c6f67b73b032d8337d5.json | Rewrite Redis layer.
This rewrite the Redis layer to function more like database or cache
drivers… a new Redis factory is introduced to retrieve Redis connection
instances. Different Redis connection instances are introduced to
account for differences between the two drivers (Predis and PhpRedis). | src/Illuminate/Redis/PhpRedisDatabase.php | @@ -1,184 +0,0 @@
-<?php
-
-namespace Illuminate\Redis;
-
-use Redis;
-use Closure;
-use RedisCluster;
-use Illuminate\Support\Arr;
-
-class PhpRedisDatabase extends Database
-{
- /**
- * The host address of the database.
- *
- * @var array
- */
- public $clients;
-
- /**
- * Create a new Redis connection instance.
- *
- * @param array $servers
- * @return void
- */
- public function __construct(array $servers = [])
- {
- $clusters = (array) Arr::pull($servers, 'clusters');
-
- $options = (array) Arr::pull($servers, 'options');
-
- $this->clients = $this->createSingleClients($servers, $options);
-
- $this->createClusters($clusters, $options);
- }
-
- /**
- * Create an array of single connection clients.
- *
- * @param array $servers
- * @param array $options
- * @return array
- */
- protected function createSingleClients(array $servers, array $options = [])
- {
- $clients = [];
-
- foreach ($servers as $key => $server) {
- $clients[$key] = $this->createRedisInstance($server, $options);
- }
-
- return $clients;
- }
-
- /**
- * Create multiple clusters (aggregate clients).
- *
- * @param array $clusters
- * @param array $options
- * @return void
- */
- protected function createClusters(array $clusters, array $options = [])
- {
- $options = array_merge($options, (array) Arr::pull($clusters, 'options'));
-
- foreach ($clusters as $name => $servers) {
- $this->clients[$name] = $this->createAggregateClient($servers, array_merge(
- $options, (array) Arr::pull($servers, 'options')
- ));
- }
- }
-
- /**
- * Create a new aggregate client supporting sharding.
- *
- * @param array $servers
- * @param array $options
- * @return array
- */
- protected function createAggregateClient(array $servers, array $options = [])
- {
- return $this->createRedisClusterInstance(
- array_map([$this, 'buildClusterConnectionString'], $servers), $options
- );
- }
-
- /**
- * Subscribe to a set of given channels for messages.
- *
- * @param array|string $channels
- * @param \Closure $callback
- * @param string $connection
- * @return void
- */
- public function subscribe($channels, Closure $callback, $connection = null)
- {
- $this->connection($connection)->subscribe((array) $channels, function ($redis, $channel, $message) use ($callback) {
- $callback($message, $channel);
- });
- }
-
- /**
- * Subscribe to a set of given channels with wildcards.
- *
- * @param array|string $channels
- * @param \Closure $callback
- * @param string $connection
- * @return void
- */
- public function psubscribe($channels, Closure $callback, $connection = null)
- {
- $this->connection($connection)->psubscribe((array) $channels, function ($redis, $pattern, $channel, $message) use ($callback) {
- $callback($message, $channel);
- });
- }
-
- /**
- * Create a new redis instance.
- *
- * @param array $server
- * @param array $options
- * @return \Redis
- */
- protected function createRedisInstance(array $server, array $options)
- {
- $client = new Redis;
-
- $timeout = empty($server['timeout']) ? 0 : $server['timeout'];
-
- if (isset($server['persistent']) && $server['persistent']) {
- $client->pconnect($server['host'], $server['port'], $timeout);
- } else {
- $client->connect($server['host'], $server['port'], $timeout);
- }
-
- if (! empty($server['prefix'])) {
- $client->setOption(Redis::OPT_PREFIX, $server['prefix']);
- }
-
- if (! empty($server['read_timeout'])) {
- $client->setOption(Redis::OPT_READ_TIMEOUT, $server['read_timeout']);
- }
-
- if (! empty($server['password'])) {
- $client->auth($server['password']);
- }
-
- if (! empty($server['database'])) {
- $client->select($server['database']);
- }
-
- return $client;
- }
-
- /**
- * Create a new redis cluster instance.
- *
- * @param array $servers
- * @param array $options
- * @return \RedisCluster
- */
- protected function createRedisClusterInstance(array $servers, array $options)
- {
- return new RedisCluster(
- null,
- array_values($servers),
- Arr::get($options, 'timeout', 0),
- Arr::get($options, 'read_timeout', 0),
- isset($options['persistent']) && $options['persistent']
- );
- }
-
- /**
- * Build a single cluster seed string from array.
- *
- * @param array $server
- * @return string
- */
- protected function buildClusterConnectionString(array $server)
- {
- return $server['host'].':'.$server['port'].'?'.http_build_query(Arr::only($server, [
- 'database', 'password', 'prefix', 'read_timeout',
- ]));
- }
-} | true |
Other | laravel | framework | 1ef8b9c3f156c7d4debc6c6f67b73b032d8337d5.json | Rewrite Redis layer.
This rewrite the Redis layer to function more like database or cache
drivers… a new Redis factory is introduced to retrieve Redis connection
instances. Different Redis connection instances are introduced to
account for differences between the two drivers (Predis and PhpRedis). | src/Illuminate/Redis/PredisDatabase.php | @@ -1,120 +0,0 @@
-<?php
-
-namespace Illuminate\Redis;
-
-use Closure;
-use Predis\Client;
-use Illuminate\Support\Arr;
-
-class PredisDatabase extends Database
-{
- /**
- * The host address of the database.
- *
- * @var array
- */
- public $clients;
-
- /**
- * Create a new Redis connection instance.
- *
- * @param array $servers
- * @return void
- */
- public function __construct(array $servers = [])
- {
- $clusters = (array) Arr::pull($servers, 'clusters');
-
- $options = array_merge(['timeout' => 10.0], (array) Arr::pull($servers, 'options'));
-
- $this->clients = $this->createSingleClients($servers, $options);
-
- $this->createClusters($clusters, $options);
- }
-
- /**
- * Create an array of single connection clients.
- *
- * @param array $servers
- * @param array $options
- * @return array
- */
- protected function createSingleClients(array $servers, array $options = [])
- {
- $clients = [];
-
- foreach ($servers as $key => $server) {
- $clients[$key] = new Client($server, $options);
- }
-
- return $clients;
- }
-
- /**
- * Create multiple clusters (aggregate clients).
- *
- * @param array $clusters
- * @param array $options
- * @return void
- */
- protected function createClusters(array $clusters, array $options = [])
- {
- $options = array_merge($options, (array) Arr::pull($clusters, 'options'));
-
- foreach ($clusters as $name => $servers) {
- $this->clients += $this->createAggregateClient($name, $servers, array_merge(
- $options, (array) Arr::pull($servers, 'options')
- ));
- }
- }
-
- /**
- * Create a new aggregate client supporting sharding.
- *
- * @param string $name
- * @param array $servers
- * @param array $options
- * @return array
- */
- protected function createAggregateClient($name, array $servers, array $options = [])
- {
- return [$name => new Client(array_values($servers), $options)];
- }
-
- /**
- * Subscribe to a set of given channels for messages.
- *
- * @param array|string $channels
- * @param \Closure $callback
- * @param string $connection
- * @param string $method
- * @return void
- */
- public function subscribe($channels, Closure $callback, $connection = null, $method = 'subscribe')
- {
- $loop = $this->connection($connection)->pubSubLoop();
-
- call_user_func_array([$loop, $method], (array) $channels);
-
- foreach ($loop as $message) {
- if ($message->kind === 'message' || $message->kind === 'pmessage') {
- call_user_func($callback, $message->payload, $message->channel);
- }
- }
-
- unset($loop);
- }
-
- /**
- * Subscribe to a set of given channels with wildcards.
- *
- * @param array|string $channels
- * @param \Closure $callback
- * @param string $connection
- * @return void
- */
- public function psubscribe($channels, Closure $callback, $connection = null)
- {
- $this->subscribe($channels, $callback, $connection, __FUNCTION__);
- }
-} | true |
Other | laravel | framework | 1ef8b9c3f156c7d4debc6c6f67b73b032d8337d5.json | Rewrite Redis layer.
This rewrite the Redis layer to function more like database or cache
drivers… a new Redis factory is introduced to retrieve Redis connection
instances. Different Redis connection instances are introduced to
account for differences between the two drivers (Predis and PhpRedis). | src/Illuminate/Redis/RedisManager.php | @@ -0,0 +1,106 @@
+<?php
+
+namespace Illuminate\Redis;
+
+use Illuminate\Support\Arr;
+use InvalidArgumentException;
+use Illuminate\Contracts\Redis\Factory;
+
+class RedisManager implements Factory
+{
+ /**
+ * The name of the default driver.
+ *
+ * @var string
+ */
+ protected $driver;
+
+ /**
+ * The Redis server configurations.
+ *
+ * @var array
+ */
+ protected $config;
+
+ /**
+ * Create a new Redis manager instance.
+ *
+ * @param string $driver
+ * @param array $config
+ */
+ public function __construct($driver, array $config)
+ {
+ $this->driver = $driver;
+ $this->config = $config;
+ }
+
+ /**
+ * Get a Redis connection by name.
+ *
+ * @param string $name
+ * @return \Illuminate\Redis\Connection
+ */
+ public function connection($name = null)
+ {
+ $name = $name ?: 'default';
+
+ if (isset($this->connections[$name])) {
+ return $this->connections[$name];
+ }
+
+ return $this->connections[$name] = $this->resolve($name);
+ }
+
+ /**
+ * Resolve the given connection by name.
+ *
+ * @param string $name
+ * @return \Illuminate\Redis\Connection
+ */
+ protected function resolve($name)
+ {
+ $options = Arr::get($this->config, 'options', []);
+
+ if (isset($this->config[$name])) {
+ return $this->connector()->connect($this->config[$name], $options);
+ }
+
+ if (isset($this->config['clusters'][$name])) {
+ $clusterOptions = Arr::get($this->config, 'clusters.options', []);
+
+ return $this->connector()->connectToCluster(
+ $this->config['clusters'][$name], $clusterOptions, $options
+ );
+ }
+
+ throw new InvalidArgumentException("Redis connection [{$name}] not configured.");
+ }
+
+ /**
+ * Get the connector instance for the current driver.
+ *
+ * @return mixed
+ */
+ protected function connector()
+ {
+ switch ($this->driver)
+ {
+ case 'predis':
+ return new Connectors\PredisConnector;
+ case 'phpredis':
+ return new Connectors\PhpRedisConnector;
+ }
+ }
+
+ /**
+ * Pass methods onto the default Redis connection.
+ *
+ * @param string $method
+ * @param array $parameters
+ * @return mixed
+ */
+ public function __call($method, $parameters)
+ {
+ return $this->connection()->{$method}(...$parameters);
+ }
+} | true |
Other | laravel | framework | 1ef8b9c3f156c7d4debc6c6f67b73b032d8337d5.json | Rewrite Redis layer.
This rewrite the Redis layer to function more like database or cache
drivers… a new Redis factory is introduced to retrieve Redis connection
instances. Different Redis connection instances are introduced to
account for differences between the two drivers (Predis and PhpRedis). | src/Illuminate/Redis/RedisServiceProvider.php | @@ -22,15 +22,9 @@ class RedisServiceProvider extends ServiceProvider
public function register()
{
$this->app->singleton('redis', function ($app) {
- $servers = $app['config']['database.redis'];
+ $config = $app->make('config')->get('database.redis');
- $client = Arr::pull($servers, 'client', 'predis');
-
- if ($client === 'phpredis') {
- return new PhpRedisDatabase($servers);
- } else {
- return new PredisDatabase($servers);
- }
+ return new RedisManager(Arr::pull($config, 'client', 'predis'), $config);
});
}
| true |
Other | laravel | framework | 1ef8b9c3f156c7d4debc6c6f67b73b032d8337d5.json | Rewrite Redis layer.
This rewrite the Redis layer to function more like database or cache
drivers… a new Redis factory is introduced to retrieve Redis connection
instances. Different Redis connection instances are introduced to
account for differences between the two drivers (Predis and PhpRedis). | src/Illuminate/Support/Facades/Redis.php | @@ -3,10 +3,8 @@
namespace Illuminate\Support\Facades;
/**
- * @see \Illuminate\Redis\Database
- * @see \Illuminate\Redis\PredisDatabase
- * @see \Illuminate\Redis\PhpRedisDatabase
- * @see \Illuminate\Contracts\Redis\Database
+ * @see \Illuminate\Redis\RedisManager
+ * @see \Illuminate\Contracts\Redis\Factory
*/
class Redis extends Facade
{ | true |
Other | laravel | framework | 1ef8b9c3f156c7d4debc6c6f67b73b032d8337d5.json | Rewrite Redis layer.
This rewrite the Redis layer to function more like database or cache
drivers… a new Redis factory is introduced to retrieve Redis connection
instances. Different Redis connection instances are introduced to
account for differences between the two drivers (Predis and PhpRedis). | tests/Cache/CacheRedisStoreTest.php | @@ -140,6 +140,6 @@ public function testGetAndSetPrefix()
protected function getRedis()
{
- return new Illuminate\Cache\RedisStore(m::mock('Illuminate\Redis\PredisDatabase'), 'prefix');
+ return new Illuminate\Cache\RedisStore(m::mock('Illuminate\Contracts\Redis\Factory'), 'prefix');
}
} | true |
Other | laravel | framework | 1ef8b9c3f156c7d4debc6c6f67b73b032d8337d5.json | Rewrite Redis layer.
This rewrite the Redis layer to function more like database or cache
drivers… a new Redis factory is introduced to retrieve Redis connection
instances. Different Redis connection instances are introduced to
account for differences between the two drivers (Predis and PhpRedis). | tests/Queue/QueueRedisQueueTest.php | @@ -11,7 +11,7 @@ public function tearDown()
public function testPushProperlyPushesJobOntoRedis()
{
- $queue = $this->getMockBuilder('Illuminate\Queue\RedisQueue')->setMethods(['getRandomId'])->setConstructorArgs([$redis = m::mock('Illuminate\Redis\PredisDatabase'), 'default'])->getMock();
+ $queue = $this->getMockBuilder('Illuminate\Queue\RedisQueue')->setMethods(['getRandomId'])->setConstructorArgs([$redis = m::mock('Illuminate\Contracts\Redis\Factory'), 'default'])->getMock();
$queue->expects($this->once())->method('getRandomId')->will($this->returnValue('foo'));
$redis->shouldReceive('connection')->once()->andReturn($redis);
$redis->shouldReceive('rpush')->once()->with('queues:default', json_encode(['job' => 'foo', 'data' => ['data'], 'id' => 'foo', 'attempts' => 1]));
@@ -22,7 +22,7 @@ public function testPushProperlyPushesJobOntoRedis()
public function testDelayedPushProperlyPushesJobOntoRedis()
{
- $queue = $this->getMockBuilder('Illuminate\Queue\RedisQueue')->setMethods(['getSeconds', 'getTime', 'getRandomId'])->setConstructorArgs([$redis = m::mock('Illuminate\Redis\PredisDatabase'), 'default'])->getMock();
+ $queue = $this->getMockBuilder('Illuminate\Queue\RedisQueue')->setMethods(['getSeconds', 'getTime', 'getRandomId'])->setConstructorArgs([$redis = m::mock('Illuminate\Contracts\Redis\Factory'), 'default'])->getMock();
$queue->expects($this->once())->method('getRandomId')->will($this->returnValue('foo'));
$queue->expects($this->once())->method('getSeconds')->with(1)->will($this->returnValue(1));
$queue->expects($this->once())->method('getTime')->will($this->returnValue(1));
@@ -41,7 +41,7 @@ public function testDelayedPushProperlyPushesJobOntoRedis()
public function testDelayedPushWithDateTimeProperlyPushesJobOntoRedis()
{
$date = Carbon\Carbon::now();
- $queue = $this->getMockBuilder('Illuminate\Queue\RedisQueue')->setMethods(['getSeconds', 'getTime', 'getRandomId'])->setConstructorArgs([$redis = m::mock('Illuminate\Redis\PredisDatabase'), 'default'])->getMock();
+ $queue = $this->getMockBuilder('Illuminate\Queue\RedisQueue')->setMethods(['getSeconds', 'getTime', 'getRandomId'])->setConstructorArgs([$redis = m::mock('Illuminate\Contracts\Redis\Factory'), 'default'])->getMock();
$queue->expects($this->once())->method('getRandomId')->will($this->returnValue('foo'));
$queue->expects($this->once())->method('getSeconds')->with($date)->will($this->returnValue(1));
$queue->expects($this->once())->method('getTime')->will($this->returnValue(1)); | true |
Other | laravel | framework | 1ef8b9c3f156c7d4debc6c6f67b73b032d8337d5.json | Rewrite Redis layer.
This rewrite the Redis layer to function more like database or cache
drivers… a new Redis factory is introduced to retrieve Redis connection
instances. Different Redis connection instances are introduced to
account for differences between the two drivers (Predis and PhpRedis). | tests/Redis/InteractsWithRedis.php | @@ -1,7 +1,7 @@
<?php
-use Illuminate\Redis\PredisDatabase;
+use Illuminate\Redis\RedisManager;
trait InteractsWithRedis
{
@@ -11,7 +11,7 @@ trait InteractsWithRedis
private static $connectionFailedOnceWithDefaultsSkip = false;
/**
- * @var PredisDatabase
+ * @var RedisManager
*/
private $redis;
@@ -26,7 +26,7 @@ public function setUpRedis()
return;
}
- $this->redis = new PredisDatabase([
+ $this->redis = new RedisManager('predis', [
'cluster' => false,
'default' => [
'host' => $host, | true |
Other | laravel | framework | 1ef8b9c3f156c7d4debc6c6f67b73b032d8337d5.json | Rewrite Redis layer.
This rewrite the Redis layer to function more like database or cache
drivers… a new Redis factory is introduced to retrieve Redis connection
instances. Different Redis connection instances are introduced to
account for differences between the two drivers (Predis and PhpRedis). | tests/Redis/PhpRedisConnectionTest.php | @@ -1,96 +0,0 @@
-<?php
-
-use Illuminate\Redis\PhpRedisDatabase;
-
-class PhpRedisConnectionTest extends PHPUnit_Framework_TestCase
-{
- public function testPhpRedisNotCreateClusterAndOptionsAndClustersServer()
- {
- $redis = $this->getRedis();
-
- $client = $redis->connection('cluster');
- $this->assertNull($client, 'cluster parameter should not create as redis server');
-
- $client = $redis->connection('options');
- $this->assertNull($client, 'options parameter should not create as redis server');
-
- $client = $redis->connection('clusters');
- $this->assertNull($client, 'clusters parameter should not create as redis server');
- }
-
- public function testPhpRedisClusterNotCreateClusterAndOptionsServer()
- {
- $redis = $this->getRedis();
- $this->assertEquals(['default', 'cluster-1', 'cluster-2'], array_keys($redis->clients));
- }
-
- public function testPhpRedisClusterCreateMultipleClustersAndNotCreateOptionsServer()
- {
- $redis = $this->getRedis();
-
- $clusterOne = $redis->connection('cluster-1');
- $clusterTwo = $redis->connection('cluster-2');
-
- $this->assertInstanceOf(RedisClusterStub::class, $clusterOne);
- $this->assertInstanceOf(RedisClusterStub::class, $clusterTwo);
-
- $client = $redis->connection('options');
- $this->assertNull($client, 'options parameter should not create as redis server');
- }
-
- protected function getRedis()
- {
- $servers = [
- 'default' => [
- 'host' => '127.0.0.1',
- 'port' => 6379,
- 'database' => 0,
- ],
- 'options' => [
- 'prefix' => 'prefix:',
- ],
- 'clusters' => [
- 'options' => [
- 'prefix' => 'cluster:',
- ],
- 'cluster-1' => [
- [
- 'host' => '127.0.0.1',
- 'port' => 6379,
- 'database' => 0,
- ],
- ],
- 'cluster-2' => [
- [
- 'host' => '127.0.0.1',
- 'port' => 6379,
- 'database' => 0,
- ],
- ],
- ],
- ];
-
- return new PhpRedisDatabaseStub($servers);
- }
-}
-
-class PhpRedisDatabaseStub extends PhpRedisDatabase
-{
- protected function createRedisClusterInstance(array $servers, array $options)
- {
- return new RedisClusterStub();
- }
-
- protected function createRedisInstance(array $server, array $options)
- {
- return new RedisStub;
- }
-}
-
-class RedisStub
-{
-}
-
-class RedisClusterStub
-{
-} | true |
Other | laravel | framework | 1ef8b9c3f156c7d4debc6c6f67b73b032d8337d5.json | Rewrite Redis layer.
This rewrite the Redis layer to function more like database or cache
drivers… a new Redis factory is introduced to retrieve Redis connection
instances. Different Redis connection instances are introduced to
account for differences between the two drivers (Predis and PhpRedis). | tests/Redis/RedisConnectionTest.php | @@ -1,72 +0,0 @@
-<?php
-
-class RedisConnectionTest extends PHPUnit_Framework_TestCase
-{
- public function testRedisNotCreateClusterAndOptionsAndClustersServer()
- {
- $redis = $this->getRedis();
-
- $client = $redis->connection('cluster');
- $this->assertNull($client, 'cluster parameter should not create as redis server');
-
- $client = $redis->connection('options');
- $this->assertNull($client, 'options parameter should not create as redis server');
-
- $client = $redis->connection('clusters');
- $this->assertNull($client, 'clusters parameter should not create as redis server');
- }
-
- public function testRedisClusterNotCreateClusterAndOptionsServer()
- {
- $redis = $this->getRedis();
- $this->assertEquals(['default', 'cluster-1', 'cluster-2'], array_keys($redis->clients));
- }
-
- public function testRedisClusterCreateMultipleClustersAndNotCreateOptionsServer()
- {
- $redis = $this->getRedis();
- $clusterOne = $redis->connection('cluster-1');
- $clusterTwo = $redis->connection('cluster-2');
-
- $this->assertCount(1, $clusterOne->getConnection());
- $this->assertCount(1, $clusterTwo->getConnection());
-
- $client = $redis->connection('options');
- $this->assertNull($client, 'options parameter should not create as redis server');
- }
-
- protected function getRedis()
- {
- $servers = [
- 'default' => [
- 'host' => '127.0.0.1',
- 'port' => 6379,
- 'database' => 0,
- ],
- 'options' => [
- 'prefix' => 'prefix:',
- ],
- 'clusters' => [
- 'options' => [
- 'prefix' => 'cluster:',
- ],
- 'cluster-1' => [
- [
- 'host' => '127.0.0.1',
- 'port' => 6379,
- 'database' => 0,
- ],
- ],
- 'cluster-2' => [
- [
- 'host' => '127.0.0.1',
- 'port' => 6379,
- 'database' => 0,
- ],
- ],
- ],
- ];
-
- return new Illuminate\Redis\PredisDatabase($servers);
- }
-} | true |
Other | laravel | framework | 9f80a2adde929b653a2bf9430e9d3b696b3f2629.json | remove unneeded property | src/Illuminate/Notifications/Events/BroadcastNotificationCreated.php | @@ -25,13 +25,6 @@ class BroadcastNotificationCreated implements ShouldBroadcast
*/
public $notification;
- /**
- * The queue connection.
- *
- * @var string
- */
- public $connection;
-
/**
* The notification data.
* | false |
Other | laravel | framework | 9682b187f64564292209a8713aed85231709b291.json | Add withPath method. Protect addQuery. | src/Illuminate/Pagination/AbstractPaginator.php | @@ -213,7 +213,7 @@ protected function appendArray(array $keys)
* @param string $value
* @return $this
*/
- public function addQuery($key, $value)
+ protected function addQuery($key, $value)
{
if ($key !== $this->pageName) {
$this->query[$key] = $value;
@@ -325,6 +325,17 @@ public function setPageName($name)
return $this;
}
+ /**
+ * Set the base path to assign to all URLs.
+ *
+ * @param string $path
+ * @return $this
+ */
+ public function withPath($path)
+ {
+ return $this->setPath($path);
+ }
+
/**
* Set the base path to assign to all URLs.
* | false |
Other | laravel | framework | 4ffd790217432f8699d4beae891fca482c230de4.json | Apply fixes from StyleCI (#16891) | src/Illuminate/Notifications/Channels/MailChannel.php | @@ -5,7 +5,6 @@
use Closure;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
-use Illuminate\Support\Collection;
use Illuminate\Contracts\Mail\Mailer;
use Illuminate\Contracts\Mail\Mailable;
use Illuminate\Notifications\Notification; | false |
Other | laravel | framework | 2efc9531debaddeec0fb7d605d627367102b5c68.json | Apply fixes from StyleCI (#16890) | src/Illuminate/Notifications/ChannelManager.php | @@ -2,19 +2,14 @@
namespace Illuminate\Notifications;
-use Ramsey\Uuid\Uuid;
use Illuminate\Mail\Markdown;
use InvalidArgumentException;
use Illuminate\Support\Manager;
use Nexmo\Client as NexmoClient;
-use Illuminate\Support\Collection;
use GuzzleHttp\Client as HttpClient;
-use Illuminate\Database\Eloquent\Model;
-use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Contracts\Bus\Dispatcher as Bus;
use Nexmo\Client\Credentials\Basic as NexmoCredentials;
-use Illuminate\Database\Eloquent\Collection as ModelCollection;
use Illuminate\Contracts\Notifications\Factory as FactoryContract;
use Illuminate\Contracts\Notifications\Dispatcher as DispatcherContract;
| false |
Other | laravel | framework | 4d8090b332ec30c80c54eb16a61134cf09562c7f.json | Correct param order. | src/Illuminate/Notifications/Events/NotificationFailed.php | @@ -43,9 +43,9 @@ class NotificationFailed
*/
public function __construct($notifiable, $notification, $channel, $data = [])
{
+ $this->data = $data;
$this->channel = $channel;
$this->notifiable = $notifiable;
$this->notification = $notification;
- $this->data = $data;
}
} | false |
Other | laravel | framework | 44958f04b0c3eacd8ebc8b19602511438f7fbbec.json | Apply fixes from StyleCI (#16889) | src/Illuminate/Mail/Mailer.php | @@ -2,7 +2,6 @@
namespace Illuminate\Mail;
-use Closure;
use Swift_Mailer;
use Swift_Message;
use Illuminate\Support\Arr;
@@ -312,7 +311,7 @@ protected function setGlobalTo($message)
public function queue($view, array $data = [], $callback = null, $queue = null)
{
if (! $view instanceof MailableContract) {
- throw new InvalidArgumentException("Only mailables may be queued.");
+ throw new InvalidArgumentException('Only mailables may be queued.');
}
return $view->queue($this->queue);
@@ -361,7 +360,7 @@ public function queueOn($queue, $view, array $data, $callback)
public function later($delay, $view, array $data = [], $callback = null, $queue = null)
{
if (! $view instanceof MailableContract) {
- throw new InvalidArgumentException("Only mailables may be queued.");
+ throw new InvalidArgumentException('Only mailables may be queued.');
}
return $view->later($delay, $this->queue); | true |
Other | laravel | framework | 44958f04b0c3eacd8ebc8b19602511438f7fbbec.json | Apply fixes from StyleCI (#16889) | src/Illuminate/Mail/Transport/MailgunTransport.php | @@ -3,7 +3,6 @@
namespace Illuminate\Mail\Transport;
use Swift_Mime_Message;
-use GuzzleHttp\Post\PostFile;
use GuzzleHttp\ClientInterface;
class MailgunTransport extends Transport
@@ -77,7 +76,7 @@ protected function payload(Swift_Mime_Message $message)
{
return [
'auth' => [
- 'api' => $this->key
+ 'api' => $this->key,
],
'multipart' => [
[
@@ -87,7 +86,7 @@ protected function payload(Swift_Mime_Message $message)
[
'name' => 'message',
'contents' => $message->toString(),
- 'filename' => 'message.mime'
+ 'filename' => 'message.mime',
],
],
]; | true |
Other | laravel | framework | dd778cbd536bcd9bb23df1d7354f7d298cd1f7a7.json | Pass keys to Collection::unique callback (#16883) | src/Illuminate/Support/Collection.php | @@ -1142,12 +1142,12 @@ public function unique($key = null, $strict = false)
return new static(array_unique($this->items, SORT_REGULAR));
}
- $key = $this->valueRetriever($key);
+ $callback = $this->valueRetriever($key);
$exists = [];
- return $this->reject(function ($item) use ($key, $strict, &$exists) {
- if (in_array($id = $key($item), $exists, $strict)) {
+ return $this->reject(function ($item, $key) use ($callback, $strict, &$exists) {
+ if (in_array($id = $callback($item, $key), $exists, $strict)) {
return true;
}
| true |
Other | laravel | framework | dd778cbd536bcd9bb23df1d7354f7d298cd1f7a7.json | Pass keys to Collection::unique callback (#16883) | tests/Support/SupportCollectionTest.php | @@ -556,9 +556,12 @@ public function testUnique()
public function testUniqueWithCallback()
{
$c = new Collection([
- 1 => ['id' => 1, 'first' => 'Taylor', 'last' => 'Otwell'], 2 => ['id' => 2, 'first' => 'Taylor', 'last' => 'Otwell'],
- 3 => ['id' => 3, 'first' => 'Abigail', 'last' => 'Otwell'], 4 => ['id' => 4, 'first' => 'Abigail', 'last' => 'Otwell'],
- 5 => ['id' => 5, 'first' => 'Taylor', 'last' => 'Swift'], 6 => ['id' => 6, 'first' => 'Taylor', 'last' => 'Swift'],
+ 1 => ['id' => 1, 'first' => 'Taylor', 'last' => 'Otwell'],
+ 2 => ['id' => 2, 'first' => 'Taylor', 'last' => 'Otwell'],
+ 3 => ['id' => 3, 'first' => 'Abigail', 'last' => 'Otwell'],
+ 4 => ['id' => 4, 'first' => 'Abigail', 'last' => 'Otwell'],
+ 5 => ['id' => 5, 'first' => 'Taylor', 'last' => 'Swift'],
+ 6 => ['id' => 6, 'first' => 'Taylor', 'last' => 'Swift'],
]);
$this->assertEquals([
@@ -573,6 +576,13 @@ public function testUniqueWithCallback()
], $c->unique(function ($item) {
return $item['first'].$item['last'];
})->all());
+
+ $this->assertEquals([
+ 1 => ['id' => 1, 'first' => 'Taylor', 'last' => 'Otwell'],
+ 2 => ['id' => 2, 'first' => 'Taylor', 'last' => 'Otwell'],
+ ], $c->unique(function ($item, $key) {
+ return $key % 2;
+ })->all());
}
public function testUniqueStrict() | true |
Other | laravel | framework | dcd64b6c36d1e545c1c2612764ec280c47fdea97.json | add queueable to queued listener stub | src/Illuminate/Foundation/Console/stubs/listener-queued.stub | @@ -3,12 +3,13 @@
namespace DummyNamespace;
use DummyFullEvent;
+use Illuminate\Bus\Queueable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class DummyClass implements ShouldQueue
{
- use InteractsWithQueue;
+ use InteractsWithQueue, Queueable;
/**
* Create the event listener. | false |
Other | laravel | framework | 1b05c8d1874a0bb444daf48e4f477045c9c08c20.json | Add missing composer dependency
Trying to use `illuminate/notifications` alone doesn't install `illuminate/queue` which is mandatory for notifications to function.
Getting this error instead: `PHP Fatal error: Trait 'Illuminate\Queue\SerializesModels' not found in /vendor/illuminate/notifications/Notification.php on line 9`. This PR fix it | src/Illuminate/Notifications/composer.json | @@ -17,6 +17,7 @@
"php": ">=5.6.4",
"illuminate/broadcasting": "5.3.*",
"illuminate/bus": "5.3.*",
+ "illuminate/queue": "5.3.*",
"illuminate/contracts": "5.3.*",
"illuminate/support": "5.3.*",
"ramsey/uuid": "~3.0" | false |
Other | laravel | framework | 7790c83208ac98fd15e6bf042b2ef881d61dc381.json | Add nullable morph columns | src/Illuminate/Database/Schema/Blueprint.php | @@ -901,6 +901,22 @@ public function morphs($name, $indexName = null)
$this->index(["{$name}_id", "{$name}_type"], $indexName);
}
+ /**
+ * Add nullable proper columns for a polymorphic table.
+ *
+ * @param string $name
+ * @param string|null $indexName
+ * @return void
+ */
+ public function nullableMorphs($name, $indexName = null)
+ {
+ $this->unsignedInteger("{$name}_id")->nullable();
+
+ $this->string("{$name}_type")->nullable();
+
+ $this->index(["{$name}_id", "{$name}_type"], $indexName);
+ }
+
/**
* Adds the `remember_token` column to the table.
* | false |
Other | laravel | framework | eb50ed3a69950f337459ff9b45e3916d96801d84.json | Apply fixes from StyleCI (#16878) | src/Illuminate/Log/Writer.php | @@ -10,8 +10,8 @@
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\ErrorLogHandler;
use Monolog\Logger as MonologLogger;
-use Monolog\Handler\RotatingFileHandler;
use Illuminate\Log\Events\MessageLogged;
+use Monolog\Handler\RotatingFileHandler;
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Contracts\Support\Arrayable; | false |
Other | laravel | framework | e83703e49862f62246b49a74b42ca03422b8d995.json | Apply fixes from StyleCI (#16876) | src/Illuminate/Http/Concerns/InteractsWithInput.php | @@ -6,7 +6,6 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Http\UploadedFile;
-use Symfony\Component\HttpFoundation\ParameterBag;
trait InteractsWithInput
{ | true |
Other | laravel | framework | e83703e49862f62246b49a74b42ca03422b8d995.json | Apply fixes from StyleCI (#16876) | src/Illuminate/Http/Request.php | @@ -4,7 +4,6 @@
use Closure;
use ArrayAccess;
-use SplFileInfo;
use RuntimeException;
use Illuminate\Support\Arr;
use Illuminate\Support\Str; | true |
Other | laravel | framework | b856355d162e35b249bf05e85ec454f289e59928.json | Fix exception message. | src/Illuminate/Foundation/Testing/WithoutMiddleware.php | @@ -16,7 +16,7 @@ public function disableMiddlewareForAllTests()
if (method_exists($this, 'withoutMiddleware')) {
$this->withoutMiddleware();
} else {
- throw new Exception('Unable to disable middleware. CrawlerTrait not used.');
+ throw new Exception('Unable to disable middleware. MakesHttpRequests trait not used.');
}
}
} | false |
Other | laravel | framework | 0f2b3be9b8753ba2813595f9191aa8d8c31886b1.json | Remove function that is no longer used. | src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php | @@ -69,25 +69,6 @@ protected function loadRoutes()
$this->app->call([$this, 'map']);
}
- /**
- * Load the standard routes file for the application.
- *
- * @param string $path
- * @return mixed
- */
- protected function loadRoutesFrom($path)
- {
- $router = $this->app->make(Router::class);
-
- if (is_null($this->namespace)) {
- return require $path;
- }
-
- $router->group(['namespace' => $this->namespace], function (Router $router) use ($path) {
- require $path;
- });
- }
-
/**
* Register the service provider.
* | false |
Other | laravel | framework | 87bd2a9e6c79715a9c73ca6134074919ede1a0e7.json | Remove unneeded provider. | src/Illuminate/Queue/ConsoleServiceProvider.php | @@ -1,61 +0,0 @@
-<?php
-
-namespace Illuminate\Queue;
-
-use Illuminate\Support\ServiceProvider;
-use Illuminate\Queue\Console\RetryCommand;
-use Illuminate\Queue\Console\ListFailedCommand;
-use Illuminate\Queue\Console\FlushFailedCommand;
-use Illuminate\Queue\Console\ForgetFailedCommand;
-
-class ConsoleServiceProvider extends ServiceProvider
-{
- /**
- * Indicates if loading of the provider is deferred.
- *
- * @var bool
- */
- protected $defer = true;
-
- /**
- * Register the service provider.
- *
- * @return void
- */
- public function register()
- {
- $this->app->singleton('command.queue.failed', function () {
- return new ListFailedCommand;
- });
-
- $this->app->singleton('command.queue.retry', function () {
- return new RetryCommand;
- });
-
- $this->app->singleton('command.queue.forget', function () {
- return new ForgetFailedCommand;
- });
-
- $this->app->singleton('command.queue.flush', function () {
- return new FlushFailedCommand;
- });
-
- $this->commands(
- 'command.queue.failed', 'command.queue.retry',
- 'command.queue.forget', 'command.queue.flush'
- );
- }
-
- /**
- * Get the services provided by the provider.
- *
- * @return array
- */
- public function provides()
- {
- return [
- 'command.queue.failed', 'command.queue.retry',
- 'command.queue.forget', 'command.queue.flush',
- ];
- }
-} | false |
Other | laravel | framework | 15db4cb8da2c4ab594c86fec7c6bd0e689a22e8e.json | Apply fixes from StyleCI (#16872) | src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php | @@ -14,10 +14,10 @@
use Illuminate\Queue\Console\FailedTableCommand;
use Illuminate\Foundation\Console\AppNameCommand;
use Illuminate\Foundation\Console\JobMakeCommand;
+use Illuminate\Database\Console\Seeds\SeedCommand;
use Illuminate\Foundation\Console\MailMakeCommand;
use Illuminate\Foundation\Console\OptimizeCommand;
use Illuminate\Foundation\Console\TestMakeCommand;
-use Illuminate\Database\Console\Seeds\SeedCommand;
use Illuminate\Foundation\Console\EventMakeCommand;
use Illuminate\Foundation\Console\ModelMakeCommand;
use Illuminate\Foundation\Console\RouteListCommand;
@@ -218,7 +218,6 @@ protected function registerCacheForgetCommand()
});
}
-
/**
* Register the command.
* | false |
Other | laravel | framework | b62983efea2bdc01b7ea0ec0c102ac7ccb3b4c7f.json | Use newer syntax | src/Illuminate/Foundation/Http/Kernel.php | @@ -34,12 +34,12 @@ class Kernel implements KernelContract
* @var array
*/
protected $bootstrappers = [
- 'Illuminate\Foundation\Bootstrap\DetectEnvironment',
- 'Illuminate\Foundation\Bootstrap\LoadConfiguration',
- 'Illuminate\Foundation\Bootstrap\HandleExceptions',
- 'Illuminate\Foundation\Bootstrap\RegisterFacades',
- 'Illuminate\Foundation\Bootstrap\RegisterProviders',
- 'Illuminate\Foundation\Bootstrap\BootProviders',
+ \Illuminate\Foundation\Bootstrap\DetectEnvironment::class,
+ \Illuminate\Foundation\Bootstrap\LoadConfiguration::class,
+ \Illuminate\Foundation\Bootstrap\HandleExceptions::class,
+ \Illuminate\Foundation\Bootstrap\RegisterFacades::class,
+ \Illuminate\Foundation\Bootstrap\RegisterProviders::class,
+ \Illuminate\Foundation\Bootstrap\BootProviders::class,
];
/** | false |
Other | laravel | framework | 730daa7dce9e069fed832e19cbdb1c23d6864b80.json | Apply fixes from StyleCI (#16841) | src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php | @@ -4,7 +4,6 @@
use Illuminate\Config\Repository;
use Symfony\Component\Finder\Finder;
-use Symfony\Component\Finder\SplFileInfo;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Config\Repository as RepositoryContract;
| false |
Other | laravel | framework | 9c033c21f32ef6a545ed49ed939d4fbd4b950aab.json | Apply fixes from StyleCI (#16837) | src/Illuminate/Hashing/BcryptHasher.php | @@ -63,7 +63,7 @@ public function check($value, $hashedValue, array $options = [])
public function needsRehash($hashedValue, array $options = [])
{
return password_needs_rehash($hashedValue, PASSWORD_BCRYPT, [
- 'cost' => isset($options['rounds']) ? $options['rounds'] : $this->rounds
+ 'cost' => isset($options['rounds']) ? $options['rounds'] : $this->rounds,
]);
}
| false |
Other | laravel | framework | 528551536aab0ec08e297f443cbfca1f870aeadb.json | Apply fixes from StyleCI (#16822) | src/Illuminate/Events/Dispatcher.php | @@ -305,7 +305,6 @@ protected function sortListeners($eventName)
$listeners = isset($this->listeners[$eventName])
? $this->listeners[$eventName] : [];
-
if (class_exists($eventName, false)) {
$listeners = $this->addInterfaceListeners($eventName, $listeners);
} | false |
Other | laravel | framework | 7b1474dcef74d1d0dd6bce8b73779c5508ed6be7.json | Add reply-to on config for Mailer | src/Illuminate/Mail/MailServiceProvider.php | @@ -47,7 +47,7 @@ public function register()
if (is_array($to) && isset($to['address'])) {
$mailer->alwaysTo($to['address'], $to['name']);
}
-
+
$replyTo = $app['config']['mail.reply-to'];
if (is_array($replyTo) && isset($replyTo['address'])) { | true |
Other | laravel | framework | 7b1474dcef74d1d0dd6bce8b73779c5508ed6be7.json | Add reply-to on config for Mailer | src/Illuminate/Mail/Mailer.php | @@ -51,7 +51,7 @@ class Mailer implements MailerContract, MailQueueContract
* @var array
*/
protected $to;
-
+
/**
* The global reply-to address and name.
*
@@ -118,7 +118,7 @@ public function alwaysTo($address, $name = null)
{
$this->to = compact('address', 'name');
}
-
+
/**
* Set the global reply-to address and name.
*
@@ -435,7 +435,7 @@ protected function createMessage()
if (! empty($this->from['address'])) {
$message->from($this->from['address'], $this->from['name']);
}
-
+
// If a global reply-to address has been specified we will set it on every message
// instances so the developer does not have to repeat themselves every time
// they create a new message. We will just go ahead and push the address. | true |
Other | laravel | framework | 4f3813069fc00a595673afb4a074d18002aa1c06.json | Add reply-to on config for Mailer | src/Illuminate/Mail/MailServiceProvider.php | @@ -47,6 +47,12 @@ public function register()
if (is_array($to) && isset($to['address'])) {
$mailer->alwaysTo($to['address'], $to['name']);
}
+
+ $replyTo = $app['config']['mail.reply-to'];
+
+ if (is_array($replyTo) && isset($replyTo['address'])) {
+ $mailer->alwaysReplyTo($replyTo['address'], $replyTo['name']);
+ }
return $mailer;
}); | true |
Other | laravel | framework | 4f3813069fc00a595673afb4a074d18002aa1c06.json | Add reply-to on config for Mailer | src/Illuminate/Mail/Mailer.php | @@ -51,6 +51,13 @@ class Mailer implements MailerContract, MailQueueContract
* @var array
*/
protected $to;
+
+ /**
+ * The global reply-to address and name.
+ *
+ * @var array
+ */
+ protected $replyTo;
/**
* The IoC container instance.
@@ -111,6 +118,18 @@ public function alwaysTo($address, $name = null)
{
$this->to = compact('address', 'name');
}
+
+ /**
+ * Set the global reply-to address and name.
+ *
+ * @param string $address
+ * @param string|null $name
+ * @return void
+ */
+ public function alwaysReplyTo($address, $name = null)
+ {
+ $this->replyTo = compact('address', 'name');
+ }
/**
* Begin the process of mailing a mailable class instance.
@@ -416,6 +435,13 @@ protected function createMessage()
if (! empty($this->from['address'])) {
$message->from($this->from['address'], $this->from['name']);
}
+
+ // If a global reply-to address has been specified we will set it on every message
+ // instances so the developer does not have to repeat themselves every time
+ // they create a new message. We will just go ahead and push the address.
+ if (! empty($this->replyTo['address'])) {
+ $message->replyTo($this->replyTo['address'], $this->replyTo['name']);
+ }
return $message;
} | true |
Other | laravel | framework | 42a851a3df17cfa8ea0fd81fa0bf4a2af4c1061a.json | Scheduler Improvements (#16806)
This PR adds improvements to the scheduler. Previously, when ->runInBackground() was used "after" hooks were not run, meaning output was not e-mailed to the developer (when using emailOutputTo.
This change provides a new, hidden schedule:finish command that is used to fire the after callbacks for a given command by its mutex name. This command will not show in the Artisan console command list since it uses the hidden command feature which is new in Symfony 3.2. | src/Illuminate/Console/Command.php | @@ -57,6 +57,13 @@ class Command extends SymfonyCommand
*/
protected $description;
+ /**
+ * Indicates whether the command should be shown in the Artisan command list.
+ *
+ * @var bool
+ */
+ protected $hidden = false;
+
/**
* The default verbosity of output commands.
*
@@ -95,6 +102,8 @@ public function __construct()
$this->setDescription($this->description);
+ $this->setHidden($this->hidden);
+
if (! isset($this->signature)) {
$this->specifyParameters();
} | true |
Other | laravel | framework | 42a851a3df17cfa8ea0fd81fa0bf4a2af4c1061a.json | Scheduler Improvements (#16806)
This PR adds improvements to the scheduler. Previously, when ->runInBackground() was used "after" hooks were not run, meaning output was not e-mailed to the developer (when using emailOutputTo.
This change provides a new, hidden schedule:finish command that is used to fire the after callbacks for a given command by its mutex name. This command will not show in the Artisan console command list since it uses the hidden command feature which is new in Symfony 3.2. | src/Illuminate/Console/ScheduleServiceProvider.php | @@ -20,7 +20,10 @@ class ScheduleServiceProvider extends ServiceProvider
*/
public function register()
{
- $this->commands('Illuminate\Console\Scheduling\ScheduleRunCommand');
+ $this->commands([
+ 'Illuminate\Console\Scheduling\ScheduleRunCommand',
+ 'Illuminate\Console\Scheduling\ScheduleFinishCommand',
+ ]);
}
/**
@@ -32,6 +35,7 @@ public function provides()
{
return [
'Illuminate\Console\Scheduling\ScheduleRunCommand',
+ 'Illuminate\Console\Scheduling\ScheduleFinishCommand',
];
}
} | true |
Other | laravel | framework | 42a851a3df17cfa8ea0fd81fa0bf4a2af4c1061a.json | Scheduler Improvements (#16806)
This PR adds improvements to the scheduler. Previously, when ->runInBackground() was used "after" hooks were not run, meaning output was not e-mailed to the developer (when using emailOutputTo.
This change provides a new, hidden schedule:finish command that is used to fire the after callbacks for a given command by its mutex name. This command will not show in the Artisan console command list since it uses the hidden command feature which is new in Symfony 3.2. | src/Illuminate/Console/Scheduling/CommandBuilder.php | @@ -0,0 +1,69 @@
+<?php
+
+namespace Illuminate\Console\Scheduling;
+
+use Illuminate\Console\Application;
+use Symfony\Component\Process\ProcessUtils;
+
+class CommandBuilder
+{
+ /**
+ * Build the command for the given event.
+ *
+ * @param \Illuminate\Console\Scheduling\Event $event
+ * @return string
+ */
+ public function buildCommand(Event $event)
+ {
+ if ($event->runInBackground) {
+ return $this->buildBackgroundCommand($event);
+ } else {
+ return $this->buildForegroundCommand($event);
+ }
+ }
+
+ /**
+ * Build the command for running the event in the foreground.
+ *
+ * @param \Illuminate\Console\Scheduling\Event $event
+ * @return string
+ */
+ protected function buildForegroundCommand(Event $event)
+ {
+ $output = ProcessUtils::escapeArgument($event->output);
+
+ return $this->finalize($event, $event->command.($event->shouldAppendOutput ? ' >> ' : ' > ').$output.' 2>&1');
+ }
+
+ /**
+ * Build the command for running the event in the foreground.
+ *
+ * @param \Illuminate\Console\Scheduling\Event $event
+ * @return string
+ */
+ protected function buildBackgroundCommand(Event $event)
+ {
+ $output = ProcessUtils::escapeArgument($event->output);
+
+ $redirect = $event->shouldAppendOutput ? ' >> ' : ' > ';
+
+ $finished = Application::formatCommandString('schedule:finish').' "'.$event->mutexName().'"';
+
+ return $this->finalize($event,
+ '('.$event->command.$redirect.$output.' 2>&1 '.(windows_os() ? '&' : ';').' '.$finished.') > '
+ .ProcessUtils::escapeArgument($event->getDefaultOutput()).' 2>&1 &'
+ );
+ }
+
+ /**
+ * Finalize the event's command syntax.
+ *
+ * @param \Illuminate\Console\Scheduling\Event $event
+ * @param string $command
+ * @return string
+ */
+ protected function finalize(Event $event, $command)
+ {
+ return $event->user && ! windows_os() ? 'sudo -u '.$event->user.' -- sh -c \''.$command.'\'' : $command;
+ }
+} | true |
Other | laravel | framework | 42a851a3df17cfa8ea0fd81fa0bf4a2af4c1061a.json | Scheduler Improvements (#16806)
This PR adds improvements to the scheduler. Previously, when ->runInBackground() was used "after" hooks were not run, meaning output was not e-mailed to the developer (when using emailOutputTo.
This change provides a new, hidden schedule:finish command that is used to fire the after callbacks for a given command by its mutex name. This command will not show in the Artisan console command list since it uses the hidden command feature which is new in Symfony 3.2. | src/Illuminate/Console/Scheduling/Event.php | @@ -6,11 +6,9 @@
use Carbon\Carbon;
use LogicException;
use Cron\CronExpression;
-use Illuminate\Console\Application;
use GuzzleHttp\Client as HttpClient;
use Illuminate\Contracts\Mail\Mailer;
use Symfony\Component\Process\Process;
-use Symfony\Component\Process\ProcessUtils;
use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\Cache\Repository as Cache;
@@ -107,7 +105,7 @@ class Event
*
* @var bool
*/
- protected $shouldAppendOutput = false;
+ public $shouldAppendOutput = false;
/**
* The array of callbacks to be run before the event is started.
@@ -149,7 +147,7 @@ public function __construct(Cache $cache, $command)
*
* @return string
*/
- protected function getDefaultOutput()
+ public function getDefaultOutput()
{
return (DIRECTORY_SEPARATOR == '\\') ? 'NUL' : '/dev/null';
}
@@ -167,7 +165,7 @@ public function run(Container $container)
}
if ($this->runInBackground) {
- $this->runCommandInBackground();
+ $this->runCommandInBackground($container);
} else {
$this->runCommandInForeground($container);
}
@@ -193,10 +191,13 @@ protected function runCommandInForeground(Container $container)
/**
* Run the command in the background.
*
+ * @param \Illuminate\Contracts\Container\Container $container
* @return void
*/
- protected function runCommandInBackground()
+ protected function runCommandInBackground(Container $container)
{
+ $this->callBeforeCallbacks($container);
+
(new Process(
$this->buildCommand(), base_path(), null, null, null
))->run();
@@ -208,7 +209,7 @@ protected function runCommandInBackground()
* @param \Illuminate\Contracts\Container\Container $container
* @return void
*/
- protected function callBeforeCallbacks(Container $container)
+ public function callBeforeCallbacks(Container $container)
{
foreach ($this->beforeCallbacks as $callback) {
$container->call($callback);
@@ -221,7 +222,7 @@ protected function callBeforeCallbacks(Container $container)
* @param \Illuminate\Contracts\Container\Container $container
* @return void
*/
- protected function callAfterCallbacks(Container $container)
+ public function callAfterCallbacks(Container $container)
{
foreach ($this->afterCallbacks as $callback) {
$container->call($callback);
@@ -235,31 +236,15 @@ protected function callAfterCallbacks(Container $container)
*/
public function buildCommand()
{
- $output = ProcessUtils::escapeArgument($this->output);
-
- $redirect = $this->shouldAppendOutput ? ' >> ' : ' > ';
-
- if ($this->withoutOverlapping) {
- $forget = Application::formatCommandString('cache:forget');
-
- if (windows_os()) {
- $command = '('.$this->command.' & '.$forget.' "'.$this->mutexName().'")'.$redirect.$output.' 2>&1 &';
- } else {
- $command = '('.$this->command.'; '.$forget.' '.$this->mutexName().')'.$redirect.$output.' 2>&1 &';
- }
- } else {
- $command = $this->command.$redirect.$output.' 2>&1 &';
- }
-
- return $this->user && ! windows_os() ? 'sudo -u '.$this->user.' -- sh -c \''.$command.'\'' : $command;
+ return (new CommandBuilder)->buildCommand($this);
}
/**
* Get the mutex name for the scheduled command.
*
* @return string
*/
- protected function mutexName()
+ public function mutexName()
{
return 'framework'.DIRECTORY_SEPARATOR.'schedule-'.sha1($this->expression.$this->command);
}
@@ -399,7 +384,9 @@ public function withoutOverlapping()
{
$this->withoutOverlapping = true;
- return $this->skip(function () {
+ return $this->then(function () {
+ $this->cache->forget($this->mutexName());
+ })->skip(function () {
return $this->cache->has($this->mutexName());
});
} | true |
Other | laravel | framework | 42a851a3df17cfa8ea0fd81fa0bf4a2af4c1061a.json | Scheduler Improvements (#16806)
This PR adds improvements to the scheduler. Previously, when ->runInBackground() was used "after" hooks were not run, meaning output was not e-mailed to the developer (when using emailOutputTo.
This change provides a new, hidden schedule:finish command that is used to fire the after callbacks for a given command by its mutex name. This command will not show in the Artisan console command list since it uses the hidden command feature which is new in Symfony 3.2. | src/Illuminate/Console/Scheduling/ScheduleFinishCommand.php | @@ -0,0 +1,61 @@
+<?php
+
+namespace Illuminate\Console\Scheduling;
+
+use Illuminate\Console\Command;
+
+class ScheduleFinishCommand extends Command
+{
+ /**
+ * The console command name.
+ *
+ * @var string
+ */
+ protected $signature = 'schedule:finish {id}';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Handle the completion of a scheduled command';
+
+ /**
+ * Indicates whether the command should be shown in the Artisan command list.
+ *
+ * @var bool
+ */
+ protected $hidden = true;
+
+ /**
+ * The schedule instance.
+ *
+ * @var \Illuminate\Console\Scheduling\Schedule
+ */
+ protected $schedule;
+
+ /**
+ * Create a new command instance.
+ *
+ * @param \Illuminate\Console\Scheduling\Schedule $schedule
+ * @return void
+ */
+ public function __construct(Schedule $schedule)
+ {
+ $this->schedule = $schedule;
+
+ parent::__construct();
+ }
+
+ /**
+ * Execute the console command.
+ *
+ * @return void
+ */
+ public function fire()
+ {
+ collect($this->schedule->events())->filter(function ($value) {
+ return $value->mutexName() == $this->argument('id');
+ })->each->callAfterCallbacks($this->laravel);
+ }
+} | true |
Other | laravel | framework | 42a851a3df17cfa8ea0fd81fa0bf4a2af4c1061a.json | Scheduler Improvements (#16806)
This PR adds improvements to the scheduler. Previously, when ->runInBackground() was used "after" hooks were not run, meaning output was not e-mailed to the developer (when using emailOutputTo.
This change provides a new, hidden schedule:finish command that is used to fire the after callbacks for a given command by its mutex name. This command will not show in the Artisan console command list since it uses the hidden command feature which is new in Symfony 3.2. | tests/Console/Scheduling/EventTest.php | @@ -17,7 +17,15 @@ public function testBuildCommand()
$event = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php -i');
$defaultOutput = (DIRECTORY_SEPARATOR == '\\') ? 'NUL' : '/dev/null';
- $this->assertSame("php -i > {$quote}{$defaultOutput}{$quote} 2>&1 &", $event->buildCommand());
+ $this->assertSame("php -i > {$quote}{$defaultOutput}{$quote} 2>&1", $event->buildCommand());
+
+ $quote = (DIRECTORY_SEPARATOR == '\\') ? '"' : "'";
+
+ $event = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php -i');
+ $event->runInBackground();
+
+ $defaultOutput = (DIRECTORY_SEPARATOR == '\\') ? 'NUL' : '/dev/null';
+ $this->assertSame("(php -i > {$quote}{$defaultOutput}{$quote} 2>&1 ; '".PHP_BINARY."' artisan schedule:finish \"framework/schedule-c65b1c374c37056e0c57fccb0c08d724ce6f5043\") > {$quote}{$defaultOutput}{$quote} 2>&1 &", $event->buildCommand());
}
public function testBuildCommandSendOutputTo()
@@ -27,12 +35,12 @@ public function testBuildCommandSendOutputTo()
$event = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php -i');
$event->sendOutputTo('/dev/null');
- $this->assertSame("php -i > {$quote}/dev/null{$quote} 2>&1 &", $event->buildCommand());
+ $this->assertSame("php -i > {$quote}/dev/null{$quote} 2>&1", $event->buildCommand());
$event = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php -i');
$event->sendOutputTo('/my folder/foo.log');
- $this->assertSame("php -i > {$quote}/my folder/foo.log{$quote} 2>&1 &", $event->buildCommand());
+ $this->assertSame("php -i > {$quote}/my folder/foo.log{$quote} 2>&1", $event->buildCommand());
}
public function testBuildCommandAppendOutput()
@@ -42,7 +50,7 @@ public function testBuildCommandAppendOutput()
$event = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php -i');
$event->appendOutputTo('/dev/null');
- $this->assertSame("php -i >> {$quote}/dev/null{$quote} 2>&1 &", $event->buildCommand());
+ $this->assertSame("php -i >> {$quote}/dev/null{$quote} 2>&1", $event->buildCommand());
}
/** | true |
Other | laravel | framework | e0e3220ac9436ba94795d850ca07ca7fd766f86b.json | Guess policy method from class name | src/Illuminate/Foundation/Auth/Access/AuthorizesRequests.php | @@ -48,7 +48,7 @@ public function authorizeForUser($user, $ability, $arguments = [])
*/
protected function parseAbilityAndArguments($ability, $arguments)
{
- if (is_string($ability)) {
+ if (is_string($ability) && (! class_exists($ability))) {
return [$ability, $arguments];
}
| true |
Other | laravel | framework | e0e3220ac9436ba94795d850ca07ca7fd766f86b.json | Guess policy method from class name | tests/Foundation/FoundationAuthorizesRequestsTraitTest.php | @@ -14,13 +14,13 @@ public function test_basic_gate_check()
$gate = $this->getBasicGate();
- $gate->define('foo', function () {
+ $gate->define('baz', function () {
$_SERVER['_test.authorizes.trait'] = true;
return true;
});
- $response = (new FoundationTestAuthorizeTraitClass)->authorize('foo');
+ $response = (new FoundationTestAuthorizeTraitClass)->authorize('baz');
$this->assertInstanceOf(Response::class, $response);
$this->assertTrue($_SERVER['_test.authorizes.trait']);
@@ -33,11 +33,11 @@ public function test_exception_is_thrown_if_gate_check_fails()
{
$gate = $this->getBasicGate();
- $gate->define('foo', function () {
+ $gate->define('baz', function () {
return false;
});
- (new FoundationTestAuthorizeTraitClass)->authorize('foo');
+ (new FoundationTestAuthorizeTraitClass)->authorize('baz');
}
public function test_policies_may_be_called()
@@ -54,15 +54,29 @@ public function test_policies_may_be_called()
$this->assertTrue($_SERVER['_test.authorizes.trait.policy']);
}
- public function test_policy_method_may_be_guessed()
+ public function test_policy_method_may_be_guessed_passing_model_instance()
{
unset($_SERVER['_test.authorizes.trait.policy']);
$gate = $this->getBasicGate();
$gate->policy(FoundationAuthorizesRequestTestClass::class, FoundationAuthorizesRequestTestPolicy::class);
- $response = (new FoundationTestAuthorizeTraitClass)->authorize([new FoundationAuthorizesRequestTestClass]);
+ $response = (new FoundationTestAuthorizeTraitClass)->authorize(new FoundationAuthorizesRequestTestClass);
+
+ $this->assertInstanceOf(Response::class, $response);
+ $this->assertTrue($_SERVER['_test.authorizes.trait.policy']);
+ }
+
+ public function test_policy_method_may_be_guessed_passing_class_name()
+ {
+ unset($_SERVER['_test.authorizes.trait.policy']);
+
+ $gate = $this->getBasicGate();
+
+ $gate->policy(FoundationAuthorizesRequestTestClass::class, FoundationAuthorizesRequestTestPolicy::class);
+
+ $response = (new FoundationTestAuthorizeTraitClass)->authorize(FoundationAuthorizesRequestTestClass::class);
$this->assertInstanceOf(Response::class, $response);
$this->assertTrue($_SERVER['_test.authorizes.trait.policy']);
@@ -115,7 +129,14 @@ public function update()
return true;
}
- public function test_policy_method_may_be_guessed()
+ public function test_policy_method_may_be_guessed_passing_model_instance()
+ {
+ $_SERVER['_test.authorizes.trait.policy'] = true;
+
+ return true;
+ }
+
+ public function test_policy_method_may_be_guessed_passing_class_name()
{
$_SERVER['_test.authorizes.trait.policy'] = true;
| true |
Other | laravel | framework | 33b508e88e322c9330908a3a2145623ae6676377.json | change method order | src/Illuminate/Container/Container.php | @@ -243,38 +243,14 @@ protected function getClosure($abstract, $concrete)
* Bind a callback to resolve with Container::call.
*
* @param string $method
- * @param \Closure $concrete
+ * @param \Closure $callback
* @return void
*/
public function bindMethod($method, $callback)
{
$this->methodBindings[$this->normalize($method)] = $callback;
}
- /**
- * Call a method that has been bound to the container.
- *
- * @param callable $callback
- * @param mixed $default
- * @return mixed
- */
- protected function callBoundMethod($callback, $default)
- {
- if (! is_array($callback)) {
- return value($default);
- }
-
- $class = is_string($callback[0]) ? $callback[0] : get_class($callback[0]);
-
- $method = $this->normalize("{$class}@{$callback[1]}");
-
- if (! isset($this->methodBindings[$method])) {
- return value($default);
- }
-
- return $this->methodBindings[$method]($callback[0], $this);
- }
-
/**
* Add a contextual binding to the container.
*
@@ -648,6 +624,30 @@ protected function callClass($target, array $parameters = [], $defaultMethod = n
return $this->call([$this->make($segments[0]), $method], $parameters);
}
+ /**
+ * Call a method that has been bound to the container.
+ *
+ * @param callable $callback
+ * @param mixed $default
+ * @return mixed
+ */
+ protected function callBoundMethod($callback, $default)
+ {
+ if (! is_array($callback)) {
+ return value($default);
+ }
+
+ $class = is_string($callback[0]) ? $callback[0] : get_class($callback[0]);
+
+ $method = $this->normalize("{$class}@{$callback[1]}");
+
+ if (! isset($this->methodBindings[$method])) {
+ return value($default);
+ }
+
+ return $this->methodBindings[$method]($callback[0], $this);
+ }
+
/**
* Get a closure to resolve the given type from the container.
* | false |
Other | laravel | framework | a153c59ae7d9c254b2c17eb321066f6b4da32f33.json | Apply Style CI fixes | src/Illuminate/Container/Container.php | @@ -240,7 +240,7 @@ protected function getClosure($abstract, $concrete)
}
/**
- * Bind a callback to resolve with Container::call
+ * Bind a callback to resolve with Container::call.
*
* @param string $method
* @param \Closure $concrete
@@ -252,23 +252,23 @@ public function bindMethod($method, $callback)
}
/**
- * Call a method that has been bound to the container
+ * Call a method that has been bound to the container.
*
* @param callable $callback
* @param mixed $default
* @return mixed
*/
protected function callBoundMethod($callback, $default)
{
- if (!is_array($callback)) {
+ if (! is_array($callback)) {
return value($default);
}
$class = is_string($callback[0]) ? $callback[0] : get_class($callback[0]);
$method = $this->normalize("{$class}@{$callback[1]}");
- if (!isset($this->methodBindings[$method])) {
+ if (! isset($this->methodBindings[$method])) {
return value($default);
}
@@ -548,6 +548,7 @@ public function call($callback, array $parameters = [], $defaultMethod = null)
return $this->callBoundMethod($callback, function () use ($callback, $parameters) {
$dependencies = $this->getMethodDependencies($callback, $parameters);
+
return call_user_func_array($callback, $dependencies);
});
} | false |
Other | laravel | framework | 45306f63049eaa6e49b695e6a162ceb8e72843f0.json | Add tests for container method binding | tests/Container/ContainerTest.php | @@ -509,6 +509,23 @@ public function testCallWithGlobalMethodName()
$this->assertEquals('taylor', $result[1]);
}
+ public function testCallWithBoundMethod()
+ {
+ $container = new Container;
+ $container->bindMethod('ContainerTestCallStub@unresolvable', function ($stub) {
+ return $stub->unresolvable('foo', 'bar');
+ });
+ $result = $container->call('ContainerTestCallStub@unresolvable');
+ $this->assertEquals(['foo', 'bar'], $result);
+
+ $container = new Container;
+ $container->bindMethod('ContainerTestCallStub@unresolvable', function ($stub) {
+ return $stub->unresolvable('foo', 'bar');
+ });
+ $result = $container->call([new ContainerTestCallStub, 'unresolvable']);
+ $this->assertEquals(['foo', 'bar'], $result);
+ }
+
public function testContainerCanInjectDifferentImplementationsDependingOnContext()
{
$container = new Container;
@@ -812,6 +829,11 @@ public function inject(ContainerConcreteStub $stub, $default = 'taylor')
{
return func_get_args();
}
+
+ public function unresolvable($foo, $bar)
+ {
+ return func_get_args();
+ }
}
class ContainerTestContextInjectOne | false |
Other | laravel | framework | 8b84d293fb062f2316734bb0d1478e435cbfa49d.json | Add support for binding Class@method callbacks | src/Illuminate/Container/Container.php | @@ -36,6 +36,13 @@ class Container implements ArrayAccess, ContainerContract
*/
protected $bindings = [];
+ /**
+ * The container's method bindings.
+ *
+ * @var array
+ */
+ protected $methodBindings = [];
+
/**
* The container's shared instances.
*
@@ -232,6 +239,42 @@ protected function getClosure($abstract, $concrete)
};
}
+ /**
+ * Bind a callback to resolve with Container::call
+ *
+ * @param string $method
+ * @param \Closure $concrete
+ * @return void
+ */
+ public function bindMethod($method, $callback)
+ {
+ $this->methodBindings[$this->normalize($method)] = $callback;
+ }
+
+ /**
+ * Call a method that has been bound to the container
+ *
+ * @param callable $callback
+ * @param mixed $default
+ * @return mixed
+ */
+ protected function callBoundMethod($callback, $default)
+ {
+ if (!is_array($callback)) {
+ return value($default);
+ }
+
+ $class = is_string($callback[0]) ? $callback[0] : get_class($callback[0]);
+
+ $method = $this->normalize("{$class}@{$callback[1]}");
+
+ if (!isset($this->methodBindings[$method])) {
+ return value($default);
+ }
+
+ return $this->methodBindings[$method]($callback[0], $this);
+ }
+
/**
* Add a contextual binding to the container.
*
@@ -503,9 +546,10 @@ public function call($callback, array $parameters = [], $defaultMethod = null)
return $this->callClass($callback, $parameters, $defaultMethod);
}
- $dependencies = $this->getMethodDependencies($callback, $parameters);
-
- return call_user_func_array($callback, $dependencies);
+ return $this->callBoundMethod($callback, function () use ($callback, $parameters) {
+ $dependencies = $this->getMethodDependencies($callback, $parameters);
+ return call_user_func_array($callback, $dependencies);
+ });
}
/** | false |
Other | laravel | framework | 592e25f45689dc2fdddbdbcb97ebcbd60695f34e.json | fix style ci | src/Illuminate/Routing/Console/ControllerMakeCommand.php | @@ -2,8 +2,8 @@
namespace Illuminate\Routing\Console;
-use Illuminate\Console\GeneratorCommand;
use Illuminate\Support\Str;
+use Illuminate\Console\GeneratorCommand;
use Symfony\Component\Console\Input\InputOption;
class ControllerMakeCommand extends GeneratorCommand
@@ -37,7 +37,7 @@ class ControllerMakeCommand extends GeneratorCommand
protected function getStub()
{
if ($this->option('model')) {
- return __DIR__ . '/stubs/controller.model.stub';
+ return __DIR__.'/stubs/controller.model.stub';
} elseif ($this->option('resource')) {
return __DIR__.'/stubs/controller.stub';
}
@@ -70,18 +70,18 @@ protected function getOptions()
}
/**
- * Parses the model namespace
+ * Parses the model namespace.
*
* @param string $modelNamespace
* @return string
*/
protected function parseModel($modelNamespace)
{
if (preg_match('([^A-Za-z0-9_/\\\\])', $modelNamespace)) {
- $this->line("");
- $this->error(" ");
- $this->error(" Model name contains invalid characters ");
- $this->error(" ");
+ $this->line('');
+ $this->error(' ');
+ $this->error(' Model name contains invalid characters ');
+ $this->error(' ');
exit(1);
}
@@ -92,8 +92,8 @@ protected function parseModel($modelNamespace)
$modelNamespace = trim($modelNamespace, '\\');
$rootNamespace = $this->laravel->getNamespace();
- if (!Str::startsWith($modelNamespace, $rootNamespace)) {
- $modelNamespace = $rootNamespace . $modelNamespace;
+ if (! Str::startsWith($modelNamespace, $rootNamespace)) {
+ $modelNamespace = $rootNamespace.$modelNamespace;
}
return $modelNamespace; | false |
Other | laravel | framework | e238299f12ee91a65ac021feca29b870b05f5dd7.json | move frequency helpers into a trait | src/Illuminate/Console/Scheduling/Event.php | @@ -15,6 +15,8 @@
class Event
{
+ use ManagesFrequencies;
+
/**
* The cache store implementation.
*
@@ -337,331 +339,6 @@ public function runsInMaintenanceMode()
return $this->evenInMaintenanceMode;
}
- /**
- * The Cron expression representing the event's frequency.
- *
- * @param string $expression
- * @return $this
- */
- public function cron($expression)
- {
- $this->expression = $expression;
-
- return $this;
- }
-
- /**
- * Schedule the event to run hourly.
- *
- * @return $this
- */
- public function hourly()
- {
- return $this->spliceIntoPosition(1, 0);
- }
-
- /**
- * Schedule the event to run daily.
- *
- * @return $this
- */
- public function daily()
- {
- return $this->spliceIntoPosition(1, 0)
- ->spliceIntoPosition(2, 0);
- }
-
- /**
- * Schedule the command at a given time.
- *
- * @param string $time
- * @return $this
- */
- public function at($time)
- {
- return $this->dailyAt($time);
- }
-
- /**
- * Schedule the event to run daily at a given time (10:00, 19:30, etc).
- *
- * @param string $time
- * @return $this
- */
- public function dailyAt($time)
- {
- $segments = explode(':', $time);
-
- return $this->spliceIntoPosition(2, (int) $segments[0])
- ->spliceIntoPosition(1, count($segments) == 2 ? (int) $segments[1] : '0');
- }
-
- /**
- * Schedule the event to run twice daily.
- *
- * @param int $first
- * @param int $second
- * @return $this
- */
- public function twiceDaily($first = 1, $second = 13)
- {
- $hours = $first.','.$second;
-
- return $this->spliceIntoPosition(1, 0)
- ->spliceIntoPosition(2, $hours);
- }
-
- /**
- * Schedule the event to run only on weekdays.
- *
- * @return $this
- */
- public function weekdays()
- {
- return $this->spliceIntoPosition(5, '1-5');
- }
-
- /**
- * Schedule the event to run only on Mondays.
- *
- * @return $this
- */
- public function mondays()
- {
- return $this->days(1);
- }
-
- /**
- * Schedule the event to run only on Tuesdays.
- *
- * @return $this
- */
- public function tuesdays()
- {
- return $this->days(2);
- }
-
- /**
- * Schedule the event to run only on Wednesdays.
- *
- * @return $this
- */
- public function wednesdays()
- {
- return $this->days(3);
- }
-
- /**
- * Schedule the event to run only on Thursdays.
- *
- * @return $this
- */
- public function thursdays()
- {
- return $this->days(4);
- }
-
- /**
- * Schedule the event to run only on Fridays.
- *
- * @return $this
- */
- public function fridays()
- {
- return $this->days(5);
- }
-
- /**
- * Schedule the event to run only on Saturdays.
- *
- * @return $this
- */
- public function saturdays()
- {
- return $this->days(6);
- }
-
- /**
- * Schedule the event to run only on Sundays.
- *
- * @return $this
- */
- public function sundays()
- {
- return $this->days(0);
- }
-
- /**
- * Schedule the event to run weekly.
- *
- * @return $this
- */
- public function weekly()
- {
- return $this->spliceIntoPosition(1, 0)
- ->spliceIntoPosition(2, 0)
- ->spliceIntoPosition(5, 0);
- }
-
- /**
- * Schedule the event to run weekly on a given day and time.
- *
- * @param int $day
- * @param string $time
- * @return $this
- */
- public function weeklyOn($day, $time = '0:0')
- {
- $this->dailyAt($time);
-
- return $this->spliceIntoPosition(5, $day);
- }
-
- /**
- * Schedule the event to run monthly.
- *
- * @return $this
- */
- public function monthly()
- {
- return $this->spliceIntoPosition(1, 0)
- ->spliceIntoPosition(2, 0)
- ->spliceIntoPosition(3, 1);
- }
-
- /**
- * Schedule the event to run monthly on a given day and time.
- *
- * @param int $day
- * @param string $time
- * @return $this
- */
- public function monthlyOn($day = 1, $time = '0:0')
- {
- $this->dailyAt($time);
-
- return $this->spliceIntoPosition(3, $day);
- }
-
- /**
- * Schedule the event to run quarterly.
- *
- * @return $this
- */
- public function quarterly()
- {
- return $this->spliceIntoPosition(1, 0)
- ->spliceIntoPosition(2, 0)
- ->spliceIntoPosition(3, 1)
- ->spliceIntoPosition(4, '*/3');
- }
-
- /**
- * Schedule the event to run yearly.
- *
- * @return $this
- */
- public function yearly()
- {
- return $this->spliceIntoPosition(1, 0)
- ->spliceIntoPosition(2, 0)
- ->spliceIntoPosition(3, 1)
- ->spliceIntoPosition(4, 1);
- }
-
- /**
- * Schedule the event to run every minute.
- *
- * @return $this
- */
- public function everyMinute()
- {
- return $this->spliceIntoPosition(1, '*');
- }
-
- /**
- * Schedule the event to run every five minutes.
- *
- * @return $this
- */
- public function everyFiveMinutes()
- {
- return $this->spliceIntoPosition(1, '*/5');
- }
-
- /**
- * Schedule the event to run every ten minutes.
- *
- * @return $this
- */
- public function everyTenMinutes()
- {
- return $this->spliceIntoPosition(1, '*/10');
- }
-
- /**
- * Schedule the event to run every thirty minutes.
- *
- * @return $this
- */
- public function everyThirtyMinutes()
- {
- return $this->spliceIntoPosition(1, '0,30');
- }
-
- /**
- * Set the days of the week the command should run on.
- *
- * @param array|mixed $days
- * @return $this
- */
- public function days($days)
- {
- $days = is_array($days) ? $days : func_get_args();
-
- return $this->spliceIntoPosition(5, implode(',', $days));
- }
-
- /**
- * Schedule the event to run between start and end time.
- *
- * @param string $startTime
- * @param string $endTime
- * @return $this
- */
- public function between($startTime, $endTime)
- {
- return $this->when($this->inTimeInterval($startTime, $endTime));
- }
-
- /**
- * Schedule the event to not run between start and end time.
- *
- * @param string $startTime
- * @param string $endTime
- * @return $this
- */
- public function unlessBetween($startTime, $endTime)
- {
- return $this->skip($this->inTimeInterval($startTime, $endTime));
- }
-
- /**
- * Schedule the event to run between start and end time.
- *
- * @param string $startTime
- * @param string $endTime
- * @return \Closure
- */
- private function inTimeInterval($startTime, $endTime)
- {
- return function () use ($startTime, $endTime) {
- $now = Carbon::now()->getTimestamp();
-
- return $now >= strtotime($startTime) && $now <= strtotime($endTime);
- };
- }
-
/**
* State that the command should run in background.
*
@@ -674,19 +351,6 @@ public function runInBackground()
return $this;
}
- /**
- * Set the timezone the date should be evaluated on.
- *
- * @param \DateTimeZone|string $timezone
- * @return $this
- */
- public function timezone($timezone)
- {
- $this->timezone = $timezone;
-
- return $this;
- }
-
/**
* Set which user the command should run as.
*
@@ -953,22 +617,6 @@ public function description($description)
return $this;
}
- /**
- * Splice the given value into the given position of the expression.
- *
- * @param int $position
- * @param string $value
- * @return $this
- */
- protected function spliceIntoPosition($position, $value)
- {
- $segments = explode(' ', $this->expression);
-
- $segments[$position - 1] = $value;
-
- return $this->cron(implode(' ', $segments));
- }
-
/**
* Get the summary of the event for display.
* | true |
Other | laravel | framework | e238299f12ee91a65ac021feca29b870b05f5dd7.json | move frequency helpers into a trait | src/Illuminate/Console/Scheduling/ManagesFrequencies.php | @@ -0,0 +1,362 @@
+<?php
+
+namespace Illuminate\Console\Scheduling;
+
+use Carbon\Carbon;
+
+trait ManagesFrequencies
+{
+ /**
+ * The Cron expression representing the event's frequency.
+ *
+ * @param string $expression
+ * @return $this
+ */
+ public function cron($expression)
+ {
+ $this->expression = $expression;
+
+ return $this;
+ }
+
+ /**
+ * Schedule the event to run between start and end time.
+ *
+ * @param string $startTime
+ * @param string $endTime
+ * @return $this
+ */
+ public function between($startTime, $endTime)
+ {
+ return $this->when($this->inTimeInterval($startTime, $endTime));
+ }
+
+ /**
+ * Schedule the event to not run between start and end time.
+ *
+ * @param string $startTime
+ * @param string $endTime
+ * @return $this
+ */
+ public function unlessBetween($startTime, $endTime)
+ {
+ return $this->skip($this->inTimeInterval($startTime, $endTime));
+ }
+
+ /**
+ * Schedule the event to run between start and end time.
+ *
+ * @param string $startTime
+ * @param string $endTime
+ * @return \Closure
+ */
+ private function inTimeInterval($startTime, $endTime)
+ {
+ return function () use ($startTime, $endTime) {
+ $now = Carbon::now()->getTimestamp();
+
+ return $now >= strtotime($startTime) && $now <= strtotime($endTime);
+ };
+ }
+
+ /**
+ * Schedule the event to run hourly.
+ *
+ * @return $this
+ */
+ public function hourly()
+ {
+ return $this->spliceIntoPosition(1, 0);
+ }
+
+ /**
+ * Schedule the event to run daily.
+ *
+ * @return $this
+ */
+ public function daily()
+ {
+ return $this->spliceIntoPosition(1, 0)
+ ->spliceIntoPosition(2, 0);
+ }
+
+ /**
+ * Schedule the command at a given time.
+ *
+ * @param string $time
+ * @return $this
+ */
+ public function at($time)
+ {
+ return $this->dailyAt($time);
+ }
+
+ /**
+ * Schedule the event to run daily at a given time (10:00, 19:30, etc).
+ *
+ * @param string $time
+ * @return $this
+ */
+ public function dailyAt($time)
+ {
+ $segments = explode(':', $time);
+
+ return $this->spliceIntoPosition(2, (int) $segments[0])
+ ->spliceIntoPosition(1, count($segments) == 2 ? (int) $segments[1] : '0');
+ }
+
+ /**
+ * Schedule the event to run twice daily.
+ *
+ * @param int $first
+ * @param int $second
+ * @return $this
+ */
+ public function twiceDaily($first = 1, $second = 13)
+ {
+ $hours = $first.','.$second;
+
+ return $this->spliceIntoPosition(1, 0)
+ ->spliceIntoPosition(2, $hours);
+ }
+
+ /**
+ * Schedule the event to run only on weekdays.
+ *
+ * @return $this
+ */
+ public function weekdays()
+ {
+ return $this->spliceIntoPosition(5, '1-5');
+ }
+
+ /**
+ * Schedule the event to run only on Mondays.
+ *
+ * @return $this
+ */
+ public function mondays()
+ {
+ return $this->days(1);
+ }
+
+ /**
+ * Schedule the event to run only on Tuesdays.
+ *
+ * @return $this
+ */
+ public function tuesdays()
+ {
+ return $this->days(2);
+ }
+
+ /**
+ * Schedule the event to run only on Wednesdays.
+ *
+ * @return $this
+ */
+ public function wednesdays()
+ {
+ return $this->days(3);
+ }
+
+ /**
+ * Schedule the event to run only on Thursdays.
+ *
+ * @return $this
+ */
+ public function thursdays()
+ {
+ return $this->days(4);
+ }
+
+ /**
+ * Schedule the event to run only on Fridays.
+ *
+ * @return $this
+ */
+ public function fridays()
+ {
+ return $this->days(5);
+ }
+
+ /**
+ * Schedule the event to run only on Saturdays.
+ *
+ * @return $this
+ */
+ public function saturdays()
+ {
+ return $this->days(6);
+ }
+
+ /**
+ * Schedule the event to run only on Sundays.
+ *
+ * @return $this
+ */
+ public function sundays()
+ {
+ return $this->days(0);
+ }
+
+ /**
+ * Schedule the event to run weekly.
+ *
+ * @return $this
+ */
+ public function weekly()
+ {
+ return $this->spliceIntoPosition(1, 0)
+ ->spliceIntoPosition(2, 0)
+ ->spliceIntoPosition(5, 0);
+ }
+
+ /**
+ * Schedule the event to run weekly on a given day and time.
+ *
+ * @param int $day
+ * @param string $time
+ * @return $this
+ */
+ public function weeklyOn($day, $time = '0:0')
+ {
+ $this->dailyAt($time);
+
+ return $this->spliceIntoPosition(5, $day);
+ }
+
+ /**
+ * Schedule the event to run monthly.
+ *
+ * @return $this
+ */
+ public function monthly()
+ {
+ return $this->spliceIntoPosition(1, 0)
+ ->spliceIntoPosition(2, 0)
+ ->spliceIntoPosition(3, 1);
+ }
+
+ /**
+ * Schedule the event to run monthly on a given day and time.
+ *
+ * @param int $day
+ * @param string $time
+ * @return $this
+ */
+ public function monthlyOn($day = 1, $time = '0:0')
+ {
+ $this->dailyAt($time);
+
+ return $this->spliceIntoPosition(3, $day);
+ }
+
+ /**
+ * Schedule the event to run quarterly.
+ *
+ * @return $this
+ */
+ public function quarterly()
+ {
+ return $this->spliceIntoPosition(1, 0)
+ ->spliceIntoPosition(2, 0)
+ ->spliceIntoPosition(3, 1)
+ ->spliceIntoPosition(4, '*/3');
+ }
+
+ /**
+ * Schedule the event to run yearly.
+ *
+ * @return $this
+ */
+ public function yearly()
+ {
+ return $this->spliceIntoPosition(1, 0)
+ ->spliceIntoPosition(2, 0)
+ ->spliceIntoPosition(3, 1)
+ ->spliceIntoPosition(4, 1);
+ }
+
+ /**
+ * Schedule the event to run every minute.
+ *
+ * @return $this
+ */
+ public function everyMinute()
+ {
+ return $this->spliceIntoPosition(1, '*');
+ }
+
+ /**
+ * Schedule the event to run every five minutes.
+ *
+ * @return $this
+ */
+ public function everyFiveMinutes()
+ {
+ return $this->spliceIntoPosition(1, '*/5');
+ }
+
+ /**
+ * Schedule the event to run every ten minutes.
+ *
+ * @return $this
+ */
+ public function everyTenMinutes()
+ {
+ return $this->spliceIntoPosition(1, '*/10');
+ }
+
+ /**
+ * Schedule the event to run every thirty minutes.
+ *
+ * @return $this
+ */
+ public function everyThirtyMinutes()
+ {
+ return $this->spliceIntoPosition(1, '0,30');
+ }
+
+ /**
+ * Set the days of the week the command should run on.
+ *
+ * @param array|mixed $days
+ * @return $this
+ */
+ public function days($days)
+ {
+ $days = is_array($days) ? $days : func_get_args();
+
+ return $this->spliceIntoPosition(5, implode(',', $days));
+ }
+
+ /**
+ * Set the timezone the date should be evaluated on.
+ *
+ * @param \DateTimeZone|string $timezone
+ * @return $this
+ */
+ public function timezone($timezone)
+ {
+ $this->timezone = $timezone;
+
+ return $this;
+ }
+
+ /**
+ * Splice the given value into the given position of the expression.
+ *
+ * @param int $position
+ * @param string $value
+ * @return $this
+ */
+ protected function spliceIntoPosition($position, $value)
+ {
+ $segments = explode(' ', $this->expression);
+
+ $segments[$position - 1] = $value;
+
+ return $this->cron(implode(' ', $segments));
+ }
+} | true |
Other | laravel | framework | e5b0325949aa664009c080bf6bbbdfe008387e5c.json | change wording of message | src/Illuminate/Foundation/Testing/TestResponse.php | @@ -45,7 +45,7 @@ public function assertStatus($status)
{
$actual = $this->getStatusCode();
- PHPUnit::assertTrue($actual === $status, "Expected status code is {$status}, got {$actual}.");
+ PHPUnit::assertTrue($actual === $status, "Expected status code {$status} but received {$actual}.");
}
/** | false |
Other | laravel | framework | 3f93af4fa18a16caf32b916cea813984ba4243c7.json | Apply fixes from StyleCI (#16747) | tests/Routing/RoutingUrlGeneratorTest.php | @@ -128,7 +128,8 @@ public function testBasicRouteGeneration()
* With Default Parameter
*/
$url->defaults(['locale' => 'en']);
- $route = new Route(['GET'], 'foo', ['as' => 'defaults', 'domain' => '{locale}.example.com', function () {}]);
+ $route = new Route(['GET'], 'foo', ['as' => 'defaults', 'domain' => '{locale}.example.com', function () {
+ }]);
$routes->add($route);
$this->assertEquals('/', $url->route('plain', [], false)); | false |
Other | laravel | framework | cd87eff116dbc88e6fa840096de481731357d774.json | kill timedout process | src/Illuminate/Queue/Worker.php | @@ -99,6 +99,10 @@ protected function registerTimeoutHandler(WorkerOptions $options)
pcntl_async_signals(true);
pcntl_signal(SIGALRM, function () {
+ if (extension_loaded('posix')) {
+ posix_kill(getmypid(), SIGKILL);
+ }
+
exit(1);
});
| false |
Other | laravel | framework | 95cc3f238f20c5dbc6d6ff8c6088b3b7bfc82452.json | fix cs, please :( | tests/Redis/PhpRedisConnectionTest.php | @@ -96,5 +96,5 @@ class RedisStub
}
class RedisClusterStub
-{
+{
} | false |
Other | laravel | framework | 117de2a24cb0885ea68b6564747cf84d62672e2b.json | fix cs and doc blocks | src/Illuminate/Redis/PhpRedisDatabase.php | @@ -20,6 +20,7 @@ class PhpRedisDatabase extends Database
* Create a new Redis connection instance.
*
* @param array $servers
+ * @return void
*/
public function __construct(array $servers = [])
{
@@ -42,6 +43,7 @@ public function __construct(array $servers = [])
*
* @param array $clusters
* @param array $options
+ * @return void
*/
protected function createClusters(array $clusters, array $options = [])
{
@@ -62,7 +64,6 @@ protected function createClusters(array $clusters, array $options = [])
* @param array $servers
* @param array $options
* @param string $connection
- *
* @return array
*/
protected function createAggregateClient(array $servers, array $options = [], $connection = 'default')
@@ -77,7 +78,6 @@ protected function createAggregateClient(array $servers, array $options = [], $c
*
* @param array $servers
* @param array $options
- *
* @return array
*/
protected function createSingleClients(array $servers, array $options = [])
@@ -96,7 +96,6 @@ protected function createSingleClients(array $servers, array $options = [])
* Build a single cluster seed string from array.
*
* @param array $server
- *
* @return string
*/
protected function buildClusterSeed(array $server)
@@ -127,6 +126,7 @@ public function subscribe($channels, Closure $callback, $connection = null, $met
* @param array|string $channels
* @param \Closure $callback
* @param string $connection
+ * @return void
*/
public function psubscribe($channels, Closure $callback, $connection = null)
{
@@ -138,7 +138,6 @@ public function psubscribe($channels, Closure $callback, $connection = null)
*
* @param array $servers
* @param array $options
- *
* @return RedisCluster
*/
protected function createRedisClusterInstance(array $servers, array $options)
@@ -157,7 +156,6 @@ protected function createRedisClusterInstance(array $servers, array $options)
*
* @param array $server
* @param array $options
- *
* @return Redis
*/
protected function createRedisInstance(array $server, array $options)
@@ -172,19 +170,19 @@ protected function createRedisInstance(array $server, array $options)
$client->connect($server['host'], $server['port'], $timeout);
}
- if (!empty($server['prefix'])) {
+ if (! empty($server['prefix'])) {
$client->setOption(Redis::OPT_PREFIX, $server['prefix']);
}
- if (!empty($server['read_timeout'])) {
+ if (! empty($server['read_timeout'])) {
$client->setOption(Redis::OPT_READ_TIMEOUT, $server['read_timeout']);
}
- if (!empty($server['password'])) {
+ if (! empty($server['password'])) {
$client->auth($server['password']);
}
- if (!empty($server['database'])) {
+ if (! empty($server['database'])) {
$client->select($server['database']);
}
| true |
Other | laravel | framework | 117de2a24cb0885ea68b6564747cf84d62672e2b.json | fix cs and doc blocks | src/Illuminate/Redis/PredisDatabase.php | @@ -19,6 +19,7 @@ class PredisDatabase extends Database
* Create a new Redis connection instance.
*
* @param array $servers
+ * @return void
*/
public function __construct(array $servers = [])
{
@@ -41,6 +42,7 @@ public function __construct(array $servers = [])
*
* @param array $clusters
* @param array $options
+ * @return void
*/
protected function createClusters(array $clusters, array $options = [])
{
@@ -61,7 +63,6 @@ protected function createClusters(array $clusters, array $options = [])
* @param array $servers
* @param array $options
* @param string $connection
- *
* @return array
*/
protected function createAggregateClient(array $servers, array $options = [], $connection = 'default')
@@ -74,7 +75,6 @@ protected function createAggregateClient(array $servers, array $options = [], $c
*
* @param array $servers
* @param array $options
- *
* @return array
*/
protected function createSingleClients(array $servers, array $options = [])
@@ -95,6 +95,7 @@ protected function createSingleClients(array $servers, array $options = [])
* @param \Closure $callback
* @param string $connection
* @param string $method
+ * @return void
*/
public function subscribe($channels, Closure $callback, $connection = null, $method = 'subscribe')
{
@@ -117,6 +118,7 @@ public function subscribe($channels, Closure $callback, $connection = null, $met
* @param array|string $channels
* @param \Closure $callback
* @param string $connection
+ * @return void
*/
public function psubscribe($channels, Closure $callback, $connection = null)
{ | true |
Other | laravel | framework | 117de2a24cb0885ea68b6564747cf84d62672e2b.json | fix cs and doc blocks | tests/Redis/PhpRedisConnectionTest.php | @@ -56,7 +56,7 @@ protected function getRedis($cluster = false)
],
'clusters' => [
'options' => [
- 'prefix' => 'cluster:'
+ 'prefix' => 'cluster:',
],
'cluster-1' => [
[
@@ -70,7 +70,7 @@ protected function getRedis($cluster = false)
'host' => '127.0.0.1',
'port' => 6379,
'database' => 0,
- ]
+ ],
],
],
];
@@ -92,6 +92,12 @@ protected function createRedisInstance(array $server, array $options)
}
}
-class RedisStub {}
+class RedisStub
+{
+
+}
-class RedisClusterStub {}
+class RedisClusterStub
+{
+
+} | true |
Other | laravel | framework | 117de2a24cb0885ea68b6564747cf84d62672e2b.json | fix cs and doc blocks | tests/Redis/RedisConnectionTest.php | @@ -51,7 +51,7 @@ protected function getRedis($cluster = false)
],
'clusters' => [
'options' => [
- 'prefix' => 'cluster:'
+ 'prefix' => 'cluster:',
],
'cluster-1' => [
[
@@ -65,7 +65,7 @@ protected function getRedis($cluster = false)
'host' => '127.0.0.1',
'port' => 6379,
'database' => 0,
- ]
+ ],
],
],
]; | true |
Other | laravel | framework | 0164218e939cf20f493c11fb8c8b17c2c9c4ecd6.json | Support newer psy/psysh | composer.json | @@ -26,7 +26,7 @@
"mtdowling/cron-expression": "~1.0",
"nesbot/carbon": "~1.20",
"paragonie/random_compat": "~1.4|~2.0",
- "psy/psysh": "0.7.*",
+ "psy/psysh": "0.7.*|0.8.*",
"ramsey/uuid": "~3.0",
"swiftmailer/swiftmailer": "~5.1",
"symfony/console": "3.1.*", | false |
Other | laravel | framework | 32d0f164424ab5b4a2bff2ed927812ae49bd8051.json | fix eloquent builder | src/Illuminate/Database/Eloquent/Builder.php | @@ -411,7 +411,9 @@ public function chunkById($count, callable $callback, $column = 'id')
$lastId = 0;
do {
- $results = $this->forPageAfterId($count, $lastId, $column)->get();
+ $clone = clone $this;
+
+ $results = $clone->forPageAfterId($count, $lastId, $column)->get();
$countResults = $results->count();
| false |
Other | laravel | framework | 402eface32dd131468948ac34022a2bb20702655.json | Add tests for interacts with database trait. | tests/Foundation/FoundationInteractsWithDatabaseTest.php | @@ -0,0 +1,115 @@
+<?php
+
+use Mockery as m;
+use Illuminate\Database\Connection;
+use Illuminate\Database\Query\Builder;
+use Illuminate\Foundation\Testing\Concerns\InteractsWithDatabase;
+
+class FoundationInteractsWithDatabaseTest extends PHPUnit_Framework_TestCase
+{
+ use InteractsWithDatabase;
+
+ protected $table = 'products';
+
+ protected $data = ['title' => 'Spark'];
+
+ protected $connection;
+
+ public function setUp()
+ {
+ $this->connection = m::mock(Connection::class);
+ }
+
+ public function tearDown()
+ {
+ m::close();
+ }
+
+ public function testSeeInDatabaseFindsResults()
+ {
+ $this->mockCountBuilder(1);
+
+ $this->seeInDatabase($this->table, $this->data);
+ }
+
+ /**
+ * @expectedException \PHPUnit_Framework_ExpectationFailedException
+ * @expectedExceptionMessage The table is empty.
+ */
+ public function testSeeInDatabaseDoesNotFindResults()
+ {
+ $builder = $this->mockCountBuilder(0);
+
+ $builder->shouldReceive('get')->once()->andReturn(collect());
+
+ $this->seeInDatabase($this->table, $this->data);
+ }
+
+ /**
+ * @expectedException \PHPUnit_Framework_ExpectationFailedException
+ * @expectedExceptionMessage Found: [{"title":"Forge"}].
+ */
+ public function testSeeInDatabaseFindsNotMatchingResults()
+ {
+ $builder = $this->mockCountBuilder(0);
+
+ $builder->shouldReceive('get')->once()->andReturn(collect([['title' => 'Forge']]));
+
+ $this->seeInDatabase($this->table, $this->data);
+ }
+
+ /**
+ * @expectedException \PHPUnit_Framework_ExpectationFailedException
+ * @expectedExceptionMessage Found: ["data","data","data"] and 2 others.
+ */
+ public function testSeeInDatabaseFindsManyNotMatchingResults()
+ {
+ $builder = $this->mockCountBuilder(0);
+
+ $builder->shouldReceive('get')->once()->andReturn(
+ collect(array_fill(0, 5, 'data'))
+ );
+
+ $this->seeInDatabase($this->table, $this->data);
+ }
+
+ public function testDontSeeInDatabaseDoesNotFindResults()
+ {
+ $this->mockCountBuilder(0);
+
+ $this->dontSeeInDatabase($this->table, $this->data);
+ }
+
+ /**
+ * @expectedException \PHPUnit_Framework_ExpectationFailedException
+ * @expectedExceptionMessage a row in the table [products] does not match the attributes {"title":"Spark"}
+ */
+ public function testDontSeeInDatabaseFindsResults()
+ {
+ $builder = $this->mockCountBuilder(1);
+
+ $builder->shouldReceive('get')->once()->andReturn(collect([$this->data]));
+
+ $this->dontSeeInDatabase($this->table, $this->data);
+ }
+
+ protected function mockCountBuilder($countResult)
+ {
+ $builder = m::mock(Builder::class);
+
+ $builder->shouldReceive('where')->with($this->data)->andReturnSelf();
+
+ $builder->shouldReceive('count')->andReturn($countResult);
+
+ $this->connection->shouldReceive('table')
+ ->with($this->table)
+ ->andReturn($builder);
+
+ return $builder;
+ }
+
+ protected function getConnection()
+ {
+ return $this->connection;
+ }
+} | false |
Other | laravel | framework | 71bb4e419b8d8f1fc3bae5c98c75b3c5ee3fe191.json | Fix date_format validation for all formats | src/Illuminate/Validation/Validator.php | @@ -1834,10 +1834,10 @@ protected function validateDateFormat($attribute, $value, $parameters)
if (! is_string($value) && ! is_numeric($value)) {
return false;
}
+
+ $date = DateTime::createFromFormat($parameters[0], $value);
- $parsed = date_parse_from_format($parameters[0], $value);
-
- return $parsed['error_count'] === 0 && $parsed['warning_count'] === 0;
+ return $date && $date->format($parameters[0]) === $value;
}
/** | false |
Other | laravel | framework | cb74be855108481fec222f02910f14c64d6ae727.json | Add test for higher order partition | tests/Support/SupportCollectionTest.php | @@ -1769,6 +1769,19 @@ public function testPartitionEmptyCollection()
return true;
}));
}
+
+ public function testHigherOrderPartition()
+ {
+ $courses = new Collection([
+ 'a' => ['free' => true], 'b' => ['free' => false], 'c' => ['free' => true],
+ ]);
+
+ list($free, $premium) = $courses->partition->free;
+
+ $this->assertSame(['a' => ['free' => true], 'c' => ['free' => true]], $free->toArray());
+
+ $this->assertSame(['b' => ['free' => false]], $premium->toArray());
+ }
}
class TestSupportCollectionHigherOrderItem | false |
Other | laravel | framework | 724950a42c225c7b53c56283c01576b050fea37a.json | allow higher order partition | src/Illuminate/Support/Collection.php | @@ -1389,7 +1389,7 @@ protected function getArrayableItems($items)
public function __get($key)
{
$proxies = [
- 'each', 'map', 'first', 'sortBy',
+ 'each', 'map', 'first', 'partition', 'sortBy',
'sortByDesc', 'sum', 'reject', 'filter',
];
| false |
Other | laravel | framework | 0927be8103b1248b7ad46c4fd400cd537e12f6be.json | Fail tests that don't pass on PHP 7.1 (#16678) | .travis.yml | @@ -10,8 +10,6 @@ env:
- setup=basic
matrix:
- allow_failures:
- - php: 7.1
fast_finish: true
include:
- php: 5.6 | false |
Other | laravel | framework | 939264f91edc5d33da5ce6cf95a271a6f4a2e1f2.json | remove old constraints | src/Illuminate/Foundation/Testing/Constraints/FormFieldConstraint.php | @@ -1,82 +0,0 @@
-<?php
-
-namespace Illuminate\Foundation\Testing\Constraints;
-
-use Symfony\Component\DomCrawler\Crawler;
-
-abstract class FormFieldConstraint extends PageConstraint
-{
- /**
- * The name or ID of the element.
- *
- * @var string
- */
- protected $selector;
-
- /**
- * The expected value.
- *
- * @var string
- */
- protected $value;
-
- /**
- * Create a new constraint instance.
- *
- * @param string $selector
- * @param mixed $value
- * @return void
- */
- public function __construct($selector, $value)
- {
- $this->selector = $selector;
- $this->value = (string) $value;
- }
-
- /**
- * Get the valid elements.
- *
- * Multiple elements should be separated by commas without spaces.
- *
- * @return string
- */
- abstract protected function validElements();
-
- /**
- * Get the form field.
- *
- * @param \Symfony\Component\DomCrawler\Crawler $crawler
- * @return \Symfony\Component\DomCrawler\Crawler
- *
- * @throws \PHPUnit_Framework_ExpectationFailedException
- */
- protected function field(Crawler $crawler)
- {
- $field = $crawler->filter(implode(', ', $this->getElements()));
-
- if ($field->count() > 0) {
- return $field;
- }
-
- $this->fail($crawler, sprintf(
- 'There is no %s with the name or ID [%s]',
- $this->validElements(), $this->selector
- ));
- }
-
- /**
- * Get the elements relevant to the selector.
- *
- * @return array
- */
- protected function getElements()
- {
- $name = str_replace('#', '', $this->selector);
-
- $id = str_replace(['[', ']'], ['\\[', '\\]'], $name);
-
- return collect(explode(',', $this->validElements()))->map(function ($element) use ($name, $id) {
- return "{$element}#{$id}, {$element}[name='{$name}']";
- })->all();
- }
-} | true |
Other | laravel | framework | 939264f91edc5d33da5ce6cf95a271a6f4a2e1f2.json | remove old constraints | src/Illuminate/Foundation/Testing/Constraints/HasElement.php | @@ -1,99 +0,0 @@
-<?php
-
-namespace Illuminate\Foundation\Testing\Constraints;
-
-use Symfony\Component\DomCrawler\Crawler;
-
-class HasElement extends PageConstraint
-{
- /**
- * The name or ID of the element.
- *
- * @var string
- */
- protected $selector;
-
- /**
- * The attributes the element should have.
- *
- * @var array
- */
- protected $attributes;
-
- /**
- * Create a new constraint instance.
- *
- * @param string $selector
- * @param array $attributes
- * @return void
- */
- public function __construct($selector, array $attributes = [])
- {
- $this->selector = $selector;
- $this->attributes = $attributes;
- }
-
- /**
- * Check if the element is found in the given crawler.
- *
- * @param \Symfony\Component\DomCrawler\Crawler|string $crawler
- * @return bool
- */
- public function matches($crawler)
- {
- $elements = $this->crawler($crawler)->filter($this->selector);
-
- if ($elements->count() == 0) {
- return false;
- }
-
- if (empty($this->attributes)) {
- return true;
- }
-
- $elements = $elements->reduce(function ($element) {
- return $this->hasAttributes($element);
- });
-
- return $elements->count() > 0;
- }
-
- /**
- * Determines if the given element has the attributes.
- *
- * @param \Symfony\Component\DomCrawler\Crawler $element
- * @return bool
- */
- protected function hasAttributes(Crawler $element)
- {
- foreach ($this->attributes as $name => $value) {
- if (is_numeric($name)) {
- if (is_null($element->attr($value))) {
- return false;
- }
- } else {
- if ($element->attr($name) != $value) {
- return false;
- }
- }
- }
-
- return true;
- }
-
- /**
- * Returns a string representation of the object.
- *
- * @return string
- */
- public function toString()
- {
- $message = "the element [{$this->selector}]";
-
- if (! empty($this->attributes)) {
- $message .= ' with the attributes '.json_encode($this->attributes);
- }
-
- return $message;
- }
-} | true |
Other | laravel | framework | 939264f91edc5d33da5ce6cf95a271a6f4a2e1f2.json | remove old constraints | src/Illuminate/Foundation/Testing/Constraints/HasInElement.php | @@ -1,78 +0,0 @@
-<?php
-
-namespace Illuminate\Foundation\Testing\Constraints;
-
-use Symfony\Component\DomCrawler\Crawler;
-
-class HasInElement extends PageConstraint
-{
- /**
- * The name or ID of the element.
- *
- * @var string
- */
- protected $element;
-
- /**
- * The text expected to be found.
- *
- * @var string
- */
- protected $text;
-
- /**
- * Create a new constraint instance.
- *
- * @param string $element
- * @param string $text
- * @return void
- */
- public function __construct($element, $text)
- {
- $this->text = $text;
- $this->element = $element;
- }
-
- /**
- * Check if the source or text is found within the element in the given crawler.
- *
- * @param \Symfony\Component\DomCrawler\Crawler|string $crawler
- * @return bool
- */
- public function matches($crawler)
- {
- $elements = $this->crawler($crawler)->filter($this->element);
-
- $pattern = $this->getEscapedPattern($this->text);
-
- foreach ($elements as $element) {
- $element = new Crawler($element);
-
- if (preg_match("/$pattern/i", $element->html())) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Returns the description of the failure.
- *
- * @return string
- */
- protected function getFailureDescription()
- {
- return sprintf('[%s] contains %s', $this->element, $this->text);
- }
-
- /**
- * Returns the reversed description of the failure.
- *
- * @return string
- */
- protected function getReverseFailureDescription()
- {
- return sprintf('[%s] does not contain %s', $this->element, $this->text);
- }
-} | true |
Other | laravel | framework | 939264f91edc5d33da5ce6cf95a271a6f4a2e1f2.json | remove old constraints | src/Illuminate/Foundation/Testing/Constraints/HasLink.php | @@ -1,116 +0,0 @@
-<?php
-
-namespace Illuminate\Foundation\Testing\Constraints;
-
-use Illuminate\Support\Str;
-use Illuminate\Support\Facades\URL;
-
-class HasLink extends PageConstraint
-{
- /**
- * The text expected to be found.
- *
- * @var string
- */
- protected $text;
-
- /**
- * The URL expected to be linked in the <a> tag.
- *
- * @var string|null
- */
- protected $url;
-
- /**
- * Create a new constraint instance.
- *
- * @param string $text
- * @param string|null $url
- * @return void
- */
- public function __construct($text, $url = null)
- {
- $this->url = $url;
- $this->text = $text;
- }
-
- /**
- * Check if the link is found in the given crawler.
- *
- * @param \Symfony\Component\DomCrawler\Crawler|string $crawler
- * @return bool
- */
- public function matches($crawler)
- {
- $links = $this->crawler($crawler)->selectLink($this->text);
-
- if ($links->count() == 0) {
- return false;
- }
-
- // If the URL is null we assume the developer only wants to find a link
- // with the given text regardless of the URL. So if we find the link
- // we will return true. Otherwise, we will look for the given URL.
- if ($this->url == null) {
- return true;
- }
-
- $absoluteUrl = $this->absoluteUrl();
-
- foreach ($links as $link) {
- $linkHref = $link->getAttribute('href');
-
- if ($linkHref == $this->url || $linkHref == $absoluteUrl) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Add a root if the URL is relative (helper method of the hasLink function).
- *
- * @return string
- */
- protected function absoluteUrl()
- {
- if (! Str::startsWith($this->url, ['http', 'https'])) {
- return URL::to($this->url);
- }
-
- return $this->url;
- }
-
- /**
- * Returns the description of the failure.
- *
- * @return string
- */
- public function getFailureDescription()
- {
- $description = "has a link with the text [{$this->text}]";
-
- if ($this->url) {
- $description .= " and the URL [{$this->url}]";
- }
-
- return $description;
- }
-
- /**
- * Returns the reversed description of the failure.
- *
- * @return string
- */
- protected function getReverseFailureDescription()
- {
- $description = "does not have a link with the text [{$this->text}]";
-
- if ($this->url) {
- $description .= " and the URL [{$this->url}]";
- }
-
- return $description;
- }
-} | true |
Other | laravel | framework | 939264f91edc5d33da5ce6cf95a271a6f4a2e1f2.json | remove old constraints | src/Illuminate/Foundation/Testing/Constraints/HasSource.php | @@ -1,47 +0,0 @@
-<?php
-
-namespace Illuminate\Foundation\Testing\Constraints;
-
-class HasSource extends PageConstraint
-{
- /**
- * The expected HTML source.
- *
- * @var string
- */
- protected $source;
-
- /**
- * Create a new constraint instance.
- *
- * @param string $source
- * @return void
- */
- public function __construct($source)
- {
- $this->source = $source;
- }
-
- /**
- * Check if the source is found in the given crawler.
- *
- * @param \Symfony\Component\DomCrawler\Crawler|string $crawler
- * @return bool
- */
- protected function matches($crawler)
- {
- $pattern = $this->getEscapedPattern($this->source);
-
- return preg_match("/{$pattern}/i", $this->html($crawler));
- }
-
- /**
- * Returns a string representation of the object.
- *
- * @return string
- */
- public function toString()
- {
- return "the HTML [{$this->source}]";
- }
-} | true |
Other | laravel | framework | 939264f91edc5d33da5ce6cf95a271a6f4a2e1f2.json | remove old constraints | src/Illuminate/Foundation/Testing/Constraints/HasText.php | @@ -1,47 +0,0 @@
-<?php
-
-namespace Illuminate\Foundation\Testing\Constraints;
-
-class HasText extends PageConstraint
-{
- /**
- * The expected text.
- *
- * @var string
- */
- protected $text;
-
- /**
- * Create a new constraint instance.
- *
- * @param string $text
- * @return void
- */
- public function __construct($text)
- {
- $this->text = $text;
- }
-
- /**
- * Check if the plain text is found in the given crawler.
- *
- * @param \Symfony\Component\DomCrawler\Crawler|string $crawler
- * @return bool
- */
- protected function matches($crawler)
- {
- $pattern = $this->getEscapedPattern($this->text);
-
- return preg_match("/{$pattern}/i", $this->text($crawler));
- }
-
- /**
- * Returns a string representation of the object.
- *
- * @return string
- */
- public function toString()
- {
- return "the text [{$this->text}]";
- }
-} | true |
Other | laravel | framework | 939264f91edc5d33da5ce6cf95a271a6f4a2e1f2.json | remove old constraints | src/Illuminate/Foundation/Testing/Constraints/HasValue.php | @@ -1,74 +0,0 @@
-<?php
-
-namespace Illuminate\Foundation\Testing\Constraints;
-
-use Symfony\Component\DomCrawler\Crawler;
-
-class HasValue extends FormFieldConstraint
-{
- /**
- * Get the valid elements.
- *
- * @return string
- */
- protected function validElements()
- {
- return 'input,textarea';
- }
-
- /**
- * Check if the input contains the expected value.
- *
- * @param \Symfony\Component\DomCrawler\Crawler|string $crawler
- * @return bool
- */
- public function matches($crawler)
- {
- $crawler = $this->crawler($crawler);
-
- return $this->getInputOrTextAreaValue($crawler) == $this->value;
- }
-
- /**
- * Get the value of an input or textarea.
- *
- * @param \Symfony\Component\DomCrawler\Crawler $crawler
- * @return string
- *
- * @throws \PHPUnit_Framework_ExpectationFailedException
- */
- public function getInputOrTextAreaValue(Crawler $crawler)
- {
- $field = $this->field($crawler);
-
- return $field->nodeName() == 'input'
- ? $field->attr('value')
- : $field->text();
- }
-
- /**
- * Return the description of the failure.
- *
- * @return string
- */
- protected function getFailureDescription()
- {
- return sprintf(
- 'the field [%s] contains the expected value [%s]',
- $this->selector, $this->value
- );
- }
-
- /**
- * Returns the reversed description of the failure.
- *
- * @return string
- */
- protected function getReverseFailureDescription()
- {
- return sprintf(
- 'the field [%s] does not contain the expected value [%s]',
- $this->selector, $this->value
- );
- }
-} | true |
Other | laravel | framework | 939264f91edc5d33da5ce6cf95a271a6f4a2e1f2.json | remove old constraints | src/Illuminate/Foundation/Testing/Constraints/IsChecked.php | @@ -1,60 +0,0 @@
-<?php
-
-namespace Illuminate\Foundation\Testing\Constraints;
-
-class IsChecked extends FormFieldConstraint
-{
- /**
- * Create a new constraint instance.
- *
- * @param string $selector
- * @return void
- */
- public function __construct($selector)
- {
- $this->selector = $selector;
- }
-
- /**
- * Get the valid elements.
- *
- * @return string
- */
- protected function validElements()
- {
- return "input[type='checkbox']";
- }
-
- /**
- * Determine if the checkbox is checked.
- *
- * @param \Symfony\Component\DomCrawler\Crawler|string $crawler
- * @return bool
- */
- public function matches($crawler)
- {
- $crawler = $this->crawler($crawler);
-
- return ! is_null($this->field($crawler)->attr('checked'));
- }
-
- /**
- * Return the description of the failure.
- *
- * @return string
- */
- protected function getFailureDescription()
- {
- return "the checkbox [{$this->selector}] is checked";
- }
-
- /**
- * Returns the reversed description of the failure.
- *
- * @return string
- */
- protected function getReverseFailureDescription()
- {
- return "the checkbox [{$this->selector}] is not checked";
- }
-} | true |
Other | laravel | framework | 939264f91edc5d33da5ce6cf95a271a6f4a2e1f2.json | remove old constraints | src/Illuminate/Foundation/Testing/Constraints/IsSelected.php | @@ -1,130 +0,0 @@
-<?php
-
-namespace Illuminate\Foundation\Testing\Constraints;
-
-use DOMElement;
-use Symfony\Component\DomCrawler\Crawler;
-
-class IsSelected extends FormFieldConstraint
-{
- /**
- * Get the valid elements.
- *
- * @return string
- */
- protected function validElements()
- {
- return 'select,input[type="radio"]';
- }
-
- /**
- * Determine if the select or radio element is selected.
- *
- * @param \Symfony\Component\DomCrawler\Crawler|string $crawler
- * @return bool
- */
- protected function matches($crawler)
- {
- $crawler = $this->crawler($crawler);
-
- return in_array($this->value, $this->getSelectedValue($crawler));
- }
-
- /**
- * Get the selected value of a select field or radio group.
- *
- * @param \Symfony\Component\DomCrawler\Crawler $crawler
- * @return array
- *
- * @throws \PHPUnit_Framework_ExpectationFailedException
- */
- public function getSelectedValue(Crawler $crawler)
- {
- $field = $this->field($crawler);
-
- return $field->nodeName() == 'select'
- ? $this->getSelectedValueFromSelect($field)
- : [$this->getCheckedValueFromRadioGroup($field)];
- }
-
- /**
- * Get the selected value from a select field.
- *
- * @param \Symfony\Component\DomCrawler\Crawler $select
- * @return array
- */
- protected function getSelectedValueFromSelect(Crawler $select)
- {
- $selected = [];
-
- foreach ($select->children() as $option) {
- if ($option->nodeName === 'optgroup') {
- foreach ($option->childNodes as $child) {
- if ($child->hasAttribute('selected')) {
- $selected[] = $this->getOptionValue($child);
- }
- }
- } elseif ($option->hasAttribute('selected')) {
- $selected[] = $this->getOptionValue($option);
- }
- }
-
- return $selected;
- }
-
- /**
- * Get the selected value from an option element.
- *
- * @param \DOMElement $option
- * @return string
- */
- protected function getOptionValue(DOMElement $option)
- {
- if ($option->hasAttribute('value')) {
- return $option->getAttribute('value');
- }
-
- return $option->textContent;
- }
-
- /**
- * Get the checked value from a radio group.
- *
- * @param \Symfony\Component\DomCrawler\Crawler $radioGroup
- * @return string|null
- */
- protected function getCheckedValueFromRadioGroup(Crawler $radioGroup)
- {
- foreach ($radioGroup as $radio) {
- if ($radio->hasAttribute('checked')) {
- return $radio->getAttribute('value');
- }
- }
- }
-
- /**
- * Returns the description of the failure.
- *
- * @return string
- */
- protected function getFailureDescription()
- {
- return sprintf(
- 'the element [%s] has the selected value [%s]',
- $this->selector, $this->value
- );
- }
-
- /**
- * Returns the reversed description of the failure.
- *
- * @return string
- */
- protected function getReverseFailureDescription()
- {
- return sprintf(
- 'the element [%s] does not have the selected value [%s]',
- $this->selector, $this->value
- );
- }
-} | true |
Other | laravel | framework | 939264f91edc5d33da5ce6cf95a271a6f4a2e1f2.json | remove old constraints | src/Illuminate/Foundation/Testing/Constraints/PageConstraint.php | @@ -1,124 +0,0 @@
-<?php
-
-namespace Illuminate\Foundation\Testing\Constraints;
-
-use PHPUnit_Framework_Constraint;
-use Symfony\Component\DomCrawler\Crawler;
-use SebastianBergmann\Comparator\ComparisonFailure;
-use PHPUnit_Framework_ExpectationFailedException as FailedExpection;
-
-abstract class PageConstraint extends PHPUnit_Framework_Constraint
-{
- /**
- * Make sure we obtain the HTML from the crawler or the response.
- *
- * @param \Symfony\Component\DomCrawler\Crawler|string $crawler
- * @return string
- */
- protected function html($crawler)
- {
- return is_object($crawler) ? $crawler->html() : $crawler;
- }
-
- /**
- * Make sure we obtain the HTML from the crawler or the response.
- *
- * @param \Symfony\Component\DomCrawler\Crawler|string $crawler
- * @return string
- */
- protected function text($crawler)
- {
- return is_object($crawler) ? $crawler->text() : strip_tags($crawler);
- }
-
- /**
- * Create a crawler instance if the given value is not already a Crawler.
- *
- * @param \Symfony\Component\DomCrawler\Crawler|string $crawler
- * @return \Symfony\Component\DomCrawler\Crawler
- */
- protected function crawler($crawler)
- {
- return is_object($crawler) ? $crawler : new Crawler($crawler);
- }
-
- /**
- * Get the escaped text pattern for the constraint.
- *
- * @param string $text
- * @return string
- */
- protected function getEscapedPattern($text)
- {
- $rawPattern = preg_quote($text, '/');
-
- $escapedPattern = preg_quote(e($text), '/');
-
- return $rawPattern == $escapedPattern
- ? $rawPattern : "({$rawPattern}|{$escapedPattern})";
- }
-
- /**
- * Throw an exception for the given comparison and test description.
- *
- * @param \Symfony\Component\DomCrawler\Crawler|string $crawler
- * @param string $description
- * @param \SebastianBergmann\Comparator\ComparisonFailure|null $comparisonFailure
- * @return void
- *
- * @throws \PHPUnit_Framework_ExpectationFailedException
- */
- protected function fail($crawler, $description, ComparisonFailure $comparisonFailure = null)
- {
- $html = $this->html($crawler);
-
- $failureDescription = sprintf(
- "%s\n\n\nFailed asserting that %s",
- $html, $this->getFailureDescription()
- );
-
- if (! empty($description)) {
- $failureDescription .= ": {$description}";
- }
-
- if (trim($html) != '') {
- $failureDescription .= '. Please check the content above.';
- } else {
- $failureDescription .= '. The response is empty.';
- }
-
- throw new FailedExpection($failureDescription, $comparisonFailure);
- }
-
- /**
- * Get the description of the failure.
- *
- * @return string
- */
- protected function getFailureDescription()
- {
- return 'the page contains '.$this->toString();
- }
-
- /**
- * Returns the reversed description of the failure.
- *
- * @return string
- */
- protected function getReverseFailureDescription()
- {
- return 'the page does not contain '.$this->toString();
- }
-
- /**
- * Get a string representation of the object.
- *
- * Placeholder method to avoid forcing definition of this method.
- *
- * @return string
- */
- public function toString()
- {
- return '';
- }
-} | true |
Other | laravel | framework | 939264f91edc5d33da5ce6cf95a271a6f4a2e1f2.json | remove old constraints | src/Illuminate/Foundation/Testing/Constraints/ReversePageConstraint.php | @@ -1,57 +0,0 @@
-<?php
-
-namespace Illuminate\Foundation\Testing\Constraints;
-
-class ReversePageConstraint extends PageConstraint
-{
- /**
- * The page constraint instance.
- *
- * @var \Illuminate\Foundation\Testing\Constraints\PageConstraint
- */
- protected $pageConstraint;
-
- /**
- * Create a new reverse page constraint instance.
- *
- * @param \Illuminate\Foundation\Testing\Constraints\PageConstraint $pageConstraint
- * @return void
- */
- public function __construct(PageConstraint $pageConstraint)
- {
- $this->pageConstraint = $pageConstraint;
- }
-
- /**
- * Reverse the original page constraint result.
- *
- * @param \Symfony\Component\DomCrawler\Crawler $crawler
- * @return bool
- */
- public function matches($crawler)
- {
- return ! $this->pageConstraint->matches($crawler);
- }
-
- /**
- * Get the description of the failure.
- *
- * This method will attempt to negate the original description.
- *
- * @return string
- */
- protected function getFailureDescription()
- {
- return $this->pageConstraint->getReverseFailureDescription();
- }
-
- /**
- * Get a string representation of the object.
- *
- * @return string
- */
- public function toString()
- {
- return $this->pageConstraint->toString();
- }
-} | true |
Other | laravel | framework | f353d7586430ef0f06c8d4aeac100da63f510b76.json | Add name alias to RouteRegistrar | src/Illuminate/Routing/RouteRegistrar.php | @@ -29,6 +29,15 @@ class RouteRegistrar
'get', 'post', 'put', 'patch', 'delete', 'options', 'any',
];
+ /**
+ * The attributes that are aliased.
+ *
+ * @var array
+ */
+ protected $aliases = [
+ 'name' => 'as',
+ ];
+
/**
* Create a new route registrar instance.
*
@@ -49,7 +58,7 @@ public function __construct(Router $router)
*/
public function attribute($key, $value)
{
- $this->attributes[$key] = $value;
+ $this->attributes[array_get($this->aliases, $key, $key)] = $value;
return $this;
} | true |
Other | laravel | framework | f353d7586430ef0f06c8d4aeac100da63f510b76.json | Add name alias to RouteRegistrar | tests/Routing/RouteRegistrarTest.php | @@ -116,7 +116,6 @@ public function testCanRegisterGroupWithMiddleware()
$this->seeMiddleware('group-middleware');
}
-
public function testCanRegisterGroupWithNamespace()
{
$this->router->namespace('App\Http\Controllers')->group(function ($router) { | true |
Other | laravel | framework | 677563189476bfcfa019295be0a7da6b33950127.json | Add middleware registration to resources | src/Illuminate/Routing/ControllerDispatcher.php | @@ -44,7 +44,7 @@ public function dispatch(Route $route, $controller, $method)
return $controller->callAction($method, $parameters);
}
- return call_user_func_array([$controller, $method], $parameters);
+ return $controller->{$method}(...array_values($parameters));
}
/** | true |
Other | laravel | framework | 677563189476bfcfa019295be0a7da6b33950127.json | Add middleware registration to resources | src/Illuminate/Routing/ResourceRegistrar.php | @@ -196,7 +196,13 @@ protected function getResourceAction($resource, $controller, $method, $options)
{
$name = $this->getResourceName($resource, $method, $options);
- return ['as' => $name, 'uses' => $controller.'@'.$method];
+ $action = ['as' => $name, 'uses' => $controller.'@'.$method];
+
+ if (isset($options['middleware'])) {
+ $action['middleware'] = $options['middleware'];
+ }
+
+ return $action;
}
/** | true |
Other | laravel | framework | 677563189476bfcfa019295be0a7da6b33950127.json | Add middleware registration to resources | src/Illuminate/Routing/RouteRegistrar.php | @@ -54,6 +54,19 @@ public function attribute($key, $value)
return $this;
}
+ /**
+ * Route a resource to a controller.
+ *
+ * @param string $name
+ * @param string $controller
+ * @param array $options
+ * @return void
+ */
+ public function resource($name, $controller, array $options = [])
+ {
+ $this->router->resource($name, $controller, $this->attributes + $options);
+ }
+
/**
* Create a route group with shared attributes.
* | true |
Other | laravel | framework | 677563189476bfcfa019295be0a7da6b33950127.json | Add middleware registration to resources | tests/Routing/RouteRegistrarTest.php | @@ -116,6 +116,7 @@ public function testCanRegisterGroupWithMiddleware()
$this->seeMiddleware('group-middleware');
}
+
public function testCanRegisterGroupWithNamespace()
{
$this->router->namespace('App\Http\Controllers')->group(function ($router) {
@@ -228,4 +229,9 @@ public function index()
{
return 'controller';
}
+
+ public function destroy()
+ {
+ return 'deleted';
+ }
} | true |
Other | laravel | framework | 126adb781c204129600363f243b9d73e202d229e.json | pull url from config | src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php | @@ -254,7 +254,7 @@ protected function prepareUrlForRequest($uri)
}
if (! Str::startsWith($uri, 'http')) {
- $uri = $this->baseUrl.'/'.$uri;
+ $uri = config('app.url').'/'.$uri;
}
return trim($uri, '/'); | false |
Other | laravel | framework | 6cc3068768ce8eff105569657c21e66a540d9c8b.json | Preserve keys in the partition method | src/Illuminate/Support/Collection.php | @@ -737,8 +737,8 @@ public function partition($callback)
$callback = $this->valueRetriever($callback);
- foreach ($this->items as $item) {
- $partitions[(int) ! $callback($item)][] = $item;
+ foreach ($this->items as $key => $item) {
+ $partitions[(int) ! $callback($item)][$key] = $item;
}
return $partitions; | true |
Other | laravel | framework | 6cc3068768ce8eff105569657c21e66a540d9c8b.json | Preserve keys in the partition method | tests/Support/SupportCollectionTest.php | @@ -1648,8 +1648,8 @@ public function testPartitionWithClosure()
return $i <= 5;
});
- $this->assertEquals([1, 2, 3, 4, 5], $firstPartition->toArray());
- $this->assertEquals([6, 7, 8, 9, 10], $secondPartition->toArray());
+ $this->assertEquals([1, 2, 3, 4, 5], $firstPartition->values()->toArray());
+ $this->assertEquals([6, 7, 8, 9, 10], $secondPartition->values()->toArray());
}
public function testPartitionByKey()
@@ -1660,9 +1660,22 @@ public function testPartitionByKey()
list($free, $premium) = $courses->partition('free');
- $this->assertSame([['free' => true, 'title' => 'Basic']], $free->toArray());
+ $this->assertSame([['free' => true, 'title' => 'Basic']], $free->values()->toArray());
- $this->assertSame([['free' => false, 'title' => 'Premium']], $premium->toArray());
+ $this->assertSame([['free' => false, 'title' => 'Premium']], $premium->values()->toArray());
+ }
+
+ public function testPartitionPreservesKeys()
+ {
+ $courses = new Collection([
+ 'a' => ['free' => true], 'b' => ['free' => false], 'c' => ['free' => true],
+ ]);
+
+ list($free, $premium) = $courses->partition('free');
+
+ $this->assertSame(['a' => ['free' => true], 'c' => ['free' => true]], $free->toArray());
+
+ $this->assertSame(['b' => ['free' => false]], $premium->toArray());
}
public function testPartitionEmptyCollection() | true |
Other | laravel | framework | 6ea6e22e77bb66446de18b0ed5b22141a75ba204.json | Fix seeJsonStructure for empty response | src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php | @@ -351,7 +351,7 @@ public function seeJsonStructure(array $structure = null, $responseData = null)
return $this->seeJson();
}
- if (! $responseData) {
+ if (is_null($responseData)) {
$responseData = $this->decodeResponseJson();
}
| false |
Other | laravel | framework | 2dbb28ffe45804c408a79f9817a6b560de3ed82a.json | Apply fixes from StyleCI (#16640) | tests/Cache/RedisCacheIntegrationTest.php | @@ -1,8 +1,8 @@
<?php
+use Mockery as m;
use Illuminate\Cache\RedisStore;
use Illuminate\Cache\Repository;
-use Mockery as m;
class RedisCacheTest extends PHPUnit_Framework_TestCase
{ | true |
Other | laravel | framework | 2dbb28ffe45804c408a79f9817a6b560de3ed82a.json | Apply fixes from StyleCI (#16640) | tests/Database/DatabaseEloquentIntegrationTest.php | @@ -1,8 +1,8 @@
<?php
use Illuminate\Database\Capsule\Manager as DB;
-use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Database\Eloquent\Relations\Pivot;
+use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Pagination\AbstractPaginator as Paginator;
| true |
Other | laravel | framework | 2dbb28ffe45804c408a79f9817a6b560de3ed82a.json | Apply fixes from StyleCI (#16640) | tests/Database/SeedCommandTest.php | @@ -1,9 +1,9 @@
<?php
+use Illuminate\Database\Seeder;
use Illuminate\Container\Container;
-use Illuminate\Database\ConnectionResolverInterface;
use Illuminate\Database\Console\Seeds\SeedCommand;
-use Illuminate\Database\Seeder;
+use Illuminate\Database\ConnectionResolverInterface;
class SeedCommandTest extends PHPUnit_Framework_TestCase
{ | true |
Other | laravel | framework | d1a4f3fc7951c04ff91855511ed8c73b1a98e533.json | Apply fixes from StyleCI (#16639) | src/Illuminate/Auth/SessionGuard.php | @@ -5,8 +5,8 @@
use RuntimeException;
use Illuminate\Support\Str;
use Illuminate\Http\Response;
-use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Contracts\Auth\UserProvider;
+use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Contracts\Auth\StatefulGuard;
use Symfony\Component\HttpFoundation\Request;
use Illuminate\Contracts\Auth\SupportsBasicAuth; | true |
Other | laravel | framework | d1a4f3fc7951c04ff91855511ed8c73b1a98e533.json | Apply fixes from StyleCI (#16639) | src/Illuminate/Broadcasting/BroadcastManager.php | @@ -7,8 +7,8 @@
use Illuminate\Support\Arr;
use InvalidArgumentException;
use Illuminate\Broadcasting\Broadcasters\LogBroadcaster;
-use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
use Illuminate\Broadcasting\Broadcasters\NullBroadcaster;
+use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
use Illuminate\Broadcasting\Broadcasters\RedisBroadcaster;
use Illuminate\Broadcasting\Broadcasters\PusherBroadcaster;
use Illuminate\Contracts\Broadcasting\Factory as FactoryContract; | true |
Other | laravel | framework | d1a4f3fc7951c04ff91855511ed8c73b1a98e533.json | Apply fixes from StyleCI (#16639) | src/Illuminate/Cache/FileStore.php | @@ -5,8 +5,8 @@
use Exception;
use Carbon\Carbon;
use Illuminate\Support\Arr;
-use Illuminate\Filesystem\Filesystem;
use Illuminate\Contracts\Cache\Store;
+use Illuminate\Filesystem\Filesystem;
class FileStore implements Store
{ | true |
Other | laravel | framework | d1a4f3fc7951c04ff91855511ed8c73b1a98e533.json | Apply fixes from StyleCI (#16639) | src/Illuminate/Cache/MemcachedStore.php | @@ -4,8 +4,8 @@
use Memcached;
use Carbon\Carbon;
-use Illuminate\Contracts\Cache\Store;
use ReflectionMethod;
+use Illuminate\Contracts\Cache\Store;
class MemcachedStore extends TaggableStore implements Store
{ | true |
Other | laravel | framework | d1a4f3fc7951c04ff91855511ed8c73b1a98e533.json | Apply fixes from StyleCI (#16639) | src/Illuminate/Database/Connection.php | @@ -11,8 +11,8 @@
use Illuminate\Support\Arr;
use Illuminate\Database\Query\Expression;
use Illuminate\Contracts\Events\Dispatcher;
-use Illuminate\Database\Query\Processors\Processor;
use Doctrine\DBAL\Connection as DoctrineConnection;
+use Illuminate\Database\Query\Processors\Processor;
use Illuminate\Database\Query\Builder as QueryBuilder;
use Illuminate\Database\Schema\Builder as SchemaBuilder;
use Illuminate\Database\Query\Grammars\Grammar as QueryGrammar; | true |
Other | laravel | framework | d1a4f3fc7951c04ff91855511ed8c73b1a98e533.json | Apply fixes from StyleCI (#16639) | src/Illuminate/Database/DatabaseServiceProvider.php | @@ -6,8 +6,8 @@
use Faker\Generator as FakerGenerator;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\ServiceProvider;
-use Illuminate\Database\Eloquent\QueueEntityResolver;
use Illuminate\Database\Connectors\ConnectionFactory;
+use Illuminate\Database\Eloquent\QueueEntityResolver;
use Illuminate\Database\Eloquent\Factory as EloquentFactory;
class DatabaseServiceProvider extends ServiceProvider | true |
Other | laravel | framework | d1a4f3fc7951c04ff91855511ed8c73b1a98e533.json | Apply fixes from StyleCI (#16639) | src/Illuminate/Database/Eloquent/Model.php | @@ -21,11 +21,11 @@
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphTo;
-use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Database\Eloquent\Relations\MorphOne;
+use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\Collection as BaseCollection;
-use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
+use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Query\Builder as QueryBuilder;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
use Illuminate\Database\Eloquent\Relations\BelongsToMany; | true |
Other | laravel | framework | d1a4f3fc7951c04ff91855511ed8c73b1a98e533.json | Apply fixes from StyleCI (#16639) | src/Illuminate/Filesystem/FilesystemAdapter.php | @@ -13,8 +13,8 @@
use League\Flysystem\AwsS3v3\AwsS3Adapter;
use League\Flysystem\FileNotFoundException;
use League\Flysystem\Adapter\Local as LocalAdapter;
-use Illuminate\Contracts\Filesystem\Filesystem as FilesystemContract;
use Illuminate\Contracts\Filesystem\Cloud as CloudFilesystemContract;
+use Illuminate\Contracts\Filesystem\Filesystem as FilesystemContract;
use Illuminate\Contracts\Filesystem\FileNotFoundException as ContractFileNotFoundException;
class FilesystemAdapter implements FilesystemContract, CloudFilesystemContract | true |
Other | laravel | framework | d1a4f3fc7951c04ff91855511ed8c73b1a98e533.json | Apply fixes from StyleCI (#16639) | src/Illuminate/Foundation/Bootstrap/RegisterFacades.php | @@ -2,8 +2,8 @@
namespace Illuminate\Foundation\Bootstrap;
-use Illuminate\Support\Facades\Facade;
use Illuminate\Foundation\AliasLoader;
+use Illuminate\Support\Facades\Facade;
use Illuminate\Contracts\Foundation\Application;
class RegisterFacades | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.