« first day (432 days earlier)      last day (4509 days later) » 

2:00 PM
@ircmaxell i cant follow you
 
@JamesButler @ircmaxell thanks for commenting! checking it out now
 
One step closer to "Pundit"
Well.. Step 1 of 10 to be exact :)
 
eih
 
@ircmaxell I didn't follow you ether on that const instance variable thing btw.
 
hum, nobody is getting @ircmaxell ^^
 
2:16 PM
@edorian Basically, when you do const foo = "bar";, it can't be changed. But you could also do const foo = new bar();...
@NikiC I'm not sure I'm getting myself
 
@ircmaxell I don't think you are ;)
 
Well for one you can't and thats not really what gordon was talking about
 
A const accepts a static scalar, so a new expression is not possible in there ;)
 
@edorian then that's fair
 
But it doesn't really matter i guess :)
Other issue that spawned from what Gordon brought up:

Preconditions: We don't want to do work in a constructor and we don't want inconsistent object state.
 
2:20 PM
@edorian ?
 
Suppose something like an emailAdress class. With ->getHost, ->getUser, ->getName and so on
 
@ircmaxell unexpected T_NEW is the result of trying assigning a new object to a const like that
 
EmailAdress { public function __construct($mail) { $this->parts = "parse_mail(...);" }

doesn't work out because it's to much work in the constructor
 
@JamesButler in what language ;-)
 
lazy parsing doesn't work out ether because the error message come up at the wrong time
 
2:22 PM
@ircmaxell php
 
@ircmaxell Somehow it's funny. Every time some additional type hinting is proposed there is immediately somebody to ask "but why don't we have typehinting here and there and there"
 
But putting in the single parts in the __constructor makes "validation" nearly impossible (suppose validation is very complex logic here)
 
@JamesButler I wasn't talking about PHP
 
@edorian surely there are only 2 times you can parse, at the start or 'later' ?
 
So what to do :)
 
2:23 PM
@edorian I would argue that it is not work in the constructor. It's doing the minimum necessary to get the object into a 1. Stable and 2. Useful state...
 
@ircmaxell but isnt parsing a separate responsibility and should be in a UrlParser class?
 
@ircmaxell aaahhhh, now your answers make sense ^^ it was somewhat non-obvious that we weren't talking about php in a php chatroom
 
I would treat EmailAddress as a value object with only getters. Then you'd always do new EmailAddress($address) and not need to call the parser...
@Gordon No, because parsing an email address is definitley distinct from a URL parser...
 
EmailParser/UrlParser/WhateverParser
 
@ircmaxell no, its not. its the equivalent of what i wrote in the code up there
the question is whether to do
 
2:24 PM
@edorian @ircmaxell Give the e-mail obj a parsed/unparsed state/flag?
 
public function __construct($url)
    {
        if ($parts = parse_url($url)) {
            foreach ($parts as $part => $value) {
                $this->$part = $value;
            }
        }
        throw new SyntaxError('Url cannot be parsed');
    }
or
public function __construct($scheme, $host, $user = null, $pass = null, $path = '/', $query = null, $fragment = null)
{
    $this->scheme = $scheme;
    $this->host = $host;
    $this->user = $user;
    $this->pass = $pass;
    $this->path = $path;
    $this->query = $query;
    $this->fragment = $fragment;
}
 
Doing the parsing inline is a considerable amount of work for a construct // a "static initialization block"
 
while the latter has the problem with values being potentially invalid
 
@Gordon There's two ways that I can see to build it. Either, EmailAddress takes a parsed object from EmailParser, or it parses it itself and does nothing else of significance
 
@JamesButler Yah. I don't want to force that onto the consumers
 
2:26 PM
@Gordon You're parsing email using parse_url?!?!?!?!?!?!??!?!?!?
 
@ircmaxell are you drunk? :)
 
@Gordon definitely.
 
@Gordon Not that I know of...
 
@ircmaxell You need to drink much to forget that you are drunk
 
@ircmaxell Email, Url, PiecesOnAChessboard. Like i stated: Something in that general direction of ValueObject with a string representation :)
 
2:27 PM
@ircmaxell then still half asleep probably :)
 
I just picked another example to not overlap
 
Like two ships passing in the night (but colliding slightly)
 
we're talking about an email address, and you post a constructor that uses parse_url.
 
I ran into that issue a week ago when creating a chess board layout thingi from a string.. I'm not sure what to do in those cases :)
@ircmaxell He was referring to his url example from above (as you joined)
 
@ircmaxell No @Gordon is talking URLs
 
2:28 PM
and I'm the drunk one
 
@ircmaxell @edorian is talking Email
 
@NikiC Not since I came into the conversation
 
@ircmaxell Just think of it as an abstracted example?
 
that code is the first url part that I saw
 
You even refereed to the url thingi in: chat.stackoverflow.com/transcript/message/2177981#2177981 :P
But ether way the generic case stands
Possible inconsistent state of a value object? Parsing in constructor? Any other approach?
 
2:31 PM
@edorian I was referring to the line about const variables. I thoguht it was a theoretical discussion on what we would like in PHP
 
@edorian I presume having another 'validate' method is too evil?
 
@edorian I don't care for the possibility of an inconsistent state via the constructor. So either you pass in the parsed value, or you parse it in the constructor...
 
@edorian Why not let an UrlParser return the Url?
 
Then again, what's the purpose of the class. Does it represent a parsed version? If so, parsing in the constructor is not bad. Does it do other things? Then parsing in the constructor is a SRP violation
 
@NikiC @ircmaxell Because something else could construct URL wrong and it wouldn't notice
 
2:32 PM
class UrlParser
{
    public function parseFromString($url)
    {
        if ($parts = parse_url($url)) {
            return new Url(
                $parts['scheme'],
                $parts['host'],
                $parts['user'],
                $parts['pass'],
                $parts['query'],
                $parts['fragment']
            );
        }
        throw new SyntaxError('Url cannot be parsed');
    }
}
 
Not saying thats a no-go .. just waying options
 
@edorian HUH? What could construct URL wrong?
 
@ircmaxell humans
 
 new Url(1,2,3,4,6,7);
 
@Gordon that's what exceptions are for
 
2:33 PM
@ircmaxell It should represent a parsed, valid state
 
@ircmaxell
 
then again, if you're concerned about that case, pass in value objects for each part, which in tern validate the component
public function __construct(EmailUser $user, URIHost $host) {
}
 
"Runtime means unforseen strangeness happened that the code does not want to deal with explicitly" quoting helly
 
(emailUser instead of URIUser because email usernames have different constraints and setup than URL usernames...
 
"Logic means who ever wrote the code was to lazy to protect against this nonsense from hapening or someone was too lazy to read the docs and sent crap to code and that code doesnt know what to do now"
 
2:35 PM
@ircmaxell yeah, that would be an option. so now can pick between Possible inconsistent state of a value object, Parsing in constructor and severe overengineering :)
 
@Gordon Yup
agree, but at some point you need to say good is good enough, and put some responsibility on the users of your class (so that new URL(1,2,3,4) is possible, but if you do that, it's your problem)
 
@JamesButler Another validate method would be code duplication or work in the wrong place i guess
 
"A negative value probably is a runtime exception based on some other code having some issue"
"If you however send a string with a number and a currency symbol you were just too lazy to read how to send the two currencies, hence logic error"
 
@edorian Yeah, it is ugly. Maybe pass the raw address to a factory of somekind (i use factory in the losest sense), which can then return email obj or fail somehow?
 
@NikiC you're going to quote the whole chat? :/
 
2:39 PM
Yeah thats the UrlParser gordon showed ? :)
 
@salathe Only what is of interest for the exception question
 
there's an exception question?
 
@edorian You could plumb them together in a factory to keep it loosely coupled. $email = $factory->getEmailAddress($email); which parses and constructs the value object...
 
Uh, stuff to read on #.pecl
 
@salathe Yes, it was never resolved and still exists.
 
2:41 PM
@ircmaxell I don't really see the need for loosely coupled value objects (yet?).. not sure
But the first implementation gordon showed me also allowed to inject a factory
Yeah.. yeah.. i can construct a case here i want something like that maybe. Good point to get my head around
 
eih
My brain isn't working today
 
(If that didn't make sense just ignore it)
 
So you would rather opt for "parser & pass data to value object" over "parse in construct especially if parinsg is complex or needs global state"
 
@ircmaxell no. just no.
@ircmaxell We can't get what he asked for because it would make PHP a completely different, namely strictly typed, language.
 
2:46 PM
@edorian Yes. I still think for simple parsing (like parse_url), it's not a total sin to parse in the constructor... Especially in most uses. Now, if your application needs to support multiple standards, or you want a generic class, then go for it...
@NikiC what?
no to that reply? Or no to the concept of return type hinting?
 
@ircmaxell no to what you said
 
@NikiC explain...?
 
@ircmaxell "We can't get what he asked for because it would make PHP a completely different, namely strictly typed, language."
 
If there every is a "most used tags in that chat room" / "what people are taking about" the PHP will be shown as: Trending for 300 days: SIGH
 
2:49 PM
@ircmaxell I fear that we are talking about different things. The Java answer was in response to the proposal to introdude private ArrayObject $foo, not about the return typehints.
 
@NikiC Is that what you think? Or are you being sarcastic? Or devil's advocate?
@edorian LOL
@NikiC AHHHHHHHH
 
@ircmaxell Yeah thats what I've read too. And thats fine isn't it?
 
@ircmaxell :D
 
Dutch PHP Conf Call for Papers is Open! http://www.phpconference.nl/call-for-papers
 
@edorian Not sure. Could as well be
though I've seen little cv-pls here recently
 
2:51 PM
@Gordon Huzza!
 
@edorian dpc is in june? pretty late. and ipc spring is in june, too. what happened there? theyve been in march or may last year, right?
 
@edorian For now. I think it would be useful to have typed variables, but as Will said, Type hinting is relatively new to PHP, so we need to take careful steps in moving forward
 
@NikiC :) Good point :)
 
@ircmaxell Having defined inputs AND outputs for a function (Do want scalar typ hinting and or autoboxing plz.) should suffice. The 4 lines in between can be magic for all i care
magic as in type juggling as in normal php
 
2:54 PM
@edorian Well, I can see it being handy in cases where you want to make the variable protected so children can access / set it, but at the same time want to enforce the type. Right now, the only way to do that is to make it private and have protected getters/setters. So then you have 2 sets of getters/setters, 1 public and 1 protected. Which can get awkward...
 
Yeah. You need to trust your children to do the right thing. Parenting can be really stressful
But I forgot that you where talking instance variables and not normal variables
There I can see the point somewhat even so the number of use cases are rather limited
 
@edorian yeah, it's not a must have, but a could be useful
 
you talking about var type hints?
 
yes
 
I like the idea, though I don't it's new
I would especially like it if PHP could use that information, but ...
 
3:09 PM
@NikiC in what way?
 
@ircmaxell perf (cpu/mem)
 
Ah
 
@ircmaxell But I don't think it currently really can. Would probably require a JIT to make really use of TI.
 
Well, now we're talking :-D
 
@ircmaxell :D
Okay, so instead of implementing those return type hints we better implement a full featured JIT will TI :D
 
3:12 PM
PHP6, now with JIT support. I like that target. I approve
 
@ircmaxell though facebook already got a reasonably slow JIT.
 
@ircmaxell there was a post about that on phpclasses recently
 
@Gordon You talking about Facebook's JIT engine?
Oh, that one
 
@Gordon and you really read that? really? on phpclasses? really?
 
@ircmaxell nope, although its mentioned in there
 
3:14 PM
yeah...
I'll stay away from .net, thank you
 
@NikiC yes, it happens rarely but it did this time
and i felt the argument brought up was quite reasonable. one could argue about whether one wanted to use .net on mono but in general it wasnt completety stupid stuff
 
@Gordon @ircmaxell The problem with every PHP rewrite that isn't a direct fork of PHP is that behavior will differ (normally be better). But PHP is BC language after all.
 
fair
 
That's why hh is only used in large self-contained environments
Like in Facebook
They have the developers to redevelop any libraries and extensions they need
But the normal user has not
And those tiny little differences in implementations will be a real pain in the ass
 
user986408
3:28 PM
is there some place on the web where sensiolabs posts release notes for a new symfony2 version.. i'm working with 2.0.4 now there is 2.0.7 - no idea if i should upgrade..
 
@ThatWebNerd symfony.com/blog?
 
@NikiC the problem with PHP's BC is that it usually refers to features introduced BC
 
user986408
@NikiC thanks.
 
user986408
@NikiC can you please explain me this?
"If you already have a project based on the Symfony Standard Edition 2.0.x, you can easily upgrade to 2.0.7 by getting the new deps and deps.lock files."
 
user986408
what are deps/deps.lock files.. where can i find/replace them
 
3:32 PM
@LeviMorrison gist.github.com/1510696
2
@ThatWebNerd I don't use S, but those files specify which versions of the various libraries that are in the Standard Edition should be checked out
similar to git submodules
 
user986408
thx
 
There probably is some script in symfony that can update them ;)
 
user986408
actually im not quite sure: http://symfony.com/blog/symfony-2-0-7-released

first i have to "get" the new deps files and "THEN" run a command which is obviously the second step
 
user986408
going to google, thanks again
 
@ThatWebNerd just do what it says: download the two files (and replace your versions of them) and then run the two commands
 
user986408
3:37 PM
just found them!.. wasn't sure if they really are located in my symfony directory
 
user986408
thx
 
I am passsing an array and writing its contents to a MySQL table. When I retrieve the contents of array they arent beign retrieved in the order in which i added them..
This used to work but now when I retrieve them its all mixed up and not returning in the order I added them..I have tried ORDER BY id but it seems to not even recognize the id
so does anyone how of what command I can use to retrieve the id of a certain column ?
 
user986408
are you even saving an id ?
 
Isnt it suppose to auto increment the moment I create the table with auto_increment?
so it should be automatically assigning ids to each entry
 
user986408
i dont know what your primary key is
 
user986408
3:41 PM
maybe.
 
// Create a MySQL table in the selected database
mysql_query("CREATE TABLE zonecheck(
Email VARCHAR NOT NULL AUTO_INCREMENT,
PRIMARY KEY(Email),
PNum VARCHAR(30),)")
 or die(mysql_error());

echo "Table Created!";
shouldnt that have worked?
instead its returning the emails based on alphabetical order
when I do Select FROM name ORDER BY Email
 
user986408
i'm not sure but isn't auto increment only reasonable when using a numeric ?
 
@Gordon Alright. @NikiC Already shouted at you for posting that link so I can skip that. Thanks :)
 
user986408
@Nadal just create a additional column "id" and assign auto_increment to it
 
3:48 PM
alright that should work, thanks!
 
user986408
@Nadal of course of the type integer. no problem
 
@ThatWebNerd just 1 question, I dont want a user inserting duplicate email and to prevent this I used primarykey on Email but if I add id in here to prevent duplicate emails should I primarykey the Email, the id or primary key email + id ?
 
@edorian dont restrain yourself: youtube.com/watch?v=CrElT8XxptU
 
user986408
well the actual prevention would be done by the scripting language but i think you could use multiple PKs - but again i'm not that good with databases
 
4:05 PM
Ummmmmmmm
> InvalidArgumentException: Overloaded object of type SplFixedArray is not compatible with ArrayIterator
 
hello!
could someone for example @Gordon or @ircmaxell come to CSS room
 
no
 
?
what about @Gordon
 
@ircmaxell By setting the initial size of Spl\ArrayList to 0, I think you broke grow.
 
@LeviMorrison no, I fixed that
 
4:19 PM
or maybe @Levi?
 
I had to set the size to 0, because otherwise toArray failed miserably (and so did iterator)
 
@ircmaxell You have to write your own iterator to deal with SplFixedArray anyway. It assumes you are using every index allocated.
Also, what's $this->list->getSize() * 2 equal to when size is 0?
 
@LeviMorrison Which is why I used arrayIterator and called array_splice on toArray
@LeviMorrison it is 0. but the next line checks for that state and sets it to 2...
 
The idea is fine, but it looks ugly :) I'm still reviewing all your changes, but they look good.
 
@LeviMorrison Well, I'm less concerned about that for 2 reasons. 1. This is a POC, so it doesn't need to be clean implementation. 2. It's tested, so we can refactor later and clean it up if we want...
 
4:24 PM
@ircmaxell I still don't like set being able to add things.
When I see set, it means to me that I can't add, only set existing.
 
@NikiC If you can compile that into readable docs, that would be great ;)
 
I can't quite tell, did you remove the trailing ?>, @ircmaxell? I don't care if you did, but I can't quite tell from the diff.
@ircmaxell merged.
 
If I have a repo with CC licensed stuff do i copy/paste the whole license in the LICENSE file or do i just denote the license used an a link to the text?
 
@LeviMorrison Set is unordered and contains exactly one of each item
you can make it immutable if you want, but it's not enum
@LeviMorrison Yes
@edorian Either way is fine
 
All right
Some netbeans guys asked for a proper license on the php-jenkins-template stuff so that they could embed it. Currently fixing that
 
4:38 PM
Very nice!
 
Or well they asked for some parts to be not under CC-BY-SA because they can't use that then but BSD seems to work so the .xml stuff goes under BSD while the text stuff stays CC
 
Yeah, usually I just link to the license in a comment ( github.com/ircmaxell/PHP-CryptLib/blob/master/test/… )
 
The xml is generated by the jenkins server and I don't want to comment in that stuff by hand every time so we decided to just put a LICENSE next to in the branch where only that file is anyways
 
"Support The 2% (Milk)" is a play on the amount of fat in the milk?
 
4:43 PM
evening , console cowboys
 
@edorian Yup
 
I see, we only have 1.5% (low fat) and 3.5% (normal) milk over here so I wasn't sure. Quite nice
 
reminds me about rant from Lewis Black about the milk : youtube.com/watch?v=tXS5GBuk-GQ
 
Word of encourage to node.js programmer: not pay attention to negative comment! In beginning people were think PHP was shit technology too!
 
@edorian We have 0% (Skim), 2% (low fat) and 4% (whole)
 
4:56 PM
5
Q: Is it considered bad practice to have PHP in your JavaScript

Greg GuidaSo many times on this site I see people trying to do things like this : <script type="text/javascript"> $(document).ready(function(){ $('<?php echo $divID ?>').click(funtion(){ alert('do something'); }); }); </script> I don't think that this is some sor...

What does PHP think?
 
@Raynos I agree with @LeviMorrison
 
Ugh I dont like using PHP for assets either
but thats not that big a problem
 
But ultimately PHP makes templating really easy so people are gonna use as a templating engine
 
theres nothing wrong with dynamic HTML
dynamic HTML and PHP as a templating language is awesome
 
5:05 PM
I don't agree with PHP in JavaScript though. It just seems incredibly wrong.
 
@NikiC Oh no! I was reading the talk you had with helly and I wished I was there! OutOfRange has to do with invalid index types, not the actual 'range' or bounds of the array!
Or maybe just Tyrael got it wrong.
 
@LeviMorrison You mean OutOfRange would be like attempting to use a string to get a numerically index key?
 
@CharlesSprayberry Yes.
I don't like the name OutOfRangeException at all.
That's a HUGE portion of the problem.
 
@LeviMorrison hrmm...why would this just not be InvalidArgument?
 
@CharlesSprayberry InvalidArgument is what I've used historically. But you typically don't think about array stuff as arguments.
 
5:12 PM
or even UnexpectedValue...I don't see how the type of the key used is a range
 
@CharlesSprayberry It doesn't. That is just how it is used. Honestly, if my remake of the Spl take on, it won't have OutOfRange. It will have something that is what I described with a different name :)
 
@LeviMorrison I'm actually interested to see what you guys come up with out of that
 
So far it's going well :)
But adoption is a completely different thing altogether
 
5:29 PM
6
Q: Testing Legacy PHP Spaghetti Code?

ClaytonI inherited a fairly large, homemade, php4+MySQL, ecommerce project from developers that literally taught themselves programming and html as they wrote it. (I would shudder except that it's really impressive that they were able to do so much by starting from scratch.) My job is to maintain it a...

30 minutes, 6 upvotes. WOW
 
Already did vote
 
yeah
 
Did you spot anything major I forgot in my answer? (If you read/scanned over it)
 
nothing major that I saw
 
5:51 PM
All right. Thanks. I'll be off. Cya later
 
25
Q: What would one need to do in order to hijack a satellite?

IncognitoI realise this borders on sci-fi, but there's been some interesting demonstrations regarding security of various satellites. What would be required to hack a satellite (in general terms, any hack really)? Are they all basically connected in the same way, or would I need different equipment, sof...

 
 
1 hour later…
7:12 PM
hrm, that thread on type hinting makes me want to reply, but I know it will just turn into a flame war. So now the decision: to reply or not...
 
@ircmaxell lol
Could you send me the link?
 
@ircmaxell What's your opinion on it?
 
7:29 PM
Oh which part of it? The scalar types?
 
@ircmaxell The part that starts a flame war
 
I think that scalar type hints are good and should be allowed. I also like Rasmus's point, if it could be implemented well (auto-casting)
 
Is NULL a scalar?
 
7:44 PM
hey i am a beginner and have such a simple question, i was hoping someone could help quickly...basically i am just looking to call the entire array of mysql results...i have $result = mysql_query($sql);
$row = mysql_fetch_array($result);
normally I call $row["name"] for a specific result
so for the whole array, would i called $row? or $result?
 
@ircmaxell I don't get it.
 
so lets say i retrieve all rows from my database where name=john
 
@ircmaxell What's so funny?
 
@stevether look at the switch statement, see anything wrong?
 
oh nm
i thought you were talking to me :)
 
7:46 PM
@ircmaxell Well, strings break and return -1
 
 52 	case IS_DOUBLE:
 53 	case IS_RESOURCE:
 54 	case IS_BOOL:
 55 	case IS_LONG:
 56 		if (Z_TYPE_P(offset) == IS_DOUBLE) {
 57 			return (long)Z_DVAL_P(offset);
 58 		} else {
 59 			return Z_LVAL_P(offset);
 60 		}
could be
 
case all these things: IS_DOUBLE
 
 52 	case IS_DOUBLE:
 57 			return (long)Z_DVAL_P(offset);
                            break;
 53 	case IS_RESOURCE:
 54 	case IS_BOOL:
 55 	case IS_LONG:
 59 			return Z_LVAL_P(offset);
 
There honestly might be a bug in there. String returns -1. Why do any processing if it's just going to return -1?
 
@LeviMorrison No it doesn't
and actually, that's why it's written like that
there's no break after string, so it falls through to the if
 
7:49 PM
49 case IS_STRING:
50 ZEND_HANDLE_NUMERIC(Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, idx);
51 break;
There is a break . . .
 
@ircmaxell Fair. PHP's core is a mess. Are you going to submit a patch for the IS_DOUBLE thing? I'll gladly do it if you aren't. It is SPL related :)
 
no, because it won't work
well, it may, but I feel odd about patching little things like that
@LeviMorrison If it's going to be submitted, I'd rather do it to start to gain some karma
 
@ircmaxell Fair. I need the karma too :) That's why I asked. It's only fair for you to submit it.
But if you aren't going to, I gladly will.
 
fair
replied to the thread
 

« first day (432 days earlier)      last day (4509 days later) »