php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47299 static lambda function now give parse error
Submitted: 2009-02-04 10:17 UTC Modified: 2009-02-04 16:12 UTC
From: nospam at example dot com Assigned:
Status: Not a bug Package: Compile Failure
PHP Version: 5.3.0beta1 OS: Windows XP SP3
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: nospam at example dot com
New email:
PHP Version: OS:

 

 [2009-02-04 10:17 UTC] nospam at example dot com
Description:
------------
The latest 5.3.0beta1 has broken static lambda functions.

Previously this worked on 5.3.0alpha3.

The example below is taken from: http://wiki.php.net/rfc/closures

The rfc page recommends using static to reduce memory overhead.

Reproduce code:
---------------
 class Example {
   public function doSomething () {
	 $x = 4;
	 $closure = static function ($y) use ($x) {
	   return $x + $y;
	 };
	 return $closure (6);
   }
 }

Expected result:
----------------
Parse error: parse error, expecting `T_PAAMAYIM_NEKUDOTAYIM'


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-04 10:18 UTC] nospam at example dot com
Expected result is for it to work.

The parse error is the problem.
 [2009-02-04 15:33 UTC] ninzya at inbox dot lv
This functionality has been temporarily dropped from PHP 5.3. Read http://news.php.net/php.internals/42876 for details.
 [2009-02-04 16:12 UTC] scottmac@php.net
The RFC is what we aim for eventually but its not what is in 5.3.0.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 11:01:36 2025 UTC