Doc #78163 [Csd]: preg_quote() documented as accepting null for $delimiter, which actually throws

From: Date: Mon, 17 Jun 2019 11:32:50 +0000
Subject: Doc #78163 [Csd]: preg_quote() documented as accepting null for $delimiter, which actually throws
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-16760@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78163&edit=1 ID: 78163 Updated by: nikic@php.net Reported by: sp at fp dot de Summary: preg_quote() documented as accepting null for $delimiter, which actually throws Status: Closed Type: Documentation Problem Package: PCRE related PHP Version: 7.3.6 Assigned To: cmb Block user comment: N Private report: N New Comment: Fixed in php-src in https://github.com/php/php-src/commit/03db04c3aba03fd55c94c9d834a6c151e351cfc5. I'd recommend reverting the docs change for clarity. "\0" is a convenient value for internal use, but not a good choice for a user-facing default. Previous Comments: ------------------------------------------------------------------------ [2019-06-14 16:15:18] salathe@php.net Automatic comment on behalf of cmb Revision: http://git.php.net/?p=doc/en.git;a=commit;h=8a69739e04cbd1ad962d32609bc961c153572590 Log: Fix #78163: preg_quote() documented as accepting null for $delimiter, which actually throws ------------------------------------------------------------------------ [2019-06-14 16:11:19] cmb@php.net Automatic comment from SVN on behalf of cmb Revision: http://svn.php.net/viewvc/?view=revision&revision=347600 Log: Fix #78163: preg_quote() documented as accepting null for $delimiter, which actually throws ------------------------------------------------------------------------ [2019-06-14 15:33:43] requinix@php.net Per the source, the actual default value is "\0" (which is always quoted anyways). ------------------------------------------------------------------------ [2019-06-14 15:29:53] sp at fp dot de Description: ------------ Referring to Nikitas post: https://www.mail-archive.com/internals@lists.php.net/msg98043.html > If you see something that is documented as =null, but does not behave the > same when null is passed, please do report a bug. preg_quote() seems to fall under that category: https://www.php.net/manual/en/function.preg-quote.php It is documented as: preg_quote ( string $str [, string $delimiter = NULL ] ) : string But actually passing NULL as second argument throws TypeError with strict_types=1: "Fatal error: Uncaught TypeError: preg_quote() expects parameter 2 to be string, null given" Test script: --------------- https://3v4l.org/ufjFF ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78163&edit=1

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