rfc:structured_object_notation
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
rfc:structured_object_notation [2016/07/31 08:36] – created midorikocak | rfc:structured_object_notation [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
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> | ||
+ | class B{ | ||
- | Instead | + | // 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"; | ||
+ | } | ||
+ | public function bar($z, $t){ | ||
+ | echo "\nYou did bar: z is " | ||
+ | echo "You can bar again or end the program\n"; | ||
+ | } | ||
- | ===== Backward Incompatible Changes ===== | + | public function __destruct(){ |
- | What breaks, and what is the justification for it? | + | echo " |
+ | } | ||
+ | } | ||
- | ===== Proposed PHP Version(s) ===== | + | // Here comes the spaghetti |
- | List the proposed PHP versions that the feature will be included in. Use relative versions such as "next PHP 7.x" or "next PHP 7.x.y" | + | $app = new B(" |
+ | $app-> | ||
+ | $app-> | ||
+ | </ | ||
- | ===== RFC Impact ===== | ||
- | ==== To SAPIs ==== | ||
- | Describe the impact to CLI, Development web server, embedded PHP etc. | ||
- | ==== To Existing Extensions ==== | + | Instead of instantiating objects on the fly, here I propose a structured definition of an object using this syntax: |
- | Will existing extensions be affected? | + | <code php> |
+ | 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-> | ||
+ | | ||
- | ==== To Opcache ==== | + | // The only allowed method |
- | It is necessary to develop RFC's with opcache | + | public function foo(1,2)(bar); |
- | Please explain how you have verified your RFC's compatibility with opcache. | + | // if allowed methods are empty or not defined |
+ | // object is destructed | ||
+ | public function bar(3,4){ | ||
+ | }; | ||
+ | } | ||
+ | </ | ||
- | ==== New Constants ==== | + | An object |
- | Describe any new constants so they can be accurately and comprehensively explained in the PHP documentation. | + | |
- | ==== php.ini Defaults | + | ===== Backward Incompatible Changes ===== |
- | If there are any php.ini settings then list: | + | Is a new feature. Mostly a syntactic sugar thanks to anonymous classes. All of the suggested syntax can be written using PHP 7.1 |
- | * hardcoded default values | + | |
- | * php.ini-development values | + | |
- | * php.ini-production values | + | |
- | ===== Open Issues | + | ===== Proposed PHP Version(s) |
- | Make sure there are no open issues when the vote starts! | + | PHP 7.2 |
- | ===== Unaffected PHP Functionality | + | ===== RFC Impact |
- | List existing areas/ | + | ==== To SAPIs ==== |
- | + | Better objects with states | |
- | This helps avoid any ambiguity, shows that you have thought deeply about the RFC's impact, | + | |
===== 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. Ide's can use the object notation for autocompletion. Also an object can tell allowed methods using magic method like __help() when $app-> |
===== 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 168: | ||
===== Rejected Features ===== | ===== Rejected Features ===== | ||
- | Keep this updated with features that were discussed on the mail lists. | + | NA. |
rfc/structured_object_notation.1469954161.txt.gz · Last modified: 2017/09/22 13:28 (external edit)