Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[openapi v3.1] PHP 8.2 deprecations #178

Open
wants to merge 1 commit into
base: openapi-31
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/json/JsonReference.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ 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.
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return (object)['$ref' => $this->getReference()];
Expand Down
2 changes: 1 addition & 1 deletion src/spec/OpenApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function performValidation()
*/
public function getMajorVersion()
{
if (preg_match(static::PATTERN_VERSION, $this->openapi, $matches)) {
if (is_string($this->openapi) && preg_match(static::PATTERN_VERSION, $this->openapi, $matches)) {
switch ($matches[1]) {
case '3.0':
return static::VERSION_3_0;
Expand Down
11 changes: 6 additions & 5 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,6 +194,7 @@ public function offsetExists($offset)
* @param mixed $offset The offset to retrieve.
* @return PathItem Can return all value types.
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
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
11 changes: 6 additions & 5 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,6 +184,7 @@ public function offsetExists($offset)
* @param mixed $offset The offset to retrieve.
* @return mixed Can return all value types.
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
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