⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Adding Property related Rules#26

Merged
floriankraemer merged 19 commits intomasterfrom
new-rules
Feb 9, 2026
Merged

Adding Property related Rules#26
floriankraemer merged 19 commits intomasterfrom
new-rules

Conversation

@floriankraemer
Copy link
Contributor

No description provided.

Florian Krämer and others added 19 commits January 13, 2026 23:49
…s name

The rule was using only the short class name for pattern matching and error
messages, inconsistent with all other class-based rules in the codebase.
Now uses $scope->getNamespace() to resolve the full class name, matching
the approach used by ForbiddenAccessorsRule and other rules.

Co-authored-by: Cursor <[email protected]>
…rrors

Introduce @phpstan-type aliases (PropertyRule, PatternConfig) for the
property rule array shapes, replacing untyped array parameters throughout.
Remove redundant null checks already handled by isset(). Resolves all 11
pre-existing PHPStan errors in PropertyMustMatchRule.

Co-authored-by: Cursor <[email protected]>
The default case in the visibility match expression silently accepted
invalid values like typos, making the visibility check a no-op. Now
throws an InvalidArgumentException with a helpful message listing the
valid options.

Co-authored-by: Cursor <[email protected]>
The getTypeAsString method now handles union types (string|int) and
intersection types (Countable&Iterator) instead of returning null and
reporting the actual type as "none". Aligns with how other rules in the
codebase handle complex types.

Co-authored-by: Cursor <[email protected]>
…orsRule

Both rules silently swallowed preg_match errors from invalid regex
patterns, treating them the same as "no match". Now throws
InvalidArgumentException with the pattern and error message so
configuration mistakes are surfaced immediately.

Co-authored-by: Cursor <[email protected]>
buildGetterError and buildSetterError had @return docblocks but lacked
actual PHP return type declarations.

Co-authored-by: Cursor <[email protected]>
The docblock listed only 'public' and 'protected' as valid visibility
values, but 'private' is also supported and works correctly.

Co-authored-by: Cursor <[email protected]>
PropertyMustMatchRule now validates that propertyPatterns is non-empty.
ForbiddenAccessorsRule now validates that classPatterns is non-empty and
that visibility values are valid (public, protected, private). Invalid
configurations now throw InvalidArgumentException immediately instead
of silently producing no results.

Co-authored-by: Cursor <[email protected]>
- Bump phpunit/phpunit from ^12.0 to ^12.5.8
- Update myclabs/deep-copy from 1.13.0 to 1.13.4
- Upgrade nikic/php-parser from v5.4.0 to v5.7.0
- Upgrade phpstan/phpstan from 2.1.11 to 2.1.38
- Upgrade phpunit/php-code-coverage from 12.1.0 to 12.5.3
- Update various references and URLs in composer.lock

These changes ensure compatibility with the latest versions of the dependencies.
… resolution

- Added ClassNameResolver trait to multiple rules (AttributeRule, CatchExceptionOfTypeNotAllowedRule, ClassMustBeFinalRule, ClassMustBeReadonlyRule, ClassMustHaveSpecificationDocblockRule, ForbiddenAccessorsRule, MethodMustReturnTypeRule, MethodSignatureMustMatchRule, PropertyMustMatchRule).
- Updated processNode methods to resolve full class names using the new trait, improving consistency and reducing code duplication.
- Removed redundant code related to manual full class name construction and unnecessary private methods.

This refactor enhances maintainability and aligns the rules with a unified approach for class name resolution.
…ules

- Introduced tests in CircularModuleDependencyRuleTest to skip non-modular namespaces and same module imports.
- Added tests in ClassMustBeFinalRuleTest to ensure final classes and anonymous classes are correctly handled.
- Updated ForbiddenAccessorsRuleTest to skip anonymous classes.
- Enhanced ForbiddenStaticMethodsRuleTest to skip dynamic method and class names.

These additions improve the robustness of the architecture rules by ensuring that specific cases are properly ignored during analysis.
…raints

- Updated README.md to mark the Dependency Constraints Rule as deprecated and introduced the new Forbidden Dependencies Rule, which enforces dependency constraints between namespaces.
- Added detailed documentation for the Forbidden Dependencies Rule and the Forbidden Static Methods Rule, outlining their configurations and use cases.
- Updated Rules.md to include descriptions and examples for the new rules, ensuring clarity on their functionalities.

These changes improve the clarity of the rules and provide guidance for users on enforcing architectural boundaries in their code.
@floriankraemer floriankraemer merged commit 35d68c7 into master Feb 9, 2026
8 checks passed
@floriankraemer floriankraemer deleted the new-rules branch February 9, 2026 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant