Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115878 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 90070 invoked from network); 27 Aug 2021 07:00:07 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 27 Aug 2021 07:00:07 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DFFF01804BD for ; Fri, 27 Aug 2021 00:34:44 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS 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-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (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 ; Fri, 27 Aug 2021 00:34:44 -0700 (PDT) Received: by mail-ej1-f53.google.com with SMTP id e21so11828174ejz.12 for ; Fri, 27 Aug 2021 00:34:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Fs5BlA5vs8KUNxC8N/vjcQQGm32D0Pr20+NSjGWHuIg=; b=hsFqSZbz0YTDTy2qyR1jLDlCeFN9AtHXcP7lyr38JjKl+6y3DUibTXIirgJcpUvZPW 7B6FFkc8J1k/AxkqS+30KIZRAX7sghyX39VGTsJpHd9Nr/3FTA92P+APvaYXQUtauOBl pc4iCWyuice/t58wOZHAGbsK4ZjZQd2UR/qJoiFmk2rgDuYnR2nL3DkpopYIqaN4xTQD 0TWfQ12HcZ7i9hzVGdTMwxZ11XzsBAIRndCexFTd+Uni30sSVLrlRBYwqAv2KxGZMYlL d5+rLKISw46H2pecaGOgAqEpKaZCPyQ8Pv4xRvxChiWh+FjbCicL0qSBsuGAGVsvuDii IeWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Fs5BlA5vs8KUNxC8N/vjcQQGm32D0Pr20+NSjGWHuIg=; b=lr5FuQVJwWrKEYGDswupau7af+pytcvr9z/CBhRigg752PV9xqYjxQX1fHajXx2JqR 4HRfQXaVAvJF5urJrKXlM9H9YbXZ2RI2HqIF6pwWdZSRozSsZZEsDzES0359h4ErPaSK Hm1+FEVqQZp1bwBHaiaY/FqJwvepqUmuv8K3V/cAUiXbleiFoSXJl8QCFdsGQmaER7uA FLxGXLKVDHGSoQyASki++gDS1RxqHj7+iARgpaWxZjX2EyZIhr1FlqpuygkSpFZncBCI PPosy/koORDXzHnVLmtYOJtBdjkzIjiSEb752fcDOwTYKsyRS9QkYcscWI2wrbn+vGts lX9g== X-Gm-Message-State: AOAM533zAz8aehmFZFcxvsN1wH7vc7M40QZDvkOyL7wtNPEpF0nSrdRG SMqpJBlTCodfIV6JF1j01PKzna/O3uPc3GXoxRY= X-Google-Smtp-Source: ABdhPJyE/kliqkvMWMOoox464sv2bbyi4sU8EW28R3eey7z5ONn+S1gutTjIrdbrxN+psfC7DBk1a1Zf1iDJha42g70= X-Received: by 2002:a17:906:fb19:: with SMTP id lz25mr8755905ejb.162.1630049683082; Fri, 27 Aug 2021 00:34:43 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 27 Aug 2021 10:34:26 +0300 Message-ID: To: Philip Hofstetter Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000053938805ca8584ea" Subject: Re: [PHP-DEV] 8.1 / Exception / Property Type / Backwards compatbility From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --00000000000053938805ca8584ea Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Aug 10, 2021 at 12:55 PM Philip Hofstetter < phofstetter@sensational.ch> wrote: > Hello > > The following valid <=3D PHP 8.0 code that intends to make the $line prop= erty > public is a fatal error in 8.1 > > class FooException extends Exception { > public $line; > } > > However, the fixed code for 8.1: > > class FooException extends Exception { > public int $line; > } > > Is a fatal error in <=3D 8.0 > > Is there a way to create a class that makes the $line property public > that=E2=80=99s compatible with all versions of PHP without requiring cond= itional > declaration of the class? > > Not sure exactly why you need to $line property public. If you need to be able to read it, you can use __get. If you also need to write it, as that also worked, you can also use __set. So an example that offers the same interface/interaction possible would be: https://3v4l.org/tHhEL#v8.0.9 https://3v4l.org/tHhEL/rfc#vgit.master But of course, when you look at the object with reflection, or how var_dump prints it, the property will still be protected. Regards, Alex --00000000000053938805ca8584ea--