-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87170b1
commit 9cadee5
Showing
3 changed files
with
48 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/** | ||
* PSR-4 compliant autoloader. | ||
* | ||
* This will be removed when Composer supports PSR-4 natively. | ||
* | ||
* @param string $fqcn The fully-qualified class name. | ||
* | ||
* @return void | ||
* @link https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md | ||
* @link https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader-examples.md | ||
*/ | ||
spl_autoload_register(function ($fqcn) { | ||
$prefix = 'Jeremeamia\\SuperClosure\\'; | ||
$baseDir = __DIR__ . '/src/'; | ||
|
||
$prefixLength = strlen($prefix); | ||
if (strncmp($prefix, $fqcn, $prefixLength) !== 0) { | ||
// Class doesn't match prefix | ||
return; | ||
} | ||
|
||
$className = substr($fqcn, $prefixLength); | ||
$filePath = $baseDir . str_replace('\\', '/', $className) . '.php'; | ||
if (is_readable($filePath)) { | ||
require $filePath; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,22 @@ | ||
<?php | ||
|
||
date_default_timezone_set('America/Los_Angeles'); | ||
date_default_timezone_set('UTC'); | ||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
// Register another PSR-4-compliant autoloader for loading test classes | ||
spl_autoload_register(function ($fqcn) { | ||
$prefix = 'Jeremeamia\\SuperClosure\\Test\\'; | ||
$baseDir = __DIR__ . '/'; | ||
|
||
$prefixLength = strlen($prefix); | ||
if (strncmp($prefix, $fqcn, $prefixLength) !== 0) { | ||
// Class doesn't match prefix | ||
return; | ||
} | ||
|
||
$className = substr($fqcn, $prefixLength); | ||
$filePath = $baseDir . str_replace('\\', '/', $className) . '.php'; | ||
if (is_readable($filePath)) { | ||
require $filePath; | ||
} | ||
}); |
9cadee5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we just run
composer self-update
before running tests on travis?9cadee5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that's a good idea. I'll give that a shot.