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
5 changes: 5 additions & 0 deletions .changeset/twenty-spies-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cambis/silverstan": patch
---

Remove spread operators from DisallowMethodCallOnUnsafeDataObjectRule.
2 changes: 0 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^9.6",
"rector/rector": "2.2.4",
"rector/rector": "^2.3",
"shipmonk/composer-dependency-analyser": "^1.7",
"silverstripe/assets": "^2.3",
"silverstripe/cms": "^5.2",
Expand Down
11 changes: 11 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

declare(strict_types=1);

use PhpCsFixer\Fixer\Import\OrderedImportsFixer;
use PhpCsFixer\Fixer\Operator\NewWithParenthesesFixer;
use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer;
use SlevomatCodingStandard\Sniffs\Namespaces\ReferenceUsedNamesOnlySniff;
Expand All @@ -26,6 +27,16 @@
'allowFallbackGlobalConstants' => false,
]
)
->withConfiguredRule(
OrderedImportsFixer::class,
[
'imports_order' => [
'class',
'function',
'const',
],
]
)
->withPreparedSets(
common: true,
psr12: true,
Expand Down
11 changes: 6 additions & 5 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/** @type {import('lint-staged').Config} */
module.exports = {
'*.php': [
'php vendor/bin/parallel-lint --colors --blame',
'php vendor/bin/rector process --ansi',
'php vendor/bin/ecs check --fix --ansi',
'*.php': (filenames) => [
`php vendor/bin/parallel-lint src tests --colors --blame ${filenames.join(' ')}`,
`php vendor/bin/rector process --dry-run --ansi ${filenames.join(' ')}`,
`php vendor/bin/ecs check --fix --ansi ${filenames.join(' ')}`,
'php vendor/bin/phpstan analyse --ansi --memory-limit=-1',
],
'!(e2e/*/composer.json)composer.json': [
'composer normalize --ansi'
'composer normalize --ansi',
],
};
12 changes: 6 additions & 6 deletions src/Rule/MethodCall/DisallowMethodCallOnUnsafeDataObjectRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

use Cambis\Silverstan\Normaliser\Normaliser;
use Cambis\Silverstan\Type\ObjectType\UnsafeObjectType;
use Cambis\Silverstan\Type\TypeSpecifyingExtension\DataObjectDeleteTypeSpecifyingExtension;
use Cambis\Silverstan\Type\TypeSpecifyingExtension\DataObjectExistsTypeSpecifyingExtension;
use Cambis\Silverstan\Type\TypeSpecifyingExtension\DataObjectWriteTypeSpecifyingExtension;
use Cambis\Silverstan\ValueObject\ClassAllowedMethodCall;
use Override;
use PhpParser\Node;
Expand All @@ -35,9 +32,12 @@
* @var string[]
*/
private const DEFAULT_ALLOWED_METHODS_CALLS = [
...DataObjectDeleteTypeSpecifyingExtension::SUPPORTED_METHODS,
...DataObjectExistsTypeSpecifyingExtension::SUPPORTED_METHODS,
...DataObjectWriteTypeSpecifyingExtension::SUPPORTED_METHODS,
'delete',
'exists',
'isInDB',
'publishRecursive',
'publishSingle',
'write',
];

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ final class DataObjectDeleteTypeSpecifyingExtension implements MethodTypeSpecify
{
/**
* @var string[]
* @api
*/
public const SUPPORTED_METHODS = [
'delete',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ final class DataObjectExistsTypeSpecifyingExtension implements MethodTypeSpecify
{
/**
* @var string[]
* @api
*/
public const SUPPORTED_METHODS = [
'exists',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ final class DataObjectWriteTypeSpecifyingExtension implements MethodTypeSpecifyi
{
/**
* @var string[]
* @api
*/
public const SUPPORTED_METHODS = [
'publishRecursive',
Expand Down
16 changes: 0 additions & 16 deletions src/TypeResolver/ValueObject/ResolvedTypes.php

This file was deleted.