Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114720 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 17411 invoked from network); 3 Jun 2021 20:34:03 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Jun 2021 20:34:03 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B24A41804CC for ; Thu, 3 Jun 2021 13:47:38 -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=-0.4 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, 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-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (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 ; Thu, 3 Jun 2021 13:47:38 -0700 (PDT) Received: by mail-qk1-f173.google.com with SMTP id k11so5686647qkk.1 for ; Thu, 03 Jun 2021 13:47:38 -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=CBloLAAmjQeGY4f5aZKUe5vmFLq4/I62b+wFiJ2Aw8M=; b=nDqRiTOToXEKxMGbPOaBnJ1xdcHwDHXr5iFs3xFgkd/qkS95QQ0h8FMPZ00i7CgZvY WslAekPt1PyAXJgOJ0sJkurSuxM0vfZYrGX0T41sgdAZ+IxjsydVzrlX+OAj/J+2FmQW haPYBCnx73XPVTVmGwlVU44HMjBXf3eKh4WzTeHMPP8iI2Y7X8myMKKsyAFmM9nTzxaU f3TzyhqMvK5sPN4iQ+c3HxIRDCybw8TUhwTnpcT3DHVEWe2Zd7hgE3jVTCUDnUJKmequ hjlTBULDeJD2UBoeaj27AERcFg8kjD4KcQ/QvNLWql3vhTfaBOrZylnap/4wf6HCNtlV XIvg== 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=CBloLAAmjQeGY4f5aZKUe5vmFLq4/I62b+wFiJ2Aw8M=; b=PZbGF/o4krZbh0YSq2yxY4DawsEubueMpYL2woi9q5jMtxmGIXDgYYaMq/X5y9/4j+ IBGtS9UASInCH6/OC1Br/2apoJBH2676aaYIvGjGjBNETjU6wmtkfj9GzYI5bvspKfOs 8hgWEjv7JFRzVaMzIZDIsJBC/VZKarQePki2fIlxPG269H+eBKy82atn7ZuIsXHzD46I MpXFInqHR5nN88/vCRPb0IosnfpWiFNypxMh7RfVU5/Bnb+Yd1c7TLtj9aa+xowXyPiP QnJtKP1U7bctQE7zB4qHecsO41VzkCl7i+DEu+CxOvWirJ4EsBAHbHTsk3SQ4WxkbuvR kEWg== X-Gm-Message-State: AOAM530JdF3gAQhTnLLrn5BBnvR/tSUCF3FD4JJ1j+7ZKH249pHZsEzq Jnqj7cuD6ErmsIpOqM3RDxZ8ADOxgVwVTesIaU2/kWbwBHs7wUED X-Google-Smtp-Source: ABdhPJwfO81kLhVKsp5NB26SOxskwnwPaKvwMjqzfUsbPqmPxfsy7EBZulg++Bn4m3gx0SngiwbeLgw4SpAxn/qVYeU= X-Received: by 2002:a37:a116:: with SMTP id k22mr1092094qke.205.1622753253610; Thu, 03 Jun 2021 13:47:33 -0700 (PDT) MIME-Version: 1.0 References: <6D61A2FD-DC80-43A5-81C2-FB19F9CB5078@dafert.at> In-Reply-To: <6D61A2FD-DC80-43A5-81C2-FB19F9CB5078@dafert.at> Date: Thu, 3 Jun 2021 21:47:23 +0100 Message-ID: To: Mel Dafert Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000003d58f405c3e2afd5" Subject: Re: [PHP-DEV] Policy for procedural style in new additions From: tekiela246@gmail.com (Kamil Tekiela) --0000000000003d58f405c3e2afd5 Content-Type: text/plain; charset="UTF-8" Hi Mel, I love this idea. We should definitely make it official that procedural style API is unfavourable and should not be added to new classes. On top of that, I would be in favor of deprecating all existing procedural APIs. - It's making it more difficult to maintain code in two variants - It's making it difficult to maintain documentation - It's confusing for users - Procedural API is usually much more verbose than OO style - The return values often do not match OO style allows method chaining vs function nesting with procedural. The only time when I ever saw any advantage to procedural style is when using date_create(). Depending on what one is used to, procedural style can be cleaner and more understandable. echo date_diff(date_create('2000-01-01'), date_create('2000-01-05'))->format('%R%a days'); vs echo (new DateTime('2000-01-01'))->diff(new DateTime('2000-01-05'))->format('%R%a days'); However, above examples are not apples to apples. When using date_create with variable input, you must employ manual error checking as it won't throw any errors like OO does. When you factor this in, the first example becomes a nightmare and a gun to shoot yourself in the foot. It happened to me. So, maybe what we could do is slowly deprecate all procedural APIs, but leave some exceptions as handy shortcut functions. If that's not possible, then I wouldn't mind seeing all procedural APIs go away. Regards, Kamil --0000000000003d58f405c3e2afd5--