Method chaining error
已回答
I posted a while back in https://youtrack.jetbrains.com/issue/WI-24761 some sample code where PHPStorm seems to loose track of the return type when doing method chaining. This issue was recently closed as non-reproducible so I updated to the latest version and tried it again only to discover the problem seems to still exist.
Maybe a separate issue needs to be opened for my code but it seemed fairly similar to that report so which is why I posted it there. I find the Youtrack system difficult to search for existing reports so I'm not sure if this exists already as another report or if a new one needs made.
请先登录再写评论。
The originally reported case isn't reproducible anymore:
Do you have another example?
Maybe it's an entirely separate error but it seemed related so I just attached it to that bug. There is a full sample code file and image showing the problem in that bug report.
interface AddressInterface {
public function getFirstname();
public function getLastname();
public function getAddress();
public function getCity();
public function getState();
public function getPostalCode();
public function getPhoneNumber();
}
class Address implements AddressInterface {
private $firstname;
private $lastname;
private $address;
private $city;
private $state;
private $postalCode;
private $phoneNumber;
public function __construct($firstname, $lastname, $address, $city, $state, $postalCode, $phone = ''){
$this
->setFirstname($firstname)
->setLastname($lastname)
->setAddress($address)
->setCity($city)
->setState($state)
->setPostalCode($postalCode)
->setPhoneNumber($phone)
;
}
public function setFirstname($firstname){
$this->firstname = $firstname;
return $this;
}
// ...
}
After a couple calls PHPStorm no longer recognizes the return type and complains about the method not existing.
https://youtrack.jetbrains.com/_persistent/Error.png?file=74-270496&c=true&rw=791&rh=195&u=1447917640855&c=true&rw=791&rh=195
@Kicken
It's more like https://youtrack.jetbrains.com/issue/WI-33097 to me
Yup, it would be better to add your example to above-mentioned report.