Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104623 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 62571 invoked from network); 10 Mar 2019 22:07:02 -0000 Received: from unknown (HELO mail-wm1-f48.google.com) (209.85.128.48) by pb1.pair.com with SMTP; 10 Mar 2019 22:07:02 -0000 Received: by mail-wm1-f48.google.com with SMTP id x10so2230104wmg.2 for ; Sun, 10 Mar 2019 11:56:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=Lki84JBk8wf80cs2gyK4PB3pPzQm3zo3s6iHv3aCrf0=; b=Z3Mwcb6CJ+IoSzJnH7+OZJ1abN8C2s296ThPvpxuO9gXuKd26YXsTdE9crifJkYiTR o0iqgvxC/2VAoXa/DucYiwUXmec1KMvWE0qRgRovVXOSBXq3JPL7CNLQgsfOpkTlYNKb KcA1mTG3wqvmJHifRhG47Uef9Qij7aBxGqUqheo8sCOQ1AIxsg5ehZQxZs61p3pfkR6q 45vhV7eQfLNUJB6mviiHAoIpudSN9K6cwuWeQ/vUVne9TWQQRV5sTFcv+4AMnlbM5vZC dP2IPSFXxFEXUFn8R0FanM77Lc26TPLt1p37JAhSqJnNAG0yU3btH8InKq3l91gsIBuA tPJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=Lki84JBk8wf80cs2gyK4PB3pPzQm3zo3s6iHv3aCrf0=; b=PXFs76wla7cY+lCDoy4XLsRvmJBe1gHH4/vlnnkEFwEWSTC035u2ZuRy4nabHgHzDk 9vXllewg9Bc+H2KraPJCSKp55OhCCKGU7mwnj6kekstLMQqzRq8+VghW6X2pYUgCUP6i moAMTcP+kyqRHGnPP5s8GCrP3ANre7yI9AbcrrvAmrztsFmyVD61kaJESQ4jE//c6+/Q Xaaf9ykP35FgOoTnZ/N7hVjqnak0CJH5fxqL/SV8VstUkqfsO7skzkyFDkB5kfnTyMG2 0B88icEaOxzmMlGf10CFX5j7wUEqTc/hQS0l2wlNf43Te5B1IiVdP5TBhvGuyqhvR77r VnGQ== X-Gm-Message-State: APjAAAWAQsMNRvHNJ1mwEDbog/2hgwIJzMQfqHwp4WWgiE6P+Z0uflCl 3uI/fovs5HGLTyOAoPxTDng= X-Google-Smtp-Source: APXvYqxfUBpYw1KX9yMGiWUXr3cOmVWe5bys46FY1WnhMVuXpP09owwZJoDXZqQwJfDLOp3Q98z/6w== X-Received: by 2002:a1c:be11:: with SMTP id o17mr15229996wmf.141.1552244189137; Sun, 10 Mar 2019 11:56:29 -0700 (PDT) Received: from ?IPv6:2001:a61:464:5501:dc97:1532:bd1c:bd5? ([2001:a61:464:5501:dc97:1532:bd1c:bd5]) by smtp.gmail.com with ESMTPSA id v196sm16588813wmf.15.2019.03.10.11.56.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Mar 2019 11:56:28 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) In-Reply-To: <2c497732-96f8-3ef0-bc18-912220fbff4d@gmail.com> Date: Sun, 10 Mar 2019 19:56:27 +0100 Cc: PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: References: <2c497732-96f8-3ef0-bc18-912220fbff4d@gmail.com> To: Rowan Collins X-Mailer: Apple Mail (2.3445.102.3) Subject: Re: [PHP-DEV] RFC: Locked Classes From: gadelat@gmail.com (Gabriel O) Isn=E2=80=99t unset() currently only way to remove reference? This part = is hence very problematic. > On 10. Mar 2019, at 19:35, Rowan Collins = wrote: >=20 > Hi all, >=20 > I'd like to present a new RFC for "locked classes": classes which = restrict dynamically adding or removing properties from their instances. >=20 > While it can be useful, the ability to set an object property which is = not part of the class definition can also lead to subtle bugs. Banning = this for all objects would be a significant and painful breaking change, = so I propose instead the option to mark a particular class with a new = keyword, "locked". >=20 > An instance of a locked class behaves like any other object, except = that: >=20 > - Attempting to set a property on the instance which was not declared = in the class (or inherited from one of its parent classes) will throw an = error, and the instance will not be modified. > - Attempting to read a property on the instance which was not declared = (or inherited) will throw an error, rather than raising a Notice and = evaluating to null. > - Attempting to call unset() on any property of the instance will = throw an error, and the instance will not be modified. >=20 > Note that ECMAScript / JavaScript includes a similar feature, called = "sealed objects". However, the proposed modifier applies to classes, and = "sealed class" has a different meaning elsewhere (e.g. C#, Kotlin), so = I've chosen "locked class" to avoid confusion. >=20 > For further details and examples, please check the RFC at = https://wiki.php.net/rfc/locked-classes and the tests in the draft = implementation at https://github.com/php/php-src/pull/3931 >=20 > Regards, >=20 > --=20 > Rowan Collins > [IMSoP] >=20 >=20 > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >=20