starting work on modernizing everything for v1.5

This commit is contained in:
Joby 2022-12-03 11:01:45 -07:00
parent 2c1b190b43
commit 949337ccbb
16 changed files with 104 additions and 49 deletions

14
.github/workflows/phpstan.yml vendored Normal file
View file

@ -0,0 +1,14 @@
name: phpstan
on: push
jobs:
phpstan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: php-actions/composer@v6
with:
dev: yes
- uses: php-actions/phpstan@v3
with:
memory_limit: 1G
args: --memory-limit 1G

11
.github/workflows/phpunit.yml vendored Normal file
View file

@ -0,0 +1,11 @@
name: phpunit
on: push
jobs:
phpunit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: php-actions/composer@v6
with:
dev: yes
- uses: php-actions/phpunit@v3

6
.gitignore vendored
View file

@ -1,2 +1,4 @@
/vendor/ /vendor
composer.lock /composer.lock
/.phpunit.result.cache
/coverage

View file

@ -3,12 +3,15 @@
"description": "A library for working with multi-dimensional arrays through flattened keys", "description": "A library for working with multi-dimensional arrays through flattened keys",
"type": "library", "type": "library",
"license": "MIT", "license": "MIT",
"authors": [{ "authors": [
"name": "Joby Elliott", {
"email": "joby@byjoby.com" "name": "Joby Elliott",
}], "email": "joby@byjoby.com"
}
],
"require-dev": { "require-dev": {
"phpunit/phpunit": "^7.3" "phpunit/phpunit": "^9.5",
"phpstan/phpstan": "^1.9"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
@ -21,12 +24,11 @@
} }
}, },
"scripts": { "scripts": {
"test": [ "test": "phpunit",
"phpunit" "stan": "phpstan"
]
}, },
"require": { "require": {
"php": ">=7.1", "php": ">=8.1",
"mustangostang/spyc": "^0.6.3" "mustangostang/spyc": "^0.6.3"
} }
} }

4
phpstan.neon Normal file
View file

@ -0,0 +1,4 @@
parameters:
level: 1
paths:
- src

View file

@ -1,7 +1,31 @@
<phpunit bootstrap="vendor/autoload.php"> <?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
executionOrder="random"
failOnWarning="true"
failOnRisky="true"
failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true"
verbose="true"
bootstrap="vendor/autoload.php">
<php>
<ini name="display_errors" value="On" />
<ini name="error_reporting" value="-1" />
<ini name="xdebug.mode" value="coverage" />
</php>
<testsuites> <testsuites>
<testsuite name="All"> <testsuite name="Tests">
<directory>tests</directory> <directory>tests/</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
</phpunit> <coverage>
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<html outputDirectory="coverage" lowUpperBound="50" highLowerBound="90" />
</report>
</coverage>
</phpunit>

View file

@ -1,5 +1,5 @@
<?php <?php
/* Flatrr | https://gitlab.com/byjoby/flatrr | MIT License */ /* Flatrr | https://github.com/jobyone/flatrr | MIT License */
namespace Flatrr\Config; namespace Flatrr\Config;

View file

@ -1,5 +1,5 @@
<?php <?php
/* Flatrr | https://gitlab.com/byjoby/flatrr | MIT License */ /* Flatrr | https://github.com/jobyone/flatrr | MIT License */
namespace Flatrr\Config; namespace Flatrr\Config;
interface ConfigInterface extends \ArrayAccess interface ConfigInterface extends \ArrayAccess

View file

@ -1,5 +1,5 @@
<?php <?php
/* Flatrr | https://gitlab.com/byjoby/flatrr | MIT License */ /* Flatrr | https://github.com/jobyone/flatrr | MIT License */
namespace Flatrr; namespace Flatrr;
class FlatArray implements FlatArrayInterface class FlatArray implements FlatArrayInterface

View file

@ -1,8 +1,16 @@
<?php <?php
/* Flatrr | https://gitlab.com/byjoby/flatrr | MIT License */ /* Flatrr | https://github.com/jobyone/flatrr | MIT License */
namespace Flatrr; namespace Flatrr;
interface FlatArrayInterface extends \ArrayAccess, \Iterator use ArrayAccess;
use Iterator;
/**
* @extends ArrayAccess<string|mixed>
* @extends Iterator<string|mixed>
*/
interface FlatArrayInterface extends ArrayAccess, Iterator
{ {
public function set(?string $name, $value); public function set(?string $name, $value);
public function get(?string $name = null); public function get(?string $name = null);

View file

@ -1,5 +1,5 @@
<?php <?php
/* Flatrr | https://gitlab.com/byjoby/flatrr | MIT License */ /* Flatrr | https://github.com/jobyone/flatrr | MIT License */
namespace Flatrr; namespace Flatrr;
@ -71,47 +71,47 @@ trait FlatArrayTrait
$this->flattenSearch($name, null, true); $this->flattenSearch($name, null, true);
} }
public function offsetSet($name, $value) public function offsetSet($name, $value): void
{ {
return $this->set($name, $value); $this->set($name, $value);
} }
public function offsetGet($name) public function offsetGet($name): mixed
{ {
return $this->get($name); return $this->get($name);
} }
public function offsetExists($name) public function offsetExists($name): bool
{ {
return $this->flattenSearch($name) !== null; return $this->flattenSearch($name) !== null;
} }
public function offsetUnset($name) public function offsetUnset($name): void
{ {
$this->unset($name); $this->unset($name);
} }
public function rewind() public function rewind(): void
{ {
return reset($this->_arrayData); reset($this->_arrayData);
} }
public function current() public function current(): mixed
{ {
return current($this->_arrayData); return current($this->_arrayData);
} }
public function next() public function next(): void
{ {
return next($this->_arrayData); next($this->_arrayData);
} }
public function key() public function key(): null|string
{ {
return key($this->_arrayData); return key($this->_arrayData);
} }
public function valid() public function valid(): bool
{ {
return isset($this->_arrayData[$this->key()]); return isset($this->_arrayData[$this->key()]);
} }

View file

@ -1,5 +1,5 @@
<?php <?php
/* Flatrr | https://gitlab.com/byjoby/flatrr | MIT License */ /* Flatrr | https://github.com/jobyone/flatrr | MIT License */
namespace Flatrr; namespace Flatrr;
@ -46,17 +46,7 @@ class SelfReferencingFlatArray extends FlatArray
return $this->filter(parent::shift($name)); return $this->filter(parent::shift($name));
} }
public function rewind() public function current(): mixed
{
return $this->filter(parent::rewind());
}
public function next()
{
return $this->filter(parent::next());
}
public function current()
{ {
return $this->filter(parent::current()); return $this->filter(parent::current());
} }

View file

@ -1,5 +1,5 @@
<?php <?php
/* Flatrr | https://gitlab.com/byjoby/flatrr | MIT License */ /* Flatrr | https://github.com/jobyone/flatrr | MIT License */
declare(strict_types=1); declare(strict_types=1);
namespace Flatrr\Config; namespace Flatrr\Config;

View file

@ -1,5 +1,5 @@
<?php <?php
/* Flatrr | https://gitlab.com/byjoby/flatrr | MIT License */ /* Flatrr | https://github.com/jobyone/flatrr | MIT License */
declare(strict_types=1); declare(strict_types=1);
namespace Flatrr; namespace Flatrr;

View file

@ -1,5 +1,5 @@
<?php <?php
/* Flatrr | https://gitlab.com/byjoby/flatrr | MIT License */ /* Flatrr | https://github.com/jobyone/flatrr | MIT License */
declare(strict_types=1); declare(strict_types=1);
namespace Flatrr; namespace Flatrr;

View file

@ -1,5 +1,5 @@
<?php <?php
/* Flatrr | https://gitlab.com/byjoby/flatrr | MIT License */ /* Flatrr | https://github.com/jobyone/flatrr | MIT License */
declare(strict_types=1); declare(strict_types=1);
namespace Flatrr; namespace Flatrr;