diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 04b188a..af44b43 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -36,3 +36,6 @@ jobs:
- name: "Psalm"
run: ./bin/psalm
+
+ - name: "CodeSniffer"
+ run: ./bin/phpcs
diff --git a/composer.json b/composer.json
index 06cd05d..57a3469 100644
--- a/composer.json
+++ b/composer.json
@@ -28,7 +28,8 @@
"phpunit/phpunit": "^9.0",
"phpstan/extension-installer": "^1.0",
"vimeo/psalm": "^4.0",
- "friends-of-phpspec/phpspec-code-coverage": "^6.0"
+ "friends-of-phpspec/phpspec-code-coverage": "^6.0",
+ "squizlabs/php_codesniffer": "^3.6"
},
"autoload": {
"psr-4": {
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 0000000..b41d2c9
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,17 @@
+
+
+ The coding standard of Gowork.
+
+ src
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/ArrayValue.php b/src/ArrayValue.php
index 6327181..d5c9b38 100644
--- a/src/ArrayValue.php
+++ b/src/ArrayValue.php
@@ -121,9 +121,9 @@ public function offsetExists($offset): bool;
/**
* @param int $offset
- * @phpstan-return TValue
+ * @return ?TValue
*/
- public function offsetGet($offset);
+ public function offsetGet($offset): mixed;
/**
* @param int $offset
diff --git a/src/AssocArray.php b/src/AssocArray.php
index c97b204..c0da603 100644
--- a/src/AssocArray.php
+++ b/src/AssocArray.php
@@ -343,7 +343,7 @@ public function offsetExists($offset): bool
* @param TKey $offset
* @return ?TValue
*/
- public function offsetGet($offset)
+ public function offsetGet($offset): mixed
{
return $this->items->toAssocArray()[$offset];
}
diff --git a/src/AssocValue.php b/src/AssocValue.php
index 4e1e2e1..5afe328 100644
--- a/src/AssocValue.php
+++ b/src/AssocValue.php
@@ -70,10 +70,10 @@ public function reverse(): AssocValue;
public function offsetExists($offset): bool;
/**
- * @phpstan-param TKey $offset
+ * @param TKey $offset
* @return ?TValue
*/
- public function offsetGet($offset);
+ public function offsetGet($offset): mixed;
/**
* @phpstan-param TKey $offset
diff --git a/src/InfiniteIterableValue.php b/src/InfiniteIterableValue.php
index 462c35e..51296f2 100644
--- a/src/InfiniteIterableValue.php
+++ b/src/InfiniteIterableValue.php
@@ -51,7 +51,7 @@ public function each(callable $callback): InfiniteIterableValue
}
/**
- * @param (callable(TValue,TValue):int) | null $comparator
+ * @phpstan-param (callable(TValue,TValue):int) | null $comparator
* @phpstan-return InfiniteIterableValue
*/
public function unique(?callable $comparator = null): InfiniteIterableValue
@@ -505,7 +505,9 @@ public function first()
public function last()
{
$value = null;
- foreach ($this->stack->iterate() as $value) {}
+ foreach ($this->stack->iterate() as $value) {
+ // iterating until the end
+ }
return $value;
}
diff --git a/src/PlainArray.php b/src/PlainArray.php
index 8025b7b..b7eb729 100644
--- a/src/PlainArray.php
+++ b/src/PlainArray.php
@@ -259,7 +259,7 @@ public function shift(&$value = null): PlainArray
$items = $this->toArray();
$value = array_shift($items);
- return new self(new JustArray($items));;
+ return new self(new JustArray($items));
}
/**
@@ -413,7 +413,7 @@ public function offsetExists($offset): bool
* @param int $offset
* @return ?TValue
*/
- public function offsetGet($offset)
+ public function offsetGet($offset): mixed
{
return $this->items->toArray()[$offset];
}
diff --git a/src/PlainStringsArray.php b/src/PlainStringsArray.php
index e0b43b7..1f5373e 100644
--- a/src/PlainStringsArray.php
+++ b/src/PlainStringsArray.php
@@ -259,7 +259,7 @@ public function offsetExists($offset): bool
/**
* @param int $offset
*/
- public function offsetGet($offset): StringValue
+ public function offsetGet($offset): ?StringValue
{
return $this->strings->offsetGet($offset);
}
diff --git a/src/StringsArray.php b/src/StringsArray.php
index 5e8ae3f..4a2be75 100644
--- a/src/StringsArray.php
+++ b/src/StringsArray.php
@@ -103,7 +103,7 @@ public function offsetExists($offset): bool;
/**
* @param int $offset
*/
- public function offsetGet($offset): StringValue;
+ public function offsetGet($offset): ?StringValue;
/**
* @param int $offset