Req #63020 [NEW]: Dynamic functions & methods unification

From: Date: Wed, 05 Sep 2012 20:21:07 +0000
Subject: Req #63020 [NEW]: Dynamic functions & methods unification
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-8813@lists.php.net to get a copy of this message
From:             p dot szymkowski at gmail dot com
Operating system: Any
PHP version:      5.4.6
Package:          Documentation problem
Bug Type:         Feature/Change Request
Bug description:Dynamic functions & methods unification

Description:
------------
This is more than a feature than a bug.

Usage of '{}' is not unified at all.

Why this syntax:
$this->{'function'}; 
works, but:
{'function'}();
doesn't?

It's really confusing. In "test script" form i am giving you full example
of it.

Test script:
---------------
<?php

function myFunction(){};

// {'myFunction'}(); // doesn't work
$str = 'myFunction';
$str(); // works

class myClass {
  public $bar = 'myClass';
  public $test = 'myClass';
  public function foo() {
  }
}

// $class = new {'myClass'}(); // doesn't work
$str = "myClass";
$class = new $str(); // works

$class->{'foo'}(); // works

// $class2 = new {$class->test}; // doesn't work
$class2 = new $class->test(); // works

Expected result:
----------------
syntax {'myFunction'}(); should work
syntax $class = new {'myClass'}(); should work
syntax $class2 = new {$class->test}; should work

Actual result:
--------------
only calling methods and getting properties of class works in that way.

-- 
Edit bug report at https://bugs.php.net/bug.php?id=63020&edit=1
-- 
Try a snapshot (PHP 5.4):            https://bugs.php.net/fix.php?id=63020&r=trysnapshot54
Try a snapshot (PHP 5.3):            https://bugs.php.net/fix.php?id=63020&r=trysnapshot53
Try a snapshot (trunk):              https://bugs.php.net/fix.php?id=63020&r=trysnapshottrunk
Fixed in SVN:                        https://bugs.php.net/fix.php?id=63020&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=63020&r=needdocs
Fixed in release:                    https://bugs.php.net/fix.php?id=63020&r=alreadyfixed
Need backtrace:                      https://bugs.php.net/fix.php?id=63020&r=needtrace
Need Reproduce Script:               https://bugs.php.net/fix.php?id=63020&r=needscript
Try newer version:                   https://bugs.php.net/fix.php?id=63020&r=oldversion
Not developer issue:                 https://bugs.php.net/fix.php?id=63020&r=support
Expected behavior:                   https://bugs.php.net/fix.php?id=63020&r=notwrong
Not enough info:                     https://bugs.php.net/fix.php?id=63020&r=notenoughinfo
Submitted twice:                     https://bugs.php.net/fix.php?id=63020&r=submittedtwice
register_globals:                    https://bugs.php.net/fix.php?id=63020&r=globals
PHP 4 support discontinued:          https://bugs.php.net/fix.php?id=63020&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=63020&r=dst
IIS Stability:                       https://bugs.php.net/fix.php?id=63020&r=isapi
Install GNU Sed:                     https://bugs.php.net/fix.php?id=63020&r=gnused
Floating point limitations:          https://bugs.php.net/fix.php?id=63020&r=float
No Zend Extensions:                  https://bugs.php.net/fix.php?id=63020&r=nozend
MySQL Configuration Error:           https://bugs.php.net/fix.php?id=63020&r=mysqlcfg



Thread (1 message)

  • p dot szymkowski at gmail dot com
« previous php.doc.bugs (#8813) next »