Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117383 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 46604 invoked from network); 19 Mar 2022 20:23:11 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Mar 2022 20:23:11 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9A69C180382 for ; Sat, 19 Mar 2022 14:49:00 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 19 Mar 2022 14:49:00 -0700 (PDT) Received: by mail-il1-f182.google.com with SMTP id x9so8107616ilc.3 for ; Sat, 19 Mar 2022 14:49:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=+56sarwUZcv7jCzL6N9X0ZaR1ccKH1KgktQBOY5cwUI=; b=ppp21U+1SaOcurHtVRMnl/rr9l0iqTH+WWYFIV8I5/9XwmKMAdksU3Msb5I0IylJU+ 4khDMP1RIcL5xkamZW++3xj+Je+DU1JmXL+RtzBLtb7lhJ/k7l01eggnIxx2QbNPu4oR kotYFQw3HqYV4yirZxMOMF2C6htPCesVtIm0c+DQKSATEnT+TiGR4S0KZLzRTsF2xs/W 9QDBww2OdncEK6U7fxppJONY8yMJB0gSKA9mR7NDgKe/3ZN4euHGqoXD1K4uSbvvMu7z fK+mRMh+N+M8qajLXGbCAXtRPj2IbTjXQXtHeydg0QyoXsOAyds9/uAS/++aRLdxfIaa /9cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=+56sarwUZcv7jCzL6N9X0ZaR1ccKH1KgktQBOY5cwUI=; b=XtUVMQhkW4jhRyhuAoO/umumFqGjLwS2WMyzbQLg76rLFtrUK9XaE+LRkf7vHsgKop YbW8nQ2U9ONi/PLm8Sr9y+fzOgmoku1vX8HcHF1XAIVcdT80KCzddsDIBHYXMjL3bsuC lzDuhPg8FF0KaO6Py0FfgYgrOEvmGNUoPzWfKzx43z3gr28ToDR4U+eItx5wKQVdNTzB T3jOBWghdI38GfTCYnVOfykG/j72dzFt3tSFk+i+X0A9DiNyBny2NStUQj+jHWsA2z5u AxL87Dx1UAOicxBcYnwTD5KKOzOzFzw4rJM6cyX45+UxiQ2fUr3jU/k8ThsLyxgDvcIm PhXw== X-Gm-Message-State: AOAM530r/wLTpeoTzIKLcHGoLjbt3TqNq8GjplSuAhAyfqt2NHce7g5J sOpjZrU5Na1ikZkO2mX7JTbxTbPjD48AhRgXE7TqglYyxDg= X-Google-Smtp-Source: ABdhPJyhQO4dKy/bypDXY8lm3/WKICEEa328xNdRyX6c5+xCB6CYxspDEFWqnwZ6zjv0ieGjp54yPWYukzMH4UpjYK0= X-Received: by 2002:a05:6e02:1bcb:b0:2c7:b047:5564 with SMTP id x11-20020a056e021bcb00b002c7b0475564mr6431898ilv.201.1647726539085; Sat, 19 Mar 2022 14:48:59 -0700 (PDT) MIME-Version: 1.0 Date: Sat, 19 Mar 2022 14:48:48 -0700 Message-ID: To: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Subject: Expected behavior for tracking objects? From: sutabi@gmail.com (Joseph Montanez) Hello, I am running into an issue with tracking PHP Objects in an internal object. In PHP only code if you override a variable passed into an object, the origin passed value should remain the same if the variable is changed outside of it. $position = new Vector3(4.0, 2.0, 4.0); $camera = new Camera3D($position); $position = 3; //-- Reassign the position to a new type //-- Now the original value passed is modified, but the value in camera should not be changed var_dump( $camera->position->x, //expected: 4, actual: 1.2621135907985048E-34 $camera->position->y, //expected: 2, actual: 1.401298464324817E-45 $camera->position->z //expected: 4, actual: 4 ); In C I am tracking the Objects by their own structs: typedef struct _php_raylib_camera3d_object { Camera3D camera3d; HashTable *prop_handler; php_raylib_vector3_object *position; php_raylib_vector3_object *target; php_raylib_vector3_object *up; zend_object std; } php_raylib_camera3d_object; Position Getter static zend_object * php_raylib_camera3d_get_position(php_raylib_camera3d_object *obj) /* {{{ */ { GC_ADDREF(&obj->position->std); return &obj->position->std; } /* }}} */ Position Setter static int php_raylib_camera3d_set_position(php_raylib_camera3d_object *obj, zval *newval) /* {{{ */ { int ret = SUCCESS; if (Z_TYPE_P(newval) == IS_NULL) { // Cannot set this to null... return ret; } php_raylib_vector3_object *phpPosition = Z_VECTOR3_OBJ_P(newval); GC_ADDREF(&phpPosition->std); GC_DELREF(&obj->position->std); obj->position = phpPosition; return ret; } /* }}} */ They are registered as a property i.e: php_raylib_camera3d_register_prop_handler(&php_raylib_camera3d_prop_handlers, "position", php_raylib_camera3d_get_position, php_raylib_camera3d_set_position, NULL, NULL, NULL, NULL); I also tried switching to tracking zend_object as well but it's the same problem. Should I be tracking other php objects as a zval instead? Thanks, Joseph Montanez