Doc #77789 [Opn->Ver]: Undocumented E_WARNINGs raised in invalid regexps

From: Date: Mon, 26 Jul 2021 13:58:27 +0000
Subject: Doc #77789 [Opn->Ver]: Undocumented E_WARNINGs raised in invalid regexps
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-18995@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77789&edit=1 ID: 77789 Updated by: cmb@php.net Reported by: beebware at gmail dot com Summary: Undocumented E_WARNINGs raised in invalid regexps -Status: Open +Status: Verified Type: Documentation Problem Package: *Regular Expressions PHP Version: 7.3.3 Block user comment: N Private report: N New Comment: Right, that should be documented, although I'd consider passing an invalid regex to these function a programming error. Previous Comments: ------------------------------------------------------------------------ [2019-03-24 11:00:42] beebware at gmail dot com Description: ------------ --- From manual page: https://php.net/function.preg-replace --- The documentation states: ``` Errors/Exceptions ¶ As of PHP 5.5.0 E_DEPRECATED level error is emitted when passing in the "\e" modifier. As of PHP 7.0.0 E_WARNING is emitted in this case and "\e" modifier has no effect. ``` However, E_WARNING s are raised if the regular expression is invalid. I feel that just adding a comment in the 'Errors/Exceptions' part of the documentation that 'E_WARNINGs will be raised if an error occurs. NULL will will be returned and preg_last_error will be populated.' will suffice, but ideally (and this would probably require a code change) a way of stopping the E_WARNINGSs being emitted would be the 'best solution'. Test script: --------------- https://3v4l.org/ULXiT <?php var_dump(preg_replace('/aodjsoidjas','','tester')); Expected result: ---------------- No E_WARNING raised, but NULL to be returned and preg_last_error to be populated. Actual result: -------------- E_WARNING is raised (not documented), but NULL to be returned and preg_last_error to be populated. ``` Warning: preg_replace(): No ending delimiter '/' found in /in/ULXiT on line 3 NULL ``` ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77789&edit=1

« previous php.doc.bugs (#18995) next »