diff --git a/Stdlib/Map/MultiMap.php b/Stdlib/Map/MultiMap.php index ec5ef5841..dc45effb0 100644 --- a/Stdlib/Map/MultiMap.php +++ b/Stdlib/Map/MultiMap.php @@ -276,7 +276,7 @@ final class MultiMap implements \Countable $permutation = Permutation::permut($key, [], false); foreach ($permutation as $permut) { - if ($this->set(\implode(':', $permut), $value)) { + if ($this->setSingle(\implode(':', $permut), $value)) { return true; } } @@ -284,7 +284,7 @@ final class MultiMap implements \Countable return false; } - return $this->set(\implode(':', $key), $value); + return $this->setSingle(\implode(':', $key), $value); } /** @@ -340,7 +340,7 @@ final class MultiMap implements \Countable $key = \is_array($key) ? $key : [$key]; if ($this->orderType !== OrderType::LOOSE) { - return $this->remove(\implode(':', $key)); + return $this->removeSingle(\implode(':', $key)); } /** @var array $keys */ @@ -348,7 +348,7 @@ final class MultiMap implements \Countable $found = false; foreach ($keys as $key => $value) { - $allFound = $this->remove(\implode(':', $value)); + $allFound = $this->removeSingle(\implode(':', $value)); if ($allFound) { $found = true; @@ -505,14 +505,15 @@ final class MultiMap implements \Countable private function getSiblingsSingle(int|string $key) : array { $siblings = []; + if (!isset($this->keys[$key])) { + return []; + } - if (isset($this->keys[$key])) { - $id = $this->keys[$key]; + $id = $this->keys[$key]; - foreach ($this->keys as $found => $value) { - if ($value === $id && $found !== $key) { - $siblings[] = $found; - } + foreach ($this->keys as $found => $value) { + if ($value === $id && $found !== $key) { + $siblings[] = $found; } } diff --git a/tests/Stdlib/Map/MultiMapTest.php b/tests/Stdlib/Map/MultiMapTest.php index b6d5afbbd..ee0d812cd 100644 --- a/tests/Stdlib/Map/MultiMapTest.php +++ b/tests/Stdlib/Map/MultiMapTest.php @@ -651,7 +651,7 @@ class MultiMapTest extends \PHPUnit\Framework\TestCase $map = new MultiMap(KeyType::MULTIPLE); $map->add(['a', 'b'], 'val2'); - $remap = $map->remap(['a', 'b'], ['c', 'd']); + $remap = $map->remap('a', 'b'); self::assertFalse($remap); } @@ -716,7 +716,7 @@ class MultiMapTest extends \PHPUnit\Framework\TestCase self::assertFalse($removed); $removed = $map->remove(['a', 'b']); - self::assertFalse($map->removeKey(['a', 'b'])); + self::assertFalse($map->removeKey('a')); } /** @@ -753,6 +753,6 @@ class MultiMapTest extends \PHPUnit\Framework\TestCase self::assertFalse($removed); $removed = $map->remove(['a', 'b']); - self::assertFalse($map->removeKey(['a', 'b'])); + self::assertFalse($map->removeKey('a')); } } diff --git a/tests/System/File/Ftp/DirectoryTest.php b/tests/System/File/Ftp/DirectoryTest.php index b9fd6dcff..375b649c3 100644 --- a/tests/System/File/Ftp/DirectoryTest.php +++ b/tests/System/File/Ftp/DirectoryTest.php @@ -665,8 +665,9 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase public function testNodeNext() : void { $dir = new Directory(new HttpUri(self::BASE . __DIR__ . '/dirtest'), '*', true, self::$con); + $dir->next(); - self::assertEquals(__DIR__ . '/dirtest/test.txt', $dir->next()->getPath()); + self::assertEquals(__DIR__ . '/dirtest/test.txt', $dir->current()->getPath()); } /** @@ -689,6 +690,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase $dir = new Directory(new HttpUri(self::BASE . __DIR__ . '/dirtest'), '*', true, self::$con); self::assertEquals('sub', $dir->key()); + $dir->next(); self::assertEquals('test.txt', $dir->key()); } @@ -813,8 +815,9 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase public function testDirname() : void { $dir = new Directory(new HttpUri(self::BASE . __DIR__ . '/dirtest'), '*', true, self::$con); + $dir->next(); - self::assertEquals('dirtest', $dir->next()->getDirname()); + self::assertEquals('dirtest', $dir->current()->getDirname()); } /** @@ -824,8 +827,9 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase public function testName() : void { $dir = new Directory(new HttpUri(self::BASE . __DIR__ . '/dirtest'), '*', true, self::$con); + $dir->next(); - self::assertEquals('test', $dir->next()->getName()); + self::assertEquals('test', $dir->current()->getName()); } /** @@ -835,8 +839,9 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase public function testBaseame() : void { $dir = new Directory(new HttpUri(self::BASE . __DIR__ . '/dirtest'), '*', true, self::$con); + $dir->next(); - self::assertEquals('test.txt', $dir->next()->getBasename()); + self::assertEquals('test.txt', $dir->current()->getBasename()); } /** @@ -846,7 +851,8 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase public function testDirpath() : void { $dir = new Directory(new HttpUri(self::BASE . __DIR__ . '/dirtest'), '*', true, self::$con); + $dir->next(); - self::assertEquals(__DIR__ . '/dirtest', $dir->next()->getDirPath()); + self::assertEquals(__DIR__ . '/dirtest', $dir->current()->getDirPath()); } } diff --git a/tests/System/File/Local/DirectoryTest.php b/tests/System/File/Local/DirectoryTest.php index 9a0dcaa10..9e670ced2 100644 --- a/tests/System/File/Local/DirectoryTest.php +++ b/tests/System/File/Local/DirectoryTest.php @@ -634,8 +634,9 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase public function testNodeNext() : void { $dir = new Directory(__DIR__ . '/dirtest'); + $dir->next(); - self::assertEquals(__DIR__ . '/dirtest/test.txt', $dir->next()->getPath()); + self::assertEquals(__DIR__ . '/dirtest/test.txt', $dir->current()->getPath()); } /** @@ -658,6 +659,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase $dir = new Directory(__DIR__ . '/dirtest'); self::assertEquals('sub', $dir->key()); + $dir->next(); self::assertEquals('test.txt', $dir->key()); } @@ -780,8 +782,9 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase public function testDirname() : void { $dir = new Directory(__DIR__ . '/dirtest'); + $dir->next(); - self::assertEquals('dirtest', $dir->next()->getDirName()); + self::assertEquals('dirtest', $dir->current()->getDirName()); } /** @@ -791,8 +794,9 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase public function testName() : void { $dir = new Directory(__DIR__ . '/dirtest'); + $dir->next(); - self::assertEquals('test', $dir->next()->getName()); + self::assertEquals('test', $dir->current()->getName()); } /** @@ -802,8 +806,9 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase public function testBaseame() : void { $dir = new Directory(__DIR__ . '/dirtest'); + $dir->next(); - self::assertEquals('test.txt', $dir->next()->getBasename()); + self::assertEquals('test.txt', $dir->current()->getBasename()); } /** @@ -813,7 +818,8 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase public function testDirpath() : void { $dir = new Directory(__DIR__ . '/dirtest'); + $dir->next(); - self::assertEquals(__DIR__ . '/dirtest', $dir->next()->getDirPath()); + self::assertEquals(__DIR__ . '/dirtest', $dir->current()->getDirPath()); } }