Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123172 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 CA63B1A009C for ; Tue, 23 Apr 2024 08:17:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1713860260; bh=WUvaVsLnSr5FxW2LStAf9LkfZdVkxzT0Fv3Q+BmPabo=; h=Date:Subject:To:References:From:In-Reply-To:From; b=Iq7Xi2rxGMPP62KcgfR51ux/9rC/6CMKm75BfQ+24lDiCGjpC8yCpe+8+bdsrLrsN 491n9vTHItb8rOkqY+K+zmPs3UsTzgOY6lARpE7KyGItvo3lBhvRYa/uHQmOXWhsvk fFoYlLun0NiGcwUlsvGTHjFzD5GYGyWp9N8eQvDxpJKKnMpoAK7yiXkPECcLZnnQx5 6M8AMyn4jKlOoga8NOB3usWJ6yTWP+DsJLvFBM6DcnO1dTbJlg/19TkYBpPTKzoyMR FOObxGFwgCU5wI80qJD+5o9kI5OAZb8oLblebQv5zFgJIjirsqbbu8Yj8/8yXntGGs 3jlU8rFutws+w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 329171809CE for ; Tue, 23 Apr 2024 08:17:35 +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.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 ; Tue, 23 Apr 2024 08:17:32 +0000 (UTC) Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-41aa2f6ff01so5967045e9.1 for ; Tue, 23 Apr 2024 01:16:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scriptfusion-com.20230601.gappssmtp.com; s=20230601; t=1713860211; x=1714465011; darn=lists.php.net; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=uJFRLWMNK3hR/0D92FqbPbzx/Vv6HdfhAxQwOiD+OTY=; b=Y7jEEoX7+Fxs0pqTzj//XxX3Czc5vtpQx2v90L1aQBT0+jivOn2U+BbFPaFZ88HH1N zTxPum9sAvoBqVkE3A7dsEvHi5iGDaM2t4LTUXw/ccoIXHhtBx7XVwEemhOyktmR/KkT 737Erb/vO7j4Q29iCtGInCoCZ/QsRU5jwF/KTuoK5UIbJNf7GSjzjS7Y3QGKlyKcFCYP son1Qmo+a7/N/Kp9aCx92/yiIbY8/vKjBXLKgBnM4cUjGEku7Eih+/v5SveIgLfr0ceK YYycPL7bMUmLWSMjZ6fWf0Acwe37V2PO0h8N69FR1i/PiphAEUwM5IBP3sY04aroZNzm uesQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713860211; x=1714465011; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uJFRLWMNK3hR/0D92FqbPbzx/Vv6HdfhAxQwOiD+OTY=; b=CUb98Z0SekEbvHWbTbMnYzonKQ/THiLWxptXfQxGHcajvRp3FN6zVxT85KzICQSEun VQ7/gBZF8Ax5CzFLCAEW2AobR9tfLx5gphtyF2SOvArCrzzY+P1vXGG7ws2Oc7uEbNu9 5Gq3WS0TAyFMgV7SBw6hqRF6tuIoX/talSCzK5UfZn45vm9REz1diuZrvMY98EtuRCpf EoaPAnDwlIzFcT2HnrLqs/+fwp7bq7bdbMK/ED0LV4K4ijQZKDi8KRs5554hvLCsXV9L gt50Ms9qkUqaSCpgc6zOd6kk/cSrlq898JxTrV08Zt9y7lGNpz/fBRO6fXC6FyaWtEsI gVwg== X-Gm-Message-State: AOJu0YzxtUpk39OC04Yo8rAnQcv8GUJqBrfgzfo6BnE6IiHO6aCfn69m OLK4qPcwEWqTuHrsGst9WtdvyuPyTXTzeXkJSud1TMgq4nAzHFbbKzjb/ezWInmcr6LzAziEXgw ksEo= X-Google-Smtp-Source: AGHT+IHVjKW3lWR6R3TykToLdvOV9lqhHf5EwCGqMBKiVjK8+RJeQ2SWhiADwQbV3myotKde3yBl8w== X-Received: by 2002:a05:600c:35c7:b0:418:913e:b9dd with SMTP id r7-20020a05600c35c700b00418913eb9ddmr8641241wmq.6.1713860211388; Tue, 23 Apr 2024 01:16:51 -0700 (PDT) Received: from ?IPV6:2a01:4b00:bf09:5101:a801:54af:e01e:ccc3? ([2a01:4b00:bf09:5101:a801:54af:e01e:ccc3]) by smtp.googlemail.com with ESMTPSA id jx12-20020a05600c578c00b0041674bf7d4csm22740570wmb.48.2024.04.23.01.16.50 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Apr 2024 01:16:51 -0700 (PDT) Message-ID: <512bd0ff-4428-4028-8c59-7fb3f8f01621@scriptfusion.com> Date: Tue, 23 Apr 2024 09:16:48 +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] PDO subclass names To: internals@lists.php.net References: <6923C7CF-9168-433C-B2B3-9069F1A766B8@sakiot.com> Content-Language: en-GB In-Reply-To: <6923C7CF-9168-433C-B2B3-9069F1A766B8@sakiot.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: bilge@scriptfusion.com (Bilge) On 21/04/2024 14:00, Saki Takamachi wrote: > Hi internals, > > Recently I've been working on an RFC regarding object support for BCMath. While working on that, I learned of the following RFC: > https://wiki.php.net/rfc/namespaces_in_bundled_extensions > > If we follow this RFC, is it reasonable to place subclasses of PDO under the namespace "PDO”? > > e.g. > ``` > PdoMysql => PDO\Mysql > PdoPgsql => PDO\Pgsql > PdoSqlite => PDO\Sqlite > PdoOdbc => PDO\Odbc > PdoDblib => PDO\Dblib > PdoFirebird => PDO\Firebird > ``` > > We'll probably get a BC Break if try to fix this after 8.4 is released, so before it's released is last chance to fix this safely. > > If Tim's RFC under discussion is passed, the namespace will be "Pdo" instead of "PDO”. > https://wiki.php.net/rfc/class-naming-acronyms > > I would appreciate hearing your opinions. > > Regards, > > Saki Hi Saki, Consider that adding a namespace does not/should not change the class name. That is, `MyClass` once namespaced becomes `MyNamespace\MyClass`. Ergo, `PdoMysql` becomes `Pdo\PdoMysql`. The class name should still make sense and be a "strong name" (without conflict) once imported. To state it more concretely, I believe it is normal and correct to include 1-3 namespace components within the class name itself, in order to create such a "strong name". As a more concrete example of this, consider `HttpClient`, `FtpClient` and `SoapClient`. Far too often, we see user libraries (incorrectly) namespace these as `Http\Client`, `Ftp\Client` and `Soap\Client` (or similar) where the leaf name just becomes `Client`. "Client", by itself is a meaningless moniker, but that is all we see once the name is imported, notwithstanding importing multiple of these clients in one file causes conflicts that now need to be resolved with local aliases. In general, I believe aliasing to be an anti-pattern that points to a failure to create strong names and thus should be avoided by including some of the namespace portion in the class name to make the class name more meaningful. Once imported, we do not see the namespace portion within the body of the file any more; `HttpClient` and `FtpClient` make much more sense by themselves, whether or not they would otherwise conflict. Kind regards, Bilge