Re: [PHP-DEV] Proposal to run all tests with and without strict_types enabled
2018-02-12 18:05 GMT-03:00 Rowan Collins: > > I think adding this to the language would be very controversial, because > it opens up the ability to undermine the "caller decides" concept of the > two scalar type modes. People on this list have openly said that they would > like to force users to call their library from strict mode, and others > (myself included) would rather that wasn't possible. On the other hand, > there were a handful of cases suggested where such an indicator would be > useful to *emulate* the two modes in functions with more complex signatures. The current beharviour makes sense to me, if the caller don't know the concept of strict types he must not be forced to handle it. I don't know such examples where would be useful the callee emulate both signatures, can you provide some? Something like correctly cast to the correct type? That can make sense. But restrict the caller doesn't seems very valuable. For testing purposes, it would presumably be enough for run-tests.php > itself to expose whether the strict types override was in effect, which > would sidestep the wider issue. > Expose only through `run-tests.php` is safer for sure, it will not be highlighted like other constants because `zend_highlight.c` wasn't modified but whatever, it's only for tests. -- Atenciosamente, Pedro Lacerda
Re: [PHP-DEV] Proposal to run all tests with and without strict_types enabled
On 12 February 2018 05:50:56 GMT+00:00, Pedro Lacerdawrote: >Besides testing, may or may not be valuable expose a `__STRICT_TYPES__` >constant. I think adding this to the language would be very controversial, because it opens up the ability to undermine the "caller decides" concept of the two scalar type modes. People on this list have openly said that they would like to force users to call their library from strict mode, and others (myself included) would rather that wasn't possible. On the other hand, there were a handful of cases suggested where such an indicator would be useful to *emulate* the two modes in functions with more complex signatures. For testing purposes, it would presumably be enough for run-tests.php itself to expose whether the strict types override was in effect, which would sidestep the wider issue. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Proposal to run all tests with and without strict_types enabled
> > 2018-02-11 20:34 GMT-03:00 Christoph M. Becker: >> >>> Umm, I wonder whether a magic constant (say, `__STRICT_TYPES__`) would >>> be more appropriate. >> >> Implement `__STRICT_TYPES__` was a breeze, very hackable codebase. A magic constant indeed sounds more appropriate. Hi Stanislav, 2018-02-12 2:18 GMT-03:00 Stanislav Malyshev : > I am not sure what would be the advantage of this. Beyond testing > strict_types functionality itself (which of course should have its own > unit tests), the tests that test standard functioning of any function > would either supply correct arguments and then strict_types would be > irrelevant (provided it works as supposed to, which is tested by its own > tests) or provide incorrect arguments, and then strict_type tests should > be different from regular ones since the errors would be different, so > we'd have to write separate tests. > So it's a lot less useful than what I thought. > The only class of errors that could be found this way would be if we > somehow made such a mistake in defining the arguments of certain > function that strict_type version of it doesn't work but regular version > works fine. Which I guess is possible but does it worth the effort to > convert all tests? Not sure. > But it's still useful, I just fixed a bug exactly about it. Given that there is very few tests that use strict_types, to "convert" all tests with `run-test -t` is not too hard. Anyway all tests other than for incorrect arguments should run correctly with `-t`, so it may be a default for testing. The problem than is to know wich tests mus be runned without it. https://github.com/php/php-src/commit/fddd7e38bd01bc6dbc473166dd6f92 e9f81a6eab Besides testing, may or may not be valuable expose a `__STRICT_TYPES__` constant. https://github.com/php/php-src/compare/master... pslacerda:experimental/strict_testing?diff=split -- Atenciosamente, Pedro Lacerda
Re: [PHP-DEV] Proposal to run all tests with and without strict_types enabled
Hi! > My proposal is to run all tests with and without strict_types, skipping if > necessary, and increasing the code coverage. Depending of you overral > reception I'll create an RFC for it. I am not sure what would be the advantage of this. Beyond testing strict_types functionality itself (which of course should have its own unit tests), the tests that test standard functioning of any function would either supply correct arguments and then strict_types would be irrelevant (provided it works as supposed to, which is tested by its own tests) or provide incorrect arguments, and then strict_type tests should be different from regular ones since the errors would be different, so we'd have to write separate tests. The only class of errors that could be found this way would be if we somehow made such a mistake in defining the arguments of certain function that strict_type version of it doesn't work but regular version works fine. Which I guess is possible but does it worth the effort to convert all tests? Not sure. -- Stas Malyshev smalys...@gmail.com -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php