- Notifications
You must be signed in to change notification settings - Fork6
Wrapper library to fix inconsistencies in PHP's core functions
License
nkkollaw/zubr
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
PHP is great and Composer, PHP-FIG, and all the different frameworks make it even greater. However, there is still legacy stuff in the language itself that makes PHP harder to use than it should be (seehttp://phpsadness.com/ for one of many lists).
Zubr is a wrapper library to fix inconsistencies in PHP's core functions. It wraps PHP's built-in functions and attempts to fix a few things—starting with consistent naming, order of arguments, and more.
For instance, from:
parse_url()urlencode()
to:
\Zubr\parse_url()\Zubr\url_encode()
and even:
htmlentities()html_entity_decode()
to:
\Zubr\html_entity_encode() // alias to htmlentities(), \Zubr\html_entities()\Zubr\html_entity_decode()
Functions always have the same name as the built-in ones, but they follow the same set of rules. Zubr is intuitive to use, because function names are predictable and similar to the ones you're used to.
Zubr's idea came from commenting this HN post:https://news.ycombinator.com/item?id=14883784
We're ignoring PHP < 7.0.0. Any function that is deprecated and not included in PHP 7.0.0 won't be found in Zubr.
See:http://phpsadness.com/sad/4
We always use snake_case.
See:http://phpsadness.com/sad/15
We add aliases usingmicro
instead ofu
(which sometimes meansuser
).
We add aliases usinguser
instead ofu
(which sometimes meansmicro
).
See:http://phpsadness.com/sad/48
We add aliases usingto
instead of2
.
See:http://phpsadness.com/sad/9 and similar.
We always put the subject first, then the keyword ($haystack
first, then$needle
).
For example, you'd say "searchGoogle fordog" (which means "search$subject
for$keyword
").
Most PHP functions already follow this convention.
See:http://phpsadness.com/sad/6
We always put the callback last.
Note: If the parameters given to a function are not what it expects, such as passing an array where a string is expected, the return value of the function is undefined. In this case it will likely return NULL but this is just a convention, and cannot be relied upon.http://php.net/manual/en/functions.internal.php
We'd like to fix the above in > 1.0 releases.
Version 1.0 will contain all of PHP'score built-in functions.
We might then go on to implement a private plugin system to addbundled extensions in 2.0, and make the plugin system public so that anyone can implement wrappers toexternal extensions in version 3.0.
We have detailed milestones with all features that will be implemented up to version 1.0 athttps://github.com/nkkollaw/zubr/milestones.
Pull requests are welcome.
Take a look at the CONTRIBUTING.md file.
Emails can be found in thecomposer.json
file.