Skip to content

Default assert.exception to 1 #5925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 3, 2020
Merged

Conversation

morrisonlevi
Copy link
Contributor

@morrisonlevi morrisonlevi commented Aug 2, 2020

As discussed on the mailing list, this changes the default of assert.exception from 0 to 1, meaning exceptions will now throw by default. To restore the old value set assert.exception=0 in an INI file.

I opted to leave existing tests as written and instead just changed the --INI-- section to have the old value.

@@ -77,7 +77,7 @@ PHP_INI_BEGIN()
STD_PHP_INI_BOOLEAN("assert.bail", "0", PHP_INI_ALL, OnUpdateBool, bail, zend_assert_globals, assert_globals)
STD_PHP_INI_BOOLEAN("assert.warning", "1", PHP_INI_ALL, OnUpdateBool, warning, zend_assert_globals, assert_globals)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we also set warning=0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think not. Exception takes priority over warning, so it doesn't issue a warning and then throw; it only throws. This way reverting to PHP < 8 behavior is only assert.exception=0.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems pretty odd from a documentation perspective to have assert.warning=1 without actually enabling warnings. Ideally this would have been assert.mode=exception or so, because really only one of assert.bail, assert.exception and assert.warning makes sense at a time. But given things as they are, I would set it to zero.

@nikic nikic added this to the PHP 8.0 milestone Aug 2, 2020
@GrahamCampbell
Copy link
Contributor

GrahamCampbell commented Aug 2, 2020

Doesn't this change need to go through the RFC process?

EDIT: It looks like something related was started here, but never completed.

@kallesommernielsen
Copy link

@GrahamCampbell, there was no object on internals so no

@GrahamCampbell
Copy link
Contributor

Isn't that what the purpose of the RFC system is to establish?

@morrisonlevi
Copy link
Contributor Author

@GrahamCampbell Do you have a specific concern about the change itself?

@GrahamCampbell
Copy link
Contributor

I think discussion over the default value assert.warning is perhaps needed. The RFC process is usually good at teasing out all the fine details, since lots of expert (in different areas) eyes see it.

@morrisonlevi
Copy link
Contributor Author

morrisonlevi commented Aug 3, 2020

IMO we should leave it as 1 or On; this way reverting to the previous behavior is just toggling assert.exception to 0.

This area needs overhauled but nobody cared to do it in time for PHP 8.0. For example, assert_options should get formally deprecated or removed (has been discouraged in documentation for all of PHP 7) and many of these settings don't make sense to me.

@kallesommernielsen
Copy link

kallesommernielsen commented Aug 3, 2020

@GrahamCampbell well yes and no, but not everything is going through the rfc system if there is a consensus like there was with this. It is all very subjective to a case by case basis.

Edit: If we go with the RFC process for the warning part here, then that part will not make it for 8.0, something I would argue that is related to this.

If your argument for using the RFC issue is that more expert eyes see it, then perhaps those expert eyes should be reading internals actual in the first place and I put their concern there, as it’s meant for.

Copy link
Member

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I don't care particularly strongly about the assert.warning part. This LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants