@ramsey zend_update_property does addref, so it has rc=2 ... so yes, either set rc=0 before update (Z_SET_REFCOUNT) or release after update (zval_dtor) ...
If generics are supported in PHP, you would have to use some kind of static analyzer to get much benefit from it, then you would end up with the task of working with psalm and phpstorm :)
Psalm/PHPStan/PHPStorm would most benefit from a native generics syntax. Especially, in Psalm/PHPStan it is not possible to specify type parameter during instantiation of function call because there is no syntax for it. So Psalm/PHPStan need to rely entirely on parameter inference.
*instantiation or function call
This is a problem in expressions like new Collection(). The analyzer has nothing to infer the type parameters here. If PHP had generics natively we could write new Collection<int>() in this case.
Since PHP-Parser can retrieve the preceding comment at each node, including function call expressions and new's class name specification, I think it would be in principle possible to deal with it in Psalm or PHPStan if someone could come up with a syntax.
It would definitely be easier to read and write with native support, though.
What if we added a List/Sequence type that had its own custom generics syntax? That's like, half the use cases for generics right there. Or would that be more work than adding it to everything?
It comes up a lot in amphp code, for example: https://github.com/amphp/websocket/blob/v2/src/Rfc6455Client.php#L24-L40 The Future and DeferredFuture props are generic as well, but I didn't bother adding the type because it's void and unused.
Annotating properties is a little nicer than inline @var
Is there no-op reorganization or front-work that could be done to move in that direction? Nikita said it was a crapton of work, but is it work that has to be done all at once, or can we leverage "Make the change easy (this may be hard) and then make the easy change"?
@Crell you should probably ask Nikic directly but this reads to me like it needs someone to plob down enough money for someone to work on it for multiple months at least, without even any guarantee of even finding how progress could be made.
@Crell we can definitely make a lot of ground work without changing the language, but I don't know if merging this change before an RFC is accepted is a good idea
How does the build system know to regen the file pdo_dbh_arginfo.h from the stub pdo_dbh.stub.php ? I'm trying to add another stub for a new that will need to be generated also.
@ArnaudLeBlanc Why not? If we know it improves the codebase, and makes future improvements easier, that seems a lot better than trying to fight with merge conflicts for the next 3 years.
Talking of which........does anyone actually use preloading, and is it worth setting up?
rather than doing something boring like setting up your autoloader, then iterating over all the source files in your src directory and just require'ing them?
@Danack I've used it in production since it came out. It's handy to have especially if you've got a build step where you can spend a bit more time creating a custom set of includes.
it's a fairly minor difference, I think it was something like 10 to 15% or so, the main thing is it doesn't have to run all the class definition opcodes / linkers like when using normal opcache
More benefit with more code included each request naturally
Yes, normal opcache only eliminates the parsing and opcode generation step on the next request, it still has to replay all of those opcodes each request. Preloading loads its state, with all that code / structure already in memory, and retains it between requests, therefore no need to re-run the opcodes