Skip to content

chore(style): fix code style #27

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

Merged
merged 4 commits into from
Jan 24, 2024
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
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ jobs:
php-version: [
'7.4',
'8.0',
'8.1'
'8.1',
'8.2',
'8.3',
]

steps:
Expand Down Expand Up @@ -56,7 +58,7 @@ jobs:
run: vendor/bin/parallel-lint src/

- name: Run CodeStyle checks
run: PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix src --allow-risky=yes --diff --dry-run
run: PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer check --allow-risky=yes --diff

- name: Run PHPStan
run: vendor/bin/phpstan analyze -clear-result-cache -c phpstan.neon src/ --no-progress
Expand Down
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
"require-dev": {
"phpunit/phpunit": "^9.6.13",
"phpstan/phpstan": "^1.10.41",
"friendsofphp/php-cs-fixer": "^v3.38.0",
"php-parallel-lint/php-parallel-lint": "^1.3.2",
"enlightn/security-checker": "^1.10.0",
"symfony/routing": "^4.4.44 || ^5.0.0"
"friendsofphp/php-cs-fixer": "*",
"php-parallel-lint/php-parallel-lint": "*",
"enlightn/security-checker": "*",
"symfony/routing": "^4.4.44 || ^5.0.0 || ^6.0.0"
},
"autoload": {
"psr-4": {
Expand All @@ -55,7 +55,8 @@
},
"scripts": {
"test": "vendor/bin/phpunit --testdox tests",
"sniff-fix": "vendor/bin/php-cs-fixer fix",
"sniff": "PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer check --allow-risky=yes --diff",
"sniff-fix": "PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --allow-risky=yes --diff",
"phpstan": "vendor/bin/phpstan analyze"
}
}
3 changes: 0 additions & 3 deletions src/CXml/Endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ public function __construct(
$this->logger = $logger ?? new NullLogger();
}

/**
* @throws Exception\CXmlException
*/
public function parseAndProcessStringAsCXml(string $xml, Context $context = null): ?CXml
{
$this->logger->info('Processing incoming CXml message', ['xml' => $xml]);
Expand Down
4 changes: 3 additions & 1 deletion src/CXml/Exception/CXmlConflictException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

namespace CXml\Exception;

class CXmlConflictException extends CXmlException {}
class CXmlConflictException extends CXmlException
{
}
4 changes: 3 additions & 1 deletion src/CXml/Exception/CXmlExpectationFailedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

namespace CXml\Exception;

class CXmlExpectationFailedException extends CXmlException {}
class CXmlExpectationFailedException extends CXmlException
{
}
4 changes: 3 additions & 1 deletion src/CXml/Exception/CXmlNotAcceptableException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

namespace CXml\Exception;

class CXmlNotAcceptableException extends CXmlException {}
class CXmlNotAcceptableException extends CXmlException
{
}
4 changes: 3 additions & 1 deletion src/CXml/Exception/CXmlNotImplementedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

namespace CXml\Exception;

class CXmlNotImplementedException extends CXmlException {}
class CXmlNotImplementedException extends CXmlException
{
}
4 changes: 3 additions & 1 deletion src/CXml/Exception/CXmlPreconditionFailedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

namespace CXml\Exception;

class CXmlPreconditionFailedException extends CXmlException {}
class CXmlPreconditionFailedException extends CXmlException
{
}
4 changes: 3 additions & 1 deletion src/CXml/Model/Message/MessagePayloadInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@

use CXml\Model\PayloadInterface;

interface MessagePayloadInterface extends PayloadInterface {}
interface MessagePayloadInterface extends PayloadInterface
{
}
4 changes: 3 additions & 1 deletion src/CXml/Model/PayloadInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

namespace CXml\Model;

interface PayloadInterface {}
interface PayloadInterface
{
}
4 changes: 3 additions & 1 deletion src/CXml/Model/Request/ProfileRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

namespace CXml\Model\Request;

class ProfileRequest implements RequestPayloadInterface {}
class ProfileRequest implements RequestPayloadInterface
{
}
4 changes: 3 additions & 1 deletion src/CXml/Model/Request/RequestPayloadInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@

use CXml\Model\PayloadInterface;

interface RequestPayloadInterface extends PayloadInterface {}
interface RequestPayloadInterface extends PayloadInterface
{
}
4 changes: 3 additions & 1 deletion src/CXml/Model/Response/ResponsePayloadInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@

use CXml\Model\PayloadInterface;

interface ResponsePayloadInterface extends PayloadInterface {}
interface ResponsePayloadInterface extends PayloadInterface
{
}
4 changes: 3 additions & 1 deletion src/CXml/Model/Response/StatusResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

namespace CXml\Model\Response;

class StatusResponse implements ResponsePayloadInterface {}
class StatusResponse implements ResponsePayloadInterface
{
}
16 changes: 7 additions & 9 deletions tests/CXmlTest/Model/OrderRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@
*/
class OrderRequestTest extends TestCase implements PayloadIdentityFactoryInterface
{
private DtdValidator $dtdValidator;

private DtdValidator $dtdValidator;

protected function setUp(): void
{
$this->dtdValidator = new DtdValidator(__DIR__.'/../../metadata/cxml/dtd/1.2.050/');
}
protected function setUp(): void
{
$this->dtdValidator = new DtdValidator(__DIR__.'/../../metadata/cxml/dtd/1.2.050/');
}

public function testMinimumExample(): void
{
Expand Down Expand Up @@ -101,8 +100,7 @@ public function testMinimumExample(): void
8500
)
);
$orderRequestHeader->addComment(new Comment(null, null, null, 'delivery-note.pdf'));

$orderRequestHeader->addComment(new Comment(null, null, null, 'delivery-note.pdf'));

$orderRequest = OrderRequest::create(
$orderRequestHeader
Expand Down Expand Up @@ -159,7 +157,7 @@ public function testMinimumExample(): void
$xml = Serializer::create()->serialize($cxml);
$this->assertXmlStringEqualsXmlFile('tests/metadata/cxml/samples/OrderRequest.xml', $xml);

$this->dtdValidator->validateAgainstDtd($xml);
$this->dtdValidator->validateAgainstDtd($xml);
}

public function newPayloadIdentity(): PayloadIdentity
Expand Down
15 changes: 7 additions & 8 deletions tests/CXmlTest/Model/ProductActivityMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@
*/
class ProductActivityMessageTest extends TestCase implements PayloadIdentityFactoryInterface
{
private DtdValidator $dtdValidator;

private DtdValidator $dtdValidator;

protected function setUp(): void
{
$this->dtdValidator = new DtdValidator(__DIR__.'/../../metadata/cxml/dtd/1.2.050/');
}
protected function setUp(): void
{
$this->dtdValidator = new DtdValidator(__DIR__.'/../../metadata/cxml/dtd/1.2.050/');
}

public function testMinimumExample(): void
{
Expand Down Expand Up @@ -73,8 +72,8 @@ public function testMinimumExample(): void
$xml = Serializer::create()->serialize($cxml);
$this->assertXmlStringEqualsXmlFile('tests/metadata/cxml/samples/ProductActivityMessage.xml', $xml);

$this->dtdValidator->validateAgainstDtd($xml);
}
$this->dtdValidator->validateAgainstDtd($xml);
}

public function newPayloadIdentity(): PayloadIdentity
{
Expand Down
2 changes: 1 addition & 1 deletion tests/CXmlTest/Model/PunchOutSetupRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function testMinimumExample(): void
$this->dtdValidator->validateAgainstDtd($xml);

$this->assertXmlStringEqualsXmlFile(__DIR__.'/../../metadata/cxml/samples/PunchOutSetupRequest.xml', $xml);
}
}

public function newPayloadIdentity(): PayloadIdentity
{
Expand Down
95 changes: 45 additions & 50 deletions tests/CXmlTest/Model/QuoteMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
use CXml\Model\Contact;
use CXml\Model\Country;
use CXml\Model\Credential;
use CXml\Model\Inventory;
use CXml\Model\InventoryQuantity;
use CXml\Model\ItemId;
use CXml\Model\Message\ProductActivityDetail;
use CXml\Model\Message\ProductActivityMessage;
use CXml\Model\Message\QuoteMessage;
use CXml\Model\Message\QuoteMessageHeader;
use CXml\Model\MoneyWrapper;
Expand All @@ -23,7 +18,6 @@
use CXml\Payload\PayloadIdentityFactoryInterface;
use CXml\Serializer;
use CXml\Validation\DtdValidator;
use PhpParser\Node\Expr\AssignOp\Mul;
use PHPUnit\Framework\TestCase;

/**
Expand All @@ -32,13 +26,12 @@
*/
class QuoteMessageTest extends TestCase implements PayloadIdentityFactoryInterface
{
private DtdValidator $dtdValidator;

private DtdValidator $dtdValidator;

protected function setUp(): void
{
$this->dtdValidator = new DtdValidator(__DIR__.'/../../metadata/cxml/dtd/1.2.050/');
}
protected function setUp(): void
{
$this->dtdValidator = new DtdValidator(__DIR__.'/../../metadata/cxml/dtd/1.2.050/');
}

public function testMinimumExample(): void
{
Expand All @@ -56,48 +49,50 @@ public function testMinimumExample(): void
'abracadabra'
);

$organizationId = new OrganizationId(
new Credential(
'domain',
'identity'
)
);
$organizationId = new OrganizationId(
new Credential(
'domain',
'identity'
)
);

$total = new MoneyWrapper('USD', 10000);
$total = new MoneyWrapper('USD', 10000);

$quoteMessage = QuoteMessage::create(
$organizationId,
$total,
QuoteMessageHeader::TYPE_ACCEPT,
'quoteId',
new \DateTime('2021-01-08T23:00:06-08:00'),
'de'
$organizationId,
$total,
QuoteMessageHeader::TYPE_ACCEPT,
'quoteId',
new \DateTime('2021-01-08T23:00:06-08:00'),
'de'
);

$contact = Contact::create(new MultilanguageString('Joe Smith'))
->addEmail('[email protected]')
->addIdReference('GUID', '123456');

$shipTo = new ShipTo(
new Address(
new MultilanguageString('Acme Inc.'),
new PostalAddress(
['Acme Inc.', 'Joe Smith'],
['123 Anystreet'],
'Sunnyvale',
new Country('US', 'United States'),
null,
'CA',
'90489'
)
)
);

$quoteMessage->getQuoteMessageHeader()
->setContact($contact)
->setShipTo($shipTo)
->addExtrinsicAsKeyValue('expiry_date', '2023-01-08T23:00:06-08:00')
->addCommentAsString('This is a comment');
$contact = Contact::create(new MultilanguageString('Joe Smith'))
->addEmail('[email protected]')
->addIdReference('GUID', '123456')
;

$shipTo = new ShipTo(
new Address(
new MultilanguageString('Acme Inc.'),
new PostalAddress(
['Acme Inc.', 'Joe Smith'],
['123 Anystreet'],
'Sunnyvale',
new Country('US', 'United States'),
null,
'CA',
'90489'
)
)
);

$quoteMessage->getQuoteMessageHeader()
->setContact($contact)
->setShipTo($shipTo)
->addExtrinsicAsKeyValue('expiry_date', '2023-01-08T23:00:06-08:00')
->addCommentAsString('This is a comment')
;

$cxml = Builder::create('Supplier’s Super Order Processor', 'en-US', $this)
->from($from)
Expand All @@ -112,7 +107,7 @@ public function testMinimumExample(): void
$xml = Serializer::create()->serialize($cxml);
$this->assertXmlStringEqualsXmlFile('tests/metadata/cxml/samples/QuoteMessage.xml', $xml);

$this->dtdValidator->validateAgainstDtd($xml);
$this->dtdValidator->validateAgainstDtd($xml);
}

public function newPayloadIdentity(): PayloadIdentity
Expand Down
4 changes: 2 additions & 2 deletions tests/CXmlTest/Model/SerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@ public function testSerializeDateOnly(): void
</Request>
</cXML>';

$this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
$this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}

public function testDeserializeOneRowXml(): void
{
Expand Down
13 changes: 6 additions & 7 deletions tests/CXmlTest/Model/ShipNoticeRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
*/
class ShipNoticeRequestTest extends TestCase implements PayloadIdentityFactoryInterface
{
private DtdValidator $dtdValidator;

private DtdValidator $dtdValidator;

protected function setUp(): void
{
$this->dtdValidator = new DtdValidator(__DIR__.'/../../metadata/cxml/dtd/1.2.050/');
}
protected function setUp(): void
{
$this->dtdValidator = new DtdValidator(__DIR__.'/../../metadata/cxml/dtd/1.2.050/');
}

public function testMinimumExample(): void
{
Expand Down Expand Up @@ -77,7 +76,7 @@ public function testMinimumExample(): void
$xml = Serializer::create()->serialize($cxml);
$this->assertXmlStringEqualsXmlFile('tests/metadata/cxml/samples/ShipNoticeRequest.xml', $xml);

$this->dtdValidator->validateAgainstDtd($xml);
$this->dtdValidator->validateAgainstDtd($xml);
}

public function newPayloadIdentity(): PayloadIdentity
Expand Down
Loading