Skip to content

Anonymous Classes #1118

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 24 commits into from
Closed

Anonymous Classes #1118

wants to merge 24 commits into from

Conversation

philsturgeon
Copy link

RFC: https://wiki.php.net/rfc/anonymous_classes

This is a work in progress right now and the RFC is being worked on, as are the tests.

Please keep feature discussions to the mailing list.

@HallofFamer
Copy link

This is excellent, I've been trying to integrate the old Anonymous class RFC into a custom build PHP, but this will make things a lot easier since it's designed for PHP 7. I wonder though, is it possible to make this into a .diff patch so I can play with its functionality on a linux server?

@philsturgeon
Copy link
Author

Why not just grab the branch and build it? It’s slightly older than master, but changes are going to be pulled in shortly. Either way it runs just fine.

-- 
Phil

From: HallofFamer [email protected]
Reply: php/php-src [email protected]>
Date: February 24, 2015 at 12:57:16 PM
To: php/php-src [email protected]>
Cc: Phil Sturgeon [email protected]>
Subject:  Re: [php-src] [WIP] Anonymous Classes (#1118)

This is excellent, I've been trying to integrate the old Anonymous class RFC into a custom build PHP, but this will make things a lot easier since it's designed for PHP 7. I wonder though, is it possible to make this into a .diff patch so I can play with its functionality on a linux server?


Reply to this email directly or view it on GitHub.

@suralc
Copy link

suralc commented Feb 24, 2015

@HallofFamer If you really need to download the diff in text form (instead of checking out the branch using git). you can add .patch (or .diff) to this pages url:
https://github.com/php/php-src/pull/1118.diff

@HallofFamer
Copy link

@suralc: Oh thats excellent, thanks. I really love Anonymous and Nested class features, they make PHP's OO more complete. Good luck to this RFC!

@Majkl578
Copy link
Contributor

Majkl578 commented Mar 7, 2015

In the RFC, you mention Class$$1 format, but here you use Class@1, which one is correct?

@Majkl578
Copy link
Contributor

Majkl578 commented Mar 9, 2015

Looks like get_class() is broken anyway, it returns (probably) pointer address: http://3v4l.org/BQhJM/rfc#rfc-anonymous_classes (but maybe 3v4l is using just outdated commit)

How would be nested anonymous clases named? Imagine:

$foo = new class {
    function bar() {
        return new class {};
    }
};
var_dump(get_class($foo->bar()));

@philsturgeon
Copy link
Author

@Majkl578 nothing broken about it. Check the RFC for more on naming things. Ignore Class$$ its Class@

@philsturgeon
Copy link
Author

Oh, yep, the names were off. The code just does class@foo instead of trying to give it a fancy human readable name.

That doesn't matter much, as relying on the class name or type hinting against it would be useless and wildly irresponsible. The RFC is now up to date with code output.

@philsturgeon philsturgeon changed the title [WIP] Anonymous Classes Anonymous Classes Mar 11, 2015
@@ -1868,7 +1877,7 @@ ZEND_FUNCTION(get_defined_functions)
array_init(&user);
array_init(return_value);

zend_hash_apply_with_arguments(EG(function_table), copy_function_name, 2, &internal, &user);
zend_hash_apply_with_arguments(EG(function_table), copy_function_name, 3, &internal, &user, &disabled);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes in this file seem unrelated.

@nikic
Copy link
Member

nikic commented Apr 27, 2015

Superseded by #1249.

@nikic nikic closed this Apr 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants