Skip to content

Commit

Permalink
Merge pull request #414 from doctrine/1.13.x
Browse files Browse the repository at this point in the history
Merge 1.13.x into 1.14.x
  • Loading branch information
greg0ire committed May 16, 2021
2 parents 03cb212 + e6e7b7d commit 5e802cc
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 185 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@

name: "Coding Standards"

on: ["pull_request", "push"]
on:
pull_request:
branches:
- "*.x"
push:
branches:
- "*.x"

jobs:
coding-standards:
Expand All @@ -26,6 +32,8 @@ jobs:

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"
with:
dependency-versions: "highest"

# https://github.com/doctrine/.github/issues/3
- name: "Run PHP_CodeSniffer"
Expand Down
55 changes: 47 additions & 8 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ on:
pull_request:
branches:
- "*.x"
- "master"
push:
branches:
- "*.x"
- "master"

env:
fail-fast: true

jobs:
phpunit:
Expand All @@ -23,29 +24,67 @@ jobs:
- "7.3"
- "7.4"
- "8.0"
deps:
dependencies:
- "highest"
include:
- deps: "lowest"
php-version: "7.2"
- php-version: "7.2"
dependencies: "lowest"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"
with:
fetch-depth: 2

- name: "Install PHP"
- name: "Install PHP with PCOV"
uses: "shivammathur/setup-php@v2"
if: "${{ matrix.php-version != '7.1' }}"
with:
php-version: "${{ matrix.php-version }}"
coverage: "pcov"
ini-values: "zend.assertions=1"

- name: "Install PHP with XDebug"
uses: "shivammathur/setup-php@v2"
if: "${{ matrix.php-version == '7.1' }}"
with:
php-version: "${{ matrix.php-version }}"
coverage: "xdebug"
ini-values: "zend.assertions=1"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"
with:
dependency-versions: "${{ matrix.deps }}"
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "--prefer-dist"

- name: "Run PHPUnit"
run: "vendor/bin/phpunit"
run: "vendor/bin/phpunit --coverage-clover=coverage.xml"

- name: "Upload coverage file"
uses: "actions/upload-artifact@v2"
with:
name: "phpunit-${{ matrix.php-version }}.coverage"
path: "coverage.xml"

upload_coverage:
name: "Upload coverage to Codecov"
runs-on: "ubuntu-20.04"
needs:
- "phpunit"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"
with:
fetch-depth: 2

- name: "Download coverage files"
uses: "actions/download-artifact@v2"
with:
path: "reports"

- name: "Upload to Codecov"
uses: "codecov/codecov-action@v1"
with:
directory: "reports"
8 changes: 4 additions & 4 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@

name: "Static Analysis"

on:
pull_request:
branches:
- "*.x"
- "master"
push:
branches:
- "*.x"
- "master"

jobs:
static-analysis-phpstan:
Expand All @@ -29,10 +28,11 @@ jobs:
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
tools: "cs2pr"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"
with:
dependency-versions: "highest"

- name: "Run a static analysis with phpstan/phpstan"
run: "vendor/bin/phpstan analyse -l 3 -c phpstan.neon --error-format=checkstyle lib/ tests/ | cs2pr"
run: "vendor/bin/phpstan analyse"
162 changes: 0 additions & 162 deletions CHANGELOG.md

This file was deleted.

4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,3 @@ See the [doctrine-project website](https://www.doctrine-project.org/projects/doc

When making a pull request, make sure your changes follow the
[Coding Standard Guidelines](https://www.doctrine-project.org/projects/doctrine-coding-standard/en/current/reference/index.html#introduction).

## Changelog

See [CHANGELOG.md](CHANGELOG.md).
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"doctrine/cache": "^1.11 || ^2.0",
"doctrine/coding-standard": "^6.0 || ^8.1",
"phpstan/phpstan": "^0.12.20",
"phpunit/phpunit": "^7.5 || ^9.1.5",
"phpunit/phpunit": "^7.5 || ^8.0 || ^9.1.5",
"symfony/cache": "^4.4 || ^5.2"
},
"config": {
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Common/Annotations/PsrCachedReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private function fetchFromCache(
$cacheKey = rawurlencode($cacheKey);

$item = $this->cache->getItem($cacheKey);
if (! $item->isHit() || ($this->debug && ! $this->refresh($cacheKey, $class))) {
if (($this->debug && ! $this->refresh($cacheKey, $class)) || ! $item->isHit()) {
$this->cache->save($item->set($this->delegate->{$method}($reflector)));
}

Expand Down
13 changes: 9 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
parameters:
level: 3
paths:
- lib
- tests
excludes_analyse:
- %currentWorkingDirectory%/tests/*/Fixtures/*
- %currentWorkingDirectory%/tests/Doctrine/Tests/Common/Annotations/ReservedKeywordsClasses.php
- %currentWorkingDirectory%/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Entity.php
- %currentWorkingDirectory%/tests/Doctrine/Tests/DoctrineTestCase.php
- tests/*/Fixtures/*
- tests/Doctrine/Tests/Common/Annotations/ReservedKeywordsClasses.php
- tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Entity.php
- tests/Doctrine/Tests/DoctrineTestCase.php
- tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php
polluteScopeWithLoopInitialAssignments: true
ignoreErrors:
- '#Instantiated class Doctrine_Tests_Common_Annotations_Fixtures_ClassNoNamespaceNoComment not found#'
Expand Down
18 changes: 18 additions & 0 deletions tests/Doctrine/Tests/Common/Annotations/PsrCachedReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Doctrine\Common\Annotations\Reader;
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
use Doctrine\Tests\Common\Annotations\Fixtures\ClassThatUsesTraitThatUsesAnotherTraitWithMethods;
use Doctrine\Tests\Common\Annotations\Fixtures\ClassWithClassAnnotationOnly;
use Psr\Cache\CacheItemInterface;
use Psr\Cache\CacheItemPoolInterface;
use ReflectionClass;
Expand Down Expand Up @@ -202,6 +203,23 @@ public function testAvoidCallingFilemtimeTooMuch(): void
$this->assertEquals([$route2], $reader->getMethodAnnotations(new ReflectionMethod($className, 'method2')));
}

public function testReaderIsNotHitIfCacheIsFresh(): void
{
$cache = new ArrayAdapter();

$readAnnotations = (new PsrCachedReader(new AnnotationReader(), $cache, true))
->getClassAnnotations(new ReflectionClass(ClassWithClassAnnotationOnly::class));

$throwingReader = $this->createMock(Reader::class);
$throwingReader->expects(self::never())->method(self::anything());

self::assertEquals(
$readAnnotations,
(new PsrCachedReader($throwingReader, $cache, true))
->getClassAnnotations(new ReflectionClass(ClassWithClassAnnotationOnly::class))
);
}

protected function doTestCacheStale(string $className, int $lastCacheModification): PsrCachedReader
{
$cacheKey = rawurlencode($className);
Expand Down

0 comments on commit 5e802cc

Please sign in to comment.