Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into 1.x
Browse files Browse the repository at this point in the history
* origin/master:
  Add setup instructions
  Pass level 8 PHPStan analysis check
  Fix link to Fields API in docs
  Fix typo
  • Loading branch information
bezhermoso committed May 13, 2022
2 parents 19ff5e1 + 650f964 commit 24edc16
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/strict-validator.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## `StrictValidator`

Hyrule helps you build robust & secure applications by only allowing fields you explicitly defined via the [Fields API](../README.md#Fields API) or [Fields-With API](./fields-with.md).
Hyrule helps you build robust & secure applications by only allowing fields you explicitly defined via the [Fields API](../README.md#fields-api) or [Fields-With API](./fields-with.md).

Hyrule enforces this by using the `Square\Hyrule\Validation\Rules\KnownPropertiesOnly` rule which it adds to all `object(...)` nodes.

Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: 7
level: 8
paths:
- src
- tests
Expand Down
2 changes: 1 addition & 1 deletion src/Nodes/AbstractNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function end(): CompoundNode
*/
public function getParent(): CompoundNode
{
return $this->parent;
return $this->end();
}


Expand Down
7 changes: 7 additions & 0 deletions src/Nodes/ArrayNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Square\Hyrule\Nodes;

use BadMethodCallException;
use Illuminate\Contracts\Validation\Rule;
use InvalidArgumentException;
use LogicException;
Expand Down Expand Up @@ -107,6 +108,12 @@ public function get(string $name = '*'): AbstractNode
__METHOD__,
));
}
if (!$this->each instanceof AbstractNode) {
throw new BadMethodCallException(sprintf(
'%s called when element type has not been declared. Did you call each(<TYPE>) yet?',
__METHOD__,
));
}
return $this->each;
}

Expand Down
4 changes: 2 additions & 2 deletions src/PHPStan/RuleMagicMethodsReflectionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct()
$methodName = $reflectionMethod->getName();
if (preg_match('/^validate[A-Z]+.+$/', $methodName)) {
$ruleName = lcfirst(substr($methodName, 8));
$this->knownRuleMethods[$ruleName] = null;
$this->knownRuleMethods[$ruleName] = true;
}
}
}
Expand Down Expand Up @@ -56,7 +56,7 @@ public function getMethod(ClassReflection $classReflection, string $methodName):
/**
* @param ClassReflection $classReflection
* @param string $methodName
* @return mixed|RuleMethodReflection
* @return RuleMethodReflection
*/
private function returnOrCreateMethodReflection(ClassReflection $classReflection, string $methodName)
{
Expand Down

0 comments on commit 24edc16

Please sign in to comment.