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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"captainhook/captainhook": "^5.27",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^12.4",
"phpunit/phpunit": "^13.0",
"slevomat/coding-standard": "^8.24",
"squizlabs/php_codesniffer": "^4.0",
"symfony/validator": "^8.0",
Expand Down
504 changes: 306 additions & 198 deletions composer.lock

Large diffs are not rendered by default.

20 changes: 18 additions & 2 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@
</rule>

<config name="installed_paths" value="../../slevomat/coding-standard"/>
<rule ref="SlevomatCodingStandard.Attributes.DisallowAttributesJoining"/>
<rule ref="SlevomatCodingStandard.Attributes.DisallowMultipleAttributesPerLine"/>

<rule ref="SlevomatCodingStandard.Classes.BackedEnumTypeSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility"/>
<rule ref="SlevomatCodingStandard.Classes.ConstantSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>

<rule ref="SlevomatCodingStandard.TypeHints.ClassConstantTypeHint"/>
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="spacesCountAroundEqualsSign" value="0"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint"/>
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/>

Expand All @@ -36,12 +45,14 @@
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
<rule ref="SlevomatCodingStandard.Whitespaces.DuplicateSpaces"/>

<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses"/>
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>

<rule ref="SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable"/>
<rule ref="SlevomatCodingStandard.Variables.UnusedVariable"/>
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>

<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses"/>
Expand All @@ -55,7 +66,12 @@
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/>
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator"/>
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
<rule ref="SlevomatCodingStandard.Complexity.Cognitive"/>
<rule ref="SlevomatCodingStandard.Complexity.Cognitive">
<properties>
<property name="warningThreshold" value="6"/>
<property name="errorThreshold" value="7"/>
</properties>
</rule>

<file>bin</file>
<file>examples</file>
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
bootstrap="./vendor/autoload.php"
colors="true"
stderr="true"
beStrictAboutTestsThatDoNotTestAnything="false"
requireSealedMockObjects="true"
displayDetailsOnPhpunitDeprecations="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
Expand Down
2 changes: 1 addition & 1 deletion src/Dependency/Finder/FinderIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Picamator\TransferObject\Dependency\Finder;

use IteratorAggregate;
use Countable;
use IteratorAggregate;
use Symfony\Component\Finder\Finder;
use Traversable;

Expand Down
2 changes: 1 addition & 1 deletion src/Generated/DefinitionBuiltInTypeTransfer.php

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

2 changes: 1 addition & 1 deletion src/Shared/Filesystem/FileAppender.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function appendToFile(string $filename, string $content): void

if ($writeResult === false) {
throw new FileAppenderException(
sprintf('Failed to write content "%s" into the file "%s".', $content, $filename),
sprintf('Failed to write content into the file "%s".', $filename),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Shared/Filesystem/FileReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private function closeFile($file, string $filename): void
}

throw new FileReaderException(
sprintf('Failed to close "%s" file.', $filename),
sprintf('Failed to close file "%s".', $filename),
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Shared/Reader/FileReaderProgress.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ private function getTotalBytes(string $filename): int
{
if (!$this->fileExists($filename)) {
throw new FileReaderException(
sprintf('File "%s" is not exist.', $filename),
sprintf('File "%s" does not exist.', $filename),
);
}

$fileSize = $this->filesize($filename);
if ($fileSize === 0) {
throw new FileReaderException(
sprintf('File size "%s" is empty.', $filename),
sprintf('File "%s" is empty.', $filename),
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Transfer/Attribute/AttributeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private function getConstantReflection(string $constantName, string $attributeNa
$firstReflectionAttribute = $reflectionAttributes[0] ?? null;
if ($firstReflectionAttribute === null) {
throw new AttributeTransferException(
\sprintf('Constant\'s "%s" attribute "%s" not found.', $constantName, $attributeName),
\sprintf('Attribute "%s" not found for constant "%s".', $constantName, $attributeName),
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/TransferGenerator/Config/Config/ConfigProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private function getConfig(): ConfigInterface
}

throw new TransferGeneratorConfigNotFoundException(
'Transfer Object generator configuration not found. Please load configuration first.'
'Transfer Object generator configuration not found. Please load the configuration first.'
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{
use ValidatorMessageTrait;

private const string ERROR_MESSAGE_TEMPLATE = 'Missing required configuration keys: "%s".';
private const string ERROR_MESSAGE_TEMPLATE = 'Missing required configuration keys: %s.';

public function validate(ConfigContentTransfer $configContentTransfer): ?ValidatorMessageTransfer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

private const string FILE_NAME_PATTERN = '*.transfer.yml';

private const string DEFINITIONS_NOT_FOUND_ERROR_MESSAGE = 'Missed Transfer Object definitions.';
private const string DEFINITIONS_NOT_FOUND_ERROR_MESSAGE = 'Missing Transfer Object definitions.';

public function __construct(
private FinderInterface $finder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{
use ValidatorMessageTrait;

private const string PROPERTY_ERROR_MESSAGE_TEMPLATE = 'Class "%s" properties were not defined.';
private const string PROPERTY_ERROR_MESSAGE_TEMPLATE = 'Properties for class "%s" are not defined.';

public function validate(DefinitionContentTransfer $contentTransfer): ?ValidatorMessageTransfer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
private const string ATTRIBUTE_NOT_FOUND_ERROR_MESSAGE_TEMPLATE = 'Attribute "%s" not found.';
private const string INVALID_ATTRIBUTE_ERROR_MESSAGE_TEMPLATE = 'Class "%s" is not an attribute.';
private const string INVALID_ATTRIBUTE_TARGET_ERROR_MESSAGE_TEMPLATE
= 'Attribute "%s" is not allowed to target on properties.';
= 'Attribute "%s" is not allowed to target properties.';

public function isApplicable(DefinitionPropertyTransfer $propertyTransfer): bool
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace Picamator\TransferObject\TransferGenerator\Generator\Render\Expander;

use Picamator\TransferObject\Generated\DefinitionPropertyTransfer;
use Picamator\TransferObject\Generated\TemplateTransfer;
use Picamator\TransferObject\TransferGenerator\Definition\Enum\BuiltInTypeEnum;
use Picamator\TransferObject\TransferGenerator\Generator\Enum\DocBlockTemplateEnum;
use Picamator\TransferObject\TransferGenerator\Generator\Enum\InitiatorAttributeEnum;
use Picamator\TransferObject\TransferGenerator\Generator\Enum\TransformerAttributeEnum;
use Picamator\TransferObject\Generated\DefinitionPropertyTransfer;
use Picamator\TransferObject\Generated\TemplateTransfer;

final class BuiltInTypeTemplateExpander extends AbstractTemplateExpander
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
use Picamator\TransferObject\Generated\DefinitionPropertyTransfer;
use Picamator\TransferObject\Generated\TemplateTransfer;
use Picamator\TransferObject\TransferGenerator\Definition\Enum\BuiltInTypeEnum;
use Picamator\TransferObject\TransferGenerator\Generator\Enum\DocBlockTemplateEnum;
use Picamator\TransferObject\TransferGenerator\Generator\Enum\InitiatorAttributeEnum;
use Picamator\TransferObject\TransferGenerator\Generator\Enum\TransformerAttributeTemplateEnum;
use Picamator\TransferObject\TransferGenerator\Generator\Enum\DocBlockTemplateEnum;

final class CollectionTypeTemplateExpander extends AbstractTemplateExpander
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace Picamator\TransferObject\TransferGenerator\Generator\Render\Expander;

use Picamator\TransferObject\TransferGenerator\Generator\Enum\TransformerAttributeTemplateEnum;
use Picamator\TransferObject\Generated\DefinitionPropertyTransfer;
use Picamator\TransferObject\Generated\TemplateTransfer;
use Picamator\TransferObject\TransferGenerator\Generator\Enum\TransformerAttributeTemplateEnum;

final class DateTimeTypeTemplateExpander extends AbstractTemplateExpander
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace Picamator\TransferObject\TransferGenerator\Generator\Render\Expander;

use Picamator\TransferObject\TransferGenerator\Generator\Enum\TransformerAttributeTemplateEnum;
use Picamator\TransferObject\Generated\DefinitionPropertyTransfer;
use Picamator\TransferObject\Generated\TemplateTransfer;
use Picamator\TransferObject\TransferGenerator\Generator\Enum\TransformerAttributeTemplateEnum;

final class EnumTypeTemplateExpander extends AbstractTemplateExpander
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace Picamator\TransferObject\TransferGenerator\Generator\Render\Expander;

use Picamator\TransferObject\TransferGenerator\Generator\Enum\TransformerAttributeTemplateEnum;
use Picamator\TransferObject\Generated\DefinitionPropertyTransfer;
use Picamator\TransferObject\Generated\TemplateTransfer;
use Picamator\TransferObject\TransferGenerator\Generator\Enum\TransformerAttributeTemplateEnum;

final class NumberTypeTemplateExpander extends AbstractTemplateExpander
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function testRunCommandWithEmptyConfigurationShouldShowErrorMessage(): vo

// Assert
$this->assertSame(1, $this->commandTester->getStatusCode());
$this->assertStringContainsString('[ERROR] File size', $output);
$this->assertStringContainsString('empty', $output);
}

#[TestDox('Run command with valid configuration but invalid definition should show error message')]
Expand Down Expand Up @@ -112,7 +112,8 @@ public function testRunCommandWithValidConfigurationAndFailedFiberStartShouldSho
// Expect
$generatorFacadeMock->expects($this->once())
->method('getTransferGeneratorBulkFiber')
->willReturn($fiber);
->willReturn($fiber)
->seal();

// Act
$commandTester->execute(
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/Command/TransferGeneratorCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ public function testRunCommandWithValidConfigurationAndFailedFiberStartShouldSho
// Expect
$generatorFacadeMock->expects($this->once())
->method('getTransferGeneratorFiber')
->willReturn($fiber);
->willReturn($fiber)
->seal();

// Act
$commandTester->execute(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function testCompareSampleDataWithTransferObjectShouldSuccessfullyMatch(
$actual = $transfer->toArray();

// Assert
$this->assertEquals($sampleContent, $actual);
$this->assertArraysAreEqual($sampleContent, $actual);
}

/**
Expand Down Expand Up @@ -241,7 +241,7 @@ public function testCompareFilteredSampleDataWithTransferObjectShouldSuccessfull
$actual = $this->filterArrayRecursive($transfer->toArray(), $filterCallback);

// Assert
$this->assertEquals($sampleContent, $actual);
$this->assertArraysAreEqual($sampleContent, $actual);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions tests/integration/Transfer/Adapter/DummyTransferAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected function setUp(): void
$this->bookmarkData = new BookmarkData();
}

#[TestDox('Transformation fromArray and toArray')]
#[TestDox('Transformation fromArray() and toArray()')]
public function testTransformationFromArrayToArray(): void
{
// Arrange
Expand All @@ -32,10 +32,10 @@ public function testTransformationFromArrayToArray(): void
$actual = $bookmarkData->toArray();

// Assert
$this->assertSame([], $actual);
$this->assertArraysAreIdentical([], $actual);
}

#[TestDox('Transfer count')]
#[TestDox('Transfer count()')]
public function testTransferCount(): void
{
// Act
Expand All @@ -52,17 +52,17 @@ public function testTransferIterator(): void
$actual = iterator_to_array($this->bookmarkData);

// Assert
$this->assertSame([], $actual);
$this->assertArraysAreIdentical([], $actual);
}

#[TestDox('Transfer debugInfo')]
#[TestDox('Transfer debugInfo()')]
public function testTransferDebugInfo(): void
{
// Act
$actual = $this->bookmarkData->__debugInfo();

// Assert
$this->assertSame([], $actual);
$this->assertArraysAreIdentical([], $actual);
}

#[TestDox('Transfer jsonSerialize')]
Expand Down
Loading