Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121606 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 15132 invoked from network); 7 Nov 2023 13:41:43 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Nov 2023 13:41:43 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DCE3E1804D4 for ; Tue, 7 Nov 2023 05:41:42 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NEUTRAL,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS34011 80.67.16.0/20 X-Spam-Virus: No X-Envelope-From: Received: from smtprelay06.ispgateway.de (smtprelay06.ispgateway.de [80.67.31.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 7 Nov 2023 05:41:42 -0800 (PST) Received: from [87.191.194.51] (helo=[192.168.178.16]) by smtprelay06.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96.1) (envelope-from ) id 1r0MKq-0003g5-1u; Tue, 07 Nov 2023 14:41:40 +0100 Message-ID: <9cf817bb-6e47-4014-9ffc-fd48cf5660e3@anthrotec.de> Date: Tue, 7 Nov 2023 14:41:39 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: de-DE To: Oladoyinbo Vincent , php internals References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Df-Sender: dGhvbWFzLmd1dGJpZXJAYW50aHJvdGVjLmRl Subject: Re: [PHP-DEV] [Discussion] Variable Type Declaration Before Usage From: thomas.gutbier@anthrotec.de (Thomas Gutbier) Am 05.11.2023 um 14:37 schrieb Oladoyinbo Vincent: > Hello Internals, > > Local based variable declaration before usage is available in most > languages like javascript, python, and many more. php has this, but it's > only available while working/dealing with oop related. Somewhat ironically, one could say that typed scalar variables are already supported, albeit with a somewhat cumbersome syntax. Instead of  ```php int $intVar; ``` you write ```php class TypedInt {     public static int $intVar = 0; } $intVar = &TypedInt::$intVar; echo $intVar; // 0 $intVar = 3; echo $intVar; // 3 $intVar = 'x'; // Fatal error: Uncaught TypeError ``` https://3v4l.org/GFNgp#v8.2.11 Greetings Thomas Gutbier