php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43141 Converting $this to int
Submitted: 2007-10-30 12:42 UTC Modified: 2007-10-30 16:52 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: felipensp at gmail dot com Assigned:
Status: Wont fix Package: Scripting Engine problem
PHP Version: 5.3CVS-2007-10-30 (snap) OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: felipensp at gmail dot com
New email:
PHP Version: OS:

 

 [2007-10-30 12:42 UTC] felipensp at gmail dot com
Description:
------------
When try converter $this to string, one Catchable fatal error occur.
$this to int, only Notice...

Reproduce code:
---------------
<?php
error_reporting(E_ALL);

class foo
{
  public $test = 'foo';

  public function __construct()
  {
      $this++; // don't convert
      ++$this; // don't convert

      //$this .= '';
      // Catchable fatal error: Object of class foo could not be converted to string    
      
      $this += 1;
      // Notice: Object of class foo could not be converted to int
      
      var_dump($this); //int(2)
      
      // $this->$this;
      // Odd... Notice: Undefined property:  foo::$2
      
      var_dump($this->test); // foo
      
      var_dump($this); // int(2)
  }
}

new foo;


Expected result:
----------------
Catchable fatal error: Object of class foo could not be converted to int

Actual result:
--------------
Notice: Object of class foo could not be converted to int in /home/felipe/public_html/bug.php on line 16
int(2)
string(3) "foo"
int(2)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-30 16:52 UTC] johannes@php.net
Yes, it's inconsistent but we won't change it (soon).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 19:01:28 2024 UTC