Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 25164f2

Browse files
Expand ReflectionConstant::getFileName() tests
1 parent 75aeeb9 commit 25164f2

File tree

1 file changed

+31
-13
lines changed

1 file changed

+31
-13
lines changed

‎ext/reflection/tests/ReflectionConstant_getFileName.phpt‎

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,40 @@ ReflectionConstant::getFileName()
55

66
include "included5.inc";
77

8-
$reflectionConstant = new ReflectionConstant('PHP_VERSION');
9-
var_dump($reflectionConstant->getFileName());
8+
function testConstant( string $name ): void {
9+
$ref = new ReflectionConstant( $name );
10+
echo "$name: ";
11+
var_dump( $ref->getFileName() );
12+
}
1013

11-
define('IN_CURRENT_FILE', 42);
12-
$reflectionConstant = new ReflectionConstant('IN_CURRENT_FILE');
13-
var_dump($reflectionConstant->getFileName());
14+
define('IN_CURRENT_FILE_DEFINED', 42);
15+
const IN_CURRENT_FILE_AST = 123;
1416

15-
$reflectionConstant = new ReflectionConstant('INCLUDED_CONSTANT_DEFINED');
16-
var_dump($reflectionConstant->getFileName());
17+
echo "From PHP:\n";
18+
testConstant( 'PHP_VERSION' );
19+
testConstant( 'STDIN' );
20+
testConstant( 'STDOUT' );
21+
testConstant( 'STDERR' );
1722

18-
$reflectionConstant = new ReflectionConstant('INCLUDED_CONSTANT_AST');
19-
var_dump($reflectionConstant->getFileName());
23+
echo "\nFrom the current file:\n";
24+
testConstant( 'IN_CURRENT_FILE_DEFINED' );
25+
testConstant( 'IN_CURRENT_FILE_AST' );
2026

27+
echo "\nFrom an included file:\n";
28+
testConstant( 'INCLUDED_CONSTANT_DEFINED' );
29+
testConstant( 'INCLUDED_CONSTANT_AST' );
2130
?>
2231
--EXPECTF--
23-
bool(false)
24-
string(%d) "%sReflectionConstant_getFileName.php"
25-
string(%d) "%sincluded5.inc"
26-
string(%d) "%sincluded5.inc"
32+
From PHP:
33+
PHP_VERSION: bool(false)
34+
STDIN: bool(false)
35+
STDOUT: bool(false)
36+
STDERR: bool(false)
37+
38+
From the current file:
39+
IN_CURRENT_FILE_DEFINED: string(%d) "%sReflectionConstant_getFileName.php"
40+
IN_CURRENT_FILE_AST: string(%d) "%sReflectionConstant_getFileName.php"
41+
42+
From an included file:
43+
INCLUDED_CONSTANT_DEFINED: string(%d) "%sincluded5.inc"
44+
INCLUDED_CONSTANT_AST: string(%d) "%sincluded5.inc"

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /