« first day (1723 days earlier)      last day (3211 days later) » 

12:02 AM
@RonaldUlyssesSwanson fixed via git.php.net/…
 
but good night now ^^
 
 
3 hours later…
2:47 AM
i am getting error when connection ftp in eclipse
option failure due to network I/O
java.net.SocketException
Connection reset by peer
socket write error
 
use phpstorm, or netbeans? eclipse is history
 
3:30 AM
i am using this $xml->getElementsByTagName('li') as $li in foreach but how can traverse it using index number
 
3:49 AM
@santosh
$elements = $xml->getElementsByTagName("li");
for($x = 0; $x < $elements->length; $x++)
echo $elements->item($x)->textContent;
 
@RonaldUlyssesSwanson $xml->getElementsByTagName("li")->item(0)->nodeValue; why this is not working
 
define not working
does it give an error?
 
it not showing any output
 
because nodeValue returns null for Element nodes
you should be using textContent
 
@RonaldUlyssesSwanson huh?
nodeValue is a property of DOMNode
It doesn't return anything. It's always initialized as the DOMNode's text value.
 
4:01 AM
well, i've just reported what mdn says
i haven't tested it
i usually use textContent for element nodes
 
@RonaldUlyssesSwanson @Sherif now i got confused whats the truth
 
@santosh looks like your problem is somewhere else
probably the <li> element is empty
 
@RonaldUlyssesSwanson i will send you the detail just min
 
@Sherif btw, you are assuming DOM is well designed :P there's a bunch of methods/props defined in a super type that are unused / don't make sense in child classes
hopefully dom4 will fix the madness
last time i checked the spec it looked fine. they aren't adding anything, mostly removing legacy stuff and improving stuff that before was extremely verbose
 
4:24 AM
@RonaldUlyssesSwanson I think I understand your confusion here. You're looking at the DOM level 2 spec. Which does actually specify a null value for DOMElement. But PHP doesn't implement DOM level 2. It's level 1.
I had to go back and dig through the spec to find this but...
> The attributes nodeName, nodeValue and attributes are included as a mechanism to get at node information without casting down to the specific derived interface. In cases where there is no obvious mapping of these attributes for a specific nodeType (e.g., nodeValue for an Element or attributes for a Comment), this returns null. Note that the specialized interfaces may contain additional and more convenient mechanisms to get and set the relevant information.
This part is a bit ambiguous at the end where it says "Note that the specialized interfaces may contain additional and more convenient mechanisms to get and set the relevant information."
So I suppose PHP is just adding a specialized interface to translate nodeValue down to textContent.
But otherwise you're right.
 
@Sherif it's what i meant. also HTMLDOM was notoriously different from plain DOM
means that in browsers HTMLElement may behave different from Element
 
Sure, the HTML and XML parts do tend to behave differently. That's why I usually ask if the person is using XML or HTML first before I try to debug DOM issues.
 
especially for backwards compatibility i believe. but yeah, it's a mess
not a php fault, for once :P
 
@RonaldUlyssesSwanson Yea, that would be the "specialized interfaces" part.
That part of the spec was pretty ambiguous so a lot of implementations ended up creating their own strange interfaces.
I only recall this because I remember fixing a similar complicated bug in a hacked up Java DOM parser that wasn't relying on stdlib.
I spent hours digging through the specifications to figure it out.
 
i can imagine, it's just as bad in browsers' DOM. even in modern browsers there are infinite inconsistencies :(
 
4:36 AM
Welcome to the World Wide Web
Anything can happen out here!
 
unrelated: sometimes i get irrationally upset about problems that should be fixed/features that would be nice to have that are very little important or even just cosmetic
i just found an illustrator bug that apparently is there since CS2
pisses me off so much
 
Well, you know business do prioritize since there objective is to make money.
Nice to have doesn't always get you the biggest bang for you buck ;)
 
yeah, i know i'm being irrational :P still i can't avoid to get upset :D
 
But then again, bugs are hard stuff :/
http://t.co/KEM72sfFPO
 
example for php: pisses me off that i can explicitly call $obj->__clone() or $obj->__destruct() or even $obj->__construct()
 
4:43 AM
You're damned if you do... damned if you don't pretty much
@RonaldUlyssesSwanson Why does that piss you off? If they're public methods and then it makes perfect sense that you can call them.
They have public visibility.
heh
If you declared the as private, then that's a totally different discussion.
 
let's not consider __construct() for a moment. if you call $x->__clone() or __destruct() you almost certainly will screw things up
 
Then don't call them?
At that point you screwed it up. Not PHP.
 
and that makes me think, why is having to write protected function x(){} more important than allowing that? i mean. i could make everything public and just not call the methods, using the same logic
 
You could
But do you really want a private __construct?
heh
 
nope, i just don't want it to be called 2+ times
 
4:48 AM
Then don't call it.
 
It's not like it's impossible for you to prevent someone from calling your method twice, but why on earth would the language make such a broad assumption about your utility?
 
it's not a broad assumption. if you don't consider js, which is "special", i don't think do exist other languages that allow you to call the constructor twice
maybe python, but not sure actually
python is special too :P
 
@RonaldUlyssesSwanson You don't think there exist any other languages that allow you to call a public method more than once?
You literally just named every language in all of existence
heh
There, now stop blabing
 
ahaha, i repeat, i know it's not important :D
Foo x = new Foo(); x.Foo(); // java
@Sherif would never do that :P
 
4:54 AM
@RonaldUlyssesSwanson But you would do $foo->__construct()?
 
i wouldn't either, but the language shouldn't allow it
 
Why not? It's a public method.
Nothing in the language design says you aren't allowed to call a public method more than once.
There is no justification for the language preventing it.
To create such a narrow restriction would undermine other people's broader use of the language with no technical justification whatsoever.
 
__construct is not part of the interface
 
What interface?
 
would you write interface A{ function __construct(int $x, string $y); } ?
it's a method that shouldn't be part of the object
(actually it's not even a "method")
 
5:00 AM
Well, it is. Whether or not it should be is a totally different discussion.
The fact of the matter, though, is that it is and as such it follows all the same rules.
Just because PHP magically calls that method for you doesn't mean it's not a method.
This part goes back to how shit was implemented in PHP 4 though.
 
it doesn't follow the rules strictly, a sign that isn't a method:
class A{ function __construct(int $a){} }
class B extends A{ function __construct(string $b){} } // the signature doesn't need to be compatible
 
Sure it does.
Try running that code.
 
:P have you tried it?
 
It should give you an E_STRICT, no?
 
nope
and it's correct, how it should be
 
5:05 AM
Ah, right scalars were PHP 7
I was thinking PHP 5
 
that's not the point
 
What is your point?
 
class A{ function __construct(ArrayObject $a){} }
class B extends A{ function __construct(SplObjectStorage $b){} }
 
It's that __construct doesn't bother to check the signature?
Someone fucked up.
 
yes, just saying that it's a sign that the constructor is not part of the interface
why?
it's totally correct
 
5:07 AM
Not sure what interface you're referring to here.
Magic methods are ... well ... magical
 
another example
 
I'm still dying to figure out what this interface is you keep referring to.
 
What contract?
 
5:09 AM
Giving me a synonym for the word I already understand isn't helping me understand to what is the subject of this object.
I understand what an interface is. I'm asking you to which interface are you referring.
 
the set of methods you will expect to have when you pass something to something else, checking its type
 
Could you try to be a little more vague please? I'm understanding you all too perfectly.
Are you trying to say that the contract between magic methods doesn't include visibility?
 
i'm not being intentionally vague, i'm struggling explaining it man :P
i'll tell you another example, maybe it helps explaining my point
 
I think you giving me arbitrary examples and ignoring the directness of my pointed question is exactly what's not helping me understand your point.
 
it's not simple, i'm trying my best
 
5:14 AM
I'm just trying to get to the precipice of this point you're making. Are you saying that magic methods should not adhere to the visibility rules of other methods in the class?
 
moin
 
Alright, well while you gather your thoughts I'm going to go see a pot about a coffee.
 
just saying that should have a different treatment @Sherif a constructor is not a method, it's a function that constructs an instance
 
a constructor is a method
it's a certain type of method, but definitely a method ... it's as much a clause of the contract the object fulfils as any other method is, it just works differently ...
 
for me a method is something you can do with an already constructed instance
 
5:18 AM
Hi all, a quick question...
A client wants to make his users have shortened urls (with the short domain he bought) when they post something on his PHP website. Also wants to track, blacklist etc too. Anyone worked on something like this before or any ideas on how to approach this?
 
already constructed = in the sense of being in a valid state
 
@RonaldUlyssesSwanson okay, but, from the perspective of the engine (for whom the constructor was written), the object is already allocated and initialized before the constructor is called ...
 
@JoeWatkins not strictly speaking of how php works internally, just struggling to make a point with @Sherif :P
@JoeWatkins we were talking of allowing $x->__construct() $x->__clone() or $x->__destruct()
they are special, that shouldn't be allowed
 
@RonaldUlyssesSwanson I guess then you're not talking about __construct(), but the concept of constructor in general, which actually isn't necessarily a method of a class, but a mechanism of allocating and initializing an object.
 
5:23 AM
PHP's __construct() is a higher level method than what would traditionally be a constructor in the sense of initiailization.
So what you're saying doesn't really apply to __construct()
PHP is doing the construction for you (i.e. the allocation and initialization part), through the new keyword and then calling on your class's magic __construct() method for you to do additional initialization of the instance.
 
@RonaldUlyssesSwanson you would break parent::__construct/parent::__destruct by disallowing the programmer to call ctor/dtor
 
maybe it doesn't apply, but the result is kind of bad, and that's the actual problem... @Sherif
 
@RonaldUlyssesSwanson But why is the result bad? What's bad about it specifically?
 
__clone does do strange things when you call it directly rather than with operator
 
@Ekin Sounds pretty trivial. You generate some random token for each url and reference the redirect url in your database then send a Location header. What part are you having trouble with?
@JoeWatkins Well then stop calling it directly :p
 
5:28 AM
yeah, it seems simple enough to me @Sherif ...
don't do bad things, or bad things will happen ....
 
I mean, I don't actually know of anyone that intentionally calls on magic methods in their code or even has a valid use case for doing so.
I doubt this is an actual problem to be concerned about.
 
IIRC a use case was found (probably marcus wrote it) that meant we couldn't change how __clone works ...
 
A use case for calling on __clone directly?
Do spill.
 
yeah, I could be wrong, but it was discussed I think for 7
 
Sounds like voodoo
 
5:30 AM
because makes me think any other encapsulation effort is useless. again, with the same logic you could have everything public and just not call it. why would i bother to have perfect visibility and things when objects could break anyway? @Sherif
 
marcus specializes in voodoo
a usecase doesn't have to be sensible remember, just has to be out there and being used ...
/me goes to walk dogs
 
@Sherif Actually you just cleared the clouds for me, thanks!
 
@RonaldUlyssesSwanson That's not the same logic. You're conflating two different ideologies here. One is that magic methods are intended to be called by the engine directly, but are user defined. So typically people don't make a habit of calling on them directly, nor is it recommended to do so. The majority of people seem to be OK with that since I don't hear anyone complaining (sans yourself). The other is that you can actually set the visibility on these methods just like any other method.
So, here, to say that one logic builds on the other is wrong. Since they do exist on parallel plains. Or, in other words, you can have private __construct just like you can have private myMethod, and the reason behind one does not chase the tail of the other.
You want most of those magic methods public, even though you can make them protected or private if you really wanted to, because the majority of the time they are being called from a public context.
 
the visibility to the engine, not to a direct call, imho. but really, i know it's trivial and i'm not even complaining actually. again i'm just being pedantic. i would like php to be a bad ass programming language that is sensible on every aspect of it
 
That doesn't mean you should be calling them directly yourself in your own code though.
@RonaldUlyssesSwanson And how exactly is it insensible in this regard?
 
5:38 AM
@JoeWatkins I thought you could examine the call context and determine if the call was being made within a class context, so you could disallow $object->__destruct() while still allowing parent::__destruct().
 
That's the part I'm still having difficulty understanding. How would you propose to make it more sensible as you say?
 
will it break things? it's insensible
 
@RonaldUlyssesSwanson That's the problem. You don't know that it will. It may... It may not... For the language to make such broad assumptions is to paint itself in a corner.
 
$x = new ImmutableStuff(30);
// ... later on
$x->__construct(40); // pwned
 
That's not any more sensible.
 
5:39 AM
also __destruct will almost certainly break things, and so does __clone
 
@RonaldUlyssesSwanson Right, because every class every person ever wrote in PHP is an immutable object and every person using it is explicitly calling the __construct method in their code in order to prove that PHP sucks.
 
clone call was disallowed till 5, now it's allowed. don't know why
 
You make an excellent case :)
You picked a subset of a subset of a subset of a problem and used that as your basis for making PHP a "bad ass programming language that is sensible on every aspect"?
Certainly you can do better than that ;)
You remind me of the ramblings of "A Fractal of Design"
Basically someone that spent an inordinate amount of time finding every problem in every nook and cranny in PHP and used that list of problems to prove to every one that PHP sucks. Then blogged about it using his PHP blog software.
 
listen, i think i've kinda made my point. i give up :P
 
What was the point? That doing stupid things is stupid and that PHP sucks if it doesn't try to prevent everyone from doing stupid things?
You can't fix stupid. In the process you will break smart.
 
5:43 AM
@Trowski everything is possible
 
@RonaldUlyssesSwanson Not that we necessarily should disallow it though.
 
That is the irony of trying to fix stupid.
Just don't be stupid and let other people worry about themselves :)
 
> let's not consider __construct() for a moment
 
And yet __construct() was the premise of your entire argument.
 
my argument was mainly about __call and __destruct, actually
 
5:47 AM
Really? Because all the examples you gave me included __constructor()
But what about them?
I mean, your only problem is still that you would have to be the one calling them directly in your code and the resulting fsck is a result of your logic being screwed up.
If you really wanted to prevent this from happening I already showed you how it's possible without modifying the language.
 
i've already answered that
 
Yes, and I've already addressed why what you're saying doesn't make PHP stupid in any way shape or form.
It just makes the person doing that stupid.
 
i didn't say php is stupid
 
And you can't keep a monkey from throwing his own feces.
Even in Java you can override init. So every language gives you enough rope to hang yourself.
What's your point?
 
> Even in Java you can override init
what?
 
5:49 AM
You've never seen @Override before?
 
how is that related to what i'm saying?
 
Because you have just as much opportunity to hang yourself in other languages.
The point is just don't do it and you'll be fine.
 
java doesn't allow you to call the constructor twice:
Foo x = new Foo();
x.Foo(); // symbol not found
 
Sure, but there are ways to trick it if you really wanted to :)
 
the only way to do nasty stuff in java is using reflection, and it's still nearly impossible to break things
 
5:52 AM
Which is my point. Java didn't actually prevent you from doing something stupid there. It just prevented you from doing one thing stupid.
lol
It is very much possible to break things in Java. Do you want to see how much broken Java code I have dealt with over the years?
 
you are making it bigger than even i think it is @Sherif i didn't want to start this :P
 
I'm not making anything big at all.
I'm merely demonstrating to you how what you are actually complaining about isn't what you think it is.
Your point is very narrow and pointed and you're grasping at straws by trying to use all of these uncorrelated examples that actually have nothing to do with the real problem.
 
i'm really aware that's really not important man, i promise :D
 
The real problem is that you found out that you can shoot yourself in the foot.
That problem exists in every language.
Then what is important?
 
but php should do its best whenever it is possible
that's important
and with priorities
 
5:55 AM
Sure, I agree and I think that it is doing its best. I haven't heard anyone really complain about this as being something of a nuisance to them.
So I really don't think that PHP is beneath its best in this regard.
You know, because all those people out there that are always calling on $foo->__construct(); just really want PHP to stop being so "not its best" :p
Come on. You know your point was completely centered around shooting yourself in the foot.
There is no way on earth you can tell me you've used a language that doesn't let you do that.
Just because you can do something doesn't necessarily mean you should. Consequently, just because you shouldn't do something doesn't mean that the language shouldn't allow you either.
I find that those are two very important concepts to consider carefully before trying to change the language.
 
lol. but again why did php bother of having method visibility, or type checking, if you rely on people being smart or pedantic about the code they write, you are screwed. the language should do the dirty job imho
 
Again, you are conflating two parallel ideologies here.
 
and just disallow them to do nasty things
 
One has nothing to do with the other even though one may be used along with the other.
 

« first day (1723 days earlier)      last day (3211 days later) »