Skip to content

Commit 38b7155

Browse files
authored
Ensure string literals in define statements are properly prefixed (#221)
1 parent 5ff91b8 commit 38b7155

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

specs/string-literal/define.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of the humbug/php-scoper package.
7+
*
8+
* Copyright (c) 2017 Théo FIDRY <[email protected]>,
9+
* Pádraic Brady <[email protected]>
10+
*
11+
* For the full copyright and license information, please view the LICENSE
12+
* file that was distributed with this source code.
13+
*/
14+
15+
return [
16+
'meta' => [
17+
'title' => 'String literal assigned as a constant declared with `define()`',
18+
// Default values. If not specified will be the one used
19+
'prefix' => 'Humbug',
20+
'whitelist' => [],
21+
'whitelist-global-constants' => true,
22+
],
23+
24+
'FQCN string argument: transform into a FQCN and prefix it' => <<<'PHP'
25+
<?php
26+
27+
define('X', 'Symfony\\Component\\Yaml\\Yaml');
28+
define('X', '\\Symfony\\Component\\Yaml\\Yaml');
29+
define('X', 'Humbug\\Symfony\\Component\\Yaml\\Yaml');
30+
define('X', '\\Humbug\\Symfony\\Component\\Yaml\\Yaml');
31+
32+
----
33+
<?php
34+
35+
namespace Humbug;
36+
37+
\define('X', 'Humbug\\Symfony\\Component\\Yaml\\Yaml');
38+
\define('X', 'Humbug\\Symfony\\Component\\Yaml\\Yaml');
39+
\define('X', 'Humbug\\Symfony\\Component\\Yaml\\Yaml');
40+
\define('X', 'Humbug\\Symfony\\Component\\Yaml\\Yaml');
41+
42+
PHP
43+
,
44+
];

0 commit comments

Comments
 (0)