Zend Framework

Zend_Tool's public/index.php doesn't work with Zend_Application

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.8.0
  • Component/s: Zend_Application
  • Labels:
    None

Description

The index.php generated by Zend_Tool (trunk revision 15149) generates the following code:

$application->bootstrap()
            ->run();

Unfortunately, Zend_Application::bootstrap() is defined as:

public function bootstrap()
{
    $this->getBootstrap()->bootstrap();
}

Either Zend_Application::bootstrap() should return $this; or Zend_Tool should generate code like this:

$application->bootstrap()
$application->run();

Activity

Hide
Rob Allen added a comment -

Attached suggested patch:

Index: tests/Zend/Application/ApplicationTest.php
===================================================================
--- tests/Zend/Application/ApplicationTest.php	(revision 15149)
+++ tests/Zend/Application/ApplicationTest.php	(working copy)
@@ -319,6 +319,12 @@
         $application = new Zend_Application('testing', $config->toArray());
         $this->assertTrue($application->hasOption('foo'));
     }
+
+    public function testBootstrapReturnsTheZendAppplicationInstance()
+    {
+        $application = $this->application->bootstrap();
+        $this->assertEquals($application, $this->application);
+    }
 }
 
 if (PHPUnit_MAIN_METHOD == 'Zend_Application_ApplicationTest::main') {
Index: library/Zend/Application.php
===================================================================
--- library/Zend/Application.php	(revision 15149)
+++ library/Zend/Application.php	(working copy)
@@ -285,11 +285,12 @@
     /**
      * Bootstrap application
      * 
-     * @return void
+     * @return Zend_Application
      */
     public function bootstrap()
     {
         $this->getBootstrap()->bootstrap();
+        return $this;
     }
 
     /**
Show
Rob Allen added a comment - Attached suggested patch:
Index: tests/Zend/Application/ApplicationTest.php
===================================================================
--- tests/Zend/Application/ApplicationTest.php	(revision 15149)
+++ tests/Zend/Application/ApplicationTest.php	(working copy)
@@ -319,6 +319,12 @@
         $application = new Zend_Application('testing', $config->toArray());
         $this->assertTrue($application->hasOption('foo'));
     }
+
+    public function testBootstrapReturnsTheZendAppplicationInstance()
+    {
+        $application = $this->application->bootstrap();
+        $this->assertEquals($application, $this->application);
+    }
 }
 
 if (PHPUnit_MAIN_METHOD == 'Zend_Application_ApplicationTest::main') {
Index: library/Zend/Application.php
===================================================================
--- library/Zend/Application.php	(revision 15149)
+++ library/Zend/Application.php	(working copy)
@@ -285,11 +285,12 @@
     /**
      * Bootstrap application
      * 
-     * @return void
+     * @return Zend_Application
      */
     public function bootstrap()
     {
         $this->getBootstrap()->bootstrap();
+        return $this;
     }
 
     /**
Hide
Rob Allen added a comment -

Fixed by Mattthew in r15150 on trunk and r15151 on release-1.8

Show
Rob Allen added a comment - Fixed by Mattthew in r15150 on trunk and r15151 on release-1.8

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: