Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.3] Directly use getTimestamp() #15549

Merged
merged 1 commit into from
Sep 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Illuminate/Cache/DatabaseStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function get($key)
$cache = (object) $cache;
}

if (Carbon::now()->timestamp >= $cache->expiration) {
if (Carbon::now()->getTimestamp() >= $cache->expiration) {
$this->forget($key);

return;
Expand Down Expand Up @@ -187,7 +187,7 @@ protected function incrementOrDecrement($key, $value, Closure $callback)
*/
protected function getTime()
{
return Carbon::now()->timestamp;
return Carbon::now()->getTimestamp();
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Illuminate/Cache/FileStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,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()->timestamp >= $expire) {
if (Carbon::now()->getTimestamp() >= $expire) {
$this->forget($key);

return ['data' => null, 'time' => null];
Expand All @@ -85,7 +85,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 the cache.
$time = ($expire - Carbon::now()->timestamp) / 60;
$time = ($expire - Carbon::now()->getTimestamp()) / 60;

return compact('data', 'time');
}
Expand Down Expand Up @@ -214,7 +214,7 @@ protected function path($key)
*/
protected function expiration($minutes)
{
$time = Carbon::now()->timestamp + (int) ($minutes * 60);
$time = Carbon::now()->getTimestamp() + (int) ($minutes * 60);

if ($minutes === 0 || $time > 9999999999) {
return 9999999999;
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Cache/MemcachedStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public function flush()
*/
protected function toTimestamp($minutes)
{
return $minutes > 0 ? Carbon::now()->addMinutes($minutes)->timestamp : 0;
return $minutes > 0 ? Carbon::now()->addMinutes($minutes)->getTimestamp() : 0;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Cache/RateLimiter.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function tooManyAttempts($key, $maxAttempts, $decayMinutes = 1)
}

if ($this->attempts($key) > $maxAttempts) {
$this->cache->add($key.':lockout', Carbon::now()->timestamp + ($decayMinutes * 60), $decayMinutes);
$this->cache->add($key.':lockout', Carbon::now()->getTimestamp() + ($decayMinutes * 60), $decayMinutes);

$this->resetAttempts($key);

Expand Down Expand Up @@ -121,6 +121,6 @@ public function clear($key)
*/
public function availableIn($key)
{
return $this->cache->get($key.':lockout') - Carbon::now()->timestamp;
return $this->cache->get($key.':lockout') - Carbon::now()->getTimestamp();
}
}
2 changes: 1 addition & 1 deletion src/Illuminate/Console/Scheduling/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ public function unlessBetween($startTime, $endTime)
private function inTimeInterval($startTime, $endTime)
{
return function () use ($startTime, $endTime) {
$now = Carbon::now()->timestamp;
$now = Carbon::now()->getTimestamp();

return $now >= strtotime($startTime) && $now <= strtotime($endTime);
};
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Cookie/CookieJar.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function make($name, $value, $minutes = 0, $path = null, $domain = null,
{
list($path, $domain, $secure) = $this->getPathAndDomain($path, $domain, $secure);

$time = ($minutes == 0) ? 0 : Carbon::now()->timestamp + ($minutes * 60);
$time = ($minutes == 0) ? 0 : Carbon::now()->getTimestamp() + ($minutes * 60);

return new Cookie($name, $value, $time, $path, $domain, $secure, $httpOnly);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Console/DownCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function fire()
protected function getDownFilePayload()
{
return [
'time' => Carbon::now()->timestamp,
'time' => Carbon::now()->getTimestamp(),
'message' => $this->option('message'),
'retry' => $this->getRetryTime(),
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ protected function addCookieToResponse($request, $response)

$response->headers->setCookie(
new Cookie(
'XSRF-TOKEN', $request->session()->token(), Carbon::now()->timestamp + 60 * $config['lifetime'],
'XSRF-TOKEN', $request->session()->token(), Carbon::now()->getTimestamp() + 60 * $config['lifetime'],
$config['path'], $config['domain'], $config['secure'], false
)
);
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Queue/Console/RestartCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class RestartCommand extends Command
*/
public function fire()
{
$this->laravel['cache']->forever('illuminate:queue:restart', Carbon::now()->timestamp);
$this->laravel['cache']->forever('illuminate:queue:restart', Carbon::now()->getTimestamp());

$this->info('Broadcasting queue restart signal.');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Queue/Jobs/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ protected function getSeconds($delay)
*/
protected function getTime()
{
return Carbon::now()->timestamp;
return Carbon::now()->getTimestamp();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Queue/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ protected function getSeconds($delay)
*/
protected function getTime()
{
return Carbon::now()->timestamp;
return Carbon::now()->getTimestamp();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Routing/Middleware/ThrottleRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected function addHeaders(Response $response, $maxAttempts, $remainingAttemp

if (! is_null($retryAfter)) {
$headers['Retry-After'] = $retryAfter;
$headers['X-RateLimit-Reset'] = Carbon::now()->timestamp + $retryAfter;
$headers['X-RateLimit-Reset'] = Carbon::now()->getTimestamp() + $retryAfter;
}

$response->headers->add($headers);
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Session/CookieSessionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,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()->timestamp <= $decoded['expires']) {
if (isset($decoded['expires']) && Carbon::now()->getTimestamp() <= $decoded['expires']) {
return $decoded['data'];
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Session/DatabaseSessionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function write($sessionId, $data)
*/
protected function getDefaultPayload($data)
{
$payload = ['payload' => base64_encode($data), 'last_activity' => Carbon::now()->timestamp];
$payload = ['payload' => base64_encode($data), 'last_activity' => Carbon::now()->getTimestamp()];

if (! $container = $this->container) {
return $payload;
Expand Down Expand Up @@ -164,7 +164,7 @@ public function destroy($sessionId)
*/
public function gc($lifetime)
{
$this->getQuery()->where('last_activity', '<=', Carbon::now()->timestamp - $lifetime)->delete();
$this->getQuery()->where('last_activity', '<=', Carbon::now()->getTimestamp() - $lifetime)->delete();
}

/**
Expand Down