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();