Re: [Discussion] "Internal" attribute and warning

From: Date: Sat, 18 May 2024 14:17:02 +0000
Subject: Re: [Discussion] "Internal" attribute and warning
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-123347@lists.php.net to get a copy of this message
Hi Robert, > Hello internals, > > I've been thinking about having an "internal" attribute that will emit > a warning if called from outside it's left-most namespace. > > It might look something like this: > > namespace MyCompany\PackageA { > #[\Internal] function doStuff() {} > } > > namespace OtherCompany\PackageB { > \MyCompany\PackageA\doStuff(); // warning emitted > } > > namespace MyCompany\PackageB { > \MyCompany\PackageB\doStuff(); // left-most part of namespace > matches, no warning > } > > This would allow for library maintainers to mark internal constructs > as such and provide users with feedback that they are using code that > may be changed without any notice. > > Any thoughts? > > Robert Landers > Software Engineer > Utrecht NL It seems to be a similar concept to package-private in Java, is my understanding correct? Regards, Saki

« previous php.internals (#123347) next »