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

Autoloader pollution when optimizing #100

Closed
roelofr opened this issue Apr 17, 2020 · 0 comments · Fixed by #101
Closed

Autoloader pollution when optimizing #100

roelofr opened this issue Apr 17, 2020 · 0 comments · Fixed by #101

Comments

@roelofr
Copy link
Contributor

roelofr commented Apr 17, 2020

The composer file is configured to always autoload all tests, even when installed as a dependency of projects (where these tests aren't used).

This results in the following classmap when optimizing the autloader:

return array(
    'Html2Text\\BasicTest' => $baseDir . '/test/BasicTest.php',
    'Html2Text\\BlockquoteTest' => $baseDir . '/test/BlockquoteTest.php',
    'Html2Text\\ConstructorTest' => $baseDir . '/test/ConstructorTest.php',
    'Html2Text\\DefinitionListTest' => $baseDir . '/test/DefinitionListTest.php',
    'Html2Text\\DelTest' => $baseDir . '/test/DelTest.php',
    'Html2Text\\Html2Text' => $baseDir . '/src/Html2Text.php',
    'Html2Text\\HtmlCharsTest' => $baseDir . '/test/HtmlCharsTest.php',
    'Html2Text\\ImageTest' => $baseDir . '/test/ImageTest.php',
    'Html2Text\\InsTest' => $baseDir . '/test/InsTest.php',
    'Html2Text\\LinkTest' => $baseDir . '/test/LinkTest.php',
    'Html2Text\\ListTest' => $baseDir . '/test/ListTest.php',
    'Html2Text\\PreTest' => $baseDir . '/test/PreTest.php',
    'Html2Text\\PrintTest' => $baseDir . '/test/PrintTest.php',
    'Html2Text\\SearchReplaceTest' => $baseDir . '/test/SearchReplaceTest.php',
    'Html2Text\\SpanTest' => $baseDir . '/test/SpanTest.php',
    'Html2Text\\StrToUpperTest' => $baseDir . '/test/StrToUpperTest.php',
    'Html2Text\\TableTest' => $baseDir . '/test/TableTest.php',
);

When we split the tests into autoload-dev and the actual code file in autoload, we cut out 16 of the 17 classes:

return array(
    'Html2Text\\Html2Text' => $baseDir . '/src/Html2Text.php',
);

The difference in code changes is small:

     "autoload": {
-        "psr-4": { "Html2Text\\": ["src/", "test/"] }
+        "psr-4": { "Html2Text\\": "src/" }
+    },
+    "autoload-dev": {
+        "psr-4": { "Html2Text\\": "test/" }
     },
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 a pull request may close this issue.

1 participant