PHP_STREAM_TO_ZVAL

php.internals

Thomas Hruska

3 years ago
In ext/standard/file.c: #define PHP_STREAM_TO_ZVAL(stream, arg) \ ZEND_ASSERT(Z_TYPE_P(arg) == IS_RESOURCE); \ php_stream_from_res(stream, Z_RES_P(arg)); Can someone clarify why that macro is named PHP_STREAM_TO_ZVAL? The current name seems to imply the inverse of what actually happens.
-- Thomas Hruska CubicleSoft President CubicleSoft has over 80 original open source projects and counting. Plus a couple of commercial/retail products. What software are you looking to build?

Christoph Becker

3 years ago
On 24.11.2022 at 16:35, Thomas Hruska wrote:
> In ext/standard/file.c: > > #define PHP_STREAM_TO_ZVAL(stream, arg) \ >     ZEND_ASSERT(Z_TYPE_P(arg) == IS_RESOURCE); \ >     php_stream_from_res(stream, Z_RES_P(arg)); > > Can someone clarify why that macro is named PHP_STREAM_TO_ZVAL?  The > current name seems to imply the inverse of what actually happens.
Yeah, looks like the commit which introduced that macro[1] got it wrong, and nobody noticed or changed that later. Maybe you want to provide a PR which fixes this. [1] <https://github.com/php/php-src/commit/39b62f26cfe1f6c93d4009b0651a1a2b5b455345>
-- Christoph M. Becker