Composer update
* updated Laravel to v5.6.38 * Added laravel tinker in dev dependencies
This commit is contained in:
committed by
Manish Verma
parent
be4b1231b6
commit
6742e13d81
31
vendor/psy/psysh/src/VersionUpdater/Checker.php
vendored
Normal file
31
vendor/psy/psysh/src/VersionUpdater/Checker.php
vendored
Normal 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();
|
||||
}
|
||||
89
vendor/psy/psysh/src/VersionUpdater/GitHubChecker.php
vendored
Normal file
89
vendor/psy/psysh/src/VersionUpdater/GitHubChecker.php
vendored
Normal 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);
|
||||
}
|
||||
}
|
||||
67
vendor/psy/psysh/src/VersionUpdater/IntervalChecker.php
vendored
Normal file
67
vendor/psy/psysh/src/VersionUpdater/IntervalChecker.php
vendored
Normal 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));
|
||||
}
|
||||
}
|
||||
36
vendor/psy/psysh/src/VersionUpdater/NoopChecker.php
vendored
Normal file
36
vendor/psy/psysh/src/VersionUpdater/NoopChecker.php
vendored
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user