php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #35746 Comparison of scalars & non-scalars w/o typecast should generate an error
Submitted: 2005-12-20 16:05 UTC Modified: 2013-04-04 13:58 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: schapht at verizon dot net Assigned: nikic (profile)
Status: Closed Package: *General Issues
PHP Version: 5.1.1 OS: Mac OS 10.4.3
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: schapht at verizon dot net
New email:
PHP Version: OS:

 

 [2005-12-20 16:05 UTC] schapht at verizon dot net
Description:
------------
When developing I find that comparison of a scalar and non-scalar is often unintentional and usually indicates a mistake elsewhere in the program.

It would be nice if comparing scalars and non-scalars generated a low-priority error message.

Reproduce code:
---------------
<?php

class A {}

$a = new A;
$b = 3;

echo $a > $b;
?>

Expected result:
----------------
Notice: Comparison of scalar and non-scalar without a typecast. in test.php on line 8
1

Actual result:
--------------
1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-04-04 13:58 UTC] nikic@php.net
-Status: Open +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: nikic
 [2013-04-04 13:58 UTC] nikic@php.net
Not sure since when, but currently this is generating a "Object of class A could not be converted to int" notice => Closed :)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 16 18:01:31 2025 UTC