« first day (4545 days earlier)      last day (409 days later) » 

7:12 AM
@Danack Both actually. I work at a company that provides interactive learning online. The idea was to provide students with an option to collaborate on the curriculum. At the time, we couldn't get it to work properly, but it always remained interesting to me
Especially when I noticed that (as far as I could find on the internet), no one attempted to do it with PHP yet. Simply because OT requires async operations. With people sometimes typing over 300+ characters per minute, you obviously can't have anything blocking. I managed to get it working with ReactPHP
 
 
4 hours later…
11:17 AM
mORNING
 
 
3 hours later…
2:11 PM
github is having problems, at least committing from the "resolve conflicts" page is borken.
 
2:40 PM
Still? There was some major outage earlier, but it's fine for me now.
 
@TimWolla Dan probably got the timezone wrong ;-)
 
Just use UTC to avoid the DST shenanigans.
 
3:37 PM
If you compiled PHP to C, would you want [1,2, 3] notation to compile down to C array, or to linked list? Or both depending on annotations?
 
@TimWolla as I said, it wasn't able to make a commit from the "resolve conflicts" page, instead giving an error message of "this page is out of date, click to refresh".
@OlleHärstedt I'd probably want to examine my life choices first...
5
 
@Danack Feasible/Desirable/Viable is another discussion ;)
 
4:04 PM
@OlleHärstedt PHP Arrays, are both indexed arrays and linked lists. And also [1, 2, 3] is not the same as [1, 3, 2].
 
 
2 hours later…
5:40 PM
Well it's enough to be "semantically backwards-compatible" right? So for linked lists you could use spldoublylinkedlist instead of array notation. OR the other way around, use splfixedsizearray instead and have [1, 2, 3] mean a linked list.

[1, 2, 3] != [1, 3, 2] fits well into C semantics, so no problem there. :)
 
I think "depending on annotations" is always going to be the way with mapping types between languages, even if there's some default
$a = [1,2,3]; could nicely turn into a C int[], but then you run $a[] = 'hello'; or $a[] = new Something; and everything will crash hard
or it turns into a zval[], and then you run $a['string-key'] = 'hello';
any more general than that, and you might as well use the existing Zend Engine representation, with its hybrid hashtable/linked-list/packed-when-possible shenanigans
 
5:55 PM
@IMSoP I just forbid that actually, it's a type error in my system.
@IMSoP Yep sure, but this was already tried by Facebook with their PHP-to-C++ compiler, so I'm interested in the other approach. Same as in kphp, I think.
 
I can't really picture what you're trying to achieve then
is it just "PHP syntax, but won't compile any real PHP programs", like Zephir only more so? zephir-lang.com/en
 
6:28 PM
@IMSoP It's a very limited use-case, mostly for my own fun, but basically having code that at the same time is a high-level C and also works semantically (but not performance-wise, of course) the same in PHP. I'm also trying out some concepts related to memory-polymorphism that I wanted to do anyway.
And yeah, Zephir is neither syntactically nor semantically compatible with PHP, so slightly different milestone than me. :)
 
7:04 PM
@OlleHärstedt then you can probably get away with keeping it simple and compile to a plain C array; you might still want to start with annotations to distinguish between int[] and string[] without too much lookahead though
after that, I'd say some basic types of Hash Table (i.e. non-consecutive keys, direct index access only) would be more useful than linked list, and simpler than dealing with all PHP's iteration behaviours
 
7:27 PM
If I'm working on a package and want that package to be compatible with all PHP versions from 7.4 to 8.1, but composer keeps requiring packages that are only compatible with 7.4 or only 8.0/8.1, are there any ways I can get composer to only try to find a set of versions that are compatible with all?
 
meaning that every package is compatible with 7.4 && 8.1?
 
yeah
I guess that usually package.lock isn't shipped with your composer package so it wouldn't matter but in this case it's something we use internally
 
> there any ways I can get composer to only try to find a set of versions that are compatible with all?
I think you're solving the wrong problem.....
It sounds like the problem you should be solving is to run your tests against all the versions of PHP you want to support?
 
Infra wants to deploy PHP 8 to the same exact codebase that has 7.4 code. I'd agree we're trying to solve the wrong problem tho :P
 
it does feel like theoretically Composer could calculate that intersection of constraints (or prove that it's unresolvable), but it probably isn't a common approach to upgrades
a lot of the time, even the direct requirements in composer.json are going to have to be different
 
7:35 PM
@scorgn does the 7.4 code run on 8.0?
 
@Tiffany It would if it weren't for the packages not being compatible with both
 
so just require 8.1 packages?
 
Then it wouldn't be compatible with 7.4
 
actually, thinking about it, Composer will always prefer the highest version within a constraint; so if a full composer update on PHP 7.4 gives you packages that don't run on 8.1, probably no such set of packages exists
because it's unlikely that downgrading something will get you that extra compatibility
 
@scorgn if they're deploying 8.x code to a 7.4 codebase............there's a contradiction of ideas
something has to give :P
 
7:37 PM
@IMSoP In this case it actually does, downgrading a package will put it to an earlier version that doesn't require another package
@Tiffany Deploying PHP 8.0 in general, not code (I edited my message to fix that :P)
 
then I guess you can lock that in to your composer.json constraint
 
ahh
 
normally deployments work where you stop code deployments going to the 7.4 servers, spin up 8.0 servers, and have new deployments go there
but they don't wanna do that for some odd reason and tell us we need it to be compatible with both 7.4 and 8.0
 
are there options for dropping 7.4 support?
 
Well we will right after we have 8 working
 
7:39 PM
i.e. put a < in require or a conflicts
 
@IMSoP Yup I can get it working that way. I'm actually not trying to get it working though :p
 
so, in fact, it feels like the only legitimate case of not including the lock file with the deployment I've seen.
what you're describing looks a lot like php version >= 7.4, then leave whatever env compute its dependencies
 
That's actually not a bad idea
 
other idea I have is deploy 8.0, use packages that support 7.4, fork the packages that aren't compatible with 8.0, and fix the issues, ensuring the code still works with 7.4....
but that seems like mroe work
 
But it's only temporary so it seems like we want to have .lock in there in general
Yeah that also seems like a lot of work lol
I'm not letting on that technically we can get the packages to a set of versions that will be compatible with both if we add specific constraints to the packages that aren't
I'm moreso just trying to prove it's not possible with composer to do what they want
and have them change their deployment strategy
 
7:44 PM
unrelatingly, xdebug + docker feels like the gift that never ends giving
makes from great philosophical questions like, what is even a breakpoint
 
@FélixAdriyelGagnon-Grenier is this a sarcastic remark about getting xdebug to work with docker?
or a compliment?
brain can't deduce the meaning :P
 
@Danack LOL!
 
a bit of both? I'm genuinely having metaphysical interests about what is a breakpoint, now that I'm trying to understand how the ide communicates a breakpoint with the server.
though if I'm being honest, it's been way easier to get phpstorm to recognize an incoming debug request than I'd imagine
now if it could only work. the request seems to hang somewhere in limbo
 
It can be inferred from usage when it contains elements. Which it must. Because it's fixed-size currently. spldoublylinkedlist does not accept constructor args tho, so inference would be a bit more complex.

Yeah, iteration is interesting...
 
7:51 PM
I've had...experience...with docker networking and xdebug, it wasn't fun
and couldn't get it to consistently work, but no longer on that project 🙃
ah, my issue was ufw related
 
8:08 PM
@OlleHärstedt I would have thought /** @var int[42] */ $foo = []; and /** @var hash<string, int> */ $foo = []; would be easier both to implement and to use with normal-looking PHP code
 
Got a bit stuck: How to turn this string: "codemirror\addon\display\fullscreen.js" into an array like $arr['codemirror']['addon']['display']? (file at the end can be skipped)
I mean, splitting the string is easy enough and adding the results as keys to an array as well. But adding each result as a child of the previous one seems a bit more challenging
 
@icecub the approach I've used before is to use a reference variable to point at each sub-array in turn, like this: 3v4l.org/NdKLY
 
@IMSoP Amazing! Thanks a lot, I can work with that.
 
glad I was able to lay my hand on the example, because it's painful to describe without it
 
8:27 PM
Ye I can imagine. It's clear now though
 
@IMSoP Hey that's a good tip for the length of a fixed-size array, will jot it down. I was working on /** @var SplDoublyLinkedList<int> */ as an example notation for lists.
Didn't decide on hashtable yet. But I think I'll follow Psalm and Phpdoc convention: just /** @var array<string, Point> */ $pointsByName = [];
(You can also do tuples actually, $things = [1, 2, "foo", new Bar()];)
 
I ended up doing this: pastebin.com/g956pzVK Removed some parts of it so I can feed a whole range of strings and actually end up with a nice filetree array
 
8:51 PM
@Tiffany tbh it goes well, I think my issue is path-mapping related.
and solved!
 
9:08 PM
@icecub I'd recommend keeping the unset($var_ref); in there, just as a habit; it's so easy to accidentally add a $var_ref = ... and wonder why the value appears somewhere "random" in the array
I avoid references wherever possible, because they're such a pain to debug, and when I do use them, I keep them tightly scoped with an explicit unset once they're not needed
 
Howdy! Is there any compact way of testing a a conditional against an array, e.g. seeing if all strings in a path are is_dir, without using a (relatively) long foreach loop? I was thinking of using Array_Filter and comparing the count before and after
 
my first thought is also array_filter, but using a negative test so that you just check if the result is zero
you could do something cleverer with array_reduce to short-cut unnecessary tests once you've found a "no"
 
@IMSoP That's a smart way to avoid counting it twice, thanks!
 
I'm sure a lot of "Collection" and "functional programming" libraries have helpers like all(callable $test) and none(callable $test) to hide the foreach loop for you
because foreach with break is probably as efficient as you can get in pure PHP, which matters if the test is slow and/or the list is long
function all(iterable $list, callable $test): bool {
    foreach ( $iterable as $item ) {
        if ( ! $test($item) ) {
            return false;
       }
    }
    return true;
}
something like that would do it, I think
 
9:40 PM
@SlamJammington OCaml has a find function on lists using a lambda: v2.ocaml.org/api/List.html
> find f l returns the first element of the list l that satisfies the predicate f.
I'm sure FP libs to PHP have similar functions :)
50% sure maybe
 

« first day (4545 days earlier)      last day (409 days later) »