-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentry.php
More file actions
82 lines (64 loc) · 2.07 KB
/
Copy pathentry.php
File metadata and controls
82 lines (64 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
use PHPModules\Demo\Config::Loader;
use PHPModules\Demo\Config::Repository;
use PHPModules\Demo\Config::SupportedFormats;
require __DIR__ . "/vendor/autoload.php";
// Seed mock data (simulates filesystem + environment)
$GLOBALS['deepseek/config'] = [
'files' => [
'config.json' => json_encode([
'app_name' => 'Config Demo',
'debug' => true,
'database' => ['host' => 'localhost', 'port' => 5432],
]),
],
'env' => [
'APP_' => [
'APP_SECRET' => 's3cr3t',
'APP_MODE' => 'development',
],
],
];
echo "=== Config Module Demo ===\n\n";
// --- Public API ---
$loader = new Loader();
$loader->addFileSource('config.json', SupportedFormats::Json);
$loader->addEnvSource('APP_');
$config = $loader->load();
echo "Loaded config values:\n";
foreach ($config->all() as $key => $value) {
printf(" %s: %s\n", $key, is_array($value) ? json_encode($value) : $value);
}
// --- Boundary enforcement ---
echo "\n--- Boundary Tests ---\n\n";
echo "1. new Repository([]) — internal constructor:\n";
try {
new Repository([]);
echo " OK (unexpected)\n";
} catch (\Error $e) {
echo " DENIED: " . $e->getMessage() . "\n";
}
echo "2. new PHPModules\Demo\\Config::Merger() — internal class:\n";
try {
new \PHPModules\Demo\Config::Merger();
echo " OK (unexpected)\n";
} catch (\Error $e) {
echo " DENIED: " . $e->getMessage() . "\n";
}
echo "\n=== Demo Complete ===\n";
/*
project-deepseek $ ../php-src-cli entry.php
=== Config Module Demo ===
Loaded config values:
app_name: Config Demo
debug: 1
database: {"host":"localhost","port":5432}
APP_SECRET: s3cr3t
APP_MODE: development
--- Boundary Tests ---
1. new Repository([]) — internal constructor:
DENIED: Cannot instantiate class PHPModules\Demo\Config::Repository via internal constructor from outside its module
2. new PHPModules\Demo\Config::Merger() — internal class:
DENIED: Cannot access internal module member "PHPModules\Demo\Config::Merger" from outside its module
=== Demo Complete ===
*/