Skip to content

add mixed return type #727

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/Contracts/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function offsetUnset($offset): void
}

#[\ReturnTypeWillChange]
public function offsetGet($offset)
public function offsetGet($offset): mixed
Comment on lines 31 to +32
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Remove redundant attribute with mixed return type

The change to add : mixed return type is correct and aligns with PHP 8 practices. However, the #[\ReturnTypeWillChange] attribute on line 31 is now redundant and should be removed since you've explicitly declared the return type.

-    #[\ReturnTypeWillChange]
     public function offsetGet($offset): mixed

This change appropriately resolves the deprecation notice while taking advantage of PHP 8's type system. As noted in the PR discussion, this does make PHP 8.0+ a requirement for this library.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#[\ReturnTypeWillChange]
public function offsetGet($offset)
public function offsetGet($offset): mixed
public function offsetGet($offset): mixed

{
if (isset($this->data[$offset])) {
return $this->data[$offset];
Expand Down
Loading