Skip to content

Commit d2b0090

Browse files
committed
Merge branch 'master' into 200
2 parents ea27a70 + af7dd49 commit d2b0090

File tree

10 files changed

+123
-43
lines changed

10 files changed

+123
-43
lines changed

.appveyor.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ environment:
33
matrix:
44

55
# Specify matrix item for your app
6-
- PHP_VERSION: 8.0
6+
- PHP_VERSION: 8.1
77
VC_VERSION: 16
88
BUILD_TYPE: nts-Win32
99
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
@@ -27,10 +27,12 @@ install:
2727
- ps: InstallPhp $Env:PHP_VERSION $Env:BUILD_TYPE $Env:VC_VERSION $Env:PLATFORM
2828
- ps: InstallPhpDevPack $Env:PHP_VERSION $Env:BUILD_TYPE $Env:VC_VERSION $Env:PLATFORM
2929
# An example to install PECL extension
30+
# NOTE If 3.1.3 is not enough for PHP >= 8.2 visit
31+
# https://pecl.php.net/package/xdebug/3.4.5/windows
3032
- ps: >-
3133
InstallPeclExtension `
3234
-Name xdebug `
33-
-Version 3.0.3 `
35+
-Version 3.1.3 `
3436
-PhpVersion $Env:PHP_VERSION `
3537
-BuildType $Env:BUILD_TYPE `
3638
-VC $Env:VC_VERSION `

.github/workflows/php.yml

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,54 @@
1-
name: PHP Composer
1+
name: PHP Composer CI
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
66
pull_request:
7-
branches: [ master ]
7+
branches: [master]
88

99
jobs:
1010
build:
11-
1211
runs-on: ubuntu-latest
1312

1413
steps:
15-
- uses: actions/checkout@v2
16-
17-
- uses: php-actions/composer@v5
18-
19-
- name: PHPUnit Tests
20-
uses: php-actions/phpunit@v2
21-
env:
22-
TEST_NAME: AllTests
23-
with:
24-
bootstrap: vendor/autoload.php
25-
configuration: phpunit.xml
26-
args: --coverage-text
27-
28-
- name: Infection analysis
29-
env:
30-
INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }}
31-
run: XDEBUG_MODE=coverage ./vendor/bin/infection --min-msi=90 --min-covered-msi=90 --threads=4 --configuration=./infection.json.dist
32-
33-
- name: Create PHPUnit coverage files
34-
run: "XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-clover=coverage.xml"
35-
- name: Upload coverage to Codecov
36-
uses: codecov/codecov-action@v1
37-
with:
38-
token: ${{ secrets.CODECOV_TOKEN }}
39-
file: coverage.xml
40-
flags: tests
41-
name: codecov-umbrella
42-
fail_ci_if_error: true
43-
44-
- name: Check minimum coverage
45-
run: "vendor/bin/coverage-check coverage.xml 100 --only-percentage"
46-
47-
- name: PHPStan analysis
48-
run: ./vendor/bin/phpstan analyse
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Setup PHP with Composer, Xdebug & tools
18+
uses: shivammathur/setup-php@v2
19+
with:
20+
php-version: '8.1'
21+
coverage: xdebug
22+
tools: composer
23+
24+
- name: Install dependencies
25+
run: composer install --no-interaction --prefer-dist
26+
27+
- name: Run PHPUnit tests with coverage
28+
run: vendor/bin/phpunit --configuration=phpunit.xml --coverage-text
29+
30+
- name: Infection analysis
31+
env:
32+
INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }}
33+
run: |
34+
XDEBUG_MODE=coverage ./vendor/bin/infection \
35+
--min-msi=90 --min-covered-msi=90 --threads=4 \
36+
--configuration=./infection.json.dist
37+
38+
- name: Create PHPUnit coverage report
39+
run: XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-clover=coverage.xml
40+
41+
- name: Upload coverage to Codecov
42+
uses: codecov/codecov-action@v5
43+
with:
44+
token: ${{ secrets.CODECOV_TOKEN }}
45+
file: coverage.xml
46+
flags: tests
47+
name: codecov-umbrella
48+
fail_ci_if_error: true
49+
50+
- name: Check minimum coverage
51+
run: ./vendor/bin/coverage-check coverage.xml 100 --only-percentage
52+
53+
- name: PHPStan analysis
54+
run: ./vendor/bin/phpstan analyse

.scrutinizer.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build:
2+
image: default-bionic
3+
environment:
4+
php: 8.1.2

Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM php:8.1-cli
2+
3+
RUN apt-get update && apt-get install -y \
4+
git \
5+
libicu-dev \
6+
libxml2-dev \
7+
libzip-dev \
8+
unzip \
9+
wget \
10+
zip \
11+
&& docker-php-ext-install zip intl \
12+
&& pecl install xdebug \
13+
&& docker-php-ext-enable xdebug \
14+
&& rm -rf /var/lib/apt/lists/*
15+
16+
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
17+
18+
WORKDIR /app
19+
20+
COPY . .
21+
22+
RUN composer install --no-interaction --prefer-dist
23+
24+
ENV XDEBUG_MODE=coverage
25+
26+
CMD ["bash"]

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,24 @@ $numerals = new SavingIterator(
9999
);
100100
```
101101

102+
## How to run tests
103+
104+
First, install [Docker](https://www.docker.com/). After that, run:
105+
106+
```bash
107+
docker-compose build
108+
109+
docker-compose run --rm php bash
110+
```
111+
112+
After you start the container, install dependencies and run tests:
113+
114+
```bash
115+
composer install
116+
117+
vendor/bin/phpunit tests
118+
```
119+
102120
## How to contribute
103121

104122
[Fork this repository](https://docs.github.com/en/get-started/quickstart/fork-a-repo), then create a folder for it and install [Composer](https://getcomposer.org/download/) if you do not have it.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "maxgoryunov/saving-iterator",
33
"description": "True Caching Iterator for PHP",
44
"require": {
5-
"php": ">=8.0"
5+
"php": ">=8.1"
66
},
77
"require-dev": {
88
"phpstan/phpstan": "^1.4.6",

docker-compose.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: "3.9"
2+
3+
services:
4+
php:
5+
build: .
6+
container_name: php-library-test
7+
volumes:
8+
- .:/app
9+
environment:
10+
INFECTION_BADGE_API_KEY: ${INFECTION_BADGE_API_KEY}
11+
CODECOV_TOKEN: ${CODECOV_TOKEN}
12+
working_dir: /app

phpstan.neon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ parameters:
44
- src
55
- fakes
66
- tests
7-
includes:
8-
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
7+
# includes:
8+
# - vendor/phpstan/phpstan/conf/bleedingEdge.neon

src/SavingIterator.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,18 @@ public function __construct(
2828
/** @phpstan-ignore-next-line */
2929
new ContextVeil(
3030
$target,
31+
/**
32+
* @todo #196:60min There are phpstan issues with
33+
* ClosureReaction here and in ContextVeilTest. Now they are
34+
* fixed by ignore-line stubs but need to be fixed according
35+
* to phpstan ruleset.
36+
*/
37+
/** @phpstan-ignore-next-line */
3138
new ClosureReaction(
39+
/**
40+
* @phpstan-param AddingIterator<TKey, TValue> $stored
41+
* Iterator for value storage.
42+
*/
3243
fn (AddingIterator $stored) => (new ValidTernary(
3344
$origin,
3445
function (Iterator $source) use ($stored) {

tests/src/ContextVeilTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function testReturnsOriginMethodResults(): void
3232
$origin = new ArrayIterator([23, 6, 26, 8, 4, 76, 94, 5]);
3333
$veil = new ContextVeil(
3434
$origin,
35+
/** @phpstan-ignore-next-line */
3536
new ClosureReaction(fn (Iterator $iterator, string $method) => $iterator)
3637
);
3738
$this->assertEquals(

0 commit comments

Comments
 (0)