coding-standard
coding-standard copied to clipboard
Slevomat Coding Standard for PHP_CodeSniffer provides many useful sniffs
```php $this->something->__invoke() ``` is fixed to ```php $this->something(); ``` which is of course wrong because it will try to call the `something()` method on `$this` instead of the `__invoke()` method...
Is it possible to force specify traversable types for local vars (using @var PHPDoc annotation)? I only found rules for parameters, properties and return values.
```php /** * @param \Propel\Runtime\Collection\ObjectCollection|\Orm\Zed\ExampleStateMachine\Persistence\PyzExampleStateMachineItem[] $exampleStateMachineItems * * @return array */ protected function hydrateTransferFromPersistence($exampleStateMachineItems) ``` results in ``` 54 | ERROR | [x] Usage of array type hint syntax in...
```php /** * Checks if current position is valid * * @return bool */ #[\ReturnTypeWillChange] public function valid() { return isset($this->dataSet[$this->position]); } ``` triggers ``` 55 | ERROR | [x]...
Hello, I just found condition that I believe could be simplified to nullsafe call automatically. From: ```php if ($this->paginator !== null) { $this->paginator->setItemsPerPage($this->itemsPerPage); } ``` To: ```php $this->paginator?->setItemsPerPage($this->itemsPerPage); ``` Feel...
It would be good if ``SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.allowPartialUses`` would be enhanced with a list of allowed namespaces (only specified namespaces are allowed to be used partial) and/or a list of namespaces that...
I have noticed there is no sniff that would handle correct indentation inside a block or comments etc. Or am I wrong and there is a sniff that would handle...
Non-static anonymous functions when used inside classes create a closure for `$this` even if it's not used. So far so good - there is a sniff for that already. But,...
I would like to be able to use the `UselessParentheses` sniff as it is right now, but disable it when used around an arrow function body like this: ```php $fn...
I was wondering if there is a sniff that can enforce placement of the `?` and `:` symbols. Given the following snippet: ```php $class = array_key_exists($foo, 'bar') ? $foo['bar']['class'] :...