Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124638 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 6DBE91A00B7 for ; Sat, 27 Jul 2024 08:42:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1722069850; bh=lApmEZPVSKmyTdDzLQraoMeQKm07pd3ZZSRcXppXv+U=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=diXbvSqh226Ove3irR7sVHWi+x1lfx/lo0fFwySih49pGQZ2S4E3YXeLlByvSOuGE coaqAA8UqUzu7e+98h0ZEFg6SwZCMlBgKF3fxkdCWcPezf23/UZaV+UQFYM9YDbJaQ seBeXb95rfFbjFxsfi0PvYMeWs0hQlvkmJdjP6m9Nt1rEKAFBf1OuHJp/Ju+8N12fA RuujCEC7aaSdUegiS6/RPl+NAY+yMq4ef3EX3EBF36CRTEcx95reAXVb5yYhD0ZCiF mICqWc0Qn7/7eWXwPYizeaMheYzzxlyxbNZflQ53TcgLPpN799lofUZLY78/Lzt+K9 oT5zO17ql/WXg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F0E88180056 for ; Sat, 27 Jul 2024 08:44:09 +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,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (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 ; Sat, 27 Jul 2024 08:44:09 +0000 (UTC) Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-65faa0614dbso4595037b3.2 for ; Sat, 27 Jul 2024 01:42:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20230601.gappssmtp.com; s=20230601; t=1722069753; x=1722674553; darn=lists.php.net; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=Np23Xk6AJIRG8Seylqoy7pRVY807Bw1LUBvNe5AtSk8=; b=kS8y28NPXL34g4KN8blgSXIiwqoyjqgUJTHy+StGTWl6v18YTjE2tA1WOY2EDGNxtw DgNvfhKAknMdJYJ6mdeUGFQkfE9+1GEW8W3xUQaaoOorNVcDmUrNYPIG7i9/KXfaPjRA cQG5kn2TDk1qGKOhxQIT3ztafZr4+rqqqM3jbjmIAw53yA4eDKLxq0ClU6btvtvSYtWU //IrDzavQoOqK4JXDuJFJ9LVijjIFu6uQVZvt0AnhbcXJcJsnWCaVvRVx/ZeQAaZldsC tBCwsjYnQD4Ur/kguLzrWgsr8HUL44vSZH1LCD1xA/YL46KrOkMOt+snQT3WpKAcwNwJ EhGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722069753; x=1722674553; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Np23Xk6AJIRG8Seylqoy7pRVY807Bw1LUBvNe5AtSk8=; b=YdJx+o9oF6nhEj9j2bGNeQaQdHputuYdeSab5jvrDHZYt/t6oWAjZAe64bUY5fvcL4 ddfm0rg0cH+0l9Q9YY9S8zZ6i+Z1TUWyhgiauL3wLZFlNetFMbxFzCKkSSv1sIWdT7d3 AXtXRViaHe6cBpkzRiyDdLCAhz8NaP16RaZtAFQtuye7Qy2wRJ4FmVzVOI7qIFJanaLy xtw9SxQ+p1fhDL/w9LRAndq5Yjq0N0+Au5qJ2cnHcVw+MUqiT+6TmK2whNCNTOyxJsB3 R9RMPRTiQct/4AdPiT/3osoupiVJA12t7P8QbpGW+qiX7wOWmjIrT4dx4wyMbXwAkQvA a3XQ== X-Gm-Message-State: AOJu0Yxiw8wKrD7h+a4+FfIpdoSqa2tNp7tk8o6+PCcURY6aBVRjlw38 X2/CZWlTCvY4T73UF+amrIhSeDlC5mVr9/fJ7KOMT6kSgnwpYl2gTODwIO8eKXI= X-Google-Smtp-Source: AGHT+IHKpMmr03tUPwXZzyJ56psHBmwGaqhOLlI3NWvq4irOY64gksg0XK6t29eutwdG3higrOplmg== X-Received: by 2002:a05:690c:7307:b0:673:b39a:92eb with SMTP id 00721157ae682-67a0978489amr24126157b3.31.1722069752767; Sat, 27 Jul 2024 01:42:32 -0700 (PDT) Received: from smtpclient.apple (c-98-252-216-111.hsd1.ga.comcast.net. [98.252.216.111]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6756c44db44sm11809037b3.144.2024.07.27.01.42.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Jul 2024 01:42:31 -0700 (PDT) Message-ID: <0EB007CB-5DCF-4363-8B13-E82CF5FE43E3@newclarity.net> Content-Type: multipart/alternative; boundary="Apple-Mail=_8F8FD66A-208E-47F2-8789-7DFE59993868" Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.8\)) Subject: Re: [PHP-DEV] Explicit callee defaults Date: Sat, 27 Jul 2024 04:42:30 -0400 In-Reply-To: <0042e36e-45c2-4e83-8eec-acde37b97d5a@app.fastmail.com> Cc: PHP internals To: Rob Landers References: <8ac3f087-a739-4759-891c-3dd19260ef5e@gmx.de> <34BF3A40-592C-41D7-8C35-5A9F3934E919@newclarity.net> <0042e36e-45c2-4e83-8eec-acde37b97d5a@app.fastmail.com> X-Mailer: Apple Mail (2.3696.120.41.1.8) From: mike@newclarity.net (Mike Schinkel) --Apple-Mail=_8F8FD66A-208E-47F2-8789-7DFE59993868 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jul 27, 2024, at 3:19 AM, Rob Landers wrote: > There=E2=80=99s nothing stopping you from doing that, except your = autoloader. If you wanted to have every class ending with Arg load the = same class without arg; so QueryArg and Query are usually in the same = file (but can be in separate files too), you could do something like = this: >=20 > function customArgAutoloader($className) { > if (substr($className, -3) =3D=3D=3D 'Arg') { > $baseClass =3D substr($className, 0, -3); > $filePath =3D __DIR__ . '/' . $baseClass . '.php'; >=20 > if (file_exists($filePath)) { > require_once $filePath; > }=20 > } > } >=20 > spl_autoload_register('customArgAutoloader'); >=20 > (Untested, but you get the idea) Sure, but that is non-standard, so it would be swimming against the = current to use it, and no one else would write code that way. Still, the reason for my comment was to ask we consider a first-class = args type which would enable being able to pass parameters like `{foo: = 1, bar: 2}` instead of `new QueryArgs(foo: 1, bar: 2)`, not to discuss = autoloaders. -Mike --Apple-Mail=_8F8FD66A-208E-47F2-8789-7DFE59993868 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
On = Jul 27, 2024, at 3:19 AM, Rob Landers <rob@bottled.codes> = wrote:
There=E2=80=99s nothing stopping you = from doing that, except your autoloader. If you wanted to have every = class ending with Arg load the same class without arg; so QueryArg and = Query are usually in the same file (but can be in separate files too), = you could do something like this:

<?php
function = customArgAutoloader($className) {
    if (substr($className, -3) =3D=3D=3D = 'Arg') {
        $baseClass =3D = substr($className, 0, -3);
        $filePath =3D = __DIR__ . '/' . $baseClass . '.php';

        if = (file_exists($filePath)) {
          &nb= sp; require_once $filePath;
        } 
    }
}

spl_autoload_register('customArgAutoloader');

(Untested, but you get the idea)

Sure, but = that is non-standard, so it would be swimming against the current to use = it, and no one else would write code that way.

Still, the reason for my comment was to ask we = consider a first-class args type which would enable being able to pass = parameters like `{foo: 1, bar: 2}` instead of  `new QueryArgs(foo: = 1, bar: 2)`, not to discuss autoloaders.

-Mike

= --Apple-Mail=_8F8FD66A-208E-47F2-8789-7DFE59993868--