php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62411 Allow calling of overloaded define()-method
Submitted: 2012-06-25 19:27 UTC Modified: 2012-07-18 09:14 UTC
From: lstrojny@php.net Assigned: pdezwart (profile)
Status: Closed Package: amqp (PECL)
PHP Version: 5.3.14 OS:
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: lstrojny@php.net
New email:
PHP Version: OS:

 

 [2012-06-25 19:27 UTC] lstrojny@php.net
Description:
------------
The attached patch allows extending AMQPExchange and AMQPQueue for testing 
purposes. Unit testing frameworks like PHPUnit allow mocking of objects often by 
generating a child class to the mocked class and overloading each method. As 
overloading declare() in userland is not possible (due to "T_DECLARE" being a 
lexer token by itself) it is necessary for those frameworks to allow calling the 
declare()-method without segfaults. The attached patch will make declare() fail 
non-fatal and return null if the AMQPExchange/AMQPQueue object has not properly 
been initialized. Without this patch unit testing PECL amqp dependent classes is 
nearly impossible.

Test script:
---------------
<?php
class FakeExchange extends AMQPExchange
{
   public function __construct()
   {}
}

$exchange = new FakeExchange();

$exchange->declare();


Patches

amqp-declare-initialization (last revision 2012-06-25 19:28 UTC by lars at strojny dot net)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-07-18 09:14 UTC] pdezwart@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: pdezwart
 [2012-07-18 09:14 UTC] pdezwart@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php

Fixed in 1.0.4. Thanks for the help!
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 15 23:01:33 2025 UTC