Bug #76964 [Opn->Nab]: Return type-hint actually cast types

From: Date: Tue, 02 Oct 2018 18:08:37 +0000
Subject: Bug #76964 [Opn->Nab]: Return type-hint actually cast types
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217372@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76964&edit=1 ID: 76964 Updated by: pmmaga@php.net Reported by: itay dot moav at email dot sitel dot org Summary: Return type-hint actually cast types -Status: Open +Status: Not a bug Type: Bug Package: *General Issues Operating System: centos7 PHP Version: 7.2.10 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php It would only fail if you use strict_types. You can find more info on http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration.strict Previous Comments: ------------------------------------------------------------------------ [2018-10-02 17:55:23] itay dot moav at email dot sitel dot org Description: ------------ The following code will return 1 I would expect it to fail class A{ static public function r():bool{ return 'ww'; } } Test script: --------------- class A{ static public function r():bool{ return 'ww'; } } var_dump(A::r()); Expected result: ---------------- I expect this call to fail with proper error message Actual result: -------------- casts the return value to 1 (int) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76964&edit=1

« previous php.bugs (#217372) next »