rfc:structured_object_notation
Differences
This shows you the differences between two versions of the page.
Next revisionBoth sides next revision | |||
rfc:structured_object_notation [2016/07/31 08:36] – created midorikocak | rfc:structured_object_notation [2016/07/31 08:50] – midorikocak | ||
---|---|---|---|
Line 86: | Line 86: | ||
Let's have one class called B, similar to above example. | Let's have one class called B, similar to above example. | ||
+ | <code php> | ||
+ | <?php | ||
- | Instead of instantiating objects on the fly, here I propose a structured definition of an object using this syntax: | + | Class B{ |
+ | // No way to define order of methods | ||
+ | public function __construct($world = " | ||
+ | echo "Hello ". $world." | ||
+ | echo "You can foo and you can bar\n"; | ||
+ | } | ||
+ | public function foo($x, $y){ | ||
+ | echo "\nYou did foo: x is " | ||
+ | echo "Now you can bar\n"; | ||
+ | } | ||
- | ===== Backward Incompatible Changes ===== | + | public function bar($z, $t){ |
- | What breaks, and what is the justification for it? | + | echo "\nYou did bar: z is " |
+ | echo "You can bar again or end the program\n"; | ||
+ | } | ||
- | ===== Proposed PHP Version(s) ===== | + | public function __destruct(){ |
- | List the proposed PHP versions that the feature will be included in. Use relative versions such as "next PHP 7.x" | + | |
+ | } | ||
+ | } | ||
- | ===== RFC Impact ===== | + | // Here comes the spaghetti |
- | ==== To SAPIs ==== | + | $app = new B(" |
- | Describe the impact to CLI, Development web server, embedded PHP etc. | + | $app-> |
+ | $app-> | ||
+ | </ | ||
- | ==== To Existing Extensions ==== | ||
- | Will existing extensions be affected? | ||
- | ==== To Opcache ==== | + | Instead of instantiating objects on the fly, here I propose |
- | It is necessary to develop RFC's with opcache in mind, since opcache is a core extension distributed with PHP. | + | <code php> |
- | Please explain how you have verified your RFC's compatibility with opcache. | + | Object $app instanceof B{ |
+ | $world = " | ||
+ | // allowed methods comes after method definition | ||
+ | // in the beginning state allowed methods are foo and bar | ||
+ | public function __construct($world){ | ||
+ | // if method body is implemented, | ||
+ | // parent class method run automatically | ||
+ | // object method runs after. | ||
+ | // This block runs $app = new B($world); | ||
+ | $this-> | ||
+ | }(foo, bar); | ||
- | ==== New Constants ==== | + | // The only allowed method is bar in this state |
- | Describe any new constants so they can be accurately and comprehensively explained | + | public function foo(1, |
- | ==== php.ini Defaults ==== | + | // if allowed methods |
- | If there are any php.ini settings then list: | + | // object is destructed |
- | * hardcoded default values | + | |
- | * php.ini-development values | + | }; |
- | * php.ini-production values | + | } |
- | ===== Open Issues ===== | + | < |
- | Make sure there are no open issues when the vote starts! | + | |
- | ===== Unaffected PHP Functionality ===== | + | An object can be instance |
- | List existing areas/ | + | |
- | This helps avoid any ambiguity, shows that you have thought deeply about the RFC's impact, | + | ===== Backward Incompatible Changes ===== |
+ | Is a new feature. Mostly a syntactic sugar thanks to anonymous classes. All of the suggested syntax can be written using PHP 7.1 | ||
+ | |||
+ | ===== Proposed PHP Version(s) ===== | ||
+ | PHP 7.2 | ||
+ | |||
+ | ===== RFC Impact ===== | ||
+ | ==== To SAPIs ==== | ||
+ | Better objects with states | ||
===== Future Scope ===== | ===== Future Scope ===== | ||
- | This sections details areas where the feature might be improved in future, but that are not currently proposed in this RFC. | + | Allowed methods can have typed parameters. |
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== | ||
- | Include these so readers know where you are heading and can discuss the proposed voting options. | + | As this is a language change, |
- | + | ||
- | State whether | + | |
- | + | ||
- | ===== Patches and Tests ===== | + | |
- | Links to any external patches and tests go here. | + | |
- | + | ||
- | If there is no patch, make it clear who will create a patch, or whether a volunteer to help with implementation is needed. | + | |
- | + | ||
- | Make it clear if the patch is intended to be the final patch, or is just a prototype. | + | |
===== Implementation ===== | ===== Implementation ===== | ||
- | After the project is implemented, | + | No implementation still. |
- | - the version(s) it was merged to | + | |
- | - a link to the git commit(s) | + | |
- | - a link to the PHP manual entry for the feature | + | |
===== References ===== | ===== References ===== | ||
Line 153: | Line 172: | ||
===== Rejected Features ===== | ===== Rejected Features ===== | ||
- | Keep this updated with features that were discussed on the mail lists. | + | NA. |
rfc/structured_object_notation.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1