robot-loader
robot-loader copied to clipboard
RobotAutoloader not load a interface
Version: Last
I see this error - https://github.com/stripe/stripe-php/issues/1601 in my stripe api. I write there and i write here :) The error is because autoloader not load a exception interface. I open the cache and i see only one interface:
'Stripe\\Exception\\OAuth\\ExceptionInterface' =>
array (
0 => 'C:\\xampp2\\htdocs\\ext\\pok4\\shop\\stripe\\lib\\Exception\\OAuth\\ExceptionInterface.php',
1 => 1696003164,
),
in the bottom of the cache i see this:
'C:\\xampp2\\htdocs\\ext\\pok4\\shop\\stripe\\lib\\Exception\\ExceptionInterface.php' => 1696003164,
maybe this is the problem - this is not load in the above clasess...
The content of this file is
<?php
namespace Stripe\Exception;
// TODO: remove this check once we drop support for PHP 5
if (\interface_exists(\Throwable::class, false)) {
/**
* The base interface for all Stripe exceptions.
*/
interface ExceptionInterface extends \Throwable
{
}
} else {
/**
* The base interface for all Stripe exceptions.
*/
// phpcs:disable PSR1.Classes.ClassDeclaration.MultipleClasses
interface ExceptionInterface
{
}
// phpcs:enable
}
Do you have any ideas how to load this in robotautoloader ?
This is by design, RobotLoader only loads classes that are always defined and not just in a condition.
Yes, i get it, but there is a workaround to load it ? Maybe with custom variable ?
When i change the content of the file to:
<?php
namespace Stripe\Exception;
interface ExceptionInterface
{
}
everything is fine and worked correctly... I'm on PHP 8.1. Maybe the other part with if is not needed... The autoloader is loaded the file OK.
I tried adding $topLevelOnly 3ccc6fd3143827bf1cd0bc739854a7d8da88e43f. Try dev-master pls.
No, not working.. I update with dev master and delete the cache, but in the new cache doesnt find the class.. Only in the bottom:
'C:\\xampp2\\htdocs\\ext\\pok4\\shop\\stripe\\lib\\Exception\\ExceptionInterface.php' => 1699278834,
Now i try to add $loader->topLevelOnly = true; but without success...
Did you delete cache?
Yes - 3 times.
Then I don't know what the problem is...