====== PHP RFC: Grouped ValueError Conversions for PHP 8.6 ====== * Version: 0.9 * Date: 2026-19-02 * Author: Muhammed Arshid KV, arshidkv12@gmail.com * Status: Under Discussion * Implementation: * [[https://github.com/php/php-src/pull/20971|Validate the option parameter in mysqli_options()]] * [[https://github.com/php/php-src/pull/21152|Validate the file permission mode in mkdir()]] * [[https://github.com/php/php-src/pull/21214|Validate the to parameter in copy()]] ===== Introduction ===== Many PHP internal functions currently return false when invalid argument values are passed. Modern PHP prefers throwing ValueError for invalid inputs. This RFC groups multiple similar changes into one proposal for PHP 8.6 to keep behavior consistent and simplify migration documentation. The following list provides a brief overview of the functionality for which invalid arguments are proposed to throw ValueError. Detailed explanations are provided in the Proposal section. * Validate the option parameter in mysqli_options() and throw a ValueError for invalid values. * Validate the file permission mode in mkdir() and throw a ValueError for invalid values. * Validate the file permission mode in chmod() and throw a ValueError for invalid values. * Validate the "to" parameter in copy() and throw a ValueError for invalid values. * Validate the "message_type" parameter in error_log() and throw a ValueError for invalid values. ===== Proposal ===== Each feature proposed for deprecation will be voted on separately and requires a 2/3 majority to pass. ==== Validate the option parameter in mysqli_options() and throw a ValueError for invalid values ==== * Author: Muhammed Arshid This proposal validates the option parameter of mysqli_options() and throws a ValueError when an invalid option is provided, instead of emitting a returning false. options(-1, 'invalid_option'); var_dump($value); // PHP ≤ 8.5: return false // PHP 8.6 (proposed): ValueError exception ?> Implementation PR: https://github.com/php/php-src/pull/20971 * Yes * No * Abstain ==== Validate the file permission mode in mkdir() and throw a ValueError for invalid values ==== * Author: Muhammed Arshid Throw a ValueError when mkdir() is called with an invalid file permission mode. getMessage(); // mkdir(): Argument #2 ($mode) must be between 0 and 0o7777 } // PHP ≤ 8.5: return false // PHP 8.6 (proposed): ValueError exception ?> * Yes * No * Abstain ==== Validate the file permission mode in chmod() and throw a ValueError for invalid values ==== * Author: Muhammed Arshid arshidkv12@gmail.com Throw a ValueError when chmod() is called with an invalid file permission mode. getMessage(); // chmod(): Argument #2 ($mode) must be between 0 and 0o7777 } // PHP ≤ 8.5: return false // PHP 8.6 (proposed): ValueError exception ?> * Yes * No * Abstain ==== Validate the to parameter in copy() and throw a ValueError for invalid values ==== Author: Muhammed Arshid arshidkv12@gmail.com Throw a ValueError when copy() is called with an invalid to parameter. getMessage(); // copy(): Argument #2 ($to) must be a non-empty valid path } // PHP ≤ 8.5: return false // PHP 8.6 (proposed): ValueError exception ?> * Yes * No * Abstain ==== Validate the "message_type" parameter in error_log() and throw a ValueError for invalid values ==== Author: Muhammed Arshid arshidkv12@gmail.com Throw a ValueError when error_log() is called with an invalid to parameter. getMessage(); // error_log(): Argument #2 ($message_type) must be an integer between 0 and 4 } ?> * Yes * No * Abstain ===== Backward Incompatible Changes ===== Code that relied on chmod() returning false for invalid mode values will now throw a ValueError. Example breakage: Fix: Impact expected to be low because: * Most code already checks return values * Invalid argument values are rare in correct programs ===== Proposed PHP Version(s) ===== Next PHP 8.x (target PHP 8.6). ===== RFC Impact ===== ==== To the Ecosystem ==== IDEs, static analyzers, and linters may update rules to detect possible ValueError throws. ==== To Existing Extensions ==== No ABI changes expected. Extensions may optionally adopt the same validation behavior. ==== To SAPIs ==== No impact. ===== Implementation ===== After the RFC is implemented, this section should contain: - the version(s) it was merged into: 8.6 - a link to the git commit(s) - a link to the PHP manual entry for the feature ===== References ===== Current discussion: https://externals.io/message/130090 ===== Rejected Features ===== None ===== Changelog ===== 1.0: Initial version under discussion 1.1: The "message_type" parameter in error_log added 1.2: Vote section added