Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113327 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 47338 invoked from network); 28 Feb 2021 13:31:23 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 28 Feb 2021 13:31:23 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 41D721804D1 for ; Sun, 28 Feb 2021 05:21:06 -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=-0.7 required=5.0 tests=BAYES_05,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-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (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, 28 Feb 2021 05:21:05 -0800 (PST) Received: by mail-lj1-f182.google.com with SMTP id e2so9011643ljo.7 for ; Sun, 28 Feb 2021 05:21:05 -0800 (PST) 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=vTuwtpvRSxn2k+RPPbvyF2NDMQ7QvONfSjomngoPlt4=; b=iaOYgvJNO1rGlSCyu59O9Zw3uTUgpRRPFXKyrId408EZJSQXmCV7TFgst8QCuW+HMF 3WBEcmcTuttvK9QJ+Vuhy2jFZMB1mnrpEzjraFwxyzf5hRsHfN69NkPF+UJ7hXb5HgfG IUoAwjIjCpFoPg6Qo3m5tTyH63lF96QAUXbGUBbkBXG2Kz/oZDLg6ZJA1clPeoBIoePU EAIVRNdmF3jcnPxvr+8Wv6cqOJOKd5MqBsbv+Ojp3/wKfhNghFJFJjxTUgvly11ONDLt XMlmiEKuUfNqmezBxFtSuUza90eG0TBx6ydYfzqZ/CSeyt2Vn8F+kdMagmQal+e6HhIf mwZg== 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=vTuwtpvRSxn2k+RPPbvyF2NDMQ7QvONfSjomngoPlt4=; b=QyTXersaKT3ZcJDUZTvg5enNI+W6wtXr1dZsgWaG3NkbPPHJj8WaQcVoG/UPhk0wj+ 41e3eho8QeEc/P6hCpAMaUS2rZITm9+xh8UClmjF297wFYfn6cVMKYAm88DV8AxjfQMx dD7+KbzCbXslsaZ1sXAHQQd7VP22U5HqnqysHP2CSwqRY3gBk9m31bQKXZHN/OIOe30A el/G59hQ5TzcyWe27xRfITWFP6QrpuoOj2ianM+uoiixhgmCN0M2QPTPg9R5G5B1z9QG B6VRbWTTg8tClutXOfHFTx9EqE5VQxr6++ZteyJ2goRp7itNXvJ4vnz2jea6Ql0/hvPM PgUQ== X-Gm-Message-State: AOAM532yIm7XknCNt4xFFo5im3qO0F9zXtFNl2lC9X+hlei2LdUXUQCc 9buolJaaEsdqropCrIUeV1OZq9ji7nC1jWJkX4VZdkNnaCzVtA== X-Google-Smtp-Source: ABdhPJyoVgtqwrvy3xU9+dJfTeFzbeGmeWswcED2QfprIjTV3i9ndH0IEwm67VUTZVEBc30a9MKTKtAcltIqPL6aF28= X-Received: by 2002:a2e:8047:: with SMTP id p7mr629942ljg.8.1614518463852; Sun, 28 Feb 2021 05:21:03 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Sun, 28 Feb 2021 15:20:57 +0200 Message-ID: To: AllenJB Cc: PHP Internals Content-Type: multipart/alternative; boundary="00000000000085734205bc655f9b" Subject: Re: [PHP-DEV] Methods Overloading in PHP From: zsidelnik@gmail.com (Eugene Sidelnyk) --00000000000085734205bc655f9b Content-Type: text/plain; charset="UTF-8" > It looks like your message is missing at least a link Sorry, I am using gmail and have attached an image which you probably can't see. ![excerpt from book]( https://habrastorage.org/webt/my/8t/in/my8tin97ukibw6ebh0cbaqhmv64.png) On Sun, Feb 28, 2021 at 3:07 PM AllenJB wrote: > > On 28/02/2021 12:49, Eugene Sidelnyk wrote: > > Hi there! > > I faced a lack of methods overloading in PHP once again and would like to > > ask will it be implemented at some point? > > As well, I want you to show some pros and cons which you see in this > > feature. > > > > Here're some thoughts about this by Yegor Bugayenko: > > > It looks like your message is missing at least a link. A quick search > did however turn up a tweet where Yego suggests it's a code smell (which > basically echos my thoughts below): > https://twitter.com/yegor256/status/932701585339240449 > > A quick search shows the most recent discussion on method overloading > here appears to be: https://externals.io/message/104073 > > The big problem with implementing method overloading in PHP is its > typing system. It might be possible to implement it in certain cases > where types are strictly defined for all parameters and return values, > but I suspect there would still be issues over scalar types > (particularly int/float) and union types. > > My personal opinion is that method overloading is unnecessary, and can > be detrimental to code readability when not used carefully. Without it I > think developers are forced to name methods that do similar things more > concisely, while when it's available they're more likely to create a > "single" generically named, overloaded method whose behavior can differ > depending on the inputs. > > --00000000000085734205bc655f9b--