laravel / pint

Laravel Pint is an opinionated PHP code style fixer for minimalists.

Home Page:https://laravel.com/docs/pint

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Default for nullable_type_declaration_for_default_null_value

otsch opened this issue · comments

After updating pint I noticed, that it changed a lot of method signatures like:

- public function foo(?string $arg = null): string
+ public function foo(string $arg = null): string

I later posted on Twitter, because I thought that's maybe not an ideal default. And I just got responses from @kocsismate and @Girgias (https://twitter.com/kocsismate90/status/1730711133042958637), saying that support for implicit nullability exists only for backwards compatibility reasons and that it will be deprecated and removed from PHP sooner or later. So, I would suggest changing the default in pint, introduced with #192.

Thanks, seems you already sent in a PR for it 👍

👋 Just chiming in as the nullable types RFC author: yes, implicit nullability was required for backward compatibility with PHP 5. Remember, this landed in PHP 7.1, so this was important at the time. It is not important now. I also suggest using the explicit version for any code which doesn't need PHP 5 compatibility. I wish I had put that recommendation in the RFC.

I also suggest using the explicit version for any code which doesn't need PHP 5 compatibility. I wish I had put that recommendation in the RFC.

As per @morrisonlevi's suggestion. I think a lot of people would prefer the explicity?

P.S.: I have already filed the implementation for deprecating the implicitly nullable parameter types: php/php-src#12959 the RFC is underway.