Skip to content

Commit c448862

Browse files
authored
Merge pull request #162 from cebe/php-8.1-compatibility
Php 8.1 compatibility
2 parents 67c63d1 + 495f3ef commit c448862

File tree

4 files changed

+24
-14
lines changed

4 files changed

+24
-14
lines changed

Diff for: .github/workflows/php.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
- "7.3"
2020
- "7.4"
2121
- "8.0"
22+
- "8.1"
2223
dependencies:
2324
- "lowest"
2425
- "highest"
@@ -48,6 +49,8 @@ jobs:
4849
# symfony/yaml v3.4 is not compatible with PHP 8.0 but has no upper-bound, so it installs on it
4950
- php: '8.0'
5051
symfony-yaml: '^3.4'
52+
- php: '8.1'
53+
symfony-yaml: '^3.4'
5154

5255
runs-on: ${{ matrix.os }}
5356

@@ -62,7 +65,11 @@ jobs:
6265
tools: composer:v2
6366

6467
- name: Require specific symfony/yaml version
65-
run: "composer require symfony/yaml:'${{ matrix.symfony-yaml }}' --prefer-dist --no-interaction --ansi --no-install"
68+
run: "composer require symfony/yaml:'${{ matrix.symfony-yaml }}' --no-interaction --ansi --no-install"
69+
70+
- name: Require newer phpunit/phpunit version
71+
run: "composer require phpunit/phpunit '^9.5' --dev --no-interaction --ansi --no-install"
72+
if: matrix.php == '8.1'
6673

6774
- name: "Install dependencies with Composer"
6875
uses: "ramsey/composer-install@v2"

Diff for: src/json/JsonReference.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ public function getReference(): string
126126
* @return mixed data which can be serialized by <b>json_encode</b>,
127127
* which is a value of any type other than a resource.
128128
*/
129-
public function jsonSerialize()
129+
#[\ReturnTypeWillChange]
130+
public function jsonSerialize() //: mixed
130131
{
131132
return (object)['$ref' => $this->getReference()];
132133
}

Diff for: src/spec/Paths.php

+7-6
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public function getErrors(): array
183183
* @return boolean true on success or false on failure.
184184
* The return value will be casted to boolean if non-boolean was returned.
185185
*/
186-
public function offsetExists($offset)
186+
public function offsetExists($offset): bool
187187
{
188188
return $this->hasPath($offset);
189189
}
@@ -194,7 +194,8 @@ public function offsetExists($offset)
194194
* @param mixed $offset The offset to retrieve.
195195
* @return PathItem Can return all value types.
196196
*/
197-
public function offsetGet($offset)
197+
#[\ReturnTypeWillChange]
198+
public function offsetGet($offset) //: mixed
198199
{
199200
return $this->getPath($offset);
200201
}
@@ -205,7 +206,7 @@ public function offsetGet($offset)
205206
* @param mixed $offset The offset to assign the value to.
206207
* @param mixed $value The value to set.
207208
*/
208-
public function offsetSet($offset, $value)
209+
public function offsetSet($offset, $value): void
209210
{
210211
$this->addPath($offset, $value);
211212
}
@@ -215,7 +216,7 @@ public function offsetSet($offset, $value)
215216
* @link http://php.net/manual/en/arrayaccess.offsetunset.php
216217
* @param mixed $offset The offset to unset.
217218
*/
218-
public function offsetUnset($offset)
219+
public function offsetUnset($offset): void
219220
{
220221
$this->removePath($offset);
221222
}
@@ -226,7 +227,7 @@ public function offsetUnset($offset)
226227
* @return int The custom count as an integer.
227228
* The return value is cast to an integer.
228229
*/
229-
public function count()
230+
public function count(): int
230231
{
231232
return count($this->_paths);
232233
}
@@ -236,7 +237,7 @@ public function count()
236237
* @link http://php.net/manual/en/iteratoraggregate.getiterator.php
237238
* @return Traversable An instance of an object implementing <b>Iterator</b> or <b>Traversable</b>
238239
*/
239-
public function getIterator()
240+
public function getIterator(): Traversable
240241
{
241242
return new ArrayIterator($this->_paths);
242243
}

Diff for: src/spec/Responses.php

+7-6
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public function getErrors(): array
173173
* @return boolean true on success or false on failure.
174174
* The return value will be casted to boolean if non-boolean was returned.
175175
*/
176-
public function offsetExists($offset)
176+
public function offsetExists($offset): bool
177177
{
178178
return $this->hasResponse($offset);
179179
}
@@ -184,7 +184,8 @@ public function offsetExists($offset)
184184
* @param mixed $offset The offset to retrieve.
185185
* @return mixed Can return all value types.
186186
*/
187-
public function offsetGet($offset)
187+
#[\ReturnTypeWillChange]
188+
public function offsetGet($offset) //: mixed
188189
{
189190
return $this->getResponse($offset);
190191
}
@@ -195,7 +196,7 @@ public function offsetGet($offset)
195196
* @param mixed $offset The offset to assign the value to.
196197
* @param mixed $value The value to set.
197198
*/
198-
public function offsetSet($offset, $value)
199+
public function offsetSet($offset, $value): void
199200
{
200201
$this->addResponse($offset, $value);
201202
}
@@ -205,7 +206,7 @@ public function offsetSet($offset, $value)
205206
* @link http://php.net/manual/en/arrayaccess.offsetunset.php
206207
* @param mixed $offset The offset to unset.
207208
*/
208-
public function offsetUnset($offset)
209+
public function offsetUnset($offset): void
209210
{
210211
$this->removeResponse($offset);
211212
}
@@ -216,7 +217,7 @@ public function offsetUnset($offset)
216217
* @return int The custom count as an integer.
217218
* The return value is cast to an integer.
218219
*/
219-
public function count()
220+
public function count(): int
220221
{
221222
return count($this->_responses);
222223
}
@@ -226,7 +227,7 @@ public function count()
226227
* @link http://php.net/manual/en/iteratoraggregate.getiterator.php
227228
* @return Traversable An instance of an object implementing <b>Iterator</b> or <b>Traversable</b>
228229
*/
229-
public function getIterator()
230+
public function getIterator(): Traversable
230231
{
231232
return new ArrayIterator($this->_responses);
232233
}

0 commit comments

Comments
 (0)