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

Error thrown in with usage of string in closure #16

Closed
bswatson opened this issue Apr 20, 2020 · 7 comments
Closed

Error thrown in with usage of string in closure #16

bswatson opened this issue Apr 20, 2020 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@bswatson
Copy link
Contributor

spl_autoload_register( function ( string $class ) {

[20-Apr-2020 15:51:12 UTC] PHP Catchable fatal error: Argument 1 passed to WP_CLI\Runner::Nexcess\LimitOrders{closure}() must be an instance of Nexcess\LimitOrders\string, string given in /chroot/home/aa5b74b2/ssldelay.watsonbot.com/html/wp-content/plugins/limit-orders/limit-orders.php on line 24

@bswatson bswatson added the bug Something isn't working label Apr 20, 2020
@stevegrunwell
Copy link
Contributor

Lemme guess, PHP 7.1 or older 🤦

@bswatson
Copy link
Contributor Author

That is correct. Seeing this issue on at least 7.3 and 7.4.

@bswatson
Copy link
Contributor Author

Actually, seeing this in PHP 7.0 as well.

@stevegrunwell
Copy link
Contributor

Hmm, perhaps this isn't as simple as I had thought; PHP added typehint support for the string scalar type back in PHP 7.0.0, so this shouldn't be a matter of PHP interpreting the "string" typehint as a class name.

Our autoloader also follows the FIG example of a PSR-4 autoloader pretty closely (though they forego typehinting). I'll rework the autoloader to explicitly cast to string rather than typehint, but could you please post a list of other plugins running in case there's a conflict with another autoloader?

@bswatson
Copy link
Contributor Author

I have only been able to replicate this when trying to install a plugin through the Nexcess Dashboard Installer.

stevegrunwell added a commit that referenced this issue Apr 20, 2020
Return as early as possible from the autoloader closure if we're not trying to access something in the `Nexcess\LimitOrders` namespace.

Additionally, remove the `string` type-hint from the closure, as it may be contributing to #16.
@stevegrunwell
Copy link
Contributor

Once 1.2.0 is tagged, let's make sure to retest this; everything in the codebase should be PHP 7.0+ compliant, so this may be a problem in the dashboard installer.

@stevegrunwell
Copy link
Contributor

Closing this, as we were able to sort out the issue (resolved in version 1.2.1 of the Nexcess Installer plugin).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants