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

Php7Cc Laravel Package

sstalle/php7cc

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require --dev sstalle/php7cc
    

    Add to composer.json under require-dev if not using global install.

  2. First Run:

    ./vendor/bin/php7cc
    

    Run in project root to scan all PHP files for PHP 7 compatibility issues.

  3. Quick Check:

    ./vendor/bin/php7cc --format=json --output=php7cc-report.json src/
    

    Generate a JSON report for CI/CD pipelines or programmatic use.

Key Files to Review

  • php7cc.phar (binary) – Main executable.
  • src/Checker.php – Core logic for rule evaluation.
  • src/Rules/ – Individual rule implementations (e.g., ArrayAccessRule, GeneratorRule).

Implementation Patterns

Workflow Integration

  1. CI/CD Pipeline:

    # Example GitHub Actions step
    - name: PHP 7 Compatibility Check
      run: ./vendor/bin/php7cc --fail-on=warning --format=checkstyle > php7cc-results.xml
    

    Fail builds on warnings/errors, output Checkstyle format for IDE integration.

  2. Pre-Commit Hook:

    # .git/hooks/pre-commit
    #!/bin/sh
    ./vendor/bin/php7cc --format=compact || exit 1
    

    Block commits with PHP 7 incompatibilities.

  3. Programmatic Use:

    use Stalle\Php7cc\Checker;
    
    $checker = new Checker();
    $results = $checker->checkFiles(['src/Controller.php']);
    foreach ($results as $file => $issues) {
        foreach ($issues as $issue) {
            echo "Line {$issue['line']}: {$issue['message']}\n";
        }
    }
    

Common Use Cases

  • Legacy Code Migration: Scan entire codebase before upgrading PHP version.
  • Pull Request Reviews: Integrate with tools like PhpStorm or SonarQube for real-time feedback.
  • Custom Rules: Extend Stalle\Php7cc\Rule\AbstractRule for project-specific checks (e.g., deprecated functions).

Gotchas and Tips

Pitfalls

  1. False Positives:

    • Rules like ListRule may flag valid PHP 5.6 syntax (e.g., list($a, $b) = $array;).
    • Fix: Use --ignore=ListRule or suppress specific lines with # @php7cc-ignore ListRule.
  2. Performance:

    • Scanning large codebases (e.g., 10K+ files) can be slow.
    • Fix: Limit scope with --path or parallelize checks in CI.
  3. Outdated Rules:

    • Last release (2017) may miss newer PHP 7.x/8.x features (e.g., typed properties, arrow functions).
    • Fix: Combine with phpstan/extension-installer for modern checks.

Debugging Tips

  • Verbose Output:

    ./vendor/bin/php7cc -v
    

    Shows skipped files and rule details.

  • Custom Config:

    # php7cc.ini
    ignore = ListRule, GeneratorRule
    fail_on = error
    

    Place in project root to override defaults.

Extension Points

  1. Add Custom Rules:

    namespace App\Php7cc;
    
    use Stalle\Php7cc\Rule\AbstractRule;
    
    class MyCustomRule extends AbstractRule {
        public function getName() { return 'MyCustomRule'; }
        public function check($node) { /* ... */ }
    }
    

    Register via php7cc.phar --rules=App\Php7cc\MyCustomRule.

  2. Override Default Rules: Modify Stalle\Php7cc\Checker to exclude/include rules dynamically.

  3. Format Output: Extend Stalle\Php7cc\Formatter\AbstractFormatter for custom reporters (e.g., Slack alerts).

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.
babenkoivan/elastic-client
innmind/static-analysis
innmind/coding-standard
datacore/hub-sdk
alengo/sulu-http-cache-bundle
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
imbo/imbo-coding-standard
visualbuilder/filament-lottie
servicioslineaonce/starter-kit
atomcoder/laravel-reorderable
irajul/filament-shadcn-theme
agtp/agtp-php
agtp/mod-php
centraldesktop/protobuf-php