-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not remove empty default values for string and array respectively (#…
…1028) * Do not remove empty string and empty array as default values for string and array respectively * Save flag initial value for field was eliminated by optimization * Add test case * Mark test as correct Signed-off-by: dsolomennikov <dsolomennikov@>
- Loading branch information
Showing
4 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
@ok | ||
<?php | ||
|
||
class User { | ||
public string $name = ''; | ||
public string $password = ''; | ||
} | ||
|
||
function test_optimized_init_value(): void { | ||
$raw = '{"name": "user"}'; | ||
|
||
$user = JsonEncoder::decode($raw, User::class); | ||
|
||
$error = JsonEncoder::getLastError(); | ||
if (!empty($error)) { | ||
echo "Error: " . $error; | ||
exit(); | ||
} | ||
|
||
var_dump(instance_to_array($user)); | ||
} | ||
|
||
test_optimized_init_value(); |