Skip to content

Commit

Permalink
Change order of conditions to please psalm
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN committed Jan 27, 2025
1 parent 9b29819 commit 97e7c86
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 60 deletions.
24 changes: 12 additions & 12 deletions generator/src/OperatorClassGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,18 @@ public function createClass(GeneratorDefinition $definition, OperatorDefinition
$constructorParam->setDefaultValue($argument->default);
}

if ($type->dollarPrefixedString) {
$namespace->addUseFunction('is_string');
$namespace->addUseFunction('str_starts_with');
$namespace->addUse(InvalidArgumentException::class);
$constructor->addBody(<<<PHP
if (is_string(\${$argument->propertyName}) && ! str_starts_with(\${$argument->propertyName}, '$')) {
throw new InvalidArgumentException('Argument \${$argument->propertyName} can be an expression, field paths and variable names must be prefixed by "$" or "$$".');
}
PHP);
}

// List type must be validated with array_is_list()
if ($type->list) {
$namespace->addUseFunction('is_array');
Expand Down Expand Up @@ -169,18 +181,6 @@ public function createClass(GeneratorDefinition $definition, OperatorDefinition
PHP);
}

if ($type->dollarPrefixedString) {
$namespace->addUseFunction('is_string');
$namespace->addUseFunction('str_starts_with');
$namespace->addUse(InvalidArgumentException::class);
$constructor->addBody(<<<PHP
if (is_string(\${$argument->propertyName}) && ! str_starts_with(\${$argument->propertyName}, '$')) {
throw new InvalidArgumentException('Argument \${$argument->propertyName} can be an expression, field paths and variable names must be prefixed by "$" or "$$".');
}
PHP);
}
}

// Set property from constructor argument
Expand Down
16 changes: 8 additions & 8 deletions src/Builder/Accumulator/AccumulatorAccumulator.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/Builder/Accumulator/LastNAccumulator.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/Builder/Accumulator/MaxNAccumulator.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/Builder/Accumulator/MinNAccumulator.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/Builder/Accumulator/PercentileAccumulator.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/Builder/Expression/AllElementsTrueOperator.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/Builder/Expression/AnyElementTrueOperator.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/Builder/Expression/ArrayElemAtOperator.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/Builder/Expression/ArrayToObjectOperator.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/Builder/Expression/FilterOperator.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/Builder/Expression/FirstNOperator.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 97e7c86

Please sign in to comment.