Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113293 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 61972 invoked from network); 26 Feb 2021 18:21:55 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 26 Feb 2021 18:21:55 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A2B7F1804DD for ; Fri, 26 Feb 2021 10:11:12 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from sender4-op-o11.zoho.com (sender4-op-o11.zoho.com [136.143.188.11]) (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 ; Fri, 26 Feb 2021 10:11:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614363068; cv=none; d=zohomail.com; s=zohoarc; b=P8RDcRppDDO6zWPQNNgHXaCwHu76pdANflAvo0ra12C1XHMqG2VWGrjLKRW8wrPBJFmrasxLFyFGRAMHuHlbo7/XdyePapIg93+PIECerGkQ69lkzYaRlPw/z6aeCTm8IcT6EPIHD42Jg9dGuLIirliSJnso8vQ62B7HjgPrKAA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614363068; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=bUki/y5+07cqHI42jeW/HzbcFzZI4wUcNBsaKkzcWi0=; b=L+m11aZCkHoAuEKvXlLLiEwZrVpgz5pPpFMZg2yAAXbye4hirNle7JrHouejirgRgqDfjg2h0dM0bNQUyFc6XqeROgVcZ5LewIM9LOezxH0Myx1x0iSpScfoeqscUNDeWhDiFHslrucySbB5WXUibw87exitH1K810IvoYRGS9Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=manuelcanga.dev; spf=pass smtp.mailfrom=php@manuelcanga.dev; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1614363068; s=zoho; d=manuelcanga.dev; i=php@manuelcanga.dev; h=Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=bUki/y5+07cqHI42jeW/HzbcFzZI4wUcNBsaKkzcWi0=; b=V8e1mlnbnJVBr/S250LOPwiByUPp/fAOVOQlWqPGBetJx7sk3IV1O1bLbntai7sc EdI+QoICEeOd3Eqyqq5M00db24VG8VbXhMmKQRvapWOsrlRnUHMnkUvLxXAFKvfYNaS n+m2BJr+MGdAUUKm/hirZOR4ue0QBu8/LltUCepc= Received: from mail.zoho.com by mx.zohomail.com with SMTP id 1614363034955131.8960662496646; Fri, 26 Feb 2021 10:10:34 -0800 (PST) Date: Fri, 26 Feb 2021 19:10:34 +0100 To: "Guilliam Xavier" Cc: "Internals" Message-ID: <177df890535.eab535f3117913.1144749575855469330@manuelcanga.dev> In-Reply-To: References: <177db7bbf72.ecf4615f732310.8822018854991483226@manuelcanga.dev> <177dd68f109.c748581d17565.7200783349436492456@manuelcanga.dev> <177de1ff1a0.feee271246706.3311842089729077831@manuelcanga.dev> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Importance: Medium User-Agent: Zoho Mail X-Mailer: Zoho Mail Subject: Re: [PHP-DEV] [RFC] class_name:namespace From: php@manuelcanga.dev (Manuel Canga) ---- En vie, 26 feb 2021 14:40:03 +0100 Guilliam Xavier escribi=C3=B3 ---- > Hi, >=20 > For that example (and most others), you're manipulating file paths anywa= y, > and assume that the FQCN is at least one level deep (i.e. not top-level)= , > so you may as well start with `$p =3D str_replace('\\', \DIRECTORY_SEPAR= ATOR, > $fqcn);` then use `dirname($p)` and/or `basename($p)`. >=20 > Now for the (rarer) cases when you actually want the namespace name and/= or > the unqualified class name, I agree that the current state is not ideal. > To my knowledge, you have the choice between "magic" string manipulation > (various ways) and "semantic" reflection (e.g. `$r =3D new > \ReflectionClass($fqcn);` -- which may try to autoload the class and thr= ows > if it doesn't actually exist -- then use `$r->getNamespaceName()` and/or > `$r->getShortName()`). > Like `str_contains()` was introduced as a "shorthand" for `false !=3D=3D > strpos()`, something like `get_namespace_name()` and/or `get_short_name(= )` > (or other namings) might be worth considering. >=20 > Regards, >=20 > --=20 > Guilliam Xavier >=20 Hi, Guilliam,=20 I think so. I don't need `dirname` function in order to extract path from a file name. = However, `dirname` exists in order to simplify a "common" task in a semanti= c way. Why don't the same with namespaces ?. There is nothing specific in order t= o work with namespaces only they can be used. Regards -- Manuel Canga Zend Certified PHP Engineer=20 Websites: https://manuelcanga.dev | https://trasweb.net Linkedin: https://es.linkedin.com/in/manuelcanga