From 7ff7da7850eb95a2e7a32a8161a2a3999d3dfdbb Mon Sep 17 00:00:00 2001 From: Lucas Michot Date: Tue, 18 Jul 2017 11:30:35 +0200 Subject: [PATCH 1/2] Move InteractsWithTime to Support --- src/Illuminate/Cache/DatabaseStore.php | 7 +++-- src/Illuminate/Cache/FileStore.php | 9 +++--- src/Illuminate/Cache/Lock.php | 7 +++-- src/Illuminate/Cache/MemcachedStore.php | 5 ++- src/Illuminate/Cache/RateLimiter.php | 7 +++-- src/Illuminate/Cache/Repository.php | 1 + src/Illuminate/Cookie/CookieJar.php | 5 ++- .../Foundation/Console/DownCommand.php | 5 ++- .../Http/Middleware/VerifyCsrfToken.php | 5 ++- .../Queue/Console/RestartCommand.php | 5 ++- .../Queue/Jobs/DatabaseJobRecord.php | 2 +- src/Illuminate/Queue/Jobs/Job.php | 2 +- src/Illuminate/Queue/Queue.php | 1 + .../Routing/Middleware/ThrottleRequests.php | 5 ++- .../Session/CookieSessionHandler.php | 7 +++-- .../Session/DatabaseSessionHandler.php | 7 +++-- .../{Queue => Support}/InteractsWithTime.php | 3 +- tests/Database/DatabaseEloquentModelTest.php | 7 +++-- tests/Queue/RedisQueueIntegrationTest.php | 31 ++++++++++--------- 19 files changed, 79 insertions(+), 42 deletions(-) rename src/Illuminate/{Queue => Support}/InteractsWithTime.php (96%) diff --git a/src/Illuminate/Cache/DatabaseStore.php b/src/Illuminate/Cache/DatabaseStore.php index 3428a4fb738f..2a1eec297be2 100755 --- a/src/Illuminate/Cache/DatabaseStore.php +++ b/src/Illuminate/Cache/DatabaseStore.php @@ -7,10 +7,11 @@ use Illuminate\Support\Carbon; use Illuminate\Contracts\Cache\Store; use Illuminate\Database\ConnectionInterface; +use Illuminate\Support\InteractsWithTime; class DatabaseStore implements Store { - use RetrievesMultipleKeys; + use InteractsWithTime, RetrievesMultipleKeys; /** * The database connection instance. @@ -72,7 +73,7 @@ public function get($key) // If this cache expiration date is past the current time, we will remove this // item from the cache. Then we will return a null value since the cache is // expired. We will use "Carbon" to make this comparison with the column. - if (Carbon::now()->getTimestamp() >= $cache->expiration) { + if ($this->currentTime() >= $cache->expiration) { $this->forget($key); return; @@ -186,7 +187,7 @@ protected function incrementOrDecrement($key, $value, Closure $callback) */ protected function getTime() { - return Carbon::now()->getTimestamp(); + return $this->currentTime(); } /** diff --git a/src/Illuminate/Cache/FileStore.php b/src/Illuminate/Cache/FileStore.php index 89ba6b380bd6..30076f59c720 100755 --- a/src/Illuminate/Cache/FileStore.php +++ b/src/Illuminate/Cache/FileStore.php @@ -6,10 +6,11 @@ use Illuminate\Support\Carbon; use Illuminate\Contracts\Cache\Store; use Illuminate\Filesystem\Filesystem; +use Illuminate\Support\InteractsWithTime; class FileStore implements Store { - use RetrievesMultipleKeys; + use InteractsWithTime, RetrievesMultipleKeys; /** * The Illuminate Filesystem instance. @@ -178,7 +179,7 @@ protected function getPayload($key) // If the current time is greater than expiration timestamps we will delete // the file and return null. This helps clean up the old files and keeps // this directory much cleaner for us as old files aren't hanging out. - if (Carbon::now()->getTimestamp() >= $expire) { + if ($this->currentTime() >= $expire) { $this->forget($key); return $this->emptyPayload(); @@ -189,7 +190,7 @@ protected function getPayload($key) // Next, we'll extract the number of minutes that are remaining for a cache // so that we can properly retain the time for things like the increment // operation that may be performed on this cache on a later operation. - $time = ($expire - Carbon::now()->getTimestamp()) / 60; + $time = ($expire - $this->currentTime()) / 60; return compact('data', 'time'); } @@ -225,7 +226,7 @@ protected function path($key) */ protected function expiration($minutes) { - $time = Carbon::now()->getTimestamp() + (int) ($minutes * 60); + $time = $this->availableAt((int) ($minutes * 60)); return $minutes === 0 || $time > 9999999999 ? 9999999999 : (int) $time; } diff --git a/src/Illuminate/Cache/Lock.php b/src/Illuminate/Cache/Lock.php index 74fcdb6fbc6a..8ac0677b7eb0 100644 --- a/src/Illuminate/Cache/Lock.php +++ b/src/Illuminate/Cache/Lock.php @@ -3,9 +3,12 @@ namespace Illuminate\Cache; use Illuminate\Contracts\Cache\LockTimeoutException; +use Illuminate\Support\InteractsWithTime; abstract class Lock { + use InteractsWithTime; + /** * The name of the lock. * @@ -69,12 +72,12 @@ public function get($callback = null) */ public function block($seconds, $callback = null) { - $starting = time(); + $starting = $this->currentTime(); while (! $this->acquire()) { usleep(250 * 1000); - if (time() - $seconds >= $starting) { + if ($this->currentTime() - $seconds >= $starting) { throw new LockTimeoutException; } } diff --git a/src/Illuminate/Cache/MemcachedStore.php b/src/Illuminate/Cache/MemcachedStore.php index 4311f3bcc8d4..ae51ea34a8c2 100755 --- a/src/Illuminate/Cache/MemcachedStore.php +++ b/src/Illuminate/Cache/MemcachedStore.php @@ -2,6 +2,7 @@ namespace Illuminate\Cache; +use Illuminate\Support\InteractsWithTime; use Memcached; use ReflectionMethod; use Illuminate\Support\Carbon; @@ -10,6 +11,8 @@ class MemcachedStore extends TaggableStore implements LockProvider, Store { + use InteractsWithTime; + /** * The Memcached instance. * @@ -212,7 +215,7 @@ public function flush() */ protected function toTimestamp($minutes) { - return $minutes > 0 ? Carbon::now()->addSeconds($minutes * 60)->getTimestamp() : 0; + return $minutes > 0 ? $this->availableAt($minutes * 60) : 0; } /** diff --git a/src/Illuminate/Cache/RateLimiter.php b/src/Illuminate/Cache/RateLimiter.php index c6460b8aa094..8c7b897a7aa3 100644 --- a/src/Illuminate/Cache/RateLimiter.php +++ b/src/Illuminate/Cache/RateLimiter.php @@ -4,9 +4,12 @@ use Illuminate\Support\Carbon; use Illuminate\Contracts\Cache\Repository as Cache; +use Illuminate\Support\InteractsWithTime; class RateLimiter { + use InteractsWithTime; + /** * The cache store implementation. * @@ -60,7 +63,7 @@ public function tooManyAttempts($key, $maxAttempts, $decayMinutes = 1) protected function lockout($key, $decayMinutes) { $this->cache->add( - $key.':lockout', Carbon::now()->getTimestamp() + ($decayMinutes * 60), $decayMinutes + $key.':lockout', $this->availableAt($decayMinutes * 60), $decayMinutes ); } @@ -135,6 +138,6 @@ public function clear($key) */ public function availableIn($key) { - return $this->cache->get($key.':lockout') - Carbon::now()->getTimestamp(); + return $this->cache->get($key.':lockout') - $this->currentTime(); } } diff --git a/src/Illuminate/Cache/Repository.php b/src/Illuminate/Cache/Repository.php index 2632e1f4ae41..3864677e38a4 100755 --- a/src/Illuminate/Cache/Repository.php +++ b/src/Illuminate/Cache/Repository.php @@ -12,6 +12,7 @@ use Illuminate\Contracts\Cache\Store; use Illuminate\Cache\Events\KeyWritten; use Illuminate\Cache\Events\CacheMissed; +use Illuminate\Support\InteractsWithTime; use Illuminate\Support\Traits\Macroable; use Illuminate\Cache\Events\KeyForgotten; use Illuminate\Contracts\Events\Dispatcher; diff --git a/src/Illuminate/Cookie/CookieJar.php b/src/Illuminate/Cookie/CookieJar.php index 2dcec7cc6306..db6acf35e4f9 100755 --- a/src/Illuminate/Cookie/CookieJar.php +++ b/src/Illuminate/Cookie/CookieJar.php @@ -4,11 +4,14 @@ use Illuminate\Support\Arr; use Illuminate\Support\Carbon; +use Illuminate\Support\InteractsWithTime; use Symfony\Component\HttpFoundation\Cookie; use Illuminate\Contracts\Cookie\QueueingFactory as JarContract; class CookieJar implements JarContract { + use InteractsWithTime; + /** * The default path (if specified). * @@ -62,7 +65,7 @@ public function make($name, $value, $minutes = 0, $path = null, $domain = null, { list($path, $domain, $secure, $sameSite) = $this->getPathAndDomain($path, $domain, $secure, $sameSite); - $time = ($minutes == 0) ? 0 : Carbon::now()->getTimestamp() + ($minutes * 60); + $time = ($minutes == 0) ? 0 : $this->availableAt($minutes * 60); return new Cookie($name, $value, $time, $path, $domain, $secure, $httpOnly, $raw, $sameSite); } diff --git a/src/Illuminate/Foundation/Console/DownCommand.php b/src/Illuminate/Foundation/Console/DownCommand.php index 48e021766c10..1f8237c694de 100644 --- a/src/Illuminate/Foundation/Console/DownCommand.php +++ b/src/Illuminate/Foundation/Console/DownCommand.php @@ -4,9 +4,12 @@ use Illuminate\Support\Carbon; use Illuminate\Console\Command; +use Illuminate\Support\InteractsWithTime; class DownCommand extends Command { + use InteractsWithTime; + /** * The console command signature. * @@ -45,7 +48,7 @@ public function handle() protected function getDownFilePayload() { return [ - 'time' => Carbon::now()->getTimestamp(), + 'time' => $this->currentTime(), 'message' => $this->option('message'), 'retry' => $this->getRetryTime(), ]; diff --git a/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php b/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php index 2e4337c91d88..413db01c5695 100644 --- a/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php +++ b/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php @@ -5,12 +5,15 @@ use Closure; use Illuminate\Support\Carbon; use Illuminate\Foundation\Application; +use Illuminate\Support\InteractsWithTime; use Symfony\Component\HttpFoundation\Cookie; use Illuminate\Contracts\Encryption\Encrypter; use Illuminate\Session\TokenMismatchException; class VerifyCsrfToken { + use InteractsWithTime; + /** * The application instance. * @@ -155,7 +158,7 @@ protected function addCookieToResponse($request, $response) $response->headers->setCookie( new Cookie( - 'XSRF-TOKEN', $request->session()->token(), Carbon::now()->getTimestamp() + 60 * $config['lifetime'], + 'XSRF-TOKEN', $request->session()->token(), $this->availableAt(60 * $config['lifetime']), $config['path'], $config['domain'], $config['secure'], false, false, $config['same_site'] ?? null ) ); diff --git a/src/Illuminate/Queue/Console/RestartCommand.php b/src/Illuminate/Queue/Console/RestartCommand.php index 2ddd7b87be0b..10b55d2c4650 100644 --- a/src/Illuminate/Queue/Console/RestartCommand.php +++ b/src/Illuminate/Queue/Console/RestartCommand.php @@ -4,9 +4,12 @@ use Illuminate\Support\Carbon; use Illuminate\Console\Command; +use Illuminate\Support\InteractsWithTime; class RestartCommand extends Command { + use InteractsWithTime; + /** * The console command name. * @@ -28,7 +31,7 @@ class RestartCommand extends Command */ public function handle() { - $this->laravel['cache']->forever('illuminate:queue:restart', Carbon::now()->getTimestamp()); + $this->laravel['cache']->forever('illuminate:queue:restart', $this->currentTime()); $this->info('Broadcasting queue restart signal.'); } diff --git a/src/Illuminate/Queue/Jobs/DatabaseJobRecord.php b/src/Illuminate/Queue/Jobs/DatabaseJobRecord.php index a0e2ac8b84f8..b4b5725467ef 100644 --- a/src/Illuminate/Queue/Jobs/DatabaseJobRecord.php +++ b/src/Illuminate/Queue/Jobs/DatabaseJobRecord.php @@ -2,7 +2,7 @@ namespace Illuminate\Queue\Jobs; -use Illuminate\Queue\InteractsWithTime; +use Illuminate\Support\InteractsWithTime; class DatabaseJobRecord { diff --git a/src/Illuminate/Queue/Jobs/Job.php b/src/Illuminate/Queue/Jobs/Job.php index 31b195fef7ef..cf8d84b2d73c 100755 --- a/src/Illuminate/Queue/Jobs/Job.php +++ b/src/Illuminate/Queue/Jobs/Job.php @@ -2,7 +2,7 @@ namespace Illuminate\Queue\Jobs; -use Illuminate\Queue\InteractsWithTime; +use Illuminate\Support\InteractsWithTime; abstract class Job { diff --git a/src/Illuminate/Queue/Queue.php b/src/Illuminate/Queue/Queue.php index 31b2b706cb99..4052a79a70b4 100755 --- a/src/Illuminate/Queue/Queue.php +++ b/src/Illuminate/Queue/Queue.php @@ -3,6 +3,7 @@ namespace Illuminate\Queue; use Illuminate\Container\Container; +use Illuminate\Support\InteractsWithTime; abstract class Queue { diff --git a/src/Illuminate/Routing/Middleware/ThrottleRequests.php b/src/Illuminate/Routing/Middleware/ThrottleRequests.php index eb8b47d51e90..6699f13642ae 100644 --- a/src/Illuminate/Routing/Middleware/ThrottleRequests.php +++ b/src/Illuminate/Routing/Middleware/ThrottleRequests.php @@ -3,6 +3,7 @@ namespace Illuminate\Routing\Middleware; use Closure; +use Illuminate\Support\InteractsWithTime; use RuntimeException; use Illuminate\Support\Str; use Illuminate\Support\Carbon; @@ -12,6 +13,8 @@ class ThrottleRequests { + use InteractsWithTime; + /** * The rate limiter instance. * @@ -151,7 +154,7 @@ protected function getHeaders($maxAttempts, $remainingAttempts, $retryAfter = nu if (! is_null($retryAfter)) { $headers['Retry-After'] = $retryAfter; - $headers['X-RateLimit-Reset'] = Carbon::now()->getTimestamp() + $retryAfter; + $headers['X-RateLimit-Reset'] = $this->availableAt($retryAfter); } return $headers; diff --git a/src/Illuminate/Session/CookieSessionHandler.php b/src/Illuminate/Session/CookieSessionHandler.php index be93e7667164..dc004595cb8f 100755 --- a/src/Illuminate/Session/CookieSessionHandler.php +++ b/src/Illuminate/Session/CookieSessionHandler.php @@ -2,6 +2,7 @@ namespace Illuminate\Session; +use Illuminate\Support\InteractsWithTime; use SessionHandlerInterface; use Illuminate\Support\Carbon; use Symfony\Component\HttpFoundation\Request; @@ -9,6 +10,8 @@ class CookieSessionHandler implements SessionHandlerInterface { + use InteractsWithTime; + /** * The cookie jar instance. * @@ -67,7 +70,7 @@ public function read($sessionId) $value = $this->request->cookies->get($sessionId) ?: ''; if (! is_null($decoded = json_decode($value, true)) && is_array($decoded)) { - if (isset($decoded['expires']) && Carbon::now()->getTimestamp() <= $decoded['expires']) { + if (isset($decoded['expires']) && $this->currentTime() <= $decoded['expires']) { return $decoded['data']; } } @@ -82,7 +85,7 @@ public function write($sessionId, $data) { $this->cookie->queue($sessionId, json_encode([ 'data' => $data, - 'expires' => Carbon::now()->addMinutes($this->minutes)->getTimestamp(), + 'expires' => $this->availableAt($this->minutes*60), ]), $this->minutes); return true; diff --git a/src/Illuminate/Session/DatabaseSessionHandler.php b/src/Illuminate/Session/DatabaseSessionHandler.php index ae0e1ee56c77..3424b04876db 100644 --- a/src/Illuminate/Session/DatabaseSessionHandler.php +++ b/src/Illuminate/Session/DatabaseSessionHandler.php @@ -3,6 +3,7 @@ namespace Illuminate\Session; use Illuminate\Support\Arr; +use Illuminate\Support\InteractsWithTime; use SessionHandlerInterface; use Illuminate\Support\Carbon; use Illuminate\Contracts\Auth\Guard; @@ -12,6 +13,8 @@ class DatabaseSessionHandler implements SessionHandlerInterface, ExistenceAwareInterface { + use InteractsWithTime; + /** * The database connection instance. * @@ -170,7 +173,7 @@ protected function getDefaultPayload($data) { $payload = [ 'payload' => base64_encode($data), - 'last_activity' => Carbon::now()->getTimestamp(), + 'last_activity' => $this->currentTime(), ]; if (! $this->container) { @@ -261,7 +264,7 @@ public function destroy($sessionId) */ public function gc($lifetime) { - $this->getQuery()->where('last_activity', '<=', Carbon::now()->getTimestamp() - $lifetime)->delete(); + $this->getQuery()->where('last_activity', '<=', $this->currentTime() - $lifetime)->delete(); } /** diff --git a/src/Illuminate/Queue/InteractsWithTime.php b/src/Illuminate/Support/InteractsWithTime.php similarity index 96% rename from src/Illuminate/Queue/InteractsWithTime.php rename to src/Illuminate/Support/InteractsWithTime.php index f1bdacc8b927..719fcad970ea 100644 --- a/src/Illuminate/Queue/InteractsWithTime.php +++ b/src/Illuminate/Support/InteractsWithTime.php @@ -1,10 +1,9 @@ expects($this->any())->method('getDateFormat')->will($this->returnValue('Y-m-d H:i:s')); $model->setRawAttributes([ 'created_at' => '2012-12-04', - 'updated_at' => Carbon::now()->getTimestamp(), + 'updated_at' => $this->currentTime(), ]); $this->assertInstanceOf(\Illuminate\Support\Carbon::class, $model->created_at); @@ -408,7 +411,7 @@ public function testTimestampsAreCreatedFromStringsAndIntegers() $this->assertInstanceOf(\Illuminate\Support\Carbon::class, $model->created_at); $model = new EloquentDateModelStub; - $model->created_at = Carbon::now()->getTimestamp(); + $model->created_at = $this->currentTime(); $this->assertInstanceOf(\Illuminate\Support\Carbon::class, $model->created_at); $model = new EloquentDateModelStub; diff --git a/tests/Queue/RedisQueueIntegrationTest.php b/tests/Queue/RedisQueueIntegrationTest.php index 31566d026eb2..37f119711c01 100644 --- a/tests/Queue/RedisQueueIntegrationTest.php +++ b/tests/Queue/RedisQueueIntegrationTest.php @@ -2,6 +2,7 @@ namespace Illuminate\Tests\Queue; +use Illuminate\Support\InteractsWithTime; use Mockery as m; use Illuminate\Support\Carbon; use PHPUnit\Framework\TestCase; @@ -12,7 +13,7 @@ class RedisQueueIntegrationTest extends TestCase { - use InteractsWithRedis; + use InteractsWithRedis, InteractsWithTime; /** * @var RedisQueue @@ -78,10 +79,10 @@ public function testPopProperlyPopsJobOffOfRedis($driver) $this->queue->push($job); // Pop and check it is popped correctly - $before = Carbon::now()->getTimestamp(); + $before = $this->currentTime(); /** @var RedisJob $redisJob */ $redisJob = $this->queue->pop(); - $after = Carbon::now()->getTimestamp(); + $after = $this->currentTime(); $this->assertEquals($job, unserialize(json_decode($redisJob->getRawBody())->data->command)); $this->assertEquals(1, $redisJob->attempts()); @@ -112,9 +113,9 @@ public function testPopProperlyPopsDelayedJobOffOfRedis($driver) $this->queue->later(-10, $job); // Pop and check it is popped correctly - $before = Carbon::now()->getTimestamp(); + $before = $this->currentTime(); $this->assertEquals($job, unserialize(json_decode($this->queue->pop()->getRawBody())->data->command)); - $after = Carbon::now()->getTimestamp(); + $after = $this->currentTime(); // Check reserved queue $this->assertEquals(1, $this->redis[$driver]->connection()->zcard('queues:default:reserved')); @@ -141,9 +142,9 @@ public function testPopPopsDelayedJobOffOfRedisWhenExpireNull($driver) $this->queue->later(-10, $job); // Pop and check it is popped correctly - $before = Carbon::now()->getTimestamp(); + $before = $this->currentTime(); $this->assertEquals($job, unserialize(json_decode($this->queue->pop()->getRawBody())->data->command)); - $after = Carbon::now()->getTimestamp(); + $after = $this->currentTime(); // Check reserved queue $this->assertEquals(1, $this->redis[$driver]->connection()->zcard('queues:default:reserved')); @@ -168,18 +169,18 @@ public function testNotExpireJobsWhenExpireNull($driver) // Make an expired reserved job $failed = new RedisQueueIntegrationTestJob(-20); $this->queue->push($failed); - $beforeFailPop = Carbon::now()->getTimestamp(); + $beforeFailPop = $this->currentTime(); $this->queue->pop(); - $afterFailPop = Carbon::now()->getTimestamp(); + $afterFailPop = $this->currentTime(); // Push an item into queue $job = new RedisQueueIntegrationTestJob(10); $this->queue->push($job); // Pop and check it is popped correctly - $before = Carbon::now()->getTimestamp(); + $before = $this->currentTime(); $this->assertEquals($job, unserialize(json_decode($this->queue->pop()->getRawBody())->data->command)); - $after = Carbon::now()->getTimestamp(); + $after = $this->currentTime(); // Check reserved queue $this->assertEquals(2, $this->redis[$driver]->connection()->zcard('queues:default:reserved')); @@ -214,9 +215,9 @@ public function testExpireJobsWhenExpireSet($driver) $this->queue->push($job); // Pop and check it is popped correctly - $before = Carbon::now()->getTimestamp(); + $before = $this->currentTime(); $this->assertEquals($job, unserialize(json_decode($this->queue->pop()->getRawBody())->data->command)); - $after = Carbon::now()->getTimestamp(); + $after = $this->currentTime(); // Check reserved queue $this->assertEquals(1, $this->redis[$driver]->connection()->zcard('queues:default:reserved')); @@ -244,9 +245,9 @@ public function testRelease($driver) //pop and release the job /** @var \Illuminate\Queue\Jobs\RedisJob $redisJob */ $redisJob = $this->queue->pop(); - $before = Carbon::now()->getTimestamp(); + $before = $this->currentTime(); $redisJob->release(1000); - $after = Carbon::now()->getTimestamp(); + $after = $this->currentTime(); //check the content of delayed queue $this->assertEquals(1, $this->redis[$driver]->connection()->zcard('queues:default:delayed')); From d7c0cd2ec2d75f326ba34e46fd1649505ba12293 Mon Sep 17 00:00:00 2001 From: Lucas Michot Date: Tue, 18 Jul 2017 11:42:55 +0200 Subject: [PATCH 2/2] StyleCI fix --- src/Illuminate/Cache/DatabaseStore.php | 2 +- src/Illuminate/Cache/FileStore.php | 1 - src/Illuminate/Cache/Lock.php | 2 +- src/Illuminate/Cache/MemcachedStore.php | 3 +-- src/Illuminate/Cache/RateLimiter.php | 3 +-- src/Illuminate/Cache/Repository.php | 1 - src/Illuminate/Cookie/CookieJar.php | 1 - src/Illuminate/Foundation/Console/DownCommand.php | 1 - .../Foundation/Http/Middleware/VerifyCsrfToken.php | 1 - src/Illuminate/Queue/Console/RestartCommand.php | 1 - src/Illuminate/Routing/Middleware/ThrottleRequests.php | 3 +-- src/Illuminate/Session/CookieSessionHandler.php | 5 ++--- src/Illuminate/Session/DatabaseSessionHandler.php | 2 +- tests/Database/DatabaseEloquentModelTest.php | 2 +- tests/Queue/RedisQueueIntegrationTest.php | 2 +- 15 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/Illuminate/Cache/DatabaseStore.php b/src/Illuminate/Cache/DatabaseStore.php index 2a1eec297be2..ed26e89a93d9 100755 --- a/src/Illuminate/Cache/DatabaseStore.php +++ b/src/Illuminate/Cache/DatabaseStore.php @@ -6,8 +6,8 @@ use Exception; use Illuminate\Support\Carbon; use Illuminate\Contracts\Cache\Store; -use Illuminate\Database\ConnectionInterface; use Illuminate\Support\InteractsWithTime; +use Illuminate\Database\ConnectionInterface; class DatabaseStore implements Store { diff --git a/src/Illuminate/Cache/FileStore.php b/src/Illuminate/Cache/FileStore.php index 30076f59c720..d910731fa326 100755 --- a/src/Illuminate/Cache/FileStore.php +++ b/src/Illuminate/Cache/FileStore.php @@ -3,7 +3,6 @@ namespace Illuminate\Cache; use Exception; -use Illuminate\Support\Carbon; use Illuminate\Contracts\Cache\Store; use Illuminate\Filesystem\Filesystem; use Illuminate\Support\InteractsWithTime; diff --git a/src/Illuminate/Cache/Lock.php b/src/Illuminate/Cache/Lock.php index 8ac0677b7eb0..e81bee6e08eb 100644 --- a/src/Illuminate/Cache/Lock.php +++ b/src/Illuminate/Cache/Lock.php @@ -2,8 +2,8 @@ namespace Illuminate\Cache; -use Illuminate\Contracts\Cache\LockTimeoutException; use Illuminate\Support\InteractsWithTime; +use Illuminate\Contracts\Cache\LockTimeoutException; abstract class Lock { diff --git a/src/Illuminate/Cache/MemcachedStore.php b/src/Illuminate/Cache/MemcachedStore.php index ae51ea34a8c2..00ba8b7c9411 100755 --- a/src/Illuminate/Cache/MemcachedStore.php +++ b/src/Illuminate/Cache/MemcachedStore.php @@ -2,11 +2,10 @@ namespace Illuminate\Cache; -use Illuminate\Support\InteractsWithTime; use Memcached; use ReflectionMethod; -use Illuminate\Support\Carbon; use Illuminate\Contracts\Cache\Store; +use Illuminate\Support\InteractsWithTime; use Illuminate\Contracts\Cache\LockProvider; class MemcachedStore extends TaggableStore implements LockProvider, Store diff --git a/src/Illuminate/Cache/RateLimiter.php b/src/Illuminate/Cache/RateLimiter.php index 8c7b897a7aa3..3f1ea046a5cc 100644 --- a/src/Illuminate/Cache/RateLimiter.php +++ b/src/Illuminate/Cache/RateLimiter.php @@ -2,9 +2,8 @@ namespace Illuminate\Cache; -use Illuminate\Support\Carbon; -use Illuminate\Contracts\Cache\Repository as Cache; use Illuminate\Support\InteractsWithTime; +use Illuminate\Contracts\Cache\Repository as Cache; class RateLimiter { diff --git a/src/Illuminate/Cache/Repository.php b/src/Illuminate/Cache/Repository.php index 3864677e38a4..2632e1f4ae41 100755 --- a/src/Illuminate/Cache/Repository.php +++ b/src/Illuminate/Cache/Repository.php @@ -12,7 +12,6 @@ use Illuminate\Contracts\Cache\Store; use Illuminate\Cache\Events\KeyWritten; use Illuminate\Cache\Events\CacheMissed; -use Illuminate\Support\InteractsWithTime; use Illuminate\Support\Traits\Macroable; use Illuminate\Cache\Events\KeyForgotten; use Illuminate\Contracts\Events\Dispatcher; diff --git a/src/Illuminate/Cookie/CookieJar.php b/src/Illuminate/Cookie/CookieJar.php index db6acf35e4f9..c7b263134a8d 100755 --- a/src/Illuminate/Cookie/CookieJar.php +++ b/src/Illuminate/Cookie/CookieJar.php @@ -3,7 +3,6 @@ namespace Illuminate\Cookie; use Illuminate\Support\Arr; -use Illuminate\Support\Carbon; use Illuminate\Support\InteractsWithTime; use Symfony\Component\HttpFoundation\Cookie; use Illuminate\Contracts\Cookie\QueueingFactory as JarContract; diff --git a/src/Illuminate/Foundation/Console/DownCommand.php b/src/Illuminate/Foundation/Console/DownCommand.php index 1f8237c694de..e4fa9d31bef2 100644 --- a/src/Illuminate/Foundation/Console/DownCommand.php +++ b/src/Illuminate/Foundation/Console/DownCommand.php @@ -2,7 +2,6 @@ namespace Illuminate\Foundation\Console; -use Illuminate\Support\Carbon; use Illuminate\Console\Command; use Illuminate\Support\InteractsWithTime; diff --git a/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php b/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php index 413db01c5695..01bea90da035 100644 --- a/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php +++ b/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php @@ -3,7 +3,6 @@ namespace Illuminate\Foundation\Http\Middleware; use Closure; -use Illuminate\Support\Carbon; use Illuminate\Foundation\Application; use Illuminate\Support\InteractsWithTime; use Symfony\Component\HttpFoundation\Cookie; diff --git a/src/Illuminate/Queue/Console/RestartCommand.php b/src/Illuminate/Queue/Console/RestartCommand.php index 10b55d2c4650..1b34041547e4 100644 --- a/src/Illuminate/Queue/Console/RestartCommand.php +++ b/src/Illuminate/Queue/Console/RestartCommand.php @@ -2,7 +2,6 @@ namespace Illuminate\Queue\Console; -use Illuminate\Support\Carbon; use Illuminate\Console\Command; use Illuminate\Support\InteractsWithTime; diff --git a/src/Illuminate/Routing/Middleware/ThrottleRequests.php b/src/Illuminate/Routing/Middleware/ThrottleRequests.php index 6699f13642ae..076989fc42e4 100644 --- a/src/Illuminate/Routing/Middleware/ThrottleRequests.php +++ b/src/Illuminate/Routing/Middleware/ThrottleRequests.php @@ -3,11 +3,10 @@ namespace Illuminate\Routing\Middleware; use Closure; -use Illuminate\Support\InteractsWithTime; use RuntimeException; use Illuminate\Support\Str; -use Illuminate\Support\Carbon; use Illuminate\Cache\RateLimiter; +use Illuminate\Support\InteractsWithTime; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\HttpException; diff --git a/src/Illuminate/Session/CookieSessionHandler.php b/src/Illuminate/Session/CookieSessionHandler.php index dc004595cb8f..e91053d0b63f 100755 --- a/src/Illuminate/Session/CookieSessionHandler.php +++ b/src/Illuminate/Session/CookieSessionHandler.php @@ -2,9 +2,8 @@ namespace Illuminate\Session; -use Illuminate\Support\InteractsWithTime; use SessionHandlerInterface; -use Illuminate\Support\Carbon; +use Illuminate\Support\InteractsWithTime; use Symfony\Component\HttpFoundation\Request; use Illuminate\Contracts\Cookie\QueueingFactory as CookieJar; @@ -85,7 +84,7 @@ public function write($sessionId, $data) { $this->cookie->queue($sessionId, json_encode([ 'data' => $data, - 'expires' => $this->availableAt($this->minutes*60), + 'expires' => $this->availableAt($this->minutes * 60), ]), $this->minutes); return true; diff --git a/src/Illuminate/Session/DatabaseSessionHandler.php b/src/Illuminate/Session/DatabaseSessionHandler.php index 3424b04876db..88d0c2e993a2 100644 --- a/src/Illuminate/Session/DatabaseSessionHandler.php +++ b/src/Illuminate/Session/DatabaseSessionHandler.php @@ -3,11 +3,11 @@ namespace Illuminate\Session; use Illuminate\Support\Arr; -use Illuminate\Support\InteractsWithTime; use SessionHandlerInterface; use Illuminate\Support\Carbon; use Illuminate\Contracts\Auth\Guard; use Illuminate\Database\QueryException; +use Illuminate\Support\InteractsWithTime; use Illuminate\Database\ConnectionInterface; use Illuminate\Contracts\Container\Container; diff --git a/tests/Database/DatabaseEloquentModelTest.php b/tests/Database/DatabaseEloquentModelTest.php index bae1bc3f962a..9e38b0f71b5b 100755 --- a/tests/Database/DatabaseEloquentModelTest.php +++ b/tests/Database/DatabaseEloquentModelTest.php @@ -3,7 +3,6 @@ namespace Illuminate\Tests\Database; use DateTime; -use Illuminate\Support\InteractsWithTime; use stdClass; use Exception; use Mockery as m; @@ -14,6 +13,7 @@ use PHPUnit\Framework\TestCase; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Support\InteractsWithTime; use Illuminate\Database\Eloquent\Relations\Relation; class DatabaseEloquentModelTest extends TestCase diff --git a/tests/Queue/RedisQueueIntegrationTest.php b/tests/Queue/RedisQueueIntegrationTest.php index 37f119711c01..f2187168f585 100644 --- a/tests/Queue/RedisQueueIntegrationTest.php +++ b/tests/Queue/RedisQueueIntegrationTest.php @@ -2,13 +2,13 @@ namespace Illuminate\Tests\Queue; -use Illuminate\Support\InteractsWithTime; use Mockery as m; use Illuminate\Support\Carbon; use PHPUnit\Framework\TestCase; use Illuminate\Queue\RedisQueue; use Illuminate\Container\Container; use Illuminate\Queue\Jobs\RedisJob; +use Illuminate\Support\InteractsWithTime; use Illuminate\Tests\Redis\InteractsWithRedis; class RedisQueueIntegrationTest extends TestCase