Rev 52 | Rev 64 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 52 | Rev 57 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | <?php
|
1 | <?php
|
2 | 2 | ||
3 | namespace PointedEars\PHPX; |
3 | namespace PointedEars\PHPX; |
4 | 4 | ||
- | 5 | if (!defined('DIRECTORY_SEPARATOR')) |
|
- | 6 | {
|
|
- | 7 | define('DIRECTORY_SEPARATOR', '/'); |
|
- | 8 | }
|
|
- | 9 | ||
5 | function autoload ($class) |
10 | function autoload ($class) |
6 | {
|
11 | {
|
7 | if (\strpos($class, '..')) |
12 | if (\strpos($class, '..') !== false) |
8 | {
|
13 | {
|
9 | throw new \InvalidArgumentException( |
14 | throw new \InvalidArgumentException( |
10 | 'Refusing to load unsafe class ' . $class); |
15 | "Refusing to load unsafe class '{$class}'"); |
11 | }
|
16 | }
|
12 | 17 | ||
13 | require_once \preg_replace('#\\\#', '/', |
18 | require_once \str_replace('\\', DIRECTORY_SEPARATOR, |
- | 19 | \preg_replace( |
|
14 | \preg_replace('#^' . \preg_quote(__NAMESPACE__) .'#', __DIR__, $class) |
20 | '#^' . \preg_quote(__NAMESPACE__, '#') .'#', |
- | 21 | __DIR__,
|
|
- | 22 | $class
|
|
- | 23 | )
|
|
15 | ) . '.php'; |
24 | ) . '.php'; |
16 | }
|
25 | }
|
17 | 26 | ||
18 | \spl_autoload_register(__NAMESPACE__ . '\\autoload'); |
27 | \spl_autoload_register(__NAMESPACE__ . '\\autoload'); |
19 | 28 |