From b84145248f95cc010c2057cff227d8264664cabd Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Thu, 5 Dec 2019 16:20:10 -0500 Subject: [PATCH] Fix dependency version, visual code tweaks --- Jenkinsfile | 6 +++--- composer.json | 6 +++--- src/ConfigInterface.php | 2 +- src/Friend.php | 2 +- src/Type/StringType.php | 4 ++-- src/View.php | 4 +++- src/View/HtmlView.php | 10 +++++++--- src/View/JsonView.php | 3 ++- tests/bootstrap.php | 4 ++-- tests/di.php | 12 ++++++------ 10 files changed, 30 insertions(+), 23 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a4bb504..fcb913e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,7 +11,7 @@ pipeline { steps { sh 'apk add --no-cache php7-phpdbg' sh 'curl -sS https://getcomposer.org/installer | php' - sh 'php composer.phar install --ignore-platform-reqs' + sh 'php composer.phar install sh 'php composer.phar run-script coverage -- --coverage-text --colors=never' } } @@ -25,7 +25,7 @@ pipeline { steps { sh 'apk add --no-cache php7-phpdbg' sh 'curl -sS https://getcomposer.org/installer | php' - sh 'php composer.phar install --ignore-platform-reqs' + sh 'php composer.phar install sh 'php composer.phar run-script coverage -- --coverage-text --colors=never' } } @@ -39,7 +39,7 @@ pipeline { steps { sh 'apk add --no-cache php7-phpdbg' sh 'curl -sS https://getcomposer.org/installer | php' - sh 'php composer.phar install --ignore-platform-reqs' + sh 'php composer.phar install sh 'php composer.phar run-script coverage -- --coverage-text --colors=never' } } diff --git a/composer.json b/composer.json index 92733fa..062f412 100644 --- a/composer.json +++ b/composer.json @@ -17,9 +17,10 @@ } }, "require": { - "aviat/query": "^2.5.1", "aura/html": "^2.5.0", - "danielstjules/stringy": "^3.2.0", + "aviat/query": "^2.5.1", + "danielstjules/stringy": "^3.1.0", + "ext-dom": "*", "ext-json": "*", "php": "^7.2", "psr/http-message": "~1.0", @@ -37,7 +38,6 @@ "phpstan/phpstan": "^0.12.0", "phpunit/phpunit": "^8.4.3", "roave/security-advisories": "dev-master", - "robmorgan/phinx": "^0.10.6", "sebastian/phpcpd": "^4.1.0", "squizlabs/php_codesniffer": "^3.0.0", "theseer/phpdox": "^0.12.0" diff --git a/src/ConfigInterface.php b/src/ConfigInterface.php index 59f05b9..19e394d 100644 --- a/src/ConfigInterface.php +++ b/src/ConfigInterface.php @@ -44,7 +44,7 @@ interface ConfigInterface { * @throws \InvalidArgumentException * @return ConfigInterface */ - public function set($key, $value): ConfigInterface; + public function set($key, $value): self; /** * Remove a config value diff --git a/src/Friend.php b/src/Friend.php index 31f9a3c..fc2f80c 100644 --- a/src/Friend.php +++ b/src/Friend.php @@ -35,7 +35,7 @@ class Friend { /** * Reflection class of the object - * @var \ReflectionClass + * @var ReflectionClass */ private $_reflect_; diff --git a/src/Type/StringType.php b/src/Type/StringType.php index 56184df..ab54bff 100644 --- a/src/Type/StringType.php +++ b/src/Type/StringType.php @@ -33,8 +33,8 @@ class StringType extends Stringy { */ public function fuzzyCaseMatch(string $strToMatch): bool { - $firstStr = self::create($this->str)->dasherize()->__toString(); - $secondStr = self::create($strToMatch)->dasherize()->__toString(); + $firstStr = (string)self::create($this->str)->dasherize(); + $secondStr = (string)self::create($strToMatch)->dasherize(); return $firstStr === $secondStr; } diff --git a/src/View.php b/src/View.php index b951c54..ff9e53e 100644 --- a/src/View.php +++ b/src/View.php @@ -50,6 +50,8 @@ abstract class View * Constructor * * @param ContainerInterface $container + * @throws Di\Exception\ContainerException + * @throws Di\Exception\NotFoundException */ public function __construct(ContainerInterface $container) { @@ -135,7 +137,7 @@ abstract class View */ public function getOutput(): string { - return $this->response->getBody()->__toString(); + return (string)$this->response->getBody(); } } // End of View.php \ No newline at end of file diff --git a/src/View/HtmlView.php b/src/View/HtmlView.php index 63daa72..b9939ee 100644 --- a/src/View/HtmlView.php +++ b/src/View/HtmlView.php @@ -16,7 +16,10 @@ namespace Aviat\Ion\View; +use Aura\Html\HelperLocator; use Aviat\Ion\Di\ContainerInterface; +use Aviat\Ion\Di\Exception\ContainerException; +use Aviat\Ion\Di\Exception\NotFoundException; /** * View class for outputting HTML @@ -26,7 +29,7 @@ class HtmlView extends HttpView { /** * HTML generator/escaper helper * - * @var \Aura\Html\HelperLocator + * @var HelperLocator */ protected $helper; @@ -41,6 +44,8 @@ class HtmlView extends HttpView { * Create the Html View * * @param ContainerInterface $container + * @throws ContainerException + * @throws NotFoundException */ public function __construct(ContainerInterface $container) { @@ -64,8 +69,7 @@ class HtmlView extends HttpView { ob_start(); extract($data, \EXTR_OVERWRITE); include_once $path; - $buffer = ob_get_contents(); - ob_end_clean(); + $buffer = ob_get_clean(); // Very basic html minify, that won't affect content between html tags diff --git a/src/View/JsonView.php b/src/View/JsonView.php index e5a6491..3716c06 100644 --- a/src/View/JsonView.php +++ b/src/View/JsonView.php @@ -17,6 +17,7 @@ namespace Aviat\Ion\View; use Aviat\Ion\Json; +use Aviat\Ion\JsonException; use Aviat\Ion\ViewInterface; /** @@ -37,7 +38,7 @@ class JsonView extends HttpView { * @param mixed $string * @throws \InvalidArgumentException * @throws \RuntimeException - * @throws \Aviat\Ion\JsonException + * @throws JsonException * @return ViewInterface */ public function setOutput($string): ViewInterface diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 799b11e..5cd5414 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -21,8 +21,8 @@ require 'Ion_TestCase.php'; // Ini Settings // ----------------------------------------------------------------------------- ini_set('session.use_cookies', 0); -ini_set("session.use_only_cookies",0); -ini_set("session.use_trans_sid",1); +ini_set('session.use_only_cookies',0); +ini_set('session.use_trans_sid',1); // Start session here to surpress error about headers not sent session_start(); diff --git a/tests/di.php b/tests/di.php index 8542826..b0c65b8 100644 --- a/tests/di.php +++ b/tests/di.php @@ -11,16 +11,16 @@ use Aviat\Ion\Di\Container; // ----------------------------------------------------------------------------- // Setup DI container // ----------------------------------------------------------------------------- -return function(array $config_array = []) { +return static function(array $config_array = []) { $container = new Container(); - $container->set('config', function() { + $container->set('config', static function() { return new Config([]); }); $container->setInstance('config', new Config($config_array)); - $container->set('request', function() { + $container->set('request', static function() { return ServerRequestFactory::fromGlobals( $_SERVER, $_GET, @@ -30,17 +30,17 @@ return function(array $config_array = []) { ); }); - $container->set('response', function() { + $container->set('response', static function() { return new Response(); }); // Create session Object - $container->set('session', function() { + $container->set('session', static function() { return (new SessionFactory())->newInstance($_COOKIE); }); // Create Html helper Object - $container->set('html-helper', function() { + $container->set('html-helper', static function() { return (new HelperLocatorFactory)->newInstance(); });