Skip to content

Commit 74c2623

Browse files
authored
Add the specifications (#92)
1 parent d2fb4d4 commit 74c2623

File tree

84 files changed

+9194
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+9194
-6
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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' => 'Class constant call of a class imported with an aliased use statement in the global scope',
18+
// Default values. If not specified will be the one used
19+
'prefix' => 'Humbug',
20+
'whitelist' => [],
21+
],
22+
23+
[
24+
'spec' => <<<'SPEC'
25+
Constant call on a aliased class which is imported via an aliased use statement and which belongs to the global namespace:
26+
- do not prefix the use statement (cf. class belonging to the global scope tests)
27+
- transform the call into a FQ call
28+
SPEC
29+
,
30+
'payload' => <<<'PHP'
31+
<?php
32+
33+
use Foo as X;
34+
35+
X::MAIN_CONST;
36+
----
37+
<?php
38+
39+
use Foo as X;
40+
41+
\Foo::MAIN_CONST;
42+
43+
PHP
44+
],
45+
46+
[
47+
'spec' => <<<'SPEC'
48+
FQ constant call on a aliased class which is imported via an aliased use statement and which belongs to the global namespace:
49+
- do not prefix the class (cf. class belonging to the global scope tests)
50+
- resolve the alias
51+
SPEC
52+
,
53+
'payload' => <<<'PHP'
54+
<?php
55+
56+
use Foo as X;
57+
58+
\X::MAIN_CONST;
59+
----
60+
<?php
61+
62+
use Foo as X;
63+
64+
\Foo::MAIN_CONST;
65+
66+
PHP
67+
],
68+
69+
[
70+
'spec' => <<<'SPEC'
71+
Constant call on a whitelisted class which is imported via an aliased use statement and which belongs to the global namespace:
72+
- prefix the use statement (cf. class belonging to the global scope tests and `scope.inc.php` for the built-in global whitelisted classes)
73+
- transform the call into a FQ call
74+
SPEC
75+
,
76+
'payload' => <<<'PHP'
77+
<?php
78+
79+
use AppKernel as X;
80+
81+
X::MAIN_CONST;
82+
----
83+
<?php
84+
85+
use Humbug\AppKernel as X;
86+
87+
\Humbug\AppKernel::MAIN_CONST;
88+
89+
PHP
90+
],
91+
92+
[
93+
'spec' => <<<'SPEC'
94+
FQ constant call on a whitelisted class which is imported via an aliased use statement and which belongs to the global namespace:
95+
- prefix the use statement (cf. class belonging to the global scope tests and `scope.inc.php` for the built-in global whitelisted classes)
96+
- transform the call into a FQ call
97+
SPEC
98+
,
99+
'payload' => <<<'PHP'
100+
<?php
101+
102+
use AppKernel as X;
103+
104+
\X::MAIN_CONST;
105+
----
106+
<?php
107+
108+
use Humbug\AppKernel as X;
109+
110+
\Humbug\AppKernel::MAIN_CONST;
111+
112+
PHP
113+
],
114+
];
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
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' => 'Class constant call of a class imported with a use statement in the global scope',
18+
// Default values. If not specified will be the one used
19+
'prefix' => 'Humbug',
20+
'whitelist' => [],
21+
],
22+
23+
[
24+
'spec' => <<<'SPEC'
25+
Constant call on a class which is imported via a use statement and which belongs to the global namespace:
26+
- do not prefix the use statement (cf. class belonging to the global scope tests)
27+
- transforms the call into a FQ call
28+
SPEC
29+
,
30+
'payload' => <<<'PHP'
31+
<?php
32+
33+
use Command;
34+
35+
Command::MAIN_CONST;
36+
----
37+
<?php
38+
39+
use Command;
40+
41+
\Command::MAIN_CONST;
42+
43+
PHP
44+
],
45+
46+
[
47+
'spec' => <<<'SPEC'
48+
FQ constant call on a class which is imported via a use statement and which belongs to the global namespace:
49+
- do not prefix the use statement (cf. class belonging to the global scope tests)
50+
- do nothing
51+
SPEC
52+
,
53+
'payload' => <<<'PHP'
54+
<?php
55+
56+
use Command;
57+
58+
\Command::MAIN_CONST;
59+
----
60+
<?php
61+
62+
use Command;
63+
64+
\Command::MAIN_CONST;
65+
66+
PHP
67+
],
68+
69+
[
70+
'spec' => <<<'SPEC'
71+
Constant call on a whitelisted class which is imported via a use statement and which belongs to the global namespace:
72+
- transform the call in a FQ call (cf. class belonging to the global scope tests and `scope.inc.php` for the built-in global whitelisted classes)
73+
SPEC
74+
,
75+
'payload' => <<<'PHP'
76+
<?php
77+
78+
use AppKernel;
79+
80+
AppKernel::MAIN_CONST;
81+
----
82+
<?php
83+
84+
use Humbug\AppKernel;
85+
86+
\AppKernel::MAIN_CONST;
87+
88+
PHP
89+
],
90+
91+
[
92+
'spec' => <<<'SPEC'
93+
FQ constant call on a whitelisted class which is imported via a use statement and which belongs to the global namespace:
94+
- prefix the class (cf. class belonging to the global scope tests and `scope.inc.php` for the built-in global whitelisted classes)
95+
SPEC
96+
,
97+
'payload' => <<<'PHP'
98+
<?php
99+
100+
use AppKernel;
101+
102+
\AppKernel::MAIN_CONST;
103+
----
104+
<?php
105+
106+
use Humbug\AppKernel;
107+
108+
\AppKernel::MAIN_CONST;
109+
110+
PHP
111+
],
112+
];
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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' => 'Class constant call in the global scope',
18+
// Default values. If not specified will be the one used
19+
'prefix' => 'Humbug',
20+
'whitelist' => [],
21+
],
22+
23+
[
24+
'spec' => <<<'SPEC'
25+
Constant call on a class belonging to the global namespace:
26+
- do not prefix the class (cf. class belonging to the global scope tests)
27+
- transforms the call into a FQ call to avoid autoloading issues
28+
SPEC
29+
,
30+
'payload' => <<<'PHP'
31+
<?php
32+
33+
Command::MAIN_CONST;
34+
----
35+
<?php
36+
37+
\Command::MAIN_CONST;
38+
39+
PHP
40+
],
41+
42+
[
43+
'spec' => <<<'SPEC'
44+
FQ constant call on a class belonging to the global namespace:
45+
- do not prefix the class (cf. class belonging to the global scope tests)
46+
- do not touch the call
47+
SPEC
48+
,
49+
'payload' => <<<'PHP'
50+
<?php
51+
52+
\Command::MAIN_CONST;
53+
----
54+
<?php
55+
56+
\Command::MAIN_CONST;
57+
58+
PHP
59+
],
60+
61+
[
62+
'spec' => <<<'SPEC'
63+
Constant call on a whitelisted class belonging to the global namespace:
64+
- prefix the class (cf. class belonging to the global scope tests and `scope.inc.php` for the built-in global whitelisted classes)
65+
- transforms the call into a FQ call to avoid autoloading issues
66+
SPEC
67+
,
68+
'payload' => <<<'PHP'
69+
<?php
70+
71+
AppKernel::MAIN_CONST;
72+
----
73+
<?php
74+
75+
\Humbug\AppKernel::MAIN_CONST;
76+
77+
PHP
78+
],
79+
80+
[
81+
'spec' => <<<'SPEC'
82+
FQ constant call on a whitelisted class belonging to the global namespace:
83+
- prefix the class (cf. class belonging to the global scope tests and `scope.inc.php` for the built-in global whitelisted classes)
84+
- transforms the call into a FQ call to avoid autoloading issues
85+
SPEC
86+
,
87+
'payload' => <<<'PHP'
88+
<?php
89+
90+
\AppKernel::MAIN_CONST;
91+
----
92+
<?php
93+
94+
\Humbug\AppKernel::MAIN_CONST;
95+
96+
PHP
97+
],
98+
];

0 commit comments

Comments
 (0)