Skip to content

Commit

Permalink
Spl bugs fixing and visibility changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Steeven Andrian committed Mar 12, 2019
1 parent e43013f commit 4b00101
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 25 deletions.
6 changes: 3 additions & 3 deletions src/DataStructures/SplArrayQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function has($needle, $strict = false)
// -----------------------------------------------------------------------

/**
* SplArrayStack::getArrayCopy
* SplArrayQueue::getArrayCopy
*
* Creates a copy of the storage.
*
Expand All @@ -104,8 +104,8 @@ public function getArrayCopy()
{
$arrayCopy = [];

foreach ($this as $key => $value) {
$arrayCopy[ $key ] = $value;
for ($this->rewind(); $this->valid(); $this->next()) {
$arrayCopy[] = $this->current();
}

return $arrayCopy;
Expand Down
22 changes: 2 additions & 20 deletions src/DataStructures/SplArrayStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,6 @@ public function __construct(array $stack = [])

// -----------------------------------------------------------------------

/**
* SplArrayStack::current
*
* Replacement for \SplStack current method
*
* @return mixed
*/
public function current()
{
if (null === ($current = parent::current())) {
$this->rewind();
}

return parent::current();
}

// -----------------------------------------------------------------------

/**
* SplArrayStack::isEmpty
*
Expand Down Expand Up @@ -104,8 +86,8 @@ public function getArrayCopy()
{
$arrayCopy = [];

foreach ($this as $key => $value) {
$arrayCopy[ $key ] = $value;
for ($this->rewind(); $this->valid(); $this->next()) {
$arrayCopy[] = $this->current();
}

return $arrayCopy;
Expand Down
9 changes: 7 additions & 2 deletions src/Traits/Collectors/FilePathCollectorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ public function addFilePath($filePath, $offset = null)
) . $this->fileDirName . DIRECTORY_SEPARATOR;
}

return $this->pushFilePath($filePath, $offset);
}

// ------------------------------------------------------------------------

public function pushFilePath($filePath, $offset = null)
{
if (is_dir($filePath) AND ! in_array($filePath, $this->filePaths)) {
if (isset($offset)) {
$this->filePaths[ $offset ] = $filePath;
Expand All @@ -111,6 +118,4 @@ public function addFilePath($filePath, $offset = null)

return $this;
}

// ------------------------------------------------------------------------
}

0 comments on commit 4b00101

Please sign in to comment.