Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126755 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 7C5491A00BC for ; Fri, 14 Mar 2025 16:09:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1741968437; bh=PlDqGN174tzzK+qGHp6fpneEjuC/GN7A6d9UBM8oWec=; h=References:In-Reply-To:From:Date:Subject:To:From; b=TCF/CjDYAQOa1mJp3tHckD/+id4+UAIy1SJkjH0+VQVfZslQRpUYZL2KogbYjILlE syTcG5slwpkLjE1ZV/riUlQWg1qpCdfe2v2Wcdg14MIZUDuwfTVYsi+javuawJh3ff qaZWW5ERcSNxRFT0Vi6zobbW47aPoKjA804X799FhAtvFjhpAIOjL0MriToAsnKdlJ V5Ps+dnM7ZSJel9BK1Mc27Otz5Ho4OYb/g+iY3OI7lPVkNv4NHYn8c1hIzJKzFzAuq oVA5rG5hWfYWGVK3Ep63W1NhsM4AyFCC6Ms5Y2Pz5TmqknZorevsvUMAPJ9I+ZPk4L x10MxAXNNCAzA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 831B1180069 for ; Fri, 14 Mar 2025 16:07:16 +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=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) (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 ; Fri, 14 Mar 2025 16:07:16 +0000 (UTC) Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-6e8f05acc13so25321986d6.2 for ; Fri, 14 Mar 2025 09:09:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741968588; x=1742573388; darn=lists.php.net; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=kn8LVIV3itQ0hqLaAfIFE3qbr/Z0S3XAHfXavfpgoGQ=; b=egZ49b3HUM6BSP59q8L1tUdOgfH7bq7cZRUhBczjABr3ebgS5Ik4gDzbVRb2ElBAG6 TCUc52eWm6vtq12ypYOxkgEzcH1QJQrA/y4GbrsUD/hLT74NyYd3W8MPcZgIi4l/H8Vh 1BInK2662Ibr8RM8NhMrBQFXE2M+fBWMxZz2dbV495Afn55PLpigEqR//vLwoaWaOFCa HNl/fKOJSQYPNBGsAmpi1dpHHVXt2ythG+hmoZpgktBHqekEe5gCWBiB3lhfJgsyOrJ3 jLXll1OYdlzBllAkZyVXA6aiVjTCTLCyL03R2KsA8cnG0BqFRwt8GaNyknGwFckAS3B7 e6kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741968588; x=1742573388; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kn8LVIV3itQ0hqLaAfIFE3qbr/Z0S3XAHfXavfpgoGQ=; b=fxIz5HCfQC7yRkcpeME4FtVAHRkHGyLhbNkTMgXstv8Si9kRm4VGzGASi4TBi5SFqL 5H753sNIsb266raVVs1Mcgi3wgKi5lftN/m2tSdgcU5QAz1G7umMTExFDRER+mWf6h3H my8g25+W8+wn+TsNbHS1mHJu/E9q3YPIsbAc28hKqbigkpbsZrfqQ6kFhjGbzfoUU+Mp DoB3iMjVX6asMNqJvU2pV0cgzg7uBhCrkhNw0+x9j6AbTeYT4PWiJOg1w0SbbSF4IJPg ZysE78ps5s4WZdn8nc9+xAr2d6F9D37U7K3IR0opXR/sPhPn2FgasDy8Lwr7kPyS7yaO VN1g== X-Gm-Message-State: AOJu0YzxPPiVvsNEsCdQtXrZqCwQwCtqmCdfxd0WJx5vQw/XHHXAIZRt 5pQhbwkkFVqzjIfnn+hhaB1zw3K1Pb9z219RL3MkViJpe8N9kaO4sYi3oBnrdcm9c3ydOURrOWF rxN8f103LV+BFFPiRcfcpYBdL9zkAcHnsqIA= X-Gm-Gg: ASbGncs7elH3ej6j82TWo3zGualUWo27a2cb/Yh1lWX9y+RVrnAcjofq3VQFD1FexFw ufngxz+aAi0nSlwdyVIXzblklNimgDb1ty8oSytrZbmqbcgcEuMZ3GAQSrQA6F6bEjCwtl6kPOv vOcV4l/Nj3AHPbe40qESXc1/AS5XNRpgeNLOOu/SHpdrx5XPhtkcqholSiy4M= X-Google-Smtp-Source: AGHT+IE4Qx/Kt7ms+OgBYn+oq39GIIUzPdXyig1SqMDRVx6Z/eKZ/d3uHScbcnQbixcy9ZMszQDV0yBGwWGJ6IlCFCs= X-Received: by 2002:ad4:5c68:0:b0:6d8:aba8:837b with SMTP id 6a1803df08f44-6eaeaabd707mr49487666d6.41.1741968588300; Fri, 14 Mar 2025 09:09:48 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 14 Mar 2025 17:09:40 +0100 X-Gm-Features: AQ5f1Jok7ctrRBs8b6ikBvhq_6eQCfOkDgi_dhU6SkWviee0zBLdLGVFStZkDU8 Message-ID: Subject: Re: [PHP-DEV] RFC: short and inner classes To: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: tovilo.ilija@gmail.com (Ilija Tovilo) Hi Bob On Thu, Mar 13, 2025 at 11:36=E2=80=AFPM Bob Weinand = wrote: > > On 6.3.2025 23:20:37, Ilija Tovilo wrote: > > > I would also like to echo what has been said about the :: operator, > > which feels out of place. I understand that \ comes with additional > > autoloading challenges, namely requiring a fallback autoloading > > strategy that currently does not conform to PSR-4. > > Could you please elaborate on why the :: operator feels out of place? > > \ is a namespace separator. > > :: is a class scoping separator. > > > You, yourself did decide to use nested :: for property hook scoping, like= parent::$x::set() - a property scoped within a class, having methods. > The same applies here - it's a class scoped within a class, having method= s. > > Breaking from these patterns seems very surprising to me. :: is an operation performed on the class. E.g. fetch a static property, fetch a constant, call a static method, while \ is part of the class name. The way I see it, the outer class can simply add an additional namespace component to the inner class. class Foo { class Bar {} // Called Foo\Bar public Bar $bar; } This is dead simple, it doesn't change any assumptions about class names by embedding new symbols, it doesn't need a new operator, you can refer to the class with its short name from inside the outer class without `self:>`, which is shorter and more straight forward, `use Foo\Bar;` will just work in other classes, etc. One thing this approach breaks is that it doesn't allow for polymorphic inner class resolution, i.e. static:>Bar. But given this was removed anyway, that point no longer applies. This can also easily be replicated by a simple method: class Foo { class Bar {} public function createBar(): Bar { return new Bar(); } } Except this is actually type-safe, because the return value of createBar() must stay compatible with Foo\Bar. Ilija