Skip to content

Commit

Permalink
Helpers: uses Validator::isTypeDeclaration()
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Mar 13, 2023
1 parent 43d6101 commit b9ca0b4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
],
"require": {
"php": ">=8.0 <8.3",
"nette/utils": "^3.2.7 || ^4.0"
"nette/utils": "^3.2.9 || ^4.0"
},
"require-dev": {
"nette/tester": "^2.4",
Expand Down
11 changes: 1 addition & 10 deletions src/PhpGenerator/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,7 @@ public static function validateType(?string $type, bool &$nullable): ?string
{
if ($type === '' || $type === null) {
return null;
}

if (!preg_match(<<<'XX'
~(?n)
(
\?? (?<type> [\w\\]+)|
(?<intersection> (?&type) (& (?&type))+ )|
(?<upart> (?&type) | \( (?&intersection) \) ) (\| (?&upart) )+
)$~xAD
XX, $type)) {
} elseif (!Nette\Utils\Validators::isTypeDeclaration($type)) {
throw new Nette\InvalidArgumentException("Value '$type' is not valid type.");
}

Expand Down

0 comments on commit b9ca0b4

Please sign in to comment.