Set minimum version to PHP 7.3

This commit is contained in:
PJ Dietz 2020-08-16 11:54:28 -04:00
parent 95c3be85c9
commit 8b467193d7
7 changed files with 64 additions and 23 deletions

View File

@ -12,7 +12,7 @@
} }
], ],
"require": { "require": {
"php": ">=7.2", "php": ">=7.3",
"psr/http-factory": "~1.0", "psr/http-factory": "~1.0",
"psr/http-message": "~1.0", "psr/http-message": "~1.0",
"psr/http-server-handler": "~1.0", "psr/http-server-handler": "~1.0",

4
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "041c27e394aba3e5c3bf6cbe8751f845", "content-hash": "bc05598d49e39b0082767d94ecb5bd4d",
"packages": [ "packages": [
{ {
"name": "psr/http-factory", "name": "psr/http-factory",
@ -4652,7 +4652,7 @@
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,
"platform": { "platform": {
"php": ">=7.2" "php": ">=7.3"
}, },
"platform-dev": [], "platform-dev": [],
"plugin-api-version": "1.1.0" "plugin-api-version": "1.1.0"

View File

@ -25,8 +25,3 @@ services:
volumes: volumes:
- .:/usr/local/src/wellrested - .:/usr/local/src/wellrested
- ./docker/nginx/site.conf:/etc/nginx/conf.d/default.conf - ./docker/nginx/site.conf:/etc/nginx/conf.d/default.conf
php-fpm:
image: php:7.4-fpm
volumes:
- .:/usr/local/src/wellrested

View File

@ -26,7 +26,7 @@ server {
# PHP # PHP
location ~ \.php$ { location ~ \.php$ {
include fastcgi_params; include fastcgi_params;
fastcgi_pass php-fpm:9000; fastcgi_pass php:9000;
fastcgi_index index.php; fastcgi_index index.php;
fastcgi_buffers 8 8k; fastcgi_buffers 8 8k;
fastcgi_buffer_size 16k; fastcgi_buffer_size 16k;

View File

@ -1,4 +1,4 @@
FROM php:7.4-cli FROM php:7.3-fpm
RUN DEBIAN_FRONTEND=noninteractive \ RUN DEBIAN_FRONTEND=noninteractive \
apt-get update && \ apt-get update && \
@ -27,20 +27,18 @@ RUN mkdir /usr/local/src/wellrested && \
chown -R www-data:www-data /usr/local/src/wellrested && \ chown -R www-data:www-data /usr/local/src/wellrested && \
chown -R www-data:www-data /var/www chown -R www-data:www-data /var/www
COPY ./src /usr/local/src/wellrested/src # Copy entrypoint script
COPY ./test /usr/local/src/wellrested/test COPY docker/php/entrypoint /usr/local/bin
COPY ./composer.* /usr/local/src/wellrested/
COPY ./phpunit.xml.dist /usr/local/src/wellrested/
# Add symlinks for php-cs-fixer, phpunit, and psalm for easier running # Add symlinks for php-cs-fixer, phpunit, and psalm for easier running
RUN ln -s /usr/local/src/wellrested/vendor/bin/php-cs-fixer /usr/local/bin/php-cs-fixer RUN ln -s /usr/local/src/wellrested/vendor/bin/php-cs-fixer /usr/local/bin/php-cs-fixer
RUN ln -s /usr/local/src/wellrested/vendor/bin/phpunit /usr/local/bin/phpunit RUN ln -s /usr/local/src/wellrested/vendor/bin/phpunit /usr/local/bin/phpunit
RUN ln -s /usr/local/src/wellrested/vendor/bin/psalm /usr/local/bin/psalm RUN ln -s /usr/local/src/wellrested/vendor/bin/psalm /usr/local/bin/psalm
ENTRYPOINT ["entrypoint"]
CMD ["php-fpm"]
WORKDIR /usr/local/src/wellrested WORKDIR /usr/local/src/wellrested
USER www-data USER www-data
ENTRYPOINT ["dumb-init", "--"]
RUN composer install

10
docker/php/entrypoint Executable file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env bash
# Run CLI commands with dumb-init to allow better signal handling.
# Run PHP-FPM as PID 1.
# https://engineeringblog.yelp.com/2016/01/dumb-init-an-init-for-docker.html
if [ "$1" == 'php-fpm' ] ; then
exec php-fpm
else
exec dumb-init -- "$@"
fi

View File

@ -15,8 +15,9 @@ class StreamTest extends TestCase
protected function setUp(): void protected function setUp(): void
{ {
$this->resource = fopen('php://memory', 'w+'); $this->resource = fopen('php://memory', 'w+');
$this->resourceDevNull = fopen('/dev/null', 'r'); $this->resourceDevNull = fopen('/dev/zero', 'r');
fwrite($this->resource, $this->content); fwrite($this->resource, $this->content);
StreamHelper::$fail = false;
} }
protected function tearDown(): void protected function tearDown(): void
@ -105,7 +106,8 @@ class StreamTest extends TestCase
public function testTellThrowsRuntimeExceptionWhenUnableToReadStreamPosition(): void public function testTellThrowsRuntimeExceptionWhenUnableToReadStreamPosition(): void
{ {
$stream = new Stream($this->resourceDevNull); StreamHelper::$fail = true;
$stream = new Stream($this->resource);
$this->expectException(RuntimeException::class); $this->expectException(RuntimeException::class);
$stream->tell(); $stream->tell();
} }
@ -135,7 +137,8 @@ class StreamTest extends TestCase
public function testSeekThrowsRuntimeExceptionWhenUnableToSeek(): void public function testSeekThrowsRuntimeExceptionWhenUnableToSeek(): void
{ {
$stream = new Stream($this->resourceDevNull); StreamHelper::$fail = true;
$stream = new Stream($this->resource);
$this->expectException(RuntimeException::class); $this->expectException(RuntimeException::class);
$stream->seek(10); $stream->seek(10);
} }
@ -150,7 +153,8 @@ class StreamTest extends TestCase
public function testRewindThrowsRuntimeExceptionWhenUnableToRewind(): void public function testRewindThrowsRuntimeExceptionWhenUnableToRewind(): void
{ {
$stream = new Stream($this->resourceDevNull); StreamHelper::$fail = true;
$stream = new Stream($this->resource);
$this->expectException(RuntimeException::class); $this->expectException(RuntimeException::class);
$stream->rewind(); $stream->rewind();
} }
@ -384,3 +388,37 @@ class StreamTest extends TestCase
$this->assertNull($stream->getMetadata()); $this->assertNull($stream->getMetadata());
} }
} }
// -----------------------------------------------------------------------------
// Declare functions in this namespace so the class under test will use these
// instead of the internal global functions during testing.
class StreamHelper
{
public static $fail = false;
}
function fseek($resource, $offset, $whence = SEEK_SET)
{
if (StreamHelper::$fail) {
return -1;
}
return \fseek($resource, $offset, $whence);
}
function ftell($resource)
{
if (StreamHelper::$fail) {
return false;
}
return \ftell($resource);
}
function rewind($resource)
{
if (StreamHelper::$fail) {
return false;
}
return \rewind($resource);
}