« first day (3803 days earlier)      last day (1139 days later) » 
01:00 - 21:0021:00 - 00:00

9:00 PM
Is just an alias tho, we already have union types
 
@Danack I find the scalar method versions enormously more easy to read
 
yeah exactly
 
I have to agree
 
You could say "if it's harder to understand, it should be harder to read"....as it draws attention more.
or other reasons.
 
@PeeHaa As you also don't need union types in most sane API's one could discuss
 
9:01 PM
@Danack Yeah. It has two benefits: 1. It's automatically scoped, so no need for array_/string_ prefixes 2. You can read it from left to right, instead of inside to outside.
 
array_map for example, the actual array i'm operating on usually gets hidden at the end of some kinda short closure etc, not exactly in plain sight. Vs $arr->map(...)
 
iterable is just that but you know covers objects which implement Iterable and arrays
:shrug
 
You don't usually see code like this in PHP, simply because it's so hideous. But it's very very common in other languages.
 
@兜甲児 Fair :)
 
Array seems easy enough. I think the major PITA will be multibyte strings.
 
9:04 PM
btw ... I haven't dare to try 8 yet, but can I use array_map and other iteration functions with an object which implements Iterable ? Or do I still have to hack it through iterator_to_array
 
m�ltibyte strings
 
@IluTov Do you have a hit-list ?
 
Also: can we add @DaveRandom to it?
 
@MarkR Hit list as in what methods to add first?
 
@IluTov Yeah. I'm not sure 1 or 2 really makes sense, there's probably a good 50 or so that would be viable.
 
9:07 PM
the harder ones to define are where they take two of the same type
 
@MarkR That's the point. We could start with a few and build from there. Trying to get all 50 right at once is likely impossible, will lead to endless conversations and eventually burnout.
 
strpos, for instance
 
@PeeHaa I always knew I was special
 
do you add $string->positionOf($otherString) or $string->positionIn($otherString) or both, and with what naming convention
 
indexOf obv :P
 
9:09 PM
Are you guys discussing a string class ?
 
@MarkR @IMSoP this
 
@兜甲児 sort of; there's a long-standing suggestion of using method syntax on non-objects
 
The symfony String component has some nice ideas in that regard
 
@MarkR sorry, I don't get it
 
Personally I would opt out for something dead simple, method names like "cut" or "has" ...
etc
 
@MarkR I think $array->keys() and $array->values() are low hanging fruit that are hard to get wrong.
 
ah, JS; the only language with an even more messed up type juggling system than PHP :P
 
^ this is super simple I like it
 
@IluTov Sure. Did you write any code for it or are you looking at Nikita's?
 
@MarkR I did write code for the scalar extensions but no, not for this one. I've just looked at my list half an hour ago and thought I'd ask before starting with anything specific.
 
9:13 PM
@MarkR in that case, make sure to copy this one too developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…
 
that is evil
 
@IMSoP Not everything is a good idea :P but it's use of scalar functions absolutely is
 
well, it's more "everything's an object", which yes, I'm fine with
I'm just not sure I'd go out of my way to match any names, rather than just having a consistent naming scheme
 
There's some benefits in transferrable knowledge between the two major ecosystems most people use
 
Are we talking about making primitives objects ? Or implementing straight classes for primitive values
 
9:17 PM
That last part ^^^ is why I am not sure about doing it just a couple of methods at a time
The consistency of the naming scheme
 
The later eh ... not good idea
 
Neither, we're talking about allowing primatives to be used as the left hand side of a method call. The scalar would remain a scalar, but the code would effectively be re-written from 123->foo($x) to int_foo(123, $x);
 
@PeeHaa The latter? What does that mean?
 
> having a consistent naming scheme
Just doing some random things without thinking about what the rest will look like
That's basically the reason we ended up with the API we have :P
 
If it comes down to naming I'd say StringObject NumberObject IntObject WhateverObject to transition into primitives as objects for later
there's ArrayObject right
 
9:20 PM
@PeeHaa precisely; emphasising "transferrable knowledge" is what gave us an API that's half C, half Perl, and the third half Rasmus's imagination
 
IMO things like indexOf etc would benefit from a more higher level approach. [].indexOf() "hello".indexOf() and there's the Q of if defaults should be changed. indexOf doing strict type checks for example.
We may still be stuck with needing union return values though :( although I guess we could at least make them null instead of false? or is that a bad idea
 
well, if you're talking about positionOf (or indexOf, if you really insist), the "not found" case could be -1 maybe?
 
Normally it would be for strings, but for arrays, -1 can be a valid key
So it's currently false, which weakly equates to 0, leading to countless errors over the years.
 
Why not sticking to the current strpos implementation strpos ( string $haystack , string $needle , int $offset = 0 ) : int|false
Ah
good point
 
well, on arrays, the current equivalent would be array_search, no?
 
9:28 PM
Have to agree with -1
so there are no type juggling confusions
 
Yeah. A giant red box on the docs for it just to point out the flaw >.<
IMO null would be significantly better for the simple reason we have ??
 
it has all the same type coercions as false, though
so you'd just have the extra confusion of remembering when to use ===false and when ===null
 
Yeah, but it has the advantage of being able to use null coalescing to assign some other value to the result.
 
not sure when that would be useful; what would you assign? 42?
 
Just making stuff up clearly, but:

$foo = "mystring";
$bar = $foo.substr($foo.indexOf('str') ?? 0)
 
9:33 PM
well, in that case you can just (int) the result, with either false or null
 
Fair point, although it doesn't seem as elegant to me.
 
wild idea: maybe there shouldn't be a "first position of" function in the first place, but an "iterate positions of" that gives a lazy iterator of zero or more matches
$position = $foo->search($bar)->first()
which kind of just punts the question to what []->first() should return
 
@Girgias I see you're thinking about looking into function autoloading. Are you thinking about extending the existing autoload function or adding a completely different one for functions?
 
although I think 90% of the trouble caused by the strpos return is (was) actually because of the lack of str_contains and str_starts_with
 
@PeeHaa No, the problem is we didn't think at all before adding new stuff ^^
 
9:39 PM
Oh man, I trashed so many strpos statements when 8.0 came. PHPStorm was like "Yo, you've got these things, I can change them" and I was like "Yes please" and Boom. Done.
 
@MarkR Need more of @Danack's words, but mostly from looking breefly at @ircmaxell's old patch it's a new one, which would also be useful for a generic one to add declared types
 
once you've separated out those, it's easy enough to write if ( $foo->contains($bar) ) { $pos = $foo->positionOf($bar); } and not have to think about what terminal value positionOf gives
 
@Girgias ah I see he already moved it to Zend too. Awesome.
 
Well IIRC it is based on PHP 5.5 or something like that lol, so will need some looking into again
 
seems like Anthony was having a fun Christmas 7 years ago ;)
 
9:44 PM
This looks roughly like what I was just browsing through in master (although now there's JIT to consider, which I have no earthly idea about)
 
I thought the problem with function autoloading wasn't the implementation though, it was finding a time machine to go back and point out that adding global function fallback is a bad idea
 
@MarkR @IMSoP I'll create a POC soon with keys and values, changing what functions to add initially can be changed trivially.
 
@IluTov Do you have an idea of how you're going to scope the functions? Some kind of mangled class name?
 
stick some null bytes in it? :P
 
@MarkR I wasn't planning on making them global functions.
 
9:51 PM
@IluTov mangled class statics or something else?
 
@MarkR I guess that's not fully clear yet.
 
10:06 PM
Incident on 2021-03-15 20:38 UTC ・ GitHub Pages has Partial Outage
 
@cmb, if you are around, I think we could use your help to coordinate the efforts around implementing AVIF/HEIF support.
 
cmb
yep, I'm here :)
and sorry, I guess I confused you with Martin
first step would be to provide a PR which updates bundled libgd with AVIF and HEIF support
next step could be to actually introduce imagecreatefromavif() etc.
getimagesize() and friends could follow up (shouldn't use libheif or libavif)
Windows support could follow (i.e. actually having libavif and libheif builds for Windows)
I don't think that either step would be particularly hard, but I don't have much time to help, unfortunately.
 
Oh, ok! I thought Martin was actively working on this too
I didn't want to duplicate his efforts
I think the only area where we're really stuck is getimagesize()
since right now the only solution we have requires libavif. I've told people that the PHP team wouldn't want to require an entire other library just for this
 
cmb
I presume both formats have a signature (like WebP has).
 
Unless getimagesize() could only include support for AVIF if libavif was present, and we could compile that conditionally
Unfortunately Joe Drago (author of libavif) has said there's not a straightforward way to just look at the bytes and get the size.
 
cmb
10:19 PM
getimagesize() is part of ext/standard; we can't introduce a hard dependency on libavif/libheif there; dynamic loading might be acceptable, but is a terrible solution
 
lol
I don't feel proud of it
 
cmb
it might be acceptable that getimagesize() just reports the format, and reports false or null for the actual image dimensions
 
that, we can do without difficulty
though it seems a little sad
 
cmb
users can then still call imagecreatefromavif() and imagesx()/imagesy()
@BenMorss yep, but if the format doesn't allow to retrieve the actual image dimension easily, that might not be the best design
I haven't looked into either, so maybe I'm missing something.
 
Is support in getimagesize needed at all?
What is that function even for?
 
10:23 PM
Once the AVIF image is decoded into GD's format, imagesx()/imagesy() should work
 
cmb
@NikiC not necessarily
 
Because those values get stored in the struct
 
cmb
indeed
 
Folks from at least two big PHP-based CMSs tell me getimagesize() is needed to recognize an image
 
cmb
well, I wouldn't trust getimagesize() to recognize images
 
10:24 PM
I don't know if they actually expect to get the size :)
 
cmb
anyway, we can still work on that later (maybe introduce something like getimagesize() in ext/gd or so)
 
Yeah, I think the image recognition is much more useful than the actual size
 
I'm happy to work on importing gd_avif.c and what's needed for the build process into PHP's gd implementation
 
cmb
great!
 
I can check with CMS folks about getimagesize()... I'd really like to get it to work, but we're unexpectedly stymied
 
cmb
10:27 PM
getimagesize()[3] is most useful though, since you get height="yyy" width="xxx" to directly insert into an <img> :p
 
ooo
see, that's why I miss using PHP
It just makes things... convenient
 
@cmb heh
 
cmb
Actually, getimagesize() and ext/gd are somewhat orthogonal. If you need to work with the image, you need the latter anyway. If you just want to recognize an image, you can use file_info instead of getimagesize (neither works reliably, though).
What people may actually be looking for is imagecreatefromfile() (there is alread imagecreatefromstring(), with obvious deficiencies).
 
All issues have been resolved!
 
that's an ambitious statement given recent performance
 
10:38 PM
ok, here's the issue from Drupal:
Looks like they only need the image type, not the dimensions
though they also discuss that perhaps they need a different way to get the type of an image
And, actually, it looks like Joomla can use one of a few methods:

https://github.com/joomla/joomla-cms/issues/30666#issuecomment-695192567
And, finally, to complete this roundup of the three most popular CMSs, WordPress uses methods beyond `getimagesize()` as well:

https://github.com/WordPress/wordpress-develop/pull/1024/files#diff-4d28b6652f0dab208c19aa45e1cf09f3c967060d8cc77502bfcd473a3216b612R5016
 
cmb
@BenMorss I'd say, start with something that is easily doable, and then discuss, and notify relevant CMS/app maintainers about it. Can still go from there. :)
 
So, out of these three major use cases, the only one that really relies on getimagesize() is Drupal. Is it reasonable to do what you said above?

"getimagesize() just reports the format, and reports false or null for the actual image dimensions"
it's a little odd, but would solve at least these use cases
 
cmb
yeah, why not; if there are valid complaints, we can still see what we can do.
 
And I do see that the docs already contain specific advice for a few image formats
excellent then!
forward
 
cmb
10:53 PM
otherwise, we may not have avif/heif support before the next image formats are widely available ;)
also, there are more serious issues, like ext/gd completely ignoring EXIF/IPTC tags
 
11:12 PM
> Elon Musk is getting in on the NFT gold rush by selling a new electronic music track he's apparently produced as an NFT. The techno song drop is appropriate considering Musk named himself the "technoking" of Tesla in a filing with the U.S. Securities and Exchange Commission on Monday.
stoner_wat.jpg
 
01:00 - 21:0021:00 - 00:00

« first day (3803 days earlier)      last day (1139 days later) »