php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46494 no access to error when extended class
Submitted: 2008-11-05 10:58 UTC Modified: 2008-11-05 21:25 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: Contact at LinuxIntro dot com Assigned:
Status: Not a bug Package: MySQLi related
PHP Version: 5.2.6 OS: Fedora
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: Contact at LinuxIntro dot com
New email:
PHP Version: OS:

 

 [2008-11-05 10:58 UTC] Contact at LinuxIntro dot com
Description:
------------
I know that this is a 'no no', but i feel that the bug here was not bogus:
http://bugs.php.net/bug.php?id=37711

I disagree with the response. $this is used in the current class, whereas parent:: is used to access properties and methods of the parent class. errno and error are properties of the parent class, NOT of $this class. Using $this to access the property of parent:: is not inheritance, it is more closely related to symbiosis or polymorphism, or something. And besides, how is parent:: automatically giving $this new properties called errno and error? Shouldn't that only be done via a set/get type function? EX:

function GetErrno(){
    $this->errno=parent::errno;
}

function GetError(){
    $this->error=parent::error;
}

The fact that this is automatically available in the scope of $this is NOT inheritance, imho, it is a BUG.

Alex Grim


Reproduce code:
---------------
class dbMYSQL extends mysqli {
...
function __construct(
parent::__construct($args....);
echo parent::errno;
echo parent::error;
}
...
}



Expected result:
----------------
0
''

or some error and error message when error occurs

Actual result:
--------------
Fatal error: Undefined class constant 'errno'
Fatal error: Undefined class constant 'error'


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-05 21:25 UTC] johannes@php.net
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

parent:: is for accessing the base implementation of a overwritten method, such a thing doesn't exist with properties.

Even if this would be a bug (what it isn't) it won't be a MySQLi issue.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 22 01:01:29 2024 UTC