-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Financial functions more rationalization #1990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I wish I could figure out what it is that phpstan is complaining about
/**
* @param mixed $basis
*/
public static function validateBasis($basis): int
{
if (!is_numeric($basis)) {
throw new Exception(Functions::VALUE());
}
$basis = (int) $basis;
if (($basis < 0) || ($basis > 4)) {
throw new Exception(Functions::NAN());
}
return $basis;
} Input argument for TYpehint for So what exactly is phpstan's compaint? |
I have a wild guess about phpstan. If nothing else, it shouldn't take long to test. Your code includes calls to getDateValue, which phpstan doesn't object to, and calls to, among others, validateBasis, which it doesn't like. Here's the docBlock for getDateValue: /**
* getDateValue.
*
* @param mixed $dateValue
*
* @return float Excel date/time serial value
*/ And here's the docBlock for validateBasis: /**
* @param mixed $basis
*/ Is it possible that adding the equivalent of the first 2 lines in the getDateValue docBlock to the validateBasis docBlock will make the problem go away? It shouldn't matter, but it's easy to test. |
a1455ba
to
dbe1d2a
Compare
PHPStan is complaining that your code is perfect 😎 and that he cannot find the error that used to be there. I rebased your branch on master (without any modifications), then I double checked that all PHPStan errors started with "Ignored error pattern", and finally I ran That file can be edited either manually or automatically, like I did. In both cases we should be careful to only remove things, and never add anything, in order to (one day) reach zero error at PHPStan max level and delete the file entirely. You can read more about baseline over there: https://phpstan.org/user-guide/baseline |
As a side note, I bought a license for PHPStan Pro, it is absolutely not required, and it's not even a "game changer", but it's slightly more friendly to fix huge batch of issues. You might want to consider it, or not. For me the main reason was to support the developer, and I appreciate the slightly improved feedback loop (though it can be reproduced with CLI tools). |
And one last thing, I plan to refactor - public function getCell($pCoordinate, $createIfNotExists = true): ?Cell
+ public function getCell($pCoordinate): Cell |
…lization' into Financial-Functions-More-Rationalization
This is:
Checklist:
Why this change is needed?