Comments (12)
Kahlan stubs on php functions works only when you test psr0 / psr4 classes - it mocks composer autoloader. So it will not work with functions
In this case, we can simply create a class with static methods instead of separate functions.
Should we move the conversation to #2 ..?
UNRELEATED: are we all in Poland? :-)
I am. Dunno about you folks :)
Wrocław here (although I'm Italian).
from zubr.
Gdańsk here
from zubr.
The thing that bothers me in PHP: convention of "segments" order in a function name.
Eg. there's urldecode()
and parse_url()
. First one is in format: $SUBJECT$ACTION, second in: $ACTION_$SUBJECT.
If it makes sense I'd like to unify this to a common format: $SUBJECT_$ACTION(). This would result in renaming parse_url()
to url_parse()
.
What do you think about it?
from zubr.
I see what you mean, and I agree that it's not great.
I think however that we should keep function names the same, so that one doesn't have to relearn the language. What I mean is that if I know PHP's build-in function is strpos
, I can expect its equivalent to be \PHP\str_pos
, and for parse_url
I'd expect it to be in \PHP\parse_url
, not \PHP\url_parse
.
My idea is to create a wrapper to PHP build-in functions that changed as little as possible, so that it can be very intuitive to use. I do think that we can use aliases, but they should probably be used as little as possible.
What do you think instead of the concept of plugin? We could have something like this, in this case a plugin called "fix-common-format" let's say, that fixed all the functions by doing:
\PHP\PHP::addAlias('url_parse', function($url) {
return parse_url($url);
});
Then we could use magic methods to catch url_parse
and call the function provided by the plugin. Just an idea but it would allow to "pick" fixes that one is interested in, and would allow adding many aliases without "polluting" regular names.
from zubr.
I think however that we should keep function names the same, so that one doesn't have to relearn the language. What I mean is that if I know PHP's build-in function is strpos, I can expect its equivalent to be \PHP\str_pos, and for parse_url I'd expect it to be in \PHP\parse_url, not \PHP\url_parse.
Good catch. It makes sense to keep the naming as you suggest.
What do you think instead of the concept of plugin? We could have something like this, in this case a plugin called "fix-common-format" let's say, that fixed all the functions by doing:
I'd say that we shouldn't complicate things. If the library is meant to be a wrapper with sane functions API it should stay that way.
Plugins may be next step, but definitely not now.
from zubr.
Plugins may be next step, but definitely not now.
I agree.
I think the priority is consistent naming (underscore) and argument order. We should tackle consistent error reporting as well (returning false vs. throwing exception vs. doing nothing), but perhaps in the future.
Do you have anything to add to the guidelines? I think it's us 2 so far, let's do this! :-)
from zubr.
IMO theses Guidelines are enough to start.
from zubr.
OK.
I'll add some more functions today. Would you want to feel like creating a stub for tests?
from zubr.
@nkkollaw I tried to add Kahlan yesterday. But Kahlan stubs on php functions works only when you test psr0 / psr4 classes - it mocks composer autoloader. So it will not work with functions :(
from zubr.
@ddziaduch : that sucks, but thanks for trying.
Perhaps we can create a wrapper class, that simply calls our function(s)?
UNRELEATED: are we all in Poland? :-)
from zubr.
Kahlan stubs on php functions works only when you test psr0 / psr4 classes - it mocks composer autoloader. So it will not work with functions
In this case, we can simply create a class with static methods instead of separate functions.
UNRELEATED: are we all in Poland? :-)
I am. Dunno about you folks :)
from zubr.
Closing this as we've established that guidelines in the README are enough to start.
from zubr.
Related Issues (20)
- Double-check Composer file
- `array_column` PSR2 errors
- Doc block guidelines HOT 7
- Slack
- Zubr isn't bundled with PHP HOT 4
- Implement validator tool HOT 2
- Automate adding functions and tests HOT 11
- xxxx
- Add test for array_count_values()
- array_change_key_case() has wrong default value
- array_change_key_case() has wrong doc format
- array_chunk() has wrong doc format
- array_chunk() has wrong doc format HOT 1
- array_combine() has wrong doc format
- Add test for array_fill_keys()
- Add test for array_fill()
- Add test for array_flip()
- Add test for array_keys()
- Remove dist folder? HOT 6
- Add a performance readme entry HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zubr.