Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
webbasics
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
webbasics
Commits
31fe1d5e
Commit
31fe1d5e
authored
Jul 14, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated some docs and a test.
parent
04252c05
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
5 deletions
+24
-5
autoloader.php
autoloader.php
+2
-3
base.php
base.php
+21
-1
router.php
router.php
+1
-0
tests/test_autoloader.php
tests/test_autoloader.php
+0
-1
No files found.
autoloader.php
View file @
31fe1d5e
...
...
@@ -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
...
...
base.php
View file @
31fe1d5e
...
...
@@ -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
*/
...
...
router.php
View file @
31fe1d5e
...
...
@@ -20,6 +20,7 @@ require_once 'base.php';
* </code>
*
* @package BasicWeb
* @todo Example
*/
class
Router
extends
Base
{
/**
...
...
tests/test_autoloader.php
View file @
31fe1d5e
...
...
@@ -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
());
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment