Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107886 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 99431 invoked from network); 28 Nov 2019 19:23:28 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 28 Nov 2019 19:23:28 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id 1A36D2C0532 for ; Thu, 28 Nov 2019 09:18:41 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Thu, 28 Nov 2019 09:18:40 -0800 (PST) Received: by mail-oi1-x22e.google.com with SMTP id x21so16772628oic.0 for ; Thu, 28 Nov 2019 09:18:40 -0800 (PST) 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=D4UPDI8+BvEMYOgPk6spmN2m2rnboGgGRL+E0A55gOI=; b=BbSC+dmzCzORG3Kgc8VAXUla0Ryye0O7wkdnW3auGn5uuPgHJHm9dEpb7tty420UiG jSFGVeaiduCrFudC8GzkJ8R67PDP8q34BmFOBvXW6xF8fXG7lIrBGYuor6m8Df/s1Jb9 d3DQLruManxBYCruquOAwofMbFzmMS0SwrH8S6s0idUz5fLe0iDuTaSBVrlkvc7sV9qh 8XnvJOqh5PZSrLJ9OhXMudPGf8AM+DgT29xL4OZuBb9hDgoRuhNbE1QPQQnFw4TUp+8m MTN3ZXUsUWcLmO5/FyYGfu8d2k9u1uPIv9WXeq7Tv5/LcYZD9fPqpwW7EJDsmd1NUcsh qw1A== 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=D4UPDI8+BvEMYOgPk6spmN2m2rnboGgGRL+E0A55gOI=; b=FyzI1gRyArswntO0ra8k2W/XxNtJr2dUJhUgLVD/XHL2YDmm9hff9NtZilo/23hcx8 tp09evV1o9h/o1DPcupXsB6nzgYUBGEjOQQL96d51mGTdVzjSTD+B1GoIFdrFbfxAac3 M3gd5ZlXVL/2I7PT+scwLsmBTTWWKmsVuMzL3BckaUWXJpgSsVCGH/TfBFJmLjSago33 3ItqKCgTsKibma6fE8VYgTSx7YX6VYC8WDkmRqOhw4UP1zE3lIsKrzXZllqcAVfpo+Ub qXLaejMr6KDRdZFLfbcEiDOabfHJdIvVQiVSnOsMCV6aXb56lMAEN/4zodGt0Eh3iD8D KT0w== X-Gm-Message-State: APjAAAXpDH0XZQLTcwIPnuZh4KwnxDXBAJg1VwVoV9zmZ5If+cbFCMdO wUI17HNSXReRbE1nkKSF1gIsTF3UPOsnDK9SDbgGQWxv X-Google-Smtp-Source: APXvYqyTyzDwEsHogP5QbtOhSG43TzPmbkf8DtuzI192muD7jYJuAxuhoYro0FGsS7Eft33qmGVyjX+Zj3z0eE7dWcc= X-Received: by 2002:a05:6808:906:: with SMTP id w6mr8952857oih.162.1574961519876; Thu, 28 Nov 2019 09:18:39 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 28 Nov 2019 14:18:27 -0300 Message-ID: To: Dan Ackroyd Cc: PHP Internals , Claude Pache Content-Type: multipart/alternative; boundary="000000000000ed606705986b4d03" X-Envelope-From: Subject: Re: [PHP-DEV] register_shutdown_function() not supports private methods From: david.proweb@gmail.com (David Rodrigues) --000000000000ed606705986b4d03 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Em qui., 28 de nov. de 2019 =C3=A0s 14:13, Dan Ackroyd escreveu: > On Wed, 27 Nov 2019 at 23:33, David Rodrigues > wrote: > > > > Hi internals, > > > > I am using the register_shutdown_function() inside a class, and then I > have > > created a private method to be called during shutdown. I have noted tha= t > if > > the method is public it works, but private does not. > > > > This shutdown function should be private, > > to avoid execution at a public scope. > > That is one of the reasons Closure::fromCallable was added: > https://www.php.net/manual/en/closure.fromcallable.php > > So like: register_shutdown_function(Closure::fromCallable([$this, 'leave' > ])); > Or in your example: https://3v4l.org/MSLA4 Thanks! It will solve the problem. > > > > spl_autoload_register([ self::class, 'privateMethod' ]); // OK > > That is not OK. It might not give an error, but it's a bug if a > private method can be called accidentally, without jumping through the > deliberate hoops to work around private methods. > In that case, it should be deprecated? > > Claude Pache wrote: > > Another workaround is to use a closure: > > Although that works, using Closure::fromCallable() has the benefits of > preserving the parameters and their info. > > function foo(int $x) { > } > > $fn =3D Closure::fromCallable('foo'); > $reflection =3D new ReflectionFunction($fn); > > foreach ($reflection->getParameters() as $param) { > echo "Param type is: " . $param->getType(); > } > // Output is "Param type is: int" > > cheers > Dan > Ack > --=20 David Rodrigues --000000000000ed606705986b4d03--