summaryrefslogtreecommitdiff
path: root/Examples
diff options
context:
space:
mode:
authorvalmat <ufabiz@gmail.com>2014-03-09 20:17:20 +0600
committervalmat <ufabiz@gmail.com>2014-03-09 20:17:20 +0600
commit5a186cc932524d85ce602e152a79d5201a4eb3b5 (patch)
tree36088c2bd542e239672cb2a6bb01494c16caf650 /Examples
parentd76e1c204a1adcaa2a605ed3041a0f1711c716dc (diff)
issue #23: Fixed loop for an objects contains no public properties
Diffstat (limited to 'Examples')
-rw-r--r--Examples/CppClassesInPhp/check_map.php69
1 files changed, 46 insertions, 23 deletions
diff --git a/Examples/CppClassesInPhp/check_map.php b/Examples/CppClassesInPhp/check_map.php
index cdd5345..2103bac 100644
--- a/Examples/CppClassesInPhp/check_map.php
+++ b/Examples/CppClassesInPhp/check_map.php
@@ -5,21 +5,51 @@
*
*/
-class cl1 {
- public $qwe = 45615;
- public $asd = "asdasdasd";
- public $zxcv = "Привет!"; // check UTF-8 chars
+class cl0 {
+ public $cl0_float = 3.14;
+ public $cl0_str1 = 'public str1';
+ private $cl0_str2 = 'private str2';
+ protected $cl0_str3 = 'protected str3';
+}
+
+class cl1 extends cl0 implements arrayaccess
+{
+ static $cl1_static = 'static prop';
+
+ const CL1_CONST = 'const prop';
+
+ public $cl1_num = 45615;
+ public $cl1_str = "Public Prop";
+
+ private $cl1_pp1 = "Private Prop1";
+ private $cl1_pp2 = "Private Prop2";
+
+ protected $cl1_prp1 = "Protected Prop1";
+ protected $cl1_prp2 = "Protected Prop2";
+
public function fn($a) {
echo $a;
}
- function __destruct(){
- echo 'cl1::__destruct';
- }
function __toString() {
return 'I\'m class cl1';
}
+ public function offsetSet($offset, $value) {
+ if (!is_null($offset)) {
+ $this->$offset = $value;
+ }
+ }
+ public function offsetExists($offset) {
+ return isset($this->$offset);
+ }
+ public function offsetUnset($offset) {
+ unset($this->$offset);
+ }
+ public function offsetGet($offset) {
+ return isset($this->$offset) ? $this->$offset : null;
+ }
+
}
class emptyClass {}
@@ -34,10 +64,15 @@ $arr = array(
new cl1(),
'%'=>'%$%$%',
);
-//$arr = array(5,17,'qwe' => 'qweqweqweqw',4=>88,'17'=>'170','1'=>4, new cl1());
-//$arr = array(3.14,2.7,11,0,500);
+
+$arr = new cl1();
+
+$arr[5] = 55;
+$arr['strstr'] = 'strstrstrstrstrstr';
+
+//$arr = new emptyClass();
//$arr = array();
-//$arr = new cl1();
+
$q = new MyClass();
@@ -47,17 +82,5 @@ var_export($arr);
// Works for objects and arrays
$q->loopObject($arr);
-
-$q->loopObject(new emptyClass());
-
-
-/*
-// Validation removal (i.e. do I need to use zval_add_ref(value);)
-echo "\nunset(\$arr):";
-unset($arr);
-echo "\nunset(\$q):";
-unset($q);
-*/
-
-
+//$q->loopObject($arr);