« first day (1681 days earlier)      last day (3264 days later) » 

12:00 AM
@samaYo It even has functionality which halts upon seeing an exception which won't be caught … before unwinding the stack.
 
what does the `backtick string expression` do in php? can't find anything about it :|
 
Anonymous
hm, it's probably easier to install it and get dirty first. I hope there are no nasty, error-prone time wasting setup problems. These days I can't get anything done without pulling my hair for 30 minutes :/ @bwoebi
 
@samaYo but please use the PHP 7 version
the 5.6 is a bit… outdated.
@Worf shell_exec()
 
@bwoebi lol
 
Anonymous
ok
 
Anonymous
12:09 AM
@Worf & mysql
 
& mysql?
 
> Unlike some other languages, backticks cannot be used within double-quoted strings.
 
Anonymous
92
Q: Using backticks around field names

nickfAfter reading a couple of answers and comments on some SQL questions here, and also hearing that a friend of mine works at a place which has a policy which bans them, I'm wondering if there's anything wrong with using backticks around field names in MySQL. That is: SELECT `id`, `name`, `another...

 
oh lol
 
@samaYo that doesn't make sense, you don't write `select * from stuff` they are just characters of a regular string :P
'SELECT * FROM `stuff`'
i was asking about the `string literal`, not a regular string containing ` :P
 
Anonymous
12:14 AM
a string is a string :P
 
it's not, sometimes it's a membrane
 
lol
 
Anonymous
strings are immutable, so no!
 
@Worf they can, they just don't have any extra effect
 
12:18 AM
yeah. doc is a bit weird
@samaYo they aren't 3v4l.org/jrI1u
 
@Worf committed
 
funny that phpunit has a bunch of imho verbose assertion methods such as $this->assertGreaterThanOrEqual and it doesn't have $this->assertOk() $this->assertFail()
the closest i can get is $this->assertTrue(true); and $this->assertTrue(false);
 
@Worf what's the diff between assertTrue and assertOk? what is ok?
 
@Worf $this->fail()?
 
how to assert success? @PeeHaa
 
12:31 AM
$this->fail() is not an assertion
 
@Worf YOu don't
You don't assert anything which is what you are asking from the looks of it
 
public function fail() { assert(false); }
 
@marcio i suppose the same difference between $this->assertGreaterThanOrEqual($x, 10) and $this->assertTrue($x >= 10)
 
what should assertOk|fail do?
 
@Worf phpunit should just catch warnings from assert(); … KISS please!
 
12:33 AM
@RonniSkansing ^ that's what I'm asking @Worf
 
just a shortcut for $this->assertTrue(true); and $this->assertTrue(false); @RonniSkansing
 
wtf
 
@bwoebi yeah :P
 
played with websocket all day
fun ..
 
12:35 AM
hope they will add it to phpunit now that we have proper assertions
 
I feel like phpunit is totally unneeded, I just use it because it's standard and has code coverage ready
 
@marcio Is there any real alternative?
 
write tests with assert();
 
But I like having a framework which handles all the stuff for me
:(
It's easy to setup a suite using phpunit imo
 
@marcio And then also do the work for catching errors and naming the tests, and doing the code coverage, and printing a report?
 
12:38 AM
also the mocking tools stuff
 
@Danack that's why I said I use phpunit because I don't want to do that :P
 
Basically everything :P
 
anyway, you just write a stand alone code coverage tool once and reuse it
 
Why would somebody when there is already a tool that does it :P
 
@Worf Doing $this->fail("Some message here") - allows you to specify why a test failed. For a test that succeeds, what message would you want to do, other than "yes, there was no error."?
 
12:39 AM
@PeeHaa that's exactly what I'm talking about
3 mins ago, by marcio
I feel like phpunit is totally unneeded, I just use it because it's standard and has code coverage ready
 
@PeeHaa cough running tests in parallel cough.
 
@Danack well $this->assertOk() would increase the counter of successful assertions, code coverage and things
 
@Danack That would be nice yeah
 
you can do that already with phpunit
 
@Worf I don't think it would affect coverage - and why do you care about the number of assertions?
 
12:41 AM
@marcio ?
 
@marcio My understanding was that it the parallel stuff is a massive hack....rather than something sane to use.
 
@PeeHaa there is a plugin, can't recall the name
 
ty
 
^ yes, this is the hack
 
12:43 AM
> To get the most out of paratest, you have to adjust the parameters carefully.
I hate having to do stuff carefully....
 
the main issue is PHP not the plugin
 
Isn't it always :P
 
not only PHP, but people writing (usually OO) code with tons of state and expecting their test to run in parallel
 
I believe the big issue is that you can't (or at least I failed to) mark "this test is safe to run in parallel" or "this test must be run separately".
(which obviously would only be needed for things that are not actually unit tests, but such is life)
The other problem with PHPunit is that looking at it's source code makes you go blind.
 
Looks very interesting. Will give it a run tomorrow and find out
 
12:45 AM
@Danack it's all legacy
 
All code is legacy code - except for stuff that no-one uses.
 
@Danack True. Luckily I only had to look at it once to fix something
 
@Danack just to brag about having more passing tests with neighborhood kids
 
I've heard Sebastian wants to throw most things away next version
 
I don't think that ever works......just making incremental improvements would be the way to go.....and those don't seem to be happening.
 
12:49 AM
most incremental work would require drop some PHP versions support
there are hacks in the code to support PHP without namespaces
xD
 
Meh - For the record I am still annoyed at this PR being closed:
> You will have to live with different settings of opcache.save_comments in your test / production environment. Or simply set opcache.save_comments=1 for production. I do not believe that opcache.save_comments=0 provides a significant performance gain anyway.
 
yuck, it's impossible to decide what looks worst... a method with a switch($testname) to return the data or the doc comment annotations.
I'd prefer a convention like:

function ATest($arg){}
function DataProviderForATest(){ return [...]; }
 
@marcio Why do you think switch($testname) is bad? It's just the same as doing file_load_contents($testname.".data");
 
file_load_contents ?
 
It's a data source - it returns some data based on the testname that was passed to it. Doing a switch statement is the same as loading the data from a file.....which presumably you don't think is a bad thing.
 
1:02 AM
function ATest($arg){}
function DataProviderForATest(){ return [...]; } // or some better naming convention
still looks better ^
has anyone proposed it?
 
1:14 AM
i have nasty idea to have implemented in php but i'm not telling you coz you'll think i'm mad :(
 
blog.sheriframadan.com no more wordpress!
phewwww
 
@Sherif congrats
 
Yea, spending 3 hours of your Saturday evening trying to recover a wordpress database only teaches you one thing.
Don't use wordpress!
 
eheh
 
@Sherif Why do people always have to learn that the hard way? :x
 
1:22 AM
@bwoebi Hey it worked fine for the first 3 years. I figured... why fuck with it?
That is .... Until it didn't...
 
That's what I mean…
Also… backups!?
 
To be completely fair this wasn't entirely WordPress's fault... My VPS suffered a harddrive crash and I spent many years heavily customizing/bastardizing the fuck out of that WP install. It wasn't trivial to get it back up and running from memory.
Sure, the database was backed up, but not the code.
 
@Sherif oh…
 
Well, that's not entirely true. I backed it up, just on the same VPS that crashed :)
 
hah
 
1:25 AM
There was a nightly rsync job that was supposed to back it up to S3, but unfortunately for me I turned that off about a year ago after I changed my S3 API key and forgot to update the cronjob.
 
Murphys law…
 
Lazy programmer === living on the bleeding edge!
You never think a RAID 10 will fail you until it finally does and then you're f***ed
 
@Sherif well… I once had an account on a server where one disk failed in a RAID… and nobody noticed… until the second one was fucked up too…
 
Yea, you just never think it's gonna happen to you.
oh well
 
Disks should fail more often so that we're really aware of it, right?
 
1:30 AM
Mechanical disks maybe.
Stick to SSD
 
2:10 AM
how do I even structure this application
 
2:27 AM
@Andrea If you have no idea now, start a bit working on it and then think again about it… Will be a major refactor maybe, but you only see what you need by trying
 
yeahh
I get stuck too often on "how do I structure this, how do I make it into classes"
I'll just write functions
 
@Andrea classes usually emerge where you need state… no need to think too much about it
@Andrea btw. may you please merge your PR 1298?
 
@bwoebi why?
 
@Andrea well, why not? :-)
 
I feel like at least one other person should approve it
someone not room 11
 
2:34 AM
Then you need to ask someone… and especially on these tiny non-controversial things nobody comments on…
 
The whole pr is probably not good - but what sapi/pi3web/pi3web_sapi.c in github.com/php/php-src/pull/1301/files ?
 
???!!!!
$ ~/Projects/2014/PHP/php-src/sapi/cli/php src/main.php ~/Projects/2014/PHP/php-src/sapi/phpdbg/phpdbg test.php
No opcodes could be compiled | No file specified or compilation failed?
Ooh, yay, I got it to capture phpdbg's output as a string
So far, so good.
 
3:00 AM
<?php
declare(strict_types=1);

namespace ajf\ElePHPants_Love_Coffee;

class CompiledVariableOperand extends Operand
{
    private $number;

    public function __construct(int $number) {
        $this->number = $number;
    }

    public function getNumber(): int {
        return $this->number;
    }
}
:3
 
3:14 AM
what is that? :P
 
What might end up being a PHP-to-JavaScript compiler
 
How useful is that?
 
very!
 
We will see.
 
possible uses of that?
 
3:18 AM
If it ends up usable, then very.
Though I'm not the first to write one, actually
 
@bwoebi is there a way to put phpdbg in php REPL mode so I don't have to type prompt> ev to execute something?
 
But I mean, why compile PHP into Javascript? Why not just run the Javascript in V8? PHP does have a V8 extension, after all.
 
How would running JS in V8 change anything?
Did you misread it as "JavaScript-to-PHP compiler"?
 
No, but I mean how often does it make sense to take PHP code and try to run it in Javascript? Why not just write JS and run it in JS, and if you really wanted to do something with it in PHP you could use the V8JS extension.
 
Existing codebases, code-sharing
Also, V8JS is awful
 
3:24 AM
Is it? What's so awful about it?
 
btw guys, we have lua, python, v8js, but we don't have a php sandbox. would love it
 
@Worf Well, we do actually. It's called Runkit
 
@Sherif Communication between PHP and JS code is really limited
 
$x = new PhpSandbox();
$x->disableEverything();
$x->enableExtension("standard");
$x->run(file_get_contents("lol.php"));
@Sherif checking it
 
@Andrea But why would the two really need to communicate within the context of the same virtual machine?
 
3:26 AM
the only way to get a value out of JS seems to be by evaluating code which happens to instantiate something
@Sherif V8JS doesn't run in the same virtual machine
You asked me what was awful about V8JS.
 
how about spidermonkey?
 
Is there an extension for this?
 
@Andrea I mean, if I understand this correctly the use case for something like V8JS is to potentially build something like a Selenium framework. In which case I don't see why the extension is so bad?
 
@Sherif V8JS is useless
JavaScript code can't do anything
And it can't properly communicate with PHP code unless you build some obtuse bridging mechanism
 
3:30 AM
If you were trying to build a headless browser then V8JS is actually a pretty nifty solution in PHP.
 
spidermonkey is cool i've used once. you can inject php functions into js transparently, and vice versa
 
@Sherif How?
V8JS makes it difficult for JS code to return data to PHP, let alone call PHP functions
Useless for writing a browser, then
A browser needs to expose APIs to JS code
 
@Andrea check spidermonkey. you basically describing why in the past i decided to use spidermonkey ext rather than the v8js one
 
@Worf Ah, looks good
 
@Andrea True, I've never actually used it for anything serious so I guess I never bothered to figure out exactly how it works. Now that I'm reading the documentation it does seem to be a bit of a pita in that regard.
hmm, I honestly thought it had a better API than this.
 
3:33 AM
I know, right?
I thought registerExtension would let you register PHP functions to be used from JS.
 
Well, it's like it's open source or anything like that.
Probably if someone wanted a better API badly enough they'd contribute one ;)
 
Nope. It's to register JS functions. It's no more useful than an eval wrapper.
 
I'd have to say the idea of using V8 instead of spidermonkey with a nice API over PHP would be much more appeasing to me.
Plus it looks like spidermonkey has no documentation yet
boo
 
spidermonkey/jeagermonkey is one of the few things made by mozilla that works :P it's just as good as v8js
 
meh, I beg to differ. V8 has a much better performance track record.
 
3:38 AM
depends on the task
 
not much better. just a bit afaik
 
Now that I think of it I suppose it would be a lot easier to translate PHP code into JS code than the other way around, sans the extension-specific code.
There's a lot of JS code that just wouldn't make sense in PHP.
 
3:49 AM
Hmm.
int preg_match ( string $pattern , string $subject [, array &$matches [, ...
I don't think that's a very friendly API.
?array preg_match(string $pattern, string $subject);
would surely be better
 
yeah.
 
@Andrea Practically any API with references sucks :(
 
i wonder sometimes if it's how php wrapped stuff or it's just 1:1 with the original library
 
This is much better.
 
i think people blame php for that, but most of time it's just a wrapped library, right?
 
3:54 AM
@Worf Still PHP's fault!
Don't just blindly copy API signatures. Change them to fit the language.
C has to have horrible out-parameter APIs everywhere. PHP doesn't.
Also, ugh. I start writing PHP code again and I remember why I don't write PHP code... Function names and parameter orders I can't remember nor guess. Arcane syntax. Needless verbosity.
 
In a world where IDEs have autocomplete and built-in documentation, is that really even a reason anymore?
 
@Andrea also sometimes i see redundant stuff, like the $offset parameter in preg_match. there's already substr for that. php itself should intern string substrings. basically
$a = "foo"; $b = substr($a, 0, 2); should not allocate a second string, but reference $a with different boundaries
 
@Sherif Yes.
@Worf No, allocating a new string is reasonable
 
@Andrea Sounds like first world problems to me
 
Programming is a first-world problem
3
 
4:00 AM
@Andrea why? not contradicting, just curiosity :P
 
@Worf Because that's its job, to cut out a piece. If you want to reference a part of the string, I guess that would be the job of some sort of slice mechanism (which we don't have)
 
as long it's the same of the original, why actually make a copy? you only do that when it's actually needed imho
 
Because it's not the same as the original?
"foo" !== substr($foo, 0, 2);
 
it is the same of the original, but you just skip elements from top and bottom
 
Making it a completely different string.
 
4:04 AM
@Sherif subsequences interning. i didn't invent it. it's a thing in some languages afaik
 
Except that PHP doesn't have interned strings.
 
it does.
$a = [1,2,3,4]; $b = array_slice($a, 1, 1); $b doesn't allocate anything more. when you access $b[0] you get it internally pointing to $a[1], basically
 
huh?
$b is a brand new array. Of course it allocates.
 
it would actually allocate if you do in a later moment...
$a = [1,2,3,4];
$b = array_slice($a, 1, 1); // just references $a but with different boundaries
$b[1] = 3; // here happens the actual copy
array and strings are already interned, but not their subsequences
@Andrea ^
 
Hmm
Could be a garbage-collection headache, though.
Say you have a 100,000-character string. You reference a short, 100-character section and return it from a function.
 
4:11 AM
well i don't know the implementation details :P i only know the theory
 
You do this for a few 100,000-character strings. You think you've used several hundred characters' worth of memory. No, you've used hundreds of thousands of characters' worth of memory, the original strings weren't GC'd
That's the problem I think
 
Are you talking about what you would like to happen or how it actually works now? I'm confused.
 
@Sherif Who, me? I'm talking about a problem you'd have if you made substr/array_slice not make a copy.
 
We went from interned strings to arrays and I'm not even sure what the problem is anymore.
@Andrea No, I was actually referring to @Worf
 
The former, then.
 
4:13 AM
@Sherif the problem originally was the preg_match(.........., $offset) parameter being redundant with substr()'s job
 
@Worf Well, it's not redundant because substr copies.
That's substr's job... copy
preg_match just reads.
If it didn't copy then it would be redundant.
 
i am saying that if a language had subseq interning, you wouldn't have the need of the $offset parameter
because substr() and array_slice() would be zero cost for reading only
 
Hmm. You know, right now, I really wish var_import was a thing.
I don't want to use eval().
 
@Worf The problem with that theory is it's based on the notion that strings are immutable objects, which in PHP they are not.
 
Implementing var_import could be quite simple, actually. Hmm...
 
4:18 AM
Even PHP 7's interned strings are merely compile-time constants, meaning not all strings are interned in PHP.
 
Ehh
PHP's strings might as well be immutable
 
If the string can't be evaluated at compile-time it can't really be interned.
@Andrea Yea, but then you'd have to deal with all the copy-on-write semantics in the underlying wrapper.
They're just two different approach to try and solve similar problems when it comes to memory efficiency.
One chose the lazy, but easier to implement path, the other is the more sophisticated, but harder to maintain one.
 
Hmm
This could actually be implemented in userland if someone wanted.
 
With copy-on-write you abstract the semantics away from the user, but still achieve the desired effect. With immutable strings you force the user to have to explicitly copy to get that effect.
 
class StringSlice {
    private $string;
    private $offset;
    private $length;
    public function __construct(string $string, int $offset, int $length) {
        ...
    }
    ...
}
 
4:23 AM
How does that make the original string immutable?
 
It doesn't. I'm talking about string slices.
 
yeah, same with arrays, but would be super ugly using that
 
Also, you just probably cost yourself more for the object than the cost of an interned sub-sequence too.
 
@Worf Might be quite elegant actually... slice("abcdef", 1, 4)->toLowerCase()
@Sherif Quite possibly. Though for larger strings the object would be a net benefit memory-wise, maybe.
 
You're still copying the string. I don't get the point.
 
4:25 AM
No copy here.
 
You're passing the string to the constructor. How's that not a copy?
 
@Sherif PHP doesn't copy strings when they're passed around.
 
Unless you're talking PHP 7.
 
Well, old versions of PHP did silly things. But they don't matter now.
 
php interned strings around php 5.2 iirc
 
4:27 AM
No it didn't. I guess you're referring to the fact that the ZVAL is what's being copied internally.
Not the byte-array itself, but whatever.
Still have COW semantics there.
 
no idea. i'm referring to function lol($str){ /* not allocating more memory here */ } $x = "bar"; lol($x);
 
And since it's getting passed to a local-scope, you will likely have to copy it to an instance property, meaning you will invoke a copy regardless.
Sure until you do ...

function __construct($string) {
$this->string = $string;
}
ANd then you do allocate more memory.
At least I'm pretty sure it would. I might be wrong.
 
you sure?
 
@Sherif ?
The object takes up space, sure
But the string isn't copied (or shouldn't be, anyway)
 
@Andrea I'm assuming the instance property breaks the refcount on the global variable.
The fact that it's now in a local scope I mean.
 
4:30 AM
i don't think it would. strings are never copied internally unless you modify them
 
@Sherif The refcount is on the string itself, not the variable
 
modify with $string[0] = 'x'
 
By assigning it to an instance property you are technically modifying it. Between the local variable and instance variable you lose the local container.
Again... I could be wrong. It's been a while since I've revisited PHP internals.
@Andrea Hmmm? Are we talking PHP 7?
 
we are on the same boat, apart i never visited PHP internals :P
 
@Sherif Yes.
 
4:32 AM
Well I know nothing about PHP 7 so...
I'm just talking PHP 5
 
Alright.
PHP 7 is a lot more efficient with things, generally
Also nicer to work with, internally
 
Yea I'll rock that boat when it's production ready
In the mean time I have to work in the real world where people won't let me run PHP 7 in production :/
 
Gosh, var_dump is really, really verbose
Might write my own version...
 
Cannot make static method PHPUnit_Framework_Assert::assertTrue(condition : bool, [message : string = '']) non static
why are you static???
 
Hi
 
4:44 AM
@Andrea I like that var_dump is verbose. Makes it more convenient for debugging.
 
@Sherif Oh I don't mind the information content
 
@Andrea print_r ?
 
You can't spot "Hello World\x00\x00" with print_r, but you can more easily with var_dump
 
@Worf A little better
 
It's easy to build a dynamic website if I know the basics of php
and I familiar with java
 
4:47 AM
@JavaFan That applies to just about any language, doesn't it? The more familiar you are with a tool the easier it is to use.
 
I think php is much easier than JAVA
 
Sure, PHP is a forgiving language, but then again that doesn't necessarily make things inherently easier.
 
Imagine a situation of a website that to show queries from MySQL database
I think I have to build a php class for every webpage
 
You think wrong.
 
what?
wrong why?
 
4:51 AM
Why would you build a PHP class for every webpage?
A PHP class does not equate to a webpage.
 
yes
every php class should include a query
 
It certainly could. Whether or not it should remains to be seen.
I think you're mistaking easy for stupid.
 
Why? please guide me
Or might be I need just a query
 
Because trying to equate a PHP script for a web page is antiquated thinking. a URI is merely a gateway to interface with your PHP. There is not a 1:1 correlation between them.
@JavaFan Have you ever built web sites with Java?
 
No
 
4:57 AM
Then maybe you should learn something like Spring, as you are already familiar with Java, and learn the concepts there.
PHP is not much different, apart from the language.
 
I know J2se not J2EE
 
Well, pick a web framework for Java then and learn it.
Then you have something to compare PHP frameworks to.
 

« first day (1681 days earlier)      last day (3264 days later) »