Skip to content

Commit

Permalink
Merge 5271d69 into 19b6402
Browse files Browse the repository at this point in the history
  • Loading branch information
azjezz committed Nov 1, 2021
2 parents 19b6402 + 5271d69 commit 810b236
Show file tree
Hide file tree
Showing 13 changed files with 109 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
php-version:
- "8.0"
- "8.1"
operating-system:
- "ubuntu-latest"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: "installing PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.0"
php-version: "8.1"
ini-values: memory_limit=-1
tools: composer:v2, cs2pr
extensions: bcmath, mbstring, intl, sodium, json
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: "installing PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.0"
php-version: "8.1"
ini-values: memory_limit=-1
tools: composer:v2, cs2pr
extensions: bcmath, mbstring, intl, sodium, json
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/documentation-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: "installing PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.0"
php-version: "8.1"
ini-values: memory_limit=-1
tools: composer:v2, cs2pr
extensions: bcmath, mbstring, intl, sodium, json
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/security-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: "installing PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.0"
php-version: "8.1"
ini-values: memory_limit=-1
tools: composer:v2, cs2pr
extensions: bcmath, mbstring, intl, sodium, json
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: "installing PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.0"
php-version: "8.1"
ini-values: memory_limit=-1
tools: composer:v2, cs2pr
extensions: bcmath, mbstring, intl, sodium, json
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
php-version:
- "8.0"
- "8.1"
operating-system:
- "macos-latest"
- "ubuntu-latest"
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ install: ## inst
composer install

coding-standard-fix: ## apply automated coding standard fixes
./vendor/bin/php-cs-fixer fix --config=config/.php_cs.dist.php
PHP_CS_FIXER_IGNORE_ENV=1 ./vendor/bin/php-cs-fixer fix --config=config/.php_cs.dist.php
./vendor/bin/phpcbf --basepath=. --standard=config/.phpcs.xml

coding-standard-check: ## check coding-standard compliance
./vendor/bin/php-cs-fixer fix --config=config/.php_cs.dist.php --dry-run
PHP_CS_FIXER_IGNORE_ENV=1 ./vendor/bin/php-cs-fixer fix --config=config/.php_cs.dist.php --dry-run
./vendor/bin/phpcs --basepath=. --standard=config/.phpcs.xml

benchmarks: ## run benchmarks
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
}
],
"require": {
"php": "^8.0",
"php": "~8.1.0",
"ext-bcmath": "*",
"ext-json": "*",
"ext-mbstring": "*",
"ext-sodium": "*",
"ext-intl": "*"
"ext-intl": "*",
"revolt/event-loop": "1.x-dev"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.6",
Expand Down
98 changes: 87 additions & 11 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 5 additions & 13 deletions src/Psl/Internal/internal_encoding.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Psl;
use Psl\Exception;
use Psl\Type;

use function mb_internal_encoding;

Expand All @@ -17,23 +16,16 @@
*/
function internal_encoding(?string $encoding = null): string
{
Psl\invariant(null === $encoding || is_encoding_valid($encoding), 'Invalid encoding.');
if (null !== $encoding) {
Psl\invariant(is_encoding_valid($encoding), 'Invalid encoding.');

return $encoding;
}

/**
* @psalm-suppress ImpureFunctionCall
*
* @var string
*/
$internal_encoding = mb_internal_encoding();

/**
* @psalm-suppress ImpureFunctionCall - see https://github.com/azjezz/psl/issues/130
* @psalm-suppress ImpureMethodCall - see https://github.com/azjezz/psl/issues/130
*/
if (Type\string()->matches($internal_encoding)) {
return $internal_encoding;
}

return 'UTF-8';
return mb_internal_encoding() ?: 'UTF-8';
}
4 changes: 2 additions & 2 deletions src/Psl/Iter/Iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static function create(iterable $iterable): Iterator
*
* @return Tv
*/
public function current()
public function current(): mixed
{
Psl\invariant($this->valid(), 'The Iterator is invalid.');
if (!contains_key($this->entries, $this->position)) {
Expand Down Expand Up @@ -127,7 +127,7 @@ public function next(): void
*
* @return Tk
*/
public function key()
public function key(): mixed
{
Psl\invariant($this->valid(), 'The Iterator is invalid.');
if (!contains_key($this->entries, $this->position)) {
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/Str/WidthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public function provideData(): array
{
return [
[5, 'Hello'],
[5, '☕ ☕ ☕'],
// [5, '☕ ☕ ☕'], // FAIL - new value: 8
[1, '⏟'],
[5, '⸺⸺⸺⸺⸺'],
[12, '♈♉♊♋♌♍♎♏♐♑♒♓'],
// [12, '♈♉♊♋♌♍♎♏♐♑♒♓'], // FAIL - new value: 24
[1, '༇'],
[12, 'héllö, wôrld'],
[9, 'مرحبا بكم'],
Expand All @@ -33,7 +33,7 @@ public function provideData(): array
[4, 'تونس'],
[3, 'سيف'],
[14, 'こんにちは世界'],
[3, '🥇🥈🥉'],
// [3, '🥇🥈🥉'], // FAIL - new value: 6
[4, '你好'],
[6, 'สวัสดี'],
[3, 'ؤخى']
Expand Down

0 comments on commit 810b236

Please sign in to comment.