Re: [PHP] possible namespace bug?
On Thu, Jan 20, 2011 at 5:27 PM, David Harkness wrote: On Thu, Jan 20, 2011 at 4:26 PM, Tommy Pham wrote: Anyway, I found the problem: \N in use org\puremvc\php\patterns\observer\Notifier; AFAIK \n is only processed inside double-quoted strings and here-docs. The \N has no special meaning beyond a namespace separator and a capital N. My guess is the same as Adam's. Since I don't see how you declare INotification, I think it's getting confused when using namespaces. In the top part, PHP assumes the class must be in the org\puremvc\php\interfaces namespace whereas in SimpleCommand's declaration, INotification is assumed to be in the org\puremvc\php\patterns\command namespace. This causes their declarations to be mismatched. David Hi David, It was a CNP error from several files that's how the INotification got left out on the e-mail. You're right. I've must had a brain fart yesterday afternoon. Thanks, Tommy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] possible namespace bug?
Hi folks, I thought I try implementing namesapce on one the ported apps I did a while back but ran into a problem. First the code: //namespace org\puremvc\php\interfaces; interface ICommand { function execute(INotification $notification); } interface INotifier { function sendNotification($notificationName, $body = null, $type = null); } //-- --- //namespace org\puremvc\php\patterns\observer; //use org\puremvc\php\interfaces\INotifier; class Notifier implements INotifier { public function __construct() { echo __METHOD__; } public function sendNotification($notificationName, $body = null, $type = null) { } } //-- --- //namespace org\puremvc\php\patterns\command; //use org\puremvc\php\interfaces\ICommand; //use org\puremvc\php\interfaces\INotifier; //use org\puremvc\php\patterns\observer\Notifier; class SimpleCommand extends Notifier implements ICommand, INotifier { public function __construct() { parent::__construct(); echo ' - '; echo __METHOD__; } function execute(INotification $notification) { } } //-- --- //echo 'br/'; new \org\puremvc\php\patterns\observer\Notifier(); //echo 'br/'; new \org\puremvc\php\patterns\command\SimpleCommand(); The above works as expected without namespace. When I uncomment the lines namespace/use, I get this error: Fatal error: Declaration of org\puremvc\php\patterns\command\SimpleCommand::execute() must be compatible with that of org\puremvc\php\interfaces\ICommand::execute() on line 30. Line 30 is the class SimpleCommand declaration. Anyone having similar problems? My platform is PHP 5.3.5 VC9 NTS as FastCGI on Win08r2 x64. Thanks, Tommy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] possible namespace bug?
On Thu, Jan 20, 2011 at 5:33 PM, Tommy Pham tommy...@gmail.com wrote: Hi folks, I thought I try implementing namesapce on one the ported apps I did a while back but ran into a problem. First the code: //namespace org\puremvc\php\interfaces; interface ICommand { function execute(INotification $notification); } interface INotifier { function sendNotification($notificationName, $body = null, $type = null); } //-- --- //namespace org\puremvc\php\patterns\observer; //use org\puremvc\php\interfaces\INotifier; class Notifier implements INotifier { public function __construct() { echo __METHOD__; } public function sendNotification($notificationName, $body = null, $type = null) { } } //-- --- //namespace org\puremvc\php\patterns\command; //use org\puremvc\php\interfaces\ICommand; //use org\puremvc\php\interfaces\INotifier; //use org\puremvc\php\patterns\observer\Notifier; class SimpleCommand extends Notifier implements ICommand, INotifier { public function __construct() { parent::__construct(); echo ' - '; echo __METHOD__; } function execute(INotification $notification) { } } Where's the INotification namespace? If it's in org\puremvc\php\interfaces, you'll have to include it, too. I see you just included the whole set of interfaces in the top part of the example. Maybe you just omitted the code, but that could be the problem. Adam -- Nephtali: A simple, flexible, fast, and security-focused PHP framework http://nephtaliproject.com