Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116318 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 6988 invoked from network); 10 Nov 2021 20:19:34 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 10 Nov 2021 20:19:34 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EA17C1804BC for ; Wed, 10 Nov 2021 13:13:06 -0800 (PST) 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-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-io1-f48.google.com (mail-io1-f48.google.com [209.85.166.48]) (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 ; Wed, 10 Nov 2021 13:13:06 -0800 (PST) Received: by mail-io1-f48.google.com with SMTP id w22so4475812ioa.1 for ; Wed, 10 Nov 2021 13:13:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1CGf4t0t6gM54vRF7Isf+WerxNxZiIVPDsLR5F3qlIE=; b=Z67JimuHYT1vEnhq69/gBYLqghCPqnnBKKNYM1QbvegwSpa8b+PMu5hYWExvrG7aFH nuIPgn05kHZrFEYSrrhR4R07Gu2yasmJObOh8fZ1fA/I8j/UTn6Nvfip/B1sAX0lq6E1 X4JjD5sLyJDz6s9gps+uzaX3mUEFhAQoUs4peUKOHV0AnIZWGbgwV88YpW9/QrG/tjw6 yOEPCLZ9EwnDt9vERuOTnY6x+pWsYFhW+qQ42b4+E60C/SrU3Wm1wdsFSQE+STMf50Zt uHoBomLMBHwyK8cZlyETEJwwEmR14rK9y/WzBRdZhNRExvaV+dNUDn7OPTtP+e0vMNj8 jEKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1CGf4t0t6gM54vRF7Isf+WerxNxZiIVPDsLR5F3qlIE=; b=oEGf+2B0yjgUk/Y6Xt9olvJ/gfNnngNcGuZuasItEj5HiqoshCZ7w9CIQ+UOWBsbuq S4lx7pvWmbJaGApgc8nUBMJTyRb+SbqGYfrHQXF6im6pz3ItH/KL+9l8LoTG6r1D3YLz Luo+dq2d5CE2+PC2jPWm6tS8Gp5Zc4OKMBdUJWSNMNfgtCavoGJOgSzT8lTU7jPykIbX 207ym4Ig9I7JW9kZHhLTHiyU5OlmOWw1Fn21VxFsCcWDpHMo7NedZgZGrfbb2dWEUvVm pOhIP5TUPMJsU9Qby0CzDTiEbfH86YXYgxtQgHXnSOq7WDAwSTF8+lczF5PTSGQFzBj4 /fSQ== X-Gm-Message-State: AOAM532OESLw7NV/eJmACqqZgP1FJ57Wvn8Q7b5Z8RxVS2heILYRT6uQ X71ONKterNJDR60WwTHsbGk79BOsaVF5Nhetp+A= X-Google-Smtp-Source: ABdhPJyrrGAUH08FJt5SJ5o8lx8yQIVDPI3pbkdqOp/a0eFcZr/vBGy26Q8DLE8nC3ZWPPl9qDgPmZBRwXzVPxJB6iY= X-Received: by 2002:a05:6638:2bb:: with SMTP id d27mr1560700jaq.66.1636578785816; Wed, 10 Nov 2021 13:13:05 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 10 Nov 2021 16:12:54 -0500 Message-ID: To: Nikita Popov Cc: PHP Internals Content-Type: multipart/alternative; boundary="0000000000002cf56e05d075b1e3" Subject: Re: [PHP-DEV] Automatic implementation of Stringable may conflict with old, untyped arginfo declarations From: jmikola@gmail.com (Jeremy Mikola) --0000000000002cf56e05d075b1e3 Content-Type: text/plain; charset="UTF-8" On Tue, Nov 9, 2021 at 4:30 AM Nikita Popov wrote: > > In > https://github.com/php/php-src/commit/a551b083073ea08f8fc53b0e1a6380b6de26cc6b > I've added a hack to add the string return type if it is missing and thus > make the signature compatible with the interface. That should address the > immediate compatibility issue. > Thanks for the quick fix. A related question that came up, and is most likely unique to ext-mongodb, follows. Many of our classes with toString() methods also implement a corresponding interface with a toString() method. For example: * https://www.php.net/manual/en/class.mongodb-bson-binary.php * https://www.php.net/manual/en/class.mongodb-bson-binaryinterface.php I'm in the process of adding explicit return type info to _all_ of our toString() arginfos (classes and interfaces), but a thought occurred to me that doing so may be a subtle BC break for userland classes implementing these interfaces, since an explicit string return type would then become necessary. But if I only modify our classes and leave our interfaces as-is, PHP rightfully reports an error because the class' toString() method cannot conform to both Stringable (with type info) and our interface (without type info) -- at least PHP versions before 8.1.0RC6. Reading the patch above, it looks like the automatic Stringable implementation only kicks in when the arginfo has no existing return type info. In that case, I think the only option to completely avoid a BC break would be to continue to leave our return type info omitted (on both our classes _and_ interfaces) and allow PHP 8.1+ to apply it automatically. Is that correct? -- jeremy mikola --0000000000002cf56e05d075b1e3--