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:
parent
970ea48b25
commit
4b9ea5472d
@ -680,7 +680,7 @@ class MethodAnalyzer extends FunctionLikeAnalyzer
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($guide_classlike_storage->user_defined
|
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
|
&& $implementer_method_storage->required_param_count > $guide_method_storage->required_param_count
|
||||||
) {
|
) {
|
||||||
if (IssueBuffer::accepts(
|
if (IssueBuffer::accepts(
|
||||||
|
@ -559,6 +559,17 @@ class MethodSignatureTest extends TestCase
|
|||||||
(new B)->foo(new stdClass);',
|
(new B)->foo(new stdClass);',
|
||||||
'error_message' => 'InvalidArgument'
|
'error_message' => 'InvalidArgument'
|
||||||
],
|
],
|
||||||
|
'interfaceHasFewerConstructorArgs' => [
|
||||||
|
'<?php
|
||||||
|
interface Foo {
|
||||||
|
public function __construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
class Bar implements Foo {
|
||||||
|
public function __construct(bool $foo) {}
|
||||||
|
}',
|
||||||
|
'error_message' => 'MethodSignatureMismatch',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user