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

PHP Fatal error #36

Closed
kokamvd opened this issue Jan 20, 2022 · 1 comment · Fixed by #33 or #37
Closed

PHP Fatal error #36

kokamvd opened this issue Jan 20, 2022 · 1 comment · Fixed by #33 or #37
Labels
bug Something isn't working

Comments

@kokamvd
Copy link
Contributor

kokamvd commented Jan 20, 2022

NOTICE: PHP message: PHP Fatal error:  Uncaught Error: Class "WeStacks\TeleBot\Traits\get_class" not found in /var/www/vendor/westacks/telebot/src/Traits/HandlesUpdates.php:40

Laravel v8.80.0 (PHP v8.1.1)

Looks like this commit is wrong 76f9607

@punyflash
Copy link
Member

punyflash commented Jan 20, 2022

The PHP have a strange behavior for such syntax. Tested some stuff in sandbox and that's what I discovered:

PHP <= 7.4

<?php

$class = new (get_class(new Exception)));

Gives error:

Parse error: syntax error, unexpected '(' in test.php on line 4

Process exited with code 255.

However, it works for PHP => 8.0.

PHP 8.1

<?php

$class = new get_class(new Exception);

Gives error:

Fatal error: Uncaught Error: Class "get_class" not found in test.php:4
Stack trace:
#0 {main}
  thrown in /in/CPRRi on line 4

Process exited with code 255.

However, it works for PHP <= 8.0.

Fix

In version 2, the kernel object will be reworked, and the issue will be resolved by itself, but for now something like this will fix the issue:

$kernel = get_class($this->kernel);
$this->kernel = new $kernel;

Thanks for contribution!

@punyflash punyflash added the bug Something isn't working label Jan 20, 2022
This was linked to pull requests Jan 20, 2022
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

Successfully merging a pull request may close this issue.

2 participants