1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Fix #1117 - enforce argument counts on interface __constructors

This commit is contained in:
Matthew Brown 2018-12-12 22:35:27 -05:00
parent 970ea48b25
commit 4b9ea5472d
2 changed files with 12 additions and 1 deletions

View File

@ -680,7 +680,7 @@ class MethodAnalyzer extends FunctionLikeAnalyzer
}
if ($guide_classlike_storage->user_defined
&& $implementer_method_storage->cased_name !== '__construct'
&& ($guide_classlike_storage->is_interface || $implementer_method_storage->cased_name !== '__construct')
&& $implementer_method_storage->required_param_count > $guide_method_storage->required_param_count
) {
if (IssueBuffer::accepts(

View File

@ -559,6 +559,17 @@ class MethodSignatureTest extends TestCase
(new B)->foo(new stdClass);',
'error_message' => 'InvalidArgument'
],
'interfaceHasFewerConstructorArgs' => [
'<?php
interface Foo {
public function __construct();
}
class Bar implements Foo {
public function __construct(bool $foo) {}
}',
'error_message' => 'MethodSignatureMismatch',
],
];
}
}