logs archiveIRC Archive / Freenode / #php / 2015 / November / 21 / 1
Korvin
I'm wondering if there's a specific reason
marchelly
sorabji, let me check this...
Korvin
phpPrime that code works all of a sudden if you call class_exists on FooAlias: https://3v4l.org/iqrGp
obviously because it triggers autoload
sorabji
why not have a use statement first?
phpPrime
Korvin, Well, class_exists specifically triggers the autoloader, unless you set the second argument to false, but there's no reason why a typehint would do that.
sorabji
it's common to use classes you expect to...use
Korvin
phpPrime I'm aware of the issue, I'm wondering why the typehint error wouldn't want to check autoload for this specific case?
phpPrime
Korvin, Because that's not the purpose of a typehint? A typehint enforces the type. It doesn't try to load the class.
gcds
marchelly: simple https://gist.github.com/gcds/60c065a266238edfe7a1
         

phpPrime
The autoloader is triggered when you actually use the class, not when you send an invalid type to a typed argument.
Komanda
from a compiled C program it's possible to see al the system calls being passed on to the cpu
Korvin
phpPrime but in this case it gives me an incorrect error
Komanda
is there something similair in the php ecosystem
phpPrime
Korvin, Sure, because you used the wrong type.
Korvin
so shouldn't it check if the hinted against class exists before letting you pass a wrong type?
phpPrime no I didn't, if php loaded the class it wouldn't be the wrong type
phpPrime
No, why should it?
Korvin
I'm not passing the wrong type
Bad_Advice_Cat
(Action) thinks Korvin's types should be interfaces.
phpPrime
Korvin, PHP won't load the class unless you try to use it.
sorabji
(Action) wonders why his reasonable suggestion of a use statement is being ignored
phpPrime
You didn't try to use FooAlias, you tried to pass Bar to a typed argument of FooAlias, two totally different things.
Korvin
sorabji i'm not looking for a fix, the fix is to not do this
I'm wondering if this should be supported
sorabji
then...
no, it shouldn't be
phpPrime
That's an abuse of an autoloader anyway.
sdwrage
Hey all. Trying to return my body tag and all of its contents back as html from DOMDocument: https://gist.github.com/sdwrage/24eb8bd0fa47275e5f52
marchelly
gcds, yes, thank you. this is great foreach example.
Korvin
phpPrime FooAlias is effectively the same as Foo and a parent of Br
Bar*
sdwrage
all I get back is an empty string
am I being an absolute idiot? lol
phpPrime
Korvin, Only because you're making it so inside of the autoloader.
That's the abusive part.
         

sdwrage
I know the string passed in is html
Korvin
phpPrime I don't know that I agree that it's abusive
I agree that it's a stupid case
phpPrime
You're trying to solve an XY problem here. Y doesn't work they way you expect it to. So don't try to use it to solve X.
Korvin
but I disagree that it's somehow abusive to alias the class when it's used
evilgohan2
alright phpPrime
made some changes
phpPrime
"abusive to alias the class from inside of the autoloader"
Big difference.
Korvin
phpPrime while I agree, I think this is an unintuitive result
evilgohan2
http://pastebin.com/aaeTAt4L
Am I using "goto" properly?
Korvin
I was asking in here to feel out whether I should post to internals
I'm going with no
evilgohan2
It's not throwing an error or a warning, but I want to ask just to be sure.
Korvin
We don't actually use this code, this was just a bug I fixed that was caused by a sloppy dev
I just thought it was odd
phpPrime https://github.com/laravel/framework/blob/5.1/src/Illuminate/Foundation/AliasLoader.php
laravel does this
phpPrime
Yea, that's definitely trying to solve an XY problem. You're walking on thin ice.
Korvin
phpPrime open an issue ;)
phpPrime
Why, I don't have an issue.
evilgohan2
phpPrime: Did you mean me, or Korvin?
Korvin
he meant me
evilgohan2
ah
gcds
So nobody has any comments on this? :( I am kinda thingking if its worth doing it https://github.com/gcds/action_blocks_concept
phpPrime
gcds, What exactly are you wondering is worth doing?
Your readme doesn't actually tell me anything useful.
gcds
library for this kind of pattern
phpPrime
What kind of pattern is that?
A command pattern?
gcds
I dont know I could not find something similar...
Korvin
I don't think it's a command pattern phpPrime because he's not passing anything in right?
gcds
It just popped in my head
Korvin
It's more like an operation queue
gcds
as doing thing in order passing values arround
phpPrime
Well if you can't explain it, I'm not sure what input I can give.
gcds, So it's a queue?
gcds
for e.g. if ActionInterface is passed as argument to another it will be resolved before giving
action queue
maybe
Idea to have higher level code than bunch of code
https://gist.github.com/gcds/57d43613554590bf9152 this was idea before cncept
phpPrime
What purpose does that serve?
gcds
DRY :)
phpPrime
How does that imply DRY, exactly?
Korvin
gcds it looks neat, but I think it'd be better if it was a pipeline
gcds
KISS I think to make it less wirting
to not repeating code over and over :)
Korvin
It doesn't look like there's any reason to have SequalAction
gcds
Korvin: yeah I thought about it in the end
Korvin
it's just a manager that lets you run the actions
gcds
Korvin: to do pipeline just need to do action for it
Korvin
I think it's not super compelling without that functionality
gcds
Korvin: and sequal now I remember is because executor only accepts one action
phpPrime
gcds, I think you misunderstood what I said. I wasn't asking you what DRY means. I was asking how this code is going to help me not repeat myself?
Korvin
I can see building factory objects that use actions to return an instance, but that only makes sense if it's a pipeline
keptek
does copy() return false if the file has been corrupted on the copy? or should i check the hash before and after copy
gcds
phpPrime: it will save you much code of lines
phpPrime
Yea, telling me what it will do isn't answering the "how" part of my question.
Korvin
phpPrime don't make him justify that this reduces the amount of code you write
if you're not using actions and instead writing these things out, using this pattern will help you not repeat yourself certainly
phpPrime
Korvin, I wasn't asking for justification. I was asking for an explanation. Justifying would it imply that I already understand how it works.
Korvin
if you're already using a good pattern and not repeating yourself, nothing is going to help you repeat yourself less
« prev 1 2 3 4 5 6 7 8 9 10 11 12 13 next »