Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102831 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30506 invoked from network); 15 Jul 2018 19:45:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jul 2018 19:45:22 -0000 Received: from [127.0.0.1] ([127.0.0.1:13026]) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ECSTREAM id CA/53-39793-154AB4B5 for ; Sun, 15 Jul 2018 15:45:21 -0400 Authentication-Results: pb1.pair.com smtp.mail=mitke013@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=mitke013@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.53 as permitted sender) X-PHP-List-Original-Sender: mitke013@gmail.com X-Host-Fingerprint: 209.85.218.53 mail-oi0-f53.google.com Received: from [209.85.218.53] ([209.85.218.53:43350] helo=mail-oi0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 88/53-39793-813AB4B5 for ; Sun, 15 Jul 2018 15:40:08 -0400 Received: by mail-oi0-f53.google.com with SMTP id b15-v6so70978342oib.10 for ; Sun, 15 Jul 2018 12:40:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=ZcAtglRRmSaDq/7M4B0DqHbOvwLk6hCM4CiGfRgRB0w=; b=q2/t0524FZpSkxLQILwK0evyfTN5DI2w4VPnb7cShta2cgEAXRMDZbXe0CjJee/fkH VPdVt30mOT6r0rZze6svrIiSt+KnkerwTmbPJXGhic6K8JMjthh5yA6Mdt6sUYmICbDn 0QSTK4ld8EEAFCiOQN9DHEz1Un1BNoXinW0qR6JiYGy4VdyLYkbtgWhj0/Ndz15F9Gfw 1gF7R14633CmsXefQQ/6AMv0s/QKMFpenRImjEEl70/whfkKP6MqDJazPRWa77rIv2sZ EioQBtRgUyAIqI6CuhXK/fvkN8cZZvuSMDLI6vmgG/KBC9UPuEwtvq1rsg6i+fBkSzCd F3AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=ZcAtglRRmSaDq/7M4B0DqHbOvwLk6hCM4CiGfRgRB0w=; b=FKF2uwm+ZVl2dnhSVANjb+gaDv+uTqDQ1TtTvttcym+34bK25m8HSQjwUPgFoJqs9e 6kje0Qw65vOXtRXh6R97n3K0DMKCCJZybqxprhmkA9pSHT3FxoGwhNBTTl2BIEP3Tr+c 342k/kwSvr+lKDlKVfXDDFjroX4k+C/O9xVkACiGmYifBHQRczcvWqFgpkkgGflFJMSx p7VrxbaKPXD44YE5hMVMuiTj2kPYo+foBigxYWAoGlrEptCCXP+zaogka2W9LflsTbkH 1IvpdWss/sL2Zo+no+OjouaDd7UP/NN4AJCuuc5jJfwChZXVKtUIUt2LNJsg5FTbtcXO BejQ== X-Gm-Message-State: AOUpUlGhjXjsbTDGaorfqR4vZ2w8rmqmvlc5+0TpOQRPxMMrMPkIQptd LgWv+yoh9PuJaoLM/2cp4xe7vqoz3p24OWyyVvkB2w== X-Google-Smtp-Source: AAOMgpf/2USpEtg5f3x7rEOSb3Qklq4OyknxPTF8utBwx+C0fRNs8atek5gnKpDzAV7IMOMhVpin+oXIt94YGBWN5+w= X-Received: by 2002:aca:69d0:: with SMTP id e199-v6mr14350747oic.286.1531683605781; Sun, 15 Jul 2018 12:40:05 -0700 (PDT) MIME-Version: 1.0 Date: Sun, 15 Jul 2018 21:39:54 +0200 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000003b217905710ee18c" Subject: [RFC] Optional typehint check for parameters From: mitke013@gmail.com (Zeljko Mitic) --0000000000003b217905710ee18c Content-Type: text/plain; charset="UTF-8" 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. --0000000000003b217905710ee18c--