Skip to content

Add expression support with "new" keyword. #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

mageekguy
Copy link

It's already possible to create class instance with :

  1. a string:
  2. a variable:
  3. a variable variable:

This commit add the possibility to use an expression :

It's already possible to create class instance with :
1) a string:
   <?php
   class Foo {}
   $foo = new Foo;
   ?>
2) a variable:
   <?php
   class Foo {}
   $class = 'Foo';
   $foo = new $class;
   ?>
3) a variable variable:
   <?php
   class Foo {}
   $class = 'Foo';
   $name = 'class';
   $foo = new $$name;
   ?>
This commit add the possibility to use an expression :
   <?php
   class Foo {}
   $oo = 'oo';
   $foo = new {'f' . $oo};
   ?>
@winks
Copy link
Contributor

winks commented Apr 20, 2012

Finding such occurrences is usually a good indication to punch the author of the code, but of course that doesn't necessarily mean the language shouldn't support it.
So if it doesn't break stuff, yeah ;)

@php-pulls
Copy link

Comment on behalf of lstrojny at php.net:

We discussed this issue briefly on IRC and we feel it is a language change that requires an RFC. Have a look at https://wiki.php.net/rfc/voting how the RFC process works. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants