File tree Expand file tree Collapse file tree 3 files changed +15
-9
lines changed Expand file tree Collapse file tree 3 files changed +15
-9
lines changed Original file line number Diff line number Diff line change 88use LogicException ;
99use ShipMonkTests \DoctrineEntityPreloader \Fixtures \Blog \PrimaryKey ;
1010use ShipMonkTests \DoctrineEntityPreloader \Fixtures \Compat \CompatibilityType ;
11+ use function get_debug_type ;
12+ use function is_string ;
1113use function pack ;
1214use function unpack ;
1315
@@ -25,11 +27,11 @@ public function convertToPHPValue(
2527 return null ;
2628 }
2729
28- if ($ value instanceof PrimaryKey ) {
29- return $ value;
30+ if (is_string ( $ value) ) {
31+ return new PrimaryKey ( unpack ( ' N ' , $ value)[ 1 ]); // @phpstan-ignore offsetAccess.nonOffsetAccessible
3032 }
3133
32- return new PrimaryKey ( unpack ( ' N ' , $ value )[ 1 ]); // @phpstan-ignore offsetAccess.nonOffsetAccessible
34+ throw new LogicException ( ' Unexpected value: ' . get_debug_type ( $ value ));
3335 }
3436
3537 public function convertToDatabaseValue (
Original file line number Diff line number Diff line change 88use LogicException ;
99use ShipMonkTests \DoctrineEntityPreloader \Fixtures \Blog \PrimaryKey ;
1010use ShipMonkTests \DoctrineEntityPreloader \Fixtures \Compat \CompatibilityType ;
11+ use function get_debug_type ;
12+ use function is_int ;
1113
1214final class PrimaryKeyIntegerType extends Type
1315{
@@ -23,11 +25,11 @@ public function convertToPHPValue(
2325 return null ;
2426 }
2527
26- if ($ value instanceof PrimaryKey ) {
27- return $ value ;
28+ if (is_int ( $ value) ) {
29+ return new PrimaryKey ( $ value) ;
2830 }
2931
30- return new PrimaryKey ( $ value );
32+ throw new LogicException ( ' Unexpected value: ' . get_debug_type ( $ value) );
3133 }
3234
3335 public function convertToDatabaseValue (
Original file line number Diff line number Diff line change 88use LogicException ;
99use ShipMonkTests \DoctrineEntityPreloader \Fixtures \Blog \PrimaryKey ;
1010use ShipMonkTests \DoctrineEntityPreloader \Fixtures \Compat \CompatibilityType ;
11+ use function get_debug_type ;
12+ use function is_string ;
1113
1214final class PrimaryKeyStringType extends Type
1315{
@@ -23,11 +25,11 @@ public function convertToPHPValue(
2325 return null ;
2426 }
2527
26- if ($ value instanceof PrimaryKey ) {
27- return $ value ;
28+ if (is_string ( $ value) ) {
29+ return new PrimaryKey (( int ) $ value) ;
2830 }
2931
30- return new PrimaryKey (( int ) $ value );
32+ throw new LogicException ( ' Unexpected value: ' . get_debug_type ( $ value) );
3133 }
3234
3335 public function convertToDatabaseValue (
You can’t perform that action at this time.
0 commit comments