Re: [PHP-DEV] [RFC[ Property accessor hooks, take 2

2024-03-13 Thread Rowan Tommins [IMSoP]

On 12/03/2024 22:43, Larry Garfield wrote:

It's slightly different, yes.  The point is that the special behavior of a hook is 
disabled if you are within the call stack of a hook, just like the special behavior of 
__get/__set is disabled if you are within the call stack of __get/__set.  What happens 
when you hit an operation that would otherwise go into an infinite loop is a bit 
different, but the "disable to avoid an infinite loop" logic is the same.



I guess I'm looking at it more from the user's point of view: it's very 
rare with __get and __set to have a method that sometimes accesses the 
"real" property, and sometimes goes through the "hook". Either there is 
no real property, or the property has private/protected scope, so any 
method on the classes sees the "real" property *regardless* of access 
via the hook.


I think it would be more helpful to justify this design on its own 
merits, particularly because it's a significant difference from other 
languages (which either don't have a "real property" behind the hooks, 
or in Kotlin's case allow access to it only *directly* inside the hook 
definitions, via the "field" keyword).





The point is to give the user the option for full backwards compatibility when it makes 
sense. This requires jumping through some hoops, which is the point. This is essentially 
equivalent to creating a by-ref getter + a setter, exposing the underlying property. By 
creating a virtual property, we are "accepting" that the two are detached. While we 
could disallow this, we recognize that there may be valid use-cases that we'd like to enable. 
 It also parallels __get/__set, where using &__get means you can write to something 
without going through __set.



I get the impression that to you, it's a given that a "virtual property" 
is something clearly distinct from a "property with hooks", and that 
users will consciously decide between one and the other.


This isn't my expectation; based on what people are used to from 
existing features, and other languages, I expect users to see this as an 
obvious starting point for defining a hooked property:


private int $_foo;
public int $foo { get => $this->_foo; set { $this->_foo = $value; } {

And this as a convenient short-hand for exactly the same thing:

public int $foo { get => $this->foo; set { $this->foo = $value; } }

Choosing one or the other won't feel like "jumping through a hoop", and 
the ability to use an  hook with one and not the other will simply 
seem like a weird oddity.





In practice I expect it virtual properties with both hooks to be very rare.  
Most virtual properties will, I expect, be lazy-computed get-only values.



I don't think this is true. Both of these are, in the terms of the RFC, 
"virtual properties":


public Something $proxied { get => $this->otherObject->thing; set { 
$this->otherObject->thing = $value; } };


public Money $price;
public int $pricePence { get => $this->price->asPence(); set { 
$this->price = Money::fromPence($value); } }


I can also imagine generated classes with "virtual" properties which 
call out to generic "getCached" and "setAndClearCache" methods doing the 
job of this pair of __get and __set methods: 
https://github.com/yiisoft/yii2/blob/master/framework/db/BaseActiveRecord.php#L274







With the change to allow  in the absence of set, I believe that would 
already work.

cf:https://3v4l.org/3Gnti/rfc#vrfc.property-hooks



Awesome! The RFC should probably highlight this, as it gives a 
significant extra option for array properties.


(Also, good to know 3v4l has a copy of the branch; I hadn't thought to 
check.)



Regards,

--
Rowan Tommins
[IMSoP]


Re: [PHP-DEV] base64_encode without padding

2024-03-13 Thread Tim Düsterhus

Hi

On 3/13/24 17:06, Remi Collet wrote:

Use case: for ARGON2 password hashing
see https://github.com/php/php-src/pull/13635

It may seems ugly to add and remove th padding char

Is a RFC needed for such a minor feature ?



Previous related discussion: https://externals.io/message/119243#119243. 
My remark about using a cache-timing safe encoder might be relevant for 
the argon2 usecase.


Best regards
Tim Düstzerhus


Re: [PHP-DEV] [RFC] [VOTE] Deprecate implicitly nullable parameter types

2024-03-13 Thread Gina P. Banyard
On Wednesday, 28 February 2024 at 15:24, Gina P. Banyard  
wrote:

> Hello internals,
> 
> I have opened the vote for the "Deprecate implicitly nullable parameter 
> types" RFC:
> https://wiki.php.net/rfc/deprecate-implicitly-nullable-types
> 
> It will run for two weeks until the 13th of March 2024.
> 
> Best regards,
> 
> Gina P. Banyard

I'm happy to announce that the RFC has been accepted unanimously, with 26 votes 
in favour.

Best regards,

Gina P. Banyard


Re: [PHP-DEV] base64_encode without padding

2024-03-13 Thread Remi Collet

Link to the PR  https://github.com/php/php-src/pull/13698


[PHP-DEV] base64_encode without padding

2024-03-13 Thread Remi Collet

I think padding should be optional (on by default to keep BC)

Of course in user land, simple to write

  $enc = trim(base64_encode('foo'), '=');

This proposal allow to simply use

  $enc = base64_encode('foo', PHP_BASE64_NO_PADDING);

And also expose it for extension as

  PHPAPI extern zend_string *php_base64_encode_ex
(const unsigned char *, size_t, zend_long flags);


Use case: for ARGON2 password hashing
see https://github.com/php/php-src/pull/13635

It may seems ugly to add and remove th padding char

Is a RFC needed for such a minor feature ?


Remi


Re: [PHP-DEV] Re: [pdo_dblib] Correct TDS protocol version

2024-03-13 Thread Saki Takamachi
Hi Rob,

> Instead of creating a BC break (which will probably affect older, less 
> maintained libraries the most), why not create new constants and deprecate 
> the old constants?

I see, it makes sense to provide a transition period for users.

Would it be a good idea to deprecate it in 8.4 and discontinue it in 9.x?

Regardg.

Saki