Skip to content

Commit

Permalink
Record whitelisted classes (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry authored Aug 3, 2018
1 parent 1fd056d commit 2008685
Show file tree
Hide file tree
Showing 50 changed files with 480 additions and 24 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ class Yaml

'FQC constant call on whitelisted class' => [
'whitelist' => ['Symfony\Component\Yaml\Yaml'],
'registered-classes' => [
['Symfony\Component\Yaml\Yaml', 'Humbug\Symfony\Component\Yaml\Yaml'],
],
'payload' => <<<'PHP'
<?php
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,9 @@ class Yaml

'FQC constant call on whitelisted class' => [
'whitelist' => ['Symfony\Component\Yaml\Yaml'],
'registered-classes' => [
['Symfony\Component\Yaml\Yaml', 'Humbug\Symfony\Component\Yaml\Yaml'],
],
'payload' => <<<'PHP'
<?php
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ class Yaml

'FQC constant call on whitelisted class' => [
'whitelist' => ['Symfony\Component\Yaml\Yaml'],
'registered-classes' => [
['Symfony\Component\Yaml\Yaml', 'Humbug\Symfony\Component\Yaml\Yaml'],
],
'payload' => <<<'PHP'
<?php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ class Yaml

'FQC constant call on whitelisted class' => [
'whitelist' => ['Symfony\Component\Yaml\Yaml'],
'registered-classes' => [
['Symfony\Component\Yaml\Yaml', 'Humbug\Symfony\Component\Yaml\Yaml'],
],
'payload' => <<<'PHP'
<?php
Expand Down
15 changes: 15 additions & 0 deletions specs/class-FQ.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@

'Different kind of whitelisted class constant calls in the global scope' => [
'whitelist' => ['Foo\Bar', 'Foo\Bar\Poz'],
'registered-classes' => [
['Foo\Bar', 'Humbug\Foo\Bar'],
['Foo\Bar\Poz', 'Humbug\Foo\Bar\Poz'],
],
'payload' => <<<'PHP'
<?php
Expand Down Expand Up @@ -184,6 +188,17 @@ class Poz
'A\Aoz',
'A\Aoo\Aoz\Poz',
],
'registered-classes' => [
['Foo\Bar', 'Humbug\Foo\Bar'],
['Foo\Bar\Poz', 'Humbug\Foo\Bar\Poz'],

['A\Foo', 'Humbug\A\Foo'],
['A\Foo\Bar', 'Humbug\A\Foo\Bar'],
['A\Foo\Bar\Poz', 'Humbug\A\Foo\Bar\Poz'],
['A\Aoo', 'Humbug\A\Aoo'],
['A\Aoo\Aoz', 'Humbug\A\Aoo\Aoz'],
['A\Aoo\Aoz\Poz', 'Humbug\A\Aoo\Aoz\Poz'],
],
'payload' => <<<'PHP'
<?php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ class Bar

'FQ Constant call on a whitelisted namespaced class partially imported with an aliased use statement' => [
'whitelist' => ['Foo\Bar'],
'registered-classes' => [
['Foo\Bar', 'Humbug\Foo\Bar'],
],
'payload' => <<<'PHP'
<?php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ class Bar

'FQ Constant call on a whitelisted namespaced class partially imported with a use statement' => [
'whitelist' => ['Foo\Bar'],
'registered-classes' => [
['Foo\Bar', 'Humbug\Foo\Bar'],
],
'payload' => <<<'PHP'
<?php
Expand Down Expand Up @@ -180,6 +183,9 @@ class Bar

'FQ constant call on a whitelisted namespaced class imported with a use statement' => [
'whitelist' => ['Foo\Bar'],
'registered-classes' => [
['Foo\Bar', 'Humbug\Foo\Bar'],
],
'payload' => <<<'PHP'
<?php
Expand Down
6 changes: 6 additions & 0 deletions specs/class-const/global-scope-two-level.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ class Command

'Constant call on a whitelisted namespaced class' => [
'whitelist' => ['PHPUnit\Command'],
'registered-classes' => [
['PHPUnit\Command', 'Humbug\PHPUnit\Command'],
],
'payload' => <<<'PHP'
<?php
Expand Down Expand Up @@ -106,6 +109,9 @@ class Command

'FQ constant call on a whitelisted namespaced class' => [
'whitelist' => ['PHPUnit\Command'],
'registered-classes' => [
['PHPUnit\Command', 'Humbug\PHPUnit\Command'],
],
'payload' => <<<'PHP'
<?php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ class Bar

'FQ Constant call on a whitelisted namespaced class partially imported with an aliased use statement' => [
'whitelist' => ['Foo\Bar'],
'registered-classes' => [
['Foo\Bar', 'Humbug\Foo\Bar'],
],
'payload' => <<<'PHP'
<?php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ class Bar

'FQ Constant call on a whitelisted namespaced class partially imported with a use statement' => [
'whitelist' => ['Foo\Bar'],
'registered-classes' => [
['Foo\Bar', 'Humbug\Foo\Bar'],
],
'payload' => <<<'PHP'
<?php
Expand Down Expand Up @@ -180,6 +183,9 @@ class Bar

'FQ constant call on a whitelisted namespaced class imported with a use statement' => [
'whitelist' => ['Foo\Bar'],
'registered-classes' => [
['Foo\Bar', 'Humbug\Foo\Bar'],
],
'payload' => <<<'PHP'
<?php
Expand Down
6 changes: 6 additions & 0 deletions specs/class-const/namespace-scope-two-level.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ class Command

'Constant call on a whitelisted namespaced class' => [
'whitelist' => ['X\PHPUnit\Command'],
'registered-classes' => [
['X\PHPUnit\Command', 'Humbug\X\PHPUnit\Command'],
],
'payload' => <<<'PHP'
<?php
Expand Down Expand Up @@ -160,6 +163,9 @@ class Command

'FQ constant call on a whitelisted namespaced class' => [
'whitelist' => ['PHPUnit\Command'],
'registered-classes' => [
['PHPUnit\Command', 'Humbug\PHPUnit\Command'],
],
'payload' => <<<'PHP'
<?php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ class Bar

'FQ Constant call on a whitelisted namespaced class partially imported with an aliased use statement' => [
'whitelist' => ['Foo\Bar'],
'registered-classes' => [
['Foo\Bar', 'Humbug\Foo\Bar'],
],
'payload' => <<<'PHP'
<?php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ class Bar

'FQ Constant call on a whitelisted namespaced class partially imported with a use statement' => [
'whitelist' => ['Foo\Bar'],
'registered-classes' => [
['Foo\Bar', 'Humbug\Foo\Bar'],
],
'payload' => <<<'PHP'
<?php
Expand Down Expand Up @@ -177,6 +180,9 @@ class Bar

'FQ constant call on a whitelisted namespaced class imported with a use statement' => [
'whitelist' => ['Foo\Bar'],
'registered-classes' => [
['Foo\Bar', 'Humbug\Foo\Bar'],
],
'payload' => <<<'PHP'
<?php
Expand Down
6 changes: 6 additions & 0 deletions specs/class-static-prop/global-scope-two-level.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ class Command

'Constant call on a whitelisted namespaced class' => [
'whitelist' => ['PHPUnit\Command'],
'registered-classes' => [
['PHPUnit\Command', 'Humbug\PHPUnit\Command'],
],
'payload' => <<<'PHP'
<?php
Expand Down Expand Up @@ -104,6 +107,9 @@ class Command

'FQ constant call on a whitelisted namespaced class' => [
'whitelist' => ['PHPUnit\Command'],
'registered-classes' => [
['PHPUnit\Command', 'Humbug\PHPUnit\Command'],
],
'payload' => <<<'PHP'
<?php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ class Bar

'FQ Constant call on a whitelisted namespaced class partially imported with an aliased use statement' => [
'whitelist' => ['Foo\Bar'],
'registered-classes' => [
['Foo\Bar', 'Humbug\Foo\Bar'],
],
'payload' => <<<'PHP'
<?php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ class Bar

'FQ Constant call on a whitelisted namespaced class partially imported with a use statement' => [
'whitelist' => ['Foo\Bar'],
'registered-classes' => [
['Foo\Bar', 'Humbug\Foo\Bar'],
],
'payload' => <<<'PHP'
<?php
Expand Down Expand Up @@ -177,6 +180,9 @@ class Bar

'FQ constant call on a whitelisted namespaced class imported with a use statement' => [
'whitelist' => ['Foo\Bar'],
'registered-classes' => [
['Foo\Bar', 'Humbug\Foo\Bar'],
],
'payload' => <<<'PHP'
<?php
Expand Down
6 changes: 6 additions & 0 deletions specs/class-static-prop/namespace-scope-two-level.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ class Command

'Constant call on a whitelisted namespaced class' => [
'whitelist' => ['X\PHPUnit\Command'],
'registered-classes' => [
['X\PHPUnit\Command', 'Humbug\X\PHPUnit\Command'],
],
'payload' => <<<'PHP'
<?php
Expand Down Expand Up @@ -104,6 +107,9 @@ class Command

'FQ constant call on a whitelisted namespaced class' => [
'whitelist' => ['PHPUnit\Command'],
'registered-classes' => [
['PHPUnit\Command', 'Humbug\PHPUnit\Command'],
],
'payload' => <<<'PHP'
<?php
Expand Down
72 changes: 71 additions & 1 deletion specs/class/abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public abstract function b();

'Declaration of a whitelisted class in the global namespace' => [
'whitelist' => ['A'],
'registered-classes' => [
['A', 'Humbug\A'],
],
'payload' => <<<'PHP'
<?php
Expand All @@ -100,6 +103,9 @@ public abstract function b();

'Declaration of a whitelisted class in the global namespace which is whitelisted' => [
'whitelist' => ['A', '\*'],
'registered-classes' => [
['A', 'Humbug\A'],
],
'payload' => <<<'PHP'
<?php
Expand Down Expand Up @@ -177,6 +183,9 @@ public abstract function b();

'Declaration of a whitelisted class in a namespace' => [
'whitelist' => ['Foo\A'],
'registered-classes' => [
['Foo\A', 'Humbug\Foo\A'],
],
'payload' => <<<'PHP'
<?php
Expand All @@ -203,8 +212,64 @@ public abstract function b();
PHP
],

'Declaration of a whitelisted class in a namespace with FQCNfor the whitelist' => [
'Declaration of a namespaced class whitelisted with a pattern' => [
'whitelist' => ['Foo\A*'],
'registered-classes' => [
['Foo\A', 'Humbug\Foo\A'],
['Foo\AA', 'Humbug\Foo\AA'],
['Foo\A\B', 'Humbug\Foo\A\B'],
],
'payload' => <<<'PHP'
<?php
namespace Foo;
abstract class A {
public function a() {}
}
abstract class AA {}
abstract class B {}
namespace Foo\A;
abstract class B {}
----
<?php
namespace Humbug\Foo;
abstract class A
{
public function a()
{
}
}
\class_alias('Humbug\\Foo\\A', 'Foo\\A', \false);
abstract class AA
{
}
\class_alias('Humbug\\Foo\\AA', 'Foo\\AA', \false);
abstract class B
{
}
namespace Humbug\Foo\A;
abstract class B
{
}
\class_alias('Humbug\\Foo\\A\\B', 'Foo\\A\\B', \false);

PHP
],

'Declaration of a whitelisted class in a namespace with FQCN for the whitelist' => [
'whitelist' => ['\Foo\A'],
'registered-classes' => [
['Foo\A', 'Humbug\Foo\A'],
],
'payload' => <<<'PHP'
<?php
Expand Down Expand Up @@ -260,6 +325,11 @@ public abstract function b();

'Multiple declarations in different namespaces with whitelisted classes' => [
'whitelist' => ['Foo\WA', 'Bar\WB', 'WC'],
'registered-classes' => [
['Foo\WA', 'Humbug\Foo\WA'],
['Bar\WB', 'Humbug\Bar\WB'],
['WC', 'Humbug\WC'],
],
'payload' => <<<'PHP'
<?php
Expand Down
4 changes: 4 additions & 0 deletions specs/class/anonymous.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ public function test()

'Declaration in the global namespace with some whitelisted classes' => [
'whitelist' => ['A', 'C'],
'registered-classes' => [
['A', 'Humbug\A'],
['C', 'Humbug\C'],
],
'payload' => <<<'PHP'
<?php
Expand Down
Loading

0 comments on commit 2008685

Please sign in to comment.