-
-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Move bootstrapping function into a dedicated class (#1263)
- Loading branch information
Showing
4 changed files
with
56 additions
and
8 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
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the box project. | ||
* | ||
* (c) Kevin Herrera <[email protected]> | ||
* Théo Fidry <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace KevinGH\Box; | ||
|
||
use ErrorException; | ||
use Isolated\Symfony\Component\Finder\Finder as IsolatedFinder; | ||
use Symfony\Component\Finder\Finder as SymfonyFinder; | ||
use function class_alias; | ||
use function class_exists; | ||
use function error_reporting; | ||
use function set_error_handler; | ||
|
||
final class Bootstrap | ||
{ | ||
use NotInstantiable; | ||
|
||
/** | ||
* @private | ||
*/ | ||
public static function registerAliases(): void | ||
{ | ||
// Exposes the finder used by PHP-Scoper PHAR to allow its usage in the configuration file. | ||
if (false === class_exists(IsolatedFinder::class)) { | ||
class_alias(SymfonyFinder::class, IsolatedFinder::class); | ||
} | ||
} | ||
|
||
public static function registerErrorHandler(): void | ||
{ | ||
set_error_handler( | ||
static function (int $code, string $message, string $file = '', int $line = -1): void { | ||
if (error_reporting() & $code) { | ||
throw new ErrorException($message, 0, $code, $file, $line); | ||
} | ||
}, | ||
); | ||
} | ||
} |
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