10up / wp_mock

WordPress API Mocking Framework
https://wp-mock.gitbook.io
Other
672 stars 70 forks source link

Ignore throws in function mocks #245

Closed unfulvio closed 2 months ago

unfulvio commented 2 months ago

Summary

I have noticed that in some circumstances the mocks contained in API/function-mocks.php could trigger false positives in static analyzers like PhpStan or just the IDE if using WP_Mock within a project. I think by removing the @throws solves this, although PhpStan will complain about it in this project. I suppose since these are just internal mocks we can safely ignore.

I did try using @noinspection tags but PhpStorm wasn't happy (whether specific to unhandled exceptions or not).

As for the strict type notations, same reason, externally it will reflect WP behavior (the alternative was to leave non-strict and rely only on phpdoc -- like WP does -- but then PhpStan would complain again... could swap that for a phpstan-ignore again, up to you)

Closes #248

Contributor checklist

Testing

Reviewer checklist

- [x] Code changes review - [ ] Documentation changes review - [x] Unit tests pass - [x] Static analysis passes
coveralls commented 2 months ago

Coverage Status

coverage: 66.445%. remained the same when pulling 10dcee68e9af683d9f03a4997f6fa5518ddd6ef4 on ignore-throws-in-function-mocks into 48b7f22934a4351e45e336f09263ee27fc9ddcbe on trunk.

coveralls commented 2 months ago

Coverage Status

coverage: 66.445%. remained the same when pulling 93465a80c6b2346f868ef2784fabf31f6b51646d on ignore-throws-in-function-mocks into 48b7f22934a4351e45e336f09263ee27fc9ddcbe on trunk.

coveralls commented 2 months ago

Coverage Status

coverage: 66.312% (-0.1%) from 66.445% when pulling d96aa5f8acfaa0f0a51a9547022331c6eba389b9 on ignore-throws-in-function-mocks into 48b7f22934a4351e45e336f09263ee27fc9ddcbe on trunk.