1--TEST--
2Test get_declared_traits() function : basic functionality
3--FILE--
4<?php
5/* Prototype  : proto array get_declared_traits()
6 * Description: Returns an array of all declared traits.
7 * Source code: Zend/zend_builtin_functions.c
8 * Alias to functions:
9 */
10
11
12echo "*** Testing get_declared_traits() : basic functionality ***\n";
13
14trait MyTrait {}
15
16// Zero arguments
17echo "\n-- Testing get_declared_traits() function with Zero arguments --\n";
18var_dump(get_declared_traits());
19
20foreach (get_declared_traits() as $trait) {
21	if (!trait_exists($trait)) {
22		echo "Error: $trait is not a valid trait.\n";
23	}
24}
25
26echo "\n-- Ensure trait is listed --\n";
27var_dump(in_array('MyTrait', get_declared_traits()));
28
29echo "\n-- Ensure userspace interfaces are not listed --\n";
30interface I {}
31var_dump(in_array( 'I', get_declared_traits()));
32
33echo "\n-- Ensure userspace classes are not listed --\n";
34class MyClass {}
35var_dump(in_array( 'MyClass', get_declared_traits()));
36
37
38echo "Done";
39?>
40--EXPECTF--
41*** Testing get_declared_traits() : basic functionality ***
42
43-- Testing get_declared_traits() function with Zero arguments --
44array(%d) {
45%a
46}
47
48-- Ensure trait is listed --
49bool(true)
50
51-- Ensure userspace interfaces are not listed --
52bool(false)
53
54-- Ensure userspace classes are not listed --
55bool(false)
56Done