{
"event": "PreToolUse",
"tool_name": "Bash",
"tool_input": {
"command": "python3 -c \"\nfrom quality import pre_rules, post_rules\n\n# Test mit vollständigem PHP-Code\ntest_critical = '''<?php\ndeclare(strict_types=1);\n\/\/ @responsibility: Test file\n\nclass Test {\n public function getTimeout(): int {\n return 3600; \/\/ Eine Stunde\n }\n}\n'''\n\nresult = pre_rules.check('\/var\/www\/dev.campus.systemische-tools.de\/src\/Test.php', test_critical)\nprint('=== Pre-Hook: Critical Magic Number 3600 ===')\nprint(f'Allowed: {result.get(\\\"allowed\\\")}')\nprint(f'Message: {result.get(\\\"message\\\", \\\"(none)\\\")}')\n\n# Test: Zeit-Berechnung\ntest_calc = '''<?php\ndeclare(strict_types=1);\n\/\/ @responsibility: Test file\n\nclass Test {\n public function getSeconds(int \\$hours): int {\n return \\$hours * 60 * 60;\n }\n}\n'''\n\nresult = pre_rules.check('\/var\/www\/dev.campus.systemische-tools.de\/src\/Test.php', test_calc)\nprint()\nprint('=== Pre-Hook: Time Calculation * 60 * 60 ===')\nprint(f'Allowed: {result.get(\\\"allowed\\\")}')\nprint(f'Message: {result.get(\\\"message\\\", \\\"(none)\\\")}')\n\n# Test: Korrekte Verwendung mit Constants\ntest_good = '''<?php\ndeclare(strict_types=1);\n\/\/ @responsibility: Test file\n\nuse Domain\\Constants;\n\nclass Test {\n public function getTimeout(): int {\n return Constants::SECONDS_PER_HOUR;\n }\n}\n'''\n\nresult = pre_rules.check('\/var\/www\/dev.campus.systemische-tools.de\/src\/Test.php', test_good)\nprint()\nprint('=== Pre-Hook: Correct Usage (Constants) ===')\nprint(f'Allowed: {result.get(\\\"allowed\\\")}')\nprint(f'Message: {result.get(\\\"message\\\", \\\"(none)\\\")}')\n\n# Test: Constants Datei selbst sollte erlaubt sein\ntest_constants = '''<?php\ndeclare(strict_types=1);\n\/\/ @responsibility: Zentrale Konstanten\n\nnamespace Domain;\n\nfinal class Constants {\n public const int SECONDS_PER_HOUR = 3600;\n public const int SECONDS_PER_DAY = 86400;\n}\n'''\n\nresult = pre_rules.check('\/var\/www\/dev.campus.systemische-tools.de\/src\/Domain\/Constants.php', test_constants)\nprint()\nprint('=== Pre-Hook: Constants.php File ===')\nprint(f'Allowed: {result.get(\\\"allowed\\\")}')\nprint(f'Message: {result.get(\\\"message\\\", \\\"(none)\\\")}')\n\n# Post-Hook Warnung Test\ntest_warnings = '''<?php\ndeclare(strict_types=1);\n\/\/ @responsibility: Test file\n\nclass Test {\n public function getLimit(): int {\n return 1000;\n }\n}\n'''\n\nresult = post_rules.check('\/var\/www\/dev.campus.systemische-tools.de\/src\/Test.php', test_warnings)\nprint()\nprint('=== Post-Hook: Magic Number Warnings ===')\nfor w in result.get('warnings', []):\n if 'W7' in w:\n print(f' - {w}')\n\"\n",
"description": "Test hooks with correct PHP code"
}
}
{
"tool_response": {
"stdout": "=== Pre-Hook: Critical Magic Number 3600 ===\nAllowed: False\nMessage: QUALITY VIOLATION [P7.1]: Critical magic number 3600 found at line 7. Use Domain\\Constants::SECONDS_PER_HOUR instead.\n\n=== Pre-Hook: Time Calculation * 60 * 60 ===\nAllowed: False\nMessage: QUALITY VIOLATION [P7.2]: Time calculation with magic numbers at line 7. Use Constants::SECONDS_PER_HOUR\n\n=== Pre-Hook: Correct Usage (Constants) ===\nAllowed: True\nMessage: (none)\n\n=== Pre-Hook: Constants.php File ===\nAllowed: True\nMessage: (none)\n\n=== Post-Hook: Magic Number Warnings ===\n - W7.1: Magic number 1000 at line 7. Consider using Constants::BATCH_LIMIT or MS_PER_SECOND\n - W7.2: File uses magic number 1000 but missing 'use Domain\\Constants'. Add import and use named constants.\n<string>:44: SyntaxWarning: invalid escape sequence '\\C'",
"stderr": "",
"interrupted": false,
"isImage": false
}
}