« first day (4268 days earlier)      last day (680 days later) » 

1:43 AM
> we also have a case in Symfony where defining service definitions in yaml doesn't work with enums because there is no way to express the "->value" part.
Jul 1, 2021 at 15:23, by Danack
....I never said the failings of the Laravel community were unique to them. Symfony are now also discovering that doing DI with a powerful enough injector is a bit better than having a massively complex hard-coded config format.
Apropos of nothing, what is a polite way of saying "I don't think your unfortunate choices should be allowed to influence the design of an upstream project?" Or is that polite enough?
 
2:31 AM
@Danack I find that very polite. could remove "your" to put less onus on the person.
 
less onus is good. But the directionality is needed.
"Unfortunate choices in a downstream project should not be allowed to influence the design of an upstream project."
 
/unless someone is into onus.
 
could even go so far as "must" tbh
though that might be a bit too confrontational
 
yeah, that might be a bit strong.
 
2:35 AM
:P
I find this quite coincidental, I've been passing the last few days refactoring userland enums to native ones, and I must say that what I find nice about enums is that they are not strings
I like having to cast values as enums
 
@FélixAdriyelGagnon-Grenier so, "now you're thinking with types", which is an easier way of thinking about programming........and more a amusing phrase if you're familiar with the series of adverts for British Gas from the 1980s.........which you might not be, I guess.
 
that would be a valid guess. what is even going on
 
@FélixAdriyelGagnon-Grenier Er, so. I'm not sure 1980s/90s UK TV is an entirely safe realm to explore btw. Things were...slightly odd.
 
2:58 AM
@Danack consider me warmed ;-)
 
Wes
folks, if i write this small rfc, what do you think would be the consensus? i'd like to have class methods that don't get inherited by child classes
i think this is a common problem with named constructors. child classes often need different constructor signatures,
but with static methods you are not allowed to change the signature (whereas you can with __construct)
class Foo{
    public self function newByTimestamp(int $ts): self{ ... }
    // ^ notice self rather than static
}
class Bar extends Foo{}
clearly this classifies as not a huge thing, but still nice to have
 
@FélixAdriyelGagnon-Grenier I'm glad you're warm.
@Wes static methods are still callable on an instance. Breaking the inheritance of methods would probably break most static analyzers.
> child classes often need different constructor signatures,
If you know which class you want to create, what's stopping you from using a particular named constructor for it?
 
Wes
3:47 AM
the problem in the example above is that Bar::newByTimestamp() looks like it wants to return a Bar object, but it actually returns a Foo
it's not a functional issue, it's just for added clarity
 
Wes
4:11 AM
is there a way to doc-comment an anon object's properties that works in phpstorm?
eg
$foo = (object)["foo" => 123];
/** @var $foo {"foo": int} */
 
JRL
heh, i actually had a modifier like that used as an example in my User Defined Operator Overloads RFC @Wes. I think I used the keyword local instead of self
 
Wes
ie to prevent that operators are overloaded in child classes as well?
 
JRL
yeah. i used it for an example of a modifier to make the implementation not inherit
 
Wes
cool! i think self would match the way self and static currently work. self refers to the class it is defined in, whereas static's class is resolved at call time
but local works too
 
JRL
it was an example of how the operator keyword didn't restrict future scope, and i totally didn't really design it much, it was just thrown in as a "wouldn't this be crazy" type thing
so don't take my word as a well thought keyword to use, lol
just interesting that someone is talking about bringing up something i made up on the spot as an actual RFC (obviously not because of what i wrote, it's just interesting)
 
Wes
4:21 AM
operator overloading would be nice to have :P
 
JRL
yeah....
 
Wes
4:34 AM
though it's not my original idea either, it was discussed here already
or twitter. i think ocramius wanted it? it was ages ago
 
JRL
ah. i think he's one of the guys that straight up told me math is not a legitimate use case in programming languages.
 
Wes
:B
 
JRL
hey, at least he was honest about it
that was clearly the opinion of several others, though they didn't have the guys to outright say it
 
Wes
you don't agree with that? i think for the most part programming languages are used for text based information these days, rather than math
but obviously math isn't a small part of programming
 
JRL
there's a difference between saying "math is not what it is most commonly used for" and "math is not a legitimate thing to consider in the language"
 
Wes
4:42 AM
lol yeah :P
ocramius is probably a black and white with absolutely no grays guy
 
JRL
maybe
 
Wes
i bet in the heat of the moment that sounded ok to him xD but from what i recall he is reasonable when it comes to programming stuff
 
JRL
eh, a lot of reasonable people are unreasonable when it comes to a few topics in programming
operator overloading happens to be one of them
 
Wes
:P
php++ was ridiculed but i thought it was a good idea
a php fork with more drastic improvements
 
JRL
at least 5 different people that voted no told me some version of "there's nothing wrong with the RFC, this is basically the best possible design for this feature in PHP, i just don't care if it's useful or well designed, i'm still voting no"
¯\_(ツ)_/¯
 
Wes
4:50 AM
yeah that happens, but you shouldn't give up
the first time union types was proposed was ridiculed by basically everybody
 
JRL
i mean, i'm currently collecting more high level feedback from multiple sources
 
Wes
NOOOO U MUST USE EXTENDS U WRONG
 
JRL
i haven't given up
 
Wes
then the very same people voted yes when it was proposed again
 
JRL
just not sure if i care to propose again, mostly
i might work on the feature more and just not propose it
 
Wes
4:53 AM
like even if you make complete sense, the community must face your exact issues to support you
 
JRL
sure, but also FUCK that
 
Wes
heh
 
JRL
i'd rather write an extension that no one uses than deal with that kind of toxicity
what i really need, is to help someone else on their RFC i think
something that i'm not driving on
just helping with
 
Wes
didn't sara make a decent operator overloading extension?
 
 
3 hours later…
7:52 AM
scalar types took 5 attempts and 7 years /cc @JRL
 
JRL
yeah, i shouldn't have gone on that rant tbh
i feel like i always just sit in here and complain about my own project, lol
but that was mostly because of the mention of marco stirring my memory :/
 
morning
anyone using Doctrine migrations?
it is not straightforward in the configuration how to use that for multiple dbal connections
 
8:54 AM
@JRL yeah, Marco can be ... unhelpfully blunt ... to put it mildly
I suspect some form of operator overloading will succeed eventually; but whether that will be the third or twelth attempt, I'm not sure
 
JRL
I'm actually still trying to figure out what to change. I don't want to propose the same exact thing again. But people who voted no tended to say they thought the design was excellent.
that's why mostly im just gathering all the negative opinions now and trying to get people to actually ellaborate on their objections
 
9:29 AM
yeah; I think it's something a lot of people have a strong gut reaction about, for some reason
 
 
1 hour later…
10:30 AM
meanwhile, this week in "ugh, trust PHP...", I fight with base64_decode silently ignoring invalid input by default
very tempted to RFC a change to make the strict parameter non-optional
probably applies to any parameter called "strict" which currently defaults to false
 
Wes
11:00 AM
unpack with param name anyone (ie ...$args but named)?

$namedArgs = ["foo" => "bar", "lol" => 123];
baz(***$namedArgs)

same as

baz(foo: "bar", lol: 123)
or is that already possible? i haven't looked at rfcs in a while
 
@Wes You can already do that
 
Wes
damn, really? lemme try
thats nice :O
need a func_get_args() that returns the names as well, like for delegation
 
11:42 AM
morns
 
11:56 AM
@Wes ... can pretty much do it all I think 3v4l.org/TSgfm
slightly clearer: 3v4l.org/fvLVE
 
Wes
12:54 PM
i don't have var_export($args, true) tho, i have actual params, with types etc.
although that might work for what i am doing hm
 
1:32 PM
@JRL Welcome to my life... :-)
 
am I missing something obvious, (besides a string replace) to have DateTime{x}::createFromFormat() recognise "Z" as a synonym for "UTC" ?
 
@Stephen I imagine it takes its as Zulu time zone: timeanddate.com/worldclock/timezone/zulu
 
@Girgias I thought it might, but it doesn't quite seem to?
 
@Stephen Why? Zulu just is the NATO pronunciation for "Z" and it corresponds to UTC
 
i.e. getLocation() on the resulting TZ object returns false for Z but an array (with null/'?' values admittedly) with Zulu or UTC
 
1:43 PM
Hum, @Derick? :D
 
it's weird, it does parse with just a 'Z'
but it's hard to clarify what it parses as, it just comes up as
["timezone_type"]=>
int(2)
["timezone"]=>
string(1) "Z"
type 2 apparently means a TZ abbreviation.
but it doesn't behave the same so I'm curious what it actually thinks it is.
 
cmb
From php.net/manual/en/timezones.others.php: "Please do not use any of the timezones listed here (besides UTC), they only exist for backward compatible reasons, and may expose erroneous behavior. Furthermore, these timezones may be removed from the IANA timezone database at any time."
 
@cmb My understanding is that this does not apply. The 'Z' is not a timezone name, but rather an UTC offset (i.e. similar to writing +00:00). In fact the 'Z' appears to be special-cased in the ISO 8601 based on web.archive.org/web/20171020084445/https://www.loc.gov/….
 
1:59 PM
@cmb Z doesn't even appear in that list, anyway
 
@Stephen Doesn't DateTimeInterface::ISO8601 do the right thing?
 
@TimWolla O does detect Z as some kind of timezone
but it doesn't detect it the same as "Zulu" or "UTC"
hence my question
I don't know if the difference is because it's considered an abbreviation and all abbreviations have different behaviour or if its because it's something distinct.
 
2:16 PM
@Stephen Do you have an example?
because I am not following what you are trying to do.
 
@Derick I believe they are asking whether 'Z' is identical to Etc/UTC when parsing a timezone with the 'O' format string, because the output is different.
'Z' appears to be detected using this: github.com/php/php-src/blob/master/ext/date/lib/….
It might (or might not?) be desirable to also special case it here: github.com/php/php-src/blob/…?
 
Fuck SPL, seriously AAAAAAAAAAAAAAAAAAAAAAAAAAAAA
 
@Derick yes. an ASN.1 (or for my purposes, LDAP) GeneralizedTime string.
> Universal time (UTC time) only. ``YYYYMMDDHH[MM[SS[.fff]]]Z''.
Z does parse using O in the parse string, but it's not immediately obvious what it's parsed as, because it behaves differently than if it's given the string Zulu or UTC
 
Etc/Utc is a "timezone identifier" from the tzdb (which you should avoid using as per php.net/manual/en/timezones.others.php)
And no, "Z" is just a short abbreviation for UTC+0
But how are you parsing it, and how doesn't it work?
 
2:32 PM
like I said, it does parse, but it's not obvious that it's parsing it as something that actually means 'the same as UTC', because the object returned is slightly different, compared to when parsing the full Zulu or UTC (i.e. getLocation() returns false).
I don't need to use getLocation, so it sounds like relying on Z parsing is fine for my purposes
but knowing how the TZ actually behaves in all scenarios is quite difficult when the object retuned has different behaviour
 
@Derick I'm curious about that one: I've always used Etc/UTC, because /usr/share/zoneinfo/UTC is a link to /usr/share/zoneinfo/Etc/UTC on my system. Is UTC the canonical name?
 
@Girgias What is it this time?
 
@TimWolla No, UTC is a short cut that doesn't require a (much slower) algorithmic calculation that Etc/UTC does
@Stephen I have asked for example several times now, and unless you're going to show me code I'm not going to reply.
 
I see, so this is something PHP-specific? Thank you for clarifying.
 
@LeviMorrison The whole filesystem handling of it is utterly broken
 
2:38 PM
It's old, so that's not surprising ^_^ Filesystems have changed in the past 20 years.
 
@TimWolla Not everything in ext/date uses the timezone database, and it doesn't need to. Same for GMT+0200
 
The fact SplFileObject inherits of SplFileInfo and that it's not final and has the most whack behaviour makes it impossible to fix
A method is an alias of another
But you can reimplement the alias and give it concrete behaviour
 
@Derick ... sorry, I thought you wanted an example of the date format im parsing.
 
LIKE WTF IS THIS
 
DateTimeImmutable::createFromFormat('YmdHisO', $value);
 
2:40 PM
@Stephen You can just change that to His\Z and the Z will be ignored as a normal character ;-)
getLocation only works on TZDB derived DateTimeZone objects
(ie, type "3" time zones)
 
@Derick I know that, but GeneralizedTime accepts three formats: no TZ, Z literal TZ, or a +/- HHMM offset.
> Type GeneralizedTime takes values of the year, month, day, hour, time, minute,second, and second fraction in any of three forms.

> Local time only. ``YYYYMMDDHH[MM[SS[.fff]]]'', where the optional fff is accurate to three decimal places.
> Universal time (UTC time) only. ``YYYYMMDDHH[MM[SS[.fff]]]Z''.
> Difference between local and UTC times. ``YYYYMMDDHH[MM[SS[.fff]]]+-HHMM''.
 
oh right, yeah, then "O" would just work fine
If you are fine with accepting just all formats, then you don't even have to bother with createFromFormat
as the constructor will just accept all of them
or at least, should
 
right, but the confusion comes when Z doesn't behave the same as e.g. Zulu or UTC, so it wasn't obvious that it was actually parsing as a correct timezone
because the abbreviations aren't documented, for all I know Z could have been interpreted as something that has DST. that's why I came to ask if anyone knew about how it's handled.
 
Abbreviations can randomly change for most part, and should be used for output and display purposes only. The A-Z timezones are special here, and handled through a hand created map.
 
cmb
2:59 PM
The problem with SplFileObject is that is heavily optimized for "regular" operations, but fails if somebody uses it in non "regular" ways. E.g. github.com/php/php-src/blob/PHP-7.3/ext/spl/internal/… can't generally work, obviously.
 
Yeah
Which is why it should have been final frankly
But the temp version extends from SplFileObject and it's pure garbage
 
3:28 PM
@Derick Hi :-) I just announced 8.2.0 alpha2, all mail worked but the primary-qa-tester one (ezmlm-store: fatal: I'm sorry, you are not allowed to post messages to this list (#5.7.2)). Any clue ?
 
@Pierrick From which email address did you send that?
 
pierrick@php.net
 
Are you sure? Because you are both in the normal and moderator lists
 
@Derick I got the same error when announcing alpha1
 
@SergeyPanteleev Sure, but we fixed that afterwards, not?
 
3:35 PM
@Derick I double checked and I sent it from my php.net ( pasteboard.co/EV14lIXXRqtp.png )
 
hmm... let me try something
 
@Derick After that I sent the mail again and got no error, but the message did not appear in ML :thinking:
 
@Pierrick can you try again?
 
@Derick Same error ! Ezmlm hates me
 
I can't find it :-/
 
3:50 PM
I'm going to ask @SergeyPanteleev or ben to send it for me then.
 
Just sent email… same error =/
 
i can't see a difference between ben and you at all
 
They look nothing alike!
 
@Pierrick you're sending it tpo primary-qa-tester@lists right, not just @php.net ?
 
Yep : primary-qa-tester@lists.php.net copy pasted it from the release process doc
 
4:29 PM
@LeviMorrison That'd be dope
Hi everyone
 
hmmm, when using fast-route with path arguments that end-up being ints (like an id that would be an int) where do y'all actually make the cast? within the handlers? when matching routes? using is_numeric on all args and cast as int if it's true?
 
Cast it on the controller (int)
if you know it has to be > 0 check for that too
 
4:51 PM
$dispatcher = FastRoute\simpleDispatcher(function(FastRoute\RouteCollector $r) {
    $r->addRoute('GET', '/users', 'get_all_users_handler');
    // {id} must be a number (\d+)
    $r->addRoute('GET', '/user/{id:\d+}', 'get_user_handler');
    // The /{title} suffix is optional
    $r->addRoute('GET', '/articles/{id:\d+}[/{title}]', 'get_article_handler');
});
Given this setup, I'd check the digits in get_user_handler, but remember that just because they are all digits doesn't mean it will fit in an integer, and that doesn't necessarily mean you should handle it as an integer even if they fit.
I've been bitten in the past by using a 64-bit number and it changed to a 128-bit number and PHP doesn't have 128-bit ints, and so it was brutal. We weren't doing any arithmetic or any other integer operations -- it should have remained a string, most likely, even when it did coincidentally fit in 64 bits.
 
oh, nice catch. that makes sense, thanks
 
 
1 hour later…
DAG
6:18 PM
silly question, when editing 5 fields in a form if I am only editing one unless I look if value is the same as before will it try to update al 5 fields ?
 
That all depends on the code/framework being used ^_^
 
o/
 
7:03 PM
When I was making a PHP code to handle memory addresses of another process, strictly speaking, I have to handle 64-bit unsigned int for the memory address
But after a bit of hesitation, I decided to treat them as regular int.
 
Regular int as in zend_long?
 
Yeah, signed int in PHP
The address where the MSB stands in the assumed OS is in kernel space
and I thought it must be a bad idea to try to handle addresses in kernel space with "PHP: Hypertext Preprocessor", lol
 
7:20 PM
Operator overloading would make it easier to handle such niche use cases like pointer arithmetic on 64-bit addresses
So I don't have a vote, but I wish it success
 
 
2 hours later…
9:17 PM
@Crell what's the reason why enums can't currently implement toString? "Enum may not include __toString"
 
@Danack It's explicitly blocked at present, as are a number of other magic methods.
 
Yes. Why's it explicitly blocked?
just default "That's probably safer" ?
 
Largely. 1. We want to make sure we don't inadvertently make life harder when ADTs get added. 2. What the "right" behavior of __toString is, is unclear. And 3, as discussed on list, enums really shouldn't be treated as "named strings", because that's not what they are, and treating them that way is likely to break things.
 
9:34 PM
hmmm, to confirm: I believe I understand that the auto-cast-string-enums-to-strings-whenever-the-engine-needs-to would only happen in non-strict-types mode, yes?
 
I... think so.
 
10:04 PM
@FélixAdriyelGagnon-Grenier Strict mode only affects function calls, Foo::Bar == 'Bar' would still equate to true.
So would all other internal functions that do loose comparison, like in_array.
But then again, that's actually what some people expect. Some people really do see enums just as fancy constants. They're not wrong per se, it's just a different viewpoint.
@Danack Twofold: 1. We weren't sure if auto-cast is desirable at all (we're still not sure) 2. It would be terrible if people started using it for different string representations. I think if we have __toString it should always be the same, namely value.
 
"It would be terrible if people started using it for different string representations." - Probably terrible, but at the same time, people sometimes have different trade-offs and what might be misues to 95% of people might be appropriate for a few people.
 
I kind of want this, but given the price tag, I can't decide... kickstarter.com/projects/deilor/defy-keyboard
 
Personally I think comparison/casting of enums should be universally consistent. What would be worse than having / not having coercion is sometimes having coercion, or enum == string to be true or false for it to sometimes be true/false.
Also, I believe with manual implementation instead of Symfony telling people to use ->value they'll have to tell them to implement Stringable instead.
 
10:32 PM
@IluTov I see. thanks for the clarification. I share the viewpoint where I like the current strict behaviour of enums not being strings, and would find it unfortunate if the language would loosen that without a way for me to keep it that way.
more widely speaking, I also think folks should not use enums as strings, but I guess that's not really for me to decide.
 
@Tiffany that seems like quite a bit of money - but at least that company appears to be already making similar keyboards, so it's unlikely the project would fail to deliver.
 
I really need to do a blog post on this topic, it seems.
 
10:50 PM
@FélixAdriyelGagnon-Grenier Well I agree. Enums are a closed set of possible values, not a collection of strings. That line becomes a bit blurry at #[IsGranted(PossibleRoles::SomeRole)] (example from Nicolas) where it could essentially be both (closed list of roles for the application, open list of strings for Symfony).
 
11:19 PM
@IluTov yeah, I haven't used attributes much so I'm having a hard time forming an opinion other than "use string constants" which does not sound all that useful.
constant SOME_STRING = "foos";
enum Roles: string {
    case Foos = SOME_STRING;
}
#[IsGranted(SOME_STRING)]
(that don't parse, just thinking out loud)
 
I just had an idea about operator overloading.
If one of the reasons for the objectors is the cognitive load of not being able to tell from the appearance of the expression whether operator overloading is being used or not, then
 
inb4 namespaced overloads
 
Is there some kind of marker that would make it easier to tell?
 
JRL
@sj-i it would need to be in the calling code, so that's a clumsy solution that also relies on userland devs to conform to some kind of standard
you're thinking something like... uhhh... ?+ instead of + correct?
 
11:28 PM
$my_int \VeryNamespaced\+ $my_other_int
 
Yeah something like.
When we look at a single quoted string, we can take comfort in knowing at first glance that interpolation will not occur.
Similarly, there may be a notation that is unobtrusive to those who want the domain-specific DSL and alarming to those who do not.
 
JRL
well the main point of operator overloading is for library authors to make it so that the calling code doesn't need to figure out how to use the operator, they use it the way they would with scalars
this would also make PHP the only language i'm aware of that approaches operator overloads in that fashion
which makes me skeptical
I guess you can sort of do something like that with arbitrary infixes in R, but that's not something that the language enforces
 
Yeah, just an idea.
 
JRL
for sure, and glad to have more of those always
admitedly, it's an idea i hadn't considered until you mentioned it just now
@IluTov Is that a problem that implementing overloads for only the comparison operators would help enums with you think?
 
I'm not following, is the idea something like use SomeOverloader\plus that would then influence how these + sign operate in that file?
 
JRL
11:35 PM
you mean sj's idea Felix?
 
JRL
they are suggesting have a separate, complimentary set of operators for objects which can be overloaded
like + is for scalars, and ?+ is for objects, for example
 
Yeah, for example. It doesn't necessarily have to be a new operator, as long as there is something in the appearance of the code to indicate that operator overloading can be used in that context.
 

« first day (4268 days earlier)      last day (680 days later) »