mirror of
https://github.com/getgrav/grav.git
synced 2026-05-06 17:06:36 +02:00
Some insight fixes
This commit is contained in:
@@ -2,13 +2,13 @@
|
||||
namespace Grav;
|
||||
|
||||
if (version_compare($ver = PHP_VERSION, $req = '5.4.0', '<')) {
|
||||
exit(sprintf('You are running PHP %s, but Grav needs at least <strong>PHP %s</strong> to run.', $ver, $req));
|
||||
throw new \RuntimeException(sprintf('You are running PHP %s, but Grav needs at least <strong>PHP %s</strong> to run.', $ver, $req));
|
||||
}
|
||||
|
||||
// Ensure vendor libraries exist
|
||||
$autoload = __DIR__ . '/vendor/autoload.php';
|
||||
if (!is_file($autoload)) {
|
||||
exit('Please run: <i>bin/grav install</i>');
|
||||
throw new \RuntimeException("Please run: <i>bin/grav install</i>");
|
||||
}
|
||||
|
||||
use Grav\Common\Grav;
|
||||
|
||||
@@ -120,7 +120,7 @@ class Assets
|
||||
}
|
||||
|
||||
// Set custom pipeline fetch command
|
||||
if (isset($config['fetch_command']) and ($config['fetch_command'] instanceof Closure)) {
|
||||
if (isset($config['fetch_command']) && ($config['fetch_command'] instanceof Closure)) {
|
||||
$this->fetch_command = $config['fetch_command'];
|
||||
}
|
||||
|
||||
@@ -143,12 +143,12 @@ class Assets
|
||||
}
|
||||
|
||||
// Set collections
|
||||
if (isset($config['collections']) and is_array($config['collections'])) {
|
||||
if (isset($config['collections']) && is_array($config['collections'])) {
|
||||
$this->collections = $config['collections'];
|
||||
}
|
||||
|
||||
// Autoload assets
|
||||
if (isset($config['autoload']) and is_array($config['autoload'])) {
|
||||
if (isset($config['autoload']) && is_array($config['autoload'])) {
|
||||
foreach ($config['autoload'] as $asset) {
|
||||
$this->add($asset);
|
||||
}
|
||||
@@ -651,9 +651,9 @@ class Assets
|
||||
$info = pathinfo($asset);
|
||||
if (isset($info['extension'])) {
|
||||
$ext = strtolower($info['extension']);
|
||||
if ($ext === 'css' and !in_array($asset, $this->css)) {
|
||||
if ($ext === 'css' && !in_array($asset, $this->css)) {
|
||||
$this->css[] = $asset;
|
||||
} elseif ($ext === 'js' and !in_array($asset, $this->js)) {
|
||||
} elseif ($ext === 'js' && !in_array($asset, $this->js)) {
|
||||
$this->js[] = $asset;
|
||||
}
|
||||
}
|
||||
@@ -673,8 +673,8 @@ class Assets
|
||||
*/
|
||||
protected function isRemoteLink($link)
|
||||
{
|
||||
return ('http://' === substr($link, 0, 7) or 'https://' === substr($link, 0, 8)
|
||||
or '//' === substr($link, 0, 2));
|
||||
return ('http://' === substr($link, 0, 7) || 'https://' === substr($link, 0, 8)
|
||||
|| '//' === substr($link, 0, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,7 @@ class Errors extends \Whoops\Run
|
||||
}
|
||||
|
||||
if (!$handler instanceof HandlerInterface) {
|
||||
throw new InvalidArgumentException(
|
||||
throw new \InvalidArgumentException(
|
||||
"Argument to " . __METHOD__ . " must be a callable, or instance of"
|
||||
. "Whoops\\Handler\\HandlerInterface"
|
||||
);
|
||||
|
||||
@@ -46,6 +46,11 @@ class SimplePageHandler extends Handler
|
||||
return Handler::QUIT;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $resource
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getResource($resource)
|
||||
{
|
||||
// If the resource was found before, we can speed things up
|
||||
@@ -67,7 +72,7 @@ class SimplePageHandler extends Handler
|
||||
}
|
||||
|
||||
// If we got this far, nothing was found.
|
||||
throw new RuntimeException(
|
||||
throw new \RuntimeException(
|
||||
"Could not find resource '$resource' in any resource paths."
|
||||
. "(searched: " . join(", ", $this->searchPaths). ")"
|
||||
);
|
||||
@@ -76,7 +81,7 @@ class SimplePageHandler extends Handler
|
||||
public function addResourcePath($path)
|
||||
{
|
||||
if (!is_dir($path)) {
|
||||
throw new InvalidArgumentException(
|
||||
throw new \InvalidArgumentException(
|
||||
"'$path' is not a valid directory"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ trait ParsedownGravTrait
|
||||
|
||||
protected function inlineSpecialCharacter($Excerpt)
|
||||
{
|
||||
if ($Excerpt['text'][0] === '&' and ! preg_match('/^&#?\w+;/', $Excerpt['text'])) {
|
||||
if ($Excerpt['text'][0] === '&' && ! preg_match('/^&#?\w+;/', $Excerpt['text'])) {
|
||||
return array(
|
||||
'markup' => '&',
|
||||
'extent' => 1,
|
||||
|
||||
Reference in New Issue
Block a user