php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43703 Signature compatibility check broken for namespaces
Submitted: 2007-12-29 10:52 UTC Modified: 2008-01-09 07:58 UTC
From: sebastian@php.net Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.3CVS-2007-12-29 (CVS) OS: Irrelevant
Private report: No CVE-ID: None
 [2007-12-29 10:52 UTC] sebastian@php.net
Description:
------------
When a namespaced class extends an namespaced abstract class, the signature compatiblity check breaks.

Reproduce code:
---------------
test.php
<?php
require 'joinpoint.php';
require 'pointcut.php';
require 'read.php';

joinpoint.php
<?php
namespace GAP;

class JoinPoint
{
}

pointcut.php
<?php
namespace GAP;

abstract class Pointcut
{
    abstract public function evaluate(JoinPoint $joinPoint);
}

read.php
<?php
namespace GAP::Pointcut::Attribute;

use GAP::Joinpoint;
use GAP::Pointcut;

class Read extends Pointcut
{
    public function evaluate(JoinPoint $joinPoint)
    {
    }
}

Expected result:
----------------
No syntax error.

Actual result:
--------------
Fatal error: Declaration of GAP::Pointcut::Attribute::Read::evaluate() must be compatible with that of GAP::Pointcut::evaluate() in /home/sb/read.php on line 12

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-05 10:07 UTC] sebastian@php.net
I think the issue lies in the following code in zend_compile.c:

if (fe->common.type == ZEND_USER_FUNCTION &&
    strchr(proto->common.arg_info[i].class_name, ':') == NULL &&
    (colon = zend_memrchr(fe->common.arg_info[i].class_name, ':', fe->common.arg_info[i].class_name_len)) != NULL &&
    strcmp(colon+1, proto->common.arg_info[i].class_name) == 0) {
	efree((char*)fe->common.arg_info[i].class_name);
	fe->common.arg_info[i].class_name = estrndup(proto->common.arg_info[i].class_name, proto->common.arg_info[i].class_name_len);
	fe->common.arg_info[i].class_name_len = proto->common.arg_info[i].class_name_len;
} else {
	return 0;
}
 [2008-01-09 07:58 UTC] dmitry@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 07:01:29 2024 UTC