Skip to content

Commit 1121ee1

Browse files
authored
Merge pull request #58 from davidcole1340/php-81-support
Fix PHP 8.1 deprecations
2 parents 9f21944 + 3ba0651 commit 1121ee1

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/Option.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,10 @@ protected function initFromSpecString($specString)
123123
$this->short = $short;
124124
$this->long = $long;
125125

126-
// option is required.
127-
if (strpos($attributes, ':') !== false) {
126+
if ($attributes === null) {
127+
$this->flag();
128+
} else if (strpos($attributes, ':') !== false) {
129+
// option is required.
128130
$this->required();
129131
} else if (strpos($attributes, '+') !== false) {
130132
// option with multiple value

src/OptionCollection.php

+2
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,13 @@ public function keys()
195195
return array_merge(array_keys($this->longOptions), array_keys($this->shortOptions));
196196
}
197197

198+
#[\ReturnTypeWillChange]
198199
public function count()
199200
{
200201
return count($this->data);
201202
}
202203

204+
#[\ReturnTypeWillChange]
203205
public function getIterator()
204206
{
205207
return new ArrayIterator($this->data);

src/OptionResult.php

+6
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ class OptionResult
3838
/* arguments */
3939
public $arguments = array();
4040

41+
#[\ReturnTypeWillChange]
4142
public function getIterator()
4243
{
4344
return new ArrayIterator($this->keys);
4445
}
4546

47+
#[\ReturnTypeWillChange]
4648
public function count()
4749
{
4850
return count($this->keys);
@@ -106,21 +108,25 @@ public function getArguments()
106108
return array_map(function ($e) { return $e->__toString(); }, $this->arguments);
107109
}
108110

111+
#[\ReturnTypeWillChange]
109112
public function offsetSet($name, $value)
110113
{
111114
$this->keys[ $name ] = $value;
112115
}
113116

117+
#[\ReturnTypeWillChange]
114118
public function offsetExists($name)
115119
{
116120
return isset($this->keys[ $name ]);
117121
}
118122

123+
#[\ReturnTypeWillChange]
119124
public function offsetGet($name)
120125
{
121126
return $this->keys[ $name ];
122127
}
123128

129+
#[\ReturnTypeWillChange]
124130
public function offsetUnset($name)
125131
{
126132
unset($this->keys[$name]);

0 commit comments

Comments
 (0)