Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99657 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42229 invoked from network); 28 Jun 2017 16:11:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jun 2017 16:11:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=david.proweb@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=david.proweb@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.173 as permitted sender) X-PHP-List-Original-Sender: david.proweb@gmail.com X-Host-Fingerprint: 209.85.192.173 mail-pf0-f173.google.com Received: from [209.85.192.173] ([209.85.192.173:35857] helo=mail-pf0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A3/42-07609-325D3595 for ; Wed, 28 Jun 2017 12:11:15 -0400 Received: by mail-pf0-f173.google.com with SMTP id q86so35755891pfl.3 for ; Wed, 28 Jun 2017 09:11:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=v2lsPC0geUdFGt+1HWTkPsO1y5WZVfjal6bFjuun8Fw=; b=heCgy1KS54re08JPavBjaVayS3wL8JJ1WiWpljnO5IkRoEHY91s5vI3ORZ66gS/Tbg RTT+1rjqbdHQWvS+kzgKMrsMMRJt9j7O3HhO47wPCQQZPj6eU9jxrWjdSKvJUgYlcfwo g2iKWKAcXaw/p7qbR/X44Pwl5h5iMavH0Fy9MCDeu7ZQuWM0WKAWDLrfT7sXRBIuSYe9 zD0JHNsIJBO2g9gCrCvTY0/6xheRuuZ4uxlUk5J55nMotso4TSSAgecxnNLnQ1gVaiM7 vIjtQgvnQm9lZUkO4U/cjxZ8FEx/xrf0Sbe5jxmDLrtFyGkAr7TShs56N/jQFZD/57Qk 12lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=v2lsPC0geUdFGt+1HWTkPsO1y5WZVfjal6bFjuun8Fw=; b=FtjiyXb1vkH6B42KvGC8ytWjq4zYruBydHW8sksfnrRz9UfJvKx6lNvV0pqwEBKVbc 0yGXGzIkmqX4A/gJ9fBfKV+mvB+L+iKteLar8CQxt1JWsh4pybB27cxpFosAw2OHlPkK sVpbus1aeJUeJ7HY+wPoo69GTnZRzTKPmjusBSZHv1bDurV7sVMbPtvMfsNJ4RkgQ/u4 Tm+rJqY4nhsgFuRVo66YI7TwVJ6qD6b9zIT0jrQ3oDzFBR/uK8gfXsEf5PYNjrHogJT8 3QRYKiBd72GbN/5dsUoVfvXnHe/tp6+Fg9kL4GzdhnWwwRbgsK9f5rkMHe3msGa+6H7h Bvag== X-Gm-Message-State: AKS2vOzpkFmjEatn5znylmrRkNsJ9fqhLeuBbvY4EBrWBHR5/19hnwvc a9hixT9klRScNuSUG3A7AV3oOyX3Ya96 X-Received: by 10.99.146.88 with SMTP id s24mr10987799pgn.85.1498666272197; Wed, 28 Jun 2017 09:11:12 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.181.138 with HTTP; Wed, 28 Jun 2017 09:10:51 -0700 (PDT) Date: Wed, 28 Jun 2017 13:10:51 -0300 Message-ID: To: PHP Internals Content-Type: multipart/alternative; boundary="f403045e3372ca960f0553076e61" Subject: Final variables From: david.proweb@gmail.com (David Rodrigues) --f403045e3372ca960f0553076e61 Content-Type: text/plain; charset="UTF-8" Hello internals, Java supports the "final" keyword before a variable to determines that this variables never change it reference. If I declare a variable as "final", I can only initialize that once, then I could not change it after (but I can manipulate the instance, without issues). There some special reason to PHP doesn't supports things like that? final $number = 123; $number = 456; // Error: you change change final variables. final $object = new stdClass; $object->allowed = true; // No error. This feature make sense because it tells to dev that the variable value could not be updated directly (new reference). Which make easy to identify when a variable is modifiable or not. It is valid for a RFC? - It can uses the "final" keyword; - It doesn't a BC; I too think that a final variable can be useful to make some internal improvements on language (but it could be a BC for PHP internals). I mean, as the variable could not be modified, then it don't need be a "flexible" type internally (I guess that it is a zval, right?). Reference: https://github.com/kalessil/phpinspectionsea/issues/363 -- David Rodrigues --f403045e3372ca960f0553076e61--