Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105205 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 76479 invoked from network); 10 Apr 2019 16:00:24 -0000 Received: from unknown (HELO mail-it1-f171.google.com) (209.85.166.171) by pb1.pair.com with SMTP; 10 Apr 2019 16:00:24 -0000 Received: by mail-it1-f171.google.com with SMTP id y134so3158457itc.5 for ; Wed, 10 Apr 2019 05:57:32 -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=7cO5gP6sm4qJ/0x6Tv3W5zlfOpCKjJDvqSxzFKdBkTE=; b=A0gtUtGeTFHTZGd5c/hNCV1fYBpjwzFZeUUAYlYo6w0g2GTwOJj1Sobu8HjiYVoy1x bpCfrG8FyXtVtz12Akdz+74kTjVLziKR+W5VHs6RDK0+RDOuoHzgGY25ruY+Gi/xiZA1 4ua3f4Zdqs02oAl/AH23O/CETcoWhJwdNkhsUUHkiCVufz2+ZzeZ0CRSdYqhjDjY/inS cW4pnXlRUVckbFCrKcuUMXZZrpT56UbjLnu/lO0MiL8d1/htZXvUX1DIr0qsw+KUBy4r 7EjYMTimM0z3jYSI8sNv0OGMCpILBwUGKpSr25VzINMYtYQXmb0b/3d03EwKn4HKeQ4g G98A== 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=7cO5gP6sm4qJ/0x6Tv3W5zlfOpCKjJDvqSxzFKdBkTE=; b=l30foC04Q6mT91ZqaNcBi0G83qClk4sA1HsAyL/U7U139wPODCRVCqPCh08r4h4WzH jy6WWP5cSjQKL0m7S7qINdzQ/I6p3eVMJnkql7y/pKk1PrZgj/NcXrIx4ZdrtxhcJm8i vqJJG2wRHZsKtPVHvseY1VsJ1R8HyoWlimH/3kQ84Cm9/n/0HA29TRwGIXevcm1PbbMc B1mjCioxOPQxW149HlQBatZBM2W2aogcstKXQYEGhniY3ADmCMAylzqHwyL8w5yw1uhu cZ7Lj0dIzOOQzRU/S4XnprpCJRbKSRiFp/J67U1DgKEh5AeuVrM2vfOR1JmtZ+cXIqUD kczg== X-Gm-Message-State: APjAAAUc1i27/JaOjhj83xn6bo5dLoIe+4zFRaq5Tfy5pul5z62fhmEW yPdGnxFgRP7G0hcZFI7w3o2wiOXIifi1bqVgae8= X-Google-Smtp-Source: APXvYqznpWu3V5HyoDseVoNUJXLAOcgh9WUfUZUw73ApNzmMcPbdUSwmSqzR0vcaCO+T+ZIeK2jNxjhJJV2bzSSplYI= X-Received: by 2002:a24:9197:: with SMTP id i145mr2965420ite.117.1554901052086; Wed, 10 Apr 2019 05:57:32 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 10 Apr 2019 14:57:14 +0200 Message-ID: To: Benjamin Morel Cc: PHP Internals Content-Type: multipart/alternative; boundary="000000000000dee18405862c9c86" Subject: Re: [PHP-DEV] Unset static properties From: nikita.ppv@gmail.com (Nikita Popov) --000000000000dee18405862c9c86 Content-Type: text/plain; charset="UTF-8" On Wed, Apr 10, 2019 at 2:20 PM Benjamin Morel wrote: > Hi internals, > > I came across this when playing with static properties: > > class A { > public static int $x; > } > > // This throws, as expected: > // Error: Typed static property A::$x must not be accessed before > initialization > echo A::$x; > > // Once we initialize the property: > A::$x = 1; > echo A::$x; // 1 > > // There is no way to revert the property back to uninitialized state: > // Error: Attempt to unset static property A::$x > unset(A::$x); > > Is this expected behaviour? I don't currently have a use case for this, but > am wondering whether it is consistent to disallow un-initializing a static > property when it's allowed to be uninitialized in the first place. > We could add support for this, but as the general consensus is that we'd much rather remove support for unsetting declared object properties (if we could cover the lazy loading use case in a different way), I don't think it makes sense to allow this. Nikita --000000000000dee18405862c9c86--