Version 5.1 - All the GraphQL #32
@ -90,7 +90,7 @@ class ByteOrderMarkSniff implements Sniff
|
|||||||
$fileStartHex = bin2hex(substr($fileStartString, 0, $bomByteLength));
|
$fileStartHex = bin2hex(substr($fileStartString, 0, $bomByteLength));
|
||||||
if ($fileStartHex === $expectedBomHex) {
|
if ($fileStartHex === $expectedBomHex) {
|
||||||
$error = "File contains a $bomName byte order mark (BOM).";
|
$error = "File contains a $bomName byte order mark (BOM).";
|
||||||
$phpcsFile->addError($error, $stackPtr);
|
$phpcsFile->addError($error, $stackPtr, 123);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ namespace CodeIgniter\Sniffs\Strings;
|
|||||||
|
|
||||||
use PHP_CodeSniffer\Sniffs\Sniff;
|
use PHP_CodeSniffer\Sniffs\Sniff;
|
||||||
use PHP_CodeSniffer\Files\File;
|
use PHP_CodeSniffer\Files\File;
|
||||||
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CodeIgniter_Sniffs_Strings_DoubleQuoteUsageSniff.
|
* CodeIgniter_Sniffs_Strings_DoubleQuoteUsageSniff.
|
||||||
@ -104,19 +105,19 @@ class VariableUsageSniff implements Sniff
|
|||||||
$this->_parseVariable($strTokens, $strPtr);
|
$this->_parseVariable($strTokens, $strPtr);
|
||||||
} catch (Exception $err) {
|
} catch (Exception $err) {
|
||||||
$error = 'There is no variable, object nor array between curly braces. Please use the escape char for $ or {.';
|
$error = 'There is no variable, object nor array between curly braces. Please use the escape char for $ or {.';
|
||||||
$phpcsFile->addError($error, $stackPtr);
|
$phpcsFile->addError($error, $stackPtr, 234);
|
||||||
}
|
}
|
||||||
$variableFound = TRUE;
|
$variableFound = TRUE;
|
||||||
if ('}' !== $strTokens[$strPtr]) {
|
if ('}' !== $strTokens[$strPtr]) {
|
||||||
$error = 'There is no matching closing curly brace.';
|
$error = 'There is no matching closing curly brace.';
|
||||||
$phpcsFile->addError($error, $stackPtr);
|
$phpcsFile->addError($error, $stackPtr, 345);
|
||||||
}
|
}
|
||||||
// don't move forward, since it will be done in the main loop
|
// don't move forward, since it will be done in the main loop
|
||||||
// $strPtr++;
|
// $strPtr++;
|
||||||
} else if (T_VARIABLE === $strToken[0]) {
|
} else if (T_VARIABLE === $strToken[0]) {
|
||||||
$variableFound = TRUE;
|
$variableFound = TRUE;
|
||||||
$error = "Variable {$strToken[1]} in double-quoted strings should be enclosed with curly braces. Please consider {{$strToken[1]}}";
|
$error = "Variable {$strToken[1]} in double-quoted strings should be enclosed with curly braces. Please consider {{$strToken[1]}}";
|
||||||
$phpcsFile->addError($error, $stackPtr);
|
$phpcsFile->addError($error, $stackPtr, 456);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$strPtr++;
|
$strPtr++;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "aviat/hummingbird-anime-client",
|
"name": "aviat/hummingbird-anime-client",
|
||||||
"description": "A self-hosted anime/manga client for Kitsu.",
|
"description": "A self-hosted anime/manga client for Kitsu.",
|
||||||
"license":"MIT",
|
"license": "MIT",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"files": [
|
"files": [
|
||||||
"src/AnimeClient.php"
|
"src/AnimeClient.php"
|
||||||
@ -17,33 +17,32 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
"amphp/artax": "^2.0",
|
||||||
"aura/html": "^2.0",
|
"aura/html": "^2.0",
|
||||||
"aura/router": "^3.0",
|
"aura/router": "^3.0",
|
||||||
"aura/session": "^2.0",
|
"aura/session": "^2.0",
|
||||||
"aviat/banker": "^1.0.0",
|
"aviat/banker": "^1.0.0",
|
||||||
"aviat/ion": "^2.2.0",
|
"aviat/ion": "^2.2.0",
|
||||||
|
"maximebf/consolekit": "^1.0",
|
||||||
"monolog/monolog": "^1.0",
|
"monolog/monolog": "^1.0",
|
||||||
"psr/http-message": "~1.0",
|
"psr/http-message": "~1.0",
|
||||||
"psr/log": "~1.0",
|
"psr/log": "~1.0",
|
||||||
"yosymfony/toml": "^1.0",
|
"yosymfony/toml": "^1.0",
|
||||||
"zendframework/zend-diactoros": "^1.3",
|
"zendframework/zend-diactoros": "^1.3"
|
||||||
"maximebf/consolekit": "^1.0",
|
|
||||||
"amphp/artax": "^2.0"
|
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"pdepend/pdepend": "^2.2",
|
|
||||||
"sebastian/phpcpd": "^3.0",
|
|
||||||
"theseer/phpdox": "dev-master",
|
|
||||||
"phploc/phploc": "^4.0",
|
|
||||||
"phpmd/phpmd": "^2.4",
|
|
||||||
"phpunit/phpunit": "^6.0",
|
|
||||||
"robmorgan/phinx": "^0.9.1",
|
|
||||||
"consolidation/robo": "~1.0",
|
"consolidation/robo": "~1.0",
|
||||||
"henrikbjorn/lurker": "^1.1.0",
|
"henrikbjorn/lurker": "^1.1.0",
|
||||||
"symfony/var-dumper": "^4.0.1",
|
"pdepend/pdepend": "^2.2",
|
||||||
"squizlabs/php_codesniffer": "^3.0.0@beta",
|
"phploc/phploc": "^4.0",
|
||||||
|
"phpmd/phpmd": "^2.4",
|
||||||
"phpstan/phpstan": "^0.9.1",
|
"phpstan/phpstan": "^0.9.1",
|
||||||
"spatie/phpunit-snapshot-assertions": "^1.2.0"
|
"phpunit/phpunit": "^6.0",
|
||||||
|
"robmorgan/phinx": "^0.9.1",
|
||||||
|
"sebastian/phpcpd": "^3.0",
|
||||||
|
"spatie/phpunit-snapshot-assertions": "^1.2.0",
|
||||||
|
"squizlabs/php_codesniffer": "^3.0.0@beta",
|
||||||
|
"theseer/phpdox": "^0.10.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "vendor/bin/robo build",
|
"build": "vendor/bin/robo build",
|
||||||
|
12
index.php
12
index.php
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
namespace Aviat\AnimeClient;
|
namespace Aviat\AnimeClient;
|
||||||
|
|
||||||
use function Aviat\AnimeClient\loadToml;
|
|
||||||
use function Aviat\Ion\_dir;
|
use function Aviat\Ion\_dir;
|
||||||
|
|
||||||
// Work around the silly timezone error
|
// Work around the silly timezone error
|
||||||
@ -27,7 +26,7 @@ if ($timezone === '' || $timezone === FALSE)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load composer autoloader
|
// Load composer autoloader
|
||||||
require __DIR__ . '/vendor/autoload.php';
|
require_once __DIR__ . '/vendor/autoload.php';
|
||||||
|
|
||||||
// Define base directories
|
// Define base directories
|
||||||
$APP_DIR = _dir(__DIR__, 'app');
|
$APP_DIR = _dir(__DIR__, 'app');
|
||||||
@ -37,8 +36,8 @@ $CONF_DIR = _dir($APP_DIR, 'config');
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Dependency Injection setup
|
// Dependency Injection setup
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
require _dir($APPCONF_DIR, 'base_config.php'); // $base_config
|
require_once $APPCONF_DIR . '/base_config.php'; // $base_config
|
||||||
$di = require _dir($APP_DIR, 'bootstrap.php');
|
$di = require $APP_DIR . '/bootstrap.php';
|
||||||
|
|
||||||
$config = loadToml($CONF_DIR);
|
$config = loadToml($CONF_DIR);
|
||||||
$config_array = array_merge($base_config, $config);
|
$config_array = array_merge($base_config, $config);
|
||||||
@ -46,10 +45,9 @@ $config_array = array_merge($base_config, $config);
|
|||||||
$container = $di($config_array);
|
$container = $di($config_array);
|
||||||
|
|
||||||
// Unset 'constants'
|
// Unset 'constants'
|
||||||
unset($APP_DIR);
|
unset($APP_DIR, $APPCONF_DIR);
|
||||||
unset($CONF_DIR);
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Dispatch to the current route
|
// Dispatch to the current route
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
$container->get('dispatcher')->__invoke();
|
$container->get('dispatcher')();
|
@ -18,7 +18,10 @@ namespace Aviat\AnimeClient;
|
|||||||
|
|
||||||
use Yosymfony\Toml\Toml;
|
use Yosymfony\Toml\Toml;
|
||||||
|
|
||||||
define('SRC_DIR', realpath(__DIR__));
|
if ( ! defined('SRC_DIR'))
|
||||||
|
{
|
||||||
|
\define('SRC_DIR', \realpath(__DIR__));
|
||||||
|
}
|
||||||
|
|
||||||
const SESSION_SEGMENT = 'Aviat\AnimeClient\Auth';
|
const SESSION_SEGMENT = 'Aviat\AnimeClient\Auth';
|
||||||
const DEFAULT_CONTROLLER = 'Aviat\AnimeClient\Controller\Index';
|
const DEFAULT_CONTROLLER = 'Aviat\AnimeClient\Controller\Index';
|
||||||
@ -29,14 +32,17 @@ const NOT_FOUND_METHOD = 'notFound';
|
|||||||
const ERROR_MESSAGE_METHOD = 'errorPage';
|
const ERROR_MESSAGE_METHOD = 'errorPage';
|
||||||
const SRC_DIR = SRC_DIR;
|
const SRC_DIR = SRC_DIR;
|
||||||
|
|
||||||
/**
|
|
||||||
|
if ( ! \function_exists('Aviat\AnimeClient\loadToml'))
|
||||||
|
{
|
||||||
|
/**
|
||||||
* Load configuration options from .toml files
|
* Load configuration options from .toml files
|
||||||
*
|
*
|
||||||
* @param string $path - Path to load config
|
* @param string $path - Path to load config
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function loadToml(string $path): array
|
function loadToml(string $path): array
|
||||||
{
|
{
|
||||||
$output = [];
|
$output = [];
|
||||||
$files = glob("{$path}/*.toml");
|
$files = glob("{$path}/*.toml");
|
||||||
|
|
||||||
@ -44,7 +50,7 @@ function loadToml(string $path): array
|
|||||||
{
|
{
|
||||||
$key = str_replace('.toml', '', basename($file));
|
$key = str_replace('.toml', '', basename($file));
|
||||||
$toml = file_get_contents($file);
|
$toml = file_get_contents($file);
|
||||||
$config = Toml::Parse($toml);
|
$config = Toml::parse($toml);
|
||||||
|
|
||||||
if ($key === 'config')
|
if ($key === 'config')
|
||||||
{
|
{
|
||||||
@ -60,4 +66,5 @@ function loadToml(string $path): array
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
|
}
|
||||||
}
|
}
|
@ -16,19 +16,17 @@
|
|||||||
|
|
||||||
namespace Aviat\AnimeClient;
|
namespace Aviat\AnimeClient;
|
||||||
|
|
||||||
use const Aviat\AnimeClient\SESSION_SEGMENT;
|
|
||||||
|
|
||||||
use function Aviat\Ion\_dir;
|
use function Aviat\Ion\_dir;
|
||||||
|
|
||||||
use Aviat\AnimeClient\API\JsonAPI;
|
|
||||||
use Aviat\Ion\Di\{ContainerAware, ContainerInterface};
|
use Aviat\Ion\Di\{ContainerAware, ContainerInterface};
|
||||||
|
use Aviat\Ion\Exception\DoubleRenderException;
|
||||||
use Aviat\Ion\View\{HtmlView, HttpView, JsonView};
|
use Aviat\Ion\View\{HtmlView, HttpView, JsonView};
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller base, defines output methods
|
* Controller base, defines output methods
|
||||||
*
|
*
|
||||||
* @property Response object $response
|
* @property $response Response object
|
||||||
*/
|
*/
|
||||||
class Controller {
|
class Controller {
|
||||||
|
|
||||||
@ -96,6 +94,8 @@ class Controller {
|
|||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param ContainerInterface $container
|
* @param ContainerInterface $container
|
||||||
|
* @throws \Aviat\Ion\Di\ContainerException
|
||||||
|
* @throws \Aviat\Ion\Di\NotFoundException
|
||||||
*/
|
*/
|
||||||
public function __construct(ContainerInterface $container)
|
public function __construct(ContainerInterface $container)
|
||||||
{
|
{
|
||||||
@ -122,7 +122,7 @@ class Controller {
|
|||||||
|
|
||||||
// Set a 'previous' flash value for better redirects
|
// Set a 'previous' flash value for better redirects
|
||||||
$serverParams = $this->request->getServerParams();
|
$serverParams = $this->request->getServerParams();
|
||||||
if (array_key_exists('HTTP_REFERER', $serverParams))
|
if (array_key_exists('HTTP_REFERER', $serverParams) && false === stripos($serverParams['HTTP_REFERER'], 'login'))
|
||||||
{
|
{
|
||||||
$this->session->setFlash('previous', $serverParams['HTTP_REFERER']);
|
$this->session->setFlash('previous', $serverParams['HTTP_REFERER']);
|
||||||
}
|
}
|
||||||
@ -146,6 +146,8 @@ class Controller {
|
|||||||
* Set the current url in the session as the target of a future redirect
|
* Set the current url in the session as the target of a future redirect
|
||||||
*
|
*
|
||||||
* @param string|null $url
|
* @param string|null $url
|
||||||
|
* @throws \Aviat\Ion\Di\ContainerException
|
||||||
|
* @throws \Aviat\Ion\Di\NotFoundException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setSessionRedirect(string $url = NULL)
|
public function setSessionRedirect(string $url = NULL)
|
||||||
@ -159,16 +161,17 @@ class Controller {
|
|||||||
|
|
||||||
$util = $this->container->get('util');
|
$util = $this->container->get('util');
|
||||||
$doubleFormPage = $serverParams['HTTP_REFERER'] === $this->request->getUri();
|
$doubleFormPage = $serverParams['HTTP_REFERER'] === $this->request->getUri();
|
||||||
|
$isLoginPage = (bool) strpos($serverParams['HTTP_REFERER'], 'login');
|
||||||
|
|
||||||
// Don't attempt to set the redirect url if
|
// Don't attempt to set the redirect url if
|
||||||
// the page is one of the form type pages,
|
// the page is one of the form type pages,
|
||||||
// and the previous page is also a form type page_segments
|
// and the previous page is also a form type page_segments
|
||||||
if ($doubleFormPage)
|
if ($doubleFormPage || $isLoginPage)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($url))
|
if (null === $url)
|
||||||
{
|
{
|
||||||
$url = $util->isViewPage()
|
$url = $util->isViewPage()
|
||||||
? $this->request->url->get()
|
? $this->request->url->get()
|
||||||
@ -181,6 +184,9 @@ class Controller {
|
|||||||
/**
|
/**
|
||||||
* Redirect to the url previously set in the session
|
* Redirect to the url previously set in the session
|
||||||
*
|
*
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
* @throws \Aviat\Ion\Di\ContainerException
|
||||||
|
* @throws \Aviat\Ion\Di\NotFoundException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function sessionRedirect()
|
public function sessionRedirect()
|
||||||
@ -204,6 +210,8 @@ class Controller {
|
|||||||
* @param string $template
|
* @param string $template
|
||||||
* @param array $data
|
* @param array $data
|
||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
|
* @throws \Aviat\Ion\Di\ContainerException
|
||||||
|
* @throws \Aviat\Ion\Di\NotFoundException
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function loadPartial($view, string $template, array $data = [])
|
protected function loadPartial($view, string $template, array $data = [])
|
||||||
@ -235,6 +243,9 @@ class Controller {
|
|||||||
* @param HtmlView $view
|
* @param HtmlView $view
|
||||||
* @param string $template
|
* @param string $template
|
||||||
* @param array $data
|
* @param array $data
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
* @throws \Aviat\Ion\Di\ContainerException
|
||||||
|
* @throws \Aviat\Ion\Di\NotFoundException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function renderFullPage($view, string $template, array $data)
|
protected function renderFullPage($view, string $template, array $data)
|
||||||
@ -260,6 +271,11 @@ class Controller {
|
|||||||
/**
|
/**
|
||||||
* 404 action
|
* 404 action
|
||||||
*
|
*
|
||||||
|
* @param string $title
|
||||||
|
* @param string $message
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
* @throws \Aviat\Ion\Di\ContainerException
|
||||||
|
* @throws \Aviat\Ion\Di\NotFoundException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function notFound(
|
public function notFound(
|
||||||
@ -280,6 +296,9 @@ class Controller {
|
|||||||
* @param string $title
|
* @param string $title
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @param string $long_message
|
* @param string $long_message
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
* @throws \Aviat\Ion\Di\ContainerException
|
||||||
|
* @throws \Aviat\Ion\Di\NotFoundException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function errorPage(int $httpCode, string $title, string $message, string $long_message = "")
|
public function errorPage(int $httpCode, string $title, string $message, string $long_message = "")
|
||||||
@ -330,7 +349,7 @@ class Controller {
|
|||||||
/**
|
/**
|
||||||
* Helper for consistent page titles
|
* Helper for consistent page titles
|
||||||
*
|
*
|
||||||
* @param string ...$parts Title segements
|
* @param string[] ...$parts Title segments
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function formatTitle(string ...$parts) : string
|
public function formatTitle(string ...$parts) : string
|
||||||
@ -344,6 +363,9 @@ class Controller {
|
|||||||
* @param HtmlView $view
|
* @param HtmlView $view
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param string $message
|
* @param string $message
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
* @throws \Aviat\Ion\Di\ContainerException
|
||||||
|
* @throws \Aviat\Ion\Di\NotFoundException
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function showMessage($view, string $type, string $message): string
|
protected function showMessage($view, string $type, string $message): string
|
||||||
@ -361,11 +383,14 @@ class Controller {
|
|||||||
* @param array $data
|
* @param array $data
|
||||||
* @param HtmlView|null $view
|
* @param HtmlView|null $view
|
||||||
* @param int $code
|
* @param int $code
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
* @throws \Aviat\Ion\Di\ContainerException
|
||||||
|
* @throws \Aviat\Ion\Di\NotFoundException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function outputHTML(string $template, array $data = [], $view = NULL, int $code = 200)
|
protected function outputHTML(string $template, array $data = [], $view = NULL, int $code = 200)
|
||||||
{
|
{
|
||||||
if (is_null($view))
|
if (null === $view)
|
||||||
{
|
{
|
||||||
$view = new HtmlView($this->container);
|
$view = new HtmlView($this->container);
|
||||||
}
|
}
|
||||||
@ -379,6 +404,7 @@ class Controller {
|
|||||||
*
|
*
|
||||||
* @param mixed $data
|
* @param mixed $data
|
||||||
* @param int $code - the http status code
|
* @param int $code - the http status code
|
||||||
|
* @throws DoubleRenderException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function outputJSON($data = 'Empty response', int $code = 200)
|
protected function outputJSON($data = 'Empty response', int $code = 200)
|
||||||
|
@ -273,8 +273,6 @@ class Manga extends Controller {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// dump($data);
|
|
||||||
|
|
||||||
foreach($data['included'] as $included)
|
foreach($data['included'] as $included)
|
||||||
{
|
{
|
||||||
if ($included['type'] === 'characters')
|
if ($included['type'] === 'characters')
|
||||||
|
Loading…
Reference in New Issue
Block a user