[PHP-DEV] Re: [RFC] OOP API for cURL extension

2024-02-15 Thread Sara Golemon
Summarizing replies so far.  Won't be able to update the RFC immediately as
my day job needs me, but some great discussions already, gang. Thanks!

* Define the conditions under which exceptions will be thrown (and which
exceptions) - I'll add these to the RFC, but in short:
  * CurlException - Never, it's an interface type to group the other
exceptions.
  * CurlHandleException - Whenever a CurlHandle::method() fails (in lieu of
returning false)
  * CurlMultiException - Same, but for the CurlMultiHandle class.
  * CurlShareException - Same, but for the CurlShareHandle class.

* Naming styles, e.g getErrorNumber(): int   vs   errno()
  Comment: Agreed with your points.  We don't have to stick to a hard line
mapping of the function names.  My initial translation did because my
bugbear is with the lack of fluency and all the rest is just window
dressing on that.
  Proposal: I'll rename all the new APIs according to a get*/set* scheme
without abbreviations, e.g.:
  * CurlHandle::getErrorNumber(): int
  * CurlHandle::getError(): ?string
  * static CurlHandle::getErrorTextFromCode(int $code): ?string
  * CurlHandle::execute(): ?string  // See late note about exec return
values
  * CurlHandle::setOptionInt(int $option, int $value): CurlHandle

* Better typing for setOpt() methods.
  Comment: Yep, this is a good and fair point.  It's going to take a little
more dicing up of the current implementation, but hopefully not too rough.
  Proposal: Keep untyped setOption() method (1/ Easier migration of
existing code, 2/ Some options may prove difficult to type), but add:
  * CurlHandle::setOptionBool(int $option, bool $value): CurlHandle
  * CurlHandle::setOptionInt(int $option, int $value): CurlHandle
  * CurlHandle::setOptionString(int $option, string $value): CurlHandle
  * etc... as needed, will this get weird when we get to Array since there
IS a setOptArray?  Maybe we just don't mirror that one, or we call it
setOptionMany(). Yeah, I like Many for the multiple option set, and Array
for the single option of array type.
  Internally, the setopt handler will be split by type so that each typed
setting can call explicitly, and the untyped one can call all.

* CurlHandle::exec() mixed typing of return values.
  Comment: Agreed.  The `true` return value becomes meaningless in the
RETURNTRANSFER==false case.
  Proposal: Update the RFC for CurlHandle::execute() to return ?string.

* https://php.watch/articles/php-curl-security-hardening
  Comment: I'll read this later when I'm updating the RFC.

* Prefer class constants to global constants.
  Comment: I'm less compelled by this.  The global scope is polluted with
the constants whether we add copies or not.  Adding a second way to spell
the constant name only adds a second way to spell the constant name.
  Proposal: Change my mind?

* Request and Response objects, along the lines of PSR-18
  Comment: I'd be in favor of that, but it's not the mountain I'm
personally trying to climb today.  No offense taken if you vote no because
this isn't enough, but I don't have the cycles to go in that hard.
   Proposal: Write an RFC (and get it passed) and I can probably help you
implement it?

-Sara


[RFC] OOP API for cURL extension

2024-02-14 Thread Sara Golemon
Good afternoon folks, I'd like to open discussion on adding OOP APIs to the
cURL extension.
https://wiki.php.net/rfc/curl-oop

This has been a long standing bug-bear of mine, and I think its time has
come.

try {
  (new \CurlHandle)->setOpt(YOUR_VOTE, true)->exec();
} catch (\CurlHandleException $ex) {
  assert(false); // Why not?!
}

-Sara


Re: [PHP-DEV] [RFC][Vote] RFC1867 for non-POST HTTP verbs

2024-01-23 Thread Sara Golemon
On Mon, Jan 22, 2024 at 1:24 AM Ilija Tovilo  wrote:

> I started the vote on the "RFC1867 for non-POST HTTP verbs" RFC.
> https://wiki.php.net/rfc/rfc1867-non-post
>
>
Apologies for not seeing the discussion period, but I'll qualify my "No"
vote, because I'm actually +1 on the general concept, and this is just a
little bikeshedding (this RFC will pass even with a no vote from me).

1/ This function reaches into the SAPI to pull out the "special" body
data.  That's great, but what about uses where providing an input string
makes sense.  For that, and for point 2, I'd suggest
`http_parse_query(string $query, ?array $options = null): array|object`.

2/ `request_` represents a new psuedo-namespace, functions are easier to
find and associate if we keep them grouped.  I recommend 'http_` because it
compliments the very related function `http_build_query()`, and for the
version of this function which refers directly to the request:
`http_parse_request(?array $options = null) : array|object`.

-Sara


Re: [PHP-DEV] Dedicated StreamBucket class

2024-01-19 Thread Sara Golemon
On Sat, Jan 13, 2024 at 1:29 AM Máté Kocsis  wrote:

> Recently, I realized that the stream_bucket_new() and
> stream_bucket_make_writeable() functions
> create stdClass instances by dynamically adding a "bucket", a "data" and a
> "datalen" property to it.
>

I don't want to stand in the way of you improving this part of Streams, and
I'm really not commenting on your PR at all. BUT I would like to
formally ask/give-permission to just redesign file I/O in PHP altogether.
This would be a nice feature drop for 9.0, and we could deprecate the old
stuff in 10, remove it in 12?

No disrespect to all the folks (including myself) who had a part in file
I/O as it exists today, but it *IS* a hot mess.  I've sketched out
redesigns with folks over the years, but I have to be honest that I don't
have the spoons to invest in Stream 2.0, nor do most of the
fellow-grayhairs I've chatted with about it.

So please, if you at all feel inclined, burn this psuedo-posix I/O hell we
have to the ground and replace it with the gleaming phoenix that PHP
deserves.

-Sara


Re: [PHP-DEV] Add security.txt file to php.net

2023-09-29 Thread Sara Golemon
On Thu, Sep 28, 2023 at 5:20 PM Ben Ramsey  wrote:
> I've added documentation inline in the security.txt file
>

To add some nitpicky bikeshedding, I'd put those instructions elsewhere
(maybe php-src:docs/release-process.md ?) and only have a single line in
the security.txt file referring out to that.  The focus of the security.txt
file should BE the metadata.

+1 on the concept, and I do like the idea of making it part of the new
branch release process as well as having one of the new RMs being the ones
to sign it.

-Sara


Re: [PHP-DEV] RFC [Discussion]: Marking overridden methods (#[\Override])

2023-05-23 Thread Sara Golemon
On Thu, May 11, 2023 at 11:37 AM Tim Düsterhus  wrote:
>
> I'm now opening discussion for the RFC "Marking overridden methods
> (#[\Override])":
>

I 100% get the intent behind this RFC, and as someone who's used this in
multiple other languages the benefit to defensive coding is obvious.

Thoughts:

I think targeting 8.3 is aggressive as we're less than a month from FF
(accounting for discussion and voting period).


The first argument (about not impacting callers) for "why an attribute and
not a keyword" feels like it's tying itself into a knot to make a specious
point.  The second argument about FC is more defensible, though I
personally think it's not merited in this particular case.  I'd personally
rather have a keyword here.


If you do go with an Attribute, then I'd go ahead and go further by
allowing to specify the name of the class being overridden and possibly
flags about intentional LSP violations.  For examples:


// Intentional LSP violations
class A {
  public function foo(): \SimpleXMLElement { return
simplexml_load_file("/tmp/file.xml"); }
}
class TestA extends A {
  #[\Override(Override::IGNORE_RETURN_TYPE_VIOLATION)]
  public function foo(): TestProxyClass { return TestProxy(parent::foo()); }
}

LSP checks are super valuable for writing clean and well debuggable code,
but sometimes they get in the way of mocking or some other non-production
activity.  This could provide a "get out of jail free card" for those
circumstances where you just want to tell the engine, "Shut up, I know what
I'm doing".



// Specific parent override
class A {
  public function foo() { return 1; }
}
class B extends A {
  // Not present in older versions of library, just added by maintainers.
  public function foo() { return bar(); }
}
class C extends B {
  // Errors because we're now overriding B::foo(), not A::foo().
  #[\Override(A::class)]
  public function foo() { return parent::foo() + 1; }
}

C was written at a time before B::foo() was implemented and makes
assumptions about its behavior.  Then B adds their of foo() which breaks
those assumptions.  C gets to know about this more quickly because the
upgrade breaks those assumptions.  C should only use this subfeature in
places where the inheritance hierarchy matters (such as intentional LSP
violations).


Just my initial thoughts, overall +1 on your proposal.

-Sara


Re: [PHP-DEV] Future stability of PHP?

2023-04-11 Thread Sara Golemon
On Tue, Apr 11, 2023 at 9:29 AM Jeffrey Dafoe  wrote:

> Essentially the same thing here. Removal of dynamic properties will be the
> next big one for my team. It's the deprecations that hit huge swaths of
> code without really offering much benefit that are annoying.
>
> Yes, we have a _lot_ of classes. Also multiple versions of Zend framework
> that we backport to. However, I see in a subsequent email that this is in
> preparation for improvements, which makes it more tolerable.
>
>
To clarify; Are you saying that you have a _lot_ of classes _which make use
of dynamic properties_?  A class where properties are predefined is
unimpacted by this.  stdClass is also unimpacted (as it implicitly has
allowdynamicproperties).  The only classes you should need to add the
attribute to are ones where you're using them, essentially, as typed
associative arrays.

I'm surprised if that's what you have, because it seems like a lot of extra
effort to give names to what are essentially anonymous structures.  The
advantage of providing a name should be that you get to know what
properties will be present (and perhaps that the values therein are
validated or typed themselves).

Can you expand a bit more on your use-case?

-Sara


Re: [PHP-DEV] Future stability of PHP?

2023-04-11 Thread Sara Golemon
On Tue, Apr 11, 2023 at 9:18 AM Robert Landers 
wrote:

> > You can add `#[AllowDynamicProperties]` to classes where you want to
> allow
> > dynamic properties.
>
> I don't think that will work in PHP 9?
>
>
In Niki's earliest draft, he wanted to completely remove dynamic properties
from *default* class handlers in 9.0, as this would simplify the most
common use-case for classes and objects and improve their runtime
efficiency.  Even in this case, however, the stdClass specialization would
have dynamic properties implemented in a way which would allow an escape
hatch for user classes via extending stdClass.

We wound up with the attribute approach instead, which means that the logic
for dynamic properties, as well as the allocation overhead, still has to
exist in all userland classes.  All approaches however, came with stdClass
working as expected out of the box, and a low-effort, forward-compatible
escape hatch for those rare cases where dynamic properties are needed on
custom classes.

This is because PHP's dedication to stability IS, AND REMAINS, steadfast
and fanatical.

-Sara


Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading

2023-04-11 Thread Sara Golemon



> On Apr 10, 2023, at 07:17, G. P. B.  wrote:
> 
> Hello Internals,
> 
> Dan and I would like to propose a new core autoloading mechanism that fixes
> some minor design issues with the current class autoloading mechanism and
> introduce a brand-new function autoloading mechanism:
> https://wiki.php.net/rfc/core-autoloading

At a high level: +1, would vote for again (I think I voted for this last time 
it came up...)

Initial thoughts, mostly based on replies so far:

1/ There's certainly some bike-shedding for the names to do.  Good points have 
already been made and I won't belabor them.

2/ I'm unconcerned by the edge case brought up about load ordering as I feel 
that having multiple definitions of a single function name in an autoload 
friendly codebase grouped in files which permit this kind of shenanigans is a 
technical possibility, but a practical absurdity.  Nobody should be designing 
traps like that.

3/ Pinning concerns me a little, and we should certainly build some strong 
unittests to validate behavior here, but I'm confident that can be resolved 
during implementation.

4/ If nothing else, I just look forward to gaining consistency here.  
autoloading being exclusive to classes has long annoyed me, just not quite to 
the point of action.  :)

-Sara
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php



Re: [PHP-DEV] Future stability of PHP?

2023-04-11 Thread Sara Golemon


> I'm saying that the DX for writing extensions is better in other languages.

Citation needed.  Java's extension API is certainly a hot mess.  Python's is 
fine, but ultimately has similar pitfalls to PHP's. Go's looks very nice at 
first blush, but given that it's closer to an FFI than a proper extension API, 
shortfalls inevitably show up when you try to do anything complex.

I'd also point out that PHP's extension API isn't stagnant.  The stub 
generation improvement of just a few years ago significantly improved the 
process of writing extensions.

> And that these days new products come along and provide extensions for
> other languages but not PHP. Which is a problem I can only work around by
> writing an extension.

Okay. Why is this a problem?  This is what's right about OSS.  That you can 
take two things and smush 'em together because you need something from both.

> PHP now has FFI which provides an easier way to extend PHP. I have huge
> hopes for it - but in my experience it doesn't feel finished.

I agree, it's not finished.  But the problem there is also the opportunity.  
OSS works best when people who have an actual need are the ones designing the 
interfaces and making things better.

I don't pay attention to FFI because I can write PHP extensions on a my mobile, 
while sitting on an island beach and playing board games (true story).  I know 
that's not universally true, but it's why I'm not putting the effort in, 
because I'll end up building the wrong solution by not truly understanding the 
requirements (also a true story, take a look at streams sometime).

If it feels like FFI is stalled, it's probably because it's "good enough" for 
the people who got it to this point.  The itch is scratched and the need is met.

So when I call the state of FFI an opportunity, I'm not saying "code or gtfo" 
as such is sometime vilified.  I'm saying this is an open source project of the 
purest kind and it really is up to someone to care about a thing enough to put 
in the work to make it better.

And if your reply is, "But I don't know C", then good news! That's another 
opportunity.  PHP is a nice language, but it's not the only one out there.  C 
is a mother language, the payoff on learning just keeps coming around.

-Sara
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php



Re: [PHP-DEV] PHP Modules

2023-04-10 Thread Sara Golemon


> On Apr 10, 2023, at 20:40, Michael Morris  wrote:
> 
> This will be long.

Yes, it's long, so I'm going to focus on a couple things and not quote too much.

> I propose PHP Modules to hold new features.

What you seem to have described is improved lexical scoping.  Rather than a 
shared "global" scope for classes, functions, constants, and variables, you'd 
like to allow files, or perhaps even statement lists (open brace to closed 
brace) to work as either independent or compositional scopes.  Basically, make 
scopes in a certain mode of PHP act more like Javascript.

I'll be honest, if we could throw away PHP's old behavior and make this the 
only mode, I'd be pretty happy.  We can't of course, at best we'd have to mix 
(and yes, I know that's part of your suggestion).

This is a LOT of complexity.

Not impossible, nothing is, but I'm fairly confident it would make maintaining 
the runtime harder, and would notably slow execution.  Not saying "no", since I 
lack that power, but I do want to make it clear how HARD this feature would be 
to implement well.


> PHP Modules also would not
> parse as templates at all - no opening  that will be a headache for IDE makers, but it's not insurmountable).

I would suggest, as a compromise, keep the initial open tag (or maybe an 
alternative one, like  I hope this helps, or at least spurs a conversation to come up with
> something to address this issue.

Lastly, like the stability thread, this isn't a new suggestion, and I'd 
recommend googling back through the archives for prior discussions.  Past 
failures don't mean it won't work today... Opinions change and so does the 
runtime, but it may be helpful to understand the complexities presented by this 
strategy, and what the objections to it will likely boil down to.

See also "PHP Editions" which is a different, but closely related proposal put 
forth by Andi as recently as the 7.x era.

-Sara
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php



Re: [PHP-DEV] Future stability of PHP?

2023-04-10 Thread Sara Golemon
> PHP has FFI but IMO it would benefit from further development. And the
> benefits of native extensions will often be what's needed instead of FFI.

I'm sorry.  I must be misunderstanding you. Are you implying PHP has no native 
extension mechanism/API?

PHP has had a native extension API since PHP 3.  Longer technically, but only 
the PHP 3 and later APIs are still supported.

Yes. I must not have understood you.

-Sara
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php



Re: [PHP-DEV] base64url format

2023-01-11 Thread Sara Golemon
On Tue, Jan 10, 2023 at 8:44 AM Larry Garfield 
wrote:
>
> > Can hold a vote if anyone objects, but this seems fairly
non-controversial.
> >
>
> It sounds to me like there's enough discussion to be had on the How to
warrant a formal RFC.  I get the sense once the bikeshedding is done it
will pass, but it's going to need the discussion/review.
>

Yep, that's my reading at this point to. Expect an RFC to be inbound with
the initial feedback integrated (e.g. new funcs vs flags).

-Sara


[PHP-DEV] base64url format

2023-01-09 Thread Sara Golemon
I've been working with JWTs lately and that means working with Base64URL
format. (Ref: https://www.rfc-editor.org/rfc/rfc4648#section-5 )
This is essentially the same thing as normal Base64, but instead of '+' and
'/', it uses '-' and '_', respectively. It also allows leaving off the
training '=' padding characters.

So far, I've just been including polyfills like this:

function base64url_decode(string $str): string {
return base64_decode(str_pad(strtr($str, '-_', '+/'), (4 -
(strlen($str) % 4)) % 4, '='));
}

function base64_encode(string $str): string {
return rtrim(strtr(base64_encode($str), '+/', '-_'), '=');
}

These work fine, but they create a LOT of string copies along the way which
shouldn't be necessary.
Would anyone mind if skipped RFC and just added `base64url_encode()` and
`base64url_decode()` to PHP 8.3?

Can hold a vote if anyone objects, but this seems fairly non-controversial.

-Sara


Re: [PHP-DEV] [RFC] Unicode Text Processing

2022-12-15 Thread Sara Golemon
On Thu, Dec 15, 2022 at 9:34 AM Derick Rethans  wrote:

> I have just published an initial draft of the "Unicode Text Processing"
> RFC, a proposal to have performant unicode text processing always
> available to PHP users, by introducing a new "Text" class.
>
> You can find it at:
> https://wiki.php.net/rfc/unicode_text_processing
>
> I'm looking forwards to hearing your opinions, additions, and
> suggestions — the RFC specifically asks for these in places.
>
>
Obviously, hurdle one is making the ICU library a requirement for building
PHP.  I'd almost make that it's own milestone in this project with the
introduction of the Text class as a separate followon.  A very casual
(IANAL) read of the ICU license doesn't seem to make this a problem, so it
may be more of a question of whether we put this on people wanting to build
PHP.  ICU is pretty widely available and used, so I also don't see this as
a major stumbling block.

Question 2 is that class.  I know folks have been clammoring for a `String`
class for some time and this actually fills that niche quite well.  A part
of me wonders if we can overload it a little to provide a psuedo locale of
"binary" so that users can, optionally, treat it like a more generalized
String class in specific cases, storing a normal `char*` zend_string under
the hood in that case.  Possibly as a specialzation tree.

/* names as examples only */
interface Stringy { /* define all those APIs */ }
class Text implements Stringy { /* ... */ }
class BinaryString implements Stringy { /* ... */ }

I think you'd get a lot more buy-in from the folks who worry that UTF16 is
overhead they don't want, but who do like the idea of an OOPy string.  It
also provides a migration path to avoid having to rethink byte vs grapheme
conversions up front, instead deferring that part of a migration till later.

Overall, I'm more positive on this than negative, and I eagerly await the
rest of this thread.

-Sara


Re: [PHP-DEV] Remove PHP-x.y.* git branches

2022-12-14 Thread Sara Golemon
On Tue, Dec 13, 2022 at 12:03 PM Tim Düsterhus  wrote:
> One benefit of removing those branches would be, that usability of
> GitHub's branch selector improves, specifically the branch selector when
> creating a new PR.
>

Maybe this is my CLI privilege talking, but who's using pulldowns to select
PR branches?  Sepcifically, IME we tend to get PRs against the `master`
branch.

All that aside, I do agree that the dropdown's contents can be daunting.
It's a big list. But:

1/ We're unlikely to get rid of the release branches 100%.  The current RC
cycles have branches for their release so that we can add revisions onto
the RC and get a stable final.  So at minimum, there's going to be a
release branch in place for each active release on 16 out of 28 days
(slightly more than 50% of the time).  Sure, that's just a couple of
version specific branches instead of hundreds, and that point is well
taken, but my counterpoint is that we will have working branches.

2/ I'm not convinced this is a confusing scheme.  While php-src doesn't
follow perfect semver, we certainly have something recognizable to the
broader OSS development community, and if you see PHP-8.0 PHP-8.0.0
PHP-8.0.1 etc... I think a programmer is going to being able to sus out the
meaning of these branches.  Even if they don't, the review process will
easily be able to set them straight.  TL;DR We can expect a reasonable
amount of sense on the part of anyone who has any reason to be poking
around branches.

Given #2, I don't see a significant benefit, given #1 I see that benefit
being naturally mitigated, and I don't see removing data from our repo as
being valuable.

Just my personal feeling on the matter, don't let me discourage you from
bringing this to an RFC and holding a vote.

-Sara


Re: [PHP-DEV] Remove PHP-x.y.* git branches

2022-12-13 Thread Sara Golemon
On Tue, Dec 13, 2022 at 11:31 AM Michael Voříšek - ČVUT FJFI <
voris...@fjfi.cvut.cz> wrote:

> Hello everyone,
>
> I am the author of https://github.com/php/php-src/issues/10007 proposal
> and I would ask you for the green light to do so.
>
>
Why do you want to remove these branches?

I agree that they have minimal value especially since the tags are the
actual release commit (and for release process versions often represent a
spur off the release branch), but the cost in the repo is negligible.  What
is gained from removing information from the repository?

-Sara


Re: [PHP-DEV] Change email address associated with account

2022-10-31 Thread Sara Golemon
On Mon, Oct 31, 2022 at 2:48 PM Josh Bruce  wrote:

> I’d like to change my email address for internals but don’t want to lose
> ownership (??) of the falsifiable RFC:
> https://wiki.php.net/rfc/objects-can-be-falsifiable
>
> Is this possible? Should I be posting this somewhere else, if so, where?
>
>
If you're talking about an @php.net address, that's not trivial, but it is
doable.  Ultimately simpler to create a new account and kill the old one.

If you're just talking about mailing list subscription, then you can unsub
from the old one and resub with the new one.  Email to `
internals-subsc...@lists.php.net` and `internals-unsubscr...@lists.php.net`
from the relevant addresses and you'll be responded with a message to
bounce back and confirm.  All self-servicey.

As for the wiki, there's not /really/ such a thing as "ownership" of an RFC
in a formal sense.  Anyone with wiki karma can edit any RFC, there's just a
gentleperson's agreement to not edit the RFCs of others without their
permission.  So again, if you get a new wiki account, and kill the old one,
that's sufficient.

-Sara


Re: [PHP-DEV] One-line heredoc for better syntax highlightning

2022-09-20 Thread Sara Golemon
On 19 September 2022 15:24:26 BST, "Olle Härstedt" <
olle.haerst...@limesurvey.org> wrote:
>Some editors can guess the domain-specific language inside heredoc, e.g.
if you do
>
>$query = <