summaryrefslogtreecommitdiff
path: root/tests/php/phpt/variables/003-value-types.phpt
blob: 477fbe270fd00fbc876b44897ec8593038933db4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
--TEST--
get_complex_array
--SKIPIF--
<?php if (!extension_loaded("extension_for_tests")) print "skip"; ?>
--FILEEOF--
<?php


# check Callable: http://php.net/manual/en/function.is-callable.php
function  ret5() {return 5;}
class someClass {
  function someMethod() {return 5;}
}
class CallableClass {
    public function __invoke(){}
}

$anObject = new someClass();
$methodVariable = array($anObject, 'someMethod');


# check array
$arr = array(
    'Null'            =>   NULL,
    'Numeric'         =>   2014,
    'Float'           =>   3.14,
    'Bool'            =>   true,
    'Array'           =>   array(5,'a' => 33, 'str'),
    'Object'          =>   new stdClass(),
    'String'          =>   'String',
    'Resource'        =>   7,
    'Constant'        =>   5,
    'ConstantArray'   =>   11,
    'Callable1'        =>  'ret5',
    'Callable2'        =>  $methodVariable,
    'Callable3'        =>  function () {return 5;},
    'Callable4'        =>  new CallableClass()
);

TestVariables\value_types($arr);

//To check uncomment the following lines:
/*
echo "\n\nCallable1:";
var_export(is_callable($arr['Callable1']));
echo PHP_EOL,'Callable2:';
var_export(is_callable($arr['Callable2']));
echo PHP_EOL,'Callable3:';
var_export(is_callable($arr['Callable3']));
echo PHP_EOL,'Callable4:';
var_export(is_callable($arr['Callable4']));
echo PHP_EOL,'No Callable:';
var_export(is_callable(new stdClass));
*/


echo PHP_EOL;
--EXPECT--
Null: Yes
Numeric: Yes
Float: Yes
Bool: Yes
Array: Yes
Object: Yes
String: Yes
Resource: No
Constant: No
ConstantArray: No
Callable1: Yes
Callable2: Yes
Callable3: Yes
Callable4: Yes