[Bugfix] Return static from factory
@dragonmantank any chance you could find a time and review this? Thanks!
Hello, thanks for the PR.
What exactly is the reason for the change? While technically static doesn't cause confusion in things like PHPStorm, it does make it less clear what the factory returns.
The return type Cron\CronExpression is incorrect. As the class is not final, it is extensible. Therefore, when you extend it
final class MyOwnCronExpression extends \Cron\CronExpression
All static checks in IDE or other static analysis tool fail for
public function someOtherFcn(MyOwnCronExpression $myOwnCronExpression) {
...
}
someOtherFcn($myOwnCronExpression); // this thinks you are passing `\Cron\CronExpression` even though you're passing MyOwnCronExpression
// because it was created using `factory()` with incorrect typehint.
The proper definition would be
* @return CronExpression
*/
public static function factory($expression, FieldFactory $fieldFactory = null) : self
but php 7.0 is still supported here so it is not possible.
Hi @dragonmantank, the phpdocs are still incorrect. Can this be merged, please?
@dragonmantank :(
it does make it less clear what the factory returns.
That's just false, it makes it precisely clear what it returns.