Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113956 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 78340 invoked from network); 5 Apr 2021 17:16:16 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Apr 2021 17:16:16 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 12B4A180002 for ; Mon, 5 Apr 2021 10:15:04 -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,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ot1-f49.google.com (mail-ot1-f49.google.com [209.85.210.49]) (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 ; Mon, 5 Apr 2021 10:15:02 -0700 (PDT) Received: by mail-ot1-f49.google.com with SMTP id h6-20020a0568300346b02901b71a850ab4so11992434ote.6 for ; Mon, 05 Apr 2021 10:15:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rushlow.dev; s=google; h=mime-version:from:date:message-id:subject:to; bh=A41DDWbJA6nKryQamgErI+xFILsoYinK8VrFzVhFUQQ=; b=ShDlSPT2RCNsAOYoVZLeV7sGsF7WiLRVkPitsBSPyBQVd9MNh47F/Lpn91/sR40gX3 u2ON+8mi/qgoLpWdQZ9xOrqavpTFQ5oxWr/3Xz9xzagKOeuhyUkxt8pb4/HRZ+agDgSs TVS8C1xPmXeaHxwFWxFsdPvUw7YQkiu6nQDGVPzi0jlWGE9wYGHIje+9+3EZC4n6FFPE OvCtVkQstVDcMefjG/LJwQpByL/3ZMjcrSHSdG4/6JEttODB4qv4BdvsLVoWLjRPPDWK RMzoKPOxt8HexStCTg54p5a80iIQCHxJFVrAgb0YMWyKqOgEah/M2FwOOvVBhm8OftPr Cv/Q== 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=A41DDWbJA6nKryQamgErI+xFILsoYinK8VrFzVhFUQQ=; b=hGSGLFoSgtFsYm+sjETdR2YouIErZLbb8htcTghENJoQwsvm7IQrDU2dQcB6zfQpiP b426/DinFhFVu3LevESYSMrDbvGESPQoxM6BFEgOBA1oGLULA5EQGqfuUDh0vD/tQNML Ytvfx/R28BdkVV8tid94/DG3X42ZlWc8cwG4upC7WB8TS2yymG5Vqe+Vq59/1jl0nFaC zU9OFVkfOX9rH0QmWHxzwWBP32gzKARxPjaVjta0feJd4JgVWh2m69FlaVTBHQu27t9n b53Lm7ZEjzc+0KXCc4Njnpnso3AoXUxbDP9C10/Hj6F9yKqy9vJI1kiKfCpfjvFV/gvM AW/Q== X-Gm-Message-State: AOAM533LNVg3xU/RfkcOiCT3txvkVX7IUoosFSOy8TgX/DpYOCXMRuDY w3iXjiRdR/VhN4eHIjRi5cmGxm3WDyFzMx3cHEcokaEvLRFAGlNu X-Google-Smtp-Source: ABdhPJzTQj4yuwNmher7vxSWM63SlRGzyw9rsORUcnn8XFFZ8SgvAaB4US2SrEzR1AfBCVKoZSfkk/b8+OFG4ihFDfg= X-Received: by 2002:a9d:17e7:: with SMTP id j94mr23383322otj.41.1617642901101; Mon, 05 Apr 2021 10:15:01 -0700 (PDT) MIME-Version: 1.0 Date: Mon, 5 Apr 2021 13:14:50 -0400 Message-ID: To: PHP Internals List Content-Type: multipart/alternative; boundary="0000000000007e745c05bf3cd691" Subject: Path forward for class_exists with different targeted PHP version implementations From: jr@rushlow.dev (Jesse Rushlow) --0000000000007e745c05bf3cd691 Content-Type: text/plain; charset="UTF-8" Howdy Internals, I discovered today (purely on accident) that class_exists($subject) actually parses the "$subect" class in question. I was attempting to use class_exists(UsesPropertyPromotion::class) to determine if an attribute implementation existed in order to generate a PHP 8 appropriate class - else fall back to generating a PHP 7 appropriate class. For context, this check was being written for Symfony's MakerBundle which generates classes for Symfony projects. Consequently the conditional worked as expected in PHP 8, but in 7 I received a Parse Error. See the bug report https://bugs.php.net/bug.php?id=80938 for additional details. Nikic pointed out the problem (not a bug) is that w/ autoload === true, class_exists will load the class. The purpose of this email is to spark the conversation on a path forward for code bases that must support multiple versions of PHP and still be able to use native PHP functions without having to jump through hoops. It would appear from a userland standpoint that class_exist() is broken / unreliable if it must first be determined if the class being checked is compatible for the PHP version used at runtime. Which brings us to the chicken and the egg... At the very least this could be a "mental note" for RFC's that introduce changes that create BC in unexpected ways in userland. Cheers! Jesse Rushlow --0000000000007e745c05bf3cd691--