note 129635 added to functions.first_class_callable_syntax

From: Date: Thu, 04 Jul 2024 04:41:49 +0000
Subject: note 129635 added to functions.first_class_callable_syntax
Groups: php.notes 
Request: Send a blank email to php-notes+get-221407@lists.php.net to get a copy of this message
As of PHP 8.2, the first class callable syntax of a class method cannot be serialized like the old array callables. For example, <?php class Bird { public function fly() { } } $bird = new Bird(); $callable1 = [$bird, 'fly']; $callable2 = $bird->fly(...); // This is fine serialize($callable1); // This will cause a fatal error // "PHP Fatal error: Uncaught Exception: Serialization of 'Closure' is not allowed" serialize($callable2); ?> So if your callable is used across session and need to be serialized, you should not use the first class callable syntax (until this is somehow fixed in the future). ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.137 (proxied: 203.186.57.202) ---- Manual Page -- https://php.net/manual/en/functions.first_class_callable_syntax.php Edit -- https://main.php.net/note/edit/129635 Del: integrated -- https://main.php.net/note/delete/129635/integrated Del: useless -- https://main.php.net/note/delete/129635/useless Del: bad code -- https://main.php.net/note/delete/129635/bad+code Del: spam -- https://main.php.net/note/delete/129635/spam Del: non-english -- https://main.php.net/note/delete/129635/non-english Del: in docs -- https://main.php.net/note/delete/129635/in+docs Del: other reasons-- https://main.php.net/note/delete/129635 Reject -- https://main.php.net/note/reject/129635 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221407) next »