Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102838 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71563 invoked from network); 16 Jul 2018 10:59:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jul 2018 10:59:29 -0000 Authentication-Results: pb1.pair.com header.from=mitke013@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=mitke013@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.42 as permitted sender) X-PHP-List-Original-Sender: mitke013@gmail.com X-Host-Fingerprint: 209.85.218.42 mail-oi0-f42.google.com Received: from [209.85.218.42] ([209.85.218.42:42828] helo=mail-oi0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D6/77-39793-19A7C4B5 for ; Mon, 16 Jul 2018 06:59:29 -0400 Received: by mail-oi0-f42.google.com with SMTP id n84-v6so73906375oib.9 for ; Mon, 16 Jul 2018 03:59:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:from:date:message-id:subject:to:cc; bh=s5sgHSkOmoPjhtu0LTcejOMNmOhA6RqCxppUhMHzo8M=; b=LExnztLMKuW7bRJc/H7oVnY9Ac8yDBZR55DDwCf08o6amxSxHZVnpupU0Q1fzTY4bV JvN0WmvE12IKN2rKakYdaNaufr3PHGoZoy+jkeDketjklz/AOASRNdoKinvuVZg9H9c8 XR8qR5IB+pzJIyCo2gzNmkY4ZqlcARSMEKaIKLwbxdkoxltaA8/HlM4GoDh0LvyEK9P5 7AJgy/+z8ARPlVYsZNUSs5sr9qZkRIOTKQRV92ZIK6t/7zx818C1VieIh9yXCpdFRErG CcaYW3wueZaAcTC2gY4ll6Rp3e5vLn8xhJgiUu1c691FdjPVUUvPGu+bptrsjbkQOvZg /lEQ== 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:from:date:message-id :subject:to:cc; bh=s5sgHSkOmoPjhtu0LTcejOMNmOhA6RqCxppUhMHzo8M=; b=W3f3FpKNvIJgw420J0c/ahToZf/2/xHaCzTBBAD07QyjltrgPIpMZLIE3rptrYhZ+L yjtKsrI1yDe+Wc7sYjqDsrKTucOqLVgTi8FIwMd/JgxTVgypkb2R4vT5cnGPRTw3l8Lb Wn6wNW/9ycqXxU4yJuUXYlii1L+7Gn//+ZZkZVKyRrN9B6HhCsr8puP3g/2wTYs7pmkJ J/7EBVlsG+leUbQ2c01RzlDCOlQTIphjQ8C0MG5L6aocG6tabEPq17NGt2zJmNE+l0+s AIAO+UVQQFZmLnMt3rH4QjpALSQAFW/XSOdFDh2LoLq3aRfEGs5Xjoz6uvh0493gwvU3 zGIQ== X-Gm-Message-State: AOUpUlFoFf3nREjUOPvVXBZLve2yIir9Zyi8NJXNEtXdoRtxNLzqYom5 GRt0BG9VfPU6VeIxXbh2/SUtw1T3NpNUDaPVwOU= X-Google-Smtp-Source: AAOMgpc6Y4YlM47V+HRsUoHsMP7S3XIfnwmAoAexiMAKGhrBF2j9nTtusX6GVvgwZtqXXP8CRzpwROdw0JOEkA7pDBQ= X-Received: by 2002:aca:4fcf:: with SMTP id d198-v6mr15799192oib.51.1531738766983; Mon, 16 Jul 2018 03:59:26 -0700 (PDT) MIME-Version: 1.0 References: Date: Mon, 16 Jul 2018 12:59:15 +0200 Message-ID: To: arvids.godjuks@gmail.com Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="00000000000018489305711bb97f" Subject: Re: [PHP-DEV] [RFC] Optional typehint check for parameters From: mitke013@gmail.com (Zeljko Mitic) --00000000000018489305711bb97f Content-Type: text/plain; charset="UTF-8" On Mon, Jul 16, 2018 at 12:56 PM Zeljko Mitic wrote: > I tried to, but I honestly can't see the problem. No decent programmer > makes error by sending wrong type of parameter and this feature is 100% > optional. I know for sure that even in my dev computer, I would use this > feature, and probably most programmers aware of the issue. > > Maybe simpler example: if I send a string to above function, the only > difference is that PHP would start executing inner code. But an inner line > like $user->getEmail() would still throw fatal error, still very easy to > spot. > > But again, I really don't see that happening and I am not an expert. And I > still never make errors like that, not even when I was learning php. And if > dev computer keeps checking type (default), it is very easy to spot a big > mistake like that. > > Given this is open discussion, I would like to see where I was wrong. > > Btw, you were not harsh at all. > > > On Mon, Jul 16, 2018 at 8:01 AM Arvids Godjuks > wrote: > >> On Sun, Jul 15, 2018, 22:45 Zeljko Mitic wrote: >> >>> PHP is dynamic language and each typed typehinted parameter has to be >>> checked every time. I am suggesting new php.ini value "typecheck.enable = >>> 1" which can be turned off. >>> >>> Example: >>> with default php config, a code like this would check each member of >>> $users >>> array: >>> >>> function demo(User ...$users) {} >>> >>> but with "typecheck.enable = 0", same code would be treated like it was >>> written this way: >>> >>> function demo(...$users) {} >>> >>> Basically, php would simply *ignore* typehints and work like they are not >>> there. >>> >>> It would be programmers responsibility to send correct values but people >>> using typehints are not those still learning the basics. >>> >>> Just like it is programmers responsibility to restart php-fpm when using >>> opcache.validate=0, it would be theirs responsibility to send correct >>> values. Any decent IDE would mark errors for wrong parameter type and >>> with >>> tools like phpstan, it is almost impossible to make one. Only development >>> computers would need to have this checks turned on. >>> >>> This creates no BC problems as it is a new feature. Given that typechecks >>> can be turned off, all existing programs would benefit from extra speed. >>> >>> I am sending this mail by following rules from >>> https://wiki.php.net/rfc/howto . I don't have any knowledge of php >>> internals so unfortunatelly, I can't help with this. I at least hope >>> someone will take this RFC into consideration. >>> >> >> Hello, >> >> php.ini settings that modify language behaviour on such large scale are >> not up for introduction or even discussion. >> PHP has been getting rid of those past 10 years, so forgive me for >> harshness, but as a user land developer I say "no chance In hell". >> >> Arvids, >> > I am sorry for last message; I know I should have put my response at bottom, but I missclicked in gmail. I wrote the message, remembered the rules and instead of revealing quoted text, I clicked on "send". --00000000000018489305711bb97f--