Skip to content

Commit

Permalink
Minor adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
magicsunday committed Aug 2, 2024
1 parent 1ab319b commit 8c01570
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '8.1', '8.2', '8.3' ]
php: [ '7.3', '7.4.', '8.0' ]

steps:
- id: checkout
Expand Down
16 changes: 2 additions & 14 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
->setRiskyAllowed(true)
->setRules([
'@PSR12' => true,
'@PER-CS2.0' => true,
'@Symfony' => true,

// Additional custom rules
Expand All @@ -57,19 +56,9 @@
'phpdoc_to_comment' => false,
'phpdoc_no_alias_tag' => false,
'no_superfluous_phpdoc_tags' => false,
'phpdoc_separation' => [
'groups' => [
[
'author',
'license',
'link',
],
],
],
'phpdoc_separation' => true,
'no_alias_functions' => true,
'whitespace_after_comma_in_array' => [
'ensure_single_space' => true,
],
'whitespace_after_comma_in_array' => true,
'single_line_throw' => false,
'self_accessor' => false,
'global_namespace_import' => [
Expand All @@ -79,7 +68,6 @@
],
'function_declaration' => [
'closure_function_spacing' => 'one',
'closure_fn_spacing' => 'one',
],
'binary_operator_spaces' => [
'operators' => [
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"require-dev": {
"phpdocumentor/reflection-docblock": "^4.0 || ^5.0",
"friendsofphp/php-cs-fixer": "^3.1",
"friendsofphp/php-cs-fixer": "^2.0 || ^3.0",
"overtrue/phplint": "^2.0 || ^3.0 || ^9.0",
"phpunit/phpunit": "^9.0 || ^10.0 || ^11.0",
"phpstan/phpstan": "^1.10",
Expand Down
9 changes: 4 additions & 5 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
colors="true"
columns="max"
stderr="true"
bootstrap="./.build/vendor/autoload.php"
cacheDirectory=".phpunit.cache"
>
<testsuites>
<testsuite name="Integration Tests">
<directory>./test</directory>
</testsuite>
</testsuites>
<source>
<coverage>
<include>
<directory>./src</directory>
<directory suffix=".php">./src</directory>
</include>
</source>
</coverage>
</phpunit>
8 changes: 1 addition & 7 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector;
use Rector\DeadCode\Rector\Property\RemoveUselessVarTagRector;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Php80\Rector\FunctionLike\MixedTypeRector;
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByMethodCallTypeRector;
Expand All @@ -44,17 +41,14 @@
SetList::CODING_STYLE,
SetList::CODE_QUALITY,
SetList::DEAD_CODE,
LevelSetList::UP_TO_PHP_81,
LevelSetList::UP_TO_PHP_73,
]);

// Skip some rules
$rectorConfig->skip([
CatchExceptionNameMatchingTypeRector::class,
ClassPropertyAssignToConstructorPromotionRector::class,
LocallyCalledStaticMethodToNonStaticRector::class,
MixedTypeRector::class,
ParamTypeByMethodCallTypeRector::class,
ReadOnlyPropertyRector::class,
RemoveUselessParamTagRector::class,
RemoveUselessReturnTagRector::class,
RemoveUselessVarTagRector::class,
Expand Down
4 changes: 2 additions & 2 deletions src/JsonMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ private function getReflectionProperty(string $className, string $propertyName):
{
try {
return new ReflectionProperty($className, $propertyName);
} catch (ReflectionException) {
} catch (ReflectionException $exception) {
return null;
}
}
Expand Down Expand Up @@ -421,7 +421,7 @@ private function getDefaultValue(string $className, string $propertyName)
return null;
}

return $reflectionProperty->getDefaultValue();
return $reflectionProperty->getDeclaringClass()->getDefaultProperties()[$propertyName] ?? null;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion test/Annotation/ReplacePropertyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ class ReplacePropertyTest extends TestCase
{
/**
* Tests replacing a property.
*
* @test
*/
#[Test]
public function replaceProperty(): void
{
$result = $this->getJsonMapper()
Expand Down
7 changes: 4 additions & 3 deletions test/Classes/Initialized.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace MagicSunday\Test\Classes;

use MagicSunday\JsonMapper\Annotation\ReplaceNullWithDefaultValue;
/**
* Class Initialized.
*
Expand All @@ -23,21 +24,21 @@ class Initialized
/**
* @var int
*
* @MagicSunday\JsonMapper\Annotation\ReplaceNullWithDefaultValue
* @ReplaceNullWithDefaultValue
*/
public $integer = 10;

/**
* @var bool
*
* @MagicSunday\JsonMapper\Annotation\ReplaceNullWithDefaultValue
* @ReplaceNullWithDefaultValue
*/
public $bool = false;

/**
* @var array<string>
*
* @MagicSunday\JsonMapper\Annotation\ReplaceNullWithDefaultValue
* @ReplaceNullWithDefaultValue
*/
public $array = [];
}
3 changes: 2 additions & 1 deletion test/Converter/CamelCasePropertyNameConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ class CamelCasePropertyNameConverterTest extends TestCase
{
/**
* Tests mapping json properties to camel case.
*
* @test
*/
#[Test]
public function checkCamelCasePropertyNameConverter(): void
{
$converter = new CamelCasePropertyNameConverter();
Expand Down
Loading

0 comments on commit 8c01570

Please sign in to comment.