parsedown-extra icon indicating copy to clipboard operation
parsedown-extra copied to clipboard

ParsedownExtra.php and tests classes are declared as psr-0 in composer.json but are not compliant with psr-0

Open jleeothon opened this issue 5 years ago • 11 comments

The psr-0 field in composer.json is wrong since the ParsedownExtra class (and also the classes in test files) are not PSR-0-compliant e.g. the classes are not even namespaced.

Maybe it is simpler and more correct to declare them under classmap?

With the latest versions of Composer, this problem generates some warnings like:

Deprecation Notice: Class ParsedownExtraTest located in ./vendor/erusev/parsedown-extra/test/ParsedownExtraTest.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.10/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201

jleeothon avatar Aug 21 '20 09:08 jleeothon

+1

jadamec avatar Sep 14 '20 11:09 jadamec

+1

vogelor avatar Sep 22 '20 08:09 vogelor

Until this is fixed, I have excluded the parsedown-extra tests from my composer.json file by appending the tests folder from this package in exclude-from-classmap:-

"autoload": {
    "exclude-from-classmap": [
        "vendor/erusev/parsedown-extra/test/"
    ]
}

I am hoping this can aid other people in getting rid of this warning until the package maintainer resolves the issue.

Edit: For further information on this see the composer documentation https://getcomposer.org/doc/04-schema.md#exclude-files-from-classmaps

lerouse avatar Oct 14 '20 11:10 lerouse

With upcoming composer v2 this package will break on install, unless that workround keep working with composer v2.

robsontenorio avatar Oct 16 '20 18:10 robsontenorio

Screenshot 2020-10-19 at 09 35 08

@robsontenorio

I have tested this with the current preview build (2.0.0-RC2) and I did not see any problems with the autoloading. So I am pretty sure this should cover the release of v2.0. I will continue to relay any feedback/issues as I encounter them. At least this should let us use this package post 2.0 release (fingers crossed).

lerouse avatar Oct 19 '20 09:10 lerouse

@lerouse the package maintainer would accept a PR? As I can see it is about just moving test file to the right folder.

Edit: declare files and test namespaces according standard.

robsontenorio avatar Oct 19 '20 11:10 robsontenorio

I believe so, there is already a PR in https://github.com/erusev/parsedown-extra/pull/154 by @KentarouTakeda that would resolve this issue but the CI is failing on php v5.3 https://travis-ci.org/github/erusev/parsedown-extra/jobs/692841233

Which is using .gitattributes to ignore the test folder from the package (technically the better way to handle tests not being included in the package).

I am not sure if this will be fixed/merged at any point?

lerouse avatar Oct 19 '20 12:10 lerouse

Deprecation Notice: Class ParsedownExtraTest located in ./vendor/erusev/parsedown-extra/test/ParsedownExtraTest.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201

  1. Actually, what is the part that's non-compliant?
  2. test/TestParsedown.php was not flagged by composer 1.x
  3. Renaming ParsedownExtraTest.php to TestParsedownExtraTest.php made the error go away. Is this a possible fix?

bilogic avatar Nov 14 '20 09:11 bilogic

@bilogic I don't think PSR-0 says anything about not-namespaced classes; yet the classes here are supposed to be loaded through PSR-0 but they're not namespaced. Correct me if wrong.

jleeothon avatar Nov 19 '20 14:11 jleeothon

I made a MR to parsedown first, because parsedown suffers from a similar problem. If it were up to me, I would solve it first in parsedown, then in parsedown-extra.

https://github.com/erusev/parsedown/pull/794

However, my team and I were using this library only in a tiny use case, and now replaced it with different Commonmark parser.

I will leave this ticket open because it may be relevant for other people, but I might probably disengage from this conversation.

jleeothon avatar Nov 19 '20 14:11 jleeothon

@bilogic I cannot answer your question (2) but I assume that Composer 1.x was loading the class anyway with something like a classmap (i.e. you'd have to run composer dump-autoload every time if there were new or changed files in the vendor directory--(off topic) you probably don't care if this is a third-party library that you won't change yourself, but it is an inconvenience if it is your application code.

About question (3) I don't know, but like I mentioned, my team isn't using this library anymore now, so I won't keep an eye on this ticket.

jleeothon avatar Nov 19 '20 14:11 jleeothon