-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.php
More file actions
39 lines (33 loc) · 1.13 KB
/
test.php
File metadata and controls
39 lines (33 loc) · 1.13 KB
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
<?php
declare(strict_types=1);
use MyPHPExt\Counter;
use MyPHPExt\Human;
echo '---------- PHP ----------', PHP_EOL;
echo 'PHP: ', PHP_VERSION, PHP_EOL;
echo '---------- Functions ----------', PHP_EOL;
hello_world();
echo whoami('Alice', 25), PHP_EOL;
echo whoami('Bob', '30'), PHP_EOL;
echo whoami('Charlie'), PHP_EOL;
try {
whoami('Charlie', []);
exit(1); // unreachable
} catch (\Throwable $e) {
echo '[Error Test]: ', 'class: ', $e::class, ', error: ', $e->getMessage(), PHP_EOL, $e->getTraceAsString(), PHP_EOL;
}
echo 'Create object human: ', human("Dave"), PHP_EOL;
echo 'Create object human: ', human("Eve", 28), PHP_EOL;
echo '---------- Methods (' . Counter::class . ') ----------', PHP_EOL;
$obj = new Counter(10);
$obj->add(10);
$obj->dec(5);
echo 'counter: ', $obj->value(), PHP_EOL;
echo '---------- Methods (' . Human::class . ') ----------', PHP_EOL;
$obj = new Human("Rick", 18);
echo 'getAge: ', $obj->getAge(), PHP_EOL;
echo (string)$obj, PHP_EOL;
$obj->setName('🧛♂️');
echo 'setAge: 1024 (out of range)', PHP_EOL;
$obj->setAge(1024);
echo 'getAge: ', $obj->getAge(), PHP_EOL;
echo (string)$obj, PHP_EOL;