php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49516 Serializing a closure throws an exception
Submitted: 2009-09-10 06:15 UTC Modified: 2009-09-10 13:26 UTC
From: oorza2k5 at gmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.3.0 OS: irrelevant
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: oorza2k5 at gmail dot com
New email:
PHP Version: OS:

 

 [2009-09-10 06:15 UTC] oorza2k5 at gmail dot com
Description:
------------
As far as I'm aware, exceptions are not supposed to be thrown by default, but rather errors are supposed to be raised.

Serializing a closure throws an exception, when it should be raising an E_ERROR instead.

Reproduce code:
---------------
<?php

$foo = function() { };

serialize($foo);

Expected result:
----------------
E_ERROR is raised and the script dies.

Actual result:
--------------
An exception is thrown.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-10 13:26 UTC] jani@php.net
Closures are special. And since they're so special, they throw exceptions. Not a bug.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Dec 03 22:00:01 2025 UTC