Skip to content

Commit

Permalink
Merge pull request #162 from cebe/php-8.1-compatibility
Browse files Browse the repository at this point in the history
Php 8.1 compatibility
  • Loading branch information
cebe authored Apr 20, 2022
2 parents 67c63d1 + 495f3ef commit c448862
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- "7.3"
- "7.4"
- "8.0"
- "8.1"
dependencies:
- "lowest"
- "highest"
Expand Down Expand Up @@ -48,6 +49,8 @@ jobs:
# symfony/yaml v3.4 is not compatible with PHP 8.0 but has no upper-bound, so it installs on it
- php: '8.0'
symfony-yaml: '^3.4'
- php: '8.1'
symfony-yaml: '^3.4'

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

Expand All @@ -62,7 +65,11 @@ jobs:
tools: composer:v2

- name: Require specific symfony/yaml version
run: "composer require symfony/yaml:'${{ matrix.symfony-yaml }}' --prefer-dist --no-interaction --ansi --no-install"
run: "composer require symfony/yaml:'${{ matrix.symfony-yaml }}' --no-interaction --ansi --no-install"

- name: Require newer phpunit/phpunit version
run: "composer require phpunit/phpunit '^9.5' --dev --no-interaction --ansi --no-install"
if: matrix.php == '8.1'

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v2"
Expand Down
3 changes: 2 additions & 1 deletion src/json/JsonReference.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ public function getReference(): string
* @return mixed data which can be serialized by <b>json_encode</b>,
* which is a value of any type other than a resource.
*/
public function jsonSerialize()
#[\ReturnTypeWillChange]
public function jsonSerialize() //: mixed
{
return (object)['$ref' => $this->getReference()];
}
Expand Down
13 changes: 7 additions & 6 deletions src/spec/Paths.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function getErrors(): array
* @return boolean true on success or false on failure.
* The return value will be casted to boolean if non-boolean was returned.
*/
public function offsetExists($offset)
public function offsetExists($offset): bool
{
return $this->hasPath($offset);
}
Expand All @@ -194,7 +194,8 @@ public function offsetExists($offset)
* @param mixed $offset The offset to retrieve.
* @return PathItem Can return all value types.
*/
public function offsetGet($offset)
#[\ReturnTypeWillChange]
public function offsetGet($offset) //: mixed
{
return $this->getPath($offset);
}
Expand All @@ -205,7 +206,7 @@ public function offsetGet($offset)
* @param mixed $offset The offset to assign the value to.
* @param mixed $value The value to set.
*/
public function offsetSet($offset, $value)
public function offsetSet($offset, $value): void
{
$this->addPath($offset, $value);
}
Expand All @@ -215,7 +216,7 @@ public function offsetSet($offset, $value)
* @link http://php.net/manual/en/arrayaccess.offsetunset.php
* @param mixed $offset The offset to unset.
*/
public function offsetUnset($offset)
public function offsetUnset($offset): void
{
$this->removePath($offset);
}
Expand All @@ -226,7 +227,7 @@ public function offsetUnset($offset)
* @return int The custom count as an integer.
* The return value is cast to an integer.
*/
public function count()
public function count(): int
{
return count($this->_paths);
}
Expand All @@ -236,7 +237,7 @@ public function count()
* @link http://php.net/manual/en/iteratoraggregate.getiterator.php
* @return Traversable An instance of an object implementing <b>Iterator</b> or <b>Traversable</b>
*/
public function getIterator()
public function getIterator(): Traversable
{
return new ArrayIterator($this->_paths);
}
Expand Down
13 changes: 7 additions & 6 deletions src/spec/Responses.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function getErrors(): array
* @return boolean true on success or false on failure.
* The return value will be casted to boolean if non-boolean was returned.
*/
public function offsetExists($offset)
public function offsetExists($offset): bool
{
return $this->hasResponse($offset);
}
Expand All @@ -184,7 +184,8 @@ public function offsetExists($offset)
* @param mixed $offset The offset to retrieve.
* @return mixed Can return all value types.
*/
public function offsetGet($offset)
#[\ReturnTypeWillChange]
public function offsetGet($offset) //: mixed
{
return $this->getResponse($offset);
}
Expand All @@ -195,7 +196,7 @@ public function offsetGet($offset)
* @param mixed $offset The offset to assign the value to.
* @param mixed $value The value to set.
*/
public function offsetSet($offset, $value)
public function offsetSet($offset, $value): void
{
$this->addResponse($offset, $value);
}
Expand All @@ -205,7 +206,7 @@ public function offsetSet($offset, $value)
* @link http://php.net/manual/en/arrayaccess.offsetunset.php
* @param mixed $offset The offset to unset.
*/
public function offsetUnset($offset)
public function offsetUnset($offset): void
{
$this->removeResponse($offset);
}
Expand All @@ -216,7 +217,7 @@ public function offsetUnset($offset)
* @return int The custom count as an integer.
* The return value is cast to an integer.
*/
public function count()
public function count(): int
{
return count($this->_responses);
}
Expand All @@ -226,7 +227,7 @@ public function count()
* @link http://php.net/manual/en/iteratoraggregate.getiterator.php
* @return Traversable An instance of an object implementing <b>Iterator</b> or <b>Traversable</b>
*/
public function getIterator()
public function getIterator(): Traversable
{
return new ArrayIterator($this->_responses);
}
Expand Down

0 comments on commit c448862

Please sign in to comment.