Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The documentation for the <=> operator is missing #3922

Open
ericmorand opened this issue Dec 1, 2023 · 6 comments
Open

The documentation for the <=> operator is missing #3922

ericmorand opened this issue Dec 1, 2023 · 6 comments

Comments

@ericmorand
Copy link
Contributor

Except if I miss something, there is no documentation for the <=> operator even though it is mentioned in both Twig 2 and 3 documentation:

https://twig.symfony.com/doc/2.x/templates.html#expressions
https://twig.symfony.com/doc/3.x/templates.html#expressions

@smnandre
Copy link
Contributor

smnandre commented Dec 2, 2023

You're right, it is only mentionned on the page you linked and the sort filter page.

And it really is the direct equivalent of the PHP spaceship.

@ericmorand
Copy link
Contributor Author

The documentation of the has every and has some operators is also a bit scarce: they both seem to accept an arrow function but there is no mention of the fact that this function receives also the key:

The arrow function receives the value of the sequence or mapping:

I had to dig into the tests of TwigPHP to discover this.

https://github.com/twigphp/Twig/blob/3.x/tests/Fixtures/expressions/has_every.test

@smnandre
Copy link
Contributor

smnandre commented Dec 2, 2023

I guess you could submit a PR, with the content you think is missing ?
You would receive help

@ericmorand
Copy link
Contributor Author

ericmorand commented Dec 2, 2023

Well, I don't know anything about these operators, so I can't submit any PR.

Besides, the people that wrote the PHP implementation did have access to the internal documentation / specification of those operators, so it should be easier to just publish these documents so that we can write the "user friendly" documentation from them.

What do you think?

@smnandre
Copy link
Contributor

smnandre commented Dec 2, 2023

I'm happy some people worked to produce all the code of this package and i'm grateful for it

Source code & implementation

Details

So..

  • the spaceship ( <=> ) is the same as in PHP. In fact, it is the PHP one.
  • has some and has every are the equivalent of their Javascript equivalent: Array.every Array.some

@stof
Copy link
Member

stof commented Dec 4, 2023

@ericmorand There is no hidden internal specification document that we could publish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants