Skip to content

Commit

Permalink
Require PHP v8.1 (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloKowalczyk authored Jul 8, 2024
1 parent 6a53ee8 commit e42beea
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 166 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

test:
# With APCu enabled
@docker-compose exec -T -w /var/www/bundle --user=www-data apache php -d apc.enable_cli=1 vendor/bin/phpunit
@docker compose exec -T -w /var/www/bundle --user=www-data apache php -d apc.enable_cli=1 vendor/bin/phpunit
# With APCu disabled
@docker-compose exec -T -w /var/www/bundle --user=www-data apache php -d apc.enable_cli=0 vendor/bin/phpunit
@docker compose exec -T -w /var/www/bundle --user=www-data apache php -d apc.enable_cli=0 vendor/bin/phpunit
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
"preferred-install": "dist"
},
"require": {
"php": ">=8.0",
"php": ">=8.1",
"symfony/config": "^5.4 || ^6.4 || ^7.0",
"symfony/dependency-injection": "^5.4 || ^6.4 || ^7.0",
"symfony/http-kernel": "^5.4 || ^6.4 || ^7.0"
},
"require-dev": {
"phpunit/phpunit": "^9.4"
"phpunit/phpunit": "^10.5"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.6'

services:
apache:
build:
Expand Down
28 changes: 13 additions & 15 deletions docker/apache/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
FROM php:8.0.27-apache
FROM php:8.1.29-apache

ENV APACHE_DOCUMENT_ROOT /var/www/html/public

RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf

RUN apt-get update && \
apt-get -y install unzip && \
apt-get -y autoremove && \
apt-get -y autoclean && \
apt-get -y clean

RUN a2enmod rewrite
RUN pecl install apcu-5.1.17 && \
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf && \
sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf && \
apt update && \
apt -y install unzip && \
apt -y autoremove && \
apt -y autoclean && \
apt -y clean && \
a2enmod rewrite && \
pecl install apcu-5.1.23 && \
docker-php-ext-enable \
opcache \
apcu

COPY --from=composer:2.5.1 /usr/bin/composer /usr/bin/composer
COPY --from=composer:2.7.7 /usr/bin/composer /usr/bin/composer

RUN usermod -u 1000 www-data && groupmod -g 1000 www-data
ENV COMPOSER_HOME /var/www/.composer
RUN mkdir -p /var/www/.composer && \
RUN usermod -u 1000 www-data && groupmod -g 1000 www-data && \
mkdir -p /var/www/.composer && \
chown -R www-data /var/www/.composer
5 changes: 3 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd"
verbose="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
cacheResult="false"
colors="true"
cacheDirectory=".phpunit.cache"
>
<testsuites>
<testsuite name="Unit test">
Expand Down
2 changes: 1 addition & 1 deletion src/Application/Size.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ final class Size
{
private const MEGABYTE_IN_BYTES = 1024 ** 2;

private function __construct(private int $sizeInBytes)
private function __construct(private readonly int $sizeInBytes)
{
}

Expand Down
42 changes: 6 additions & 36 deletions src/Application/StatsProvider/ApcuStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,12 @@
final class ApcuStats
{
public function __construct(
private bool $enabled,
private int $slotsSize,
private int $slotsUsage,
private Size $memorySize,
private Size $memoryUsage,
private string $memoryType,
public readonly bool $enabled,
public readonly int $slotsSize,
public readonly int $slotsUsage,
public readonly Size $memorySize,
public readonly Size $memoryUsage,
public readonly string $memoryType,
) {
}

public function enabled(): bool
{
return $this->enabled;
}

public function slotsSize(): int
{
return $this->slotsSize;
}

public function slotsUsage(): int
{
return $this->slotsUsage;
}

public function memorySize(): Size
{
return $this->memorySize;
}

public function memoryUsage(): Size
{
return $this->memoryUsage;
}

public function memoryType(): string
{
return $this->memoryType;
}
}
21 changes: 3 additions & 18 deletions src/Application/StatsProvider/JitStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,13 @@

final class JitStats
{
private Size $bufferUsage;
public readonly Size $bufferUsage;

public function __construct(
private bool $enabled,
private Size $bufferSize,
public readonly bool $enabled,
public readonly Size $bufferSize,
Size $bufferFree,
) {
$this->bufferUsage = $bufferSize->subtract($bufferFree);
}

public function enabled(): bool
{
return $this->enabled;
}

public function bufferSize(): Size
{
return $this->bufferSize;
}

public function bufferUsage(): Size
{
return $this->bufferUsage;
}
}
63 changes: 9 additions & 54 deletions src/Application/StatsProvider/OpcacheStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,60 +9,15 @@
final class OpcacheStats
{
public function __construct(
private bool $enabled,
private Size $size,
private Size $usage,
private Size $internedStringsSize,
private Size $internedStringsUsage,
private int $internedStringsNumber,
private int $scriptSlotsSize,
private int $scriptSlotsUsage,
private float $hitRatio
public readonly bool $enabled,
public readonly Size $size,
public readonly Size $usage,
public readonly Size $internedStringsSize,
public readonly Size $internedStringsUsage,
public readonly int $internedStringsNumber,
public readonly int $scriptSlotsSize,
public readonly int $scriptSlotsUsage,
public readonly float $hitRatio
) {
}

public function enabled(): bool
{
return $this->enabled;
}

public function size(): Size
{
return $this->size;
}

public function usage(): Size
{
return $this->usage;
}

public function internedStringsSize(): Size
{
return $this->internedStringsSize;
}

public function internedStringsUsage(): Size
{
return $this->internedStringsUsage;
}

public function internedStringsNumber(): int
{
return $this->internedStringsNumber;
}

public function scriptSlotsSize(): int
{
return $this->scriptSlotsSize;
}

public function scriptSlotsUsage(): int
{
return $this->scriptSlotsUsage;
}

public function hitRatio(): float
{
return $this->hitRatio;
}
}
21 changes: 3 additions & 18 deletions src/Application/StatsProvider/RealPathStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,9 @@
final class RealPathStats
{
public function __construct(
private bool $enabled,
private Size $size,
private Size $usage,
public readonly bool $enabled,
public readonly Size $size,
public readonly Size $usage,
) {
}

public function enabled(): bool
{
return $this->enabled;
}

public function size(): Size
{
return $this->size;
}

public function usage(): Size
{
return $this->usage;
}
}
8 changes: 4 additions & 4 deletions src/DataCollector/CacheStatsDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ final class CacheStatsDataCollector extends DataCollector
private const JIT_KEY = 'jit';

public function __construct(
private RealPathProvider $realPathProvider,
private OpcacheProvider $opcacheProvider,
private ApcuProvider $apcuProvider,
private JitProvider $jitProvider
private readonly RealPathProvider $realPathProvider,
private readonly OpcacheProvider $opcacheProvider,
private readonly ApcuProvider $apcuProvider,
private readonly JitProvider $jitProvider
) {
}

Expand Down
24 changes: 12 additions & 12 deletions tests/Unit/Application/StatsProvider/ApcuProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ public function test_apcu_provider_works_with_extension_enabled(): void

$apcuProvider = $this->createApcuProvider();
$apcuStatus = $apcuProvider->provide();
$memorySize = $apcuStatus->memorySize();
$memoryUsage = $apcuStatus->memoryUsage();
$memorySize = $apcuStatus->memorySize;
$memoryUsage = $apcuStatus->memoryUsage;

$this->assertTrue($apcuStatus->enabled());
$this->assertTrue($apcuStatus->enabled);
$this->assertGreaterThan(0, $memorySize->asBytes());
$this->assertGreaterThan(0, $memoryUsage->asBytes());
$this->assertGreaterThan(0, $apcuStatus->slotsSize());
$this->assertGreaterThanOrEqual(0, $apcuStatus->slotsUsage());
$this->assertNotEmpty($apcuStatus->memoryType());
$this->assertGreaterThan(0, $apcuStatus->slotsSize);
$this->assertGreaterThanOrEqual(0, $apcuStatus->slotsUsage);
$this->assertNotEmpty($apcuStatus->memoryType);
}

public function test_apcu_provider_works_with_extension_disabled(): void
Expand All @@ -36,15 +36,15 @@ public function test_apcu_provider_works_with_extension_disabled(): void

$apcuProvider = $this->createApcuProvider();
$apcuStatus = $apcuProvider->provide();
$memorySize = $apcuStatus->memorySize();
$memoryUsage = $apcuStatus->memoryUsage();
$memorySize = $apcuStatus->memorySize;
$memoryUsage = $apcuStatus->memoryUsage;

$this->assertFalse($apcuStatus->enabled());
$this->assertFalse($apcuStatus->enabled);
$this->assertSame(0, $memorySize->asBytes());
$this->assertSame(0, $memoryUsage->asBytes());
$this->assertSame(0, $apcuStatus->slotsSize());
$this->assertSame(0, $apcuStatus->slotsUsage());
$this->assertEmpty($apcuStatus->memoryType());
$this->assertSame(0, $apcuStatus->slotsSize);
$this->assertSame(0, $apcuStatus->slotsUsage);
$this->assertEmpty($apcuStatus->memoryType);
}

private function isApcuEnabled(): bool
Expand Down

0 comments on commit e42beea

Please sign in to comment.