Skip to content

Conversation

nielsdos
Copy link
Member

No description provided.

} else if (zend_string_equals_literal(Z_STR_P(data), "SCRIPT_FILENAME")) {
PHAR_G(phar_SERVER_mung_list) |= PHAR_MUNG_SCRIPT_FILENAME;
} else {
zend_throw_exception_ex(phar_ce_PharException, 0, "Invalid value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME");
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this should be a ValueError as this is a programming error? Also specify the argument number of the array param

Copy link
Member

Choose a reason for hiding this comment

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

as well, above should have been a TypeError it seems.

Copy link
Member Author

Choose a reason for hiding this comment

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

phar is full of custom exceptions. Just looking at phar_object.c reveals several instances of BadMethodCallException for example which should ideally have been a ValueError [1], e.g. zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unknown compression type specified");.

[1] Of course, phar predates ValueError etc...

If we want to make proper use of Value/TypeError in phar we should do an entire pass over the extension so it all remains internally consistent, rather than doing it on a case per case basis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants