« first day (3385 days earlier)      last day (1546 days later) » 

12:39 AM
"Whoops" - When you write a while(true) loop to write to the database and forget the exit condition
 
12:49 AM
@MarkR ... lol
 
9200+ file uploads later (DB query used duplicate key to decide if a file could be uploaded... was meant to exit the first time it didnt get the exception)
hurray for PHP timeouts :P
 
 
3 hours later…
3:54 AM
web scraping
 
 
5 hours later…
9:02 AM
morning
 
9:24 AM
o/
 
cmb
\o
 
 
1 hour later…
10:27 AM
@PeeHaa are you basically just trying to turn a bitfield (binary string) into an array of bools?
 
10:40 AM
@DaveRandom array_map("boolval", array_merge(...array_map(function($n) { return str_split(str_pad(decbin(hexdec($n)), 16, 0, STR_PAD_LEFT)); }, str_split(bin2hex($in), 4))));
 
that's certainly going to do it, but I can't actually figure out if that's exactly what he wants :-P
 
actually, str_split() with ord and decbin is easier
instead of this
 
yeh I don't like that
I'd actually prefer to use bitwise ops for it anyway, just for readability
(ymmv)
 
agree :-D
In actual code.. yea
 
 
1 hour later…
11:48 AM
Morning o/
 
Gninrom \o
 
12:28 PM
abstract class Foo<T> {}
class Bar extends Foo<int> {}
function test(Foo<int> $param) {}
test(new Bar);
^-- now works and mostly does reasonable things
class Foo<T> {}
function test(Foo<int> $param) {}
test(new Foo<int>);
^-- getting that to work would be soooo much harder though
 
12:43 PM
Maybe you consider compiling of each concrete generic type into separate class name? Then it should be easier to implement...
So, hierarchy will be Foo->Foo<int>->Bar and instanceof check will happily accept both test(new Bar) and test(new Foo<int>).
Separate class will help to reflect classes later:
`(new ReflectionClass(Foo<int>::class))->getMethod('templateMethod')->getReturnType()' => 'int' or `(new ReflectionFunction('test'))->getParameter(0)->getClass()` => reflection class instance for `Foo<int>`
 
12:59 PM
Difficult on a parsing level or data representation?
 
1:16 PM
They really made a mess of docker desktop in the 2.2 branch, I think everything is broken in it.
 
@lisachenko It's not possible to construct such a hierarchy if there are variant type parameters
@bwoebi I've been wondering what the type resolution semantics are supposed to be. Say you have abstract class Foo<T> {} with an unused type parameter and then you do Foo<DoesntExist>. Is that an error or not?
That is, is the type DoesntExist immediately loaded?
I would guess that, going by the existing behavior we have regarding type loading, the answer is "no" and that's valid code
Otherwise one wouldn't even be able to construct types like Foo<DateTimeZone|IntlDateTimeZone>, where the latter is only used if the extension is available
@lisachenko To clarify, say you have class Traversable<out T>, then Traversable<A> subtype Traversable<B> iff A subtype B. You can't model that with simple class entry inheritance
And per what I was saying above, even without type parameter variance you might have Foo<A> equals Foo<B> where A equals B in a non-trivial way (assuming types are not fully pre-resolved)
 
@NikiC oh, now I see that it is impossible. Thank you )
 
@NikiC Yeah, we should mirror the existing type loading semantics
 
@NikiC for me it's better to shut up )) Just learning PHP engine and its possibilities
 
1:48 PM
abstract class Test<T> {}
class Test2 extends Test<UndefinedClass> {}
function test(Test<UndefinedClass> $param) {}

$obj = new Test2;
test($obj);
 
@NikiC btw, Java restricts generic types to be non-complex (union types are not allowed for generics)
 
@bwoebi ^-- would this code pass (or some variant with more classes in between)? I.e. type equality holds even if classes cannot be loaded, based on string comparison?
 
@NikiC for this case, I would expect compile-time error during declaration of class Test2
 
@lisachenko Java does not have union types, no?
 
@NikiC Yes.
Because in the end a generic arg is just a name to be substituted in the place of a type name.
In the type gets evaluated, also the generic gets evaluated.
I even can imagine this being nice for some black magic :-D
But that's not an argument in favor haha
 
1:52 PM
I too would expect an error as soon as attempting to define Test2 based on the principle of erroring at the earliest opportunity to detect it.
 
@MarkR I we do that, then we should also trigger checks for function args when linking the classes - which we don't currently.
Generics are just placeholders in that sense
 
@MarkR The problem is that this does not match how type checks currently work
E.g. you can write class Foo { public function test(Bar $bar) {} } and this is not going to try to load Bar. You will not get an error if the class is not definde
 
Though @NikiC ... what would happen if there were class Foo<T extends Bar> {} and you do new Buzz<NotABar>?
 
It would be weird if writing class Foo { public function test(Baz<Bar> $bar) {} } would trigger class loading then
@bwoebi I think the answer would be the same as how variance checks work
 
but isnt that only because test(Bar $bar) might never be called anyways, whereas Foo<UndefinedClass> is entirely unusable?
 
1:55 PM
@NikiC yeah true
 
I.e. we try to prove the constraint without loading first, and then load if we fail
 
Just use Java!
 
@beberlei It's perfectly usable, because the type is never actually used ;)
 
ah right...
 
And really, the more interesting case is the Collection<DateTimeZone|IntlDateTimeZone> mentioned above. That seems like a conceivable type to have even if you don't have a hard dependency on the intl extension
 
1:59 PM
@NikiC @Ocramius will be happy about the possibility to hide some more state :-D
And check that innocuously
 
My prediction is that 95% of developers will use Generics for typed collections only. And the remaining 5% will use it for weird things. Too much effort for such little use.
 
Id personally prefer not to have the nuance in it. If you're extending something, that something should exist, and in the case of generics that would mean fully loading the type.
 
@Gordon That's not right I guess
 
@bwoebi 99% for typed collections, 1% for weird things?
 
@MarkR It would certainly be easier to implement it that way ...
 
2:03 PM
If class extends generic, this generic should be resoved at compile-time. As well as used generic type. And restrict usage of generic functions/methods. A method can be generic only if current class is declared generic as well.
 
Lazy type resolution is a pretty fugly thing to deal with
I'll open an issue on the RFC repo ... the answer doesn't seem super clear
 
It would also leave the door open for changing the internal mechanics of generics at a later date, such as baking concrete implementations of certain things, without changing external behaviour
 
@Gordon I mean the 95/5 ratio is fine - in terms of usage, but not in terms of devs using it at all
 
If generics do land, I'm immediately re-writing my data access layer, no more code generation..... class Query<T> { public function query(): ResultSet<T> } ... which I guess is still typed collections, but more than an array
 
@bwoebi :D
 
2:12 PM
For PHP8 (and generics), I would like to see general Object class in PHP which will be default base class for all classes in PHP. To define collection of objects like this Collection<T extends Object>
 
and I'm likely going to borrow some stuff out of rust and do a class Result<T> { public T $type; public Exception $error; }
 
All I hear is Java lol
 
But yes, almost every single thing that's currently using docblock Type[] is probably going to get properly typed
 
@Gordon ))
 
2:17 PM
@lisachenko well, we have the object type - so we could just allow the special ? extends object without object being an actual type (just like we will allow ? extends (int|string) I suppose ??)
 
How can a byref extend a byval?
 
@bwoebi I think it would better to introduce it, even from the PHP's core point of view (eg. copying default functions and object handlers from parent to child class). Also it would be nice to have a real type for that, and not a virtual one.
@bwoebi and what can I pass to Generic<? extends (int|string)> ??
It looks weird...
Actually, generic with union types - is really bad idea. Single type or class in generic - OK, inheritance/parent class check - OK, union types - NO...
 
Does the union type stuff already support recursive branching or is it flattened?

class Unionified<T> {
public T|X $value;
}

$x = new Unionified<A|B>;
$x->value now A|B|X ?
 
class UnionIntString { public int|string $value;} class UnionCollection<T extends UnionIntString>{}
 
2:40 PM
@lisachenko That would be such an arbitrary limitation though
Like int|string is the key type of arrays for example
 
@NikiC Does monday morning work? :-)
 
Generic<T : int|string> is on the deep end of things, but array<int|string> doesn't look particularly out of place ;)
@Derick What's on the list?
 
weakmaps, ::class, and : static, and perhaps we can chat about generics if that's far enough proceeded
Might probably get two or three eps out of it
 
@NikiC for array - yes, it can be good, but sometimes I want to have two separate types in PHP instead of single array: list and map.
list type will have integer indexes and will be packed all the time, whereas map will use string type keys. In this case Marco will be happy ))
There are several places in PHP that can benefit from separate types (instead of checking ZEND_ARRAY_NOT_PACKED attr)
 
ah handy, thanks
Slight tangent, but do things like function foo(): Bar<Baz> get resolved beforehand when preloading?
 
3:12 PM
@lisachenko There's no reason for this, is there? Current object should be fine.
class Collection<T: object> {}
 
@LeviMorrison Why not just introduce a normal class? And simplify code checks and syntax.
 
We could. I was just saying there isn't any need to change it for this feature. Not that I see, at least.
 
There is none, you are correct
 
user2286243
@Derick Thank you. But it needs you to know the timezone used by MySQL server. In the, I decided to force MySQL to always use UTC.
 
@LeviMorrison yes, it doesn't required for generics (separate RFC should be for that)
 
3:17 PM
@VarunAgw That's always a good idea :-)
 
@Derick what time?
 
@LeviMorrison the more I learn PHP internals, the more improvements I want to do ))
 
Yep. :)
 
@lisachenko lol
 
@NikiC ))
 
3:19 PM
@NikiC What works for you? 10am UTC/11am CET?
 
@lisachenko The more you learn the more you want to improve. Then comes a point where the more you learn the more you realize you can't improve anything :P
6
@Derick Works for me
 
@NikiC But hopefully we have you and Dmitry ))
 
@NikiC Cool - I'll shoot you an email with talking points then soonish
 
@NikiC And only narrow windows for BC breaks.
Which may not align with your personal schedule and may not have time to do much.
I found a todo in my notepad:
> In PHP 8, ensure that internal method compatibilities are fatal errors.
Have we done this yet?
 
@LeviMorrison yes
I made an rfc for that
@LeviMorrison Here it is: wiki.php.net/rfc/lsp_errors
 
3:26 PM
Thank you!
And you are sure that internal classes and such get tested for the same LSP errors?
 
we spoke about that on the podcast too!
 
Morning
 
madainn mhath!
 
o/
 
3:41 PM
\o
 
o\
 
Hello! I'm trying to add a breakline to the implode function of php and it's impossible for me. I'm using tooltip from bootstrap
<a href="#"cass="d-inline-block" tabindex="0" data-toggle="tooltip" title="'.implode(",\n", $whoLiked).'">
Any ideas why it's not working?
 
@NikiC Suggestion: for generic parameters, always resolve at compile time (similar to inheritance). Rationale: when you eventually add bounded type parameters, it's not the usage that's invalid, it's the declaration that is. So rather than cause a weirdness of "this sometimes loads, sometimes not, based on these weird chain of rules", just make it always load
 
@GabrielDube how do you know its not working?
 
3:50 PM
@Ghostff I's showing in one line, example: name1, name2
It's*
 
@GabrielDube are you writing to a file?
 
I'm echoing that line
@Ghostff echo '<a href="#"cass="d-inline-block" tabindex="0" data-toggle="tooltip" title="'.implode(",\n", $whoLiked).'"><img src="'.$emojiData->getUrl().'" width="15px">'.$numberRows.'</a>
 
@GabrielDube so when you view page source, there is no new line?
 
@Ghostff Nope, this is what the source is showing:

<a href="#"cass="d-inline-block" tabindex="0" data-toggle="tooltip" title="Christine,
Tuesday">
 
@GabrielDube not sure, maybe try "\r\n"
 
3:58 PM
Monomorphization notes: github.com/PHPGenerics/php-generics-rfc/issues/44 cc @Jasny-ArnoldDaniels
 
@Ghostff I was able to fix it by adding data-html="true" and then replacing the \n with <br>
 
@ircmaxell Heh, we're there already ;)
This is basically how variance checks work. They don't load if it's possible to prove the subtyping relationship without loading, otherwise they do.
But yes, I think the general consensus seems to eagerly load generic types, at least if the class is eagerly loaded
 
@GabrielDube using a type of template framework?
 
@Ghostff I'm using CodeIgniter
 
Hi, I'm wondering how stupid the idea is to have session management done by postgres roles...
the only downside I thought of is the maximum role name length which is 63 bytes according to show max_identifier_length;
SID can be created with pgcrypto
for each logged in user, a temporary role can be created with the same rights as the source user role
But I haven't wrote or used such a mechanism before, so I'm wondering if it has been done before, and how it would perform
owasp says the SID length must be at least 128 bits, which will fit in the role name length...
 
4:12 PM
@NikiC Oh, I'm aware that it's already there. But it's already there because the behavior was there before variance was added. This is something new (rather than a new behavior on existing functionality), so I'd suggest breaking the pattern at this point
 
yeah
 
@Code4R7 what are the pros?
 
When the PHP project uses Postgres, the method adds authentication on the database level, so the attack vector is smaller.
ultimately, the need for an application account to access the data won't be needed
and you don't need your framework to think about authentication and autorisation
but the downside is that it will be postgres-specific
 
4:31 PM
Am sorry, I meant in comparison to an actual table. I doubt its would be good idea.
 
@ircmaxell Loading too early causes issues; see the variance checks :)
 
5:05 PM
@bwoebi <_<
 
@NikiC hopefully now everything is addressed with reflection default values ;) i still have a few rounds of review in me :o
(you shall not wear me down ;-))
 
5:50 PM
I think it would be a good idea. The weak point would be that I need an application account to create and remove temporary roles, but that could be done using a security definer function
It is a bit specific, but implementing SessionHandlerInterface is also specific.
each literal character can hold 8 bits of entropy (except for 0x00)
so that would be roughly equivalent to a SID of 480 bits...
 
6:07 PM
@beberlei Which PR is that?
 
6:26 PM
I'm getting tired of handling sessions in PHP... SessionUpdateTimestampHandlerInterface ? It's not properly documented since 2017...
 
 
1 hour later…
7:30 PM
@Code4R7 That sounds a bit like using a hydraulic press to drive a nail into a board. It will do the job, but if you just want to drive a nail, a hammer will do nicely.
 
8:20 PM
@Trowski Rather think of it as throwing the big clumsy old hammer out of the (opened) window and go buy a new one that is easier to use and shines and stuff.
All a session has to do is maintain state through a temporary random ID. Why couldn't I do that without PHP's built-in and not very transparant session functions?
 
git push DANGER master, always like contributing to php-src :p
 
8:43 PM
@Code4R7 You can. I just wouldn't use postgres roles for it.
@NikiC With 7.4 on macOS, fwrite is returning false when it used to return 0 on a non-blocking stream. Checking the value of errno with FFI, it is EAGAIN.
Specifically is happening on an IPC socket. Any ideas?
 
@Trowski update to a newer version
tomorrow :)
 
@NikiC Ah, so fixed in 7.4.2?
 
yes, or at least I think so
 
Sounds good
 
9:18 PM
@Trowski We might skip the assertion on PHP 7.4.1 and 7.4.0 then.
 
@kelunik Yeah, probably a good idea.
@kelunik Actually, it's not that simple, we have to treat false like 0 as well.
 

« first day (3385 days earlier)      last day (1546 days later) »