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

RobotAutoloader not load a interface #29

Open
Pok4 opened this issue Nov 6, 2023 · 8 comments
Open

RobotAutoloader not load a interface #29

Pok4 opened this issue Nov 6, 2023 · 8 comments

Comments

@Pok4
Copy link

Pok4 commented Nov 6, 2023

Version: Last

I see this error - stripe/stripe-php#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 ?

@dg
Copy link
Member

dg commented Nov 6, 2023

This is by design, RobotLoader only loads classes that are always defined and not just in a condition.

@Pok4
Copy link
Author

Pok4 commented Nov 6, 2023

Yes, i get it, but there is a workaround to load it ? Maybe with custom variable ?

@Pok4
Copy link
Author

Pok4 commented Nov 6, 2023

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.

@dg
Copy link
Member

dg commented Nov 6, 2023

I tried adding $topLevelOnly 3ccc6fd. Try dev-master pls.

@Pok4
Copy link
Author

Pok4 commented Nov 6, 2023

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...

@dg
Copy link
Member

dg commented Nov 6, 2023

Did you delete cache?

@Pok4
Copy link
Author

Pok4 commented Nov 6, 2023

Yes - 3 times.

@dg
Copy link
Member

dg commented Nov 6, 2023

Then I don't know what the problem is...

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

No branches or pull requests

2 participants