diff --git a/src/Attribute/AttributeBagNamespaced.php b/src/Attribute/AttributeBagNamespaced.php index 840b07ee..515acce1 100644 --- a/src/Attribute/AttributeBagNamespaced.php +++ b/src/Attribute/AttributeBagNamespaced.php @@ -93,11 +93,11 @@ public function removeAttribute($name) public function getAttributes() { $attributes = array(); - $len = strlen($this->prefix); + $len = \strlen($this->prefix); foreach ($this->bag->getAttributes() as $name => $value) { - if (strpos($name, $this->prefix) === 0) { - $attributes[substr($name, $len)] = $value; + if (\strpos($name, $this->prefix) === 0) { + $attributes[\substr($name, $len)] = $value; } } diff --git a/src/Graph.php b/src/Graph.php index 5bb68258..be3fcbea 100644 --- a/src/Graph.php +++ b/src/Graph.php @@ -115,14 +115,14 @@ public function createEdgeDirected(Vertex $source, Vertex $target) public function createVertices($n) { $vertices = array(); - if (is_int($n) && $n >= 0) { + if (\is_int($n) && $n >= 0) { for ($id = $this->getNextId(), $n += $id; $id < $n; ++$id) { $vertices[$id] = new Vertex($this, $id); } - } elseif (is_array($n)) { + } elseif (\is_array($n)) { // array given => check to make sure all given IDs are available (atomic operation) foreach ($n as $id) { - if (!is_int($id) && !is_string($id)) { + if (!\is_int($id) && !\is_string($id)) { throw new InvalidArgumentException('All Vertex IDs have to be of type integer or string'); } elseif ($this->vertices->hasVertexId($id)) { throw new OverflowException('Given array of Vertex IDs contains an ID that already exists. Given IDs must be unique'); @@ -159,7 +159,7 @@ private function getNextId() } // auto ID - return max(array_keys($this->verticesStorage))+1; + return \max(\array_keys($this->verticesStorage))+1; } /** @@ -267,22 +267,22 @@ public function __clone() $map = array(); foreach ($vertices as $originalVertex) { - assert($originalVertex instanceof Vertex); + \assert($originalVertex instanceof Vertex); $vertex = new Vertex($this, $originalVertex->getId()); $vertex->getAttributeBag()->setAttributes($originalVertex->getAttributeBag()->getAttributes()); // create map with old vertex hash to new vertex object - $map[spl_object_hash($originalVertex)] = $vertex; + $map[\spl_object_hash($originalVertex)] = $vertex; } foreach ($edges as $originalEdge) { - assert($originalEdge instanceof Edge); + \assert($originalEdge instanceof Edge); // use map to match old vertex hashes to new vertex objects $vertices = $originalEdge->getVertices()->getVector(); - $v1 = $map[spl_object_hash($vertices[0])]; - $v2 = $map[spl_object_hash($vertices[1])]; + $v1 = $map[\spl_object_hash($vertices[0])]; + $v2 = $map[\spl_object_hash($vertices[1])]; // recreate edge and assign attributes if ($originalEdge instanceof EdgeUndirected) { diff --git a/src/Set/Edges.php b/src/Set/Edges.php index 37ba8dc5..acd32340 100644 --- a/src/Set/Edges.php +++ b/src/Set/Edges.php @@ -76,7 +76,7 @@ public function __construct(array $edges = array()) */ public function getIndexEdge(Edge $edge) { - $id = array_search($edge, $this->edges, true); + $id = \array_search($edge, $this->edges, true); if ($id === false) { throw new OutOfBoundsException('Given edge does NOT exist'); } @@ -99,9 +99,9 @@ public function getEdgeFirst() if (!$this->edges) { throw new UnderflowException('Does not contain any edges'); } - reset($this->edges); + \reset($this->edges); - return current($this->edges); + return \current($this->edges); } /** @@ -115,9 +115,9 @@ public function getEdgeLast() if (!$this->edges) { throw new UnderflowException('Does not contain any edges'); } - end($this->edges); + \end($this->edges); - return current($this->edges); + return \current($this->edges); } /** @@ -133,7 +133,7 @@ public function getEdgeRandom() throw new UnderflowException('Does not contain any edges'); } - return $this->edges[array_rand($this->edges)]; + return $this->edges[\array_rand($this->edges)]; } /** @@ -196,7 +196,7 @@ public function hasEdgeMatch($callbackCheck) */ public function getEdgesMatch($callbackCheck) { - return new static(array_filter($this->edges, $callbackCheck)); + return new static(\array_filter($this->edges, $callbackCheck)); } /** @@ -213,7 +213,7 @@ public function getEdgesOrder($orderBy, $desc = false) $callback = $this->getCallback($orderBy); $array = $this->edges; - uasort($array, function (Edge $va, Edge $vb) use ($callback, $desc) { + \uasort($array, function (Edge $va, Edge $vb) use ($callback, $desc) { $ra = $callback($desc ? $vb : $va); $rb = $callback($desc ? $va : $vb); @@ -242,8 +242,8 @@ public function getEdgesOrder($orderBy, $desc = false) public function getEdgesShuffled() { // shuffle the edge positions - $keys = array_keys($this->edges); - shuffle($keys); + $keys = \array_keys($this->edges); + \shuffle($keys); // re-order according to shuffled edge positions $edges = array(); @@ -305,7 +305,7 @@ public function getEdgesDistinct() $edges = array(); foreach ($this->edges as $edge) { // filter duplicate edges - if (!in_array($edge, $edges, true)) { + if (!\in_array($edge, $edges, true)) { $edges []= $edge; } } @@ -333,7 +333,7 @@ public function getEdgesIntersection($otherEdges) $edges = array(); foreach ($this->edges as $eid => $edge) { - $i = array_search($edge, $otherArray, true); + $i = \array_search($edge, $otherArray, true); if ($i !== false) { // remove from other array in order to check for duplicate matches @@ -353,7 +353,7 @@ public function getEdgesIntersection($otherEdges) */ public function getVector() { - return array_values($this->edges); + return \array_values($this->edges); } /** @@ -364,7 +364,7 @@ public function getVector() */ public function count() { - return count($this->edges); + return \count($this->edges); } /** @@ -431,10 +431,10 @@ private function getEdgeMatchOrNull($callbackCheck) */ private function getCallback($callback) { - if (is_callable($callback)) { - if (is_array($callback)) { + if (\is_callable($callback)) { + if (\is_array($callback)) { $callback = function (Edge $edge) use ($callback) { - return call_user_func($callback, $edge); + return \call_user_func($callback, $edge); }; } return $callback; diff --git a/src/Set/Vertices.php b/src/Set/Vertices.php index bc40c9de..4692a126 100644 --- a/src/Set/Vertices.php +++ b/src/Set/Vertices.php @@ -109,7 +109,7 @@ public function hasVertexId($id) */ public function getIndexVertex(Vertex $vertex) { - $id = array_search($vertex, $this->vertices, true); + $id = \array_search($vertex, $this->vertices, true); if ($id === false) { throw new OutOfBoundsException('Given vertex does NOT exist'); } @@ -132,9 +132,9 @@ public function getVertexFirst() if (!$this->vertices) { throw new UnderflowException('Does not contain any vertices'); } - reset($this->vertices); + \reset($this->vertices); - return current($this->vertices); + return \current($this->vertices); } /** @@ -148,9 +148,9 @@ public function getVertexLast() if (!$this->vertices) { throw new UnderflowException('Does not contain any vertices'); } - end($this->vertices); + \end($this->vertices); - return current($this->vertices); + return \current($this->vertices); } /** @@ -166,7 +166,7 @@ public function getVertexRandom() throw new UnderflowException('Does not contain any vertices'); } - return $this->vertices[array_rand($this->vertices)]; + return $this->vertices[\array_rand($this->vertices)]; } /** @@ -215,7 +215,7 @@ public function hasVertexMatch($callbackCheck) */ public function getVerticesMatch($callbackCheck) { - return new static(array_filter($this->vertices, $callbackCheck)); + return new static(\array_filter($this->vertices, $callbackCheck)); } /** @@ -234,7 +234,7 @@ public function getVerticesOrder($orderBy, $desc = false) $callback = $this->getCallback($orderBy); $array = $this->vertices; - uasort($array, function (Vertex $va, Vertex $vb) use ($callback, $desc) { + \uasort($array, function (Vertex $va, Vertex $vb) use ($callback, $desc) { $ra = $callback($desc ? $vb : $va); $rb = $callback($desc ? $va : $vb); @@ -263,8 +263,8 @@ public function getVerticesOrder($orderBy, $desc = false) public function getVerticesShuffled() { // shuffle the vertex positions - $keys = array_keys($this->vertices); - shuffle($keys); + $keys = \array_keys($this->vertices); + \shuffle($keys); // re-order according to shuffled vertex positions $vertices = array(); @@ -295,7 +295,7 @@ public function getVerticesIntersection($otherVertices) $vertices = array(); foreach ($this->vertices as $vid => $vertex) { - $i = array_search($vertex, $otherArray, true); + $i = \array_search($vertex, $otherArray, true); if ($i !== false) { // remove from other array in order to check for duplicate matches @@ -397,7 +397,7 @@ public function getIds() */ public function getVector() { - return array_values($this->vertices); + return \array_values($this->vertices); } /** @@ -408,7 +408,7 @@ public function getVector() */ public function count() { - return count($this->vertices); + return \count($this->vertices); } /** @@ -432,7 +432,7 @@ public function isEmpty() */ public function hasDuplicates() { - return (count($this->vertices) !== count($this->getMap())); + return (\count($this->vertices) !== \count($this->getMap())); } /** @@ -493,10 +493,10 @@ private function getVertexMatchOrNull($callbackCheck) */ private function getCallback($callback) { - if (is_callable($callback)) { - if (is_array($callback)) { + if (\is_callable($callback)) { + if (\is_array($callback)) { $callback = function (Vertex $vertex) use ($callback) { - return call_user_func($callback, $vertex); + return \call_user_func($callback, $vertex); }; } return $callback; diff --git a/src/Set/VerticesMap.php b/src/Set/VerticesMap.php index e70e6c41..f894ac64 100644 --- a/src/Set/VerticesMap.php +++ b/src/Set/VerticesMap.php @@ -39,7 +39,7 @@ public function getVerticesDistinct() public function getIds() { - return array_keys($this->vertices); + return \array_keys($this->vertices); } public function getIndexVertex(Vertex $vertex) diff --git a/src/Vertex.php b/src/Vertex.php index 3298f99d..bd24d304 100644 --- a/src/Vertex.php +++ b/src/Vertex.php @@ -35,7 +35,7 @@ class Vertex implements EdgesAggregate, AttributeAware */ public function __construct(Graph $graph, $id) { - if (!is_int($id) && !is_string($id)) { + if (!\is_int($id) && !\is_string($id)) { throw new InvalidArgumentException('Vertex ID has to be of type integer or string'); } @@ -89,7 +89,7 @@ public function addEdge(Edge $edge) */ public function removeEdge(Edge $edge) { - $id = array_search($edge, $this->edges, true); + $id = \array_search($edge, $this->edges, true); if ($id === false) { throw new InvalidArgumentException('Given edge does NOT exist'); } diff --git a/src/Walk.php b/src/Walk.php index 4a21746d..f79ff9fc 100644 --- a/src/Walk.php +++ b/src/Walk.php @@ -116,10 +116,10 @@ public static function factoryCycleFromPredecessorMap(array $predecessors, Verte } while (!isset($vertices[$vid])); // reverse cycle, because cycle is actually built in opposite direction due to checking predecessors - $vertices = array_reverse($vertices, true); + $vertices = \array_reverse($vertices, true); // additional edge from last vertex to first vertex - $vertices[] = reset($vertices); + $vertices[] = \reset($vertices); return self::factoryCycleFromVertices($vertices, $orderBy, $desc); } @@ -245,7 +245,7 @@ public function getAlternatingSequence() $vertices = $this->vertices->getVector(); $ret = array(); - for ($i = 0, $l = count($this->edges); $i < $l; ++$i) { + for ($i = 0, $l = \count($this->edges); $i < $l; ++$i) { $ret []= $vertices[$i]; $ret []= $edges[$i]; } @@ -275,7 +275,7 @@ public function isValid() $edges = $this->getGraph()->getEdges()->getVector(); // check source graph contains all edges foreach ($this->edges as $edge) { - if (!in_array($edge, $edges, true)) { + if (!\in_array($edge, $edges, true)) { return false; } }