Skip to content

Commit

Permalink
Merge pull request #63 from raziel057/fix-path-windows
Browse files Browse the repository at this point in the history
Fix path on windows
  • Loading branch information
malarzm authored Sep 27, 2023
2 parents bdaa697 + 53bd463 commit 4f2d4f2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Doctrine/Deprecations/Deprecation.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use function assert;
use function debug_backtrace;
use function sprintf;
use function str_replace;
use function strpos;
use function strrpos;
use function substr;
Expand Down Expand Up @@ -138,7 +139,7 @@ public static function triggerIfCalledFromOutside(string $package, string $link,

// first check that the caller is not from a tests folder, in which case we always let deprecations pass
if (isset($backtrace[1]['file'], $backtrace[0]['file']) && strpos($backtrace[1]['file'], DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR) === false) {
$path = DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . $package . DIRECTORY_SEPARATOR;
$path = DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $package) . DIRECTORY_SEPARATOR;

if (strpos($backtrace[0]['file'], $path) === false) {
return;
Expand Down
2 changes: 2 additions & 0 deletions tests/Doctrine/Deprecations/DeprecationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ public function testDeprecationIfCalledFromOutside(): void
);

Foo::triggerDependencyWithDeprecation();

$this->assertEquals(1, Deprecation::getUniqueTriggeredDeprecationsCount());
}

public function testDeprecationIfCalledFromOutsideNotTriggeringFromInside(): void
Expand Down

0 comments on commit 4f2d4f2

Please sign in to comment.