PageRenderTime 132ms CodeModel.GetById 110ms app.highlight 6ms RepoModel.GetById 15ms app.codeStats 0ms

/hphp/test/spec/tests/expressions/primary_expressions/intrinsics_empty.php

http://github.com/facebook/hiphop-php
PHP | 154 lines | 101 code | 47 blank | 6 comment | 0 complexity | 2f2147a38aaf4c2dec113ffabdf63abc MD5 | raw file
  1<?php
  2
  3/*
  4   +-------------------------------------------------------------+
  5   | Copyright (c) 2015 Facebook, Inc. (http://www.facebook.com) |
  6   +-------------------------------------------------------------+
  7*/
  8
  9error_reporting(-1);
 10
 11include_once 'Point.inc';
 12
 13echo "--------- TRUE -------------\n";
 14
 15var_dump(empty(TRUE));
 16$v = TRUE;
 17var_dump(empty($v));
 18
 19echo "--------- FALSE -------------\n";
 20
 21var_dump(empty(FALSE));
 22$v = FALSE;
 23var_dump(empty($v));
 24
 25echo "--------- -10 -------------\n";
 26
 27var_dump(empty(-10));
 28$v = -10;
 29var_dump(empty($v));
 30
 31echo "---------- 0 ------------\n";
 32
 33var_dump(empty(0));
 34$v = 0;
 35var_dump(empty($v));
 36
 37echo "---------- 123 ------------\n";
 38
 39var_dump(empty(123));
 40$v = 123;
 41var_dump(empty($v));
 42
 43echo "--------- -10.56 -------------\n";
 44
 45var_dump(empty(-10.56));
 46$v = -10.56;
 47var_dump(empty($v));
 48
 49echo "--------- 0.0 -------------\n";
 50
 51var_dump(empty(0.0));
 52$v = 0.0;
 53var_dump(empty($v));
 54
 55echo "-------- 123.456 --------------\n";
 56
 57var_dump(empty(123.456));
 58$v = 123.456;
 59var_dump(empty($v));
 60
 61echo "--------- NULL -------------\n";
 62
 63var_dump(empty(NULL));
 64$v = NULL;
 65var_dump(empty($v));
 66
 67echo "---------- \"\" ------------\n";
 68
 69var_dump(empty(""));
 70$v = "";
 71var_dump(empty($v));
 72
 73echo "---------- \"0\" ------------\n";
 74
 75var_dump(empty("0"));
 76$v = "0";
 77var_dump(empty($v));
 78
 79echo "---------- \"00\" ------------\n";
 80
 81var_dump(empty("00"));
 82$v = "00";
 83var_dump(empty($v));
 84
 85echo "--------- \"Hello\" -------------\n";
 86
 87var_dump(empty("Hello"));
 88$v = "Hello";
 89var_dump(empty($v));
 90
 91echo "--------- [] -------------\n";
 92
 93var_dump(empty([]));
 94$v = [];
 95var_dump(empty($v));
 96
 97echo "---------- [10, 20] ------------\n";
 98
 99var_dump(empty([10, 20]));
100$v = [10, 20];
101var_dump(empty($v));
102
103echo "--------- Point(3, 5) -------------\n";
104
105$v = new Point(3, 5);
106var_dump(empty($v));
107
108echo "--------- instance of class having no properties -------------\n";
109
110class XX {}
111$v = new XX;
112var_dump(empty($v));
113
114echo "--------- undefined parameter -------------\n";
115
116function f($p)
117{
118    var_dump($p);
119    var_dump(empty($p));
120}
121
122f();
123f(NULL);
124f(10);
125
126echo "---------- resource STDIN ------------\n";
127
128var_dump(empty(STDIN));
129$v = STDIN;
130var_dump(empty($v));
131
132echo "---------- dynamic property ------------\n";
133
134class X1
135{
136}
137
138class X2
139{
140    public function __isset($name)
141    {
142        echo "Inside " . __METHOD__ . " with \$name $name\n";
143//      return FALSE;
144        return TRUE;
145    }
146}
147
148$x1 = new X1;
149var_dump(empty($x1->m));
150$x1->m = 123;
151var_dump(empty($x1->m));
152
153$x2 = new X2;
154var_dump(empty($x2->m));