|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-01-29 08:44 UTC] aharvey@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 09 06:00:01 2025 UTC |
Description: ------------ If a class function returns a class constant or true and the result is checked with a switch, the switch does not enter the correct block. I expect $bResult should be converted to 1 if it is "true" but not to -1. Reproduce code: --------------- <?php class Foo { const ERR_ONE = -1; public function bar() { return true; } public function isErr() { return self::ERR_ONE; } } $oFoo = new Foo(); $bResult = $oFoo->bar(); switch ($bResult) { case Foo::ERR_ONE: "ERR_ONE: " . var_dump($bResult); break; default: echo "default"; break; } $bResult = $oFoo->isErr(); switch ($bResult) { case Foo::ERR_ONE: "ERR_ONE: " . var_dump($bResult); break; default: echo "default"; break; } Expected result: ---------------- Expected to get "default" and "ERR_ONE: int(-1)" Actual result: -------------- ERR_ONE: bool(true) ERR_ONE: int(-1)