Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PHP-CS-Fixer Github action #82

Merged
merged 9 commits into from
Nov 4, 2021
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
1 change: 0 additions & 1 deletion .github/workflows/draft-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
push:
branches:
- master
- develop

jobs:
update_release_draft:
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: php-cs-fixer

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
lint:
name: Run php-cs-fixer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Run php-cs-fixer
uses: docker://oskarstark/php-cs-fixer-ga
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Apply php-cs-fixer changes
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/vendor/
composer.lock
.phpunit.result.cache
.php-cs-fixer.cache
/composer.phar
28 changes: 28 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__.'/src')
->in(__DIR__.'/tests')
->in(__DIR__.'/examples');

$config = new PhpCsFixer\Config();

return $config
->setRules([
'@PSR2' => true,
'@Symfony' => true,
'@PhpCsFixer' => true,
'phpdoc_order' => true,
'ordered_class_elements' => true,
'multiline_whitespace_before_semicolons' => false,
'no_superfluous_phpdoc_tags' => false,
'phpdoc_annotation_without_dot' => false,
'phpdoc_types_order' => [
'null_adjustment' => 'always_last',
],
'yoda_style' => false,
'ternary_to_null_coalescing' => true,
'array_syntax' => ['syntax' => 'short'],
'php_unit_test_class_requires_covers' => false,
])
->setFinder($finder);
5 changes: 0 additions & 5 deletions .styleci.yml

This file was deleted.

5 changes: 2 additions & 3 deletions examples/cryptokeys.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

require __DIR__.'/../vendor/autoload.php';

require __DIR__.'/CliLogger.php';

/*
* This example will create, activate, deactivate and delete Crypto Keys for DNSSEC in an existing zone.
*/
// This example will create, activate, deactivate and delete Crypto Keys for DNSSEC in an existing zone.

use Exonet\Powerdns\Powerdns;

Expand Down
5 changes: 2 additions & 3 deletions examples/cryptokeys_advanced.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

require __DIR__.'/../vendor/autoload.php';

require __DIR__.'/CliLogger.php';

/*
* This example will create cryptokeys in an existing zone with custom settings.
*/
// This example will create cryptokeys in an existing zone with custom settings.

use Exonet\Powerdns\Powerdns;

Expand Down
5 changes: 2 additions & 3 deletions examples/cryptokeys_zsk_ksk.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

require __DIR__.'/../vendor/autoload.php';

require __DIR__.'/CliLogger.php';

/*
* This example will create ZSK and KSK keys for an existing zone.
*/
// This example will create ZSK and KSK keys for an existing zone.

use Exonet\Powerdns\Powerdns;

Expand Down
5 changes: 2 additions & 3 deletions examples/list_records_for_zone.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

require __DIR__.'/../vendor/autoload.php';

require __DIR__.'/CliLogger.php';

/*
* This example will create a new domain and adds some default DNS records.
*/
// This example will create a new domain and adds some default DNS records.

use Exonet\Powerdns\Powerdns;
use Exonet\Powerdns\Resources\Record;
Expand Down
9 changes: 3 additions & 6 deletions examples/manage_records.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

require __DIR__.'/../vendor/autoload.php';

require __DIR__.'/CliLogger.php';

/*
* This example will create, update and delete some DNS records in an existing zone.
*/
// This example will create, update and delete some DNS records in an existing zone.

use Exonet\Powerdns\Powerdns;
use Exonet\Powerdns\RecordType;
Expand Down Expand Up @@ -45,9 +44,7 @@
return $resourceRecord->setTtl(60);
})->save();

/*
* To delete a specific record from the zone, perform a search followed by a delete:
*/
// To delete a specific record from the zone, perform a search followed by a delete:
$zone->find('test3')->delete();

/*
Expand Down
5 changes: 2 additions & 3 deletions examples/new_domain.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

require __DIR__.'/../vendor/autoload.php';

require __DIR__.'/CliLogger.php';

/*
* This example will create a new domain and adds some default DNS records.
*/
// This example will create a new domain and adds some default DNS records.

use Exonet\Powerdns\Powerdns;
use Exonet\Powerdns\RecordType;
Expand Down
1 change: 1 addition & 0 deletions examples/new_domain_from_zone_resource.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

require __DIR__.'/../vendor/autoload.php';

require __DIR__.'/CliLogger.php';

/*
Expand Down
22 changes: 11 additions & 11 deletions src/AbstractZone.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ abstract class AbstractZone
* The class constructor.
*
* @param ConnectorInterface $connector The zone to use.
* @param null|string $canonicalDomain The PowerDNS Connector to make calls.
* @param string|null $canonicalDomain The PowerDNS Connector to make calls.
*/
public function __construct(ConnectorInterface $connector, ?string $canonicalDomain = null)
{
Expand Down Expand Up @@ -75,24 +75,24 @@ public function resource(): ZoneResource
}

/**
* Get the zone path for API calls.
*
* @param null|string $path The path to append to the zone.
* Get the canonical name of the zone. Includes the trailing dot (.).
*
* @return string The API zone path.
* @return string The canonical zone name.
*/
protected function getZonePath(?string $path = null): string
public function getCanonicalName(): string
{
return sprintf('zones/%s%s', $this->zone, $path);
return $this->zone;
}

/**
* Get the canonical name of the zone. Includes the trailing dot (.).
* Get the zone path for API calls.
*
* @return string The canonical zone name.
* @param string|null $path The path to append to the zone.
*
* @return string The API zone path.
*/
public function getCanonicalName(): string
protected function getZonePath(?string $path = null): string
{
return $this->zone;
return sprintf('zones/%s%s', $this->zone, $path);
}
}
7 changes: 6 additions & 1 deletion src/Connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function delete(string $urlPath): array
*
* @param string $method The method to use for the call.
* @param string $urlPath The URL path.
* @param null|string $payload (Optional) The payload to include.
* @param string|null $payload (Optional) The payload to include.
*
* @throws PowerdnsException When an unknown response is returned.
* @throws ValidationException When a validation error is returned.
Expand Down Expand Up @@ -148,12 +148,17 @@ protected function parseResponse(PsrResponse $response): array
case 200:
case 201:
return $contents ?? [];

break;

case 204:
return [];

break;

case 422:
throw new ValidationException($contents['error']);

break;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Cryptokey.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Cryptokey extends AbstractZone
* Crypto Key constructor.
*
* @param ConnectorInterface $connector The zone to use.
* @param null|string $canonicalDomain The Powerdns Connector to make calls.
* @param string|null $canonicalDomain The Powerdns Connector to make calls.
* @param CryptokeyResource|null $cryptoKeyResource The cryptokey resource class to use for API responses.
*/
public function __construct(
Expand Down
4 changes: 2 additions & 2 deletions src/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class Helper
* Make a new resource record based on the arguments or an array with data.
*
* @param string $zoneName The zone name for this resource record.
* @param string|array $name The resource record name or an array with the data.
* @param array|string $name The resource record name or an array with the data.
* @param string $type The type of the resource record.
* @param string|array $content The content of the resource record.
* @param array|string $content The content of the resource record.
* @param int $ttl The TTL.
*
* @throws Exceptions\InvalidRecordType If the given type is invalid.
Expand Down
10 changes: 5 additions & 5 deletions src/Powerdns.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ class Powerdns implements PowerdnsInterface
/**
* PowerDNS Client constructor.
*
* @param null|string $host (optional) The PowerDNS host. Must include protocol (http, https, etc.).
* @param null|string $apiKey (optional) The PowerDNS API key.
* @param string|null $host (optional) The PowerDNS host. Must include protocol (http, https, etc.).
* @param string|null $apiKey (optional) The PowerDNS API key.
* @param int|null $port (optional) The PowerDNS API Port.
* @param null|string $server (optional) The PowerDNS server to use.
* @param string|null $server (optional) The PowerDNS server to use.
* @param ConnectorInterface|null $connector (optional) The Connector to make calls.
*/
public function __construct(
Expand Down Expand Up @@ -212,7 +212,7 @@ public function deleteZone(string $canonicalDomain): bool
*
* @return Zone[] Array containing the zones
*
* @link https://doc.powerdns.com/authoritative/http-api/zone.html#get--servers-server_id-zones
* @see https://doc.powerdns.com/authoritative/http-api/zone.html#get--servers-server_id-zones
*/
public function listZones(bool $omitDnssecAndEditedSerialFields = false): array
{
Expand Down Expand Up @@ -243,7 +243,7 @@ public function cryptokeys(string $canonicalDomain): Cryptokey
* The $statistics and $includeRings parameters are supported in PowerDNS 4.3 and newer.
* On older PowerDNS instances these parameters are ignored.
*
* @param null|string $statistic Optional name of a specific statistic to get.
* @param string|null $statistic Optional name of a specific statistic to get.
* @param bool $includeRings Include ring statistics or not.
*
* @return array An array with statistics.
Expand Down
4 changes: 2 additions & 2 deletions src/PowerdnsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function deleteZone(string $canonicalDomain): bool;
*
* @return Zone[] Array containing the zones
*
* @link https://doc.powerdns.com/authoritative/http-api/zone.html#get--servers-server_id-zones
* @see https://doc.powerdns.com/authoritative/http-api/zone.html#get--servers-server_id-zones
*/
public function listZones(bool $omitDnssecAndEditedSerialFields = false): array;

Expand All @@ -95,7 +95,7 @@ public function cryptokeys(string $canonicalDomain): Cryptokey;
* The $statistics and $includeRings parameters are supported in PowerDNS 4.3 and newer.
* On older PowerDNS instances these parameters are ignored.
*
* @param null|string $statistic Optional name of a specific statistic to get.
* @param string|null $statistic Optional name of a specific statistic to get.
* @param bool $includeRings Include ring statistics or not.
*
* @return array An array with statistics.
Expand Down
12 changes: 6 additions & 6 deletions src/Zone.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ class Zone extends AbstractZone
* resource records will be created in a single call to the PowerDNS server. If $name is a string, a single resource
* record is created.
*
* @param string|mixed[] $name The resource record name.
* @param mixed[]|string $name The resource record name.
* @param string $type The type of the resource record.
* @param string|mixed[] $content The content of the resource record. When passing a multidimensional array,
* @param mixed[]|string $content The content of the resource record. When passing a multidimensional array,
* multiple records are created for this resource record.
* @param int $ttl The TTL.
*
Expand Down Expand Up @@ -85,7 +85,7 @@ public function put(Transformer $transformer): bool
* Get all the resource records in the current zone. If $recordType is specified, only get those specific resource
* records.
*
* @param null|string $recordType (optional) The type of resource record.
* @param string|null $recordType (optional) The type of resource record.
*
* @return ResourceSet A ResourceSet containing all the resource records.
*/
Expand All @@ -107,7 +107,7 @@ public function get(?string $recordType = null): ResourceSet
* specified, only get those specific resource records.
*
* @param string $resourceRecordName The name of the resource record.
* @param null|string $recordType (optional) The type of resource record.
* @param string|null $recordType (optional) The type of resource record.
*
* @return ResourceSet A ResourceSet containing all the resource records.
*/
Expand All @@ -119,8 +119,8 @@ public function find(string $resourceRecordName, ?string $recordType = null): Re

foreach ($records as $record) {
if (
$record->getName() === $resourceRecordName ||
$record->getName() === sprintf('%s.%s', $resourceRecordName, $this->zone)
$record->getName() === $resourceRecordName
|| $record->getName() === sprintf('%s.%s', $resourceRecordName, $this->zone)
) {
$foundResources->addResource($record);
}
Expand Down
3 changes: 3 additions & 0 deletions tests/ConnectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
use PHPUnit\Framework\TestCase;
use Psr\Log\NullLogger;

/**
* @internal
*/
class ConnectorTest extends TestCase
{
public function testApiCallsAreExecuted()
Expand Down
3 changes: 3 additions & 0 deletions tests/HelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
use Exonet\Powerdns\RecordType;
use PHPUnit\Framework\TestCase;

/**
* @internal
*/
class HelperTest extends TestCase
{
public function testWithArguments(): void
Expand Down
3 changes: 3 additions & 0 deletions tests/PowerdnsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
use Mockery;
use PHPUnit\Framework\TestCase;

/**
* @internal
*/
class PowerdnsTest extends TestCase
{
public function testConfigViaConstructor(): void
Expand Down
3 changes: 3 additions & 0 deletions tests/Resources/CommentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use Exonet\Powerdns\Resources\Comment;
use PHPUnit\Framework\TestCase;

/**
* @internal
*/
class CommentTest extends TestCase
{
public function testSettersAndGetters(): void
Expand Down
Loading