Web lists-archives.com

Re: [PHP] [PHP7][Bug?] What is the difference between 'boolean' and 'bool'?




On Wed, 16 Dec 2015 12:51:39 -0800
David Harkness <david.h@xxxxxxxxxxxxxxxxx> wrote:
> On Wed, Dec 16, 2015 at 12:46 PM, Daniel Korner <
> daniel.korner@xxxxxxxxxxxxxx> wrote:
> 
> > But that doesn't seem to be the case, as "bool" behaves (in some cases)
> > totally
> > different than "boolean" (as a type).[2]  
> 
> 
> Can you post some code that demonstrates this? AFAIK they should be
> synonyms.
> 
> David

Ehh... I tried to avoid posting code via E-Mail (therefor the gist). But Yes I
can :) *copy past smallest example from the gist*

Code (example4):
	function bar(boolean $foo): boolean{return $foo;}
	var_dump(bar((bool)true));
Output:
	PHP Fatal error:  Uncaught TypeError: Argument 1 passed to bar() must
	be an
	instance of boolean, boolean given, called in ./example4.php:2
	Stack trace:
	#0 ./example4.php(3): bar(true)
	#1 {main}
  		thrown in ./example4.php on line 2


Code (example5):
	function bar(bool $foo): bool{return $foo;}
	var_dump(bar((boolean)true));
Output:
	bool(true)

Attachment: pgpjQmwXABdeK.pgp
Description: OpenPGP digital signature