Skip to content

Commit

Permalink
Merge pull request #58 from davidcole1340/php-81-support
Browse files Browse the repository at this point in the history
Fix PHP 8.1 deprecations
  • Loading branch information
c9s authored Nov 22, 2021
2 parents 9f21944 + 3ba0651 commit 1121ee1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ protected function initFromSpecString($specString)
$this->short = $short;
$this->long = $long;

// option is required.
if (strpos($attributes, ':') !== false) {
if ($attributes === null) {
$this->flag();
} else if (strpos($attributes, ':') !== false) {
// option is required.
$this->required();
} else if (strpos($attributes, '+') !== false) {
// option with multiple value
Expand Down
2 changes: 2 additions & 0 deletions src/OptionCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,13 @@ public function keys()
return array_merge(array_keys($this->longOptions), array_keys($this->shortOptions));
}

#[\ReturnTypeWillChange]
public function count()
{
return count($this->data);
}

#[\ReturnTypeWillChange]
public function getIterator()
{
return new ArrayIterator($this->data);
Expand Down
6 changes: 6 additions & 0 deletions src/OptionResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ class OptionResult
/* arguments */
public $arguments = array();

#[\ReturnTypeWillChange]
public function getIterator()
{
return new ArrayIterator($this->keys);
}

#[\ReturnTypeWillChange]
public function count()
{
return count($this->keys);
Expand Down Expand Up @@ -106,21 +108,25 @@ public function getArguments()
return array_map(function ($e) { return $e->__toString(); }, $this->arguments);
}

#[\ReturnTypeWillChange]
public function offsetSet($name, $value)
{
$this->keys[ $name ] = $value;
}

#[\ReturnTypeWillChange]
public function offsetExists($name)
{
return isset($this->keys[ $name ]);
}

#[\ReturnTypeWillChange]
public function offsetGet($name)
{
return $this->keys[ $name ];
}

#[\ReturnTypeWillChange]
public function offsetUnset($name)
{
unset($this->keys[$name]);
Expand Down

0 comments on commit 1121ee1

Please sign in to comment.