colder / php-weakref

PECL extension that implements weak references and weak maps in PHP
http://pecl.php.net/weakref
Other
36 stars 13 forks source link

Objections to publishing a polyfill for PHP's WeakMap/WeakReference based on this repo? #32

Closed TysonAndre closed 2 years ago

TysonAndre commented 2 years ago

I have an approach based on replacing the handlers instead of just the destructor handler working at weakreference_bc for https://github.com/TysonAndre/pecl-weakreference_bc/ targeting 7.0-7.4 - it'll work as long as it isn't used with other extensions doing the same thing to an object.

The actual impact of changing spl_object_hash may be limited


With this repo being abandoned, and https://wiki.php.net/rfc/deprecate_dynamic_properties recently passing, some libraries/applications may need an approach to replace former uses of dynamic properties - having a WeakMap polyfill would help let them continue to support PHP <= 7.4 and allow those users to use newer application/library releases in older php versions before upgrading.

  1. Are there objections to creating a new repo based on this, following the PHP API instead of this for WeakMap
  2. Are there any less obvious roadblocks other than replacing the destructor(dtor) this project faced (e.g. incompatibilities with common extensions)?

Related to #31

For #28 , this did not crash in php's development server in php 7.2

<?php

$obj = (object) [
    "someProperty" => "someValue"
];

$ref = WeakReference::create($obj);

echo $ref->get()->someProperty;
TysonAndre commented 2 years ago

(spl_object_hash replaced the last 16 digits with 0 in php 8.0 (which I see you saw), but this extension doesn't target php 8.0)

I misread that, that only applies to php < 7.0.3, the handlers weren't part of the spl_object_hash from 7.0.3 onwards.

Are there objections to creating a new repo based on this, following the PHP API instead of this for WeakMap

Asking again in case this was missed