Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111378 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 31996 invoked from network); 8 Aug 2020 17:11:06 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 Aug 2020 17:11:06 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 10B3E1804CD for ; Sat, 8 Aug 2020 09:09:48 -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=-2.1 required=5.0 tests=BAYES_00,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-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (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 ; Sat, 8 Aug 2020 09:09:47 -0700 (PDT) Received: by mail-lf1-f52.google.com with SMTP id k13so2564649lfo.0 for ; Sat, 08 Aug 2020 09:09:47 -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=A3Xy/voWBos+iNEAJsHznVJlFqoPaSUiZUovj/YJIGs=; b=Mevug6gz5glCp+XdXN2rpE6UFDcvUDTXQxMw/5cbo12GUfRzNbv6LkG7HfTC7lO/ok 9M9KRrW5sgrLDkgkDsmMVHSdAKtHo5dWod3Sj8d9wLQ7osaflpNi4ke6wPGaU5SsmQFK DB2YFG8e/WkSDCaO81h4RGgNr0B9FKkl6WCk5XXsYz6APvJcr/EcwXFjOZbiy/rtuv0o BXNJGL8KN2eg3oCnJrHyuwPHPuceKbvo1HwMpPQN2Wib1q4hklgh5RSu2absHUD9Ox1E nD45iM7Mn1wZYvX39xtXolVCxB2oMP+eolBNu9k2082Wvsp4WBFGg2A4V0KDc3E5w8X1 oupw== 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=A3Xy/voWBos+iNEAJsHznVJlFqoPaSUiZUovj/YJIGs=; b=AVfrj2r1n3qAjDK8f7fzVeA9moGqYcWhiAqWlUHVIWnHNyy+bXtw3VdAHrtNXKIGkT bLVCqLtYdb1ksI+bUyNUMzzYhxpo/Aijdttem7hIVeEOSFs5Yf3LYQirhM8UK9o7YDLE h5o46OYATqWAwXiVt8XgaLIZNZXTMN83MgPu4F1BH0YN4sL7lMf8Vrwi53bt+o8P93ul ih11+AS7bdoOICwOIHxKIO6lOq61WMGN/FxHLBh+a+JzD62Lc0T3HgzQVeBv4s3WU0RE FKZY9pfwJPmWbl65zVaE5k/ED5zibBYDgljRhxmqr2Qm+Ic4BvSUnlHPd0JlcvAPk6VM 4dsQ== X-Gm-Message-State: AOAM532OlMlp3Iz4v+r5zgE6EuXx0VvJ2zo4sHypRKhfb6qmDalqkPRR 2FE+lsI7JD2vCXXxAoVwwkzZjXCqcfgXdy58Og== X-Google-Smtp-Source: ABdhPJyuD/d6vg5nBiOHoUI2DQarsIn9SO/b7tCygGaqT0nb9DCEw0xC70qRkFXnAn2ViQaWdPkneH5iv6aM4KFW4sI= X-Received: by 2002:a19:4c57:: with SMTP id z84mr9275922lfa.92.1596902985270; Sat, 08 Aug 2020 09:09:45 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 8 Aug 2020 18:09:33 +0200 Message-ID: To: tyson andre Cc: PHP Developers Mailing List Content-Type: multipart/alternative; boundary="0000000000002d890d05ac5ff3df" Subject: Re: [PHP-DEV] Putting the match expression in constant expressions in PHP 8.0 or 8.1 From: guilliam.xavier@gmail.com (Guilliam Xavier) --0000000000002d890d05ac5ff3df Content-Type: text/plain; charset="UTF-8" On Sat, Aug 8, 2020 at 2:22 AM tyson andre wrote: > Hi internals, > > The match expression can be thought of as a much more concise/readable > equivalent to chained ternary operators. > I'm proposing allowing matches in constant expressions when all parts of > the match are constant expressions. > > For example, these two class constants would have equivalent behaviors if > match expressions were allowed in constant expressions. > > ``` > class MyClass { > const CONFIG_SETTING = (APP_ENVIRONMENT == 'dev' || APP_ENVIRONMENT == > 'stage') ? 'development-config' : > (APP_ENVIRONMENT == 'prod' ? 'production-config' : null); > > const CONFIG_SETTING = match(APP_ENVIRONMENT) { > 'dev', 'stage' => 'development-config', > 'prod' => 'production-config', > default => null, > }; > } > ``` > > https://github.com/php/php-src/pull/5951 implements the main part of the > change. > Hi, thanks, just noticed that your examples should use `===` not `==`. Regards -- Guilliam Xavier --0000000000002d890d05ac5ff3df--