From d37237c274e08f3686a324320a9c1445e6d55191 Mon Sep 17 00:00:00 2001 From: Chris Boden Date: Tue, 3 Jan 2012 12:22:02 -0700 Subject: [PATCH 1/2] AppInterface Method Removal Removed the construct AppInterface requirement in the construct to let applications branch out easier. Each application can now specify its own dependancies rather than trying to rabbit hole apps. --- lib/Ratchet/Application/ApplicationInterface.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/Ratchet/Application/ApplicationInterface.php b/lib/Ratchet/Application/ApplicationInterface.php index 4c0c919..6d964cb 100644 --- a/lib/Ratchet/Application/ApplicationInterface.php +++ b/lib/Ratchet/Application/ApplicationInterface.php @@ -7,12 +7,6 @@ use Ratchet\Resource\Connection; * It impelemtns the decorator and command pattern to build an application stack */ interface ApplicationInterface { - /** - * Decorator pattern - * @param Ratchet\ApplicationInterface Application to wrap in protocol - */ - public function __construct(ApplicationInterface $app = null); - /** * When a new connection is opened it will be passed to this method * @param Ratchet\Resource\Connection The socket/connection that just connected to your application From ed3cfc16da8d1712f53dd44a4fdc66ffe59bb342 Mon Sep 17 00:00:00 2001 From: Chris Boden Date: Wed, 4 Jan 2012 11:22:42 -0700 Subject: [PATCH 2/2] Loosened Dependencies Removed construct dependency from ApplicationInterface - changing full decorator to changeable stack. --- lib/Ratchet/Application/Server/App.php | 6 +----- lib/Ratchet/Application/WebSocket/App.php | 6 +----- lib/Ratchet/Application/WebSocket/WebSocketAppInterface.php | 2 +- tests/Ratchet/Tests/Application/Server/AppTest.php | 5 ----- 4 files changed, 3 insertions(+), 16 deletions(-) diff --git a/lib/Ratchet/Application/Server/App.php b/lib/Ratchet/Application/Server/App.php index 5964f39..8eb8fb0 100644 --- a/lib/Ratchet/Application/Server/App.php +++ b/lib/Ratchet/Application/Server/App.php @@ -41,11 +41,7 @@ class App implements ApplicationInterface { */ protected $_run = true; - public function __construct(ApplicationInterface $application = null) { - if (null === $application) { - throw new \UnexpectedValueException("Server requires an application to run off of"); - } - + public function __construct(ApplicationInterface $application) { $this->_app = $application; } diff --git a/lib/Ratchet/Application/WebSocket/App.php b/lib/Ratchet/Application/WebSocket/App.php index 362039c..c0454e4 100644 --- a/lib/Ratchet/Application/WebSocket/App.php +++ b/lib/Ratchet/Application/WebSocket/App.php @@ -41,11 +41,7 @@ class App implements ApplicationInterface, ConfiguratorInterface { protected $_mask_payload = false; - public function __construct(ApplicationInterface $app = null) { - if (null === $app) { - throw new \UnexpectedValueException("WebSocket requires an application to run"); - } - + public function __construct(ApplicationInterface $app) { $this->_app = $app; $this->_factory = new Factory; } diff --git a/lib/Ratchet/Application/WebSocket/WebSocketAppInterface.php b/lib/Ratchet/Application/WebSocket/WebSocketAppInterface.php index f78ca6c..642a625 100644 --- a/lib/Ratchet/Application/WebSocket/WebSocketAppInterface.php +++ b/lib/Ratchet/Application/WebSocket/WebSocketAppInterface.php @@ -12,7 +12,7 @@ interface WebSocketAppInterface extends ApplicationInterface { * Currently instead of this, I'm setting header in the Connection object passed around...not sure which I like more * @param string */ - function setHeaders($headers); + //function setHeaders($headers); /** * @return string diff --git a/tests/Ratchet/Tests/Application/Server/AppTest.php b/tests/Ratchet/Tests/Application/Server/AppTest.php index a9e96a6..4e3aed6 100644 --- a/tests/Ratchet/Tests/Application/Server/AppTest.php +++ b/tests/Ratchet/Tests/Application/Server/AppTest.php @@ -36,11 +36,6 @@ class AppTest extends \PHPUnit_Framework_TestCase { return array_pop($connections); } - public function testDoNotAllowStacklessServer() { - $this->setExpectedException('UnexpectedValueException'); - new ServerApp; - } - public function testOnOpenPassesClonedSocket() { $this->_server->run($this->_catalyst); $master = $this->getMasterConnection();