From 3dc32e4ef47ce72ac1c8be46ee54b9d29b1335f3 Mon Sep 17 00:00:00 2001 From: Ron Cemer Date: Wed, 14 Oct 2015 10:49:28 -0500 Subject: [PATCH] PHP 5.3 compatibility. --- src/KMeans/Cluster.php | 8 ++++---- src/KMeans/Point.php | 6 +++--- src/KMeans/Space.php | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/KMeans/Cluster.php b/src/KMeans/Cluster.php index 48564e7..ca2f93d 100644 --- a/src/KMeans/Cluster.php +++ b/src/KMeans/Cluster.php @@ -44,14 +44,14 @@ class Cluster extends Point implements IteratorAggregate, Countable public function toArray() { - $points = []; + $points = array(); foreach ($this->points as $point) $points[] = $point->toArray(); - return [ + return array( 'centroid' => parent::toArray(), 'points' => $points, - ]; + ); } public function attach(Point $point) @@ -103,4 +103,4 @@ class Cluster extends Point implements IteratorAggregate, Countable { return count($this->points); } -} \ No newline at end of file +} diff --git a/src/KMeans/Point.php b/src/KMeans/Point.php index 63a9137..4a33f59 100644 --- a/src/KMeans/Point.php +++ b/src/KMeans/Point.php @@ -43,10 +43,10 @@ class Point implements ArrayAccess public function toArray() { - return [ + return array( 'coordinates' => $this->coordinates, 'data' => isset($this->space[$this]) ? $this->space[$this] : null, - ]; + ); } public function getDistanceWith(self $point) @@ -117,4 +117,4 @@ class Point implements ArrayAccess { unset($this->coordinates[$offset]); } -} \ No newline at end of file +} diff --git a/src/KMeans/Space.php b/src/KMeans/Space.php index 0210c3f..401d001 100644 --- a/src/KMeans/Space.php +++ b/src/KMeans/Space.php @@ -50,11 +50,11 @@ class Space extends SplObjectStorage public function toArray() { - $points = []; + $points = array(); foreach ($this as $point) $points[] = $point->toArray(); - return ['points' => $points]; + return array('points' => $points); } public function newPoint(array $coordinates) @@ -98,7 +98,7 @@ class Space extends SplObjectStorage } } - return [$min, $max]; + return array($min, $max); } public function getRandomPoint(Point $min, Point $max) @@ -229,4 +229,4 @@ class Space extends SplObjectStorage return $continue; } -} \ No newline at end of file +}