-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Do not execute the tests twice when generating the coverage - Fix prefixing of string literals with methods (as a method argument or passed as a parameter) - Fix static property calls: the class was not prefixed - Prefix Composer use statement: there is no reason not to anymore
- Loading branch information
Showing
17 changed files
with
2,070 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
137 changes: 137 additions & 0 deletions
137
...class-static-prop/global-scope-single-level-with-single-level-use-statement-and-alias.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the humbug/php-scoper package. | ||
* | ||
* Copyright (c) 2017 Théo FIDRY <[email protected]>, | ||
* Pádraic Brady <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
return [ | ||
'meta' => [ | ||
'title' => 'Class static property call of a class imported with an aliased use statement in the global scope', | ||
// Default values. If not specified will be the one used | ||
'prefix' => 'Humbug', | ||
'whitelist' => [], | ||
], | ||
|
||
[ | ||
'spec' => <<<'SPEC' | ||
Constant call on a aliased class which is imported via an aliased use statement and which belongs to the global namespace: | ||
- prefix the use statement (cf. class belonging to the global scope tests) | ||
- prefix the constant | ||
SPEC | ||
, | ||
'payload' => <<<'PHP' | ||
<?php | ||
class Foo {} | ||
use Foo as X; | ||
X::$mainStaticProp; | ||
---- | ||
<?php | ||
namespace Humbug; | ||
class Foo | ||
{ | ||
} | ||
use Humbug\Foo as X; | ||
\Humbug\Foo::$mainStaticProp; | ||
|
||
PHP | ||
], | ||
|
||
[ | ||
'spec' => <<<'SPEC' | ||
FQ constant call on a aliased class which is imported via an aliased use statement and which belongs to the global namespace: | ||
- do not prefix the class (cf. class belonging to the global scope tests) | ||
- do nothing | ||
SPEC | ||
, | ||
'payload' => <<<'PHP' | ||
<?php | ||
class Foo {} | ||
class X {} | ||
use Foo as X; | ||
\X::$mainStaticProp; | ||
---- | ||
<?php | ||
namespace Humbug; | ||
class Foo | ||
{ | ||
} | ||
class X | ||
{ | ||
} | ||
use Humbug\Foo as X; | ||
\Humbug\X::$mainStaticProp; | ||
|
||
PHP | ||
], | ||
|
||
[ | ||
'spec' => <<<'SPEC' | ||
Constant call on a whitelisted class which is imported via an aliased use statement and which belongs to the global namespace: | ||
- prefix the use statement (cf. class belonging to the global scope tests and `scope.inc.php` for the built-in global whitelisted classes) | ||
- transform the call into a FQ call | ||
SPEC | ||
, | ||
'payload' => <<<'PHP' | ||
<?php | ||
use Reflector as X; | ||
X::$mainStaticProp; | ||
---- | ||
<?php | ||
namespace Humbug; | ||
use Reflector as X; | ||
\Reflector::$mainStaticProp; | ||
|
||
PHP | ||
], | ||
|
||
[ | ||
'spec' => <<<'SPEC' | ||
FQ constant call on a whitelisted class which is imported via an aliased use statement and which belongs to the global namespace: | ||
- prefix the use statement (cf. class belonging to the global scope tests and `scope.inc.php` for the built-in global whitelisted classes) | ||
- do nothing | ||
SPEC | ||
, | ||
'payload' => <<<'PHP' | ||
<?php | ||
class X {} | ||
use Reflector as X; | ||
\X::$mainStaticProp; | ||
---- | ||
<?php | ||
namespace Humbug; | ||
class X | ||
{ | ||
} | ||
use Reflector as X; | ||
\Humbug\X::$mainStaticProp; | ||
|
||
PHP | ||
], | ||
]; |
128 changes: 128 additions & 0 deletions
128
specs/class-static-prop/global-scope-single-level-with-single-level-use-statement.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the humbug/php-scoper package. | ||
* | ||
* Copyright (c) 2017 Théo FIDRY <[email protected]>, | ||
* Pádraic Brady <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
return [ | ||
'meta' => [ | ||
'title' => 'Class static property call of a class imported with a use statement in the global scope', | ||
// Default values. If not specified will be the one used | ||
'prefix' => 'Humbug', | ||
'whitelist' => [], | ||
], | ||
|
||
[ | ||
'spec' => <<<'SPEC' | ||
Constant call on a class which is imported via a use statement and which belongs to the global namespace: | ||
- do not prefix the use statement (cf. class belonging to the global scope tests) | ||
- transforms the call into a FQ call | ||
SPEC | ||
, | ||
'payload' => <<<'PHP' | ||
<?php | ||
class Command {} | ||
use Command; | ||
Command::$mainStaticProp; | ||
---- | ||
<?php | ||
namespace Humbug; | ||
class Command | ||
{ | ||
} | ||
use Humbug\Command; | ||
\Humbug\Command::$mainStaticProp; | ||
|
||
PHP | ||
], | ||
|
||
[ | ||
'spec' => <<<'SPEC' | ||
FQ constant call on a class which is imported via a use statement and which belongs to the global namespace: | ||
- do not prefix the use statement (cf. class belonging to the global scope tests) | ||
- do nothing | ||
SPEC | ||
, | ||
'payload' => <<<'PHP' | ||
<?php | ||
class Command {} | ||
use Command; | ||
\Command::$mainStaticProp; | ||
---- | ||
<?php | ||
namespace Humbug; | ||
class Command | ||
{ | ||
} | ||
use Humbug\Command; | ||
\Humbug\Command::$mainStaticProp; | ||
|
||
PHP | ||
], | ||
|
||
[ | ||
'spec' => <<<'SPEC' | ||
Constant call on a whitelisted class which is imported via a use statement and which belongs to the global namespace: | ||
- 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) | ||
SPEC | ||
, | ||
'payload' => <<<'PHP' | ||
<?php | ||
use Reflector; | ||
Reflector::$mainStaticProp; | ||
---- | ||
<?php | ||
namespace Humbug; | ||
use Reflector; | ||
\Reflector::$mainStaticProp; | ||
|
||
PHP | ||
], | ||
|
||
[ | ||
'spec' => <<<'SPEC' | ||
FQ constant call on a whitelisted class which is imported via a use statement and which belongs to the global namespace: | ||
- prefix the class (cf. class belonging to the global scope tests and `scope.inc.php` for the built-in global | ||
whitelisted classes) | ||
SPEC | ||
, | ||
'payload' => <<<'PHP' | ||
<?php | ||
use Reflector; | ||
\Reflector::$mainStaticProp; | ||
---- | ||
<?php | ||
namespace Humbug; | ||
use Reflector; | ||
\Reflector::$mainStaticProp; | ||
|
||
PHP | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the humbug/php-scoper package. | ||
* | ||
* Copyright (c) 2017 Théo FIDRY <[email protected]>, | ||
* Pádraic Brady <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
return [ | ||
'meta' => [ | ||
'title' => 'Class static property call in the global scope', | ||
// Default values. If not specified will be the one used | ||
'prefix' => 'Humbug', | ||
'whitelist' => [], | ||
], | ||
|
||
[ | ||
'spec' => <<<'SPEC' | ||
Constant call on a class belonging to the global namespace: | ||
- do not prefix the class (cf. class belonging to the global scope tests) | ||
- transforms the call into a FQ call to avoid autoloading issues | ||
SPEC | ||
, | ||
'payload' => <<<'PHP' | ||
<?php | ||
class Command {} | ||
Command::$mainStaticProp; | ||
---- | ||
<?php | ||
namespace Humbug; | ||
class Command | ||
{ | ||
} | ||
\Humbug\Command::$mainStaticProp; | ||
|
||
PHP | ||
], | ||
|
||
[ | ||
'spec' => <<<'SPEC' | ||
FQ constant call on a class belonging to the global namespace: | ||
- do not prefix the class (cf. class belonging to the global scope tests) | ||
- do not touch the call | ||
SPEC | ||
, | ||
'payload' => <<<'PHP' | ||
<?php | ||
class Command {} | ||
\Command::$mainStaticProp; | ||
---- | ||
<?php | ||
namespace Humbug; | ||
class Command | ||
{ | ||
} | ||
\Humbug\Command::$mainStaticProp; | ||
|
||
PHP | ||
], | ||
|
||
[ | ||
'spec' => <<<'SPEC' | ||
Constant call on a whitelisted class belonging to the global namespace: | ||
- prefix the class (cf. class belonging to the global scope tests and `scope.inc.php` for the built-in global whitelisted classes) | ||
- transforms the call into a FQ call to avoid autoloading issues | ||
SPEC | ||
, | ||
'payload' => <<<'PHP' | ||
<?php | ||
Reflector::$mainStaticProp; | ||
---- | ||
<?php | ||
namespace Humbug; | ||
\Reflector::$mainStaticProp; | ||
|
||
PHP | ||
], | ||
|
||
[ | ||
'spec' => <<<'SPEC' | ||
FQ constant call on a whitelisted class belonging to the global namespace: | ||
- prefix the class (cf. class belonging to the global scope tests and `scope.inc.php` for the built-in global whitelisted classes) | ||
- transforms the call into a FQ call to avoid autoloading issues | ||
SPEC | ||
, | ||
'payload' => <<<'PHP' | ||
<?php | ||
\Reflector::$mainStaticProp; | ||
---- | ||
<?php | ||
namespace Humbug; | ||
\Reflector::$mainStaticProp; | ||
|
||
PHP | ||
], | ||
]; |
Oops, something went wrong.