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
Possible improvements #149
Comments
I love the idea of constants. To be honest, this is exactly why I am here, as I wanted to create a similar issue. I can make a PR just let me know what are your thoughts @lstrojny? $getRegion = compose(
$selectAdministrativeBoundary,
$sortByPlaceRank,
'Functional\first' // <--- This is ugly as hell :(
);
$getRegion = compose(
$selectAdministrativeBoundary,
$sortByPlaceRank,
Functional::FIRST // <--- This is art, java-like syntax
); |
I very much like the idea to use constants for convenient indirection, that indeed looks very nice. I would love to see a PR. Bonus points if the constants table is either automatically generated or introspected for completeness in a test. |
On MortalFlesh/CallbackParser: one of my goals (which should probably be explicitly stated) with this library is to support functional programming in PHP using standard PHP functionality. In DSL terms: an internal DSL if you like, not an external DSL. MortalFlesh/CallbackParser is cute but it goes to much into external DSL and I still have high hopes that we get short array functions in PHP eventually 😄 Closing this issue since the constants table has been introduced, thank you for that. |
Hey I really like this library. I'm quite interesting in functional programming and this is much help in PHP :) But since I quite know php and its "bad parts" I came up with few possible improvements, if you were interested.
For example, if you need to pass one of your functions (or any other) as a parameter, you need to do it by its
fully qualified name
(instring
) which sucks. So I tried to useconstants
to keep myfully qualified name
in reusable value: https://github.com/MortalFlesh/php-query-builder-composer/blob/master/src/functions.php#L9-L17 - this saves me a lot of pain (typos, remembering all names) it would be much nicer, if suchconstants
could be camel case and not upper case (byPSR2
) but this is still quite big help. So I though about a single final class, which would hold all function names in constants and could be used as:Constant with
fully qualified name
could also be right in file where function is declared. And it would be my pleasure to contribute by this idea to your library if you finds it helpful.And even more to callbacks, I have this little library https://github.com/MortalFlesh/CallbackParser which allows to have callbacks in strings and saves some awful function syntax for small and easy callbacks. Such as:
The text was updated successfully, but these errors were encountered: