- 🇬🇧United Kingdom adamps
I like passing 'create' because it's much more informative to the reader than just TRUE.
What we can do is to add types to the function arguments. This would then force conversion to bool.
- 🇨🇭Switzerland berdir Switzerland
> What we can do is to add types to the function arguments. This would then force conversion to bool.
That's now how types work. Types don't convert automatically, that will give you a fatal error.
- 🇬🇧United Kingdom jonathanshaw Stroud, UK
I like passing 'create' because it's much more informative to the reader than just TRUE.
So let's used string or mixed in the interface, rather than violating our own interface. Someone swapping out the Subscriber class could get bitten if they believed what the interface said.
- Status changed to Needs review
over 1 year ago 6:13pm 2 August 2023 - last update
over 1 year ago 20 pass, 12 fail - 🇬🇧United Kingdom adamps
I realise it's a little strange that I pass strings like this for bool - I'm content to give it up. Here's a patch that adds types to SubscriberInterface - let's see what happens.
The last submitted patch, 6: simplenews.param-types.3260400-6.patch, failed testing. View results →
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.- last update
over 1 year ago 59 pass - 🇬🇧United Kingdom adamps
That's now how types work. Types don't convert automatically, that will give you a fatal error.
It seems there are some specific exceptions where types do convert automatically. See https://www.php.net/manual/en/language.types.type-juggling.php#language.....
In this context the value must be a value of the type. Two exceptions exist, the first one is: if the value is of type int and the declared type is float, then the integer is converted to a floating point number. The second one is: if the declared type is a scalar type, the value is convertable to a scalar type, and the coercive typing mode is active (the default), the value may be converted to an accepted scalar value. See below for a description of this behaviour.
- Status changed to Fixed
about 1 year ago 12:31pm 20 September 2023 Automatically closed - issue fixed for 2 weeks with no activity.
- Status changed to Fixed
about 1 year ago 4:07pm 17 November 2023 - 🇨🇭Switzerland berdir Switzerland
Follow-up: 🐛 Subscriber::loadByMail(): Argument #1 ($mail) must be of type string, null given Needs review