Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Static analysis
on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]

jobs:
phpstan:
name: PHPStan code analysis [PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }}]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
php: [8.2, 8.3, 8.4]
#dependency-version: [ prefer-lowest, prefer-stable ]
dependency-version: [ prefer-stable ]

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl
coverage: none

- name: Copy .env
run: php -r "copy('.env.actions', '.env');"
- name: Run composer install
run: composer install --prefer-dist
- name: Run larastan (PHPStan) - Static code analysis
run: ./vendor/bin/phpstan analyse --memory-limit=2G

phpcs:
name: PHPcs PSR check [PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }}]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
php: [8.2, 8.3, 8.4]
#dependency-version: [ prefer-lowest, prefer-stable ]
dependency-version: [ prefer-stable ]

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl
coverage: none

- name: Copy .env
run: php -r "copy('.env.actions', '.env');"
- name: Run composer install
run: composer install --prefer-dist

- name: Run phpcs - PSR2 check
# run: ./vendor/bin/phpcs --standard=phpcs.xml src # Run with warnings > This will still trigger failure
run: ./vendor/bin/phpcs --standard=phpcs.xml src -n # To run errors only
# run: ./vendor/bin/phpcs --standard=PSR2 src
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ nb-configuration.xml

# OS
.DS_Store

composer.lock
composer.phar
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# v2.1.0
- Changed PHP requirements to `^8.2`
- Minimum version for "guzzlehttp/guzzle" is now `^7.9`
- Minimum version for "psr/log" is now `^3.0`
50 changes: 30 additions & 20 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
{
"name": "ecodenl/lvbag-php-wrapper",
"description": "PHP Wrapper for the LVBAG API ",
"type": "library",
"license": "OSL-3.0",
"authors": [
{
"name": "Bodhi Looij",
"email": "b.looij@wedesignit.nl",
"role": "Developer"
"name": "ecodenl/lvbag-php-wrapper",
"description": "PHP Wrapper for the LVBAG API ",
"type": "library",
"license": "OSL-3.0",
"authors": [
{
"name": "Bodhi Looij",
"email": "b.looij@wedesignit.nl",
"role": "Developer"
},
{
"name": "Yannick Schrijvers",
"email": "y.schrijvers@wedesignit.nl",
"role": "Developer"
}
],
"require": {
"php": "^8.2",
"guzzlehttp/guzzle": "^7.9",
"psr/log": "^3.0",
"ext-json": "*"
},
"autoload": {
"psr-4": {
"Ecodenl\\LvbagPhpWrapper\\": "src"
}
},
"require-dev": {
"phpstan/phpstan": "^2.0",
"squizlabs/php_codesniffer": "^3.11"
}
],
"require": {
"php": "^7.4.0|^8.0",
"guzzlehttp/guzzle": "^6.3.1|^7.4.5",
"psr/log": "^1.1.4|^3.0"
},
"autoload": {
"psr-4": {
"Ecodenl\\LvbagPhpWrapper\\": "src"
}
}
}
107 changes: 107 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="PHP_CodeSniffer">
<description>The coding standard for our project.</description>

<rule ref="PSR1">
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
</rule>

<rule ref="PSR2">
<!-- https://stackoverflow.com/questions/37399031/php-codesniffer-ignore-exclude-underscore-rule-in-methods/37401598#37401598 -->
<!-- This rule forces braces of multiline functions to be on the same line -->
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.NewlineBeforeOpenBrace"/>
<!-- Forces ternary statements to be on a single line -->
<exclude name="Squiz.WhiteSpace.OperatorSpacing.SpacingBefore"/>
</rule>

<rule ref="PSR2.Classes.ClassDeclaration"/>
<rule ref="PSR2.Classes.PropertyDeclaration"/>
<rule ref="PSR2.ControlStructures.ControlStructureSpacing"/>
<rule ref="PSR2.ControlStructures.ElseIfDeclaration"/>
<rule ref="PSR2.ControlStructures.SwitchDeclaration"/>
<rule ref="PSR2.Files.EndFileNewline"/>
<rule ref="PSR2.Methods.MethodDeclaration"/>
<rule ref="PSR2.Namespaces.NamespaceDeclaration"/>
<rule ref="PSR2.Namespaces.UseDeclaration"/>

<rule ref="PSR12.Operators.OperatorSpacing"/>

<!--http://edorian.github.io/php-coding-standard-generator/#phpcs-->
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<rule ref="Generic.ControlStructures.InlineControlStructure"/>
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="120"/>
<!-- A hard limit for errors is nice, but it also counts things like translation strings, which when compacted don't always read nice -->
<!-- <property name="absoluteLineLimit" value="200"/>-->
</properties>
</rule>
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<element key="eval" value="null"/>
<element key="dd" value="null"/>
<element key="dump" value="null"/>
<element key="die" value="null"/>
<element key="var_dump" value="null"/>
<element key="sizeof" value="count"/>
<element key="delete" value="unset"/>
<element key="print" value="echo"/>
<element key="create_function" value="null"/>
</property>
</properties>
</rule>
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
<rule ref="Generic.Formatting.SpaceAfterCast"/>
<rule ref="Generic.Formatting.SpaceAfterNot"/>
<rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
<rule ref="Generic.Functions.OpeningFunctionBraceBsdAllman"/>
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
<rule ref="Generic.NamingConventions.CamelCapsFunctionName"/>
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
<rule ref="Generic.PHP.ForbiddenFunctions"/>
<rule ref="Generic.PHP.LowerCaseConstant"/>
<rule ref="Generic.Strings.UnnecessaryStringConcat"/>
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
<rule ref="Generic.WhiteSpace.ScopeIndent"/>

<rule ref="PEAR.ControlStructures.ControlSignature">
<properties>
<property name="ignoreComments" value="false"/>
</properties>
</rule>
<rule ref="PEAR.Formatting.MultiLineAssignment"/>
<rule ref="PEAR.Functions.ValidDefaultValue"/>
<rule ref="PEAR.WhiteSpace.ObjectOperatorIndent"/>
<rule ref="PEAR.WhiteSpace.ScopeClosingBrace"/>

<!-- TODO: PHP Unit currently not available -->
<!--<rule ref="PHPUnitStandard.Testing.FileNameSuffix"/>-->
<!--<rule ref="PHPUnitStandard.Testing.NoOutputFunctions"/>-->
<!--<rule ref="PHPUnitStandard.Testing.NoOutputStatements"/>-->
<!--<rule ref="PHPUnitStandard.Testing.TestOrProviderIsPublic"/>-->
<!--<rule ref="PHPUnitStandard.Testing.UnusedProvider"/>-->

<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
<!-- THIS ALSO DOES NOT ALLOW NEW LINES FOR OPERATORS, WHICH WE DO ACTUALLY WANT -->
<!--<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing"/>-->
<rule ref="Squiz.WhiteSpace.OperatorSpacing"/>
<!-- HANDLED VIA PEAR.WhiteSpace.ScopeClosingBrace -->
<!--<rule ref="Squiz.WhiteSpace.ScopeClosingBrace"/>-->
<rule ref="Squiz.WhiteSpace.ScopeKeywordSpacing"/>
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>

<exclude-pattern>vendor/*</exclude-pattern>
<exclude-pattern>storage/*</exclude-pattern>
<exclude-pattern>bootstrap/*</exclude-pattern>
<exclude-pattern>public/*</exclude-pattern>
<exclude-pattern>*/migrations/*</exclude-pattern>
<exclude-pattern>*/seeds/*</exclude-pattern>
<exclude-pattern>*.blade.php</exclude-pattern>
<exclude-pattern>*.js</exclude-pattern>
</ruleset>
22 changes: 22 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#includes:
# Example:
#- vendor/nesbot/carbon/extension.neon

parameters:

paths:
- src/

# Level 10 is the highest level, see https://phpstan.org/user-guide/rule-levels
level: 5

#excludePaths:
# Example:
#- ./src/Traits/FluentCaller.php

ignoreErrors:
# These errors are ignored because we are 100% certain it's not actually an issue
- '#Unsafe usage of new static(.*)#'

#tips:
#treatPhpDocTypesAsCertain: false
9 changes: 6 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ A simple PHP wrapper for IMBAG API (LVBAG)

## Version Information

| Package version | API Version | Status | PHP Version |
|:----------------|:------------|:------------------------|:------------|
| 2.x.x | 2.x.x | Active support :rocket: | ^7.4.0 \| ^8.0 |
To keep versioning simple, the package version is aligned with the LV BAG API version.

| Package version | API Version | Status | PHP Version |
|:----------------|:------------|:------------------------|:---------------|
| 2.1.x | 2.x.x | Active support :rocket: | ^8.2 |
| 2.0.x | 2.x.x | No active support :x: | ^7.4.0 \| ^8.0 |


## Installing
Expand Down
6 changes: 3 additions & 3 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ public function __construct(
string $secret,
string $crs,
bool $useProductionEndpoint = false,
LoggerInterface $logger = null
) {
?LoggerInterface $logger = null
)
{
$this->logger = $logger;

if ($useProductionEndpoint) {
Expand Down Expand Up @@ -85,5 +86,4 @@ public function get(string $uri, array $options = []): array
{
return $this->request('GET', $uri, $options);
}

}
12 changes: 2 additions & 10 deletions src/Resources/AdresUitgebreid.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ class AdresUitgebreid extends Resource
{
/**
* Returns specific data about the given identification.
*
* @param string $nummeraanduidingIdentificatie
*
* @return array
*/
public function show(string $nummeraanduidingIdentificatie): array
{
Expand All @@ -18,15 +14,11 @@ public function show(string $nummeraanduidingIdentificatie): array

/**
* Returns a list of address(es) from given attributes.
*
* @param array $attributes
*
* @return array
*/
public function list(array $attributes): ?array
public function list(array $attributes): array
{
$response = $this->client->get($this->uri, static::buildQuery($this->paginate() + $attributes));

return $response['_embedded']['adressen'] ?? null;
return $response['_embedded']['adressen'] ?? [];
}
}
1 change: 0 additions & 1 deletion src/Resources/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

abstract class Resource
{
/** @var Client $client */
protected Client $client;

protected int $page = 1;
Expand Down
13 changes: 2 additions & 11 deletions src/Resources/Woonplaats.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ class Woonplaats extends Resource
{
/**
* Returns specific data about the given identification.
*
* @param string $identificatie
* @param array $attributes
*
* @return array
*/
public function show(string $identificatie, array $attributes = []): array
{
Expand All @@ -19,15 +14,11 @@ public function show(string $identificatie, array $attributes = []): array

/**
* Returns a list of cities from given attributes.
*
* @param array $attributes
*
* @return array
*/
public function list(array $attributes): ?array
public function list(array $attributes): array
{
$response = $this->client->get($this->uri, static::buildQuery($this->paginate() + $attributes));

return $response['_embedded']['woonplaatsen'] ?? null;
return $response['_embedded']['woonplaatsen'] ?? [];
}
}
3 changes: 2 additions & 1 deletion src/Traits/FluentCaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Ecodenl\LvbagPhpWrapper\Traits;

trait FluentCaller {
trait FluentCaller
{

public static function init()
{
Expand Down
7 changes: 7 additions & 0 deletions upgrading.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# From v2.0 to v2.1
To keep the LV BAG wrapper up to date, we have to drop support for deprecated PHP versions and packages.
Changes are limited, and most likely you won't have to do anything.

## PHP
The minimum PHP version is now 8.2. Ensure your PHP version is up to date.