refactor: PHPDocs in env()#9468
Conversation
neznaika0
left a comment
There was a problem hiding this comment.
We get rid of "mixed" wherever possible. array<int|string, mixed> is better.
paulbalandan
left a comment
There was a problem hiding this comment.
hey, can this be better suited if we use generics instead?
|
Do you mean like this? i think better --- a/system/Common.php
+++ b/system/Common.php
@@ -371,9 +371,11 @@ if (! function_exists('env')) {
* retrieving values set from the .env file for
* use in config files.
*
- * @param array<int|string, mixed>|bool|float|int|string|null $default
+ * @template T
*
- * @return array<int|string, mixed>|bool|float|int|string|null
+ * @param T|null $default
+ *
+ * @return T|null
*/
function env(string $key, $default = null)
{ |
|
I think you can drop the null part in the phpdocs: see https://phpstan.org/r/b764e608-6ea7-4edf-aa2d-5821cc80057b. But please try again with your examples. |
|
When i set default from my config property is passed. The problem is EDIT : Now all passed using |
|
@paulbalandan I'm not familiar with |
paulbalandan
left a comment
There was a problem hiding this comment.
Sorry, please disregard the generics idea. I tried tinkering it on the phpstan playground and I got no luck.
|
Local and runner already passed |
|
The thing is |
Description
default not sync with return
Checklist: