Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.8k
[Config] Fix array shape generation for backed enums#62563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:7.4
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
07f5138 to0879077Compare| $values =array_column($enumFqcn::cases(),'value'); | ||
| returnimplode('|',array_map(staticfunction ($value) { | ||
| return\is_string($value) ?'"'.$value.'"' :$value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| return\is_string($value) ?'"'.$value.'"' :$value; | |
| return\is_string($value) ?var_export($value,true) :$value; |
"test will become""test"," must be escape, so i thinkvar_export is good solution for it, but it using' to wrap string, or maybeaddslashes($value, '"') but i dont really like it
Ref:https://phpstan.org/r/924d234a-ce8c-46e4-9374-ff940704394d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
updated
| case Foo ='foo'; | ||
| case Bar ='bar'; | ||
| case Bar ='bar baz'; | ||
| case Qux ='"test"'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Not sure if should check for such edgecase
116a0ef to12fa494Compare
Uh oh!
There was an error while loading.Please reload this page.
Spotted insymfony/ai#1013 ➡️https://github.com/symfony/ai/actions/runs/19780810683/job/56680686767?pr=1013
It works for
redis, but not forpostgres, becauseredisis using->values(Distance::cases())andpostgresis using->enumFqcn(PostgresDistance::class):Redis
Enum
Config
RESULT
* redis?: array<string, array{// Default: [] * connection_parameters?: mixed,// see https://github.com/phpredis/phpredis?tab=readme-ov-file#example-1 * client?: string,// a service id of a Redis client * index_name: string, * key_prefix?: string,// Default: "vector:" * distance?: \Symfony\AI\Store\Bridge\Redis\Distance::Cosine|\Symfony\AI\Store\Bridge\Redis\Distance::L2|\Symfony\AI\Store\Bridge\Redis\Distance::Ip,// Distance metric to use for vector similarity search // Default: "COSINE" * }>,Postgres
Enum
Config
RESULT
* postgres?: array<string, array{// Default: [] * dsn?: string, * username?: string, * password?: string, * table_name: string, * vector_field?: string, * distance?: cosine|inner_product|l1|l2,// Distance metric to use for vector similarity search // Default: "l2" * dbal_connection?: string, * }>,you can see, that the result is different:
FQCN:
distance?: \Symfony\AI\Store\Bridge\Redis\Distance::Cosine|\Symfony\AI\Store\Bridge\Redis\Distance::L2|\Symfony\AI\Store\Bridge\Redis\Distance::Ip,vs. strings:
distance?: cosine|inner_product|l1|l2,Why?