Skip to content

Commit

Permalink
Bump minimal PHP version to 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
antonkomarev committed Dec 10, 2023
1 parent 24f74a4 commit 70c43d9
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 110 deletions.
2 changes: 1 addition & 1 deletion .docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ----------------------
# The FPM base container
# ----------------------
FROM php:7.4-fpm-alpine AS dev
FROM php:8.1-cli-alpine AS dev

RUN apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS
Expand Down
85 changes: 0 additions & 85 deletions .docker/php/www.conf

This file was deleted.

4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
}
},
"require": {
"php": "^7.4|^8.0",
"php": "^8.1",
"ext-mbstring": "*"
},
"require-dev": {
"phpunit/phpunit": "^9.0|^10.0"
"phpunit/phpunit": "^10.0"
},
"config": {
"sort-packages": true
Expand Down
3 changes: 1 addition & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ services:
build:
context: ./
dockerfile: ./.docker/php/Dockerfile
restart: unless-stopped
tty: true
working_dir: /app
volumes:
- ./:/app
- ./.docker/php/www.conf:/usr/local/etc/php-fpm.d/www.conf:ro
16 changes: 6 additions & 10 deletions src/Character.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@

final class Character
{
private int $codePoint;

private function __construct(
int $codePoint
public readonly int $codePoint,
) {
$this->codePoint = $codePoint;

if ($codePoint < 0x0000 || $codePoint > 0x10FFFF) {
throw new \OutOfRangeException(
"Character code point value `$codePoint` is out of range",
Expand All @@ -30,7 +26,7 @@ private function __construct(
}

public static function of(
string $string
string $string,
): self {
if (mb_strlen($string) !== 1) {
throw new \InvalidArgumentException(
Expand All @@ -44,15 +40,15 @@ public static function of(
}

public static function ofDecimal(
int $decimal
int $decimal,
): self {
return new self(
$decimal,
);
}

public static function ofHexadecimal(
string $hexadecimal
string $hexadecimal,
): self {
if (preg_match('#^U\+[0-9A-Fa-f]{4,}$#', $hexadecimal) !== 1) {
throw new \InvalidArgumentException(
Expand All @@ -66,7 +62,7 @@ public static function ofHexadecimal(
}

public static function ofHtmlEntity(
string $htmlEntity
string $htmlEntity,
): self {
return self::of(
html_entity_decode(
Expand All @@ -77,7 +73,7 @@ public static function ofHtmlEntity(
}

public static function ofXmlEntity(
string $xmlEntity
string $xmlEntity,
): self {
return self::of(
html_entity_decode(
Expand Down
13 changes: 6 additions & 7 deletions src/UnicodeString.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,27 @@

final class UnicodeString
{
private array $characterList;

/**
* @param list<Character> $characterList
*/
private function __construct(
array $characterList
public readonly array $characterList,
) {
$this->characterList = $characterList;
}

/**
* @param list<Character> $characterList
*/
public static function ofCharacterList(
array $characterList
array $characterList,
): self {

return new self(
$characterList,
);
}

public static function of(
string $string
string $string,
): self {
$charList = preg_split('//u', $string, -1, PREG_SPLIT_NO_EMPTY);

Expand Down
6 changes: 3 additions & 3 deletions test/Unit/UnicodeStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function testBasicChars(): void

$text = UnicodeString::of($string);

$characterList = $text->characterList();
$characterList = $text->characterList;
$this->assertSame('M', strval($characterList[0]));
$this->assertSame('a', strval($characterList[1]));
$this->assertSame('r', strval($characterList[2]));
Expand Down Expand Up @@ -52,7 +52,7 @@ public function testCombiningChars(): void

$text = UnicodeString::of($string);

$characterList = $text->characterList();
$characterList = $text->characterList;
$this->assertSame('Á̀', strval($characterList[0]));
$this->assertSame('b́', strval($characterList[1]));
$this->assertSame('ć', strval($characterList[2]));
Expand All @@ -67,7 +67,7 @@ public function testEmojiCombiningChars(): void

$text = UnicodeString::of($string);

$characterList = $text->characterList();
$characterList = $text->characterList;
$this->assertSame('👨', strval($characterList[0]));
$this->assertSame('👩', strval($characterList[1]));
$this->assertSame('👧', strval($characterList[2]));
Expand Down

0 comments on commit 70c43d9

Please sign in to comment.