From 5f27002de38b0488a7d12983bf06982780abd54d Mon Sep 17 00:00:00 2001 From: Pera Jovic Date: Mon, 25 Apr 2016 21:51:13 +0200 Subject: [PATCH 1/4] Add php_cs config and run fixer --- .php_cs.php | 50 ++++++++++++++++++++++++++++++++++ src/DateTimeValue.php | 6 ++++ src/DateTimeValueInterface.php | 6 ++++ src/DateValue.php | 8 +++++- src/DateValueInterface.php | 6 ++++ test/bootstrap.php | 6 ++++ test/src/ClassesTest.php | 18 ++++++++---- test/src/JsonSerializeTest.php | 18 ++++++++---- test/src/NowTest.php | 17 +++++++----- test/src/TestCase.php | 6 ++++ 10 files changed, 121 insertions(+), 20 deletions(-) create mode 100644 .php_cs.php diff --git a/.php_cs.php b/.php_cs.php new file mode 100644 index 0000000..aa87abf --- /dev/null +++ b/.php_cs.php @@ -0,0 +1,50 @@ +. All rights reserved. + */ + +$header = <<. All rights reserved. +EOF; + +Symfony\CS\Fixer\Contrib\HeaderCommentFixer::setHeader($header); + +return (new Symfony\CS\Config\Config('psr2'))->fixers([ + 'header_comment', + 'array_element_no_space_before_comma', + 'array_element_white_space_after_comma', + 'double_arrow_multiline_whitespaces', + 'hash_to_slash_comment', + 'include', + 'join_function', + 'multiline_array_trailing_comma', + 'namespace_no_leading_whitespace', + 'no_blank_lines_after_class_opening ', + 'no_empty_lines_after_phpdocs', + 'phpdoc_scalar', + 'phpdoc_short_description', + 'self_accessor', + 'single_array_no_trailing_comma', + 'single_blank_line_before_namespace', + 'spaces_after_semicolon', + 'spaces_before_semicolon', + 'spaces_cast', + 'standardize_not_equal', + 'ternary_spaces', + 'trim_array_spaces', + 'unused_use', + 'whitespacy_lines', + 'ordered_use', + 'short_array_syntax', + 'phpdoc_params', + '-phpdoc_separation', + '-phpdoc_no_package', + '-print_to_echo', + '-concat_without_spaces', + '-empty_return', +])->finder((new Symfony\CS\Finder\DefaultFinder())->in([__DIR__ . '/src', __DIR__ . '/test'])); diff --git a/src/DateTimeValue.php b/src/DateTimeValue.php index 179bcb8..ee03b98 100644 --- a/src/DateTimeValue.php +++ b/src/DateTimeValue.php @@ -1,5 +1,11 @@ . All rights reserved. + */ + namespace ActiveCollab\DateValue; use Carbon\Carbon; diff --git a/src/DateTimeValueInterface.php b/src/DateTimeValueInterface.php index 16ad08e..2baf2a5 100644 --- a/src/DateTimeValueInterface.php +++ b/src/DateTimeValueInterface.php @@ -1,5 +1,11 @@ . All rights reserved. + */ + namespace ActiveCollab\DateValue; /** diff --git a/src/DateValue.php b/src/DateValue.php index 11dfd05..5905795 100644 --- a/src/DateValue.php +++ b/src/DateValue.php @@ -1,5 +1,11 @@ . All rights reserved. + */ + namespace ActiveCollab\DateValue; use Carbon\Carbon; @@ -12,7 +18,7 @@ class DateValue extends Carbon implements DateValueInterface /** * Create a new DateValue instance. * - * @param string $time + * @param string $time * @param \DateTimeZone|string $tz */ public function __construct($time = null, $tz = null) diff --git a/src/DateValueInterface.php b/src/DateValueInterface.php index 6f0b652..b95fdc5 100644 --- a/src/DateValueInterface.php +++ b/src/DateValueInterface.php @@ -1,5 +1,11 @@ . All rights reserved. + */ + namespace ActiveCollab\DateValue; /** diff --git a/test/bootstrap.php b/test/bootstrap.php index 52caf8b..d38a09f 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -1,5 +1,11 @@ . All rights reserved. + */ + defined('BASE_PATH') || define('BASE_PATH', realpath(__DIR__)); date_default_timezone_set('GMT'); diff --git a/test/src/ClassesTest.php b/test/src/ClassesTest.php index fc0511b..d0d4b3d 100644 --- a/test/src/ClassesTest.php +++ b/test/src/ClassesTest.php @@ -1,11 +1,17 @@ . All rights reserved. + */ + namespace ActiveCollab\DateValue\Test; -use ActiveCollab\DateValue\DateValueInterface; -use ActiveCollab\DateValue\DateValue; -use ActiveCollab\DateValue\DateTimeValueInterface; use ActiveCollab\DateValue\DateTimeValue; +use ActiveCollab\DateValue\DateTimeValueInterface; +use ActiveCollab\DateValue\DateValue; +use ActiveCollab\DateValue\DateValueInterface; use ReflectionClass; /** @@ -14,7 +20,7 @@ class ClassesTest extends TestCase { /** - * Test if date value class exists + * Test if date value class exists. */ public function testDateValueClass() { @@ -23,11 +29,11 @@ public function testDateValueClass() } /** - * Test if date time value class exists + * Test if date time value class exists. */ public function testDateTimeValueClass() { $this->assertTrue(class_exists(DateTimeValue::class, true)); $this->assertTrue((new ReflectionClass(DateTimeValue::class))->implementsInterface(DateTimeValueInterface::class)); } -} \ No newline at end of file +} diff --git a/test/src/JsonSerializeTest.php b/test/src/JsonSerializeTest.php index f8a220d..b953303 100644 --- a/test/src/JsonSerializeTest.php +++ b/test/src/JsonSerializeTest.php @@ -1,9 +1,15 @@ . All rights reserved. + */ + namespace ActiveCollab\DateValue\Test; -use ActiveCollab\DateValue\DateValue; use ActiveCollab\DateValue\DateTimeValue; +use ActiveCollab\DateValue\DateValue; /** * @package ActiveCollab\DateValue\Test @@ -16,7 +22,7 @@ class JsonSerializeTest extends TestCase private $reference; /** - * Set up test environment + * Set up test environment. */ public function setUp() { @@ -28,7 +34,7 @@ public function setUp() } /** - * Tear down test environment + * Tear down test environment. */ public function tearDown() { @@ -38,7 +44,7 @@ public function tearDown() } /** - * Test date serialization + * Test date serialization. */ public function testSerializeDate() { @@ -54,7 +60,7 @@ public function testSerializeDate() } /** - * Test date time serialization + * Test date time serialization. */ public function testSerializeDateTime() { @@ -65,4 +71,4 @@ public function testSerializeDateTime() $this->assertEquals($this->reference->getTimestamp(), json_decode(json_encode(new DateTimeValue()), true)); } -} \ No newline at end of file +} diff --git a/test/src/NowTest.php b/test/src/NowTest.php index 3bed0a6..5cd6da8 100644 --- a/test/src/NowTest.php +++ b/test/src/NowTest.php @@ -1,12 +1,15 @@ . All rights reserved. + */ + namespace ActiveCollab\DateValue\Test; -use ActiveCollab\DateValue\DateValueInterface; -use ActiveCollab\DateValue\DateValue; -use ActiveCollab\DateValue\DateTimeValueInterface; use ActiveCollab\DateValue\DateTimeValue; -use ReflectionClass; +use ActiveCollab\DateValue\DateValue; /** * @package ActiveCollab\DateValue\Test @@ -14,7 +17,7 @@ class NowTest extends TestCase { /** - * Test if now uses current timestamp + * Test if now uses current timestamp. */ public function testRealNow() { @@ -22,7 +25,7 @@ public function testRealNow() } /** - * Test if now can be overriden, for test purposes + * Test if now can be overriden, for test purposes. */ public function testTestNow() { @@ -30,4 +33,4 @@ public function testTestNow() $this->assertEquals((new DateTimeValue())->format('Y-m-d H:i:s'), date('2013-10-02 11:18:32')); } -} \ No newline at end of file +} diff --git a/test/src/TestCase.php b/test/src/TestCase.php index e1933c3..0cc0e5f 100644 --- a/test/src/TestCase.php +++ b/test/src/TestCase.php @@ -1,5 +1,11 @@ . All rights reserved. + */ + namespace ActiveCollab\DateValue\Test; abstract class TestCase extends \PHPUnit_Framework_TestCase From 1a8599c8ceee272c47243f5782c0252b60b7d100 Mon Sep 17 00:00:00 2001 From: Pera Jovic Date: Mon, 25 Apr 2016 21:58:15 +0200 Subject: [PATCH 2/4] Reorganize phpunit --- phpunit.xml | 19 +++++++++++++++++++ test/bootstrap.php | 2 +- test/phpunit.xml | 7 ------- test/src/ClassesTest.php | 1 + test/src/JsonSerializeTest.php | 1 + test/src/NowTest.php | 1 + test/src/{ => TestCase}/TestCase.php | 6 ++++-- 7 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 phpunit.xml delete mode 100644 test/phpunit.xml rename test/src/{ => TestCase}/TestCase.php (50%) diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..b4ba67f --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,19 @@ + + + + ./test/src + + + diff --git a/test/bootstrap.php b/test/bootstrap.php index d38a09f..8af81a8 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -10,4 +10,4 @@ date_default_timezone_set('GMT'); require dirname(__DIR__).'/vendor/autoload.php'; -require __DIR__.'/src/TestCase.php'; +require __DIR__.'/src/TestCase/TestCase.php'; diff --git a/test/phpunit.xml b/test/phpunit.xml deleted file mode 100644 index a791e21..0000000 --- a/test/phpunit.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - ./src - - - diff --git a/test/src/ClassesTest.php b/test/src/ClassesTest.php index d0d4b3d..830653d 100644 --- a/test/src/ClassesTest.php +++ b/test/src/ClassesTest.php @@ -12,6 +12,7 @@ use ActiveCollab\DateValue\DateTimeValueInterface; use ActiveCollab\DateValue\DateValue; use ActiveCollab\DateValue\DateValueInterface; +use ActiveCollab\DateValue\Test\TestCase\TestCase; use ReflectionClass; /** diff --git a/test/src/JsonSerializeTest.php b/test/src/JsonSerializeTest.php index b953303..7fa07ee 100644 --- a/test/src/JsonSerializeTest.php +++ b/test/src/JsonSerializeTest.php @@ -10,6 +10,7 @@ use ActiveCollab\DateValue\DateTimeValue; use ActiveCollab\DateValue\DateValue; +use ActiveCollab\DateValue\Test\TestCase\TestCase; /** * @package ActiveCollab\DateValue\Test diff --git a/test/src/NowTest.php b/test/src/NowTest.php index 5cd6da8..0d46943 100644 --- a/test/src/NowTest.php +++ b/test/src/NowTest.php @@ -10,6 +10,7 @@ use ActiveCollab\DateValue\DateTimeValue; use ActiveCollab\DateValue\DateValue; +use ActiveCollab\DateValue\Test\TestCase\TestCase; /** * @package ActiveCollab\DateValue\Test diff --git a/test/src/TestCase.php b/test/src/TestCase/TestCase.php similarity index 50% rename from test/src/TestCase.php rename to test/src/TestCase/TestCase.php index 0cc0e5f..c17d157 100644 --- a/test/src/TestCase.php +++ b/test/src/TestCase/TestCase.php @@ -6,8 +6,10 @@ * (c) A51 doo . All rights reserved. */ -namespace ActiveCollab\DateValue\Test; +namespace ActiveCollab\DateValue\Test\TestCase; -abstract class TestCase extends \PHPUnit_Framework_TestCase +use PHPUnit_Framework_TestCase; + +abstract class TestCase extends PHPUnit_Framework_TestCase { } From c31935051b0a21ea3e30987cbef2b9341b94bbb9 Mon Sep 17 00:00:00 2001 From: Pera Jovic Date: Mon, 25 Apr 2016 22:00:24 +0200 Subject: [PATCH 3/4] Minor changes --- src/DateTimeValueInterface.php | 5 ++++- src/DateValueInterface.php | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/DateTimeValueInterface.php b/src/DateTimeValueInterface.php index 2baf2a5..2fdb383 100644 --- a/src/DateTimeValueInterface.php +++ b/src/DateTimeValueInterface.php @@ -8,9 +8,12 @@ namespace ActiveCollab\DateValue; +use DateTimeInterface; +use JsonSerializable; + /** * @package ActiveCollab\DateValue */ -interface DateTimeValueInterface extends \DateTimeInterface, \JsonSerializable +interface DateTimeValueInterface extends DateTimeInterface, JsonSerializable { } diff --git a/src/DateValueInterface.php b/src/DateValueInterface.php index b95fdc5..7a1f4f9 100644 --- a/src/DateValueInterface.php +++ b/src/DateValueInterface.php @@ -8,9 +8,12 @@ namespace ActiveCollab\DateValue; +use DateTimeInterface; +use JsonSerializable; + /** * @package ActiveCollab\DateValue */ -interface DateValueInterface extends \DateTimeInterface, \JsonSerializable +interface DateValueInterface extends DateTimeInterface, JsonSerializable { } From 8bdb0a97639ad4dba1f0039864140f9ee5b204ab Mon Sep 17 00:00:00 2001 From: Ilija Studen Date: Tue, 26 Apr 2016 09:50:08 +0200 Subject: [PATCH 4/4] Fix phpunit command --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ec80f45..5eb479f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,4 +3,4 @@ php: - 5.6 - '7' install: composer install --dev -script: phpunit -c test/phpunit.xml \ No newline at end of file +script: phpunit