Skip to content

Commit

Permalink
perf(CachingTypeResolver): Use rawurlencode instead of md5.
Browse files Browse the repository at this point in the history
  • Loading branch information
priyadi committed Jan 24, 2024
1 parent b38a77a commit 65bc893
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* perf(`TransformerRegistry`): Cache `TransformerInterface` instances.
* perf: Optimize `ObjectCache` & `Context`.
* perf(`TypeFactory`): Optimize `objectWithKeyValue`.
* perf(`CachingTypeResolver`): Use `rawurlencode` instead of `md5`.

## 0.5.14

Expand Down
2 changes: 1 addition & 1 deletion src/TypeResolver/CachingTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function getSimpleTypes(Type|MixedType $type): array
return [$type];
}

$key = md5(serialize($type));
$key = rawurlencode(serialize($type));

if ($result = $this->simpleTypesCache[$key] ?? null) {

Check failure on line 65 in src/TypeResolver/CachingTypeResolver.php

View workflow job for this annotation

GitHub Actions / Symfony 6.4.*, highest deps, PHP 8.3, ubuntu-latest

RiskyTruthyFalsyComparison

src/TypeResolver/CachingTypeResolver.php:65:13: RiskyTruthyFalsyComparison: Operand of type array<array-key, Rekalogika\Mapper\Transformer\Contracts\MixedType|Symfony\Component\PropertyInfo\Type>|null contains type array<array-key, Rekalogika\Mapper\Transformer\Contracts\MixedType|Symfony\Component\PropertyInfo\Type>, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. (see https://psalm.dev/356)

Check failure on line 65 in src/TypeResolver/CachingTypeResolver.php

View workflow job for this annotation

GitHub Actions / Symfony 7.*, highest deps, PHP 8.3, ubuntu-latest

RiskyTruthyFalsyComparison

src/TypeResolver/CachingTypeResolver.php:65:13: RiskyTruthyFalsyComparison: Operand of type array<array-key, Rekalogika\Mapper\Transformer\Contracts\MixedType|Symfony\Component\PropertyInfo\Type>|null contains type array<array-key, Rekalogika\Mapper\Transformer\Contracts\MixedType|Symfony\Component\PropertyInfo\Type>, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. (see https://psalm.dev/356)
return $result;
Expand Down

0 comments on commit 65bc893

Please sign in to comment.