Composer update

* updated Laravel to v5.6.38
* Added laravel tinker in dev dependencies
This commit is contained in:
Manish Verma
2018-09-17 10:07:24 +05:30
committed by Manish Verma
parent be4b1231b6
commit 6742e13d81
781 changed files with 32607 additions and 942 deletions

View File

@@ -0,0 +1,31 @@
<?php
/*
* This file is part of Psy Shell.
*
* (c) 2012-2018 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Psy\VersionUpdater;
interface Checker
{
const ALWAYS = 'always';
const DAILY = 'daily';
const WEEKLY = 'weekly';
const MONTHLY = 'monthly';
const NEVER = 'never';
/**
* @return bool
*/
public function isLatest();
/**
* @return string
*/
public function getLatest();
}

View File

@@ -0,0 +1,89 @@
<?php
/*
* This file is part of Psy Shell.
*
* (c) 2012-2018 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Psy\VersionUpdater;
use Psy\Shell;
class GitHubChecker implements Checker
{
const URL = 'https://api.github.com/repos/bobthecow/psysh/releases/latest';
private $latest;
/**
* @return bool
*/
public function isLatest()
{
return \version_compare(Shell::VERSION, $this->getLatest(), '>=');
}
/**
* @return string
*/
public function getLatest()
{
if (!isset($this->latest)) {
$this->setLatest($this->getVersionFromTag());
}
return $this->latest;
}
/**
* @param string $version
*/
public function setLatest($version)
{
$this->latest = $version;
}
/**
* @return string|null
*/
private function getVersionFromTag()
{
$contents = $this->fetchLatestRelease();
if (!$contents || !isset($contents->tag_name)) {
throw new \InvalidArgumentException('Unable to check for updates');
}
$this->setLatest($contents->tag_name);
return $this->getLatest();
}
/**
* Set to public to make testing easier.
*
* @return mixed
*/
public function fetchLatestRelease()
{
$context = \stream_context_create([
'http' => [
'user_agent' => 'PsySH/' . Shell::VERSION,
'timeout' => 3,
],
]);
\set_error_handler(function () {
// Just ignore all errors with this. The checker will throw an exception
// if it doesn't work :)
});
$result = @\file_get_contents(self::URL, false, $context);
\restore_error_handler();
return \json_decode($result);
}
}

View File

@@ -0,0 +1,67 @@
<?php
/*
* This file is part of Psy Shell.
*
* (c) 2012-2018 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Psy\VersionUpdater;
class IntervalChecker extends GitHubChecker
{
private $cacheFile;
private $interval;
public function __construct($cacheFile, $interval)
{
$this->cacheFile = $cacheFile;
$this->interval = $interval;
}
public function fetchLatestRelease()
{
// Read the cached file
$cached = \json_decode(@\file_get_contents($this->cacheFile, false));
if ($cached && isset($cached->last_check) && isset($cached->release)) {
$now = new \DateTime();
$lastCheck = new \DateTime($cached->last_check);
if ($lastCheck >= $now->sub($this->getDateInterval())) {
return $cached->release;
}
}
// Fall back to fetching from GitHub
$release = parent::fetchLatestRelease();
if ($release && isset($release->tag_name)) {
$this->updateCache($release);
}
return $release;
}
private function getDateInterval()
{
switch ($this->interval) {
case Checker::DAILY:
return new \DateInterval('P1D');
case Checker::WEEKLY:
return new \DateInterval('P1W');
case Checker::MONTHLY:
return new \DateInterval('P1M');
}
}
private function updateCache($release)
{
$data = [
'last_check' => \date(DATE_ATOM),
'release' => $release,
];
\file_put_contents($this->cacheFile, \json_encode($data));
}
}

View File

@@ -0,0 +1,36 @@
<?php
/*
* This file is part of Psy Shell.
*
* (c) 2012-2018 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Psy\VersionUpdater;
use Psy\Shell;
/**
* A version checker stub which always thinks the current verion is up to date.
*/
class NoopChecker implements Checker
{
/**
* @return bool
*/
public function isLatest()
{
return true;
}
/**
* @return string
*/
public function getLatest()
{
return Shell::VERSION;
}
}