php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53800 namespace, interfaces and classes
Submitted: 2011-01-20 23:53 UTC Modified: 2011-01-21 01:21 UTC
From: tommyhp2 at gmail dot com Assigned:
Status: Closed Package: CGI/CLI related
PHP Version: 5.3.5 OS: Windows 2008 R2
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tommyhp2 at gmail dot com
New email:
PHP Version: OS:

 

 [2011-01-20 23:53 UTC] tommyhp2 at gmail dot com
Description:
------------
The script works as expected when not using namespace.  I get a fatal error on my "class SimpleCommand extends Notifier implements ICommand, INotifier" declaration.

Test script:
---------------
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();

Expected result:
----------------
org\puremvc\php\patterns\observer\Notifier::__construct
org\puremvc\php\patterns\observer\Notifier::__construct -> 
org\puremvc\php\patterns\command\SimpleCommand::__construct

Actual result:
--------------
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 21

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-21 01:21 UTC] tommyhp2 at gmail dot com
-Status: Open +Status: Closed
 [2011-01-21 01:21 UTC] tommyhp2 at gmail dot com
sorry ... found my problem.

use org\puremvc\php\patterns\observer\Notifier;

\N >.> perhaps this should be a request changing \ to / to prevent escaping?

Thanks for your time.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 22:01:27 2024 UTC