{"id":1916,"date":"2025-05-12T20:33:45","date_gmt":"2025-05-12T11:33:45","guid":{"rendered":"https:\/\/ani2life.com\/wp\/?p=1916"},"modified":"2025-05-12T20:33:45","modified_gmt":"2025-05-12T11:33:45","slug":"php-8-4-property-hooks-%eb%ac%b8%eb%b2%95%ec%9c%bc%eb%a1%9c-%ec%95%bd%ed%95%9c-%ec%b0%b8%ec%a1%b0-%ed%8e%b8%ed%95%98%ea%b2%8c-%ec%93%b0%ea%b8%b0","status":"publish","type":"post","link":"https:\/\/ani2life.com\/wp\/?p=1916","title":{"rendered":"PHP 8.4 Property hooks \ubb38\ubc95\uc73c\ub85c \uc57d\ud55c \ucc38\uc870 \ud3b8\ud558\uac8c \uc4f0\uae30"},"content":{"rendered":"<p>PHP\uc5d0\uc11c\ub294 <a href=\"https:\/\/www.php.net\/manual\/en\/class.weakreference.php\" target=\"_blank\" rel=\"noopener\">WeakReference \ud074\ub798\uc2a4<\/a>\ub97c \uc0ac\uc6a9\ud574\uc11c \uc57d\ud55c \ucc38\uc870\ub97c \uc4f8 \uc218 \uc788\ub2e4.<\/p>\n<p>\uadf8\ub7f0\ub370 \uc57d\ud55c \ucc38\uc870\ub97c \uc4f0\uac8c \ub418\uba74 \uc57d\ud55c \ucc38\uc870\uc5d0 \ud574\ub2f9\ud558\ub294 \uac1d\uccb4\ub97c \uc0ac\uc6a9\ud560 \ub54c \ucf54\ub529\uc774 \ubc88\uac70\ub86d\ub2e4. WeakReference::create()\ub85c \ub9cc\ub4e0 \uac1d\uccb4\uc5d0\uc11c get() \uba54\uc11c\ub4dc\ub97c \ud638\ucd9c\ud574\uc57c \ud574\ub2f9 \uac1d\uccb4\ub97c \uc4f8 \uc218 \uc788\uae30 \ub54c\ubb38\uc774\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\">$obj = new stdClass();\r\n$weakref = WeakReference::create($obj);\r\nvar_dump($weakref-&gt;get());<\/pre>\n<p>\uc774\uc5d0 \uc544\ub798\uc640 \uac19\uc774 Property hooks \ubb38\ubc95\uc744 \ud65c\uc6a9\ud558\uc5ec \uac15\ud55c \ucc38\uc870 \uc4f0\ub4ef\uc774 \uc57d\ud55c \ucc38\uc870\ub97c \ud3b8\ud558\uac8c \uc0ac\uc6a9\ud560 \uc218 \uc788\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\">class Foo\r\n{\r\n    public function hello(): void\r\n    {\r\n        echo 'hello' . PHP_EOL;\r\n    }\r\n}\r\n\r\nclass Bar\r\n{\r\n    \/** @var \\WeakReference&lt;\\Foo&gt; *\/\r\n    private \\WeakReference $_foo;\r\n\r\n    public private(set) ?Foo $foo {\r\n        get =&gt; $this-&gt;_foo-&gt;get();\r\n        set {\r\n            $this-&gt;_foo = \\WeakReference::create($value);\r\n        }\r\n    }\r\n\r\n    public function __construct(\\Foo $foo)\r\n    {\r\n        $this-&gt;foo = $foo;\r\n    }\r\n}\r\n\r\n$foo = new \\Foo();\r\n$bar = new \\Bar($foo);\r\n\r\n$bar-&gt;foo-&gt;hello(); \/\/ hello\r\n\r\nvar_dump($bar-&gt;foo); \/\/ object(Foo)#1 (0) {}\r\nunset($foo);\r\nvar_dump($bar-&gt;foo); \/\/ NULL\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP\uc5d0\uc11c\ub294 WeakReference \ud074\ub798\uc2a4\ub97c \uc0ac\uc6a9\ud574\uc11c \uc57d\ud55c \ucc38\uc870\ub97c \uc4f8 \uc218 \uc788\ub2e4. \uadf8\ub7f0\ub370 \uc57d\ud55c \ucc38\uc870\ub97c \uc4f0\uac8c \ub418\uba74 \uc57d\ud55c \ucc38\uc870\uc5d0 \ud574\ub2f9\ud558\ub294 \uac1d\uccb4\ub97c \uc0ac\uc6a9\ud560 \ub54c \ucf54\ub529\uc774 \ubc88\uac70\ub86d\ub2e4. WeakReference::create()\ub85c \ub9cc\ub4e0 \uac1d\uccb4\uc5d0\uc11c get() \uba54\uc11c\ub4dc\ub97c \ud638\ucd9c\ud574\uc57c \ud574\ub2f9 \uac1d\uccb4\ub97c \uc4f8 \uc218 \uc788\uae30 \ub54c\ubb38\uc774\ub2e4. $obj = new stdClass(); $weakref = WeakReference::create($obj); var_dump($weakref-&gt;get()); \uc774\uc5d0 \uc544\ub798\uc640 \uac19\uc774 Property hooks \ubb38\ubc95\uc744 \ud65c\uc6a9\ud558\uc5ec \uac15\ud55c \ucc38\uc870 \uc4f0\ub4ef\uc774 \uc57d\ud55c \ucc38\uc870\ub97c \ud3b8\ud558\uac8c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[7],"tags":[152],"_links":{"self":[{"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1916"}],"collection":[{"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1916"}],"version-history":[{"count":2,"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1916\/revisions"}],"predecessor-version":[{"id":1918,"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1916\/revisions\/1918"}],"wp:attachment":[{"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1916"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1916"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1916"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}