Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106543 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 92173 invoked from network); 11 Aug 2019 15:23:07 -0000 Received: from unknown (HELO mail-lj1-f177.google.com) (209.85.208.177) by pb1.pair.com with SMTP; 11 Aug 2019 15:23:07 -0000 Received: by mail-lj1-f177.google.com with SMTP id r9so96020449ljg.5 for ; Sun, 11 Aug 2019 05:51:01 -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=+B/xkcWlh0BWEL7sLXN1zgYhWShdhLc3w5iMiAFP8OY=; b=lHadNAqfZhyBvTP6IyXQIryPuLg435VgB/MMIjNsjH86F8nr/Iq+KFOPgcWJzKY5Yt GyYx/NA9zN3WnuZrIVXbfo63tvJs3sUnGuGtkEMXs0y+6h2Y3Gj8J44BMR2mm0kaUduj MPusDDlrfdMnaEa4uNl9faeZg3UCjs/PQJQESzAw7gZOZVunbmj2vfmkpJviQTVOdYDP /oZ539Ma92zqF4iaO3qDT6r6RVcbRDGf/Ue14SvZ+5bW6+JrPW4vKsVTZZXXsEUihs0+ JCM4jywsevtDZDkx5xOQrKZbo/xCofmBY4kLRPfJk6nMJ+VPSblOr1KuBWu9QUVa3oh8 oo2Q== 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=+B/xkcWlh0BWEL7sLXN1zgYhWShdhLc3w5iMiAFP8OY=; b=QMyyh99uNYXXrGJRAFHinKmOumwfSvavCAQlAB2dYTi0wVD+Wdd11djuGvCx+JUzoq TFTCXrJtJaG3sCnpC2b7ey7aFXo6/SuL2ye4N4C0QyGk8kdnaYwITX28HZxa8cPMz6IZ T73IP9HVosCdrU43sSNEiULH4hSo+4E1yCDZHYdxHz8AxPCE65BoyXz1JVakwpll0tUH x33yrJkVK+tFklVSnIlDIJUe+8TNhqmCYYPNzxacgCMMulOSHESKpBQnMF7fhVGMKujN C9QliZGb96MkEIw8HJvi4ur1luZQxPp9ayt7pQC2q53/7JJqt01ANEi7EzMxQPydDA3I KEDg== X-Gm-Message-State: APjAAAXEvIvFo6HnjWNGAEiF6ik2xlJXzxUsnTUij4LI7JU413rpTuuK nt+94RxwymSWR5vM1gH3ze58OMcUPpUsSFXg39b4X8T6 X-Google-Smtp-Source: APXvYqyXSQNMI1EiMJjuzsRAZclvUwHABf2iz2KaEUXjLZ1sfyQazzbJz2F7doJdpyWT42514LeK99E/MR9IY41R/Hg= X-Received: by 2002:a2e:7c15:: with SMTP id x21mr16535885ljc.55.1565527860459; Sun, 11 Aug 2019 05:51:00 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sun, 11 Aug 2019 14:50:44 +0200 Message-ID: To: Sara Golemon Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000023a9c058fd6dc2f" Subject: Re: [PHP-DEV] Adding return types to internal methods (PHP 8) From: nikita.ppv@gmail.com (Nikita Popov) --000000000000023a9c058fd6dc2f Content-Type: text/plain; charset="UTF-8" On Sun, Aug 11, 2019 at 2:37 PM Sara Golemon wrote: > On Sun, Aug 11, 2019 at 3:44 AM Nikita Popov wrote: > >> What do you think about this? As we are currently annotating everything >> with types, and we're at a major version, this would be the ideal time to >> make this change. But there's certainly a BC break here. (And, for the >> record, this is not the type of BC break where P++ or editions help, >> without creating a larger mess.) >> >> I think your original proposal was spot on. It added to the language > without creating any BC breaks. The ideal outcome. > This modification adds an admittedly small BC break for an equally small > benefit. > > -1 from me. > > -Sara > > P.S. - Perhaps a way to the middle might be to introduce implicit return > type hints. If a child method is implemented with no return type specified > on a parent method which has one, then the parent's type is assumed at bind > time, then we provide a better runtime error if that assumption is violated > in a strict_types=1 context which is the only place where strict covariance > of return types matters to PHP. > This is an interesting idea. There's still a BC break here, but it's more limited and only applies to code that is actively violating type contracts (that were previously implicit). Imho this should not be bound to strict_types though: strict_types controls coercion behavior of scalar type annotations, and nothing else. It should not be overloaded with this additional meaning (and I don't think the BC break is nowhere near large enough to justify this overloading). Do you have this in mind as something for use by internal classes only, or as a general language feature? I can see the use as a general language feature (see for example the debacle where PHPUnit added "void" annotations to some methods). The migration problem of adding return types is certainly not limited to internal classes. On the other hand it does seem somewhat weird that an (inherited) return type will be enforced that was not explicitly given in the source. Regards, Nikita --000000000000023a9c058fd6dc2f--