[php-src] PR #11991: Fix implode() function signature

From: Date: Thu, 17 Aug 2023 12:59:39 +0000
Subject: [php-src] PR #11991: Fix implode() function signature
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-23399@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/11991 Author: kamil-tekiela @kocsismate Please review this and tell me if we can do it like this. This function cannot take null as the second parameter. Allowing it to do so leads to a very confusing error message. ``` implode('', null); // implode(): Argument #1 ($pieces) must be of type array, string given ``` Looking at the documentation, there is no argument called $pieces. If someone passes a string as the first argument and null as the second, it's more likely that the second argument is the wrong one. In my opinion the stub should say that the second parameter is optional and it's an empty array by default. After reading arguments, we check if pieces is null anyway. This fixes all confusing error messages to reflect reality. FWIW, I just got this error in real life and was VERY confused. The real error was that the second argument was null when it should have been an array, but this error message didn't tell me that.

« previous php.git-pulls (#23399) next »