Skip to content

Commit

Permalink
Add pslam and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tburry committed Sep 4, 2019
1 parent e658e03 commit 47c1576
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ jobs:
php --version
composer --version
- run:
name: Test setup
name: Static Analysis
command: |
cd ~/workspace/repo
./vendor/bin/psalm
- run:
name: PHPUnit Tests
command: |
Expand Down
55 changes: 55 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0"?>
<psalm
totallyTyped="false"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>

<issueHandlers>
<LessSpecificReturnType errorLevel="info" />

<!-- level 3 issues - slightly lazy code writing, but provably low false-negatives -->

<DeprecatedMethod errorLevel="info" />
<DeprecatedProperty errorLevel="info" />
<DeprecatedClass errorLevel="info" />
<DeprecatedConstant errorLevel="info" />
<DeprecatedFunction errorLevel="info" />
<DeprecatedInterface errorLevel="info" />
<DeprecatedTrait errorLevel="info" />

<InternalMethod errorLevel="info" />
<InternalProperty errorLevel="info" />
<InternalClass errorLevel="info" />

<MissingClosureReturnType errorLevel="info" />
<MissingReturnType errorLevel="info" />
<MissingPropertyType errorLevel="info" />
<InvalidDocblock errorLevel="info" />
<MisplacedRequiredParam errorLevel="info" />

<PropertyNotSetInConstructor errorLevel="info" />
<MissingConstructor errorLevel="info" />
<MissingClosureParamType errorLevel="info" />
<MissingParamType errorLevel="info" />

<RedundantCondition errorLevel="info" />

<DocblockTypeContradiction errorLevel="info" />
<RedundantConditionGivenDocblockType errorLevel="info" />

<UnresolvableInclude errorLevel="info" />

<RawObjectIteration errorLevel="info" />

<InvalidStringClass errorLevel="info" />
</issueHandlers>
</psalm>
8 changes: 5 additions & 3 deletions src/Transformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __invoke($data) {
/**
* Transform a spec node.
*
* @param array|array $spec The spec node to transform.
* @param int|string|array $spec The spec node to transform.
* @param array $data The data to transform.
* @param array $root The root of the data from the first call to `transform()`.
* @param string $path The current spec path being transformed.
Expand Down Expand Up @@ -91,19 +91,21 @@ private function transformInternal($spec, $data, $root, string $path) {
/**
* Resolve a JSON reference.
*
* @param string $ref The reference to resolve.
* @param int|string $ref The reference to resolve.
* @param mixed $context The current data context to lookup.
* @param mixed $root The root data context for absolute references.
* @param bool $found Set to **true** if the reference was found or **false** otherwise.
* @return mixed Returns the value at the reference.
*/
private function resolveReference(string $ref, $context, $root, bool &$found = null) {
private function resolveReference($ref, $context, $root, bool &$found = null) {
$found = true;

if ($ref === '') {
return $context;
} elseif ($ref === '/') {
return $root;
} elseif (is_int($ref)) {
return $context[$ref];
} elseif ($ref[0] === '/') {
$ref = substr($ref, 1);
$context = $root;
Expand Down

0 comments on commit 47c1576

Please sign in to comment.