Add comprehensive quality tooling and fix code style issues

Quality Tools Added:
- PHPStan (Level 8) for static analysis
- PHP_CodeSniffer (PSR-12) for code style
- Updated PHPUnit test suite with type safety

Code Improvements:
- Fixed all PHPStan Level 8 errors (13 issues)
- Auto-fixed 25 PSR-12 code style violations
- Added proper type hints for arrays and method parameters
- Fixed PDOStatement|false handling in api.php and tests
- Improved null-safety for parse_url() calls

Configuration:
- phpstan.neon: Level 8, analyzes src/ and tests/
- phpcs.xml: PSR-12 standard, excludes vendor/
- docker-compose.yml: Mount config files for tooling
- composer.json: Add phpstan, phpcs, phpcbf scripts

Documentation:
- Updated README.md with testing and quality sections
- Updated AGENTS.md with quality gates and workflows
- Added pre-commit checklist for developers

All tests pass (9/9), PHPStan clean (0 errors), PHPCS compliant (1 warning)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-03 23:58:21 +02:00
parent b5640ad131
commit e569d189d5
13 changed files with 378 additions and 27 deletions

View File

@@ -18,7 +18,8 @@ class CrawlerIntegrationTest extends TestCase
// Create a test job
$stmt = $this->db->prepare("INSERT INTO crawl_jobs (domain, status) VALUES (?, 'pending')");
$stmt->execute(['https://httpbin.org']);
$this->testJobId = $this->db->lastInsertId();
$lastId = $this->db->lastInsertId();
$this->testJobId = is_numeric($lastId) ? (int)$lastId : 0;
}
protected function tearDown(): void

View File

@@ -17,7 +17,8 @@ class CrawlerTest extends TestCase
// Create a test job
$stmt = $db->prepare("INSERT INTO crawl_jobs (domain, status) VALUES (?, 'pending')");
$stmt->execute(['https://example.com']);
$this->testJobId = $db->lastInsertId();
$lastId = $db->lastInsertId();
$this->testJobId = is_numeric($lastId) ? (int)$lastId : 0;
}
protected function tearDown(): void

View File

@@ -42,6 +42,7 @@ class DatabaseTest extends TestCase
{
$db = Database::getInstance();
$stmt = $db->query('SELECT 1 as test');
$this->assertNotFalse($stmt, 'Query failed');
$result = $stmt->fetch();
$this->assertEquals(['test' => 1], $result);