diff --git a/.php_cs b/.php_cs index 31ee793b..ff96ac7a 100644 --- a/.php_cs +++ b/.php_cs @@ -11,6 +11,8 @@ $config = Symfony\CS\Config\Config::create() 'no_blank_lines_after_class_opening', 'no_empty_lines_after_phpdocs', 'operators_spaces', + 'duplicate_semicolon', + 'namespace_no_leading_whitespace', 'phpdoc_indent', 'phpdoc_no_empty_return', 'phpdoc_no_package', @@ -23,6 +25,7 @@ $config = Symfony\CS\Config\Config::create() 'remove_lines_between_uses', 'return', 'single_array_no_trailing_comma', + 'single_quote', 'spaces_before_semicolon', 'spaces_cast', 'standardize_not_equal', diff --git a/.travis.yml b/.travis.yml index b3985e42..73394967 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,17 @@ -sudo: false language: php php: - - 5.5 - 5.6 + - 7.0 - hhvm - - 7 +sudo: false +cache: + directories: + - $HOME/.composer/cache before_script: - composer self-update - composer install script: - - phpunit --coverage-clover=coverage.clover + - phpunit after_script: - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover coverage.clover + - if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi diff --git a/LICENSE b/LICENSE index 5200beeb..dd5c9de9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,23 +1,21 @@ -Copyright (c) 2012-2016, Akihito Koriyama -All rights reserved. +The MIT License (MIT) -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: +Copyright (c) 2012-2016 Akihito Koriyama -- Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -- Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/composer.json b/composer.json index d5e5108c..5addd964 100644 --- a/composer.json +++ b/composer.json @@ -31,5 +31,27 @@ "psr-4": { "BEAR\\Sunday\\": "src/" } + }, + "autoload-dev": { + "files": ["tests/functions.php"] + }, + "scripts" :{ + "test": [ + "phpmd src text ./phpmd.xml", + "phpcs src tests", + "phpunit" + ], + "cs-fix": [ + "php-cs-fixer fix --config-file=./.php_cs", + "phpcbf src" + ], + "build": [ + "rm -rf ./build; mkdir -p ./build/logs ./build/pdepend ./build/api", + "pdepend --jdepend-xml=./build/logs/jdepend.xml --jdepend-chart=./build/pdepend/dependencies.svg --overview-pyramid=./build/pdepend/overview-pyramid.svg src", + "phploc --log-csv ./build/logs/phploc.csv src", + "phpcs --report=checkstyle --report-file=./build/logs/checkstyle.xml --standard=phpcs.xml src", + "apigen generate -s src -d build/api", + "@test" + ] } } diff --git a/phpcs.xml b/phpcs.xml index 4c9e459e..76dc14b7 100755 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,13 +1,12 @@ - The coding standard used for applications using BEAR.Sunday Framework. + + - - @@ -15,10 +14,6 @@ - - - src - tests diff --git a/phpmd.xml b/phpmd.xml index d33710cd..8d483397 100644 --- a/phpmd.xml +++ b/phpmd.xml @@ -1,24 +1,12 @@ - - - - - - - - - - - - - - - + + + @@ -28,10 +16,14 @@ - + - + + + + + @@ -41,10 +33,13 @@ + + + - + diff --git a/tests/Fake/Inject/DummyLogger.php b/tests/Fake/Inject/DummyLogger.php new file mode 100644 index 00000000..1d34103c --- /dev/null +++ b/tests/Fake/Inject/DummyLogger.php @@ -0,0 +1,36 @@ +logger; + } +} diff --git a/tests/Fake/Inject/PsrLoggerModule.php b/tests/Fake/Inject/PsrLoggerModule.php new file mode 100644 index 00000000..1857e6c6 --- /dev/null +++ b/tests/Fake/Inject/PsrLoggerModule.php @@ -0,0 +1,13 @@ +bind('Psr\Log\LoggerInterface')->to(__NAMESPACE__ . '\DummyLogger'); + } +} diff --git a/tests/Fake/Inject/ResourceInjectApplication.php b/tests/Fake/Inject/ResourceInjectApplication.php new file mode 100644 index 00000000..7c06284c --- /dev/null +++ b/tests/Fake/Inject/ResourceInjectApplication.php @@ -0,0 +1,13 @@ +resource; + } +} diff --git a/tests/Fake/Provide/Transfer/FakeHttpResponder.php b/tests/Fake/Provide/Transfer/FakeHttpResponder.php index 36f79559..8e5eba9f 100644 --- a/tests/Fake/Provide/Transfer/FakeHttpResponder.php +++ b/tests/Fake/Provide/Transfer/FakeHttpResponder.php @@ -9,9 +9,6 @@ use BEAR\Resource\ResourceObject; -require_once __DIR__ . '/header.php'; -require_once __DIR__ . '/http_response_code.php'; - class FakeHttpResponder extends HttpResponder { public static $code; diff --git a/tests/Fake/Provide/Transfer/header.php b/tests/Fake/Provide/Transfer/header.php index 907e404b..0cd98271 100644 --- a/tests/Fake/Provide/Transfer/header.php +++ b/tests/Fake/Provide/Transfer/header.php @@ -7,10 +7,9 @@ */ namespace BEAR\Sunday\Provide\Transfer; -function header( - $string, - $replace = true, - $http_response_code = null -) { +function header($string, $replace = true, $http_response_code = null) +{ FakeHttpResponder::$headers[] = func_get_args(); + + unset($string, $replace, $http_response_code); } diff --git a/tests/Fake/Provide/Transfer/http_response_code.php b/tests/Fake/Provide/Transfer/http_response_code.php index 3dd4dd94..b5c414ad 100644 --- a/tests/Fake/Provide/Transfer/http_response_code.php +++ b/tests/Fake/Provide/Transfer/http_response_code.php @@ -5,4 +5,5 @@ function http_response_code($int) { FakeHttpResponder::$code = func_get_args(); + unset($int); } diff --git a/tests/Inject/PsrLoggerInjectTest.php b/tests/Inject/PsrLoggerInjectTest.php index 40243acc..cebad568 100644 --- a/tests/Inject/PsrLoggerInjectTest.php +++ b/tests/Inject/PsrLoggerInjectTest.php @@ -2,59 +2,8 @@ namespace BEAR\Sunday\Inject; -use Psr\Log\LoggerInterface; -use Ray\Di\AbstractModule; use Ray\Di\Injector; -class PsrLoggerApplication -{ - use PsrLoggerInject; - - public function returnDependency() - { - return $this->logger; - } -} - -class DummyLogger implements LoggerInterface -{ - public function emergency($message, array $context = []) - { - } - public function alert($message, array $context = []) - { - } - public function critical($message, array $context = []) - { - } - public function error($message, array $context = []) - { - } - public function warning($message, array $context = []) - { - } - public function notice($message, array $context = []) - { - } - public function info($message, array $context = []) - { - } - public function debug($message, array $context = []) - { - } - public function log($level, $message, array $context = []) - { - } -} - -class PsrLoggerModule extends AbstractModule -{ - protected function configure() - { - $this->bind('Psr\Log\LoggerInterface')->to(__NAMESPACE__ . '\DummyLogger'); - } -} - class PsrLoggerInjectTest extends \PHPUnit_Framework_TestCase { public function testInjectTrait() diff --git a/tests/Inject/ResourceInjectTest.php b/tests/Inject/ResourceInjectTest.php index f29eea3e..7d5870f6 100644 --- a/tests/Inject/ResourceInjectTest.php +++ b/tests/Inject/ResourceInjectTest.php @@ -6,16 +6,6 @@ use BEAR\Sunday\Module\Resource\ResourceModule; use Ray\Di\Injector; -class ResourceInjectApplication -{ - use ResourceInject; - - public function returnDependency() - { - return $this->resource; - } -} - class ResourceInjectTest extends \PHPUnit_Framework_TestCase { public function testInjectTrait() diff --git a/tests/functions.php b/tests/functions.php new file mode 100644 index 00000000..067d779e --- /dev/null +++ b/tests/functions.php @@ -0,0 +1,4 @@ +