From 49824597849bc19b96b72a6244c4bb0c1958988e Mon Sep 17 00:00:00 2001 From: Hari K T Date: Sat, 13 Jan 2018 00:55:41 +0530 Subject: [PATCH 1/8] Fixed issue-28. Need to write some tests --- src/Aura/Uri/Url/Factory.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Aura/Uri/Url/Factory.php b/src/Aura/Uri/Url/Factory.php index 759add5..8bf4d2a 100644 --- a/src/Aura/Uri/Url/Factory.php +++ b/src/Aura/Uri/Url/Factory.php @@ -15,6 +15,7 @@ use Aura\Uri\Query; use Aura\Uri\Host; use Aura\Uri\PublicSuffixList; +use ArrayObject; /** * @@ -112,6 +113,7 @@ public function newInstance($spec) $path->setFromString($elem['path']); $query = new Query([]); + $query->setFlags(ArrayObject::ARRAY_AS_PROPS); $query->setFromString($elem['query']); $host = new Host($this->psl, []); From 27d4acc18289d3ad50ce410394b9d98a3ec24e1f Mon Sep 17 00:00:00 2001 From: Hari KT Date: Sat, 13 Jan 2018 01:45:03 +0530 Subject: [PATCH 2/8] Adde tests. Test is failing on local, so test on dev --- tests/Aura/Uri/QueryTest.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/Aura/Uri/QueryTest.php b/tests/Aura/Uri/QueryTest.php index c17eb22..671a202 100644 --- a/tests/Aura/Uri/QueryTest.php +++ b/tests/Aura/Uri/QueryTest.php @@ -65,4 +65,24 @@ public function test_deepArrays() $actual = $this->query->__toString(); $this->assertEquals($expect, $actual); } + + public function testSetQueryString() + { + $query_string = 'foo=bar&baz=dib'; + $this->query->setFromString($query_string); + $this->query->offsetSet('foo', 'another'); + $this->query->offsetUnset('baz'); + $this->query->page = 1; + $this->query['limit'] = 50; + $actual = $this->query->getArrayCopy(); + $expected = [ + 'foo' => 'another', + 'pagetrt' => 1, + 'limit' => 50, + ]; + $this->assertEquals($actual, $expected); + $expect = 'foo=another&page=1&limit=50'; + $actual = $this->query->__toString(); + $this->assertEquals($expect, $actual); + } } From 1ca2b51e06764d1c8e84df7e4ab68b5db6a7c286 Mon Sep 17 00:00:00 2001 From: Hari KT Date: Sat, 13 Jan 2018 10:20:05 +0530 Subject: [PATCH 3/8] Move setFlags(ArrayObject::ARRAY_AS_PROPS) inside constructor, so even if the Query object is created from outside people will not complain --- src/Aura/Uri/Query.php | 7 +++++++ src/Aura/Uri/Url/Factory.php | 1 - tests/Aura/Uri/QueryTest.php | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Aura/Uri/Query.php b/src/Aura/Uri/Query.php index f1d3eb7..0d7b120 100644 --- a/src/Aura/Uri/Query.php +++ b/src/Aura/Uri/Query.php @@ -19,6 +19,13 @@ */ class Query extends \ArrayObject { + + public function __construct($input = [], $flags = 0, $iterator_class = "ArrayIterator") + { + parent::__construct($input, $flags, $iterator_class); + $this->setFlags(\ArrayObject::ARRAY_AS_PROPS); + } + /** * * Returns the query portion as a string. diff --git a/src/Aura/Uri/Url/Factory.php b/src/Aura/Uri/Url/Factory.php index 8bf4d2a..6ae0d6c 100644 --- a/src/Aura/Uri/Url/Factory.php +++ b/src/Aura/Uri/Url/Factory.php @@ -113,7 +113,6 @@ public function newInstance($spec) $path->setFromString($elem['path']); $query = new Query([]); - $query->setFlags(ArrayObject::ARRAY_AS_PROPS); $query->setFromString($elem['query']); $host = new Host($this->psl, []); diff --git a/tests/Aura/Uri/QueryTest.php b/tests/Aura/Uri/QueryTest.php index 671a202..94dc166 100644 --- a/tests/Aura/Uri/QueryTest.php +++ b/tests/Aura/Uri/QueryTest.php @@ -77,7 +77,7 @@ public function testSetQueryString() $actual = $this->query->getArrayCopy(); $expected = [ 'foo' => 'another', - 'pagetrt' => 1, + 'page' => 1, 'limit' => 50, ]; $this->assertEquals($actual, $expected); From a7e3f66c9373bd17a4fa204e6f2aaa313d5d2d01 Mon Sep 17 00:00:00 2001 From: Hari KT Date: Sat, 13 Jan 2018 10:38:30 +0530 Subject: [PATCH 4/8] update travis include scrutinizer --- .scrutinizer.yml | 10 ++++++++++ .travis.yml | 48 ++++++++++++++++++++++++++++++++++++++++++++---- composer.json | 3 +++ 3 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 .scrutinizer.yml diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 0000000..7c7c845 --- /dev/null +++ b/.scrutinizer.yml @@ -0,0 +1,10 @@ +filter: + paths: ["src/*"] +tools: + external_code_coverage: true + php_code_coverage: true + php_sim: true + php_mess_detector: true + php_pdepend: true + php_analyzer: true + php_cpd: true diff --git a/.travis.yml b/.travis.yml index a42d812..c94dcf9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,47 @@ language: php -php: - - 5.4 - - 5.5 + +matrix: + include: + - os: linux + dist: precise + sudo: false + php: 5.3 + - os: linux + dist: precise + sudo: false + php: 5.4 + - os: linux + dist: precise + sudo: false + php: 5.5 + - os: linux + dist: precise + sudo: false + php: 5.6 + - os: linux + dist: trusty + sudo: false + php: 7 + - os: linux + dist: trusty + sudo: false + php: 7.1 + - os: linux + dist: trusty + sudo: false + php: 7.2 + env: + - TEST_COVERAGE=true + - os: linux + dist: trusty + php: nightly + before_script: + - composer self-update + - composer install - cd tests -script: phpunit +script: + - if [[ $TEST_COVERAGE == 'true' ]]; then ../vendor/bin/phpunit --coverage-clover=coverage.clover ; else ../vendor/bin/phpunit ; fi +after_script: + - wget https://scrutinizer-ci.com/ocular.phar + - php ocular.phar code-coverage:upload --format=php-clover coverage.clover \ No newline at end of file diff --git a/composer.json b/composer.json index 24801df..abaf2ba 100644 --- a/composer.json +++ b/composer.json @@ -15,6 +15,9 @@ "php": ">=5.4.0", "aura/installer-default": "1.0.0" }, + "require-dev": { + "phpunit/phpunit": "~5.7 || ~4.8" + }, "autoload": { "psr-0": { "Aura\\Uri": "src/" From dcfb90de9c073311ba02264d17c31d73b6aa9e64 Mon Sep 17 00:00:00 2001 From: Hari KT Date: Sat, 13 Jan 2018 10:42:40 +0530 Subject: [PATCH 5/8] Remove 5.3 adding it accidentally via copying .travis from auth --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index c94dcf9..b529600 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,10 +2,6 @@ language: php matrix: include: - - os: linux - dist: precise - sudo: false - php: 5.3 - os: linux dist: precise sudo: false From 257590b17a5f55bdbb2fa030fbd99978f0cde838 Mon Sep 17 00:00:00 2001 From: Hari KT Date: Sat, 13 Jan 2018 10:56:09 +0530 Subject: [PATCH 6/8] Add doc comments --- src/Aura/Uri/Query.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Aura/Uri/Query.php b/src/Aura/Uri/Query.php index 0d7b120..8482d44 100644 --- a/src/Aura/Uri/Query.php +++ b/src/Aura/Uri/Query.php @@ -20,6 +20,15 @@ class Query extends \ArrayObject { + /** + * + * ArrayObject constructor used to setFlags + * @see https://github.com/auraphp/Aura.Uri/issues/28 + * + * @param mixed $input + * @param integer $flags + * @param string $iterator_class + */ public function __construct($input = [], $flags = 0, $iterator_class = "ArrayIterator") { parent::__construct($input, $flags, $iterator_class); From 89d8fa18f50a189231b442c9a18f3ea81597e488 Mon Sep 17 00:00:00 2001 From: Hari KT Date: Sat, 13 Jan 2018 11:02:57 +0530 Subject: [PATCH 7/8] Fix code coverage reporting --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b529600..97cc7cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,5 +39,4 @@ before_script: script: - if [[ $TEST_COVERAGE == 'true' ]]; then ../vendor/bin/phpunit --coverage-clover=coverage.clover ; else ../vendor/bin/phpunit ; fi after_script: - - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover coverage.clover \ No newline at end of file + - if [[ $TEST_COVERAGE == 'true' ]]; then wget https://scrutinizer-ci.com/ocular.phar; php ocular.phar code-coverage:upload --format=php-clover coverage.clover ; fi \ No newline at end of file From d5d44327468619246d8519ff289776ddcd2131cd Mon Sep 17 00:00:00 2001 From: Hari KT Date: Tue, 16 Jan 2018 22:59:15 +0530 Subject: [PATCH 8/8] Fix docblocks to mark as int than integer --- src/Aura/Uri/Query.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Aura/Uri/Query.php b/src/Aura/Uri/Query.php index 8482d44..b9e78be 100644 --- a/src/Aura/Uri/Query.php +++ b/src/Aura/Uri/Query.php @@ -25,8 +25,8 @@ class Query extends \ArrayObject * ArrayObject constructor used to setFlags * @see https://github.com/auraphp/Aura.Uri/issues/28 * - * @param mixed $input - * @param integer $flags + * @param mixed $input + * @param int $flags * @param string $iterator_class */ public function __construct($input = [], $flags = 0, $iterator_class = "ArrayIterator")