From 6dff52acc19df2a6375984f9f723e30e232d39b3 Mon Sep 17 00:00:00 2001 From: "Derek J. Lambert" Date: Wed, 24 Feb 2016 20:28:58 -0600 Subject: [PATCH 01/13] Use existing local var --- tests/CrEOF/Spatial/Tests/DBAL/Types/SchemaTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CrEOF/Spatial/Tests/DBAL/Types/SchemaTest.php b/tests/CrEOF/Spatial/Tests/DBAL/Types/SchemaTest.php index 7a92b5fd..6b5f1324 100644 --- a/tests/CrEOF/Spatial/Tests/DBAL/Types/SchemaTest.php +++ b/tests/CrEOF/Spatial/Tests/DBAL/Types/SchemaTest.php @@ -64,7 +64,7 @@ public function testDoctrineTypeMapping() $databaseTypes = $type->getMappedDatabaseTypes($platform); foreach ($databaseTypes as $databaseType) { - $typeMapping = $this->getPlatform()->getDoctrineTypeMapping($databaseType); + $typeMapping = $platform->getDoctrineTypeMapping($databaseType); $this->assertEquals($doctrineType, $typeMapping); } From 0a5b64e040920bda2fb9ae1cddde26f426253842 Mon Sep 17 00:00:00 2001 From: "Derek J. Lambert" Date: Tue, 22 Mar 2016 14:13:21 -0500 Subject: [PATCH 02/13] Use strict compare. Compare to null is cheaper. --- lib/CrEOF/Spatial/PHP/Types/AbstractGeometry.php | 2 +- lib/CrEOF/Spatial/PHP/Types/AbstractPolygon.php | 2 +- tests/CrEOF/Spatial/Tests/OrmTestCase.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/CrEOF/Spatial/PHP/Types/AbstractGeometry.php b/lib/CrEOF/Spatial/PHP/Types/AbstractGeometry.php index adc5a21e..cab04c45 100644 --- a/lib/CrEOF/Spatial/PHP/Types/AbstractGeometry.php +++ b/lib/CrEOF/Spatial/PHP/Types/AbstractGeometry.php @@ -99,7 +99,7 @@ protected function validatePointValue($point) case ($point instanceof AbstractPoint): return $point->toArray(); break; - case (is_array($point) && count($point) == 2 && is_numeric($point[0]) && is_numeric($point[1])): + case (is_array($point) && count($point) === 2 && is_numeric($point[0]) && is_numeric($point[1])): return array_values($point); break; default: diff --git a/lib/CrEOF/Spatial/PHP/Types/AbstractPolygon.php b/lib/CrEOF/Spatial/PHP/Types/AbstractPolygon.php index 0acf4bf2..8d0473f0 100644 --- a/lib/CrEOF/Spatial/PHP/Types/AbstractPolygon.php +++ b/lib/CrEOF/Spatial/PHP/Types/AbstractPolygon.php @@ -79,7 +79,7 @@ public function getRings() */ public function getRing($index) { - if (-1 == $index) { + if (-1 === $index) { $index = count($this->rings) - 1; } diff --git a/tests/CrEOF/Spatial/Tests/OrmTestCase.php b/tests/CrEOF/Spatial/Tests/OrmTestCase.php index dd3f99f0..4c357830 100644 --- a/tests/CrEOF/Spatial/Tests/OrmTestCase.php +++ b/tests/CrEOF/Spatial/Tests/OrmTestCase.php @@ -198,7 +198,7 @@ protected function setUp() */ protected function getEntityManager() { - if (isset($this->entityManager)) { + if (null !== $this->entityManager) { return $this->entityManager; } From 7dcdbda736bacdc1b6ef3788cda62a48a401463b Mon Sep 17 00:00:00 2001 From: "Derek J. Lambert" Date: Tue, 22 Mar 2016 14:13:50 -0500 Subject: [PATCH 03/13] Correct namespace --- tests/CrEOF/Spatial/Tests/PHP/Types/Geometry/LineStringTest.php | 2 +- tests/CrEOF/Spatial/Tests/PHP/Types/Geometry/MultiPointTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/CrEOF/Spatial/Tests/PHP/Types/Geometry/LineStringTest.php b/tests/CrEOF/Spatial/Tests/PHP/Types/Geometry/LineStringTest.php index ba5949e1..581a2c44 100644 --- a/tests/CrEOF/Spatial/Tests/PHP/Types/Geometry/LineStringTest.php +++ b/tests/CrEOF/Spatial/Tests/PHP/Types/Geometry/LineStringTest.php @@ -21,7 +21,7 @@ * SOFTWARE. */ -namespace CrEOF\Spatial\Tests\PHP\Types\Spatial\Geometry; +namespace CrEOF\Spatial\Tests\PHP\Types\Geometry; use CrEOF\Spatial\PHP\Types\Geometry\LineString; use CrEOF\Spatial\PHP\Types\Geometry\Point; diff --git a/tests/CrEOF/Spatial/Tests/PHP/Types/Geometry/MultiPointTest.php b/tests/CrEOF/Spatial/Tests/PHP/Types/Geometry/MultiPointTest.php index 8727c021..77233a80 100644 --- a/tests/CrEOF/Spatial/Tests/PHP/Types/Geometry/MultiPointTest.php +++ b/tests/CrEOF/Spatial/Tests/PHP/Types/Geometry/MultiPointTest.php @@ -21,7 +21,7 @@ * SOFTWARE. */ -namespace CrEOF\Spatial\Tests\PHP\Types\Spatial\Geometry; +namespace CrEOF\Spatial\Tests\PHP\Types\Geometry; use CrEOF\Spatial\PHP\Types\Geometry\MultiPoint; use CrEOF\Spatial\PHP\Types\Geometry\Point; From 9d453d93c7491c57a92a36a872936f8489c87252 Mon Sep 17 00:00:00 2001 From: "Derek J. Lambert" Date: Tue, 22 Mar 2016 17:08:19 -0500 Subject: [PATCH 04/13] Set result cache in tests --- tests/CrEOF/Spatial/Tests/OrmTestCase.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/CrEOF/Spatial/Tests/OrmTestCase.php b/tests/CrEOF/Spatial/Tests/OrmTestCase.php index 4c357830..df711913 100644 --- a/tests/CrEOF/Spatial/Tests/OrmTestCase.php +++ b/tests/CrEOF/Spatial/Tests/OrmTestCase.php @@ -209,7 +209,8 @@ protected function getEntityManager() $config = new Configuration(); - $config->setMetadataCacheImpl(new ArrayCache); + $config->setMetadataCacheImpl(new ArrayCache()); + $config->setResultCacheImpl(new ArrayCache()); $config->setProxyDir(__DIR__ . '/Proxies'); $config->setProxyNamespace('CrEOF\Spatial\Tests\Proxies'); $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver(array(realpath(__DIR__ . '/Fixtures')), true)); From 23a1c357c9335eae1a94c9d571d51a1d9fb1f7aa Mon Sep 17 00:00:00 2001 From: "Derek J. Lambert" Date: Tue, 22 Mar 2016 17:08:49 -0500 Subject: [PATCH 05/13] CS/WS --- .../Spatial/Tests/PHP/Types/Geometry/MultiPolygonTest.php | 4 ++-- tests/CrEOF/Spatial/Tests/PHP/Types/Geometry/PolygonTest.php | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/CrEOF/Spatial/Tests/PHP/Types/Geometry/MultiPolygonTest.php b/tests/CrEOF/Spatial/Tests/PHP/Types/Geometry/MultiPolygonTest.php index 3c1e198d..80febc59 100644 --- a/tests/CrEOF/Spatial/Tests/PHP/Types/Geometry/MultiPolygonTest.php +++ b/tests/CrEOF/Spatial/Tests/PHP/Types/Geometry/MultiPolygonTest.php @@ -1,14 +1,14 @@ * @license http://dlambert.mit-license.org MIT diff --git a/tests/CrEOF/Spatial/Tests/PHP/Types/Geometry/PolygonTest.php b/tests/CrEOF/Spatial/Tests/PHP/Types/Geometry/PolygonTest.php index 256d2e03..c816abd2 100644 --- a/tests/CrEOF/Spatial/Tests/PHP/Types/Geometry/PolygonTest.php +++ b/tests/CrEOF/Spatial/Tests/PHP/Types/Geometry/PolygonTest.php @@ -26,6 +26,7 @@ use CrEOF\Spatial\PHP\Types\Geometry\LineString; use CrEOF\Spatial\PHP\Types\Geometry\Point; use CrEOF\Spatial\PHP\Types\Geometry\Polygon; + /** * Polygon object tests * From f3a83b2b80b79631c66e389dc363154ce91acea5 Mon Sep 17 00:00:00 2001 From: "Derek J. Lambert" Date: Wed, 23 Mar 2016 09:10:46 -0500 Subject: [PATCH 06/13] Replace switch with if --- lib/CrEOF/Spatial/PHP/Types/AbstractGeometry.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/CrEOF/Spatial/PHP/Types/AbstractGeometry.php b/lib/CrEOF/Spatial/PHP/Types/AbstractGeometry.php index cab04c45..47ec59e3 100644 --- a/lib/CrEOF/Spatial/PHP/Types/AbstractGeometry.php +++ b/lib/CrEOF/Spatial/PHP/Types/AbstractGeometry.php @@ -115,14 +115,8 @@ protected function validatePointValue($point) */ protected function validateRingValue($ring) { - switch (true) { - case ($ring instanceof AbstractLineString): - $ring = $ring->toArray(); - break; - case (is_array($ring)): - break; - default: - throw new InvalidValueException(sprintf('Invalid %s LineString value of type "%s"', $this->getType(), (is_object($ring) ? get_class($ring) : gettype($ring)))); + if (! (is_array($ring) || $ring instanceof AbstractLineString)) { + throw new InvalidValueException(sprintf('Invalid %s LineString value of type "%s"', $this->getType(), (is_object($ring) ? get_class($ring) : gettype($ring)))); } $ring = $this->validateLineStringValue($ring); @@ -187,6 +181,7 @@ protected function validateMultiPolygonValue(array $polygons) if ($polygon instanceof GeometryInterface) { $polygon = $polygon->toArray(); } + $polygon = $this->validatePolygonValue($polygon); } From 9682ceaf294a8fb1f3473c24f6f5512003e6a6e1 Mon Sep 17 00:00:00 2001 From: "Derek J. Lambert" Date: Wed, 23 Mar 2016 09:12:22 -0500 Subject: [PATCH 07/13] LineString Geometry test --- .../PHP/Types/Geography/LineStringTest.php | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 tests/CrEOF/Spatial/Tests/PHP/Types/Geography/LineStringTest.php diff --git a/tests/CrEOF/Spatial/Tests/PHP/Types/Geography/LineStringTest.php b/tests/CrEOF/Spatial/Tests/PHP/Types/Geography/LineStringTest.php new file mode 100644 index 00000000..1b6b4526 --- /dev/null +++ b/tests/CrEOF/Spatial/Tests/PHP/Types/Geography/LineStringTest.php @@ -0,0 +1,89 @@ + + * @license http://dlambert.mit-license.org MIT + * + * @group php + */ +class LineStringTest extends \PHPUnit_Framework_TestCase +{ + + /** + * @expectedException \CrEOF\Spatial\Exception\InvalidValueException + * @expectedExceptionMessage Invalid longitude value "550", must be in range -180 to 180. + */ + public function testLineStringFromObjectsToArray() + { + $expected = array( + array(550, 550), + array(551, 551), + array(552, 552), + array(553, 553) + ); + $lineString = new LineString(array( + new Point(550, 550), + new Point(551, 551), + new Point(552, 552), + new Point(553, 553) + )); + + $this->assertCount(4, $lineString->getPoints()); + $this->assertEquals($expected, $lineString->toArray()); + } + + /** + * @expectedException \CrEOF\Spatial\Exception\InvalidValueException + * @expectedExceptionMessage Invalid longitude value "550", must be in range -180 to 180. + */ + public function testLineStringFromArraysGetPoints() + { + $expected = array( + array(550, 550), + array(551, 551), + array(552, 552), + array(553, 553) + ); + $lineString = new LineString( + array( + array(550, 550), + array(551, 551), + array(552, 552), + array(553, 553) + ) + ); + $actual = $lineString->getPoints(); + + $this->assertCount(4, $actual); + $this->assertEquals($expected, $actual); + } +} From 919f0dc4e84486db75ce3f0508fd2e3702190511 Mon Sep 17 00:00:00 2001 From: "Derek J. Lambert" Date: Wed, 23 Mar 2016 09:22:15 -0500 Subject: [PATCH 08/13] Doctrine test case not longer needed. Add test namespace to composer.json. Remove TestInit and bootstrap composer autoload. --- composer.json | 5 +++++ phpunit.xml.dist | 14 +++++++------- tests/CrEOF/Spatial/Tests/TestInit.php | 10 ---------- 3 files changed, 12 insertions(+), 17 deletions(-) delete mode 100644 tests/CrEOF/Spatial/Tests/TestInit.php diff --git a/composer.json b/composer.json index b5b179de..c45ff203 100644 --- a/composer.json +++ b/composer.json @@ -25,5 +25,10 @@ "psr-0": { "CrEOF\\Spatial": "lib/" } + }, + "autoload-dev": { + "psr-0": { + "CrEOF\\Spatial\\Tests": "tests/" + } } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 329337fb..b5b3e131 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,11 +1,11 @@ - + backupGlobals="false" + colors="true" + bootstrap="./vendor/autoload.php" + beStrictAboutTestsThatDoNotTestAnything="true" + beStrictAboutOutputDuringTests="true" + beStrictAboutChangesToGlobalState="true" +> diff --git a/tests/CrEOF/Spatial/Tests/TestInit.php b/tests/CrEOF/Spatial/Tests/TestInit.php deleted file mode 100644 index 13ee135e..00000000 --- a/tests/CrEOF/Spatial/Tests/TestInit.php +++ /dev/null @@ -1,10 +0,0 @@ -add('CrEOF\Spatial\Tests', __DIR__ . '/../../..'); -$loader->add('Doctrine\Tests', __DIR__ . '/../../../../vendor/doctrine/orm/tests'); -$loader->register(); From 3a30cb5c285fa9802ef7ba7c81fd22f2dd94d741 Mon Sep 17 00:00:00 2001 From: "Derek J. Lambert" Date: Wed, 23 Mar 2016 09:23:48 -0500 Subject: [PATCH 09/13] Name is a required attribute of testsuite --- phpunit.xml.dist | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b5b3e131..3d835ab7 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,4 +1,7 @@ + - + ./tests/CrEOF/Spatial/Tests From 01a185769face075e631b12cb3a977692ea4a7fc Mon Sep 17 00:00:00 2001 From: "Derek J. Lambert" Date: Wed, 23 Mar 2016 09:40:21 -0500 Subject: [PATCH 10/13] Travis config needs changes too --- tests/travis/composer.orm2.3.json | 5 +++++ tests/travis/composer.orm2.4.json | 5 +++++ tests/travis/composer.orm2.5.json | 5 +++++ tests/travis/travis.mysql.xml | 20 +++++++++++--------- tests/travis/travis.pgsql.xml | 20 +++++++++++--------- 5 files changed, 37 insertions(+), 18 deletions(-) diff --git a/tests/travis/composer.orm2.3.json b/tests/travis/composer.orm2.3.json index bc2ee258..5a1c184c 100644 --- a/tests/travis/composer.orm2.3.json +++ b/tests/travis/composer.orm2.3.json @@ -25,5 +25,10 @@ "psr-0": { "CrEOF\\Spatial": "lib/" } + }, + "autoload-dev": { + "psr-0": { + "CrEOF\\Spatial\\Tests": "tests/" + } } } diff --git a/tests/travis/composer.orm2.4.json b/tests/travis/composer.orm2.4.json index 2ac28127..2f36dc5a 100644 --- a/tests/travis/composer.orm2.4.json +++ b/tests/travis/composer.orm2.4.json @@ -25,5 +25,10 @@ "psr-0": { "CrEOF\\Spatial": "lib/" } + }, + "autoload-dev": { + "psr-0": { + "CrEOF\\Spatial\\Tests": "tests/" + } } } diff --git a/tests/travis/composer.orm2.5.json b/tests/travis/composer.orm2.5.json index 0338cfbf..71c2cda7 100644 --- a/tests/travis/composer.orm2.5.json +++ b/tests/travis/composer.orm2.5.json @@ -25,5 +25,10 @@ "psr-0": { "CrEOF\\Spatial": "lib/" } + }, + "autoload-dev": { + "psr-0": { + "CrEOF\\Spatial\\Tests": "tests/" + } } } diff --git a/tests/travis/travis.mysql.xml b/tests/travis/travis.mysql.xml index 03cbcfc5..1d70b2ac 100644 --- a/tests/travis/travis.mysql.xml +++ b/tests/travis/travis.mysql.xml @@ -1,15 +1,17 @@ - + - + ../CrEOF/Spatial/Tests diff --git a/tests/travis/travis.pgsql.xml b/tests/travis/travis.pgsql.xml index c1d326aa..d87c11d5 100644 --- a/tests/travis/travis.pgsql.xml +++ b/tests/travis/travis.pgsql.xml @@ -1,15 +1,17 @@ - + - + ../CrEOF/Spatial/Tests From fc32501e3796afa31fe36c7776302db864197baf Mon Sep 17 00:00:00 2001 From: Jan Jakes Date: Wed, 23 Mar 2016 09:01:24 +0100 Subject: [PATCH 11/13] Do not parse numeric values in Point coordinate setters --- lib/CrEOF/Spatial/PHP/Types/AbstractPoint.php | 40 +++++++++++-------- .../Spatial/PHP/Types/Geography/Point.php | 34 +++++++++------- 2 files changed, 44 insertions(+), 30 deletions(-) diff --git a/lib/CrEOF/Spatial/PHP/Types/AbstractPoint.php b/lib/CrEOF/Spatial/PHP/Types/AbstractPoint.php index cc9d6c4f..9deadfa7 100644 --- a/lib/CrEOF/Spatial/PHP/Types/AbstractPoint.php +++ b/lib/CrEOF/Spatial/PHP/Types/AbstractPoint.php @@ -64,16 +64,20 @@ public function __construct() */ public function setX($x) { - $parser = new Parser($x); - - try { - $this->x = (float) $parser->parse(); - } catch (RangeException $e) { - throw new InvalidValueException($e->getMessage(), $e->getCode(), $e->getPrevious()); - } catch (UnexpectedValueException $e) { - throw new InvalidValueException($e->getMessage(), $e->getCode(), $e->getPrevious()); + if (!is_numeric($x)) { + $parser = new Parser($x); + + try { + $x = $parser->parse(); + } catch (RangeException $e) { + throw new InvalidValueException($e->getMessage(), $e->getCode(), $e->getPrevious()); + } catch (UnexpectedValueException $e) { + throw new InvalidValueException($e->getMessage(), $e->getCode(), $e->getPrevious()); + } } + $this->x = (float) $x; + return $this; } @@ -93,16 +97,20 @@ public function getX() */ public function setY($y) { - $parser = new Parser($y); - - try { - $this->y = (float) $parser->parse(); - } catch (RangeException $e) { - throw new InvalidValueException($e->getMessage(), $e->getCode(), $e->getPrevious()); - } catch (UnexpectedValueException $e) { - throw new InvalidValueException($e->getMessage(), $e->getCode(), $e->getPrevious()); + if (!is_numeric($y)) { + $parser = new Parser($y); + + try { + $y = $parser->parse(); + } catch (RangeException $e) { + throw new InvalidValueException($e->getMessage(), $e->getCode(), $e->getPrevious()); + } catch (UnexpectedValueException $e) { + throw new InvalidValueException($e->getMessage(), $e->getCode(), $e->getPrevious()); + } } + $this->y = (float) $y; + return $this; } diff --git a/lib/CrEOF/Spatial/PHP/Types/Geography/Point.php b/lib/CrEOF/Spatial/PHP/Types/Geography/Point.php index 62b1b9d8..0f2135e2 100644 --- a/lib/CrEOF/Spatial/PHP/Types/Geography/Point.php +++ b/lib/CrEOF/Spatial/PHP/Types/Geography/Point.php @@ -45,16 +45,19 @@ class Point extends AbstractPoint implements GeographyInterface */ public function setX($x) { - $parser = new Parser($x); + if (!is_numeric($x)) { + $parser = new Parser($x); - try { - $x = (float) $parser->parse(); - } catch (RangeException $e) { - throw new InvalidValueException($e->getMessage(), $e->getCode(), $e->getPrevious()); - } catch (UnexpectedValueException $e) { - throw new InvalidValueException($e->getMessage(), $e->getCode(), $e->getPrevious()); + try { + $x = $parser->parse(); + } catch (RangeException $e) { + throw new InvalidValueException($e->getMessage(), $e->getCode(), $e->getPrevious()); + } catch (UnexpectedValueException $e) { + throw new InvalidValueException($e->getMessage(), $e->getCode(), $e->getPrevious()); + } } + $x = (float) $x; if ($x < -180 || $x > 180) { throw new InvalidValueException(sprintf('Invalid longitude value "%s", must be in range -180 to 180.', $x)); } @@ -72,16 +75,19 @@ public function setX($x) */ public function setY($y) { - $parser = new Parser($y); + if (!is_numeric($y)) { + $parser = new Parser($y); - try { - $y = (float) $parser->parse(); - } catch (RangeException $e) { - throw new InvalidValueException($e->getMessage(), $e->getCode(), $e->getPrevious()); - } catch (UnexpectedValueException $e) { - throw new InvalidValueException($e->getMessage(), $e->getCode(), $e->getPrevious()); + try { + $y = $parser->parse(); + } catch (RangeException $e) { + throw new InvalidValueException($e->getMessage(), $e->getCode(), $e->getPrevious()); + } catch (UnexpectedValueException $e) { + throw new InvalidValueException($e->getMessage(), $e->getCode(), $e->getPrevious()); + } } + $y = (float) $y; if ($y < -90 || $y > 90) { throw new InvalidValueException(sprintf('Invalid latitude value "%s", must be in range -90 to 90.', $y)); } From 0ab13634a81037395354115793b2ab9293f8009c Mon Sep 17 00:00:00 2001 From: "Derek J. Lambert" Date: Wed, 6 Apr 2016 18:11:24 -0500 Subject: [PATCH 12/13] Add test for #141 --- tests/CrEOF/Spatial/Tests/PHP/Types/Geometry/PointTest.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/CrEOF/Spatial/Tests/PHP/Types/Geometry/PointTest.php b/tests/CrEOF/Spatial/Tests/PHP/Types/Geometry/PointTest.php index 0628e5d8..e9d5ac0c 100644 --- a/tests/CrEOF/Spatial/Tests/PHP/Types/Geometry/PointTest.php +++ b/tests/CrEOF/Spatial/Tests/PHP/Types/Geometry/PointTest.php @@ -35,12 +35,17 @@ */ class PointTest extends \PHPUnit_Framework_TestCase { - public function testGoodNumericPoint() + public function testGoodNumericPoints() { $point1 = new Point(-73.7562317, 42.6525793); $this->assertEquals(42.6525793, $point1->getLatitude()); $this->assertEquals(-73.7562317, $point1->getLongitude()); + + $point2 = new Point(0.00001, 0.00003); + + $this->assertEquals(0.00003, $point2->getLatitude()); + $this->assertEquals(0.00001, $point2->getLongitude()); } public function testGoodStringPoints() From a23d2993bd4e375397f02fd91aa5f5751b9c938b Mon Sep 17 00:00:00 2001 From: "Derek J. Lambert" Date: Wed, 6 Apr 2016 18:13:47 -0500 Subject: [PATCH 13/13] Use type safe comparisons. Replace is_null will null comparison. Remove nested if and make condition even more ridiculous. --- lib/CrEOF/Spatial/PHP/Types/AbstractPoint.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/CrEOF/Spatial/PHP/Types/AbstractPoint.php b/lib/CrEOF/Spatial/PHP/Types/AbstractPoint.php index 9deadfa7..9070c577 100644 --- a/lib/CrEOF/Spatial/PHP/Types/AbstractPoint.php +++ b/lib/CrEOF/Spatial/PHP/Types/AbstractPoint.php @@ -64,7 +64,7 @@ public function __construct() */ public function setX($x) { - if (!is_numeric($x)) { + if (! is_numeric($x)) { $parser = new Parser($x); try { @@ -97,7 +97,7 @@ public function getX() */ public function setY($y) { - if (!is_numeric($y)) { + if (! is_numeric($y)) { $parser = new Parser($y); try { @@ -185,12 +185,12 @@ protected function validateArguments(array $argv = null) { $argc = count($argv); - if (1 == $argc && is_array($argv[0])) { + if (1 === $argc && is_array($argv[0])) { return $argv[0]; } - if (2 == $argc) { - if (is_array($argv[0]) && (is_numeric($argv[1]) || is_null($argv[1]) || is_string($argv[1]))) { + if (2 === $argc) { + if (is_array($argv[0]) && (is_numeric($argv[1]) || null === $argv[1] || is_string($argv[1]))) { $argv[0][] = $argv[1]; return $argv[0]; @@ -201,10 +201,8 @@ protected function validateArguments(array $argv = null) } } - if (3 == $argc) { - if ((is_numeric($argv[0]) || is_string($argv[0])) && (is_numeric($argv[1]) || is_string($argv[1])) && (is_numeric($argv[2]) || is_null($argv[2]) || is_string($argv[2]))) { - return $argv; - } + if (3 === $argc && ((is_numeric($argv[0]) || is_string($argv[0])) && (is_numeric($argv[1]) || is_string($argv[1])) && (is_numeric($argv[2]) || null === $argv[2] || is_string($argv[2])))) { + return $argv; } array_walk($argv, function (&$value) {