At the moment there is a mess in the code. How do you want to test code like:
$entityType = \go\core\orm\EntityType::findById($this->entityTypeId);
$className = $entityType->getClassName();
You cant actually use if (!$entityType) {...} because the return type is bool and entityType could be also true. Perhaps all functions returning something byId, by should return ?stratic. Sure you can create hint to fool phpstan but then you would hide real error. For example
|
public function setFromEntity(string $entityName) { |
|
$e = EntityType::findByName($entityName); |
|
$this->fromEntity = $e->getName(); |
|
$this->fromEntityTypeId = $e->getId(); |
would raise the exception to calling getName on bool
Sometimes phpstan is the hell but it really uncover real errors in the code.
I can help you with that but if I am not wrong my last PR with hints went to trash, so I dont want waste my time with sometime you dont want, need or merge. Please let me know.
At the moment there is a mess in the code. How do you want to test code like:
You cant actually use if (!$entityType) {...} because the return type is bool and entityType could be also true. Perhaps all functions returning something byId, by should return ?stratic. Sure you can create hint to fool phpstan but then you would hide real error. For example
groupoffice/www/go/core/model/Link.php
Lines 127 to 130 in 49b238c
Sometimes phpstan is the hell but it really uncover real errors in the code.
I can help you with that but if I am not wrong my last PR with hints went to trash, so I dont want waste my time with sometime you dont want, need or merge. Please let me know.