rfc:instance_counter
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:instance_counter [2013/04/10 08:14] – Update according to the patch frank | rfc:instance_counter [2013/04/30 08:00] – [Vote] frank | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: instance counter ====== | ====== PHP RFC: instance counter ====== | ||
- | * Version: 0.3 | + | * Version: 0.4 |
* Date: 2013-04-08 | * Date: 2013-04-08 | ||
* Author: Frank Liepert, contact@frank-liepert.de | * Author: Frank Liepert, contact@frank-liepert.de | ||
* Contributor: | * Contributor: | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
Line 12: | Line 12: | ||
Coming to Object-Orientated Programming, | Coming to Object-Orientated Programming, | ||
- | One might say, simply implement a static counter in each class. But what about built-in classes like SPL? A wrapper would be required. Implementing it these ways, it does not only sound, but it actually is cumbersome. The purpose of this RFC is to address this issue. | + | One might say, simply implement a static counter in each class. But what about built-in classes like SPL? A wrapper would be required. Implementing it these ways, it not only sounds, but actually is cumbersome. The purpose of this RFC is to address this issue. |
===== Proposal ===== | ===== Proposal ===== | ||
Line 18: | Line 18: | ||
The proposal is to add a new functionality dealing with the number of instances of either a specific class name/object or set of class names/ | The proposal is to add a new functionality dealing with the number of instances of either a specific class name/object or set of class names/ | ||
- | The function name should fit in with the current names of class/ | + | The function name should fit in with the current names of class/ |
* **If no argument is provided, the number of all objects in the object store as an associative array (' | * **If no argument is provided, the number of all objects in the object store as an associative array (' | ||
Line 92: | Line 92: | ||
* **If an an array is provided, it will be the treated as an inclusive indexed array of class names. An associative array (' | * **If an an array is provided, it will be the treated as an inclusive indexed array of class names. An associative array (' | ||
<code php> | <code php> | ||
- | print_r (get_objects_count(array(' | + | print_r (get_objects_count(array(' |
// Array ( [stdClass] => 0 ) | // Array ( [stdClass] => 0 ) | ||
Line 114: | Line 114: | ||
print_r (get_objects_count(array(' | print_r (get_objects_count(array(' | ||
// Array ( [stdClass] => 0 ) | // Array ( [stdClass] => 0 ) | ||
+ | </ | ||
+ | |||
+ | ===== General questions & answers ===== | ||
+ | |||
+ | ==== Inheritance ==== | ||
+ | |||
+ | On internals list there was the question, if only the " | ||
+ | <code php> | ||
+ | class A {} | ||
+ | class B extends A {} | ||
+ | |||
+ | print get_objects_count(' | ||
+ | // 0 | ||
+ | |||
+ | $b = new B; | ||
+ | |||
+ | var_dump($b instanceof A); | ||
+ | // bool(true) | ||
+ | |||
+ | print get_objects_count(' | ||
+ | // 0 | ||
+ | |||
+ | print get_objects_count(' | ||
+ | // 1 | ||
</ | </ | ||
Line 125: | Line 149: | ||
===== Function name ===== | ===== Function name ===== | ||
- | Further suggestions for the function name in example #1: | + | Since there were no objections against |
< | < | ||
- | // Proposed | + | // Proposed |
get_objects_count() | get_objects_count() | ||
Line 164: | Line 188: | ||
===== Open Issues ===== | ===== Open Issues ===== | ||
- | * Decision on function name. | + | None. |
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
Line 181: | Line 204: | ||
- None. | - None. | ||
+ | |||
+ | ===== Vote ===== | ||
+ | <doodle title=" | ||
+ | * Yes? | ||
+ | * No? | ||
+ | </ | ||
+ | | ||
+ | ==== Voting period ==== | ||
+ | Start: **2013/ | ||
+ | |||
+ | End: **2013/ |
rfc/instance_counter.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1