Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113278 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 783 invoked from network); 26 Feb 2021 08:27:49 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 26 Feb 2021 08:27:49 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 306DF1804F2 for ; Fri, 26 Feb 2021 00:17:00 -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 00:16:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614327411; cv=none; d=zohomail.com; s=zohoarc; b=NR+FZaBtoge7tT8qRL7R0Q7z+ec/1whjiqwJ8xrL8HKFolPKzE0K6Jm0NoEHzkhwrP14P5k3H7gKAlKaj6jzS08lsb88K62XjP/IaEomrxQyVPafOxsXCTKboqUcJa27ZljLoMvlgaD5ju2QmRTpA/qpr0lSqfg8UDJVap5qDC8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614327411; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=orQjmU0V5JW9hU0kZRIkBxInYp1AdgsFofKun9lGGfw=; b=jVneFda0Fw/8S9UfR5HGLqI8MICeORfqCU+G30sHzOR0CyS6M+PTy1SMasSjm+WX79NKmHksGKLiXiL15uEehgCzRQhGPRUaFly5cdOfE5JFxpL7pSyUhk0pHbZ6UNmSoltD0j9tirH159ofXPEyKDZIR+XiNc46bNs9GSNJFqA= 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=1614327411; 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=orQjmU0V5JW9hU0kZRIkBxInYp1AdgsFofKun9lGGfw=; b=MHTs/e9xWFfFT72Q0uBy+pHgueTqwjCDGsq/LC/e9QM7Ihqf427TELcLy2DM/gL1 98P9QL40w6FmeFLZuTafvckgIq32z2WOerTzefEYf2K8GI2Z4bX+Gs5TkZMTzM/um0O x+zdvvVE1ArpdfKKr/TKLDfP1Zy99CRcW/at4bJ4= Received: from mail.zoho.com by mx.zohomail.com with SMTP id 1614327378219727.8068506382901; Fri, 26 Feb 2021 00:16:18 -0800 (PST) Date: Fri, 26 Feb 2021 09:16:18 +0100 To: "Manuel Canga" Cc: "David Gebler" , "Internals" Message-ID: <177dd68f109.c748581d17565.7200783349436492456@manuelcanga.dev> In-Reply-To: <177db7bbf72.ecf4615f732310.8822018854991483226@manuelcanga.dev> References: <177db7bbf72.ecf4615f732310.8822018854991483226@manuelcanga.dev> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Importance: Medium User-Agent: Zoho Mail X-Mailer: Zoho Mail Subject: Re: [PHP-DEV] [RFC] class_name:namespace From: php@manuelcanga.dev (Manuel Canga) Hello, another example with "factories method"[1]: ```php use MyProject\Framework; abstract class AbstractController { private const HELPER_PATH = static::namespace.'/Helpers'; private const SERVICE_PATH = static::namespace.'/Services'; public function instanceHelper( string $helperClass ) { $helperClassName = self::HELPER_PATH."/{$helperClass}"; return new $helperClassName(); } public function instanceService( string $serviceClass ) { $serviceClassName = self::SERVICE_PATH."/{$serviceClass}"; return new $serviceClassName(); } } use MyProject\MyModule; class Controller { public function __invoke() { //...... $date = $this->instanceHelper('Date'); //... } } ``` [1]: https://en.wikipedia.org/wiki/Factory_method_pattern Regards -- Manuel Canga Zend Certified PHP Engineer Websites: https://manuelcanga.dev | https://trasweb.net Linkedin: https://es.linkedin.com/in/manuelcanga