1.2.268. Could Be Self¶
Mark arguments, return types and properties that can be set to self
. This applies only to methods.
This analysis works when typehints have already been configured.
<?php
class x {
// Accept a x object as input
function foo(x $b) : x {
// Returns a x object
return $b;
}
}
?>
1.2.268.1. Connex PHP features¶
1.2.268.1.1. Suggestions¶
Add self typehint to the code.
Add the literal class/type typehint to the code.
1.2.268.1.2. Specs¶
Short name |
Typehints/CouldBeSelf |
Rulesets |
|
Exakat since |
2.1.2 |
PHP Version |
All |
Severity |
Major |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Available in |