Compare commits

...

11 Commits

Author SHA1 Message Date
Timothy Warren 762d8ca1c4 Make sure fresh dependencies are installed on CI runs
Gitea - aviat/ion/master This commit looks good Details
2019-12-05 16:28:28 -05:00
Timothy Warren b5adf036bf CI tweaks
Gitea - aviat/ion/master This commit looks good Details
2019-12-05 16:26:05 -05:00
Timothy Warren 9313cb33b7 Fix syntax of Jenkinsfile
Gitea - aviat/ion/master There was a failure building this commit Details
2019-12-05 16:21:19 -05:00
Timothy Warren b84145248f Fix dependency version, visual code tweaks
Gitea - aviat/ion/master There was a failure building this commit Details
2019-12-05 16:20:10 -05:00
Timothy Warren 10682b8d60 Update headers
Gitea - aviat/ion/master This commit looks good Details
2019-12-05 15:39:02 -05:00
Timothy Warren 4034b8b2c0 Update minimum PHP version to 7.2, bump version number 2019-12-05 15:38:34 -05:00
Timothy Warren a2cb95aa5b Update dependencies
Gitea - aviat/ion/master This commit looks good Details
2019-12-05 15:25:47 -05:00
Timothy Warren 6ff9476c0b Move XML codec from Hummingbird
Gitea - aviat/ion/master This commit looks good Details
2019-03-12 09:51:38 -04:00
Timothy Warren 68914d22c4 Add silly build status image, remove colors from CI output
Gitea - aviat/ion/master This commit looks good Details
2018-10-11 14:00:51 -04:00
Timothy Warren 69c3f0354e Update CI command
Gitea - aviat/ion/master This commit looks good Details
2018-10-11 13:49:39 -04:00
Timothy Warren ac798d840f Set up Jenkins build
Gitea - aviat/ion/master There was a failure building this commit Details
2018-10-11 13:30:20 -04:00
64 changed files with 780 additions and 380 deletions

1
.gitignore vendored
View File

@ -30,3 +30,4 @@ build/humbuglog.txt
phpdoc/
tests/test_data/json_write.json
tests/test_data/sessions/
.phpunit.result.cache

View File

@ -1,31 +0,0 @@
test:7:
before_script:
- sh build/docker_install.sh > /dev/null
- apk add --no-cache php7-phpdbg
- curl -sS https://getcomposer.org/installer | php
- php composer.phar install --ignore-platform-reqs
image: php:7-alpine
script:
- phpdbg -qrr -- vendor/bin/phpunit -c build --coverage-text --colors=never
test:7.1:
stage: test
before_script:
- sh build/docker_install.sh > /dev/null
- apk add --no-cache php7-phpdbg
- curl -sS https://getcomposer.org/installer | php
- php composer.phar install --ignore-platform-reqs
image: php:7.1-alpine
script:
- phpdbg -qrr -- ./vendor/bin/phpunit -c build --coverage-text --colors=never
test:7.2:
stage: test
before_script:
- sh build/docker_install.sh > /dev/null
- apk add --no-cache php7-phpdbg
- curl -sS https://getcomposer.org/installer | php
- php composer.phar install --ignore-platform-reqs
image: php:7.2-alpine
script:
- phpdbg -qrr -- ./vendor/bin/phpunit -c build --coverage-text --colors=never

View File

@ -4,8 +4,9 @@ install:
- composer install
php:
- 7.1
- 7.2
- 7.3
- 7.4
- nightly
script:
@ -13,7 +14,7 @@ script:
- vendor/bin/phpunit -c build
services:
- redis
- redis-server
matrix:
allow_failures:

50
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,50 @@
pipeline {
agent none
stages {
stage('PHP 7.2') {
agent {
docker {
image 'php:7.2-alpine'
args '-u root --privileged'
}
}
steps {
sh 'apk add --no-cache php7-phpdbg'
sh 'curl -sS https://getcomposer.org/installer | php'
sh 'rm -f composer.lock'
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 'rm -f composer.lock'
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 'rm -f composer.lock'
sh 'php composer.phar install --ignore-platform-reqs'
sh 'php composer.phar run-script coverage -- --coverage-text --colors=never'
}
}
}
}

View File

@ -1,7 +1,6 @@
# Ion
[![build status](https://git.timshomepage.net/aviat/ion/badges/master/build.svg)](https://git.timshomepage.net/aviat/ion/commits/master)
[![coverage report](https://git.timshomepage.net/aviat/ion/badges/master/coverage.svg)](https://git.timshomepage.net/aviat/ion/commits/master)
[![Build Status](https://travis-ci.org/timw4mail/ion.svg?branch=master)](https://travis-ci.org/timw4mail/ion)
[![Build Status](https://jenkins.timshomepage.net/buildStatus/icon?job=Gitea%20-%20aviat/ion/master)](https://jenkins.timshomepage.net/job/Gitea%20-%20aviat/ion/master)
Ion is a set of helpful PHP libraries for general web development

View File

@ -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');

View File

@ -1,12 +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
echo -e 'http://dl-cdn.alpinelinux.org/alpine/edge/main\nhttp://dl-cdn.alpinelinux.org/alpine/edge/community\nhttp://dl-cdn.alpinelinux.org/alpine/edge/testing' > /etc/apk/repositories
apk add --no-cache \
curl \
git

View File

@ -3,13 +3,13 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/

View File

@ -20,7 +20,7 @@
<!-- <log type="coverage-clover" target="logs/clover.xml"/>
<log type="coverage-crap4j" target="logs/crap4j.xml"/> -->
<log type="coverage-xml" target="logs/coverage" />
<log type="junit" target="logs/junit.xml" logIncompleteSkipped="false"/>
<log type="junit" target="logs/junit.xml" />
</logging>
<php>
<server name="HTTP_USER_AGENT" value="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393" />

View File

@ -1,54 +1,55 @@
{
"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": {
"aura/html": "^2.5.0",
"aviat/query": "^2.5.1",
"danielstjules/stringy": "^3.1.0",
"ext-dom": "*",
"ext-json": "*",
"php": "^7.2",
"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",
"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"
}
}

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion;
@ -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

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Di;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Di;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Di;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Di;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Di\Exception;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Di\Exception;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Exception;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Exception;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion;
@ -35,7 +35,7 @@ class Friend {
/**
* Reflection class of the object
* @var \ReflectionClass
* @var ReflectionClass
*/
private $_reflect_;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Model;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Transformer;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Transformer;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Type;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Type;
@ -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;
}

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion;
@ -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

View File

@ -4,19 +4,22 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
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

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\View;

View File

@ -4,19 +4,20 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
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

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion;

279
src/XML.php Normal file
View File

@ -0,0 +1,279 @@
<?php declare(strict_types=1);
/**
* Ion
*
* Building blocks for web development
*
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2019 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion;
use DOMDocument, DOMNode, DOMNodeList, InvalidArgumentException;
/**
* XML <=> PHP Array codec
*/
final class XML {
/**
* XML representation of the data
*
* @var string
*/
private $xml;
/**
* PHP array version of the data
*
* @var array
*/
private $data;
/**
* XML constructor
*
* @param string $xml
* @param array $data
*/
public function __construct(string $xml = '', array $data = [])
{
$this->setXML($xml)->setData($data);
}
/**
* Serialize the data to an xml string
*
* @return string
*/
public function __toString(): string
{
return static::toXML($this->getData());
}
/**
* Get the data parsed from the XML
*
* @return array
*/
public function getData(): array
{
return $this->data;
}
/**
* Set the data to create xml from
*
* @param array $data
* @return self
*/
public function setData(array $data): self
{
$this->data = $data;
return $this;
}
/**
* Get the xml created from the data
*
* @return string
*/
public function getXML(): string
{
return $this->xml;
}
/**
* Set the xml to parse the data from
*
* @param string $xml
* @return self
*/
public function setXML(string $xml): self
{
$this->xml = $xml;
return $this;
}
/**
* Parse an xml document string to a php array
*
* @param string $xml
* @return array
*/
public static function toArray(string $xml): array
{
$data = [];
$xml = static::stripXMLWhitespace($xml);
$dom = new DOMDocument();
$hasLoaded = @$dom->loadXML($xml);
if ( ! $hasLoaded)
{
throw new InvalidArgumentException('Failed to load XML');
}
$root = $dom->documentElement;
$data[$root->tagName] = [];
if ($root->hasChildNodes())
{
static::childNodesToArray($data[$root->tagName], $root->childNodes);
}
return $data;
}
/**
* Transform the array into XML
*
* @param array $data
* @return string
*/
public static function toXML(array $data): string
{
$dom = new DOMDocument();
$dom->encoding = 'UTF-8';
static::arrayPropertiesToXmlNodes($dom, $dom, $data);
return $dom->saveXML();
}
/**
* Parse the xml document string to a php array
*
* @return array
*/
public function parse(): array
{
$xml = $this->getXML();
$data = static::toArray($xml);
return $this->setData($data)->getData();
}
/**
* Transform the array into XML
*
* @return string
*/
public function createXML(): string
{
return static::toXML($this->getData());
}
/**
* Strip whitespace from raw xml to remove irrelevant text nodes
*
* @param string $xml
* @return string
*/
private static function stripXMLWhitespace(string $xml): string
{
// Get rid of unimportant text nodes by removing
// whitespace characters from between xml tags,
// except for the xml declaration tag, Which looks
// something like:
/* <?xml version="1.0" encoding="UTF-8"?> */
return preg_replace('/([^?])>\s+</', '$1><', $xml);
}
/**
* Recursively create array structure based on xml structure
*
* @param array $root A reference to the current array location
* @param DOMNodeList $nodeList The current NodeList object
* @return void
*/
private static function childNodesToArray(array &$root, DOMNodelist $nodeList): void
{
$length = $nodeList->length;
for ($i = 0; $i < $length; $i++)
{
$el = $nodeList->item($i);
$current =& $root[$el->nodeName];
// It's a top level element!
if (( ! $el->hasChildNodes()) || ($el->childNodes->item(0) instanceof \DomText))
{
$current = $el->textContent;
continue;
}
// An empty value at the current root
if ($current === NULL)
{
$current = [];
static::childNodesToArray($current, $el->childNodes);
continue;
}
$keys = array_keys($current);
// Wrap the array in a containing array
// if there are only string keys
if ( ! is_numeric($keys[0]))
{
// But if there is only one key, don't wrap it in
// an array, just recurse to parse the child nodes
if (count($current) === 1)
{
static::childNodesToArray($current, $el->childNodes);
continue;
}
$current = [$current];
}
$current[] = [];
$index = count($current) - 1;
static::childNodesToArray($current[$index], $el->childNodes);
}
}
/**
* Recursively create xml nodes from array properties
*
* @param DOMDocument $dom The current DOM object
* @param DOMNode $parent The parent element to append children to
* @param array $data The data for the current node
* @return void
*/
private static function arrayPropertiesToXmlNodes(DOMDocument $dom, DOMNode $parent, array $data): void
{
foreach ($data as $key => $props)
{
// 'Flatten' the array as you create the xml
if (is_numeric($key))
{
foreach ($props as $k => $p)
{
break;
}
}
$node = $dom->createElement($key);
if (\is_array($props))
{
static::arrayPropertiesToXmlNodes($dom, $node, $props);
} else
{
$tNode = $dom->createTextNode((string)$props);
$node->appendChild($tNode);
}
$parent->appendChild($node);
}
}
}

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Tests;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Tests;
@ -20,7 +20,9 @@ use Aviat\Ion\Config;
class ConfigTest extends Ion_TestCase {
public function setUp()
protected $config;
public function setUp(): void
{
$this->config = new Config([
'foo' => 'bar',
@ -34,7 +36,7 @@ class ConfigTest extends Ion_TestCase {
]);
}
public function testConfigHas()
public function testConfigHas(): void
{
$this->assertTrue($this->config->has('foo'));
$this->assertTrue($this->config->has(['a', 'b', 'c']));
@ -43,7 +45,7 @@ class ConfigTest extends Ion_TestCase {
$this->assertFalse($this->config->has(['c', 'b', 'a']));
}
public function testConfigGet()
public function testConfigGet(): void
{
$this->assertEquals('bar', $this->config->get('foo'));
$this->assertEquals('baz', $this->config->get('bar'));
@ -51,26 +53,26 @@ class ConfigTest extends Ion_TestCase {
$this->assertNull($this->config->get(['apple', 'sauce', 'is']));
}
public function testConfigSet()
public function testConfigSet(): void
{
$ret = $this->config->set('foo', 'foobar');
$this->assertInstanceOf('Aviat\Ion\Config', $ret);
$this->assertInstanceOf(Config::class, $ret);
$this->assertEquals('foobar', $this->config->get('foo'));
$this->config->set(['apple', 'sauce', 'is'], 'great');
$apple = $this->config->get('apple');
$this->assertEquals('great', $apple['sauce']['is'], "Config value not set correctly");
$this->assertEquals('great', $apple['sauce']['is'], 'Config value not set correctly');
$this->assertEquals('great', $this->config->get(['apple', 'sauce', 'is']), "Array argument get for config failed.");
}
public function testConfigBadSet()
public function testConfigBadSet(): void
{
$this->expectException('InvalidArgumentException');
$this->config->set(NULL, FALSE);
}
public function dataConfigDelete()
public function dataConfigDelete(): array
{
return [
'top level delete' => [
@ -130,7 +132,7 @@ class ConfigTest extends Ion_TestCase {
/**
* @dataProvider dataConfigDelete
*/
public function testConfigDelete($key, $assertKeys)
public function testConfigDelete($key, array $assertKeys): void
{
$config = new Config([]);
$config->set(['apple', 'sauce', 'is'], 'great');
@ -142,7 +144,7 @@ class ConfigTest extends Ion_TestCase {
}
}
public function testGetNonExistentConfigItem()
public function testGetNonExistentConfigItem(): void
{
$this->assertNull($this->config->get('foobar'));
}

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Tests\Di;
@ -33,13 +33,13 @@ class ContainerAwareTest extends Ion_TestCase {
protected $aware;
public function setUp()
public function setUp(): void
{
$this->container = new Container();
$this->aware = new Aware($this->container);
}
public function testContainerAwareTrait()
public function testContainerAwareTrait(): void
{
// The container was set in setup
// check that the get method returns the same

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Tests\Di;
@ -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'));

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Tests;
@ -26,8 +26,7 @@ class EnumTest extends Ion_TestCase {
'FOOBAR' => 'baz'
];
public function setUp()
{
public function setUp(): void {
parent::setUp();
$this->enum = new TestEnum();
}

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Tests\Exception;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Tests;
@ -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);

View File

@ -4,25 +4,22 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
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);

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Tests;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Tests\Model;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Tests;
@ -24,8 +24,7 @@ class StringWrapperTest extends TestCase {
protected $wrapper;
public function setUp()
{
public function setUp(): void {
$this->wrapper = new class {
use StringWrapper;
};

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Tests;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Tests\Transformer;
@ -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();
}

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Tests\Type;
@ -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();
}

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Tests\Type;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Tests\View;
@ -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);
}

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Tests\View;
@ -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);

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Tests\View;
@ -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);

88
tests/XMLTest.php Normal file
View File

@ -0,0 +1,88 @@
<?php declare(strict_types=1);
/**
* Ion
*
* Building blocks for web development
*
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2019 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Tests;
use Aviat\Ion\XML;
use PHPUnit\Framework\TestCase;
class XMLTest extends TestCase {
protected $xml;
protected $expectedXml;
protected $object;
protected $array;
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');
$this->array = [
'entry' => [
'foo' => [
'bar' => [
'baz' => 42
]
],
'episode' => '11',
'status' => 'watching',
'score' => '7',
'storage_type' => '1',
'storage_value' => '2.5',
'times_rewatched' => '1',
'rewatch_value' => '3',
'date_start' => '01152015',
'date_finish' => '10232016',
'priority' => '2',
'enable_discussion' => '0',
'enable_rewatching' => '1',
'comments' => 'Should you say something?',
'tags' => 'test tag, 2nd tag'
]
];
$this->object = new XML();
}
public function testToArray()
{
$this->assertEquals($this->array, XML::toArray($this->xml));
}
public function testParse()
{
$this->object->setXML($this->xml);
$this->assertEquals($this->array, $this->object->parse());
}
public function testToXML()
{
$this->assertEquals($this->expectedXml, XML::toXML($this->array));
}
public function testCreateXML()
{
$this->object->setData($this->array);
$this->assertEquals($this->expectedXml, $this->object->createXML());
}
public function testToString()
{
$this->object->setData($this->array);
$this->assertEquals($this->expectedXml, $this->object->__toString());
$this->assertEquals($this->expectedXml, (string)$this->object);
}
}

View File

@ -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();

View File

@ -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();
});

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Tests;

View File

@ -4,14 +4,14 @@
*
* Building blocks for web development
*
* PHP version 7.1
* PHP version 7.2
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @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
* @version 3.0.0
* @link https://git.timshomepage.net/aviat/ion
*/
namespace Aviat\Ion\Tests;

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<entry><foo><bar><baz>42</baz></bar></foo><episode>11</episode><status>watching</status><score>7</score><storage_type>1</storage_type><storage_value>2.5</storage_value><times_rewatched>1</times_rewatched><rewatch_value>3</rewatch_value><date_start>01152015</date_start><date_finish>10232016</date_finish><priority>2</priority><enable_discussion>0</enable_discussion><enable_rewatching>1</enable_rewatching><comments>Should you say something?</comments><tags>test tag, 2nd tag</tags></entry>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<entry>
<foo>
<bar>
<baz>42</baz>
</bar>
</foo>
<episode>11</episode>
<status>watching</status>
<score>7</score>
<storage_type>1</storage_type>
<storage_value>2.5</storage_value>
<times_rewatched>1</times_rewatched>
<rewatch_value>3</rewatch_value>
<date_start>01152015</date_start>
<date_finish>10232016</date_finish>
<priority>2</priority>
<enable_discussion>0</enable_discussion>
<enable_rewatching>1</enable_rewatching>
<comments>Should you say something?</comments>
<tags>test tag, 2nd tag</tags>
</entry>