Эх сурвалжийг харах

Updated some docs and a test.

Taddeus Kroes 13 жил өмнө
parent
commit
31fe1d5e6d
4 өөрчлөгдсөн 24 нэмэгдсэн , 5 устгасан
  1. 2 3
      autoloader.php
  2. 21 1
      base.php
  3. 1 0
      router.php
  4. 0 1
      tests/test_autoloader.php

+ 2 - 3
autoloader.php

@@ -35,8 +35,7 @@ require_once 'base.php';
  * $baz = new Foo\Bar\Baz();  // Includes 'classes/foo/bar/baz.php'
  * </code>
  * 
- * Multiple autoloaders can be registered at the same time. Be sure to disable
- * exceptions on the previously added loaders!
+ * Multiple autoloaders can be registered at the same time:
  * <code>
  * <code>
  * File structure:
@@ -45,7 +44,7 @@ require_once 'base.php';
  * other_classes/
  *   | bar.php  // Contains class 'Bar'
  * </code>
- * Autoloader::create('classes', false)->register();
+ * Autoloader::create('classes')->register();
  * Autoloader::create('other_classes')->register();
  * $foo = new Foo();  // Includes 'classes/foo.php'
  * $bar = new Bar();  // Includes 'other_classes/bar.php', since 'classes/bar.php' does not exist

+ 21 - 1
base.php

@@ -15,7 +15,27 @@ require_once 'logger.php';
  * Base class for instantiable classes in the BasicWeb package.
  * 
  * The base class defines a static 'create' method that acts as a chainable
- * shortcut for the class constructor.
+ * shortcut for the class constructor:
+ * <code>
+ * class Foo extends Base {
+ *     function __contruct($bar, $baz) {
+ *         $this->bar = bar;
+ *         $this->baz = baz;
+ *     }
+ * }
+ * 
+ * $foo = Foo::create('bar', 'baz');
+ * // is equivalent to:
+ * $foo = new Foo('bar', 'baz');
+ * </code>
+ * 
+ * The advantage of the 'create' constructor is that is allows chaining:
+ * <code>
+ * Foo::create('bar', 'baz')->method();
+ * // as opposed to:
+ * $foo = new Foo('bar', 'baz');
+ * $foo->method();
+ * </code>
  * 
  * @package BasicWeb
  */

+ 1 - 0
router.php

@@ -20,6 +20,7 @@ require_once 'base.php';
  * </code>
  * 
  * @package BasicWeb
+ * @todo Example
  */
 class Router extends Base {
 	/**

+ 0 - 1
tests/test_autoloader.php

@@ -147,7 +147,6 @@ class AutoloaderTest extends PHPUnit_Framework_TestCase {
 		$second_loader = new Autoloader(PATH.'second');
 		$this->autoloader->register();
 		$second_loader->register(true);  // Prepend so that the second loader attemps to load Bar first
-		$second_loader->set_throw_errors(false);
 		$this->assertInstanceOf('Foo', new FooBaz());
 	}
 }