php-src icon indicating copy to clipboard operation
php-src copied to clipboard

add creating object constructor from Jason

Open loveyandex opened this issue 4 years ago • 2 comments

Description

add this signature and syntax to PHP core to enjoy developer from fast developing

class MyObject{

__json_constructor( {"AdditionAmount": 0 // default value,
                "CashRegisterDeviceRef": null,
                "CustomerAddressRef": null,
                "DeliveryDesc": "",
                "Description": null,
                "DeviceReceiptCode": null,
                "DocumentRef": 0,
                "EffectiveNetPrice": 11678899,
                "ExcludedPolicies": "",
                "Fee": 11678899.000000,
                "FreeProductBusinessPolicyConditionRowRef": null,
                "FreeProductBusinessPolicyRef": null,
                "HasReservation": false,
              
            })


}

//create new that instance :
$obj= new MyObject({"AdditionAmount": 0,
                "CashRegisterDeviceRef": null,
                "CustomerAddressRef": null,
                "DeliveryDesc": "",
                "Description": null,
                "DeviceReceiptCode": null,
                "DocumentRef": 0,
                "EffectiveNetPrice": 11678899,
                "ExcludedPolicies": "",
                "Fee": 11678899.000000,
                "FreeProductBusinessPolicyConditionRowRef": null,
                "FreeProductBusinessPolicyRef": null,
                "HasReservation": false,
              
            })


loveyandex avatar Dec 08 '21 14:12 loveyandex

How is that supposed to work? Are all JSON properties to be checked; are superfluous properties to be ignored, or error? What about properties with object values (potentially again having properties with object values, and so on).

This certainly needs more thought and discussion, and finally the RFC process. Feel free to pursue this process.

cmb69 avatar Dec 08 '21 15:12 cmb69

i just tell problem and idea and solution details of that should be in implementing time not by me you can make it a RFC but i am bussy to make it if you do it php lang will be more popular thanks

loveyandex avatar Dec 16 '21 11:12 loveyandex