Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ name: ci

on:
push:
branches:
- main

jobs:
run:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ["8.2", "8.3", "8.4"]
php-versions: ["8.2", "8.3", "8.4", "8.5"]
name: PHP ${{ matrix.php-versions }}
steps:
- name: Checkout
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
},
"require-dev": {
"laravel/pint": "^1.17.3",
"pestphp/pest": "^2.35.1",
"phpstan/phpstan": "^1.12.2",
"rector/rector": "^1.2.4",
"pestphp/pest": "^v3.8.6",
"phpstan/phpstan": "^2.2.5",
"rector/rector": "^2.5.3",
"symfony/var-dumper": "^6.4|^7.1.4"
},
"autoload": {
Expand Down
2 changes: 2 additions & 0 deletions src/Nodes/ArrayNode.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Devium\Toml\Nodes;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Nodes/ArrayTableNode.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Devium\Toml\Nodes;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Nodes/BareNode.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Devium\Toml\Nodes;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Nodes/BooleanNode.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Devium\Toml\Nodes;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Nodes/FloatNode.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Devium\Toml\Nodes;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Nodes/InlineTableNode.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Devium\Toml\Nodes;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Nodes/IntegerNode.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Devium\Toml\Nodes;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Nodes/KeyNode.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Devium\Toml\Nodes;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Nodes/KeyValuePairNode.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Devium\Toml\Nodes;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Nodes/LocalDateNode.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Devium\Toml\Nodes;

use Devium\Toml\TomlLocalDate;
Expand Down
2 changes: 2 additions & 0 deletions src/Nodes/LocalDateTimeNode.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Devium\Toml\Nodes;

use Devium\Toml\TomlLocalDateTime;
Expand Down
2 changes: 2 additions & 0 deletions src/Nodes/LocalTimeNode.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Devium\Toml\Nodes;

use Devium\Toml\TomlLocalTime;
Expand Down
2 changes: 2 additions & 0 deletions src/Nodes/Node.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Devium\Toml\Nodes;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Nodes/NumericNode.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Devium\Toml\Nodes;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Nodes/OffsetDateTimeNode.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Devium\Toml\Nodes;

use Devium\Toml\TomlDateTime;
Expand Down
2 changes: 2 additions & 0 deletions src/Nodes/RootTableNode.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Devium\Toml\Nodes;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Nodes/StringNode.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Devium\Toml\Nodes;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Nodes/TableNode.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Devium\Toml\Nodes;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Nodes/TomlDateTimeNode.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Devium\Toml\Nodes;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Nodes/ValuableNode.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Devium\Toml\Nodes;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Toml.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Devium\Toml;

use stdClass;
Expand Down
2 changes: 2 additions & 0 deletions src/TomlDateTimeInterface.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Devium\Toml;

interface TomlDateTimeInterface {}
2 changes: 1 addition & 1 deletion src/TomlDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected static function toArray(mixed $object): mixed
}

if (is_array($object) || is_object($object)) {
return array_map(static fn ($value) => self::toArray($value), (array) $object);
return array_map(self::toArray(...), (array) $object);
}

return $object;
Expand Down
4 changes: 2 additions & 2 deletions src/TomlEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected static function stringifyTable(object $obj, string $prefix = ''): stri
}

$type = self::extendedTypeOf($obj->{$k});
$key = preg_match(self::BARE_KEY, $k) ? $k : self::formatString($k);
$key = preg_match(self::BARE_KEY, (string) $k) ? $k : self::formatString($k);
if ($type === 'array' && self::isArrayOfTables($obj->{$k})) {
$tables .= self::stringifyArrayTable($obj->{$k}, $prefix !== '' && $prefix !== '0' ? "$prefix.$key" : $key);
} elseif ($type === 'object') {
Expand Down Expand Up @@ -205,7 +205,7 @@ protected static function stringifyInlineTable(array|stdClass $obj): string
if ($i !== 0) {
$res .= ', ';
}
$res .= preg_match(self::BARE_KEY, $k) ? $k : self::formatString($k);
$res .= preg_match(self::BARE_KEY, (string) $k) ? $k : self::formatString($k);
$res .= ' = ';
$res .= self::stringifyValue($obj->{$k});
}
Expand Down
2 changes: 2 additions & 0 deletions src/TomlInputIterator.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Devium\Toml;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/TomlLocalDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static function fromString($value): self
throw new TomlError("invalid local date format \"$value\"");
}

[$year, $month, $day] = array_map('intval', explode('-', (string) $value));
[$year, $month, $day] = array_map(intval(...), explode('-', (string) $value));

if (! self::isYear($year) || ! self::isMonth($month) || ! self::isDay($day)) {
throw new TomlError("invalid local date format \"$value\"");
Expand Down
4 changes: 2 additions & 2 deletions src/TomlLocalTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public static function fromString($value): self
}

$components = explode(':', (string) $value);
[$hour, $minute] = array_map('intval', array_slice($components, 0, 2));
$p = array_map('intval', explode('.', $components[2]));
[$hour, $minute] = array_map(intval(...), array_slice($components, 0, 2));
$p = array_map(intval(...), explode('.', $components[2]));
$second = $p[0];
$millisecond = $p[1] ?? 0;

Expand Down
2 changes: 1 addition & 1 deletion src/TomlNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static function normalize(Nodes\Node $node): mixed
*/
protected static function mapNormalize(array $items): array
{
return array_map(static fn ($element) => self::normalize($element), $items);
return array_map(self::normalize(...), $items);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/TomlObject.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Devium\Toml;

use ArrayObject;
Expand Down
4 changes: 2 additions & 2 deletions src/TomlParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ protected function dateOrDateTime(string $value): OffsetDateTimeNode|LocalDateTi
);
$value .= implode('', array_map(static fn (TomlToken $token) => $token->value, $tokens));

$lastTokenValue = strtolower($tokens[count($tokens) - 1]->value);
$lastTokenValue = strtolower((string) $tokens[count($tokens) - 1]->value);

if (str_ends_with($lastTokenValue, 'z')) {
return new OffsetDateTimeNode($this->parseDate($value));
Expand Down Expand Up @@ -429,7 +429,7 @@ protected function parseInteger(
}

$octalOrBinary = ($radix === 8 && $char === 'o') || ($radix === 2 && $char === 'b');
if (! ($i === 1 && $octalOrBinary) && ! $this->digitalChecks($radix, $char)) {
if (($i !== 1 || ! $octalOrBinary) && ! $this->digitalChecks($radix, $char)) {
break;
}

Expand Down
4 changes: 2 additions & 2 deletions src/TomlTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static function tagObject(mixed $obj): array|stdClass
}

if (is_array($obj)) {
return array_map(static fn ($item) => self::tagObject($item), $obj);
return array_map(self::tagObject(...), $obj);
}

$tagged = new stdClass;
Expand All @@ -84,7 +84,7 @@ public static function tagObject(mixed $obj): array|stdClass
public static function untagObject($obj)
{
if (is_array($obj)) {
return array_map(static fn ($item) => self::untagObject($item), $obj);
return array_map(self::untagObject(...), $obj);
}

if (property_exists($obj, 'type') && property_exists($obj, 'value') && count(get_object_vars($obj)) === 2) {
Expand Down
2 changes: 1 addition & 1 deletion src/TomlTokenizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ protected function scanBasicString(): TomlToken
*/
public function sequence(...$types): array
{
return array_map(fn ($type) => $this->expect($type), $types);
return array_map($this->expect(...), $types);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/TomlUtils.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Devium\Toml;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/helpers.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

use Devium\Toml\Toml;
use Devium\Toml\TomlError;

Expand Down
2 changes: 2 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Tests;

use PHPUnit\Framework\TestCase as BaseTestCase;
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/TomlDecodeTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

use Devium\Toml\TomlError;

it('can decode TOML',
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/TomlEncodeTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

use Devium\Toml\TomlError;

it('can encode TOML',
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/TomlErrorTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

use Devium\Toml\TomlError;

it('shows code block and caret',
Expand Down