Skip to content

Commit 6c0934b

Browse files
authored
Merge pull request #69 from slackhq/ih_use_null_type
Type NullBuilder correctly
2 parents 1b5f58b + 46517c3 commit 6c0934b

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/Codegen/Constraints/NullBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ protected function getCheckMethod(): CodegenMethod {
4141

4242
<<__Override>>
4343
public function getType(): string {
44-
return 'mixed';
44+
return 'null';
4545
}
4646

4747
}

src/Constraints/NullConstraint.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
use namespace Slack\Hack\JsonSchema;
66

77
class NullConstraint {
8-
public static function check(mixed $input, string $pointer): mixed {
9-
if ($input === null) {
8+
public static function check(mixed $input, string $pointer): null {
9+
if ($input is null) {
1010
return $input;
1111
} else {
1212
$error = shape(

tests/examples/codegen/AnyOfValidator3.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* To re-generate this file run `make test`
66
*
77
*
8-
* @generated SignedSource<<f75639f4e8e44660c38760a9b0e53aa6>>
8+
* @generated SignedSource<<d77b8264266f73d1a54d15323844b5c1>>
99
*/
1010
namespace Slack\Hack\JsonSchema\Tests\Generated;
1111
use namespace Slack\Hack\JsonSchema;
@@ -15,7 +15,7 @@
1515

1616
final class AnyOfValidator3AnyOf0 {
1717

18-
public static function check(mixed $input, string $pointer): mixed {
18+
public static function check(mixed $input, string $pointer): null {
1919
$typed = Constraints\NullConstraint::check($input, $pointer);
2020

2121
return $typed;
@@ -24,7 +24,7 @@ public static function check(mixed $input, string $pointer): mixed {
2424

2525
final class AnyOfValidator3AnyOf1 {
2626

27-
public static function check(mixed $input, string $pointer): mixed {
27+
public static function check(mixed $input, string $pointer): null {
2828
$typed = Constraints\NullConstraint::check($input, $pointer);
2929

3030
return $typed;

tests/examples/codegen/FriendsSchemaValidator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* To re-generate this file run `make test`
66
*
77
*
8-
* @generated SignedSource<<c1e1a034a097914b540fefaa46b64ab6>>
8+
* @generated SignedSource<<401cc11f57c0dbcdfeb500b3e2a606f7>>
99
*/
1010
namespace Slack\Hack\JsonSchema\Tests\Generated;
1111
use namespace Slack\Hack\JsonSchema;
@@ -24,7 +24,7 @@
2424
'last_name' => string,
2525
?'age' => int,
2626
?'~devices/' => vec<TFriendsSchemaValidatorItemsPropertiesNanDevicesNanItems>,
27-
?'enemies' => mixed,
27+
?'enemies' => null,
2828
?'rating' => vec<mixed>,
2929
?'contact' => vec<mixed>,
3030
?'empty_object' => TFriendsSchemaValidatorItemsPropertiesEmptyObject,
@@ -185,7 +185,7 @@ public static function check(
185185

186186
final class FriendsSchemaValidatorItemsPropertiesEnemies {
187187

188-
public static function check(mixed $input, string $pointer): mixed {
188+
public static function check(mixed $input, string $pointer): null {
189189
$typed = Constraints\NullConstraint::check($input, $pointer);
190190

191191
return $typed;

0 commit comments

Comments
 (0)