coenjacobs / mozart

Developers tool for WordPress plugins: Wraps all your projects dependencies in your own namespace, in order to prevent conflicts with other plugins loading the same dependencies in different versions.
https://coenjacobs.me/projects/mozart/
MIT License
427 stars 53 forks source link

Fix all PHPStan Level 4 problems #110

Closed szepeviktor closed 3 years ago

szepeviktor commented 3 years ago
 ------ ---------------------------------------------------------------------------------------------
  Line   Mover.php
 ------ ---------------------------------------------------------------------------------------------
  73     Access to an undefined property CoenJacobs\Mozart\Composer\Autoload\Autoloader::$namespace.
 ------ ---------------------------------------------------------------------------------------------

 ------ ---------------------------------------------------------------------------------------------------
  Line   Replace/NamespaceReplacer.php
 ------ ---------------------------------------------------------------------------------------------------
  22     Call to an undefined method CoenJacobs\Mozart\Composer\Autoload\Autoloader::getSearchNamespace().
 ------ ---------------------------------------------------------------------------------------------------

These interface-things are the 2 remaining ones. Please use @phpstan.

szepeviktor commented 3 years ago

💡 The fun begins on Level 5.

coenjacobs commented 3 years ago

Thank you @szepeviktor, I have merged this with the latest master branch as I have today introduced Psalm (via #112) in our CI chain. This is merely a personal preference, as I think PHPStan and Psalm basically come down to the same principle.

As it turns out, Psalm found an issue with one of your changes and I don't know why the tests are failing. Will have to investigate a little bit. Might have to do with the fact that Psalm already changed some parts of the code that you also did and the changes might not add up any longer. Will have a look soon, but if you can have a look and update based on my merge commit, please let me know.

szepeviktor commented 3 years ago

Okay. I leave it up to you as Psalm has an unsustainable origin and I dug deep into PHPStan.

szepeviktor commented 3 years ago

Actually I've spent hundreds of hours advocating PHPStan...

szepeviktor commented 3 years ago

Regarding

src/Composer/Autoload/NamespaceAutoloader.php#L29 $this->paths with declared type 'array<array-key, string>' cannot be assigned type 'non-empty-array<array-key, array<array-key, mixed>|string>'

autoload can be many different thing https://getcomposer.org/doc/04-schema.md#autoload not just strings.

coenjacobs commented 3 years ago

@szepeviktor Care to elaborate on this statement?

Psalm has an unsustainable origin

I'm not saying that Psalm is perfect, it's just a tool to run static analysis. If there are any real issues with Psalm, that I'm obviously not aware of, I'm open to changing. But I need some more motivation on that, other than just your word. So some links on the topic, or an educated opinion are very much appreciated.

szepeviktor commented 3 years ago