Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127901 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id C04F51A00BC for ; Sat, 5 Jul 2025 00:01:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1751673548; bh=yDhHPFox0qQXl8IQWXQDsSmlh/3adX9EWBtAxqE0ZTc=; h=Date:Subject:To:References:From:In-Reply-To:From; b=Ui/Ij7zwAc5pewN1SyUxmA2ZAzHlD1KfMCzhV2S7lkADr605MfIJmaG3EUAHlB2Iv 5ADjMnfix7DRPtDRuKPwrJvGr0k+LrACXNaB8dGSwIfg0lKaJakNxY89R24eMHEQwI fuCxwgTyJVG9mOTYphCkkUS7wxB8g+DujINYHZFoYOYd+gfuwD5JWIth71fqeSy3L2 ErGfH6JxqqoYqqcs8B2C7t0aMBACLHLfLPAJJk0h5fNqq5ePOxK8RSsHOMpibBdeGX Fk9RJPIVcmEdxxfxvQnROmhjIENpOtjO9gp+ppMApcNa6DLFHB5Vz0i31R9BaQ9TG0 /phl3ev8TzLAQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EB9451805B3 for ; Fri, 4 Jul 2025 23:59:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,DMARC_MISSING, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from james.smtp.mailx.hosts.net.nz (james.smtp.mailx.hosts.net.nz [43.245.52.187]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 4 Jul 2025 23:59:05 +0000 (UTC) Received: from 122-57-0-20-vdsl.sparkbb.co.nz ([122.57.0.20] helo=[192.168.1.65]) by james.smtp.mailx.hosts.net.nz with esmtpsa authed as varteg.nz (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_128_GCM:128) (Exim 4.96) (envelope-from ) id 1uXqKs-001xQm-1Y for internals@lists.php.net; Sat, 05 Jul 2025 12:00:54 +1200 Message-ID: <1783986c-957e-4ff7-8683-f4b99befa945@varteg.nz> Date: Sat, 5 Jul 2025 12:00:07 +1200 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [RFC] Deprecations for PHP 8.5 To: internals@lists.php.net References: Content-Language: en-GB In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Hosts-DKIM-Check: none From: Weedpacket@varteg.nz (Morgan) On 2025-07-04 19:38, Alexandru Pătrănescu wrote: > > I'm thinking about constructors usually like this: > They are functions that are invoked statically (using the `new` keyword) > on the class before the object is created, and they execute on instance > level, after the object is created. > > They are called as static methods, and they are very similar to static > factory methods, and for better or worse, static methods are supported > in interfaces. > They're really more instance methods (they need an instance to exist for them to act on, hence $this). The "new" operator creates the instance and then the __construct method is called on that new instance. One consequence of this is that the __construct method can be called _after_ instantiation (because in the normal course of things it _is_): class Foo { public function __construct(public int $v=0) { echo "Constructed {$this->v}!"; } } $t = Foo::__construct(5); $u = new Foo(17); $u->__construct(42);