Skip to content

Commit

Permalink
Merge pull request #21 from weirdan/upgrade-psalm-interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
weirdan authored Jun 26, 2021
2 parents 0b5f55a + db1010b commit 992e041
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 25 deletions.
31 changes: 8 additions & 23 deletions Hooks/MockReturnTypeUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,20 @@
namespace Psalm\MockeryPlugin\Hooks;

use PhpParser;
use Psalm\Codebase;
use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\FileManipulation;
use Psalm\StatementsSource;
use Psalm\Plugin\EventHandler\AfterMethodCallAnalysisInterface;
use Psalm\Plugin\EventHandler\Event\AfterMethodCallAnalysisEvent;
use Psalm\Type;
use Psalm\Plugin\Hook;

class MockReturnTypeUpdater implements Hook\AfterMethodCallAnalysisInterface
class MockReturnTypeUpdater implements AfterMethodCallAnalysisInterface
{
/**
* Called after an expression has been checked
*
* @param PhpParser\Node\Expr $expr
* @param Context $context
* @param string[] $suppressed_issues
* @param FileManipulation[] $file_replacements
*/
public static function afterMethodCallAnalysis(
PhpParser\Node\Expr $expr,
string $method_id,
string $appearing_method_id,
string $declaring_method_id,
Context $context,
StatementsSource $statements_source,
Codebase $codebase,
array &$file_replacements = [],
Type\Union &$return_type_candidate = null
): void {
public static function afterMethodCallAnalysis(AfterMethodCallAnalysisEvent $event): void
{
$return_type_candidate = $event->getReturnTypeCandidate();
$expr = $event->getExpr();
$method_id = $event->getMethodId();
if ($return_type_candidate && $method_id === 'Mockery::mock' && isset($expr->args[0])) {
$first_arg = $expr->args[0]->value;

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"require": {
"mockery/mockery": "^0.9 || ^1.0",
"vimeo/psalm": "^4.0"
"vimeo/psalm": "^4.5"
},
"require-dev": {
"codeception/codeception": "^4.0.3",
Expand Down
6 changes: 5 additions & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
<file>stubs</file>

<!-- inherit rules from: -->
<rule ref="PSR12"/>
<rule ref="PSR12">

<!-- conflicts with PSR-12 -->
<exclude name="PSR2.ControlStructures.ControlStructureSpacing.SpacingAfterOpenBrace" />
</rule>

<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<rule ref="Generic.Files.ByteOrderMark"/>
Expand Down

0 comments on commit 992e041

Please sign in to comment.