Skip to content

Commit

Permalink
Add PHPStan, fix some issues
Browse files Browse the repository at this point in the history
  • Loading branch information
BafS committed Oct 30, 2023
1 parent 0710b96 commit d9404cc
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 15 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: PHP static analysis

on:
push:
branches: [ master, main ]
pull_request:
branches: [ master, main ]

jobs:
ci:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['8.2']

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none

- name: Install Dependencies
run: composer update --no-interaction --no-progress --ansi

- name: PhpStan
run: ./vendor/bin/phpstan analyse
2 changes: 1 addition & 1 deletion .github/workflows/php.yml → .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PHP Unit/Quality CI
name: PHP unit tests

on:
push:
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"require-dev": {
"phpunit/phpunit": "^9.0|^10.0",
"php-coveralls/php-coveralls": "^2.0"
"php-coveralls/php-coveralls": "^2.0",
"phpstan/phpstan": "^1.10"
},
"minimum-stability": "stable"
}
64 changes: 63 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Builder/AttributeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public function addSubAttributes(array $attributes)
}

/**
* @param \string[] $canonicalValues
* @param string[] $canonicalValues
*
* @return AttributeBuilder
*/
Expand All @@ -208,7 +208,7 @@ public function setCanonicalValues(array $canonicalValues)
}

/**
* @param \string[] $referenceTypes
* @param string[] $referenceTypes
*
* @return AttributeBuilder
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Model/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct($id)
abstract public function getResourceType();

/**
* @return \string[]
* @return string[]
*/
public function getSchemas()
{
Expand Down Expand Up @@ -123,7 +123,7 @@ public function serializeObject()
if (!$extension) {
continue;
}
if ($extension instanceof ResourceExtension) {
if ($extension instanceof SerializableInterface) {
$result[$schemaId] = $extension->serializeObject();
} elseif (is_array($extension)) {
$result[$schemaId] = $extension;
Expand Down
12 changes: 5 additions & 7 deletions src/Model/Schema/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ class Attribute implements SerializableInterface
* @param bool $required
* @param string $description
* @param Attribute[] $subAttributes
* @param \string[] $canonicalValues
* @param string[] $canonicalValues
* @param bool $caseExact
* @param string $mutability
* @param string $returned
* @param string $uniqueness
* @param \string[] $referenceTypes
* @param string[] $referenceTypes
*/
public function __construct(
$name,
Expand Down Expand Up @@ -143,7 +143,7 @@ public function getSubAttributes()
}

/**
* @return \string[]
* @return string[]
*/
public function getCanonicalValues()
{
Expand Down Expand Up @@ -183,7 +183,7 @@ public function getUniqueness()
}

/**
* @return \string[]
* @return string[]
*/
public function getReferenceTypes()
{
Expand Down Expand Up @@ -274,7 +274,7 @@ public static function deserializeObject(array $data)
$subAttributes[] = static::deserializeObject($subAttribute);
}
}
$result = new static(
return new static(
$data['name'],
$data['type'],
$data['multiValued'],
Expand All @@ -288,7 +288,5 @@ public static function deserializeObject(array $data)
isset($data['uniqueness']) ? $data['uniqueness'] : null,
isset($data['referenceTypes']) ? $data['referenceTypes'] : []
);

return $result;
}
}
2 changes: 1 addition & 1 deletion src/Validator/ValidationResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function getErrors()
}

/**
* @return \string[]
* @return string[]
*/
public function getErrorsAsStrings()
{
Expand Down

0 comments on commit d9404cc

Please sign in to comment.