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

Update composer.json #164

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update composer.json #164

wants to merge 1 commit into from

Conversation

wuwx
Copy link

@wuwx wuwx commented Mar 14, 2021

fix composer with warning:

Class ParsedownExtraTest located in ./vendor/erusev/parsedown-extra/test/ParsedownExtraTest.php does not comply with psr-0 autoloading standard. Skipping.

@LazyTechwork
Copy link

@erusev We need this merge!

@erusev
Copy link
Owner

erusev commented Apr 19, 2021

Thanks for the PR.

How can I reproduce the issue? When I do composer require erusev/parsedown-extra, I get no warning; I'm on composer 2.0.12.

@Wiejeben
Copy link

Wiejeben commented Jul 29, 2021

It happens specifically on composer dumpautoload:

$ composer --version   
Composer version 2.1.5 2021-07-23 10:35:47

$ composer dumpautoload   
Generating optimized autoload files
Class ParsedownExtraTest located in ./vendor/erusev/parsedown-extra/test/ParsedownExtraTest.php does not comply with psr-0 autoloading standard. Skipping.

I believe its because the test classes don't have namespaces.

#156
#162

@daftspunk
Copy link

@erusev

This occurs specifically with the composer optimizer. You can replicate this by generating the autoloader with the optimize flag set -o

composer dump-autoload -o

Should output

Class ParsedownExtraTest located in ~/vendor/erusev/parsedown-extra\test\ParsedownExtraTest.php does not comply with psr-0 autoloading standard. Skipping.

Hope this helps

@erusev
Copy link
Owner

erusev commented Oct 25, 2021

Can anyone explain why the same issue doesn't occur with Parsedown, which also uses psr-0? Would help me understand the problem. Thanks!

@cebe
Copy link

cebe commented Nov 24, 2021

the warning is about ParsedownExtraTest not ParsedownExtra, so the change is not related to the warning message.

@daftspunk
Copy link

@erusev

I believe PSR is wanting ParsedownTest to be in the namespace test since it resides in a directory of that name.

\test\ParsedownTest 

Most other libraries will place the source files in the src directory and then instruct PSR to look inside there. That way the tests and other materials are kept out of the way.

So basically,

  1. create a src/ directory
  2. move Parsedown.php inside src/
  3. update composer.json to find the source file in there, eg:
"psr-0": {"Parsedown": "src"}

I haven't tested this, but it is the theoretical fix. I hope this helps.

@cebe
Copy link

cebe commented Nov 25, 2021

@daftspunk this has nothing to do with Parsedown or ParsedownExtra class.

To fix this, namespaces of the classes in tests/ directory could be adjusted to use another autoloading strategy, e.g. putting them into a test\ namespace.

@erusev
Copy link
Owner

erusev commented Nov 30, 2021

I still don't understand why the same issue doesn't occur with Parsedown, and now I have one more question, perhaps it's related:

Why does composer require erusev/parsedown-extra add dev files to the vendor folder, including:tests/, .travis.yml, phpunit.xml.dist? This doesn't happen for parsedown (composer require erusev/parsedown). What's different in parsedown-extra?

@daftspunk
Copy link

Hey @erusev. Me again. I note that in both repos you are implementing the use of .gitattributes which are being instructed to ignore the test/ folder.

This will have an interesting effect, via composer:

  • if you install the "source" version of a package, the test/ folder will be included
  • if you install the "dist" version of a package, the test/ folder won't be delivered, this is because the zip/tarball is made using git directives

This is likely why you are seeing inconsistent outcomes with equivalent packages.

@erusev
Copy link
Owner

erusev commented Dec 6, 2021

Hey @daftspunk thanks for sharing your thoughts, but I still don't understand it.

In an empty folder, run composer require erusev/parsedown-extra and you get both parsedown and parsedown-extra in vendor/. One of them (parsedown-extra) has a test/ folder and the other one (parsedown) doesn't.

Why is that?

@daftspunk
Copy link

@erusev

That's because the latest tagged version of parsedown-extra (v0.8.1) does not contain the .gitattributes file. See here: https://github.com/erusev/parsedown-extra/tree/91ac3ff98f0cea243bdccc688df43810f044dcef

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.

6 participants