These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | require_once __DIR__ . '/vendor/autoload.php'; |
||
4 | |||
5 | // load the config for the application |
||
6 | $config_path = __DIR__ . '/config.json'; |
||
7 | |||
8 | $handle = @fopen($config_path, 'r'); |
||
9 | if ($handle === false) { |
||
10 | throw new RuntimeException("Could not load config"); |
||
11 | } |
||
12 | $config = fread($handle, filesize($config_path)); |
||
13 | fclose($handle); |
||
14 | |||
15 | $config = json_decode($config); |
||
16 | $last_json_error = json_last_error(); |
||
17 | if ($last_json_error !== JSON_ERROR_NONE) { |
||
18 | throw new RuntimeException("Could not parse config - JSON error detected"); |
||
19 | } |
||
20 | |||
21 | // timezones are fun |
||
22 | date_default_timezone_set('America/Phoenix'); |
||
23 | |||
24 | // configure the db connections holder |
||
25 | $db_connections = new Aura\Sql\ConnectionLocator(); |
||
26 | $db_connections->setDefault(function () use ($config) { |
||
27 | $connection = $config->database->slave; |
||
28 | return new Aura\Sql\ExtendedPdo( |
||
29 | "mysql:host={$connection->host}", |
||
30 | $connection->user, |
||
31 | $connection->password |
||
32 | ); |
||
33 | }); |
||
34 | $db_connections->setWrite('master', function () use ($config) { |
||
35 | $connection = $config->database->master; |
||
36 | return new Aura\Sql\ExtendedPdo( |
||
37 | "mysql:host={$connection->host}", |
||
38 | $connection->user, |
||
39 | $connection->password |
||
40 | ); |
||
41 | }); |
||
42 | $db_connections->setRead('slave', function () use ($config) { |
||
43 | $connection = $config->database->slave; |
||
44 | $pdo = new Aura\Sql\ExtendedPdo( |
||
45 | "mysql:host={$connection->host}", |
||
46 | $connection->user, |
||
47 | $connection->password |
||
48 | ); |
||
49 | |||
50 | $profiler = new Aura\Sql\Profiler(); |
||
51 | $profiler->setActive(true); |
||
52 | $pdo->setProfiler($profiler); |
||
53 | |||
54 | return $pdo; |
||
55 | }); |
||
56 | |||
57 | // setup the profiler |
||
58 | $console = new Particletree\Pqp\Console(); |
||
59 | $profiler = new Particletree\Pqp\PhpQuickProfiler(); |
||
60 | $profiler->setConsole($console); |
||
61 | |||
62 | // setup the service locator |
||
63 | $container = new Pimple\Container(); |
||
64 | $container['config'] = $config; |
||
65 | $container['db_connection_locator'] = $db_connections; |
||
66 | $container['console'] = $console; |
||
67 | $container['profiler'] = $profiler; |
||
68 | $container['default_timezone'] = new DateTimeZone('America/Phoenix'); |
||
69 | $container['mail'] = function ($c) { |
||
0 ignored issues
–
show
|
|||
70 | return new Jacobemerick\Archangel\Archangel(); |
||
71 | }; |
||
72 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.