-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[PhpUnitBridge]allow outdated vendors mode #24867
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
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4a02b81
Refactor inVendors to a private static method
greg0ire 9fdbe2b
Introduce weak_lagging_vendors mode
greg0ire b17db80
Skip if php 7.2 and php input or phar
greg0ire de52e93
Give out more details
greg0ire 8566bd6
Include the trace in the deprecation metadata
greg0ire cc6e2bb
Adapt to new message format
greg0ire f613ebf
Refactor static variable to static property
greg0ire 4d40407
Refactor lagging into outdated
greg0ire 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
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
42 changes: 42 additions & 0 deletions
42
...idge/PhpUnit/Tests/DeprecationErrorHandler/allow_outdated_vendors_directly_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,42 @@ | ||
--TEST-- | ||
Test DeprecationErrorHandler in weak vendors mode when calling deprecated api | ||
--FILE-- | ||
<?php | ||
|
||
putenv('SYMFONY_DEPRECATIONS_HELPER=allow_outdated_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'; | ||
eval(<<<'EOPHP' | ||
namespace PHPUnit\Util; | ||
|
||
class Test | ||
{ | ||
public static function getGroups() | ||
{ | ||
return array(); | ||
} | ||
} | ||
EOPHP | ||
); | ||
require __DIR__.'/fake_vendor/autoload.php'; | ||
require __DIR__.'/fake_vendor/acme/lib/SomeService.php'; | ||
$defraculator = new \Acme\Lib\SomeService(); | ||
$defraculator->deprecatedApi(); | ||
|
||
|
||
?> | ||
--EXPECTF-- | ||
Remaining deprecation notices (1) | ||
|
||
1x: deprecatedApi is deprecated! You should stop relying on it! | ||
1x in SomeService::deprecatedApi from acme\lib | ||
|
35 changes: 35 additions & 0 deletions
35
...ridge/PhpUnit/Tests/DeprecationErrorHandler/allow_outdated_vendors_on_lagging_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,35 @@ | ||
--TEST-- | ||
Test DeprecationErrorHandler in weak vendors mode on vendor file | ||
--FILE-- | ||
<?php | ||
|
||
putenv('SYMFONY_DEPRECATIONS_HELPER=allow_outdated_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'; | ||
eval(<<<'EOPHP' | ||
namespace PHPUnit\Util; | ||
|
||
class Test | ||
{ | ||
public static function getGroups() | ||
{ | ||
return array(); | ||
} | ||
} | ||
EOPHP | ||
); | ||
require __DIR__.'/fake_vendor/autoload.php'; | ||
require __DIR__.'/fake_vendor/acme/outdated-lib/outdated_file.php'; | ||
|
||
?> | ||
--EXPECTF-- | ||
Outdated vendor deprecation notices (1) |
14 changes: 14 additions & 0 deletions
14
...Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/SomeService.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,14 @@ | ||
<?php | ||
|
||
namespace acme\lib; | ||
|
||
class SomeService | ||
{ | ||
public function deprecatedApi() | ||
{ | ||
@trigger_error( | ||
__FUNCTION__.' is deprecated! You should stop relying on it!', | ||
E_USER_DEPRECATED | ||
); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...dge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/acme/outdated-lib/outdated_file.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,7 @@ | ||
<?php | ||
/* We have not caught up on the deprecations yet and still call the other lib | ||
in a deprecated way. */ | ||
|
||
include __DIR__.'/../lib/SomeService.php'; | ||
$defraculator = new \acme\lib\SomeService(); | ||
$defraculator->deprecatedApi(); |
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.
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.
you should throw a meaningful exception when reaching this place explaining that the provided path is not a vendor path, instead of letting PHP throw a fatal error due to
null
not respecting thestring
return type (which would not be clear at all).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.
@stof we're inside the error handler, that's why I refrained from doing that, I'm not sure how it will behave, but I will try.
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.
Wait, it's an error handler, so an exception should probably be fine.
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.
Reaching this place would indicate a bad usage of the private method inside the class anyway (as you are not supposed to pass a non-vendor path). So I think it would be fine (and would make it easier for contributors to see their mistakes)
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 tried putting an exception unconditionally on the first line, and it worked as expected, so it's fine indeed 👍