Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91951 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2594 invoked from network); 25 Mar 2016 17:45:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Mar 2016 17:45:25 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.171 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.220.171 mail-qk0-f171.google.com Received: from [209.85.220.171] ([209.85.220.171:36597] helo=mail-qk0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FE/93-10214-53975F65 for ; Fri, 25 Mar 2016 12:45:25 -0500 Received: by mail-qk0-f171.google.com with SMTP id s68so35092358qkh.3 for ; Fri, 25 Mar 2016 10:45:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to; bh=tPGqF9cL0xcLwjixSAOAtP5z5MvaXTDc9jNvs34tjhw=; b=SL+grzH8a4uXaocTJDecfC35Ep/kXmu2+UT4RxWlybS2wK11EOz87v7oXxtAtpAkEa fNpdCJiLwEefEYyOfqjzvu31u1dZJDWLMq+7S1u9X8H3QtDW2RYgNfP9UgtLXoOKMV5X SDp3CGYq+Y00bLZrMvZ3XA8r+Q6ns8ZVkyKAwXoA1CNkhASgsTu5jBhOju8llpZzSywG ti7QXyFlxD/jNbKl1SotTZ9kWiQ53kPfr8q3bLduxGzHuAusBX24RZIC/Hyr3Br0+f9L B9cnGGg95G6lfbKJL9jAY0O614RBBzBL9y7pPNnNrdRl+X3isElg+6h3MLRfZI78Ep3x saAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=tPGqF9cL0xcLwjixSAOAtP5z5MvaXTDc9jNvs34tjhw=; b=QBWDxDDbw3Xqc0yj+lXxY05MM8zwQNsxR3gUmBK4W7usy/yl/jChPZMAChlpBN8pLF eKT57HLuSvHU/tfq+NHU3qLVwHqnGzMTwycJoRILYrC444q9MQC4RyXtqZtiQy2wUP1L stbURQFYFNI9hKhDeuT0uOOkgL7bYR4EFccqEEkUyQxg6U+2t33GOp9ys/2k25A4G92P dhncXsd/u0njDsqF/O9ypQwTX8L3Zre/gy2npI8OW6+6p37LrzqBskNsdc5MFQPVKo5P WP7Soui+orBT8gCuMuOw2aOn4D2bm2rBpDynDkL8R1O5vYkxHPij/sS2J6Ss2c+ybsE4 Ze2g== X-Gm-Message-State: AD7BkJLzkzYRmIXrrtABqur7EdAL8N4k71tA7nWqiVbIFK9zhbxHuOHWkKrtjyInivlwWVxoCyXUp48eHeUcWw== MIME-Version: 1.0 X-Received: by 10.37.80.207 with SMTP id e198mr2495146ybb.61.1458927921851; Fri, 25 Mar 2016 10:45:21 -0700 (PDT) Received: by 10.129.148.70 with HTTP; Fri, 25 Mar 2016 10:45:21 -0700 (PDT) Date: Fri, 25 Mar 2016 18:45:21 +0100 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary=001a113e645488f31c052ee3204d Subject: Allow empty property names From: nikita.ppv@gmail.com (Nikita Popov) --001a113e645488f31c052ee3204d Content-Type: text/plain; charset=UTF-8 Hi internals, Currently we do not allow (*) creating empty property names on objects, i.e. $obj->{''} = 42; is illegal. While empty property names are unlikely to be useful per se, they are problematic for deserialization of foreign formats like JSON. To avoid this issue {"": null} will currently decode to a property named "_empty_" rather than "". Notably, this means that JSON decode and encode do not round-trip (as we do not convert _empty_ back to an empty name while encoding). There is no technical reason (that I can see) for keeping this arbitrary restriction. I believe that the original reason for the restriction was our use of NUL-prefixed property names for name mangling, combined with the fact that an empty string at the C level happens to "start" with a NUL byte. A patch to drop the restriction and allow empty property names: https://github.com/php/php-src/pull/1836 It does not touch the JSON handling, as there are BC concerns involved there, I leave that to the ext/json maintainer. Any objections to changing this? Regards, Nikita (*) There are roundabout ways to create them anyway. --001a113e645488f31c052ee3204d--