Re: "strict_types" should be renamed "raise_type_error". WAS: About declare(strict_types = 1)
| From: | Matthew Leverton | Date: | Mon, 16 Mar 2015 20:34:21 +0000 |
| Subject: | Re: "strict_types" should be renamed "raise_type_error". WAS: About declare(strict_types = 1) | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-85088@lists.php.net to get a copy of this message | ||
On Mon, Mar 16, 2015 at 2:53 PM, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote:
> Hi all,
>
> I think this is important, but not many people realize the importance.
> Therefore I created this as a new thread at the last minutes of vote.
>
...
>
> "strict_mode" is just controlling errors, then it should be named as error
> controlling directive and raise E_WARNING/E_TYPE or whatever.
>
> Even if what its controlling is error that can be overridden by caller, yet
> calling it "strict_types" is not correct. Proper name would be something
> like "raise_type_error".
>
> Let's see how it looks if "strict_types" is renamed to
> "raise_type_error"
>
...
> <?php
> declare(raise_type_error = 1);
> require "lib.php";
> foo("123"); // will give an error
> ?>
>
I agree that the name doesn't by itself explain the feature, but how
could it possibly? You'd end up with something like:
declare(raise_type_errors_on_parameter_mismatches_when_calling_functions_from_this_file_regardless_of_where_the_functions_are_defined_and_what_the_setting_is_in_other_files=1);
I don't think your suggestion explains the feature any better than
strict_types. (Although the irony of using =1 instead of =true isn't
lost on me!)
--
Matthew Leverton