Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111291 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 10745 invoked from network); 3 Aug 2020 05:07:56 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Aug 2020 05:07:56 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E6B0B18050B for ; Sun, 2 Aug 2020 21:05:14 -0700 (PDT) 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,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-il1-f177.google.com (mail-il1-f177.google.com [209.85.166.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 2 Aug 2020 21:05:14 -0700 (PDT) Received: by mail-il1-f177.google.com with SMTP id c16so18195645ils.8 for ; Sun, 02 Aug 2020 21:05:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZiM7+KBFKzAFqd0ueD+Lzz3oUF7IUMhw5IPrvi/K3ik=; b=tohaHBw/RUz7QRyaI+oMubML+D6sMd7bGIvWuu6jtdDeA++wPiJNtZsSpOaic814+C o7TUFSKisMpBepJ/xJ/lRJZex04w9Fr/I6o7agCtd2A5OTkhQcOHCDnQNr7+5uXFwMuw 3hKpZs3U8q8CVgQfZOVUMYVfEReWXRLX+pEVAIK3LU/lJs8hGtIFYdzPrEZKKUc79og1 DBxPCquihT8tEQTc8u/yi0HcwtC+V4XgHm6B2ufJ47uJK1VZ4D+nTV+do/00tCNmDWmI rOODsKyW1kcKqqJVRDW6DSu5i8bMUKP2N0Au9BXCD/dVnXlqBNyzINhQzOZJg3qOAYNu G2og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZiM7+KBFKzAFqd0ueD+Lzz3oUF7IUMhw5IPrvi/K3ik=; b=D0IPeDJsN9jr7WT9vnG7Yk/agcaQoWs2U+P2LBxLd6N5QY7nugGJHK9qYzF7lg9Q4f JcVTe7ata7LEb6oHtDmlHcuY6BEeXeGGCZtlBNkhEGr27496Axnx0ZyfXDr84BTx4dlR QNk+I14VMPIyKWvzsU2ac6TQYiPrSzTtZbFYbaqZwlWeK+pRDmIRXUcgInGWFuefvKql RVXgo0uuGZ1TVuTSreqbB5EGTwtCes7Gyuv1NswSchCJGEp+jRw9DW7jaPcSU51XiDQF ysZ3P7kQ6QlDznXSXau7280+mCYP7+m/LoSKTuOOA7v3lijXvsS2hkq8cGriynrdAVZG C1aQ== X-Gm-Message-State: AOAM531OLyu90aJNcBmumTb2DlNuNKaW4vUvZbTerGXImmLBH6vROxc0 07gGUmEiaB3h6mmoAMwPv4T3VFNMUsyfWSU3W3E= X-Google-Smtp-Source: ABdhPJzwJ9vtGmUNRcl6gqRYwrUnHv6zXPwawyNIGQoF8RCr9K+pMJ/o47Uo5dzm9f3a0mGrjTCM0FVdguNlVEWbEU8= X-Received: by 2002:a92:7b0f:: with SMTP id w15mr14831561ilc.283.1596427510502; Sun, 02 Aug 2020 21:05:10 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 3 Aug 2020 06:04:58 +0200 Message-ID: To: 3u93n3 Cc: tandre@php.net, kriscraig@php.net, danielc@php.net, derick@php.net, nikic@php.net, joe@joeferguson.me, internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000ac5ba105abf13ef9" Subject: Re: [PHP-DEV] Feature Request: dependencies container From: ocramius@gmail.com (Marco Pivetta) --000000000000ac5ba105abf13ef9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Heya, On Mon, Aug 3, 2020, 05:32 3u93n3 wrote: > The main idea is to take control over objects creation and injecting > dependencies. > > 1. Some of them are provided through constructor (those, which could only > be retrieved right before instantiating our object). > 2. Others are provided through `__inject` and PHP will inject all those > dependencies automatically. Configuration we define in separate class, an= d > pass it's instance into function-helper. > Overall, I don't think this is a good candidate for php-src 2 primary reasons: 1. This is already possible in userland: you can already define your own `__inject` method, and, convention-based, rely on it in your own userland DIC 2. Setter injection (as well as property injection, and also the proposed `__inject`) leads to temporal coupling smells. Explained otherwise, your object instances are not "functioning" right after instantiation, which makes their API more complex and reduces reliability (they are broken until injection has happened). Please just use the constructor: it works, and it is a simple pre-existing injection point =F0=9F=91=8D --000000000000ac5ba105abf13ef9--