# |
Jun 14th 2018, 11:27 |
neon1024 |
@lorenzo I see, yeah, it’s an interesting idea |
# |
Jun 14th 2018, 11:27 |
josbeir |
its a subject that will probably give heated discussions if it was implemented in a framework like cake |
# |
Jun 14th 2018, 11:26 |
lorenzo |
Static is the same idea, but again placed into a class for no good reason other than grouping and auto loading |
# |
Jun 14th 2018, 11:26 |
lorenzo |
You can do that with composer, though |
# |
Jun 14th 2018, 11:26 |
lorenzo |
Only if you include the file @neon1024 |
# |
Jun 14th 2018, 11:25 |
neon1024 |
Are namespace functions always available? |
# |
Jun 14th 2018, 11:25 |
neon1024 |
How does this differ from static? |
# |
Jun 14th 2018, 11:24 |
lorenzo |
State would need to be passed as arguments, forcing you to basically come up naturally with the idea of dependency injection |
# |
Jun 14th 2018, 11:24 |
LubosR |
josbeir, ok :) thanks anyway |
# |
Jun 14th 2018, 11:24 |
josbeir |
yeah i just remembered @lorenzo but its pretty verbose, not sure if its a better way to handle the problem |
# |
Jun 14th 2018, 11:24 |
lorenzo |
Another example is middleware, actually. We wouldn’t have the serialization problem if middleware was only a function with no state |
# |
Jun 14th 2018, 11:23 |
josbeir |
@Lubors, yes i just saw that too in the code :slightly_smiling_face: |
# |
Jun 14th 2018, 11:23 |
neon1024 |
I see, sorry I didn’t know about the feature. http://php.net/manual/en/language.namespaces.faq.php#language.namespaces.faq.innamespace |
# |
Jun 14th 2018, 11:23 |
LubosR |
josbeir, neon1024: Thanks. Since 3.6 and splitted setters/ getters, should we have setConfigShallow and getConfigShallow? |
# |
Jun 14th 2018, 11:22 |
lorenzo |
Well, since 5.6 you can write functions una namespace. But there are really annoying limitations, like no auto loading |
# |
Jun 14th 2018, 11:22 |
josbeir |
agree with @lorenzo thats its just a dummy 'namespace' class but there's no 'clean' alternative imo |
# |
Jun 14th 2018, 11:21 |
josbeir |
not needed for validation (in the example above) |
# |
Jun 14th 2018, 11:21 |
neon1024 |
Wouldn’t that sacrifice the interface contract? |
# |
Jun 14th 2018, 11:21 |
lorenzo |
just have the functions in a namespace, and import them by namespace |
# |
Jun 14th 2018, 11:21 |
josbeir |
validator_comparison() ? |
# |
Jun 14th 2018, 11:21 |
josbeir |
in your validation example, what would be the 'clean' alternative in php? prefix your function names? |
# |
Jun 14th 2018, 11:20 |
lorenzo |
not necessarily, @josbeir. More about how we communicate APIs. Having classes opens up the possibility of having state, and state is quite often not needed at all. Like in the validation class |
# |
Jun 14th 2018, 11:19 |
josbeir |
you mean functional progreamming @lorenzo? |
# |
Jun 14th 2018, 11:19 |
lorenzo |
one example is the Validation class, all those functions were put inside a class just for grouping them, as if the Validation class were a namespace |
# |
Jun 14th 2018, 11:18 |
neon1024 |
@lorenzo Sorry, I don’t think I follow that. A class might existing in a different namespace than it’s named |
# |
Jun 14th 2018, 11:16 |
neon1024 |
OH, I mean `$this->setConfig('item.nested', 'foobar')` |
# |
Jun 14th 2018, 11:16 |
lorenzo |
Creating plain functions in php was frowned upon for a decade, but I now think that thinking was a mistake |
# |
Jun 14th 2018, 11:16 |
josbeir |
i mean, its just $this->configShallow($config- |
# |
Jun 14th 2018, 11:16 |
neon1024 |
If the bahviour implements the InstanceConfigTrait, you can use `$this->` :point_up: |
# |
Jun 14th 2018, 11:16 |
lorenzo |
It just php, but OO practices. Now I think that we are mostly using classes as autoloadable functions, and the class name is like the namespace of those functions. That makes me wonder if we should just create more namespaces functions instead of classes |
# |
Jun 14th 2018, 11:16 |
josbeir |
$this->setConfig($config, true) i think |
# |
Jun 14th 2018, 11:15 |
josbeir |
use shallowMerge Lubros |
# |
Jun 14th 2018, 11:15 |
LubosR |
When using defaultConfig with behavior, I can see the property is merged. Is there any nice way how to replace property instead of merge? |
# |
Jun 14th 2018, 11:15 |
josbeir |
and know how they work |
# |
Jun 14th 2018, 11:15 |
josbeir |
learning new languages is not a requirement in life, altho you should _know_ about them |
# |
Jun 14th 2018, 11:14 |
josbeir |
thats not a bad thing |
# |
Jun 14th 2018, 11:14 |
neon1024 |
I don’t know if I like it, as I have no real experience of any other language. I know PHP, so I use PHP. |
# |
Jun 14th 2018, 11:13 |
josbeir |
altho it has its flaws, i still like php a lot personally |
# |
Jun 14th 2018, 11:13 |
neon1024 |
Oh really? Which parts are those? |
# |
Jun 14th 2018, 11:13 |
neon1024 |
Perhaps I should do the same code kata in different lagnauges |
# |
Jun 14th 2018, 11:13 |
lorenzo |
unfortunately coding is haskell has confused me a lot. What I though it was bad in php now I think is good, and viceversa :( |