@@ -36,9 +36,9 @@ discard block |
||
| 36 | 36 | \preg_match(self::REGEX, $type, $matches, PREG_UNMATCHED_AS_NULL); |
| 37 | 37 | $this->callback = (string) ($matches['callback'] ?? null); |
| 38 | 38 | $this->customType = (string) ($matches['customType'] ?? null); |
| 39 | - $this->emptyNullable = ! ! ($matches['emptyNullable'] ?? false); |
|
| 40 | - $this->iterable = ! ! ($matches['iterable'] ?? false); |
|
| 41 | - $this->nullable = ! ! ($this->emptyNullable || ($matches['nullable'] ?? false)); |
|
| 39 | + $this->emptyNullable = !!($matches['emptyNullable'] ?? false); |
|
| 40 | + $this->iterable = !!($matches['iterable'] ?? false); |
|
| 41 | + $this->nullable = !!($this->emptyNullable || ($matches['nullable'] ?? false)); |
|
| 42 | 42 | $this->type = (string) ($matches['type'] ?? 'mixed'); |
| 43 | 43 | $this->isPhpType = \in_array($this->type, self::TYPES, true); |
| 44 | 44 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | public function castValue($value) |
| 80 | 80 | { |
| 81 | 81 | // Immediately return if nullable or empty. |
| 82 | - if (($this->nullable && $value === null) || ($this->emptyNullable && ! $value)) { |
|
| 82 | + if (($this->nullable && $value === null) || ($this->emptyNullable && !$value)) { |
|
| 83 | 83 | return null; |
| 84 | 84 | } |
| 85 | 85 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | Normalize::setType($value, $this->type); |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - return $this->emptyNullable && ! $value |
|
| 129 | + return $this->emptyNullable && !$value |
|
| 130 | 130 | ? null |
| 131 | 131 | : $value; |
| 132 | 132 | } |