Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122712 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 185051A009C for ; Thu, 21 Mar 2024 16:47:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1711039664; bh=WW9PNRG1YzUSERstrKlIViNnhlTVeYfX0Q37jP6lm/I=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=X5pKlIMsofq0suiYlEv+1FoPZVxag3NRvd74GEKt40HTebb13gZsPFXliNpZlsNjy exDrE1p7VQ449T9bXoqA3izuMVHj+t/tLGplg7i4PwsGuZd6uTpl+tARgS5HGg1+aA Ki/qF0qSkQigwGk9QOMwrnmJkW/TU7RhsKsAUh78rUpK267efQmTJBDkO2mzHmP5jA nKJn1pgnIFFcTsLQXrMv5tcHOUy/idNmqMFj1brasrQh6DLKZqKbGPq3Ps8CHWQUMw uUoAVy1SExeGv65lpVIJGNrxAzo5c1HaqGTMnKo6mlUgkXxmjtL1ibQvmI4yDGADTV sAL8/uAn41G6A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D7B391805AE for ; Thu, 21 Mar 2024 16:47:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-oo1-f54.google.com (mail-oo1-f54.google.com [209.85.161.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 21 Mar 2024 16:47:43 +0000 (UTC) Received: by mail-oo1-f54.google.com with SMTP id 006d021491bc7-5a4a2d99598so611261eaf.2 for ; Thu, 21 Mar 2024 09:47:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711039641; x=1711644441; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=hkgO6KlLfqZowjLCmWz/N3Re8dq+7Acy4zEOU2e+6Xs=; b=HnkkCkwNT9hJ0B3F6z9B8mxqdBp6tQ776KoipN/ppCByKGY8fhYn1XZl83yGa4+0ED b2yFlZCPwEmRfy0UMmkb6PCFVyXnoo9YtsCyOXMx0r1vNCq0mAY1D1Sk6pS1Tr4RZX61 1ngV2v45cKqPjrXPSOnKXxblSGNtLXRwdcHhPbZbfZ/jYERUNqBw+4BHzz/MRRSsi/AO DIMlBK4WidRT2yfd1quKTLBy+e1jATwuiHQJQDovFb9onLBB1EsLeSGCKqc9JYckuMu/ FO58wWaSbR9B2Mc5j4xhH9aZv4K8xOW0IO810TGgKFHKKyOsMCbq6tAXiY7ONNhhaWDy UyPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711039641; x=1711644441; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hkgO6KlLfqZowjLCmWz/N3Re8dq+7Acy4zEOU2e+6Xs=; b=L4+gNrG/hPjN12y57sZNgA4NuPGvdT2e6jW2NhMpgaMir2F8zIzEXiZYVBdspR0F/9 MHUNfNwAfdZoUndNabjXehMcWMyizcc++SHvubi91vzvXt5cJ76spLDVYQiINn6wifyP eyXXmM3vLw3VOZo8NQGl9hSCvblLsddrbSGQ7K12zQObU/tTX7bJFwu5T+FjrQ5jabzi zkmbwmNLR/TBVBxD5uQSG17tsrJyvU5YTwwQz49Q/aJMyfxDj2YoTVifYpTb8U6U3yYe moK/muicVjKEHdcK56Lo/LsQD3FmOUWU0S/tfeSwpkJbejEqpJ9fyeBLrbOxRviIPPBi hAqA== X-Gm-Message-State: AOJu0YxVloQOH3NdCFnAqMq+78BhGj3ei7apB7x/2eybQV+7gzZ6EwUk kbGMPozjWMy7IVX170wtT23bff5kvGqiw1wYhI7RA+h1wUUECQCUIwGNxBUUdkVjKPu3XrplzU1 T38FJF7HEtw7dC2P1cgcNwLb2/5FhFxuyITe+Rg== X-Google-Smtp-Source: AGHT+IE6C3VnjIJ/To5LoXOFLtB/Xny7P3zbr3K8cv7pW9zRoVHs4EWtutz4asRbtMhU5MnL5fjXsex65/0clFycXAc= X-Received: by 2002:a05:6820:1f06:b0:5a1:1e5e:1fd0 with SMTP id dl6-20020a0568201f0600b005a11e5e1fd0mr75907oob.2.1711039640830; Thu, 21 Mar 2024 09:47:20 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: <452aae1b-8929-4f08-a388-45b374d2a365@app.fastmail.com> In-Reply-To: Date: Thu, 21 Mar 2024 17:47:09 +0100 Message-ID: Subject: Re: [PHP-DEV] [RFC[ Property accessor hooks, take 2 To: Larry Garfield Cc: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: landers.robert@gmail.com (Robert Landers) On Thu, Mar 21, 2024 at 5:15=E2=80=AFPM Larry Garfield wrote: > > On Thu, Mar 21, 2024, at 9:10 AM, Robert Landers wrote: > > Hello, > > > > I'm a bit confused on inheritance. In the following example of a > > proxy, do I need to be aware of a parent's hook and handle it > > specially? > > > > class Loud > > { > > public string $name { > > get { > > return strtoupper($this->name); > > } > > } > > } > > > > class LoudProxy extends Loud > > { > > public string $name { > > get { > > // detected the parent has a hook? // > > $return =3D parent::$name::get(); > > // do something with return // > > return $return; > > } > > } > > } > > > > what happens if the Loud class later removes its hook implementation > > (ex: moves it to the set hook)? Will my proxy now cause an error? > > > > Would simply calling $this->name call the parents hook? > > Per the RFC: > > "If there is no hook on the parent property, its default get/set behavior= will be used. " > > so parent::$name::get() will "read the parent property", which will go th= rough a hook if one is defined, and just read the raw value if not. So the= re is no detection logic needed, and the parent can add/remove a hook witho= ut affecting the child. > > Calling $this->name in LoudProxy's get hook will access backing property = on LoudProxy itself, ignoring the parent entirely. > > --Larry Garfield Awesome! Thanks! I just wasn't sure what "default" meant in this context. Robert Landers Software Engineer Utrecht NL