Skip to content

Commit

Permalink
Add parameter-dependent psalm return type hint to temporal accessors
Browse files Browse the repository at this point in the history
Please refer to the Psalm documentation for conditional types[^0] for
more information. Although the docs specify that template parameters are
required, the reference-a-variable shorthand for templates also work,
see the [example].

Usually this project seems to prefer `@phpstan-`-prefixes, but this
construct is currently not available to PHPstan[^1].

[^0]: https://psalm.dev/docs/annotating_code/type_syntax/conditional_types/
[^1]: phpstan/phpstan#3853
[example]: https://psalm.dev/r/11cdedd7b3
  • Loading branch information
nederdirk authored and mringler committed Mar 9, 2021
1 parent 6446fad commit 3a9de61
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Propel/Generator/Builder/Om/ObjectBuilder.php
Expand Up @@ -894,6 +894,8 @@ public function addTemporalAccessorComment(&$script, Column $column)
* @return string|{$dateTimeClass}{$orNull} Formatted date/time value as string or $dateTimeClass object (if format is NULL), NULL if column is NULL" . ($handleMysqlDate ? ', and 0 if column value is ' . $mysqlInvalidDateString : '') . "
*
* @throws PropelException - if unable to parse/validate the date/time value.
*
* @psalm-return (\$format is null ? {$dateTimeClass}{$orNull} : string{$orNull})
*/";
}

Expand Down

0 comments on commit 3a9de61

Please sign in to comment.