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

Phpstan Rules Laravel Package

solido/phpstan-rules

Custom PHPStan ruleset for Solido-based projects. Adds extra static analysis for enhanced DTOs with simple phpstan.neon config to declare DTO namespaces and excluded interfaces, helping catch type and structure issues across your application.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Purpose Alignment: The solido/phpstan-rules package is highly specialized for enforcing Solido-specific DTO and domain-driven design (DDD) patterns within PHPStan. It bridges the gap between static analysis and architectural constraints, making it ideal for projects leveraging Solido’s enhanced DTOs, repositories, or domain layers.
  • Complementarity: Integrates seamlessly with PHPStan’s existing ecosystem, adding Solido-specific validation layers without replacing core functionality. Works alongside other PHPStan extensions (e.g., phpstan/extension-installer) for a modular static analysis pipeline.
  • Extensibility: Rules are configuration-driven (via phpstan.neon), allowing teams to incrementally adopt or customize enforcement without modifying the package itself. Supports excluded interfaces and namespace scoping, reducing false positives.
  • Architectural Debt Mitigation: Addresses common pain points in Solido-based projects, such as:
    • DTO misuse (e.g., direct instantiation, invalid property access).
    • Type safety gaps in repository interactions.
    • Inconsistent domain modeling (e.g., violating DTO immutability).

Integration Feasibility

  • Low-Coupling Design: Rules operate at the static analysis layer, with no runtime dependencies on Solido’s framework. This ensures backward compatibility with existing PHPStan setups.
  • Minimal Configuration Overhead:
    • Requires only 2–3 lines in phpstan.neon to define DTO namespaces and exclusions.
    • No changes to business logic, DTO classes, or repository implementations.
  • Toolchain Synergy:
    • PHPStan 1.x+: Compatible with modern PHPStan versions, including parallel analysis for performance.
    • CI/CD Ready: Designed for pre-commit hooks or pipeline integration (e.g., GitHub Actions, GitLab CI).
  • Dependency Risks:
    • No transitive dependencies beyond PHPStan, reducing version conflict risks.
    • Lightweight footprint (package size: ~50KB), making it suitable for resource-constrained environments.

Technical Risk

Risk Category Description Mitigation Strategy
False Positives Rules may flag legitimate dynamic behavior (e.g., magic methods, excluded interfaces). Configure excluded_interfaces and suppress rules selectively via PHPDoc comments.
Rule Obsolescence Solido’s DTO conventions may evolve, rendering rules outdated. Monitor Solido’s release notes and update rules or configurations proactively.
Performance Impact Additional rules increase static analysis time, especially for large codebases. Benchmark with --memory-limit and --parallel flags; limit scope to critical paths.
Configuration Errors Incorrect dto_namespaces or level settings may break CI/CD. Start with level=warning in CI, then enforce level=error after validation.
Limited Community Low stars (2) and dependents (0) indicate niche adoption. Rely on Solido’s documentation and internal testing; contribute fixes if needed.

Key Questions for TPM

  1. Architectural Adoption:
    • Are we fully committed to Solido’s DTO pattern, or is this a trial? (Avoid premature integration if adoption is uncertain.)
    • How do Solido’s DTOs differ from our current patterns? (Custom rules may need adjustments.)
  2. Static Analysis Maturity:
    • Do we already use PHPStan? If not, assess setup effort (e.g., configuration, CI integration).
    • What’s our tolerance for false positives? (Start with level=warning to gauge impact.)
  3. CI/CD Integration:
    • Can we fail builds on violations without disrupting workflows? (Gradual enforcement recommended.)
    • How will we triage rule violations (e.g., tooling, documentation, owner assignments)?
  4. Long-Term Maintenance:
    • Who will monitor Solido updates and adjust rules/configurations? (Assign a static analysis owner.)
    • Are we prepared to customize or extend rules if Solido’s conventions change?
  5. Team Readiness:
    • Do developers understand Solido’s DTO expectations? (Provide training or documentation.)
    • How will we communicate rule violations (e.g., IDE plugins, CI feedback)?

Integration Approach

Stack Fit

  • Primary Use Case:
    • Solido Framework Projects: Enforce DTO purity, repository interactions, and domain constraints.
    • DTO-Heavy Architectures: Validate type safety and immutability in projects using Solido-like patterns (e.g., custom DTOs, CQRS).
  • Secondary Use Case:
    • Legacy Modernization: Gradually introduce static analysis for Solido-adjacent codebases (e.g., migrating to DDD).
    • API Layers: Ensure request/response DTOs conform to Solido standards.
  • Non-Fit:
    • Non-Solido PHP Projects: Rules are irrelevant without Solido’s DTO conventions.
    • Teams Without PHPStan: Requires existing static analysis infrastructure.
    • Microservices with Loose Coupling: Rules assume centralized DTO definitions; may conflict with service-specific DTOs.

Migration Path

Phase Action Items Success Criteria
1. Assessment - Audit DTO usage (namespaces, interfaces, instantiation patterns). Identify scope of DTOs and current violations (if any).
- Verify PHPStan setup (composer.json, phpstan.neon). Ensure PHPStan 1.x+ is installed and configurable.
2. Configuration - Add solido/phpstan-rules to composer.json. Package installs without conflicts.
- Configure phpstan.neon with dto_namespaces and excluded_interfaces. Rules detect expected DTOs without false positives.
3. Validation - Run PHPStan locally (--level=5) to identify violations. No critical false positives; violations are actionable.
- Adjust level (e.g., warningerror) incrementally. CI/CD fails only on intentional violations.
4. CI/CD Integration - Add PHPStan to pre-commit hooks or pipeline. Builds fail on violations without manual intervention.
5. Enforcement - Document rules for the team (e.g., Confluence, README). Developers understand and comply with DTO constraints.
6. Optimization - Suppress rules for legitimate edge cases (e.g., dynamic properties). Minimal false positives; rules add real value.

Compatibility

  • PHPStan Version:
    • Tested: PHPStan 1.x (confirmed via composer.json).
    • Recommendation: Pin version in composer.json to avoid surprises:
      "require-dev": {
          "phpstan/phpstan": "^1.10",
          "solido/phpstan-rules": "^1.0"
      }
      
  • PHP Version:
    • Requirement: PHP 8.0+ (aligned with Solido’s modern PHP support).
    • Action: Update php.ini or Docker config if using older PHP.
  • Solido Version:
    • Assumption: Rules align with Solido’s current DTO conventions (e.g., immutability, naming).
    • Risk: If using a forked or custom Solido version, rules may need adaptation.
  • IDE/Tooling:
    • PHPStorm/VSCode: Integrate with PHPStan plugins for real-time feedback.
    • CI Systems: Test compatibility with GitHub Actions, GitLab CI, or Jenkins.

Sequencing

  1. Pilot Phase:
    • Scope: Apply rules to one module (e.g., API layer or domain service).
    • Goal: Validate rule effectiveness and team adoption before scaling.
  2. Gradual Rollout:
    • Phase 1: level=warning in CI (non-blocking).
    • Phase 2: level=error for high-priority DTOs (e.g., critical APIs).
    • Phase 3: Full enforcement across **all
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.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
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