« first day (3846 days earlier)      last day (1102 days later) » 
00:00 - 19:0019:00 - 00:00

12:05 AM
@Crell what's your opinion on pi versus tau?
 
Pi is tastier.
 
Mmmm, this is true.
The reasons for using tau over pi are pretty compelling but I'm so used to pi.
I mean, shit, I memorized over 50 digits of pi in highschool to win a pizza. Worth it.
 
12:23 AM
(I actually have no idea what you're talking about, food puns aside.)
 
@Crell tauday.com/tau-manifesto haven't read through the entire site, but it seems reliable enough on the subject
Essentially it's an argument for using tau as a replacement to 2π, supposed to be easier to work with in circle calculations
There are compelling arguments for tau, but I imagine the US would sooner adopt metric nationwide rather than switch to tau
 
1:13 AM
I mean it's not just a US specific issue for tau
 
1:58 AM
Could someone please cast the final Needs More Focus closevote at stackoverflow.com/q/25618777/2943403 so that the votes don't age away?
 
 
3 hours later…
5:26 AM
morning room.
 
Wes
6:12 AM
hello
 
6:28 AM
o/
Morning all
Today I found out that nesting namespaces IS NOT a syntax error :/
I've checked it with
namespace Foo {
    class Bar {}
    namespace Baz {
        class BazBaz {}
    }
}
namespace {
    var_dump(get_declared_classes());
}
And was hoping to see a syntax error but got only fatal error
I was hoping it could be possible to nest namespaces in order to add ability to mark top one as final
With final keyword in front of namespace Foo like final namespace Foo i was hoping to forbid any further class declarations inside the top namespace
The idea in my mind was to be able to craft one file library which possibly could then be imported like import Foo;
Which in fact could be an equivalent of
use Foo\Bar;
use Foo\Baz\BazBaz;
etc. for all const and functions, or in some variant with choice of imported/aliased symbols
I'm making bullshit or not?
Ofc autoload is another topic which I wasn't considering at this stage
 
namespaces aren't a real thing, there's nothing to nest
 
I know they're not a real thing yet, was hoping to refresh this topic
the amount of use clauses in my projects takes significant amount of lines, in most cases completely unnecessarily
also I'd love to see someday a standard library written in PHP itself
 
namespaces right now are a bit like traits, they are a copy-paste trick of the compiler, there's nothing like a "namespace" internally, with all the symbols you declared on it, the namespace was just pasted infront of the classes at compile time, all classes are in one big table ...
 
if all could be put in one namespace with no further extensions it'd be possible to import - use all symbols as aliases, without considering how to load that yet
@JoeWatkins yes, I know that I even have somewhere old branch where I tried to craft it as a thing with nested structure hierarchies etc.
 
that's the problem with using namespaces for anything, most people imagine that a namespace is this thing that holds all the symbols they declared in it, like some sort of organizational unit, but they're not that, they're pasted strings, information which is lost by runtime ...
 
6:41 AM
Also nobody said it'd be always like that that a namespace is just a prefix of symbols
 
yeah, there's nothing stopping us from making namespaces a real thing ... except that it's a pretty hard change ... and it would effect the core of php - the code that calls functions ... I'm not sure if it's reasonably doable without having at least some effect on performance of that ...
there are probably other things we can do that would not have to touch any of that code ...
 
@brzuchal So introduce a necessary build step for all packages?
 
@kelunik dunno yet, was thinking out loud, in my mind I had standard library functions implemented in PHP so was looking for a fast and easy way to alias a bunch of symbols but that would require a namespace to be a real thing and freezed for no further extensions
This way it'd allow for inheritance but not within the restricted namespace anymore
 
Which issue does that solve?
 
6:57 AM
many use clauses, list symbols within the namespace without file discovery in further extensions we could add more restrictions like flags for subnamespaces or namespaces like package private etc. if all symbolic could be loaded as a sort of single assembly
a single assembly could possibly hide some classes from further inheritance outside of restricted namespace
that could somehow allow things to let them be internal
if symbols could be found withing assembly/final-namespace (whatever) like that they could be hidden from lookup outside world
possibly instead of friend classes final classes could permit extending from the same namespace if it's marked as final
 
I don't see the need of a single assembly to implement namespace-private symbols. Yes, people can declare things in another namespace to access things they shouldn't, but there's no way to prevent that anyway.
 
sealed class Shape permits Circle, Square, Rectangle {}

final class Circle extends Shape {} // ok
final class Square extends Shape {} // ok
final class Rectangle extends Shape {} // ok
would turn into
final namespace Foo {
    final class Shape {}
    final class Circle extends Shape {} // ok
    final class Square extends Shape {} // ok
    final class Rectangle extends Shape {} // ok
}
class Triangle extends Foo\Shape {} // Fatal error
without introducing new keywords like permits
@kelunik if the interpreter could have embedded assemblies it could be
ahhh nvm
 
7:28 AM
@brzuchal There'll always be ways like pre-processing the used files, using forks, etc.
 
@kelunik yeah, ofc but that is not so trivial, again I was thinking of ability to load/alias all namespace declared symbols in more fashion way than hundreds lines of use clauses
 
7:55 AM
what if i do this in another file?

```
namespace Foo {
class Proxy extends Shape {}
}

namespace Bar {
class Triangle extends \Foo\Shape {}
}
```
 
@SaifEddinGmati nothing, exactly the same as removing sealed and permits, right?
 
If we restrict all symbols inside Foo to be in the same file .. then it's going to be a mess, i don't declare 2 functions in the same file usually, so i won't do it with 4 classes ( also, won't work with auotloading )
@brzuchal but here i didn't modify the original code
 
but only if Foo namespace was not declared yet
one file for assembly is just a one file for the interpreter
it's not something you wanna edit manually rather build from bunch of files
even if not placing multiple symbols in one file is nothing scarry
ofc if you expec autoloading to work for you it's a completely different topic
 
what does that mean?

assuming i want `Psl\Result\Result` sealed to `Psl\Result\Success` and `Psl\Result\Failure`, how would i do this in multiple files?
@brzuchal we don't have a solution that is capable of auto loading this, unless if you are using a classmap and defining every class to your autoloader, but that is not a good solution if your code base contains 100s of symbols.
 
fork() don't close fpm_globals.listening_socket ・ FPM related ・ #80992
 
8:18 AM
Morning
 
8:33 AM
o/
 
\o
 
Wes
8:46 AM
every time youtube brings me on a cheese rolling contest video i wonder if @DaveRandom has ever participated to one in his youth. so it's time to ask
 
9:14 AM
readlink() works no correctly ・ Filesystem function related ・ #80993
 
9:30 AM
if you use symlinks on windows, expect screwiness
 
9:49 AM
Johnjpw ・ *General Issues ・ #80994
 
10:00 AM
@Wes more of @Danack's part of the country I believe, not sure I am a bit more of a town mouse than that anyway tbh
so is he
it would not surprise me in the slightest if Phil Sturgeon had participated in a cheese roll
 
10:36 AM
Howdy ho
 
cmb
10:56 AM
so archive from local? @Derick, @GabrielCaruso, @Sara
 
Uh, this wasn't a problem with my RC1
 
cmb
ah, seems makedist has been "rewritten" for 7.4, and uses local by default: github.com/php/php-src/blob/PHP-7.4/scripts/dev/…
 
11:33 AM
I'm gonna start the process for PHP 8.0, today is a holiday here in NL, I almost forgot about it :p
 
I'll do the 7.4 one after my walk - so in about 3 hours
@GabrielCaruso You saw stas' email about the extra commit to cherry pick?
 
@Derick Yeap, but thanks for the heads up, I forgot about it last time :D
 
cmb
also note that stas didn't commit a NEWS entry; I'm about to fix that @GabrielCaruso, @Derick
 
k
 
@cmb I was going to ask about it, thanks!
 
cmb
11:47 AM
 
Thanks, pulling 3e518e06 and a4d9ccbc into PHP-8.0.5
 
@brzuchal Java's modules change this I think, but it's not really a problem IMO with Java packages. Package private classes still help a lot, even if other people can define classes in your namespace.
 
@kelunik maybe it's just an illusion that that kind of feature should be. expected in PHP, maybe I'm just trying to reinvent the wheel dunno, I see many nice features landing in PHP but for topics like assemblies, packages, modules, symbol visibility restrictions like package/private etc. come back from time to time
I remember there was a topic about a modules some time ago but it also went nowhere
 
@brzuchal Please do solve the namespace visibility, I just think you won't get happy implementing assemblies as a requirement for that.
 
Either it is not highly demanded or there is no clue how to achieve it and who is enough strong and brave to implement it
@kelunik can you rephrase, I am not sure if you propose solving the namespace visibility with a PoC or in terms of my thoughts only
 
11:55 AM
@brzuchal I suggest to solve namespace visibility without restricting others to define classes in a foreign namespace.
 
You mean visibility of symbols so they can be used within the same namespace and to be forbidden in inheritance outside of their namespace, yes?
Off-topic I find working with named arguments+promoted properties really nice but with one exception - inheritance requires still repeating all arguments and done properly should apply all upper properties via parent ctor, this is not an issue with small amount of properties but is a hell when you have an anemic model with 20 properties and 40lines is just proxying ctor parameters to the parent ctor with named arguments
And I do use named arguments when calling parent ctor cause I wanna my IDE to figure out how to sort them if I ever decide to reorder them in upper class
I tried with ...$additional - but as I was notified it is not yet implemented, but that doesn't solve all the issues, additional array entries cause error cause they don't match named arguments
I feel like all these features are nice until you meet a code which has more then 10 properties still
Possibly regular classes just don't fit here and some kind of data classes with autogenerated ctor or initializer would be better here if the only difference in two classes where one extend another is just additional fields, public fields, all public fields
 
half-formed thought: it would be useful to have some kind of "pass through" keyword
as in "all the arguments I received, pass them to this function"
there are a bunch of cases where you just want to proxy a call and add behaviour, not change the signature
 
12:12 PM
I'd say yes and no
 
I guess that matches "half-formed" 😆
 
In my case a VehicleModel has 28 public properties declared as promoted arguments
Yes, I just wanna extend my thoughts
lemme do that
 
sorry, didn't mean to interrupt
 
no ofense :D
In my case, a VehicleEntity is something what extends VehicleModel but adds a bunch of protected properties, like the identity, time of creation time of last update etc.
they're protected cause there is no readonly modifier and I don't allow to mutate them
the rest what comes from parent class the 28 properties are still public but since I extend it they're declared in entity class in ctor and passed to parent ctor
possibly I just hurt myself on purpose here and it could be done/modelled different way
but if I did that unconsciously possibly there's someone else who'd do that
ideally I'd get rid of ctor at all in my case
but wanna have a nice initializer
 
so maybe something like __construct($extra1, $extra2, delegate parent::__construct)
 
12:18 PM
which is able to initialize all necessary properties
 
where the "delegate" grabs the parent signature and kind of injects it in
 
possibly I should pass the inherited as an argument and keep it in standalone property, but I didn't
possibly something like that yes
 
if you use composition instead of inheritance, you end up having to do the same thing in all the other methods, because you have to re-declare them and pass on the arguments
 
but also if I'd be able to mark these special properties like identity timestamps of creation and update with special keyword like readonly and let the engine generate the initializer by sort of keyword on class declaration level like data class VehicleEntity extends VehicleModel
then I'd save around 60 lines of code proxying these arguments into parent ctor and even more when I count all use clauses IDE put above class declaration for inherited class properties types
<?php

data class VehicleEntity extends VehicleModel {
    public readonly Uuid $id;
    public readonly DateTimeImmutable $createdAt;
    public readonly DateTimeImmutable $updatedAt;
}
this would be ideal
and ability to create the instance just like the ctor with all promoted properties would've been there
with all 28 inherited properties
one more line for namespace and that's it while now with protected properties I need to declare getters proxy all ctor arguments into parent one with some use clauses I'm near to 107 lines long file
9 vs 107 that's a lot
 
12:42 PM
@DaveRandom yeah, about 40 miles away. And no, I have never partaken in it. Tbh, I'd probably break something just trying to get up that hill, let alone down it. /cc @wes
 
1:02 PM
@brzuchal Yes, but rather than just inheritance, I'd work on usage, but that's probably not easily doable in PHP, because types aren't known at compile time. So maybe focus on inheritance and construction?
 
1:24 PM
@beberlei stuff I probably shouldn't send to internals as it might attract Java Zealots:
Jul 14 '16 at 19:02, by Danack
They are nuts. Seriously, I consider some groups of programmers to have gone collectively insane, and you should do the opposite of what they do, even if you're not 100% sure why you should do the opposite.
Jun 6 '15 at 22:09, by Danack
For the record, this is why I do not think anyone should copy anything Enterprise level Java programmers have done. They've clearly, as group gone collectively insane.
 
well every framework in PHP has implemented a bad version of AOP in plain PHP with varying degrees of magic and code generation: wordpress, drupal, magento 2 is especially crazy about this
 
@Danack Not sure I'd go that far, they might get something right, but there are some programmers that seem to really like making things complicated (I assume it makes them feel clever?)
 
@beberlei stuff that happens in userland is at least debuggable with xdebug. Stuff that happens internally and is only debuggable with gdb.....scares me.
 
why would it be debugable only with gdb? the engine could make this visible
 
Europe DateTimeZone bug in specific DateTime interval ・ Date/time related ・ #80995
 
1:34 PM
Even if it might be possible in this case, I was referring more to the general "slipping new language features into attributes".
 
If they're engine-interpreted attributes, a debugger would still be able to respond to them.
 
IMHO, attributes should stay as is now, they are a cool feature to be used in user land for mapping, validation, .. etc ( saves parsing time compared to doctrine/annotations, all IDEAs support them as they are part of the language, linting .. etc). but they should not be something that is used by PHP itself.
 
I disagree. Certainly they could be abused (true of literally anything), but there are targeted places where they would make the language better in ways that could only be (reasonably) done by the engine.
 
i am unsure, if we keep adding more and more keywords to declarations instead i am torn.
 
attributes could be useful, but not in their current form only ...
oh btw @beberlei, my implementation for inheritance of attributes didn't do any more than the current implementation does, validate the attribute when added to a class ...
 
1:44 PM
Property guards are an example where IMO an attribute is the superior approach, because it lets you out-of-band more complex rules in a clean way.
 
what happens in the validate handler isn't up to us internally, and the example sealed extension was just an example ...
 
@JoeWatkins i have a flawed patch, let me link
 
from: https://docs.hhvm.com/hack/attributes/predefined-attributes

the only things that make sense to me to be attributes are #[Memoize], #[MemoizeLSB], #[Override] and #[Entrypoint]
 
@JoeWatkins gist.github.com/beberlei/3c6a46ce7163bca8783a74674d583fa2 - havent compiled it yet though and missing a lot edges, especilally attr->flags does not even contain the attributes flags passed to the constructor and that is by design (attribute classes are not loaded to avoid autoloader from triggering)
the validator hook is not the right approach for the Sealed extension. there would need to be a handler called with the "finalized" ce after the "compile" is done
 
that doesn't look like enough to me ... why shouldn't the validator be run ?
you are not designing that, you don't get to say what it's used for ... it has to be consistent, why should validate run for some classes and not others, what does validate mean ?
 
1:49 PM
the validator is for validating that the arguments passed to the attributes constructor are valid based on type semantics
 
it's passed the class entry
 
its not about validating behavior that the attribute brings
i need to check why the CE is passed
i don't remember what the decision was there
 
to me, and everyone who programs, (zend_attribute *attr, uint32_t target, zend_class_entry *scope); as a callback tells me to validate the attributes with respect to that target and scope ...
@beberlei again, you're not designing that part, I don't understand why it should be invoked for one class and not others ... it should be ... nothing else really makes sense ...
how it gets used you just don't get to decide, don't make it inconsistent because you think it opens the door to abuse, provide a consistent api ...
 
can you clarify with what you mean with "designing that part", i don't understand
 
what happens in the validate hook
 
1:53 PM
what the validator allows an extension to do is fail the compile, when the attribute gets passed arguments that are known not to pass the constructor of the attribute. Its a sort of fail early, instead of watiing for ReflectionAttribute::newInstance validation to kick in
i can very well design a hook with a use case in mind
i am trying to explain why we added the validator, what the goal was
 
@JoeWatkins Once you validate you usually let them in the car then pay them some money.
 
@JoeWatkins i believe this commit by nikita shows that the ce param was initially a mistake to add there: f06afc434ae
 
@beberlei no, you declared it with that prototype, how it might be getting used isn't down to you ... Joe Blogs can use validate() however he sees fit, and if you inherit the properties without invoking the validator in exactly the same way you did for the parent, then you broke his thing ...
 
this shows why the ce was there in the first place
 
that's specifically for the single internal attribute, Attribute though isn't it ?
why does anyone using that api have to care, they might well be able to deal with unlinked/unresolved classes for their use case, right ?
 
2:00 PM
if the attribute is #[Attribute(Attribute::SOMETHING)] then argv ZVAL is an AST node that still needs to be resolved, but nikitas bugfix there showed that this doesn't work when the CE is not yet complete
 
I mean changing the api, or introducing new hooks is a abi/api breaking change, too late for that in the current release cycle, and it looks to me like the hook exists ... even if not your original intention, even if the prototype is a mistake ...
 
it might make sense to break the api for 8.1, i don't know of a single internal attribute, and it would be easy to macro away for users in any case
 
that's definitely not the best, but also not that important ... I mean, not everything even needs arguments ...
 
we are planing to add some to the tideways extension soon, and other profilres / apms might too
 
it's not really too late for 8.1 just yet actually ...
 
2:14 PM
@beberlei anyone using that hook currently is already dealing with the possibility that the class isn't linked, right ? which seems fine to me, they store it for processing in some other hook they have installed ... there's nothing actually wrong with that ...
people might have already started to work on this stuff ... maybe ...
I just wonder if there needs to be an additional hook, or just execute the current one later ...
 
2:41 PM
@SaifEddinGmati Idk stuff like #[Deprecated] is also fine IMHO
 
@Girgias in PHP it probably doesn't ..; the only value __Deprecated adds in Hack is that the type checker gives you an error when using a deprecated symbol, but there's no runtime effects, while #[Deprecated] in php would probably trigger a deprecation notice ...
 
Isn't that the point?
 
Yea, I think that's what I'd want to see happen :P
 
i like hacks approach better ( here's an error at build time, but nothing further at runtime ), tho, that's not applicable in PHP since it doesn't have an official type checker builtin
 
2:58 PM
@JoeWatkins regardless of the signature of the callback, there's a semantic difference between "validate the attribute with respect to the class" and "validate the class with respect to the attribute": the first would imply an error message like "A Sealed attribute is not allowed here, because the class has the wrong parent" which isn't what we want
what we want is an error message that says "this class definition is wrong, because this extension says it's wrong, based on the Attribute you added"
the attribute is just what the extension can look at to decide whether it's wrong
 
Fun email of the day:
Hi,

I would like to buy this xdebug.com.
How much would you like for the site?

Thanks
Regards
 
lol
a million dollars
but doctor evil a million dollars is nothing
 
@Derick reply: "if you have to ask, you can't afford it"
 
@JoeWatkins regarding extensions using attributes, consider the example of a profiler: using existing hooks, it can measure the resources used by each function; it could also check an ini setting for functions to ignore; now, with attributes, it could look for a #[ACME\Profiler\Ignore] attribute and ignore those functions
 
@IMSoP the issue with sealed is that the extension doesn't need to check the class that defines the attributes, but sub-classes.
 
3:06 PM
@SaifEddinGmati no, the issue is that the extension needs to be able to fail the class declaration
if there was an extension hook right next to the current check for "final", the extension would have all the information it needs
all it needs is access to the parent class's attributes; it doesn't need to be "notified" of them in any way
 
yea, you are right
 
you are placing new code to validate with the sealed keyword as well at some place. The attribute validator or anything else would just need to be at that place instead
 
indeed
 
we are talking about a new feature, that is by definition new code in places, that could just very well be attribute related
but joe raises important questions about the validator hook
 
I think consistency is a good argument against #[Sealed], but if "final" wasn't already a keyword, "#[Final]" would be a perfectly reasonable attribute
 
3:12 PM
what about "abstract"?
 
no reason why not
 
@SaifEddinGmati FWIW, would you like to chat with me on the PHP Intenrals News podcast once the Sealed classes RFC is no longer in draft?
 
"abstract", "final", etc, kind of are "attributes of the class", in the plain English sense
they just had to be special cases in the parser because we didn't have an attribute syntax yet
 
But should they be attributes?
Even if there were an attribute syntax at the time I'd argue that keywords like final and abstract should still exist.
 
@Derick well see, you can contact me then
 
3:20 PM
CLI Make '-B' incompatible with '-r' and <file> ・ Unknown/Other Function ・ #80996
 
IMO, any boolean "attribute" is an anti-pattern, just like boolean args are. I think final and abstract belong in the language.
 
@CharlesSprayberry it all comes down to being extendable vs being opinionated: there is a set of rules for when a class can/must be inherited; having keywords says "this is the set of rules, it is hard-coded and immutable"; having attributes would say "the set of rules is extensible, and here are the ones currently defined"
@LeviMorrison that analogy implies that "finalclass" should be a single keyword; "final" already is a boolean "attribute", in the sense of "a flag on the class"
 
@IMSoP I specifically mean #[] when talking about attributes there, not a flag on the class.
 
I know, but I don't see the analogy to parameters as valid
whether it has #[] around it or not, it's one of many boolean things you can add to the declaration
whereas "public", "private", and "protected" are values for a non-boolean "visibility"
 
As an example, deprecated is better as an attribute because you can do things like refer a replacement, or say as of what version it was deprecated in; it's more than "just" a boolean.
 
3:27 PM
so if there wasn't that parameter, would you prefer a "deprecated" keyword in the grammar?
 
how do we declare the final attribute final?

#[Attribute()]
#[Final]
class Final {}

? 😅
 
hah! no reason why not, I guess
 
@IMSoP No, because deprecated should not be reduced to a boolean.
 
I'm trying to understand your distinction of booleans, is all
it feels very arbitrary
 
@IMSoP deprecated needs arguments: when? why? what's the alternative?
 
3:32 PM
I'm not saying it shouldn't have them, I'm just saying I don't see the connection between arguments and being better as an attribute
 
IMO langauge features such as "sealed" should be keywords. I think deprecated is fine as an attribute, because it's a mere hint to the developer. It doesn't directly effect language-run-time behaviour.
 
#[Deprecated(message: "use foo() instead")]
 
#[Deprecated(alternative: Bar::class, version: '3.4')]
class Foo {} // Foo is deprecated since 3.4, use Bar instead.
 
Comparing attributes without parameters to boolean parameters is like saying enum parameters with only two options available is equivalent to booleans IMO.
 
the behaviour is triggered by the presence of #[Deprecated]; the fact that it has an argument to tweak that behaviour is just an extra detail
 
3:33 PM
it doesn't influence running code though
 
^ #[Deprecated] cannot result in an error, #[Sealed()] can ( when a class is extending a sealed class which doesn't permit it )
 
yeah, that's at least a reasonably clear distinction
 
Yes, that was my point.
 
(some people insist that any diagnostic affects behaviour, because it triggers a call to the user's error handler; those people are wrong :P)
 
All attributes will affect some kind of behavior, otherwise there'd be no reason to put an attribute somewhere.
 
3:35 PM
IMO attributes should be for runtime behaviour, and keywords for compile time (yes, I know PHP somewhat blends these rules)
 
I think userland libraries would often say the opposite: attributes are part of the build machinery
you don't want to be constantly looking up attributes at run-time, you want to have used them to generate code, or reject it
 
@kelunik that behavior is never "fatal error if ..."
 
I'd concur with IMSoP, 90% of my use of attributes are at a build stage.
 
Compilation can be seen as part of the build stage. :P
 
yes, but Derick said they shouldn't be used at compile time
 
3:40 PM
That'd rule out JIT hints using attributes.
 
JIT is all run time
 
Anyway, if #[Sealed] is to be enforced by the language, it should be part of the language syntax, not an attribute.
 
I have removed #[Sealed] from the RFC anyways, the three syntax options are now all keywords,
 
TBH, I'd probably vote against it currently, as package private would probably solve most use cases IMO.
 
personally prefers sealed class Foo permits Bar, Baz {} as it's the most clear out of the three options, but results in 2 new reserved keywords ( sealed, permits ), class Foo permits Bar, Baz {} results in a 1 new keyword ( permits ), class Foo for Bar, Baz {} doesn't bring any new keywords.
 
3:46 PM
A straw poll re: attributes for engine features would probably be a reasonable first-step. Removed from the RFC or not the debate has started and shows little sign of abatement .
 
@kelunik honestly i don't see the point here, these are two completely different features.
 
@SaifEddinGmati As you have to list specific implementations, I see this mostly being used for allowing classes by the same author, usually residing in the same package.
 
@SaifEddinGmati what is a "package"? the closest thing we have is namespaces, and it would be extremely easy to get around private namespaces as i have mentioned before.
 
@SaifEddinGmati As said before, "getting around" is nothing that I see being solvable. You can always setup an autoloader that auto-patches files or patch files in the vendor directory.
 
unless we bring a new construct to the define packages like:

```
package "foo" [
Foo::class,
Bar::class,
];
```
@kelunik then you modified the source code, if doing that, then nothing makes sense anymore, type hints can be removed, final classes can be made non final, ... etc.
 
3:54 PM
@SaifEddinGmati Exactly, so it's not a problem I'd try solving. If you define symbols in a foreign namespace you deserve what you get, just like if you patch files directly in vendor.
 
I would rather have a more protective solution, usually if you want a class to only be inherited internally, you already know which symbols should be allowed, private namespaces make it easy to work around them.
@JoeWatkins and also we need to keep this in mind
 
That's fine, I just don't share that opinion. ;-)
 
I don't think people would create a separate namespace, and certainly not a new package, just to hold Maybe, Some and None
so I agree with Saif here that sealing and visibility are two separate things
 
@IMSoP In Rust it's defined in core::option::, which is then exported by both std:: and core::.
So it really depends on some of the details of what it means to be a package, and how easy and accepted it is to re-export something in a new one.
 
4:11 PM
huh, I stand corrected then :)
 
I think it's because it's used all over Rust internals, and people wishing to use options won't want to bring in a large amount of dependencies. It's a case where a tiny package is advantageous.
 
@IMSoP orthopedic shoes :P
 
4:43 PM
Visibility is also not a question of extension, it's a question of usage at all. You would want everyone to be able to use a common Maybe tree, just not hang extra weirdness onto it.
That's different than a class that's internal to a package where, if you're not the package author, if you call new ThatClass you are Doing It Wrong(tm).
 
^ you are allowed to do new Foo() ( sealed class Foo permits Bar {} ), and use it however as you like. but i don't think it make sense for people to use Foo if it's declared as private class Foo {}
 
if we ever do have package visibility, please let's plan ahead so we don't end up with a "private protected" modifier like C# docs.microsoft.com/en-us/dotnet/csharp/language-reference/…
 
```
private protected sealed abstract class Foo extends Bar implements Baz permits Qux {
use Quux;
}
```

seems about right
 
@SaifEddinGmati brain dribbles out onto the floor
 
5:00 PM
#Visibility(Visibility::PRIVATE_PROTECTED)
#Sealed(Qux::class)
#Abstract
#Extends(Bar::class)
#Implements(Baz::class)
#UsesTrait(Quux::class)
class Foo {
}
hm, can an enum be an attribute?
 
#[Visibility(Visibility::PRIVATE_PROTECTED)]
#[Sealed(Qux::class)]
#[Abstract]
#[Extends(Bar::class)]
#[Implements(Baz::class)]
#[UsesTrait(Quux::class)]
#[Class]
#[Methods('hello')]
Foo;

private function hello(): void { var_dump($this); // object "Foo" }
 
Don't forget the PHPDoc and constructor property promotion
 
@IMSoP No.
 
aw, that's a shame
"#[Orm\TypeEnum::Int]" would be a nice shortcut for "#[Orm\Type(Orm\TypeEnum::Int)]"
 
why not #[ORM\Type\Integer]?
 
5:07 PM
true; just feels very enum-y
I guess this is the sealed class / enum / ADT cross-over again
if the child class doesn't do anything other than be a possible value, that's kind of what an enum is
 
on 7.4, so null-safe operator isn't available... I have a method that returns ?\DOMXPath, in the event that the method returns null, should I just use an if null check? I was thinking I could use null-coalesce assignment somehow, but if the method returns null, null-coalesce assignment doesn't exactly work
wondering which is better from a code design standpoint
 
@Tiffany do whatever is simple that works. worry about making it look nice later...aka big ol' if statements.
 
👍 thanks
 
@cmb There's a "too many arguments for format" build error
The rc arg is too much
 
5:25 PM
IIRC, doctrine types do more than that, they are the ones responsible for converting values from PHP to whatever database you are using.

but i assume your example is not related to doctrine, either way, the base type there shouldn't be sealed, unless you don't want people implementing their own types.
 
@IMSoP Oh, you mean that direction. Yeah, there's 2 blockers. One, an Enum can't be instantiated, and that's what attribiutes do. Two, Enums can't yet take arguments.
Possible heuristic for keyword vs attribute: Is it boolean? If so, keyword. If it has modifiers on the modifier, attribute.
 
@SaifEddinGmati tbh, I was just trying to think of an example; it actually came into my head with the imaginary #[Visibility::PRIVATE_PROTECTED]
@Crell yeah, Levi said something similar, and I don't get it
 
Don't get it how?
 
don't get why that's a useful distinction
 
Because attribute syntax has a built in way to handle variation: They take arguments.
 
5:28 PM
so do functions, but that doesn't mean you have to
 
But protected(write-once) $foo; just looks weird.
 
no, I mean the other way around: what's wrong with an attribute that doesn't take arguments?
 
At least in theory, one could implement any language keyword as an attribute now. But that's a pathological case.
In concept, nothing. But for many cases (this is a heuristic, not a hard rule!), it's less typing and easier linting and more consistent with the existing language to make it a keyword.
 
I don't think it's the right heuristic, is all
"if it fits in a family with existing keywords, make it a keyword" is much more convincing
and suggests that "sealed" would be a keyword
 
I think Michal's point about class symbols vs strings is the best argument on sealed, specifically.
 
5:33 PM
I didn't see that, and it's also a good argument; although it would be good to add a proper way of passing around class and function references anyway
a heuristic based on "if it takes arguments" would suggest "extends" should be an attribute, but "final" should be a keyword, and I don't think that's what either you or Levi had in mind
 
true...
 
also, "nojit" as a keyword and "#[JitMode(...)]" as an attribute
 
#[Jit(mode: ...)], #[Jit(enable: false)]?
 
#[OneAttributeToRuleThemAll(enableJit: false)]
there you go, you don't need to name anything, everything's a parameter now
 
#[Eval(code: "echo 'hello, world!';")]
 
5:40 PM
since I clearly suck at inventing examples that don't have holes to pick, here's a real-life attribute with no arguments: doctrine-project.org/projects/doctrine-orm/en/2.9/reference/…
and about half the attributes on that page have no required parameters
 
Which notation is that
 
because the presence of the attribute is the most important thing, just like the presence of a keyword like "final"
 
PHP doc please ?
 
@ln-s which notation is what?
 
#[Eval(code: "echo 'hello, world!';")]
if it's a new feature I would like to know more about it, as long as it's core PHP
 
5:45 PM
that's just Saif being silly; although it's a perfectly valid attribute, if you want to implement it in userland
 
#[PostPersist]
public function sendOptinMail() {}

^ Is this some doctrine Reflection class parsing logic or is it actually interpreted by the PHP interpreter
That's the question
 
@ln-s it's Doctrine's existing annotations re-written with PHP 8's native attributes php.net/attributes
 
@ln-s doctrine
when calling EntityManager::persist($object) it will execute it after persisting to database
 
the second thing on the shiny PHP 8 announcement page: php.net/releases/8.0/en.php
 
i always forget nullsafe operator was added to 8.0, til now i don't think i have actually used it, not because i don't have a use case for it, i just forget it exists
 
5:55 PM
eugh; time to stop telling people they're Wrong On The Internet and get some fresh air
 
same, gonna get dinner then play some apex, reading replies to the RFC draft gave me a headache.
 
6:17 PM
o/
 
6:28 PM
\o
 
ReflectionParameter::getDeclaringClass() replaced ReflectionParameter::getClass(), yes?
 
no
getType
because it has to deal with the lists now
 
Ah. The docs page for getClass really needs a "do this instead" example.
 
getType will return ReflectionNamedType or ReflectionUnionType
reflection is a mess ... thankfully it's all in one god file, so it's quite an easy mess to find your way around ...
I'm quite concerned that 50% of the potential energy that internals has is going to be expended on attributes if we don't decide now what they are going to be used for and what they are not going to be used for ...
 
6:43 PM
Much the same as the eternal namespace debate.
 
I think I liked the distinction Derick made earlier when he said they should not be used for the compiler, or compile time ... I'd go one further and say nothing /Zend should be an attribute, nothing in the compiler, nothing in the type system, nothing in potentially utf8/wchar or today's strings, nothing in fibers, nothing in core ... we should not waste time talking about any of that
 
I disagree, because they do offer useful power that is difficult to represent in keywords at times. Validation guards for properties or arguments, for instance.
 
apart from the fact they aren't really up to the job of doing any of the things they are being suggested for, they are primarily, I think, for userland, and extensions, and definitely at runtime ... while we could make them suitable for more complex work, I think it a mistake ...
just looking at that doctrine mess makes me feel sick to my stomach ...
@Crell that's runtime
 
I guess I'm not clear on where you're drawing the line, then. It would require modifying the opcodes to inject the guard around any property set call, wouldn't it?
 
jesus no
I can't think of anything worse than an attribute resulting in different instructions, setting a flag is one step too far for me, changing the output of the compiler is utterly out of the question imo ...
 
6:51 PM
i don't think we should, Java does this, and it's a mess, Hack does this but have it's reasons: it's an unfinished language.
e.g, hack soft types were using `function foo(@int $bar): void {}`, but were switched to `function foo(<<__Soft>> $bar): void {}`, not because attributes are a better fit, but because they wanted to replace the attribute syntax from `<<attr>>` to `@attr`, but `@` was taken by soft type declaration ( `@` no more silences errors in hack ).
 
@JoeWatkins What is the major difference between a keyword and an attribute in your mind? Is it just that attributes are currently just not up to the job?
 
Hack is a pile of good ideas, that are not implemented properly, or are half-baked.
 
@SaifEddinGmati It's right there in the name...
 
> while we could make them suitable for more complex work, I think it a mistake ...
 
fixing generics parsers issues: #[GenericTemplates('Tk', 'Tv')] class Collection { ... }
 
6:55 PM
I think before making that determination we would benefit from theorycrafting what else we might want to add in future, and compare what syntax might look like for them, vs attributes.
 
@SaifEddinGmati this is a joke, in case i have to say it
 
it doesn't matter if you think it looks nicer as an attribute
 
class Foo {

  #[Regex('w+')]
  public string $name;

  #[Range(0, 100)]
  public int $age;

  #[ValidateMethod('validateFoo']
  public string $foo;

  public function validateFoo(string $foo) {
    // return true, false, or a modified string. Or something, TBD.
  }
}
 
@Crell this is basically symfony/validator.
 
you don't really think that belongs in the core do you ?
 
6:56 PM
That's the sort of thing I'd like to be able to do with guards, and from a user POV attributes "feel" like a good syntax for that. What other approach would work, syntactically?
 
this is literally symfony/validator, you can install it right now, and it works exactly like that!

it's a good use of attributes in userland, but it should stay there.
 
@JoeWatkins Nikita proposed guards as an inline part of property accessors. This is what I evolved the concept into in my head at least. And yes, I can see use for it.
@SaifEddinGmati In userland means you have to proactively check an object later to see if it's valid. You can't prevent invalid values from being assigned.
 
@Crell a design by contract framework
@Crell I've read that pr, I see no mention or code for anything you're describing, context ?
 
00:00 - 19:0019:00 - 00:00

« first day (3846 days earlier)      last day (1102 days later) »