php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64077 Use of self keyword causing error
Submitted: 2013-01-25 20:53 UTC Modified: 2013-02-14 14:45 UTC
From: iceman2g2 at gmail dot com Assigned:
Status: Closed Package: Class/Object related
PHP Version: Irrelevant 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: iceman2g2 at gmail dot com
New email:
PHP Version: OS:

 

 [2013-01-25 20:53 UTC] iceman2g2 at gmail dot com
Description:
------------
PHP Version: 5.3.17
Server API: CGI/FastCGI

I'm using the self keyword to call a method that's defined in an abstract class. 
The call to the method itself is being made within the abstract class. The 
method is both private and static.

Here's a definition of the method:
private static function _executeCallback($sequence, $event, array $param = 
array(), Dhonki_Model 
$object = NULL)

This is the snippet of code that calls the method:
if (isset(self::$_event_callback[$model]['find']['after']) || 
isset(self::$_event_callback[__CLASS__]['find']['after'])) {
			self::_executeCallback('after', 'find', $param, 
$object);
		}

The problem comes with the use of:
self::_executeCallback('after', 'find', $param, $object);

To fix the error I use the code:
Dhonki_Model::_executeCallback('after', 'find', $param, $object);



I don't know if this is an error related to something I'm doing or if it's a 
bug. Again this same code works on several other servers, and in fact works 
several other places in the class.

Clayton

Expected result:
----------------
I expected self::_executeCallback and Dhonki_Model::_executeCallback to be 
functionally equivalent. In fact they seem to be functionally equivalent on 
several other servers using this code. The also seem to be equivalent elsewhere in 
the same abstract class that use the self::_executeCallback.

Actual result:
--------------
Unable to autoload `t6exla` class or interface.

I'm not sure where the t6exla is coming from as the name of my class is 
Dhonki_Model.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-01-26 11:57 UTC] cataphract@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2013-01-26 11:57 UTC] cataphract@php.net
-Status: Open +Status: Feedback
 [2013-02-14 14:45 UTC] iceman2g2 at gmail dot com
-Status: Feedback +Status: Closed
 [2013-02-14 14:45 UTC] iceman2g2 at gmail dot com
This issue has been tracked down. It seems the issue revolved around calling a 
method that 
wasn't declared as static in a static manner.

So a method defined as: 
public function getById($flight)

Was changed to:
public static function getById($flight)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 04:01:30 2024 UTC