Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Workerman Bundle Laravel Package

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.

View on GitHub
Deep Wiki
Context7

TriggerFactory Cron Expression Detection Fix - Implementation Plan

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


Task 1: Update TriggerFactory.php

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;
  • Step 2: Replace fragile cron detection with library validation

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),
  • Step 3: Run tests to verify changes

Run: ./vendor/bin/phpunit tests/TriggerFactoryTest.php -v Expected: All tests pass (some may fail - see Task 2)

  • Step 4: Commit
git add src/Scheduler/Trigger/TriggerFactory.php
git commit -m "fix: use CronExpression::isValidExpression for robust cron detection"

Task 2: Update TriggerFactoryTest.php

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'],
  • Step 2: Update testFivePartNonCronExpressionThrowsException

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
}
  • Step 3: Run tests to verify all pass

Run: ./vendor/bin/phpunit tests/TriggerFactoryTest.php -v Expected: All tests pass

  • Step 4: Commit
git add tests/TriggerFactoryTest.php
git commit -m "test: add cron detection test cases and fix obsolete exception test"

Task 3: Final verification

Files:

  • Run: Full test suite

  • Step 1: Run full test suite

Run: ./vendor/bin/phpunit Expected: All tests pass

  • Step 2: Run static analysis if available

Run: ./vendor/bin/phpstan analyse src/Scheduler/Trigger/TriggerFactory.php --level=max 2>/dev/null || echo "phpstan not configured"


Spec Coverage Check

  • Replace fragile heuristic - Task 1
  • Add CronExpression import - Task 1
  • Test for cron without asterisks (0 0 1 1 1) - Task 2
  • Remove obsolete test - Task 2
  • Verify no regressions - Task 3
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky