Skip to content

Commit

Permalink
Merge pull request #376 from php-vcr/360-php-81-compatibility
Browse files Browse the repository at this point in the history
360 php 81 compatibility
  • Loading branch information
higidi committed Dec 15, 2022
2 parents d85a1c6 + 483c3aa commit 107a20d
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ jobs:

tests:
strategy:
fail-fast: true
fail-fast: false
matrix:
php:
- "8.0"
- "8.1"
stability:
- "stable"
dependencies:
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"symfony/event-dispatcher-contracts": "^1|^2|^3"
},
"require-dev": {
"guzzlehttp/guzzle": "^7.0",
"phpunit/phpunit": "^9.5.0",
"guzzlehttp/guzzle": "^7",
"phpunit/phpunit": "^9.5.10",
"mikey179/vfsstream": "^1.6.10",
"phpstan/phpstan": "^1",
"phpstan/phpstan-beberlei-assert": "^1",
Expand Down
14 changes: 12 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
version: "3.8"
services:
workspace:
workspace80:
tty: true
build:
context: resources/docker/workspace
context: resources/docker/workspace/8.0
args:
PUID: "${PUID:-1000}"
PGID: "${PGID:-1000}"
volumes:
- .:/var/www/html
- ~/.composer:/home/user/.composer
workspace81:
tty: true
build:
context: resources/docker/workspace/8.1
args:
PUID: "${PUID:-1000}"
PGID: "${PGID:-1000}"
Expand Down
File renamed without changes.
40 changes: 40 additions & 0 deletions resources/docker/workspace/8.1/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM php:8.1-cli-alpine

ARG PUID=1000
ARG PGID=1000

RUN apk add --no-cache --virtual .build-deps \
# for extensions
$PHPIZE_DEPS \
# for soap
libxml2-dev \
# for xdebug \
linux-headers \
&& \
apk add --no-cache \
bash \
# for soap
libxml2 \
# for composer
unzip \
&& \
docker-php-ext-install soap \
&& \
pecl install \
# pcov for coverage runs
pcov && docker-php-ext-enable pcov \
&& \
# for debugging
pecl install xdebug && docker-php-ext-enable xdebug \
&& \
apk del .build-deps

COPY --from=composer:2 /usr/bin/composer /usr/bin/composer

WORKDIR /var/www/html

# Add a non-root user to prevent files being created with root permissions on host machine.
RUN addgroup -g ${PGID} user && \
adduser -u ${PUID} -G user -D user

USER user
2 changes: 1 addition & 1 deletion src/VCR/CodeTransform/AbstractCodeTransform.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function register(): void
*
* @see http://www.php.net/manual/en/php-user-filter.filter.php
*/
public function filter($in, $out, &$consumed, $closing)
public function filter($in, $out, &$consumed, $closing): int
{
while ($bucket = stream_bucket_make_writeable($in)) {
$bucket->data = $this->transformCode($bucket->data);
Expand Down
2 changes: 1 addition & 1 deletion src/VCR/Storage/AbstractStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function __construct(string $cassettePath, string $cassetteName, string $
*
* @return array<string,mixed>|null parsed current record
*/
public function current()
public function current(): ?array
{
return $this->current;
}
Expand Down
4 changes: 1 addition & 3 deletions src/VCR/Storage/Blackhole.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ public function key(): int
throw new \BadMethodCallException('Not implemented');
}

/** @return array<mixed>|null */
public function next(): ?array
public function next(): void
{
return null;
}

public function rewind(): void
Expand Down
2 changes: 1 addition & 1 deletion src/VCR/Storage/Yaml.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function rewind(): void
$this->position = 0;
}

public function valid()
public function valid(): bool
{
if (null === $this->current) {
$this->next();
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Storage/AbstractStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function next(): void
{
}

public function valid()
public function valid(): bool
{
return (bool) $this->position;
}
Expand Down
5 changes: 4 additions & 1 deletion tests/Unit/Storage/BlackholeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ public function testStoreRecordingIsCallable(): void
]);
}

/**
* @doesNotPerformAssertions
*/
public function testNextIsCallable(): void
{
$this->assertNull($this->storage->next());
$this->storage->next();
}

/**
Expand Down

0 comments on commit 107a20d

Please sign in to comment.