Skip to content

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
m3m0r7 committed Jan 2, 2024
1 parent 5a49cb7 commit de6ded7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/VM/Core/Runtime/BasicObject/Kernel/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@

use RubyVM\VM\Core\Runtime\BasicObject\BasicObject;
use RubyVM\VM\Core\Runtime\BasicObject\Kernel\Object_\Comparable\String_;
use RubyVM\VM\Exception\RubyVMException;

abstract class Kernel extends BasicObject
{
public function __dir__(): String_
{
if (!$this->context instanceof \RubyVM\VM\Core\Runtime\Executor\Context\ContextInterface) {
throw new RubyVMException('A context is not injected');
}

return String_::createBy(
$this->context
->instructionSequence()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,20 @@ class Dir extends Enumerable implements RubyClassInterface, SymbolizeInterface
use Symbolizable;
protected ?\ArrayIterator $iterator = null;

/**
* @var \DirectoryIterator[]
*/
protected array $files = [];

protected string $directory;

public function __construct(protected SymbolInterface $symbol)
{
$this->directory = (string) $this->symbol;
$this->files = iterator_to_array(
new \DirectoryIterator($this->symbol->valueOf()),
$this->files = array_values(
iterator_to_array(
new \DirectoryIterator($this->symbol->valueOf()),
)
);
}

Expand All @@ -38,7 +43,7 @@ public static function pwd(): RubyClassInterface

public function getIterator(): \ArrayIterator
{
return $this->iterator ??= new \ArrayIterator($this->directory);
return $this->iterator ??= new \ArrayIterator($this->files);
}

public function offsetExists(mixed $offset): bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testCount(): void
->disassemble();

$this->assertSame(ExecutedStatus::SUCCESS, $executor->execute()->executedStatus);
$count = count(iterator_to_array(new \DirectoryIterator(getcwd())));
$count = count(iterator_to_array(new \DirectoryIterator(getcwd() ?: './')));
$this->assertSame("{$count}\n", $rubyVMManager->stdOut->readAll());
}
}

0 comments on commit de6ded7

Please sign in to comment.