Skip to content

Commit

Permalink
fix some phpinsights error
Browse files Browse the repository at this point in the history
  • Loading branch information
heqiming committed Jul 29, 2024
1 parent 023f470 commit c3f5fa1
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 5 deletions.
2 changes: 2 additions & 0 deletions phpinsights.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
docker run -it --rm -v "$(pwd):/app" nunomaduro/phpinsights $*
5 changes: 4 additions & 1 deletion pint.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"preset": "laravel"
"preset": "laravel",
"rules": {
"new_with_parentheses": false
}
}
6 changes: 5 additions & 1 deletion src/Rules/Hash.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ class Hash extends AbstractRule implements RuleContract

/**
* configuration for the specified driver.
*
* @var array<mixed, mixed>
*/
protected array $options = [];

public function __construct(?HasherContract $hasher = null)
{
if (is_null($hasher)) {
$hasher = new BcryptHasher;
$hasher = new BcryptHasher();
}
$this->use($hasher);
}
Expand All @@ -55,6 +57,8 @@ public function use(HasherContract $hasher): self

/**
* set hasher options
*
* @param array<mixed, mixed> $options
*/
public function options(array $options): self
{
Expand Down
2 changes: 1 addition & 1 deletion src/Rules/Mask.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function transform($input)
$left = $this->paddingLeft;
$right = $this->paddingRight;

if ($len < ($left + $right)) {
if ($len < $left + $right) {
return str_repeat($this->aterisk, $this->repeatTimes);
}

Expand Down
9 changes: 7 additions & 2 deletions src/Rules/Mix.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Leoboy\Desensitization package.
*
Expand All @@ -25,15 +27,18 @@ class Mix extends AbstractRule implements RuleContract
/**
* bound rules list
*
* @var RuleContract[]
* @var array<RuleContract>
*/
protected array $rules = [];

/**
* @param array<RuleContract> $rules
*/
public function __construct(array $rules = [])
{
foreach ($rules as $rule) {
if (! ($rule instanceof RuleContract)) {
throw new InvalidRuleException('Rule must be instance of RuleContract: '.get_class($rule));
throw new InvalidRuleException('Rule must be instance of RuleContract: '.$rule::class);
}
}
$this->rules = $rules;
Expand Down
2 changes: 2 additions & 0 deletions src/Rules/None.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Leoboy\Desensitization package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/Rules/Replace.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Leoboy\Desensitization package.
*
Expand Down

0 comments on commit c3f5fa1

Please sign in to comment.