diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml
new file mode 100644
index 0000000..45f5e23
--- /dev/null
+++ b/.github/workflows/phpstan.yml
@@ -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
diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml
new file mode 100644
index 0000000..c5a182c
--- /dev/null
+++ b/.github/workflows/phpunit.yml
@@ -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
diff --git a/.gitignore b/.gitignore
index 3a9875b..82dac7f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
-/vendor/
-composer.lock
+/vendor
+/composer.lock
+/.phpunit.result.cache
+/coverage
\ No newline at end of file
diff --git a/composer.json b/composer.json
index 66585af..88dadc1 100644
--- a/composer.json
+++ b/composer.json
@@ -3,12 +3,15 @@
"description": "A library for working with multi-dimensional arrays through flattened keys",
"type": "library",
"license": "MIT",
- "authors": [{
- "name": "Joby Elliott",
- "email": "joby@byjoby.com"
- }],
+ "authors": [
+ {
+ "name": "Joby Elliott",
+ "email": "joby@byjoby.com"
+ }
+ ],
"require-dev": {
- "phpunit/phpunit": "^7.3"
+ "phpunit/phpunit": "^9.5",
+ "phpstan/phpstan": "^1.9"
},
"autoload": {
"psr-4": {
@@ -21,12 +24,11 @@
}
},
"scripts": {
- "test": [
- "phpunit"
- ]
+ "test": "phpunit",
+ "stan": "phpstan"
},
"require": {
- "php": ">=7.1",
+ "php": ">=8.1",
"mustangostang/spyc": "^0.6.3"
}
}
diff --git a/phpstan.neon b/phpstan.neon
new file mode 100644
index 0000000..faa90c7
--- /dev/null
+++ b/phpstan.neon
@@ -0,0 +1,4 @@
+parameters:
+ level: 1
+ paths:
+ - src
\ No newline at end of file
diff --git a/phpunit.xml b/phpunit.xml
index 89c010e..bc2f7c1 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -1,7 +1,31 @@
-
+
+
+
+
+
+
+
-
- tests
+
+ tests/
-
+
+
+ src
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Config/Config.php b/src/Config/Config.php
index 33c5987..cfb66a7 100644
--- a/src/Config/Config.php
+++ b/src/Config/Config.php
@@ -1,5 +1,5 @@
+ * @extends Iterator
+ */
+interface FlatArrayInterface extends ArrayAccess, Iterator
{
public function set(?string $name, $value);
public function get(?string $name = null);
diff --git a/src/FlatArrayTrait.php b/src/FlatArrayTrait.php
index 3225986..8e49847 100644
--- a/src/FlatArrayTrait.php
+++ b/src/FlatArrayTrait.php
@@ -1,5 +1,5 @@
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);
}
- public function offsetExists($name)
+ public function offsetExists($name): bool
{
return $this->flattenSearch($name) !== null;
}
- public function offsetUnset($name)
+ public function offsetUnset($name): void
{
$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);
}
- 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);
}
- public function valid()
+ public function valid(): bool
{
return isset($this->_arrayData[$this->key()]);
}
diff --git a/src/SelfReferencingFlatArray.php b/src/SelfReferencingFlatArray.php
index be12251..542d3ed 100644
--- a/src/SelfReferencingFlatArray.php
+++ b/src/SelfReferencingFlatArray.php
@@ -1,5 +1,5 @@
filter(parent::shift($name));
}
- public function rewind()
- {
- return $this->filter(parent::rewind());
- }
-
- public function next()
- {
- return $this->filter(parent::next());
- }
-
- public function current()
+ public function current(): mixed
{
return $this->filter(parent::current());
}
diff --git a/tests/Config/ConfigTest.php b/tests/Config/ConfigTest.php
index 54edc70..3f6a0ad 100644
--- a/tests/Config/ConfigTest.php
+++ b/tests/Config/ConfigTest.php
@@ -1,5 +1,5 @@