Skip to content
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

Add rector [batch] #54

Closed
wants to merge 6 commits into from
Closed
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
21 changes: 21 additions & 0 deletions .github/workflows/rector.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on:
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'psalm.xml'

name: rector

jobs:
rector:
uses: yiisoft/actions/.github/workflows/rector.yml@master
with:
os: >-
['ubuntu-latest']
php: >-
['8.0']
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"rector/rector": "^0.14.3",
"roave/infection-static-analysis-plugin": "^1.16",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.18",
Expand Down
22 changes: 22 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests',
]);

// register a single rule
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);

// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_80,
]);
};
88 changes: 0 additions & 88 deletions src/Alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ final class Alert extends Widget
* The HTML attributes for the main widget tag.
*
* @param array $value Array of attribute name => attribute value pairs.
*
* @return static
*/
public function attributes(array $value): self
{
Expand All @@ -60,8 +58,6 @@ public function attributes(array $value): self
* The message body.
*
* @param string $value The message body.
*
* @return static
*/
public function body(string $value): self
{
Expand All @@ -75,8 +71,6 @@ public function body(string $value): self
*
* @param array $value Array of attribute name => attribute value pairs.
*
* @return static
*
* {@see Html::renderTagAttributes()} for details on how attributes are being rendered.
*/
public function bodyAttributes(array $value): self
Expand All @@ -90,8 +84,6 @@ public function bodyAttributes(array $value): self
* CSS class for the message body tag.
*
* @param string $value CSS class name.
*
* @return static
*/
public function bodyClass(string $value): self
{
Expand All @@ -102,10 +94,6 @@ public function bodyClass(string $value): self

/**
* Allows you to add an extra wrapper for the message body.
*
* @param string|null $tag
*
* @return static
*/
public function bodyTag(?string $tag = null): self
{
Expand All @@ -123,8 +111,6 @@ public function bodyTag(?string $tag = null): self
*
* @param array $value
*
* @return static
*
* {@see Html::renderTagAttributes()} for details on how attributes are being rendered.
*/
public function bodyContainerAttributes(array $value): self
Expand All @@ -136,10 +122,6 @@ public function bodyContainerAttributes(array $value): self

/**
* The CSS class for extra message wrapper.
*
* @param string $value
*
* @return static
*/
public function bodyContainerClass(string $value): self
{
Expand All @@ -150,10 +132,6 @@ public function bodyContainerClass(string $value): self

/**
* Allows you to add an extra wrapper for the panel body.
*
* @param bool $value
*
* @return static
*/
public function bodyContainer(bool $value): self
{
Expand All @@ -173,8 +151,6 @@ public function bodyContainer(bool $value): self
*
* @param array $value
*
* @return static
*
* {@see Html::renderTagAttributes()} for details on how attributes are being rendered.
*/
public function buttonAttributes(array $value): self
Expand All @@ -186,10 +162,6 @@ public function buttonAttributes(array $value): self

/**
* The CSS class for the button.
*
* @param string $value
*
* @return static
*/
public function buttonClass(string $value): self
{
Expand All @@ -200,10 +172,6 @@ public function buttonClass(string $value): self

/**
* The label for the button.
*
* @param string $value
*
* @return static
*/
public function buttonLabel(string $value = ''): self
{
Expand All @@ -214,10 +182,6 @@ public function buttonLabel(string $value = ''): self

/**
* The onclick JavaScript for the button.
*
* @param string $value
*
* @return static
*/
public function buttonOnClick(string $value): self
{
Expand All @@ -228,10 +192,6 @@ public function buttonOnClick(string $value): self

/**
* Set attribute class for main widget tag.
*
* @param string $value
*
* @return static
*/
public function class(string $value): self
{
Expand All @@ -249,10 +209,6 @@ public function id(?string $value): self

/**
* The header content.
*
* @param string $value
*
* @return static
*/
public function header(string $value): self
{
Expand All @@ -266,8 +222,6 @@ public function header(string $value): self
*
* @param array $value
*
* @return static
*
* {@see Html::renderTagAttributes()} for details on how attributes are being rendered.
*/
public function headerAttributes(array $value): self
Expand All @@ -279,10 +233,6 @@ public function headerAttributes(array $value): self

/**
* The CSS class for the header.
*
* @param string $value
*
* @return static
*/
public function headerClass(string $value): self
{
Expand All @@ -293,10 +243,6 @@ public function headerClass(string $value): self

/**
* Allows you to add a div tag to the header extra wrapper.
*
* @param bool $value
*
* @return static
*/
public function headerContainer(bool $value = true): self
{
Expand All @@ -307,10 +253,6 @@ public function headerContainer(bool $value = true): self

/**
* The CSS class for the header extra wrapper.
*
* @param string $value
*
* @return static
*/
public function headerContainerClass(string $value): self
{
Expand All @@ -324,8 +266,6 @@ public function headerContainerClass(string $value): self
*
* @param array $value
*
* @return static
*
* {@see Html::renderTagAttributes()} for details on how attributes are being rendered.
*/
public function headerContainerAttributes(array $value): self
Expand All @@ -338,11 +278,7 @@ public function headerContainerAttributes(array $value): self
/**
* Set tag name for the header.
*
* @param string $value
*
* @throws InvalidArgumentException
*
* @return static
*/
public function headerTag(string $value): self
{
Expand All @@ -360,8 +296,6 @@ public function headerTag(string $value): self
*
* @param array $value
*
* @return static
*
* {@see Html::renderTagAttributes()} for details on how attributes are being rendered.
*/
public function iconAttributes(array $value): self
Expand All @@ -373,10 +307,6 @@ public function iconAttributes(array $value): self

/**
* Set icon CSS class.
*
* @param string $value
*
* @return static
*/
public function iconClass(string $value): self
{
Expand All @@ -392,8 +322,6 @@ public function iconClass(string $value): self
*
* @param array $value
*
* @return static
*
* {@see Html::renderTagAttributes()} for details on how attributes are being rendered.
*/
public function iconContainerAttributes(array $value): self
Expand All @@ -405,10 +333,6 @@ public function iconContainerAttributes(array $value): self

/**
* The CSS class for the icon container.
*
* @param string $value
*
* @return static
*/
public function iconContainerClass(string $value): self
{
Expand All @@ -419,10 +343,6 @@ public function iconContainerClass(string $value): self

/**
* Set icon text.
*
* @param string $value
*
* @return static
*/
public function iconText(string $value): self
{
Expand All @@ -433,10 +353,6 @@ public function iconText(string $value): self

/**
* Set layout body.
*
* @param string $value
*
* @return static
*/
public function layoutBody(string $value): self
{
Expand All @@ -447,10 +363,6 @@ public function layoutBody(string $value): self

/**
* Set layout header.
*
* @param string $value
*
* @return static
*/
public function layoutHeader(string $value): self
{
Expand Down
8 changes: 1 addition & 7 deletions src/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,15 @@ final class Block extends Widget
{
private ?string $id = null;
private bool $renderInPlace = false;
private WebView $webView;

public function __construct(WebView $webView)
public function __construct(private WebView $webView)
{
$this->webView = $webView;
}

/**
* Returns a new instance with the specified Widget ID.
*
* @param string $value The Widget ID.
*
* @return self
*/
public function id(string $value): self
{
Expand All @@ -71,8 +67,6 @@ public function id(string $value): self
* Enables in-place rendering and returns a new instance.
*
* Without calling this method, the captured content of the block is not displayed.
*
* @return self
*/
public function renderInPlace(): self
{
Expand Down
Loading