Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123639 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 qa.php.net (Postfix) with ESMTPS id 4484A1A009C for ; Sun, 16 Jun 2024 17:08:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1718557802; bh=r+Ux6SfAcs8QjXcS81bPgB+100U/iiFDONde6aA/O3Q=; h=Date:Subject:To:References:From:In-Reply-To:From; b=MUsG6Sm+ZdUH2LH6BJvzYAHbQR4RjZSm5fIoNPZFw51gsL5nw4R7KG4Ui1zaNU35Z YW2Yg8KuVQtybcDqkR8D/ID1CKJDT1DlBgYcMxKAmv/d5l0GJ2TFhJ1cgCq0992rK5 vBsfEUwmIbZt41wr9Am/U69wYXqH54fb+2vJ6s0zbYp9TULYIcTBF+X5CIFwe0uby5 igx7y7KGQSETIOqNQgPe/LfR0TBeWGW/KeKsZiwxOkkKsx/+hpVKvHwBUb5qwc6SLM aevsWK2ewZW43DiDwW12KhvehzaKHaXk7i2Wyx99eos9ktm40H99H0tgPjidjRKQOD z3Ro8VO9pftIA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C29BC18005A for ; Sun, 16 Jun 2024 17:10:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fhigh3-smtp.messagingengine.com (fhigh3-smtp.messagingengine.com [103.168.172.154]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 16 Jun 2024 17:09:59 +0000 (UTC) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 3F44B11400AE for ; Sun, 16 Jun 2024 13:08:48 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Sun, 16 Jun 2024 13:08:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1718557728; x=1718644128; bh=F+nyauXIfO c0eGuDRa1XzsEzHvJpl+hPmjYY5lfcBSE=; b=IVfWmTwLMUgIgJ85VyS75su45C Ic4+uaecYuFEBFj3FWzSB+p9+1D9rXvowJHi7q8zoM6oiAD9Y7ip01KZ4xw7GJPr 3h+80ciS8DVmtItObuQOW6ao6+mtW7B63LJpkiGLXnDd00Tw8N89vIDnp8Py5s5T 2jdtmx55cRgSdAe0HiTOWlrRV0n2J93KaaAgfGNKMtxjlOiQh6cFYBebWj2fz2nI kI2Xy14IqglJAmzs1MAHEyDnsJgvuUFKQ7rkNEzzjaoVfQSr+Q/lgl9cIq/on7xS B/bzSLzpbarEhF/9JlIF4IwRo4bIczvfA9fhoA4w4WBPl4vfCpPH7q4WJ7MQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1718557728; x=1718644128; bh=F+nyauXIfOc0eGuDRa1XzsEzHvJp l+hPmjYY5lfcBSE=; b=FuE7Wr+PssEKIFIUb1hpVLZdlvLWkMKkM8H3JaVrkbXM Pi2gdJovSBLVOVV2+u46bYS9cSE4AbixVwcCVEdzRe4TwmUSv5L2a7KA2LUr2DS7 Z/4VhNbqYqcf2OumQtD3fXmPkKUcCSozycnHtkh6ABeVglWcobmL/yzOW7yKlcBW uFEkp8XWYxljB5dtVg3PswQ0T9XNyCCIFD1w6X0LEPZbrpuuEN1Xg1IihkRlqWWi Nbby3dbhox328a6jZOl1yz8aDOzf61C74fAYbxx1jiey5qbkObQa+Hg4kKVYqr+v Ut0bKXLkY1swOyh3dl6Nc6QGbXD2jAtICncqFvt+Jg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfedvfedguddtlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurheptgfkffggfgfuvfhfhfgjsegrtd erredtvdejnecuhfhrohhmpedftfhofigrnhcuvfhomhhmihhnshculgfkoffuohfrngdf uceoihhmshhophdrphhhphesrhifvggtrdgtohdruhhkqeenucggtffrrghtthgvrhhnpe ehteelieeigfeuudeiueeiffdvveehudeufeekjeeugffffedtiedtgeettdelteenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehimhhsohhprd hphhhpsehrfigvtgdrtghordhukh X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sun, 16 Jun 2024 13:08:47 -0400 (EDT) Content-Type: multipart/alternative; boundary="------------SD2AZiY0lvGqARj0vTXtVFHw" Message-ID: <4e439377-5c20-40d7-bb99-5d0ac6c348e9@rwec.co.uk> Date: Sun, 16 Jun 2024 18:08:46 +0100 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] Static class To: internals@lists.php.net References: <0cf69a14-f1b5-4077-9d91-d7b579485eec@scriptfusion.com> <936e1aa3-48cc-4552-9f68-676ebcdeb596@rwec.co.uk> <1fc2f2d0-718f-45ec-8968-b66a1bde686e@scriptfusion.com> Content-Language: en-GB In-Reply-To: From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") This is a multi-part message in MIME format. --------------SD2AZiY0lvGqARj0vTXtVFHw Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 16/06/2024 16:24, Andreas Hennings wrote: > For a function call, the namespace is usually only visible in the > imports list at the top of the file. This is one of those interesting cases where the language itself is flexible, but people are used to a specific style: a use statement can import any level of namespace, to provide as much or as little context as needed in a particular piece of code. namespace Acme\Artistry\Color {     function fromRgb($red, $green, $blue) { /*...*/ } } namespace My\Own\Application {     use Acme\Artistry\Color;     // ...     $color = Color\fromRgb(1,2,3);     // ... } Maybe that's rare in practice, but it's always tricky to judge how much the language should account for such habits  - see also "every class needs a new file", and my pet hate "deprecation notices get promoted to errors". > The class name that is part of a static method call hints at an object > type, whereas for a namespace fragment it may not be really clear what > it describes. > In a static factory call, like `Color::fromRgb($red, $green, $blue)`, > I would argue that having the class name as part of the call improves > DX. This example seems slightly off: if the static method is on the class it is a factory for, that class clearly isn't completely static. Presumably what we're actually talking about is something like "ColorFactory::fromRgb(...)" - or maybe "GraphicsFactory::colorFromRgb(...)", where you might well want to abbreviate to "colorFromRgb(...)". Your points are generally well made, I just wanted to point out there are some nuances in that particular area. Regards, -- Rowan Tommins [IMSoP] --------------SD2AZiY0lvGqARj0vTXtVFHw Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 16/06/2024 16:24, Andreas Hennings wrote:
For a function call, the namespace is usually only visible in the
imports list at the top of the file.

This is one of those interesting cases where the language itself is flexible, but people are used to a specific style: a use statement can import any level of namespace, to provide as much or as little context as needed in a particular piece of code.

namespace Acme\Artistry\Color {
    function fromRgb($red, $green, $blue) { /*...*/ }
}

namespace My\Own\Application {
    use Acme\Artistry\Color;

    // ...
    $color = Color\fromRgb(1,2,3);
    // ...
}


Maybe that's rare in practice, but it's always tricky to judge how much the language should account for such habits  - see also "every class needs a new file", and my pet hate "deprecation notices get promoted to errors".


The class name that is part of a static method call hints at an object
type, whereas for a namespace fragment it may not be really clear what
it describes.
In a static factory call, like `Color::fromRgb($red, $green, $blue)`,
I would argue that having the class name as part of the call improves
DX.

This example seems slightly off: if the static method is on the class it is a factory for, that class clearly isn't completely static.

Presumably what we're actually talking about is something like "ColorFactory::fromRgb(...)" - or maybe "GraphicsFactory::colorFromRgb(...)", where you might well want to abbreviate to "colorFromRgb(...)".


Your points are generally well made, I just wanted to point out there are some nuances in that particular area.

Regards,

-- 
Rowan Tommins
[IMSoP]
--------------SD2AZiY0lvGqARj0vTXtVFHw--