Skip to content

Commit

Permalink
phpstan 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rodber committed Nov 26, 2024
1 parent 3f27c35 commit ea3145a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"kevinlebrun/colors.php": "^1.0"
},
"require-dev": {
"phpstan/phpstan": "^1.9",
"phpstan/phpstan": "^2.0",
"phpunit/phpunit": "^9.5",
"symplify/easy-coding-standard": "^11.1"
},
Expand Down
9 changes: 7 additions & 2 deletions src/Outputs/Output.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ final public function setUp(WriterInterface $writer, array $trace): void
$this->writer = $writer;
$this->trace = $trace;
$frame = $this->trace[0] ?? [];
/** @var string $class */
$class = $frame['class'] ?? '';
/** @var string $type */
$type = $frame['type'] ?? '';
$this->caller = $class . $type;
/** @var ?string $function */
$function = $frame['function'] ?? null;
if ($function !== null) {
$this->caller .= $function . '()';
Expand Down Expand Up @@ -67,13 +70,15 @@ final public function caller(): string

protected function getCallerFile(FormatInterface $format): string
{
$item = $this->trace[0] ?? null;
$item = $this->trace[0] ?? [];
// @codeCoverageIgnoreStart
if (! isset($item['file'])) {
return '@';
}
// @codeCoverageIgnoreEnd
$fileLine = $item['file'] . ':' . $item['line'];
$fileLine = $item['file'] // @phpstan-ignore-line
. ':'
. $item['line'];

return $format->highlight(
VarDumperInterface::FILE,
Expand Down
2 changes: 1 addition & 1 deletion src/VarDumpInstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

final class VarDumpInstance
{
private static ?VarDumpInterface $instance;
private static VarDumpInterface $instance;

public function __construct(VarDumpInterface $varDump)
{
Expand Down
10 changes: 0 additions & 10 deletions src/VarDumpable.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

namespace Chevere\VarDump;

use Chevere\VarDump\Interfaces\ProcessorInterface;
use Chevere\VarDump\Interfaces\VarDumpableInterface;
use Chevere\VarDump\Interfaces\VarDumperInterface;
use LogicException;
Expand Down Expand Up @@ -63,15 +62,6 @@ private function assertSetProcessorName(): void
)
);
}
if (! is_subclass_of($processorName, ProcessorInterface::class, true)) {
throw new LogicException(
(string) message(
'Processor `%processorName%` must implement the `%interfaceName%` interface',
processorName: $processorName,
interfaceName: ProcessorInterface::class,
)
);
}
$this->processorName = $processorName;
}
}

0 comments on commit ea3145a

Please sign in to comment.