Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119905 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 58718 invoked from network); 11 Apr 2023 10:57:36 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Apr 2023 10:57:36 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 048541804F8 for ; Tue, 11 Apr 2023 03:57:36 -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, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 11 Apr 2023 03:57:35 -0700 (PDT) Received: by mail-pg1-f176.google.com with SMTP id q191so11505218pgq.7 for ; Tue, 11 Apr 2023 03:57:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1681210654; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=IzIhYvrZqSCpwUXa/WWucQDjNYrqXCJvoViFUrRCJIo=; b=lMFLJ0FsKKu1gNivYOWEDqwRAvrH8EgMG8OzUJ+gv+TklRjVM6USibPV51Waova7C7 /ECAyVGtVTzqQc29RmL6dNIp4Vbr1/eDeSnnU3SkmRF38Il88kZHgjpZF5fh7Y0c7qEq Fmf7mAGCgeRDkSHSsEc7bF46iUlLDyt+g48fy5igCmZiFxj3dQeleWWal6YIqaMmTeHB kGHFhTfbiCUKigSZPoONJsgh4mtKb+gY/HcUC42pk3Vwsus/ZOHulOuWzW7gg+72FLaa XKDVoR3IdpYV3V/aCbS9R6to/cjF2qQD0E77YIrkLgwtqITPWI9RJg/hIemc/pqb6ntQ DWag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681210654; h=cc: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=IzIhYvrZqSCpwUXa/WWucQDjNYrqXCJvoViFUrRCJIo=; b=Pew6mXqsM7g5XIMkLrbbbfxdMCk2oUG/MP1/sFX5AvR8vwH/uoGUxdUM8wP1mkN6Db 8UF1VUtLZXfWakxvdUHP+bd1kNciRrRHz+Pdp1FoVkxT3VJt8ci+TN04XzAzyNpBd3wU rlRkEGKBppwgIiatWR8qCCbef/lPOUkOWLXJqzBIoTSPqqkti2akqejrAqvbyT2jZJNC OHvNlUE3+w/7Wi8kXxakx6TFk/4+YeL/9JkU/Vo9/FU2a72n4g+d4D0nKr+0oZhKicS6 +Ja5sc0UETNVgS4f0Kh+CQiRHV5Tasl90/AhuhKN73Qz5r5vjLTL1gYU2Pc+kdMat9I0 749A== X-Gm-Message-State: AAQBX9fanuiuZaQhVPiaToXQd3NIp5MjdUUreCXJQbTepI1w2W/a6zTn 2STicvmT6jWV+Yx9tyDqT493YBUpEkobq8sKnXo+ejv0 X-Google-Smtp-Source: AKy350Zsf2VRDt1eYkMfOEtzqg8hiAiQ+ZzcxAJUaHhhV69L28RRMuSE+zYORXGD7DQcHB82JDbqhd+kzbL7ojXCvjA= X-Received: by 2002:a63:2745:0:b0:517:f0ad:55c0 with SMTP id n66-20020a632745000000b00517f0ad55c0mr614225pgn.9.1681210654476; Tue, 11 Apr 2023 03:57:34 -0700 (PDT) MIME-Version: 1.0 References: <7fe2339ed7ba287811e9437d029696a9b9d8a332.camel@sandfox.me> In-Reply-To: <7fe2339ed7ba287811e9437d029696a9b9d8a332.camel@sandfox.me> Date: Tue, 11 Apr 2023 11:57:23 +0100 Message-ID: To: Anton Smirnov Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000da4e2705f90d5ba9" Subject: Re: [PHP-DEV] [RFC] New core autoloading mechanism with support for function autoloading From: george.banyard@gmail.com ("G. P. B.") --000000000000da4e2705f90d5ba9 Content-Type: text/plain; charset="UTF-8" On Mon, 10 Apr 2023 at 20:12, Anton Smirnov wrote: > Hello George, > > I'm not sure I'm 100% correct but I think that this RFC still allows to > call different functions for the same code, just not in the same run. > > Consider this pseudocode: > > //- funcs.php > > namespace My; > > function myfunc(...) { ... } > function array_map(...) { ... } > > //- code1.php > > namespace My; > > myfunc(1); // autoload triggered > // bonus points if it's a different file or some obscure method > array_map(strlen(...), []); // My\array_map > > //- code2.php > > namespace My; > > // no prior autoload > array_map(strlen(...), []); // global array_map > No, array_map will trigger the autoloader (actually strlen() will trigger it once first) and the autoloader should then load the array_map function from the My namespace. However, if the autoloader does not correctly load the My\array_map() function then it will be bound to the global function. I can add some test cases for that if needed. > And if I understand the current order of execution correctly, here is a > more extreme example: > > //- moreextreme.php > > namespace My; > > if (some_random()) { > array_map('My\myfunc', []); // global array_map > } else { > array_map(myfunc(...), []); // My\array_map > } > > -- > Anton > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > --000000000000da4e2705f90d5ba9--