@@ -16,7 +16,7 @@ |
||
| 16 | 16 | * |
| 17 | 17 | * @param Query $query |
| 18 | 18 | */ |
| 19 | - public function __invoke(array|null $query = null): ResourceObject; |
|
| 19 | + public function __invoke(array | null $query = null): ResourceObject; |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * Set query |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
| 44 | 44 | |
| 45 | 45 | // Filter out framework internal calls to focus on user code |
| 46 | - $filtered = array_filter($backtrace, static function (array $frame): bool { |
|
| 47 | - if (! isset($frame['file'])) { |
|
| 46 | + $filtered = array_filter($backtrace, static function(array $frame): bool { |
|
| 47 | + if (!isset($frame['file'])) { |
|
| 48 | 48 | return false; |
| 49 | 49 | } |
| 50 | 50 | |
@@ -54,19 +54,19 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | // Skip vendor files except user application |
| 57 | - if (str_contains($frame['file'], '/vendor/') && ! str_contains($frame['file'], '/tests/')) { |
|
| 57 | + if (str_contains($frame['file'], '/vendor/') && !str_contains($frame['file'], '/tests/')) { |
|
| 58 | 58 | return false; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // Skip PHPUnit test framework files |
| 62 | - return ! str_contains($frame['file'], '/phpunit/'); |
|
| 62 | + return !str_contains($frame['file'], '/phpunit/'); |
|
| 63 | 63 | }); |
| 64 | 64 | |
| 65 | 65 | // Reset array keys and limit results |
| 66 | 66 | $result = array_slice(array_values($filtered), 0, $limit); |
| 67 | 67 | |
| 68 | 68 | // Clean up the frames to only include relevant information |
| 69 | - return array_map(static function (array $frame): array { |
|
| 69 | + return array_map(static function(array $frame): array { |
|
| 70 | 70 | $clean = ['function' => $frame['function']]; |
| 71 | 71 | |
| 72 | 72 | if (isset($frame['file'])) { |
@@ -46,6 +46,6 @@ |
||
| 46 | 46 | $crc = crc32($this->exceptionAsString); |
| 47 | 47 | $crcHex = dechex($crc & 0xFFFFFFFF); // Ensure positive hex value |
| 48 | 48 | |
| 49 | - return 'e-bear-resource-' . $crcHex; |
|
| 49 | + return 'e-bear-resource-'.$crcHex; |
|
| 50 | 50 | } |
| 51 | 51 | } |
@@ -66,7 +66,7 @@ |
||
| 66 | 66 | $crc = crc32($this->exceptionAsString); |
| 67 | 67 | $crcHex = dechex($crc & 0xFFFFFFFF); // Ensure positive hex value |
| 68 | 68 | |
| 69 | - return 'e-bear-resource-' . $crcHex; |
|
| 69 | + return 'e-bear-resource-'.$crcHex; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** @return array<string, mixed> */ |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | public static function start(): self |
| 38 | 38 | { |
| 39 | - if (! extension_loaded('xdebug') || ! function_exists('xdebug_start_trace')) { |
|
| 39 | + if (!extension_loaded('xdebug') || !function_exists('xdebug_start_trace')) { |
|
| 40 | 40 | return new self(); // @codeCoverageIgnore |
| 41 | 41 | } |
| 42 | 42 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $envMode = getenv('XDEBUG_MODE'); |
| 45 | 45 | $iniMode = ini_get('xdebug.mode'); |
| 46 | 46 | $xdebugMode = $envMode !== false ? $envMode : ($iniMode !== false ? $iniMode : ''); |
| 47 | - if (! str_contains($xdebugMode, 'trace')) { |
|
| 47 | + if (!str_contains($xdebugMode, 'trace')) { |
|
| 48 | 48 | return new self(); // @codeCoverageIgnore |
| 49 | 49 | } |
| 50 | 50 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | $outputDir = sys_get_temp_dir(); // @codeCoverageIgnore |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - $traceFilePrefix = rtrim($outputDir, '/') . '/' . $instance->traceId; |
|
| 66 | + $traceFilePrefix = rtrim($outputDir, '/').'/'.$instance->traceId; |
|
| 67 | 67 | xdebug_start_trace($traceFilePrefix); // @codeCoverageIgnore |
| 68 | 68 | |
| 69 | 69 | // Note: Return value is void, trace may fail silently if already started elsewhere |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | public function stop(): self |
| 74 | 74 | { |
| 75 | - if (! $this->canStopTrace()) { |
|
| 75 | + if (!$this->canStopTrace()) { |
|
| 76 | 76 | return new self(); // @codeCoverageIgnore |
| 77 | 77 | } |
| 78 | 78 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | private function canStopTrace(): bool |
| 83 | 83 | { |
| 84 | - if (! function_exists('xdebug_stop_trace')) { |
|
| 84 | + if (!function_exists('xdebug_stop_trace')) { |
|
| 85 | 85 | return false; // @codeCoverageIgnore |
| 86 | 86 | } |
| 87 | 87 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $iniMode = ini_get('xdebug.mode'); |
| 91 | 91 | $xdebugMode = $envMode !== false ? $envMode : ($iniMode !== false ? $iniMode : ''); |
| 92 | 92 | |
| 93 | - if (! str_contains($xdebugMode, 'trace')) { |
|
| 93 | + if (!str_contains($xdebugMode, 'trace')) { |
|
| 94 | 94 | return false; // @codeCoverageIgnore |
| 95 | 95 | } |
| 96 | 96 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | // Try to stop trace and get the trace file path |
| 109 | 109 | // Suppress "Function trace was not started" error for graceful handling |
| 110 | - set_error_handler(static function (int $errno, string $errstr): bool { |
|
| 110 | + set_error_handler(static function(int $errno, string $errstr): bool { |
|
| 111 | 111 | // Ignore specific xdebug trace errors (only handle E_NOTICE) |
| 112 | 112 | return $errno === E_NOTICE && str_contains($errstr, 'Function trace was not started'); |
| 113 | 113 | }); |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | restore_error_handler(); |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - if ($traceFile === false || ! is_string($traceFile) || ! file_exists($traceFile)) { |
|
| 123 | + if ($traceFile === false || !is_string($traceFile) || !file_exists($traceFile)) { |
|
| 124 | 124 | return new self(); // @codeCoverageIgnore |
| 125 | 125 | } |
| 126 | 126 | |
@@ -19,13 +19,13 @@ discard block |
||
| 19 | 19 | { |
| 20 | 20 | /** @param array<string, mixed>|null $data */ |
| 21 | 21 | public function __construct( |
| 22 | - public readonly ?array $data = null, |
|
| 22 | + public readonly ? array $data = null, |
|
| 23 | 23 | ) { |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | public static function start(): self |
| 27 | 27 | { |
| 28 | - if (! function_exists('xhprof_enable')) { |
|
| 28 | + if (!function_exists('xhprof_enable')) { |
|
| 29 | 29 | return new self(); // @codeCoverageIgnore |
| 30 | 30 | } |
| 31 | 31 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | public function stop(string $uri): self |
| 39 | 39 | { |
| 40 | - if (! function_exists('xhprof_disable')) { |
|
| 40 | + if (!function_exists('xhprof_disable')) { |
|
| 41 | 41 | return new self(); // @codeCoverageIgnore |
| 42 | 42 | } |
| 43 | 43 | |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | $this->uri = $request->toUri(); |
| 40 | 40 | $this->call = [ |
| 41 | 41 | $request->resourceObject::class, |
| 42 | - 'on' . ucfirst(strtolower($request->method)) |
|
| 42 | + 'on'.ucfirst(strtolower($request->method)) |
|
| 43 | 43 | ]; |
| 44 | 44 | |
| 45 | 45 | // Start profiling (but don't capture data yet - that's for close) |
@@ -12,18 +12,18 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | $logDirectory = $argv[1] ?? null; |
| 14 | 14 | |
| 15 | -if (! $logDirectory) { |
|
| 15 | +if (!$logDirectory) { |
|
| 16 | 16 | fwrite(STDERR, "Usage: php server.php <log-directory>\n"); |
| 17 | 17 | exit(1); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | -if (! is_dir($logDirectory)) { |
|
| 20 | +if (!is_dir($logDirectory)) { |
|
| 21 | 21 | fwrite(STDERR, "Directory not found: $logDirectory\n"); |
| 22 | 22 | exit(1); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | // Find the latest semantic log file |
| 26 | -$pattern = rtrim($logDirectory, '/') . '/semantic-dev-*.json'; |
|
| 26 | +$pattern = rtrim($logDirectory, '/').'/semantic-dev-*.json'; |
|
| 27 | 27 | $files = glob($pattern); |
| 28 | 28 | |
| 29 | 29 | if (empty($files)) { |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | while ($line = fgets(STDIN)) { |
| 45 | 45 | $request = json_decode(trim($line), true); |
| 46 | 46 | |
| 47 | - if (! $request) { |
|
| 47 | + if (!$request) { |
|
| 48 | 48 | continue; |
| 49 | 49 | } |
| 50 | 50 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | ] |
| 108 | 108 | }; |
| 109 | 109 | |
| 110 | - fwrite(STDOUT, json_encode($response) . "\n"); |
|
| 110 | + fwrite(STDOUT, json_encode($response)."\n"); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | function getLog(string $file): array |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | 'content' => [ |
| 130 | 130 | [ |
| 131 | 131 | 'type' => 'text', |
| 132 | - 'text' => $analysisPrompt . "\n\n```json\n" . json_encode($logData, JSON_PRETTY_PRINT) . "\n```", |
|
| 132 | + 'text' => $analysisPrompt."\n\n```json\n".json_encode($logData, JSON_PRETTY_PRINT)."\n```", |
|
| 133 | 133 | ], |
| 134 | 134 | ], |
| 135 | 135 | 'isError' => false, |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | 'content' => [ |
| 145 | 145 | [ |
| 146 | 146 | 'type' => 'text', |
| 147 | - 'text' => 'Unknown tool: ' . $toolName, |
|
| 147 | + 'text' => 'Unknown tool: '.$toolName, |
|
| 148 | 148 | ], |
| 149 | 149 | ], |
| 150 | 150 | 'isError' => true, |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | $script = $args['script'] ?? ''; |
| 157 | 157 | $xdebugMode = $args['xdebug_mode'] ?? 'trace'; |
| 158 | 158 | |
| 159 | - if (! $script) { |
|
| 159 | + if (!$script) { |
|
| 160 | 160 | return [ |
| 161 | 161 | 'content' => [ |
| 162 | 162 | [ |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | ]; |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - if (! file_exists($script)) { |
|
| 171 | + if (!file_exists($script)) { |
|
| 172 | 172 | return [ |
| 173 | 173 | 'content' => [ |
| 174 | 174 | [ |
@@ -185,14 +185,14 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | // Execute the PHP script with profiling using php-dev.ini |
| 187 | 187 | $env = "XDEBUG_MODE=$xdebugMode XDEBUG_CONFIG='compression_level=0'"; |
| 188 | - $phpDevIni = __DIR__ . '/php-dev.ini'; |
|
| 189 | - $command = "$env php -c " . escapeshellarg($phpDevIni) . ' ' . escapeshellarg($script) . ' 2>&1'; |
|
| 188 | + $phpDevIni = __DIR__.'/php-dev.ini'; |
|
| 189 | + $command = "$env php -c ".escapeshellarg($phpDevIni).' '.escapeshellarg($script).' 2>&1'; |
|
| 190 | 190 | |
| 191 | 191 | $output = shell_exec($command); |
| 192 | 192 | |
| 193 | 193 | // Find semantic log files created during script execution |
| 194 | 194 | $logDirectory = $GLOBALS['logDirectory']; |
| 195 | - $pattern = rtrim($logDirectory, '/') . '/semantic-dev-*.json'; |
|
| 195 | + $pattern = rtrim($logDirectory, '/').'/semantic-dev-*.json'; |
|
| 196 | 196 | |
| 197 | 197 | $files = glob($pattern); |
| 198 | 198 | $newLogFiles = array_filter($files, static fn ($file) => filemtime($file) >= $beforeExecution); |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | 'content' => [ |
| 222 | 222 | [ |
| 223 | 223 | 'type' => 'text', |
| 224 | - 'text' => "Script executed successfully.\nLog file: $executionLog\n\n" . $analysisPrompt . "\n\n```json\n" . json_encode($logData, JSON_PRETTY_PRINT) . "\n```", |
|
| 224 | + 'text' => "Script executed successfully.\nLog file: $executionLog\n\n".$analysisPrompt."\n\n```json\n".json_encode($logData, JSON_PRETTY_PRINT)."\n```", |
|
| 225 | 225 | ], |
| 226 | 226 | ], |
| 227 | 227 | 'isError' => false, |
@@ -68,7 +68,7 @@ |
||
| 68 | 68 | |
| 69 | 69 | // Save analysis prompt alongside JSON for AI-native processing |
| 70 | 70 | $promptFilename = str_replace('.json', '-prompt.md', $filename); |
| 71 | - $analysisPrompt = $this->getAnalysisPrompt() . "\n\n```json\n" . $jsonContent . "\n```"; |
|
| 71 | + $analysisPrompt = $this->getAnalysisPrompt()."\n\n```json\n".$jsonContent."\n```"; |
|
| 72 | 72 | file_put_contents($promptFilename, $analysisPrompt, LOCK_EX); |
| 73 | 73 | } |
| 74 | 74 | |