Skip to content

Commit b089da2

Browse files
authored
Remove whitelist keyword usage in the specs (#552)
1 parent 8b46042 commit b089da2

File tree

157 files changed

+16181
-16532
lines changed

Some content is hidden

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

157 files changed

+16181
-16532
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,9 @@ the bundled code of your PHAR and the consumer code. For example if you have
324324
a PHPUnit PHAR with isolated code, you still want the PHAR to be able to
325325
understand the `PHPUnit\Framework\TestCase` class.
326326

327+
Notes for the rework of the docs which are coming as I'm reviewing the tests:
328+
- excluded namespaces take precedence over exposing a symbol. For example, exposing the class `Acme\Foo` and excluding the namespace `Acme` will result in the class `Acme\Foo` to NOT be exposed, but excluded instead.
329+
327330

328331
### Constants & Classes & functions from the global namespace
329332

specs/binary/simple.php

Lines changed: 52 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414

1515
return [
1616
'meta' => [
17-
'title' => 'Simple binary file',
17+
'title' => 'Excerpts of code used for executable PHP files (e.g. for PHPUnit)',
1818
// Default values. If not specified will be the one used
1919
'prefix' => 'Humbug',
20-
'whitelist' => [],
2120

22-
'expose-global-constants' => true,
21+
'expose-global-constants' => false,
2322
'expose-global-classes' => false,
24-
'expose-global-functions' => true,
23+
'expose-global-functions' => false,
2524
'expose-namespaces' => [],
2625
'expose-constants' => [],
2726
'expose-classes' => [],
@@ -37,91 +36,55 @@
3736
],
3837

3938
'Some statements made directly in the global namespace' => <<<'PHP'
40-
<?php declare(strict_types=1);
41-
42-
/*
43-
* This file is part of PHPUnit.
44-
*
45-
* (c) Sebastian Bergmann <[email protected]>
46-
*
47-
* For the full copyright and license information, please view the LICENSE
48-
* file that was distributed with this source code.
49-
*/
50-
51-
if (\true) {
52-
echo "yo";
53-
}
54-
55-
if (\false) {
56-
echo "oy";
57-
}
58-
59-
----
60-
<?php
61-
62-
declare (strict_types=1);
63-
namespace Humbug;
64-
65-
/*
66-
* This file is part of PHPUnit.
67-
*
68-
* (c) Sebastian Bergmann <[email protected]>
69-
*
70-
* For the full copyright and license information, please view the LICENSE
71-
* file that was distributed with this source code.
72-
*/
73-
if (\true) {
74-
echo "yo";
75-
}
76-
if (\false) {
77-
echo "oy";
78-
}
79-
80-
PHP
81-
,
39+
<?php declare(strict_types=1);
40+
41+
if (\true) {
42+
echo "yo";
43+
}
44+
45+
if (\false) {
46+
echo "oy";
47+
}
48+
49+
----
50+
<?php
51+
52+
declare (strict_types=1);
53+
namespace Humbug;
54+
55+
if (\true) {
56+
echo "yo";
57+
}
58+
if (\false) {
59+
echo "oy";
60+
}
61+
62+
PHP,
8263

8364
'Some statements made directly in the global namespace with a shebang' => <<<'PHP'
84-
#!/usr/bin/env php
85-
<?php declare(strict_types=1);
86-
87-
/*
88-
* This file is part of PHPUnit.
89-
*
90-
* (c) Sebastian Bergmann <[email protected]>
91-
*
92-
* For the full copyright and license information, please view the LICENSE
93-
* file that was distributed with this source code.
94-
*/
95-
96-
if (\true) {
97-
echo "yo";
98-
}
99-
100-
if (\false) {
101-
echo "oy";
102-
}
103-
104-
----
105-
#!/usr/bin/env php
106-
<?php
107-
declare (strict_types=1);
108-
namespace Humbug;
109-
110-
/*
111-
* This file is part of PHPUnit.
112-
*
113-
* (c) Sebastian Bergmann <[email protected]>
114-
*
115-
* For the full copyright and license information, please view the LICENSE
116-
* file that was distributed with this source code.
117-
*/
118-
if (\true) {
119-
echo "yo";
120-
}
121-
if (\false) {
122-
echo "oy";
123-
}
124-
125-
PHP
126-
,
65+
#!/usr/bin/env php
66+
<?php declare(strict_types=1);
67+
68+
if (\true) {
69+
echo "yo";
70+
}
71+
72+
if (\false) {
73+
echo "oy";
74+
}
75+
76+
----
77+
#!/usr/bin/env php
78+
<?php
79+
declare (strict_types=1);
80+
namespace Humbug;
81+
82+
if (\true) {
83+
echo "yo";
84+
}
85+
if (\false) {
86+
echo "oy";
87+
}
88+
89+
PHP,
12790
];

specs/class-const/global-scope-single-level-with-single-level-use-statement-and-alias.php

Lines changed: 122 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717
'title' => 'Class constant call of a class imported with an aliased use statement in the global scope',
1818
// Default values. If not specified will be the one used
1919
'prefix' => 'Humbug',
20-
'whitelist' => [],
2120

22-
'expose-global-constants' => true,
21+
'expose-global-constants' => false,
2322
'expose-global-classes' => false,
24-
'expose-global-functions' => true,
23+
'expose-global-functions' => false,
2524
'expose-namespaces' => [],
2625
'expose-constants' => [],
2726
'expose-classes' => [],
@@ -36,94 +35,129 @@
3635
'expected-recorded-functions' => [],
3736
],
3837

39-
'Constant call on a aliased class which is imported via an aliased use statement and which belongs to the global namespace' => [
38+
'Constant call on a aliased class which is imported via an aliased use statement and which belongs to the global namespace' => <<<'PHP'
39+
<?php
40+
41+
class Foo {}
42+
43+
use Foo as X;
44+
45+
X::MAIN_CONST;
46+
----
47+
<?php
48+
49+
namespace Humbug;
50+
51+
class Foo
52+
{
53+
}
54+
use Humbug\Foo as X;
55+
X::MAIN_CONST;
56+
57+
PHP,
58+
59+
'FQ constant call on a aliased class which is imported via an aliased use statement and which belongs to the global namespace' => <<<'PHP'
60+
<?php
61+
62+
class Foo {}
63+
class X {}
64+
65+
use Foo as X;
66+
67+
\X::MAIN_CONST;
68+
----
69+
<?php
70+
71+
namespace Humbug;
72+
73+
class Foo
74+
{
75+
}
76+
class X
77+
{
78+
}
79+
use Humbug\Foo as X;
80+
\Humbug\X::MAIN_CONST;
81+
82+
PHP,
83+
84+
'Constant call on an internal class which is imported via an aliased use statement and which belongs to the global namespace' => <<<'PHP'
85+
<?php
86+
87+
use Reflector as X;
88+
89+
X::MAIN_CONST;
90+
----
91+
<?php
92+
93+
namespace Humbug;
94+
95+
use Reflector as X;
96+
X::MAIN_CONST;
97+
98+
PHP,
99+
100+
'FQ constant call on an internal class which is imported via an aliased use statement and which belongs to the global namespace' => <<<'PHP'
101+
<?php
102+
103+
class X {}
104+
105+
use Reflector as X;
106+
107+
\X::MAIN_CONST;
108+
----
109+
<?php
110+
111+
namespace Humbug;
112+
113+
class X
114+
{
115+
}
116+
use Reflector as X;
117+
\Humbug\X::MAIN_CONST;
118+
119+
PHP,
120+
121+
'Constant call on an exposed class which is imported via an aliased use statement and which belongs to the global namespace' => [
122+
'expose-classes' => ['Foo'],
40123
'payload' => <<<'PHP'
41-
<?php
42-
43-
class Foo {}
44-
45-
use Foo as X;
46-
47-
X::MAIN_CONST;
48-
----
49-
<?php
50-
51-
namespace Humbug;
52-
53-
class Foo
54-
{
55-
}
56-
use Humbug\Foo as X;
57-
X::MAIN_CONST;
58-
59-
PHP
60-
],
61-
62-
'FQ constant call on a aliased class which is imported via an aliased use statement and which belongs to the global namespace' => [
63-
'payload' => <<<'PHP'
64-
<?php
65-
66-
class Foo {}
67-
class X {}
68-
69-
use Foo as X;
70-
71-
\X::MAIN_CONST;
72-
----
73-
<?php
74-
75-
namespace Humbug;
76-
77-
class Foo
78-
{
79-
}
80-
class X
81-
{
82-
}
83-
use Humbug\Foo as X;
84-
\Humbug\X::MAIN_CONST;
85-
86-
PHP
124+
<?php
125+
126+
use Foo as X;
127+
128+
X::MAIN_CONST;
129+
----
130+
<?php
131+
132+
namespace Humbug;
133+
134+
use Humbug\Foo as X;
135+
X::MAIN_CONST;
136+
137+
PHP,
87138
],
88139

89-
'Constant call on a whitelisted class which is imported via an aliased use statement and which belongs to the global namespace' => [
140+
'FQ constant call on an excluded class which is imported via an aliased use statement and which belongs to the global namespace' => [
141+
'expose-classes' => ['Foo'],
90142
'payload' => <<<'PHP'
91-
<?php
92-
93-
use Reflector as X;
94-
95-
X::MAIN_CONST;
96-
----
97-
<?php
98-
99-
namespace Humbug;
100-
101-
use Reflector as X;
102-
X::MAIN_CONST;
103-
104-
PHP
105-
],
106-
107-
'FQ constant call on a whitelisted class which is imported via an aliased use statement and which belongs to the global namespace' => [
108-
'payload' => <<<'PHP'
109-
<?php
110-
111-
class X {}
112-
113-
use Reflector as X;
114-
115-
\X::MAIN_CONST;
116-
----
117-
<?php
118-
119-
namespace Humbug;
120-
121-
class X
122-
{
123-
}
124-
use Reflector as X;
125-
\Humbug\X::MAIN_CONST;
126-
127-
PHP
143+
<?php
144+
145+
class X {}
146+
147+
use Foo as X;
148+
149+
\X::MAIN_CONST;
150+
----
151+
<?php
152+
153+
namespace Humbug;
154+
155+
class X
156+
{
157+
}
158+
use Humbug\Foo as X;
159+
\Humbug\X::MAIN_CONST;
160+
161+
PHP,
128162
],
129163
];

0 commit comments

Comments
 (0)