8889841cPK     $([QTX      )  test_fixtures/vendor/doctrine/foo/Baz.phpnu [        oldFunc();
    }
}
PK     $([wa    )  test_fixtures/vendor/doctrine/foo/Bar.phpnu [        oldFunc();
    }
}
PK     $([u  u  %  test_fixtures/src/RootDeprecation.phpnu [        oldFunc();
    }
    public static function triggerDependencyWithDeprecationFromInside(): void
    {
        $bar = new Bar();
        $bar->newFunc();
    }
}
PK     $([@.    	  README.mdnu [        # Doctrine Deprecations
A small (side-effect free by default) layer on top of
`trigger_error(E_USER_DEPRECATED)` or PSR-3 logging.
- no side-effects by default, making it a perfect fit for libraries that don't know how the error handler works they operate under
- options to avoid having to rely on error handlers global state by using PSR-3 logging
- deduplicate deprecation messages to avoid excessive triggering and reduce overhead
We recommend to collect Deprecations using a PSR logger instead of relying on
the global error handler.
## Usage from consumer perspective:
Enable Doctrine deprecations to be sent to a PSR3 logger:
```php
\Doctrine\Deprecations\Deprecation::enableWithPsrLogger($logger);
```
Enable Doctrine deprecations to be sent as `@trigger_error($message, E_USER_DEPRECATED)`
messages.
```php
\Doctrine\Deprecations\Deprecation::enableWithTriggerError();
```
If you only want to enable deprecation tracking, without logging or calling `trigger_error` then call:
```php
\Doctrine\Deprecations\Deprecation::enableTrackingDeprecations();
```
Tracking is enabled with all three modes and provides access to all triggered
deprecations and their individual count:
```php
$deprecations = \Doctrine\Deprecations\Deprecation::getTriggeredDeprecations();
foreach ($deprecations as $identifier => $count) {
    echo $identifier . " was triggered " . $count . " times\n";
}
```
### Suppressing Specific Deprecations
Disable triggering about specific deprecations:
```php
\Doctrine\Deprecations\Deprecation::ignoreDeprecations("https://link/to/deprecations-description-identifier");
```
Disable all deprecations from a package
```php
\Doctrine\Deprecations\Deprecation::ignorePackage("doctrine/orm");
```
### Other Operations
When used within PHPUnit or other tools that could collect multiple instances of the same deprecations
the deduplication can be disabled:
```php
\Doctrine\Deprecations\Deprecation::withoutDeduplication();
```
Disable deprecation tracking again:
```php
\Doctrine\Deprecations\Deprecation::disable();
```
## Usage from a library/producer perspective:
When you want to unconditionally trigger a deprecation even when called
from the library itself then the `trigger` method is the way to go:
```php
\Doctrine\Deprecations\Deprecation::trigger(
    "doctrine/orm",
    "https://link/to/deprecations-description",
    "message"
);
```
If variable arguments are provided at the end, they are used with `sprintf` on
the message.
```php
\Doctrine\Deprecations\Deprecation::trigger(
    "doctrine/orm",
    "https://github.com/doctrine/orm/issue/1234",
    "message %s %d",
    "foo",
    1234
);
```
When you want to trigger a deprecation only when it is called by a function
outside of the current package, but not trigger when the package itself is the cause,
then use:
```php
\Doctrine\Deprecations\Deprecation::triggerIfCalledFromOutside(
    "doctrine/orm",
    "https://link/to/deprecations-description",
    "message"
);
```
Based on the issue link each deprecation message is only triggered once per
request.
A limited stacktrace is included in the deprecation message to find the
offending location.
Note: A producer/library should never call `Deprecation::enableWith` methods
and leave the decision how to handle deprecations to application and
frameworks.
## Usage in PHPUnit tests
There is a `VerifyDeprecations` trait that you can use to make assertions on
the occurrence of deprecations within a test.
```php
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
class MyTest extends TestCase
{
    use VerifyDeprecations;
    public function testSomethingDeprecation()
    {
        $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issue/1234');
        triggerTheCodeWithDeprecation();
    }
}
```
## What is a deprecation identifier?
An identifier for deprecations is just a link to any resource, most often a
Github Issue or Pull Request explaining the deprecation and potentially its
alternative.
PK     $([EZ  Z  	  phpcs.xmlnu [        
    
    
    
    
    
    
    
    
    lib
    tests
    
    
        
    
PK     $([;I        phpunit.xml.distnu [        
    
        
            tests
        
    
PK     $(["p"   "   
  .gitignorenu [        vendor
.phpcs-cache
composer.lock
PK     $([bNXJ  J  6  tests/Doctrine/Deprecations/VerifyDeprecationsTest.phpnu [        expectDeprecationWithIdentifier('http://example.com');
        Deprecation::trigger('doctrine/dbal', 'http://example.com', 'message');
    }
    public function testExpectNoDeprecationWithIdentifier(): void
    {
        $this->expectNoDeprecationWithIdentifier('http://example.com');
        Deprecation::trigger('doctrine/dbal', 'http://otherexample.com', 'message');
    }
}
PK     $([!      /  tests/Doctrine/Deprecations/DeprecationTest.phpnu [        setAccessible(true);
        $reflectionProperty->setValue([]);
        $reflectionProperty = new ReflectionProperty(Deprecation::class, 'ignoredLinks');
        $reflectionProperty->setAccessible(true);
        $reflectionProperty->setValue([]);
        Deprecation::enableTrackingDeprecations();
    }
    public function expectDeprecation(): void
    {
        if (method_exists(TestCase::class, 'expectDeprecation')) {
            parent::expectDeprecation();
        } else {
            parent::expectException(Deprecated::class);
        }
    }
    public function expectDeprecationMessage(string $message): void
    {
        if (method_exists(TestCase::class, 'expectDeprecationMessage')) {
            parent::expectDeprecationMessage($message);
        } else {
            parent::expectExceptionMessage($message);
        }
    }
    public function expectErrorHandler(string $expectedMessage, string $identifier, int $times = 1): void
    {
        set_error_handler(function ($type, $message) use ($expectedMessage, $identifier, $times): void {
            $this->assertStringMatchesFormat(
                $expectedMessage,
                $message
            );
            $this->assertEquals([$identifier => $times], Deprecation::getTriggeredDeprecations());
        });
    }
    public function testDeprecation(): void
    {
        Deprecation::enableWithTriggerError();
        $this->expectDeprecationWithIdentifier('https://github.com/doctrine/deprecations/1234');
        $this->expectErrorHandler(
            'this is deprecated foo 1234 (DeprecationTest.php:%d called by TestCase.php:%d, https://github.com/doctrine/deprecations/1234, package doctrine/orm)',
            'https://github.com/doctrine/deprecations/1234'
        );
        Deprecation::trigger(
            'doctrine/orm',
            'https://github.com/doctrine/deprecations/1234',
            'this is deprecated %s %d',
            'foo',
            1234
        );
        $this->assertEquals(1, Deprecation::getUniqueTriggeredDeprecationsCount());
        Deprecation::trigger(
            'doctrine/orm',
            'https://github.com/doctrine/deprecations/1234',
            'this is deprecated %s %d',
            'foo',
            1234
        );
        $this->assertEquals(2, Deprecation::getUniqueTriggeredDeprecationsCount());
    }
    public function testDeprecationWithoutDeduplication(): void
    {
        Deprecation::enableWithTriggerError();
        Deprecation::withoutDeduplication();
        $this->expectErrorHandler(
            'this is deprecated foo 2222 (DeprecationTest.php:%d called by TestCase.php:%d, https://github.com/doctrine/deprecations/2222, package doctrine/orm)',
            'https://github.com/doctrine/deprecations/2222'
        );
        Deprecation::trigger(
            'doctrine/orm',
            'https://github.com/doctrine/deprecations/2222',
            'this is deprecated %s %d',
            'foo',
            2222
        );
        $this->assertEquals(1, Deprecation::getUniqueTriggeredDeprecationsCount());
        $this->expectErrorHandler(
            'this is deprecated foo 2222 (DeprecationTest.php:%d called by TestCase.php:%d, https://github.com/doctrine/deprecations/2222, package doctrine/orm)',
            'https://github.com/doctrine/deprecations/2222',
            2
        );
        Deprecation::trigger(
            'doctrine/orm',
            'https://github.com/doctrine/deprecations/2222',
            'this is deprecated %s %d',
            'foo',
            2222
        );
        $this->assertEquals(2, Deprecation::getUniqueTriggeredDeprecationsCount());
    }
    public function testDeprecationResetsCounts(): void
    {
        try {
            Deprecation::trigger(
                'doctrine/orm',
                'https://github.com/doctrine/deprecations/1234',
                'this is deprecated %s %d',
                'foo',
                1234
            );
        } catch (Throwable $e) {
            Deprecation::disable();
            $this->assertEquals(0, Deprecation::getUniqueTriggeredDeprecationsCount());
            $this->assertEquals(['https://github.com/doctrine/deprecations/1234' => 0], Deprecation::getTriggeredDeprecations());
        }
    }
    public function expectDeprecationMock(string $message, string $identifier, string $package): MockObject
    {
        $mock = $this->createMock(LoggerInterface::class);
        $mock->method('notice')->with($message, $this->callback(function ($context) use ($identifier, $package) {
            $this->assertEquals($package, $context['package']);
            $this->assertEquals($identifier, $context['link']);
            return true;
        }));
        return $mock;
    }
    public function testDeprecationWithPsrLogger(): void
    {
        $this->expectDeprecationWithIdentifier('https://github.com/doctrine/deprecations/2222');
        $mock = $this->expectDeprecationMock(
            'this is deprecated foo 1234',
            'https://github.com/doctrine/deprecations/2222',
            'doctrine/orm'
        );
        Deprecation::enableWithPsrLogger($mock);
        Deprecation::trigger(
            'doctrine/orm',
            'https://github.com/doctrine/deprecations/2222',
            'this is deprecated %s %d',
            'foo',
            1234
        );
    }
    public function testDeprecationWithIgnoredPackage(): void
    {
        Deprecation::enableWithTriggerError();
        Deprecation::ignorePackage('doctrine/orm');
        Deprecation::trigger(
            'doctrine/orm',
            'https://github.com/doctrine/orm/issue/1234',
            'this is deprecated %s %d',
            'foo',
            1234
        );
        $this->assertEquals(1, Deprecation::getUniqueTriggeredDeprecationsCount());
        $this->assertEquals(['https://github.com/doctrine/orm/issue/1234' => 1], Deprecation::getTriggeredDeprecations());
    }
    public function testDeprecationIfCalledFromOutside(): void
    {
        Deprecation::enableWithTriggerError();
        $this->expectErrorHandler(
            'Bar::oldFunc() is deprecated, use Bar::newFunc() instead. (Bar.php:16 called by Foo.php:14, https://github.com/doctrine/foo, package doctrine/foo)',
            'https://github.com/doctrine/foo'
        );
        Foo::triggerDependencyWithDeprecation();
    }
    public function testDeprecationIfCalledFromOutsideNotTriggeringFromInside(): void
    {
        Deprecation::enableWithTriggerError();
        Foo::triggerDependencyWithDeprecationFromInside();
        $this->assertEquals(0, Deprecation::getUniqueTriggeredDeprecationsCount());
    }
    public function testDeprecationIfCalledFromOutsideNotTriggeringFromInsideClass(): void
    {
        Deprecation::enableWithTriggerError();
        $baz = new Baz();
        $baz->usingOldFunc();
        $this->assertEquals(0, Deprecation::getUniqueTriggeredDeprecationsCount());
    }
    public function testDeprecationCalledFromOutsideInRoot(): void
    {
        Deprecation::enableWithTriggerError();
        $this->expectDeprecationWithIdentifier('https://github.com/doctrine/deprecations/4444');
        $this->expectErrorHandler(
            'this is deprecated foo 1234 (RootDeprecation.php:%d called by DeprecationTest.php:%d, https://github.com/doctrine/deprecations/4444, package doctrine/orm)',
            'https://github.com/doctrine/deprecations/4444'
        );
        RootDeprecation::run();
        $this->assertEquals(1, Deprecation::getUniqueTriggeredDeprecationsCount());
    }
}
PK     $([Vk*  *    .github/workflows/ci.ymlnu [        name: "Continuous Integration"
on:
  pull_request:
jobs:
  coding-standards:
    name: "Coding Standards"
    runs-on: "ubuntu-latest"
    strategy:
      matrix:
        php-version:
          - "7.4"
    steps:
      - name: "Checkout"
        uses: "actions/checkout@v2"
      - name: "Install PHP"
        uses: "shivammathur/setup-php@v2"
        with:
          coverage: "none"
          php-version: "${{ matrix.php-version }}"
          tools: "cs2pr"
      - name: "Cache dependencies installed with composer"
        uses: "actions/cache@v1"
        with:
          path: "~/.composer/cache"
          key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
          restore-keys: "php-${{ matrix.php-version }}-composer-locked-"
      - name: "Install dependencies with composer"
        run: "composer install --no-interaction --no-progress --no-suggest"
      - name: "Run squizlabs/php_codesniffer"
        run: "vendor/bin/phpcs -q --no-colors --report=checkstyle | cs2pr"
  phpunit:
    name: PHPUnit
    runs-on: ubuntu-latest
    strategy:
        matrix:
            php-version: ['7.1', '7.2', '7.3', '7.4']
    steps:
        - name: "Checkout"
          uses: "actions/checkout@v2"
        - name: Setup PHP
          uses: shivammathur/setup-php@v1
          with:
              php-version: ${{ matrix.php-version }}
        - name: "Install dependencies with composer"
          run: "composer install --no-interaction --no-progress --no-suggest"
        - name: PHPUnit
          run: "vendor/bin/phpunit"
PK     $([" }  }  
  composer.jsonnu [        {
    "name": "doctrine/deprecations",
    "type": "library",
    "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.",
    "homepage": "https://www.doctrine-project.org/",
    "license": "MIT",
    "require": {
        "php": "^7.1|^8.0"
    },
    "require-dev": {
        "phpunit/phpunit": "^7.0|^8.0|^9.0",
        "psr/log": "^1.0",
        "doctrine/coding-standard": "^6.0|^7.0|^8.0"
    },
    "suggest": {
        "psr/log": "Allows logging deprecations via PSR-3 logger implementation"
    },
    "autoload": {
        "psr-4": {"Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations"}
    },
    "autoload-dev": {
        "psr-4": {
            "DeprecationTests\\": "test_fixtures/src",
            "Doctrine\\Foo\\": "test_fixtures/vendor/doctrine/foo"
        }
    }
}
PK     $([/Gdz    8  lib/Doctrine/Deprecations/PHPUnit/VerifyDeprecations.phpnu [         */
    private $doctrineDeprecationsExpectations = [];
    /** @var array */
    private $doctrineNoDeprecationsExpectations = [];
    public function expectDeprecationWithIdentifier(string $identifier): void
    {
        $this->doctrineDeprecationsExpectations[$identifier] = Deprecation::getTriggeredDeprecations()[$identifier] ?? 0;
    }
    public function expectNoDeprecationWithIdentifier(string $identifier): void
    {
        $this->doctrineNoDeprecationsExpectations[$identifier] = Deprecation::getTriggeredDeprecations()[$identifier] ?? 0;
    }
    /**
     * @before
     */
    public function enableDeprecationTracking(): void
    {
        Deprecation::enableTrackingDeprecations();
    }
    /**
     * @after
     */
    public function verifyDeprecationsAreTriggered(): void
    {
        foreach ($this->doctrineDeprecationsExpectations as $identifier => $expectation) {
            $actualCount = Deprecation::getTriggeredDeprecations()[$identifier] ?? 0;
            $this->assertTrue(
                $actualCount > $expectation,
                sprintf(
                    "Expected deprecation with identifier '%s' was not triggered by code executed in test.",
                    $identifier
                )
            );
        }
        foreach ($this->doctrineNoDeprecationsExpectations as $identifier => $expectation) {
            $actualCount = Deprecation::getTriggeredDeprecations()[$identifier] ?? 0;
            $this->assertTrue(
                $actualCount === $expectation,
                sprintf(
                    "Expected deprecation with identifier '%s' was triggered by code executed in test, but expected not to.",
                    $identifier
                )
            );
        }
    }
}
PK     $([