Closed Toilal closed 5 years ago
The reason it is commented is because it was added after the 1.0 release, and would otherwise break existing implementations. It will be explicitly added in the 2.0 version.
I don't know if there is a way I can annotate the methods so that PHPStan stops complaining? Maybe adding a @param
would be enough, I'll have to experiment a bit.
Okay, so far the only solution I've found is to ignore the errors in your PHPStan config:
parameters:
ignoreErrors:
- '#Method AutoMapperPlus\\(Auto)?MapperInterface::map(Multiple)?\(\) invoked with 3 parameters, 2 required#'
I don't really like this solution because I'd rather fix it in the library itself. So unless anyone has a better idea I'm going to create a PHPStan extension with the above config and make it auto-installable with phpstan/extension-installer. Then I can add that as a dependency to the main library.
Thanks for the explanations, i'll just ignore the error in PHPStan at the moment.
I've provided the workaround as a separate package. See the explanation and usage instructions here.
Is there any reason for
$context
parameter to be commented in interfaces ?I'm using PHPStan and it raise an error when typing with
AutoMapperInterface
and trying to use context.https://github.com/mark-gerarts/automapper-plus/blob/88145c341c95277918636d21707626ab4f299230/src/AutoMapperInterface.php#L27 https://github.com/mark-gerarts/automapper-plus/blob/88145c341c95277918636d21707626ab4f299230/src/MapperInterface.php#L32 https://github.com/mark-gerarts/automapper-plus/blob/88145c341c95277918636d21707626ab4f299230/src/MapperInterface.php#L47