-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Introduce weak vendors mode #21539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Introduce weak vendors mode #21539
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
35 changes: 35 additions & 0 deletions
35
...Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/deprecation_riddled.php
This file contains hidden or 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,35 @@ | ||
<?php | ||
|
||
eval(<<<'EOPHP' | ||
namespace PHPUnit\Util; | ||
|
||
class Test | ||
{ | ||
public static function getGroups() | ||
{ | ||
return array(); | ||
} | ||
} | ||
EOPHP | ||
); | ||
|
||
@trigger_error('root deprecation', E_USER_DEPRECATED); | ||
|
||
class FooTestCase | ||
{ | ||
public function testLegacyFoo() | ||
{ | ||
@trigger_error('silenced foo deprecation', E_USER_DEPRECATED); | ||
trigger_error('unsilenced foo deprecation', E_USER_DEPRECATED); | ||
} | ||
|
||
public function testNonLegacyBar() | ||
{ | ||
@trigger_error('silenced bar deprecation', E_USER_DEPRECATED); | ||
trigger_error('unsilenced bar deprecation', E_USER_DEPRECATED); | ||
} | ||
} | ||
|
||
$foo = new FooTestCase(); | ||
$foo->testLegacyFoo(); | ||
$foo->testNonLegacyBar(); |
3 changes: 3 additions & 0 deletions
3
src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/autoload.php
This file contains hidden or 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,3 @@ | ||
<?php | ||
|
||
require_once __DIR__.'/composer/autoload_real.php'; |
5 changes: 5 additions & 0 deletions
5
...mfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/composer/autoload_real.php
This file contains hidden or 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,5 @@ | ||
<?php | ||
|
||
class ComposerAutoloaderInitFake | ||
{ | ||
} |
1 change: 1 addition & 0 deletions
1
src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/composer/installed.json
This file contains hidden or 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 @@ | ||
{"just here": "for the detection"} |
74 changes: 74 additions & 0 deletions
74
src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/weak_vendors_on_non_vendor.phpt
This file contains hidden or 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,74 @@ | ||
--TEST-- | ||
Test DeprecationErrorHandler in weak vendors mode on a non vendor file | ||
--FILE-- | ||
<?php | ||
|
||
putenv('SYMFONY_DEPRECATIONS_HELPER=weak_vendors'); | ||
putenv('ANSICON'); | ||
putenv('ConEmuANSI'); | ||
putenv('TERM'); | ||
|
||
$vendor = __DIR__; | ||
while (!file_exists($vendor.'/vendor')) { | ||
$vendor = dirname($vendor); | ||
} | ||
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php'); | ||
require PHPUNIT_COMPOSER_INSTALL; | ||
require_once __DIR__.'/../../bootstrap.php'; | ||
|
||
@trigger_error('root deprecation', E_USER_DEPRECATED); | ||
|
||
eval(<<<'EOPHP' | ||
namespace PHPUnit\Util; | ||
|
||
class Test | ||
{ | ||
public static function getGroups() | ||
{ | ||
return array(); | ||
} | ||
} | ||
EOPHP | ||
); | ||
|
||
class FooTestCase | ||
{ | ||
public function testLegacyFoo() | ||
{ | ||
@trigger_error('silenced foo deprecation', E_USER_DEPRECATED); | ||
trigger_error('unsilenced foo deprecation', E_USER_DEPRECATED); | ||
trigger_error('unsilenced foo deprecation', E_USER_DEPRECATED); | ||
} | ||
|
||
public function testNonLegacyBar() | ||
{ | ||
@trigger_error('silenced bar deprecation', E_USER_DEPRECATED); | ||
trigger_error('unsilenced bar deprecation', E_USER_DEPRECATED); | ||
} | ||
} | ||
|
||
$foo = new FooTestCase(); | ||
$foo->testLegacyFoo(); | ||
$foo->testNonLegacyBar(); | ||
|
||
?> | ||
--EXPECTF-- | ||
Unsilenced deprecation notices (3) | ||
|
||
unsilenced foo deprecation: 2x | ||
2x in FooTestCase::testLegacyFoo | ||
|
||
unsilenced bar deprecation: 1x | ||
1x in FooTestCase::testNonLegacyBar | ||
|
||
Remaining deprecation notices (1) | ||
|
||
silenced bar deprecation: 1x | ||
1x in FooTestCase::testNonLegacyBar | ||
|
||
Legacy deprecation notices (1) | ||
|
||
Other deprecation notices (1) | ||
|
||
root deprecation: 1x | ||
|
27 changes: 27 additions & 0 deletions
27
src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/weak_vendors_on_vendor.phpt
This file contains hidden or 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,27 @@ | ||
--TEST-- | ||
Test DeprecationErrorHandler in weak vendors mode on vendor file | ||
--FILE-- | ||
<?php | ||
|
||
putenv('SYMFONY_DEPRECATIONS_HELPER=weak_vendors'); | ||
putenv('ANSICON'); | ||
putenv('ConEmuANSI'); | ||
putenv('TERM'); | ||
|
||
$vendor = __DIR__; | ||
while (!file_exists($vendor.'/vendor')) { | ||
$vendor = dirname($vendor); | ||
} | ||
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php'); | ||
require PHPUNIT_COMPOSER_INSTALL; | ||
require_once __DIR__.'/../../bootstrap.php'; | ||
require __DIR__.'/fake_vendor/autoload.php'; | ||
require __DIR__.'/fake_vendor/acme/lib/deprecation_riddled.php'; | ||
--EXPECTF-- | ||
Unsilenced deprecation notices (2) | ||
|
||
Remaining vendor deprecation notices (1) | ||
|
||
Legacy deprecation notices (1) | ||
|
||
Other deprecation notices (1) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope you have nothing against the multiline
$colorize
call. IMO it's more readable in an objective way (you can see all the code w/o scrolling when reviewing, for instance).