Skip to content

Develop#5

Merged
walmir-silva merged 6 commits into
mainfrom
develop
Mar 5, 2026
Merged

Develop#5
walmir-silva merged 6 commits into
mainfrom
develop

Conversation

@walmir-silva

Copy link
Copy Markdown
Contributor

No description provided.

Core/Infra fixes:
- Transform: add @param variadic docblock for $rules
- TransformationContextImpl: separate @param docblocks in __construct
- ProcessorBridge: typed @param array<string,list<...>> $fieldRules
- TransformationResult: separate @param docblocks in __construct
- AttributeTransformer: @var inline cast before engine::transform() call
- TransformerEngine: @param on resolveValue/resolveRule private methods

Rule fixes (17 files):
- Pattern: (is_T($_p = $context->getParameter(KEY, DEFAULT)) ? $_p : DEFAULT)
- ArrayToKeyValueRule: is_int|is_string guard for array key
- CsvToArrayRule: explicit list<string> cast on headers before array_combine
- ImplodeRule: is_scalar guard in lambda fn
- GroupByRule: array_key_exists + is_int|is_string for group key
- RenameKeysRule: is_string|is_int guard for mapped key
- FlattenRule: @param/@return on flattenArray
- UnflattenRule: @var type annotation on $result + safe separator
…r, phpunit

Psalm fixes:
- Add #[Override] attribute to all TransformationRule implementations
  (transform() and getName() methods) via psalm --alter
- AgeRule: remove redundant (int) cast, DateInterval->y is already int
- DateToIso8601Rule: ensure $tz is non-empty-string before DateTimeZone()
- RelativeDateRule: use intdiv(int, int) instead of / operator;
  cast abs() result to (int) since abs(int) returns float|int in Psalm
- PercentageRule: use 100.0 instead of 100 to fix float * int InvalidOperand

CS-Fixer: auto-format new source and test files to project code style
…ec V4.0

Coverage: 47/47 classes · 118/118 methods · 450/450 lines (100%)

- Create 22 individual test files (one CoversClass per rule) so pcov
  correctly attributes coverage to each class independently
- Remove duplicate test methods from consolidated test files to avoid
  coverage-attribution conflicts
- Add missing branch tests: ctype_digit, empty-string, non-string passthrough
- Fix PluckRuleTest: assert [null,'Bob'] (rule uses $item[$field] ?? null)
- Fix GroupByRuleTest: testEmptyFieldReturnsValue, testItemMissingField
- Add devkit.php: exclude tests/ from cs-fixer to prevent @PHP84Migration
  from breaking pcov coverage attribution
…ame() methods

All getName() assertions now validate the actual string value instead of
just the type, following ARFA 1.3 Spec V4.0 testing standards.

Files updated (7 consolidated test files):
- BrazilianRulesTest: CpfToDigits, CnpjToDigits, CepToDigits, PhoneFormat
- DataRulesTest: CsvToArray, JsonEncode, Implode
- DateRulesTest: DateToIso8601, RelativeDate
- EncodingRulesTest: Base64Encode, Base64Decode
- NumericRulesTest: CurrencyFormat
- StringRulesTest: CamelCase, SnakeCase, KebabCase, PascalCase, Mask, Reverse, Repeat
- StructureRulesTest: Flatten, Pluck, GroupBy, RenameKeys, Unflatten
Replace all `(new Foo())->method()` inline patterns with local variable
assignments to satisfy cs-fixer @PHP84Migration rules while keeping pcov
code-coverage attribution correct:

  Before:  $this->assertX((new FooRule())->transform($v, $ctx));
  After:   $rule = new FooRule();
           $this->assertX($rule->transform($v, $ctx));

This enables cs-fixer to run on tests/ without breaking phpunit coverage.

kcode quality: All 4 tools pass — cs-fixer + phpstan + psalm + phpunit
Coverage: 100% classes · 100% methods · 100% lines
abs(int) returns float|int — Rector removes the (int) cast (treats it as
useless) but Psalm requires it for intdiv(). This creates a circular conflict
between kcode format (Rector removes cast) and kcode quality (Psalm fails).

Solution: $diff >= 0 ? $diff : -$diff is purely int — no cast, no abs(),
no conflict between tools.

Also applies Rector refactoring suggestions from kcode format run.
@walmir-silva walmir-silva merged commit ff2d547 into main Mar 5, 2026
4 of 7 checks passed
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