Skip to content

Fix autoloading#41

Closed
staabm wants to merge 3 commits into
theseer:mainfrom
staabm:fix
Closed

Fix autoloading#41
staabm wants to merge 3 commits into
theseer:mainfrom
staabm:fix

Conversation

@staabm

@staabm staabm commented Dec 1, 2025

Copy link
Copy Markdown
Contributor

No description provided.

@theseer

theseer commented Dec 1, 2025

Copy link
Copy Markdown
Owner

There IS an autoloader in src/autoload.php ?

@theseer

theseer commented Dec 1, 2025

Copy link
Copy Markdown
Owner

Why?

@staabm

staabm commented Dec 1, 2025

Copy link
Copy Markdown
Contributor Author

I am not sure why it happens, but I think there is a autoloading problem (that we have multiple same named classes arround).

locally it works for me. but I can see these errors in CI now

@theseer

theseer commented Dec 1, 2025

Copy link
Copy Markdown
Owner

But we do not? PHPUnit prefixes the classes, there is only one ;-)

@staabm

staabm commented Dec 1, 2025

Copy link
Copy Markdown
Contributor Author

I need to lookup how this custom autoloader, the custom tool installer and the ant setup works.

its pretty non-standard for me :)

@staabm

staabm commented Dec 1, 2025

Copy link
Copy Markdown
Contributor Author

local debugging wise, it looks like the autoloader is not used at all for loading the tokenizer classes..

@staabm

staabm commented Dec 1, 2025

Copy link
Copy Markdown
Contributor Author

my guess is, that the test-suite is loading the XMLSerialize class from within PHPUnit instead of the ones in our src folder

@staabm

staabm commented Dec 1, 2025

Copy link
Copy Markdown
Contributor Author

see the CI output which proofs my point

➜ tokenizer git:(fix) ✗ tools/phpunit
PHPUnit 10.5.59 by Sebastian Bergmann and contributors.

Runtime: PHP 8.3.28
Configuration: /Users/m.staab/dvl/tokenizer/phpunit.xml

...................string(91) "phar:///Users/m.staab/.phive/phars/phpunit-10.5.59.phar/theseer-tokenizer/XMLSerializer.php"

@staabm

staabm commented Dec 1, 2025

Copy link
Copy Markdown
Contributor Author

@theseer I think the problem is, that PHPUnit 10.x started to use pre-loading for its classes and therefore in this current setup we cannot replace PHPUnit internal classes with our own

(or at least the relevant XMLSerializer class is loaded that early, that we cannot inject our own class)

//cc @sebastianbergmann

@staabm

staabm commented Dec 1, 2025

Copy link
Copy Markdown
Contributor Author

But we do not? PHPUnit prefixes the classes, there is only one ;-)

I just extracted the phpunit-10.5.59.phar phar using

php -r '$phar = new Phar("/Users/m.staab/.phive/phars/phpunit-10.5.59.phar"); $phar->extractTo("./directory");'

and that way I can see the XmlSerializer class is not prefixed:

<?php declare(strict_types = 1);
namespace TheSeer\Tokenizer;

use DOMDocument;

class XMLSerializer {

@theseer

theseer commented Dec 1, 2025

Copy link
Copy Markdown
Owner

But it should be scoped, shouldn't it? It's a third party dependency...

@staabm

staabm commented Dec 1, 2025

Copy link
Copy Markdown
Contributor Author

as far as I can tell in the PHPUnit 10.x release I did not find any file which is prefixed. either it doesn't work in the latest release or its something only happening on newer major versions.. I don't know.

I guess it should be prefixed/scoped - yes.

@sebastianbergmann

Copy link
Copy Markdown
Contributor

I guess it should be prefixed/scoped - yes.

At first glance it currently is not. PHP-Scoper is run in the build process, but the resulting PHAR does not seem to be scoped. I will look into this ASAP.

@theseer

theseer commented Dec 2, 2025

Copy link
Copy Markdown
Owner

As Autoloading is not the culprit, tracking the issue will continue in #40.

@theseer theseer closed this Dec 2, 2025
@staabm staabm deleted the fix branch December 2, 2025 08:14
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.

3 participants