crazy-goat/workerman-bundle
Symfony bundle integrating Workerman to run a high-performance async HTTP server, scheduler and supervisor in pure PHP. Keeps the Symfony kernel/container alive between requests for faster apps. Supports SO_REUSEPORT and optional direct Request creation for speed.
For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (
- [ ]) syntax for tracking.
Goal: Fix fragile cron expression detection in TriggerFactory by using CronExpression::isValidExpression()
Architecture: Replace fragile heuristic (5 parts + contains '*') with library validation method. The library already handles all valid cron formats including aliases.
Tech Stack: PHP 8.2, cron-expression library (dragonmantank/cron-expression), PHPUnit
Files:
Modify: src/Scheduler/Trigger/TriggerFactory.php:5-7
Modify: src/Scheduler/Trigger/TriggerFactory.php:37-42
Step 1: Add CronExpression import
Add after line 5 (namespace line):
use Cron\CronExpression;
Replace lines 39-40:
is_string($expression) && count(explode(' ', $expression)) === 5 && str_contains($expression, '*'),
is_string($expression) && str_starts_with($expression, '@') => new CronExpressionTrigger($expression),
With:
is_string($expression) && CronExpression::isValidExpression($expression) => new CronExpressionTrigger($expression),
Run: ./vendor/bin/phpunit tests/TriggerFactoryTest.php -v
Expected: All tests pass (some may fail - see Task 2)
git add src/Scheduler/Trigger/TriggerFactory.php
git commit -m "fix: use CronExpression::isValidExpression for robust cron detection"
Files:
Modify: tests/TriggerFactoryTest.php:114-128
Modify: tests/TriggerFactoryTest.php:131-137
Step 1: Add test case for cron without asterisks
Add to cronExpressionProvider array (after line 127):
'daily at midnight on Monday (no asterisks)' => ['0 0 1 1 1'],
The test '1 2 3 4 5' previously expected exception, but CronExpression::isValidExpression('1 2 3 4 5') returns true (it's valid - means 1:02:03 on 4th day of 5th month).
Replace testFivePartNonCronExpressionThrowsException with a test for a truly invalid expression:
public function testFivePartNonCronExpressionThrowsException(): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid interval');
TriggerFactory::create('1 2 3 4 5 6'); // 6 parts - invalid
}
Run: ./vendor/bin/phpunit tests/TriggerFactoryTest.php -v
Expected: All tests pass
git add tests/TriggerFactoryTest.php
git commit -m "test: add cron detection test cases and fix obsolete exception test"
Files:
Run: Full test suite
Step 1: Run full test suite
Run: ./vendor/bin/phpunit
Expected: All tests pass
Run: ./vendor/bin/phpstan analyse src/Scheduler/Trigger/TriggerFactory.php --level=max 2>/dev/null || echo "phpstan not configured"
How can I help you explore Laravel packages today?