Hi,
before php 7 I used to have those rules:
<rule ref="Squiz.Commenting.FunctionComment.Missing"/>
<rule ref="Squiz.Commenting.FunctionComment.MissingParamTag"/>
<rule ref="Squiz.Commenting.FunctionComment.MissingParamName"/>
<rule ref="Squiz.Commenting.FunctionComment.ParamNameNoMatch"/>
<rule ref="Squiz.Commenting.FunctionComment.IncorrectTypeHint"/>
<rule ref="Squiz.Commenting.FunctionComment.MissingReturn"/>
to make sure that every function had its parameters and return type specified somewhere. now with php 7 I'd like to do specify the types directly without having to repeat that, eg:
// before:
/**
* @param string $bar
* @param Option $o
* @param int[] $ids
* @return string
*/
function foo($bar, Option $o, array $ids) {
// …
}
// after:
/**
* @param int[] $ids
*/
function foo(string $bar, Option $o, array $ids): string {
// …
}
So that's probably multiple sniffs, note that those should fail:
function foo($bar): string {
// $bar should be type hinted
}
/**
* @param int $bar
*/
function foo(string $bar): string {
// $bar: string does not include int
}
/**
* @param int[] $ids
*/
function foo($ids): string {
// $ids should be `array` type hinted
}
/**
* @return string[]
*/
function foo() {
// function return type should be type hinted `array`
}
function foo() {
// function return type should be type hinted
}
for that I propose those sniffs:
<rule ref="Generic.Function.MissingParamTypeHint"/>
<rule ref="Generic.Function.IncorrectParamTypeHint"/>
<rule ref="Generic.Function.MissingReturnTypeHint"/>
<rule ref="Generic.Function.IncorrectReturnTypeHint"/>
what do you think, would that be useful ?
Hi,
before php 7 I used to have those rules:
to make sure that every function had its parameters and return type specified somewhere. now with php 7 I'd like to do specify the types directly without having to repeat that, eg:
So that's probably multiple sniffs, note that those should fail:
for that I propose those sniffs:
what do you think, would that be useful ?