« first day (502 days earlier)      last day (4460 days later) » 

6:03 PM
while ($property = current($array)) {
            $this->{key($property)} = $property;
            next($array);
        }
Anyway how i can do this correctly? :)
 
@edorian Still thinking
@edorian I'm not sure what most of the methods he is proposing are supposed to do, but what I think does make sense is to create Builder classes for stuff like classes, methods, etc.
I'm thinking about APIs like these:
$builder->createClass('SomeLogger')
    ->extend('BaseLogger')
    ->implement('Logger')
    ->addMethod($builder->createMethod('log')
        ->addParam($builder->createParam('msg'))
        ->addParam($builder->createParam('type')->optional()->default(...))
        ->addStmts(...)
    )
    ->build();

// not sure how possible this is
$builder->class('SomeLogger')
    ->extend('BaseLogger')
    ->implement('Logger')
    ->method('log')
        ->param('msg')
        ->param('type')->optional()->default(...)
 
@NikiC I'm not sure what the creational methods are supposed to do ether. Presumably save to disk
But I mostly care about the inspection and not the modification aspects
 
@edorian Not sure I get that
 
user895378
@edorian -- thanks for the pywatch heads up for watching my PHPUnit test results
 
chat comment --amend *spelling fixes
 
6:12 PM
ah ^^
 
@rdlowrey Sure :) Did you get it to work and work with colors?
 
user895378
Yup. Perfectly.
 
Most of the inspection functions he posted are already available as direct properties. E.g. $method->getArguments() is available as $method->args. $class->getName() is available as $class->name. etc
 
So . . . I have a class that implements ArrayAccess, but I don't want users to be able to unset properties. What exception would you throw?
 
@LeviMorrison urgh, again expections...
PHP exceptions are fun :)
@LeviMorrison I'd say LogicException
As your class never allows unsetting in general, not just in a specific case
 
6:18 PM
@NikiC Oh, i didn't see that when looking through the nodes :)
 
@edorian It's kind of non-obvious because it is all magic ^^
 
I've noticed i can ask each node where their definition started but can I ask the more abstract "concept" of a namespace/class/method where it's definition started and where it ended?
 
The available ->subNodes are documented at the top of the class with @property's
 
(If asking like that makes any sense)
 
@edorian You can ask about the start line for ns/class/method too, it works on all nodes. But I currently don't save the end line. Probably should do that.
 
6:21 PM
Oh, there github.com/nikic/PHP-Parser/blob/master/lib/PHPParser/Node/Stmt/… Heh.. comments. Thats probably why I've missed it
 
dinner
 
From what I can see so far the "end" line is the only thing that would be in the way of getting that into phpunit-code-coverage and throwing out the old token stream stuff
 
yo ho ho
 
He there
I was very happy seeing your tweet with the C-gist and realizing what you are trying to do :)
Getting something done in that regard seems to be only possible with showing an implementation instead of endless talking :)
 
he's building php6 next
 
6:28 PM
So, Pdo and other things can create object properties before the constuctor is called. Can I do that in PHP code? Or does it have to be a C implementation?
 
dynamically? I don't know of any way (short of eval hacks)
 
but the constructor will not be called at all then
(and you can to that since 4.0.0 with unserialize :) )
 
That's perfectly okay in this case.
Unserialize seems so hacky.
 
Well you are doing something really hacky when using reflection anyways :)
 
6:34 PM
Blargh.
 
"new Reflection*" in production code should give you the same feeling as seeing "eval($something);" shouldn't it? :)
 
I am creating an object that tracks changes to its properties, but only tracks them after they are initially set. However, I don't know what the properties will be until runtime, and I don't want to use the constructor.
Hmm.
Also, after the object is 'created', I don't want new properties to be created.
I guess I have to set a bunch of flags :/
 
Are you building a base class for DTOs/persistable stuff?
 
I'm not really familiar with the term, but I believe that is what I am doing.
 
user895378
@LeviMorrison I wasn't familiar either: en.wikipedia.org/wiki/Data_transfer_object
 
6:41 PM
In this case my 'DTO' doesn't know how to create or persist itself, another class does that. Other than that, it seems to be the same.
 
hi guys
 
Ok so Data Mapped Objects is more appropriate. Or just "buiness objects or models". I see
 
why time() function gives different value from a server that is GMT +01 and server that is GMT+02
 
I usually don't want to have to much magic in there but well. having a protected $properties = ['name', 'foo', 'bar']; and using that in the base class seems like the approach i might consider
@Vlad because it returns local time?
 
6:45 PM
but isnt it Unix timestamp from 01.01.1970 00:00:00 GMT+00?
or it deosn matter
aha ok
 
who's the know it all here?
 
.. yeah.. time shouldn't return a local timestamp.. localtime() should do that
 
as there's always know it all among these chats
 
do i have to do some configuring on the apache or php.ini when working with time? or localtime(time(), true); will do the job
 
6:51 PM
    public function __set($property, $value) {
        if ($this->locked && !$this->offsetExists($property)) {
            throw new DomainException(
                "User is locked: you cannot create new properties."
            );
        }

        if ($this->offsetExists($property)) {
            return $this->modified[$property] = $value;
        }

        return $this->properties[$property] = $value;
    }
That seems so ugly.
(DomainException should probably be something else, it was just left-over from before the rewrite)
(Well, maybe not)
 
ratin -107 rofl
 
7:12 PM
@tereško yea i know but im working in an old project where I dont have good OOP code :P
 
7:55 PM
Hi all again
 
Hi, I'm having trouble making an inlcude. but i'm no able to express it, pastie.org/3498816
accidently commented the troubled parts -.-'
line 31-33
that viewburp.php nees a user, and if it doesnt it outputs text aswell
but nothing is coming up. not even errors, if i echo the include i get a "1"
also, the viewburp.php has a function (the only one) and has no return
 
@edorian :-D
@edorian I'm just doing dirty POC patches at this point, because I don't want to spend a ton of time doing it. Just enough to get the point across. Then if there's valid discussion, I will clean it up and make it worthy
 
Question: Is there anything in PHP which allows me to overwrite code at runtime?
 
@Christian PHP code?
there is no real runtime in php
 
(other than using an extension, that is)
 
8:06 PM
it is not compiled...
 
@Neal Huh? When a PHP script is running, it's called runtime.
 
@Christian ok.
What exactly do you want to do?
 
A simple javascript example....
 
@Neal That's not true in the least
 
var a = function(){};
... later on...
a = function(){ /* do something else */ };
 
8:08 PM
$a = function() {};
$a = function() {};
 
And how reliable is it? What's the memory leak risk?
oh, can I attach lambdas to an stdClass?
 
no
 
PHP's in a sorry, inconsistent state, imho. :P
 
It is, but not for that reason
 
Lots of reasons I think. I mean, I could live without this 'feature'....
Hmm.
Or maybe not.
 
8:13 PM
nah, you don't need that
 
OK, there's no $this...but I don't need it in my case.
 
there is in 5.4
 
Good luck to my future self.
 
@ircmaxell COOL!
Wait, uh... "string"->bindTo() works? That doesn't look correct...?
Oh, $this->$method is not a string.
 
correct
 
So, basically, you're doing $closure->bindTo
 
Looks like I have some learning to do :D
I've heard about this $this business but didn't get this far on it.
I suppose there's no way to make this work with ye old PHP version though?
 
8:23 PM
nope
 
user895378
$theNewHotness = function() { return 'Closure::bindTo'; };
 
@rdlowrey Not in my case though. See I'm running a PHP-based server, and I got fed up having to restart the server each time I change a module's code.
So I figured I could just wrap up my modules in lambdas and make the server reload the module when the file changes (overriding the earlier lambdas).
 
@Christian Huh?
why the heck would you want to do that?
 
user895378
A PHP based server? hmm ...
 
@ircmaxell What, running a PHP server or reloading modules?
 
8:27 PM
You're basically creating DLL Hell for PHP?
 
@ircmaxell LOL. No.
 
user895378
@Christian Is that just for research and general knowledge? Because like @ircmaxell I can't imagine why you'd want to do that for any other purpose
 
It's while it is still in development. When it's finished, a code update will be requiring a restart.
 
just restart the server then
 
This server's interactive. Restarting it would mean having to do some stuff to get back at the testing part.
Say, @ircmaxell are there any plans to get PHP namespacing more dynamic? eg: namespace $name;
 
8:38 PM
why would you ever want to do that?
 
@ircmaxell Dunno. Just had that crazy idea this morning.
Hmm, there isn't any reflection for namespaces?
 
9:02 PM
@Christian because namespaces aren't constructs. They are compile-time syntax sugar only
 
@Christian what would you do , if you could ?
i kinda fail to see the point in it
 
PHP 5.4 has been released.
21
 
user895378
woot
 
@NikiC Not updated on www yet
Oh, yes, just flipped
 
@ircmaxell web/php.git already has the announcement. Will take a while till it is mirrored online
 
9:14 PM
Well, the official release is
Woah, 5.3 is no longer supported at all?
wtf?
 
WTF?
why the hell...
 
It is still supported
the message was still in there from 5.2, so...
 
> This version is no longer supported by PHP.net
 
it's being removed
 
idk how to make blockquotes...
 
9:16 PM
yes you do
 
Cool i did it ^_^
 
@ircmaxell Sure it is, just a mistake somewhere
 
@salathe Yeah, confirmed in #php.pecl
I figured as much, but wanted to verify: php.net/downloads.php#v5
 
Aaaand it's fixed :)
 
@NikiC not really
 
9:20 PM
@salathe why?
only the news doesn't show up ^^
 
5.3.10 is still current stable in the 5.3 branch
 
5.4 had a release yesterday
but no post
 
@edorian pssh, that's sooooo 15 minutes ago
 
@Leigh Post is coming every minute
 
9:27 PM
every minute?
 
@salathe * * * * * post
 
@NikiC but... every ?
 
@NikiC: Just kind of strange that it's a day late, even the RC8 news was like 8 days late
 
@Leigh not strange at all, getting everything together for a release takes a while
especially if you've not done it before
it's not like we have a big red button "new release plz" :P
 
9:30 PM
post is live
 
(maybe we should)
 
Yet!
 
Well, what do we say the official release date is? :) yesterday because the windows binaries + source release was available, or today because there's a news post?
 
But i saw a jenkins so maybe get snapshots every minute
 
@Leigh who cares?
 
9:31 PM
@Leigh It's today, first March. Yesterday only some preparations were made ;)
 
@salathe: I want my tag wiki edit credit :D
 
@Leigh then mark it as today, tell them I told you so
 
Your Badge Progress
Research Assistant
1 tag wiki edits (2% done)
huzzah
 
What does this mean?
> The break/continue $var syntax was removed
?
 
that you can't do "break $var;" anymore
 
9:33 PM
@Neal It means that you shouldn't care, as you don't know what it is ;)
 
@NikiC lol but what is it?
 
@Neal $var = 2; break $var; is no longer supported. break 2 continues to work just fine.
 
break accepts an optional numeric argument which tells it how many nested enclosing structures are to be broken out of.
 
@salathe hmmm odd. why is that?
 
c/p fu
 
9:35 PM
@Neal why removed? because having a variable there makes no sense at all.
 
@salathe and having a number does?
 
@Neal yes
 
@salathe How is that?
 
What is the best HTTP status code to return when a required POST variable was not sent? I was thinking there was something better than 400, but can't seem to find it.
 
Anyway, great work guys who contributed, I'm glad it's finally out. We're due to begin a product rewrite at work, due for completion around September. I was pushing to have 5.4 as a target version, but nobody was game because it wasn't even released as stable.
 
9:37 PM
@Neal Because it makes sense to want to jump out of more than one level of loop
just not $n levels of loops
 
anyone can explain what does it mean? Class::{expr}() syntax is now supported.
 
@LeviMorrison: 417? Expectation Failed
 
@MelvinProtacio you can now do funky stuff.
 
@Neal like?
 
although its specifically for the Expect header, it feels fitting :D
 
9:38 PM
@Leigh Inappropriate. That deals specifically with an Expect: header.
 
@MelvinProtacio Here is one example:
$method = 'method';

$test = new Test();

$test->method();
$test->$method();
$test->{'method'}();

Test::method();
Test::$method();
Test::{'method'}();
Result:
method
method
method
method
method
method
assuming that class has a method called method that echo's out the word method
 
@salathe So now the hot times for the doc team starts finishing up documenting everything that is now finalized and sorting the inital burst of comments?
 
@edorian that, or hiding under a rock for a while.
 
Documentation karma? What karma?
;)
 
@Neal expression is the term and not literal, so it means it could also be $test->{1+1}()?
 
9:40 PM
@LeviMorrison: Seriously though, I think it has to be either 400 or 500
 
@LeviMorrison commit access
 
400 is best fit in my opinion
 
@MelvinProtacio One assumes (if you have a method called 2())
 
@Leigh No way is it a 500.
 
user895378
@Leigh I don't think a 500 makes sense
 
9:41 PM
But idk
 
@salathe Well given you are on the php team you should have collected a nice collection of rocks over the years
 
@edorian it's a very nice collection :)
 
@edorian It's a common phrase that indicates "I don't know what you are talking about" even though I clearly do.
 
@LeviMorrison @rdlowrey then I think you're stuck with 400
 
@Neal wtf! that might lead to non-readable code and may lead to hard to detect problems :(
 
9:43 PM
@MelvinProtacio Yea...
 
user895378
@MelvinProtacio Agreed ... seems like the possibility for wholly unreadable code outweighs any benefits.
 
To the Stack!
awaaaay!
 
smashing the stack, for fun and profit.. those were the days :x
 
> cli.pager and cli.prompt for CLI SAPI using readline in interactive mode.
 
9:44 PM
One of my favorites
 
@rdlowrey i wanted to avoid that feature if that is considered a feature at all costs :D
 
user895378
@MelvinProtacio "Just because you can doesn't mean you should"
 
@rdlowrey that's true but what's the point in putting that up :D
 
user895378
Haha just agreeing with you. That's it :D
 
@rdlowrey the parameter is not actually an expression but an expression that evaluates to a string, the documentation should be updated
 
9:48 PM
0
Q: PHP 5.4 Class::{expr}() syntax

NealSo now I can do something like this: class Test { function method(){ echo 'method'. PHP_EOL;} } $method = 'method'; $test = new Test(); $test->method(); $test->$method(); $test->{'method'}(); Test::method(); Test::$method(); Test::{'method'}(); Which results in: method metho...

 
@ircmaxell oy
 
u know its relevant
 
@ircmaxell haha!
 
9:50 PM
@Neal Not saying it isn't relevant
it isn't a good format of a question for SO
 
is it a question?
 
0
A: PHP 5.4 Class::{expr}() syntax

NikiCThis is mainly a feature for consistency, I would say. Compare it to what can be done with non-static methods: $this->{'get' . $name}(); Which can be quite useful. Similarly self::{'get' . $name}() could be considered useful by some. Personally I think that static methods are inherently e...

 
@Neal And it's not new to 5.4, 5.3 supported it as well: codepad.viper-7.com/3OO0qQ
 
@Neal "Why/When would be the best time to actually use this way of calling a class method, if ever?" this is open to several opinions and very argumentative
 
@ircmaxell not that variation
 
9:52 PM
@ircmaxell you are actually assigning it to a variable
 
Oh, for {"foo"}
even more of a reason to close the question, it's not even clear what it's asking...
 
:D
 
I didn't catch what "zend.multibyte - to control the new multibyte support." does on internals .. hmm
 
@MelvinProtacio I guess. How can I make that question better?
 
@edorian . . . we have multibyte support in PHP? Since when?
Does this mean PHP 6 is around the corner? o.0
 
9:55 PM
@Neal: I'm wondering if some sort of MVC router would be a good fit for that syntax
 
@Leigh Like how?
 
@ircmaxell Articles dont help me...
 
@Leigh i don't find it useful at all since it will definitely lead to more troubles
 
@Neal sure they do
 
9:56 PM
@ircmaxell no. no they dont. im doing too many things at once.
 
like if you are parsing the URI parts and you don't have there are some unexpected literals on your URI then that would lead to exceptions
 
huh, what problem is their with @Neal's question?
 
@Neal teach a man to fish vs give them a fish
 
howdy hiyall
 
@MelvinProtacio: Not saying I'd use it, just trying to think of a valid practical use. @Neal: Like instantiating your standard controller, and using a method extracted from the request uri to call a method
 
9:57 PM
@NikiC They are saying its subjective... which it is not meant to be
 
@Leigh That's already doable . . .
 
@LeviMorrison: Not saying it wasn't
 
@Leigh haha true. I use call_user_func_array(array($this, $method), $args); now
which is annoying as hell...
 
@Neal that's probably the reason they created that syntax
 
@Neal: I use method_exists and $class->$method($args) .. each to their own
 
9:58 PM
@NikiC Subjective and Argumentitive. No real answer
 
@Neal Depending on the method declaration, you can do $class->$method($args)
 
@LeviMorrison wait
 
@LeviMorrison On what version of PHP?
 
that's not the syntax
it says expr is enclosed on the braces
and not assigned to a variable
 
@MelvinProtacio: Stop getting over-excited, we were talking about something else.
 
9:59 PM
$class->{expr}();
 
@ircmaxell I adjusted the question slightly to be more concise: stackoverflow.com/questions/9524658/php-5-4-classexpr-syntax
 
@Leigh haha LOL
 

« first day (502 days earlier)      last day (4460 days later) »