nelmio / alice

Expressive fixtures generator
MIT License
2.5k stars 329 forks source link

Nested functions errors #1144

Open ZhukV opened 1 year ago

ZhukV commented 1 year ago

I try to use nested functions in my fixtures and receive error.

Fixture:

data: '<calculateFeeActionData("ababab", "acacac", <money("USD", "100.02")>)>'

Error:

Nelmio\Alice\Throwable\Exception\FixtureBuilder\ExpressionLanguage\MalformedFunctionException: The value "<money(__ARG_TOKEN__3518f8944d42212dd37daffe097d216e" contains an unclosed function.

The functions calculateFeeActionData and money presented by faker provider.

Full stack trace:

Nelmio\Alice\Throwable\Exception\FixtureBuilder\ExpressionLanguage\MalformedFunctionException: The value "<money(__ARG_TOKEN__3518f8944d42212dd37daffe097d216e" contains an unclosed function.

/code/vendor/nelmio/alice/src/Throwable/Exception/FixtureBuilder/ExpressionLanguage/ExpressionLanguageExceptionFactory.php:60
/code/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Lexer/FunctionTokenizer.php:116
/code/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Lexer/FunctionTokenizer.php:43
/code/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Lexer/FunctionLexer.php:52
/code/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Lexer/GlobalPatternsLexer.php:61
/code/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Lexer/ReferenceEscaperLexer.php:47
/code/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Lexer/EmptyValueLexer.php:41
/code/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Parser/SimpleParser.php:55
/code/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FunctionTokenParser.php:166
/code/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FunctionTokenParser.php:130
/code/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FunctionTokenParser.php:98
/code/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/IdentityTokenParser.php:74
/code/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/TolerantFunctionTokenParser.php:81
/code/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/TokenParserRegistry.php:65
/code/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Parser/SimpleParser.php:88
/code/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Parser/SimpleParser.php:58
/code/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Parser/StringMergerParser.php:45
/code/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Parser/FunctionFixtureReferenceParser.php:48
/code/vendor/nelmio/alice/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/SimpleValueDenormalizer.php:64
/code/vendor/nelmio/alice/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/SimpleValueDenormalizer.php:43
/code/vendor/nelmio/alice/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/UniqueValueDenormalizer.php:48
/code/vendor/nelmio/alice/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Property/SimplePropertyDenormalizer.php:39
/code/vendor/nelmio/alice/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/SimpleSpecificationsDenormalizer.php:144
/code/vendor/nelmio/alice/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/SimpleSpecificationsDenormalizer.php:102
/code/vendor/nelmio/alice/src/FixtureBuilder/Denormalizer/Fixture/Chainable/SimpleDenormalizer.php:74
/code/vendor/nelmio/alice/src/FixtureBuilder/Denormalizer/Fixture/FixtureDenormalizerRegistry.php:59
/code/vendor/nelmio/alice/src/FixtureBuilder/Denormalizer/Fixture/TolerantFixtureDenormalizer.php:42
/code/vendor/nelmio/alice/src/FixtureBuilder/Denormalizer/Fixture/SimpleFixtureBagDenormalizer.php:79
/code/vendor/nelmio/alice/src/FixtureBuilder/Denormalizer/SimpleDenormalizer.php:45
/code/vendor/nelmio/alice/src/FixtureBuilder/SimpleBuilder.php:38
/code/vendor/nelmio/alice/src/Loader/SimpleDataLoader.php:44
/code/vendor/nelmio/alice/src/Loader/SimpleFileLoader.php:46

Note: if I use function with one argument, all ok correctly.

theofidry commented 1 year ago

Until a fix (see #998) I would suggest a custom faker provider (see https://github.com/nelmio/alice/blob/master/doc/customizing-data-generation.md#custom-faker-data-providers)

d0niek commented 2 months ago

Hi @theofidry!

Any progress on it?

theofidry commented 2 months ago

No, and since there is a acceptable workaround it's far from being a priority to me atm.

d0niek commented 2 months ago

Oh.. please can you point me this "workaround"?

theofidry commented 2 months ago

https://github.com/nelmio/alice/issues/1144#issuecomment-1756897753