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

Fixes for PHP 8.0 #598

Merged
merged 3 commits into from
Nov 30, 2020
Merged

Fixes for PHP 8.0 #598

merged 3 commits into from
Nov 30, 2020

Conversation

CedNet
Copy link
Contributor

@CedNet CedNet commented Nov 26, 2020

In php 8 method_exists' first value cannot default to null, must be object or string.

Was throwing error: method_exists(): Argument #1 ($object_or_class) must be of type object|string, null given.

In php 8 method_exists' first value cannot default to null, must be object or string.

Was throwing error: method_exists(): Argument formers#1 ($object_or_class) must be of type object|string, null given.
@@ -132,7 +132,7 @@ public function __call($method, $parameters)
}

// Redirect calls to the Control Group
if (method_exists($this->group, $method) or Str::startsWith($method, 'onGroup')) {
if (method_exists($this->group ?: '', $method) or Str::startsWith($method, 'onGroup')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it make more sense to do it like this? No reason to check for an empty method name to exists because we know it will not exist right?

Suggested change
if (method_exists($this->group ?: '', $method) or Str::startsWith($method, 'onGroup')) {
if ((!empty($this->group) && method_exists($this->group, $method)) or Str::startsWith($method, 'onGroup')) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Either works. Your version does the same, just a bit more expressive which might be a better. Possibly has better bc support with older PHP versions.

@stayallive stayallive changed the title Fix for PHP 8.0 Fixes for PHP 8.0 Nov 30, 2020
@stayallive stayallive merged commit 9c56e05 into formers:master Nov 30, 2020
@stayallive
Copy link
Contributor

Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants