Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 1.x #1920 +/- ##
==========================================
- Coverage 77.31% 77.30% -0.01%
==========================================
Files 828 828
Lines 24569 24559 -10
==========================================
- Hits 18995 18986 -9
+ Misses 5574 5573 -1
🚀 New features to boost your workflow:
|
|
|
||
| if ($typeChecker->isUuid()) { | ||
| return type_uuid()->cast($value); | ||
| } |
There was a problem hiding this comment.
I don't think those two can be removed, it seems that we are missing tests for them but by removing those lines following code will fail, breaking backward compatibility of caster:
<?php
declare(strict_types=1);
use Flow\Types\Type\AutoCaster;
use Symfony\Component\Uid\Uuid;
require_once __DIR__ . '/vendor/autoload.php';
$output = (new AutoCaster())->cast(Uuid::v7()->toString());
dd($output); // this should be Uuid instance, not string | @@ -36,24 +34,15 @@ public function cast(mixed $value) : mixed | |||
| */ | |||
| private function castArray(array $value) : array | |||
There was a problem hiding this comment.
Uhm I think I messed up a bit this castArray.
The only thing it does now is that it narrows array types.
For example when we have array [1, 2, 3.0] in which we have int's and float, it will narrow the type to float as all int can be represented by float however I don't think this should be responsibility of a class called AutoCaster 😅
Probably I was trying to fix some bug and I did it here without properly thinking this through 🤦♂️
I think this is much bigger issue that will need to be solved in separated PR (probably will require some more explicit array types narrowing mechanism) but for now removing key types makes sense.
While working on #1917, I have noticed that
AutoCasteralways gets pre-converted data (array instead of string json,\DOMDocumentinstead of string XML), so validating if the given value is scalar with logic type inside is not needed. This also removes the check for the array key, as it was never used outside of the loop.Change Log
Added
Fixed
Changed
Removed
Deprecated
Security