Skip to content

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Dec 1, 2025

No description provided.

@theseer
Copy link
Owner

theseer commented Dec 1, 2025

There IS an autoloader in src/autoload.php ?

@theseer
Copy link
Owner

theseer commented Dec 1, 2025

Why?

@staabm
Copy link
Contributor Author

staabm commented Dec 1, 2025

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
Copy link
Owner

theseer commented Dec 1, 2025

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

@staabm
Copy link
Contributor Author

staabm commented Dec 1, 2025

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

its pretty non-standard for me :)

@staabm
Copy link
Contributor Author

staabm commented Dec 1, 2025

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

@staabm
Copy link
Contributor Author

staabm commented Dec 1, 2025

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

@staabm
Copy link
Contributor Author

staabm commented Dec 1, 2025

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
Copy link
Contributor Author

staabm commented Dec 1, 2025

@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
Copy link
Contributor Author

staabm commented Dec 1, 2025

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
Copy link
Owner

theseer commented Dec 1, 2025

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

@staabm
Copy link
Contributor Author

staabm commented Dec 1, 2025

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
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
Copy link
Owner

theseer commented Dec 2, 2025

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