From a2cb95aa5b5891f0863d776d2bf386a1cfa2e626 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Thu, 5 Dec 2019 15:25:47 -0500 Subject: [PATCH] Update dependencies --- .gitignore | 1 + .travis.yml | 2 + Jenkinsfile | 34 ++++-- .../Sniffs/Commenting/InlineCommentSniff.php | 4 +- build/docker_install.sh | 11 -- build/header_comment.txt | 2 +- composer.json | 102 +++++++++--------- tests/ConfigTest.php | 3 +- tests/Di/ContainerAwareTest.php | 3 +- tests/Di/ContainerTest.php | 54 +++++----- tests/EnumTest.php | 3 +- tests/FriendTest.php | 3 +- tests/Ion_TestCase.php | 19 ++-- tests/StringWrapperTest.php | 3 +- tests/Transformer/AbstractTransformerTest.php | 3 +- tests/Type/ArrayTypeTest.php | 3 +- tests/View/HtmlViewTest.php | 3 +- tests/View/HttpViewTest.php | 3 +- tests/View/JsonViewTest.php | 3 +- tests/XMLTest.php | 15 ++- 20 files changed, 138 insertions(+), 136 deletions(-) delete mode 100644 build/docker_install.sh diff --git a/.gitignore b/.gitignore index 603fd50..f5961d9 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ build/humbuglog.txt phpdoc/ tests/test_data/json_write.json tests/test_data/sessions/ +.phpunit.result.cache \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 405517d..950a8e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,8 @@ install: php: - 7.1 - 7.2 + - 7.3 + - 7.4 - nightly script: diff --git a/Jenkinsfile b/Jenkinsfile index 7bd347a..debe479 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,8 +9,6 @@ pipeline { } } steps { - sh 'chmod +x ./build/docker_install.sh' - sh 'sh build/docker_install.sh' sh 'apk add --no-cache php7-phpdbg' sh 'curl -sS https://getcomposer.org/installer | php' sh 'php composer.phar install --ignore-platform-reqs' @@ -25,8 +23,6 @@ pipeline { } } steps { - sh 'chmod +x ./build/docker_install.sh' - sh 'sh build/docker_install.sh' sh 'apk add --no-cache php7-phpdbg' sh 'curl -sS https://getcomposer.org/installer | php' sh 'php composer.phar install --ignore-platform-reqs' @@ -41,8 +37,34 @@ pipeline { } } steps { - sh 'chmod +x ./build/docker_install.sh' - sh 'sh build/docker_install.sh' + 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 run-script coverage -- --coverage-text --colors=never' + } + } + stage('PHP 7.3') { + agent { + docker { + image 'php:7.3-alpine' + args '-u root --privileged' + } + } + 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 run-script coverage -- --coverage-text --colors=never' + } + } + stage('PHP 7.4') { + agent { + docker { + image 'php:7.4-alpine' + args '-u root --privileged' + } + } + steps { sh 'apk add --no-cache php7-phpdbg' sh 'curl -sS https://getcomposer.org/installer | php' sh 'php composer.phar install --ignore-platform-reqs' diff --git a/build/CodeIgniter/Sniffs/Commenting/InlineCommentSniff.php b/build/CodeIgniter/Sniffs/Commenting/InlineCommentSniff.php index d8e51eb..9fb43b0 100644 --- a/build/CodeIgniter/Sniffs/Commenting/InlineCommentSniff.php +++ b/build/CodeIgniter/Sniffs/Commenting/InlineCommentSniff.php @@ -93,12 +93,12 @@ class InlineCommentSniff implements Sniff private function _checkCommentStyle(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - if ($tokens[$stackPtr]['content']{0} === '#') { + if ($tokens[$stackPtr]['content'][0] === '#') { $error = 'Perl-style comments are not allowed; use "// Comment" or DocBlock comments instead'; $phpcsFile->addError($error, $stackPtr, 'WrongStyle'); return FALSE; } else if (substr($tokens[$stackPtr]['content'], 0, 2) === '/*' - || $tokens[$stackPtr]['content']{0} === '*' + || $tokens[$stackPtr]['content'][0] === '*' ) { $error = 'Multi lines comments are not allowed; use "// Comment" DocBlock comments instead'; $phpcsFile->addError($error, $stackPtr, 'WrongStyle'); diff --git a/build/docker_install.sh b/build/docker_install.sh deleted file mode 100644 index 66bccc5..0000000 --- a/build/docker_install.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -# We need to install dependencies only for Docker -[[ ! -e /.dockerenv ]] && [[ ! -e /.dockerinit ]] && exit 0 - -set -xe - -# Install git (the php image doesn't have it) which is required by composer -apk --update add --no-cache \ - curl \ - git diff --git a/build/header_comment.txt b/build/header_comment.txt index ea5a646..baf0af8 100644 --- a/build/header_comment.txt +++ b/build/header_comment.txt @@ -7,7 +7,7 @@ * * @package Ion * @author Timothy J. Warren - * @copyright 2015 - 2018 Timothy J. Warren + * @copyright 2015 - 2019 Timothy J. Warren * @license http://www.opensource.org/licenses/mit-license.html MIT License * @version 2.4.1 * @link https://git.timshomepage.net/timw4mail/ion diff --git a/composer.json b/composer.json index f799a6e..c9479cf 100644 --- a/composer.json +++ b/composer.json @@ -1,54 +1,54 @@ { - "name": "aviat/ion", - "description": "Basic PHP Framework", - "license":"MIT", - "autoload": { - "files": [ - "src/functions.php" - ], - "psr-4": { - "Aviat\\Ion\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "Aviat\\Ion\\Tests\\": "tests/", - "CodeIgniter\\": "build/CodeIgniter/" - } - }, - "require": { - "aviat/query": "^2.5", - "aura/html": "2.*", - "container-interop/container-interop": "1.*", - "danielstjules/stringy": "^3.0.0", - "ext-json": "*", - "psr/http-message": "~1.0", - "psr/log": "~1.0", - "zendframework/zend-diactoros": "^2.0.0", - "zendframework/zend-httphandlerrunner": "^1.0" - }, - "require-dev": { - "aura/session": "^2.1.0", - "consolidation/robo": "^1.1.0", - "monolog/monolog": "1.*", - "pdepend/pdepend": "^2.2", - "phploc/phploc": "^4.0", - "phpmd/phpmd": "^2.4", - "phpstan/phpstan": "^0.9.1", - "phpunit/phpunit": "^6.5.13", - "robmorgan/phinx": "^0.10.6", - "sebastian/phpcpd": "^3.0.1", - "squizlabs/php_codesniffer": "^3.0.0", - "theseer/phpdox": "^0.11.0" - }, - "scripts": { - "coverage": "phpdbg -qrr -- vendor/bin/phpunit -c build", - "build": "robo build", - "docs": "cd build && ../vendor/bin/phpdox && cd ..", - "phpstan": "phpstan analyse -l 7 -c phpstan.neon src tests", - "test": "phpunit -c phpunit.dist.xml" - }, - "suggest": { - "monolog/monolog": "Provides implementation of psr/log" + "name": "aviat/ion", + "description": "Basic PHP Framework", + "license": "MIT", + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "Aviat\\Ion\\": "src/" } + }, + "autoload-dev": { + "psr-4": { + "Aviat\\Ion\\Tests\\": "tests/", + "CodeIgniter\\": "build/CodeIgniter/" + } + }, + "require": { + "aviat/query": "^2.5", + "aura/html": "2.*", + "danielstjules/stringy": "^3.0.0", + "ext-json": "*", + "psr/http-message": "~1.0", + "psr/log": "~1.0", + "zendframework/zend-diactoros": "^2.0.0", + "zendframework/zend-httphandlerrunner": "^1.0" + }, + "require-dev": { + "aura/session": "^2.1.0", + "consolidation/robo": "^2.0.0", + "monolog/monolog": "^2.0.1", + "pdepend/pdepend": "^2.2", + "phploc/phploc": "^5.0", + "phpmd/phpmd": "^2.4", + "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" + }, + "scripts": { + "coverage": "phpdbg -qrr -- vendor/bin/phpunit -c build", + "build": "robo build", + "docs": "cd build && ../vendor/bin/phpdox && cd ..", + "phpstan": "phpstan analyse -l 7 -c phpstan.neon src tests", + "test": "phpunit -c phpunit.dist.xml" + }, + "suggest": { + "monolog/monolog": "Provides implementation of psr/log" + } } diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index f451fa3..c62c088 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -20,8 +20,7 @@ use Aviat\Ion\Config; class ConfigTest extends Ion_TestCase { - public function setUp() - { + public function setUp(): void { $this->config = new Config([ 'foo' => 'bar', 'asset_path' => '/assets', diff --git a/tests/Di/ContainerAwareTest.php b/tests/Di/ContainerAwareTest.php index 8f1a92e..8ec3710 100644 --- a/tests/Di/ContainerAwareTest.php +++ b/tests/Di/ContainerAwareTest.php @@ -33,8 +33,7 @@ class ContainerAwareTest extends Ion_TestCase { protected $aware; - public function setUp() - { + public function setUp(): void { $this->container = new Container(); $this->aware = new Aware($this->container); } diff --git a/tests/Di/ContainerTest.php b/tests/Di/ContainerTest.php index f7464aa..b686531 100644 --- a/tests/Di/ContainerTest.php +++ b/tests/Di/ContainerTest.php @@ -21,6 +21,8 @@ use Aviat\Ion\Di\Exception\ContainerException; use Aviat\Ion\Tests\Ion_TestCase; use Monolog\Logger; use Monolog\Handler\{TestHandler, NullHandler}; +use Aviat\Ion\Di\ContainerInterface; +use Aviat\Ion\Di\Exception\NotFoundException; class FooTest { @@ -37,27 +39,27 @@ class FooTest2 { class ContainerTest extends Ion_TestCase { - public function setUp() + public function setUp(): void { $this->container = new Container(); } - public function dataGetWithException() + public function dataGetWithException(): array { return [ 'Bad index type: number' => [ 'id' => 42, - 'exception' => 'Aviat\Ion\Di\Exception\ContainerException', + 'exception' => ContainerException::class, 'message' => 'Id must be a string' ], 'Bad index type: array' => [ 'id' => [], - 'exception' => 'Aviat\Ion\Di\Exception\ContainerException', + 'exception' => ContainerException::class, 'message' => 'Id must be a string' ], 'Non-existent id' => [ 'id' => 'foo', - 'exception' => 'Aviat\Ion\Di\Exception\NotFoundException', + 'exception' => NotFoundException::class, 'message' => "Item 'foo' does not exist in container." ] ]; @@ -66,7 +68,7 @@ class ContainerTest extends Ion_TestCase { /** * @dataProvider dataGetWithException */ - public function testGetWithException($id, $exception, $message) + public function testGetWithException($id, $exception, $message): void { try { @@ -82,24 +84,24 @@ class ContainerTest extends Ion_TestCase { /** * @dataProvider dataGetWithException */ - public function testGetNewWithException($id, $exception, $message) + public function testGetNewWithException($id, $exception, $message): void { $this->expectException($exception); $this->expectExceptionMessage($message); $this->container->getNew($id); } - public function dataSetInstanceWithException() + public function dataSetInstanceWithException(): array { return [ 'Non-existent id' => [ 'id' => 'foo', - 'exception' => 'Aviat\Ion\Di\Exception\NotFoundException', + 'exception' => NotFoundException::class, 'message' => "Factory 'foo' does not exist in container. Set that first.", ], 'Non-existent id 2' => [ 'id' => 'foobarbaz', - 'exception' => 'Aviat\Ion\Di\Exception\NotFoundException', + 'exception' => NotFoundException::class, 'message' => "Factory 'foobarbaz' does not exist in container. Set that first.", ], ]; @@ -108,7 +110,7 @@ class ContainerTest extends Ion_TestCase { /** * @dataProvider dataSetInstanceWithException */ - public function testSetInstanceWithException($id, $exception, $message) + public function testSetInstanceWithException($id, $exception, $message): void { try { @@ -121,21 +123,21 @@ class ContainerTest extends Ion_TestCase { } } - public function testGetNew() + public function testGetNew(): void { - $this->container->set('footest', function($item) { + $this->container->set('footest', static function($item) { return new FooTest($item); }); // Check that the item is the container, if called without arguments $footest1 = $this->container->getNew('footest'); - $this->assertInstanceOf('Aviat\Ion\Di\ContainerInterface', $footest1->item); + $this->assertInstanceOf(ContainerInterface::class, $footest1->item); $footest2 = $this->container->getNew('footest', ['Test String']); $this->assertEquals('Test String', $footest2->item); } - public function testSetContainerInInstance() + public function testSetContainerInInstance(): void { $this->container->set('footest2', function() { return new FooTest2(); @@ -145,36 +147,36 @@ class ContainerTest extends Ion_TestCase { $this->assertEquals($this->container, $footest2->getContainer()); } - public function testGetNewReturnCallable() + public function testGetNewReturnCallable(): void { - $this->container->set('footest', function($item) { - return function() use ($item) { + $this->container->set('footest', static function($item) { + return static function() use ($item) { return $item; }; }); // Check that the item is the container, if called without arguments $footest1 = $this->container->getNew('footest'); - $this->assertInstanceOf('Aviat\Ion\Di\ContainerInterface', $footest1()); + $this->assertInstanceOf(ContainerInterface::class, $footest1()); $footest2 = $this->container->getNew('footest', ['Test String']); $this->assertEquals('Test String', $footest2()); } - public function testGetSet() + public function testGetSet(): void { - $container = $this->container->set('foo', function() { - return function() {}; + $container = $this->container->set('foo', static function() { + return static function() {}; }); $this->assertInstanceOf(Container::class, $container); - $this->assertInstanceOf('Aviat\Ion\Di\ContainerInterface', $container); + $this->assertInstanceOf(ContainerInterface::class, $container); // The factory returns a callable $this->assertTrue(is_callable($container->get('foo'))); } - public function testLoggerMethods() + public function testLoggerMethods(): void { // Does the container have the default logger? $this->assertFalse($this->container->hasLogger()); @@ -189,8 +191,8 @@ class ContainerTest extends Ion_TestCase { $container = $this->container->setLogger($logger1); $container2 = $this->container->setLogger($logger2, 'test'); - $this->assertInstanceOf('Aviat\Ion\Di\ContainerInterface', $container); - $this->assertInstanceOf('Aviat\Ion\Di\Container', $container2); + $this->assertInstanceOf(ContainerInterface::class, $container); + $this->assertInstanceOf(Container::class, $container2); $this->assertEquals($logger1, $this->container->getLogger('default')); $this->assertEquals($logger2, $this->container->getLogger('test')); diff --git a/tests/EnumTest.php b/tests/EnumTest.php index 94263ad..36113f6 100644 --- a/tests/EnumTest.php +++ b/tests/EnumTest.php @@ -26,8 +26,7 @@ class EnumTest extends Ion_TestCase { 'FOOBAR' => 'baz' ]; - public function setUp() - { + public function setUp(): void { parent::setUp(); $this->enum = new TestEnum(); } diff --git a/tests/FriendTest.php b/tests/FriendTest.php index 22c76cf..ef1a140 100644 --- a/tests/FriendTest.php +++ b/tests/FriendTest.php @@ -21,8 +21,7 @@ use Aviat\Ion\Tests\FriendTestClass; class FriendTest extends Ion_TestCase { - public function setUp() - { + public function setUp(): void { parent::setUp(); $obj = new FriendTestClass(); $this->friend = new Friend($obj); diff --git a/tests/Ion_TestCase.php b/tests/Ion_TestCase.php index 5fb7933..74b22bb 100644 --- a/tests/Ion_TestCase.php +++ b/tests/Ion_TestCase.php @@ -18,11 +18,8 @@ namespace Aviat\Ion\Tests; use function Aviat\Ion\_dir; -use Aura\Web\WebFactory; -use Aviat\Ion\Json; use PHPUnit\Framework\TestCase; use Zend\Diactoros\ServerRequestFactory; -use Zend\Diactoros\Response as HttpResponse; define('ROOT_DIR', realpath(__DIR__ . '/../') . '/'); define('SRC_DIR', ROOT_DIR . 'src/'); @@ -34,10 +31,10 @@ define('TEST_VIEW_DIR', __DIR__ . '/test_views'); */ class Ion_TestCase extends TestCase { // Test directory constants - const ROOT_DIR = ROOT_DIR; - const SRC_DIR = SRC_DIR; - const TEST_DATA_DIR = TEST_DATA_DIR; - const TEST_VIEW_DIR = TEST_VIEW_DIR; + public const ROOT_DIR = ROOT_DIR; + public const SRC_DIR = SRC_DIR; + public const TEST_DATA_DIR = TEST_DATA_DIR; + public const TEST_VIEW_DIR = TEST_VIEW_DIR; protected $container; protected static $staticContainer; @@ -51,7 +48,7 @@ class Ion_TestCase extends TestCase { self::$session_handler = $session_handler; }*/ - public function setUp() + public function setUp(): void { parent::setUp(); @@ -100,7 +97,7 @@ class Ion_TestCase extends TestCase { // Set up DI container $di = require('di.php'); $container = $di($config_array); - $container->set('session-handler', function() { + $container->set('session-handler', static function() { // Use mock session handler $session_handler = new TestSessionHandler(); session_set_save_handler($session_handler, TRUE); @@ -116,7 +113,7 @@ class Ion_TestCase extends TestCase { * @param array $supers * @return void */ - public function setSuperGlobals(array $supers = []) + public function setSuperGlobals(array $supers = []): void { $default = [ '_SERVER' => $_SERVER, @@ -127,7 +124,7 @@ class Ion_TestCase extends TestCase { ]; $request = call_user_func_array( - ['Zend\Diactoros\ServerRequestFactory', 'fromGlobals'], + [ServerRequestFactory::class, 'fromGlobals'], array_merge($default, $supers) ); $this->container->setInstance('request', $request); diff --git a/tests/StringWrapperTest.php b/tests/StringWrapperTest.php index 1c93db6..3fd8864 100644 --- a/tests/StringWrapperTest.php +++ b/tests/StringWrapperTest.php @@ -24,8 +24,7 @@ class StringWrapperTest extends TestCase { protected $wrapper; - public function setUp() - { + public function setUp(): void { $this->wrapper = new class { use StringWrapper; }; diff --git a/tests/Transformer/AbstractTransformerTest.php b/tests/Transformer/AbstractTransformerTest.php index f81aceb..5bf1a22 100644 --- a/tests/Transformer/AbstractTransformerTest.php +++ b/tests/Transformer/AbstractTransformerTest.php @@ -25,8 +25,7 @@ class AbstractTransformerTest extends Ion_TestCase { protected $untransformer; - public function setUp() - { + public function setUp(): void { $this->transformer = new TestTransformer(); $this->untransformer = new TestTransformerUntransform(); } diff --git a/tests/Type/ArrayTypeTest.php b/tests/Type/ArrayTypeTest.php index f4f259d..08283ee 100644 --- a/tests/Type/ArrayTypeTest.php +++ b/tests/Type/ArrayTypeTest.php @@ -22,8 +22,7 @@ use Aviat\Ion\Tests\Ion_TestCase; class ArrayTypeTest extends Ion_TestCase { use ArrayWrapper; - public function setUp() - { + public function setUp(): void { parent::setUp(); } diff --git a/tests/View/HtmlViewTest.php b/tests/View/HtmlViewTest.php index a00d542..defe352 100644 --- a/tests/View/HtmlViewTest.php +++ b/tests/View/HtmlViewTest.php @@ -24,8 +24,7 @@ class HtmlViewTest extends HttpViewTest { protected $template_path; - public function setUp() - { + public function setUp(): void { parent::setUp(); $this->view = new TestHtmlView($this->container); } diff --git a/tests/View/HttpViewTest.php b/tests/View/HttpViewTest.php index 20d1455..de8b319 100644 --- a/tests/View/HttpViewTest.php +++ b/tests/View/HttpViewTest.php @@ -26,8 +26,7 @@ class HttpViewTest extends Ion_TestCase { protected $view; protected $friend; - public function setUp() - { + public function setUp(): void { parent::setUp(); $this->view = new TestHttpView($this->container); $this->friend = new Friend($this->view); diff --git a/tests/View/JsonViewTest.php b/tests/View/JsonViewTest.php index 3a67698..055adbe 100644 --- a/tests/View/JsonViewTest.php +++ b/tests/View/JsonViewTest.php @@ -21,8 +21,7 @@ use Aviat\Ion\Tests\TestJsonView; class JsonViewTest extends HttpViewTest { - public function setUp() - { + public function setUp(): void { parent::setUp(); $this->view = new TestJsonView($this->container); diff --git a/tests/XMLTest.php b/tests/XMLTest.php index 33ba504..e8699e5 100644 --- a/tests/XMLTest.php +++ b/tests/XMLTest.php @@ -1,17 +1,17 @@ - * @copyright 2015 - 2018 Timothy J. Warren + * @copyright 2015 - 2018 Timothy J. Warren * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @version 2.4.1 - * @link https://git.timshomepage.net/timw4mail/ion + * @version 4.1 + * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient */ namespace Aviat\Ion\Tests; @@ -26,8 +26,7 @@ class XMLTest extends TestCase { protected $object; protected $array; - public function setUp() - { + public function setUp(): void { $this->xml = file_get_contents(__DIR__ . '/test_data/XML/xmlTestFile.xml'); $this->expectedXml = file_get_contents(__DIR__ . '/test_data/XML/minifiedXmlTestFile.xml');