diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ae20cbe..6d6b31f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -49,8 +49,14 @@ jobs: - name: 'Run composer audit' run: 'composer audit --format=plain' + - name: 'Run Parallel Lint' + run: 'vendor/bin/parallel-lint --exclude vendor .' + - name: 'Run PHP CodeSniffer' run: 'vendor/bin/phpcs --extensions=php,phtml' - name: 'Run PHPMD' run: 'vendor/bin/phpmd . xml phpmd.xml.dist' + + - name: 'Run PHPStan' + run: 'vendor/bin/phpstan analyse' diff --git a/Block/Toolbar.php b/Block/Toolbar.php index 78e11de..62c7256 100644 --- a/Block/Toolbar.php +++ b/Block/Toolbar.php @@ -19,27 +19,14 @@ */ class Toolbar extends MagentoTemplateBlock { - /** - * @var DataHelper - */ - protected $dataHelper; + protected DataHelper $dataHelper; + protected SummaryFactory $blockSummaryFactory; /** * @var Zone\AbstractZone[] */ - protected $zones = []; - - /** - * @var SummaryFactory - */ - protected $blockSummaryFactory; + protected array $zones = []; - /** - * @param Context $context - * @param DataHelper $dataHelper - * @param SummaryFactory $blockSummaryFactory - * @param array $data - */ public function __construct( Context $context, DataHelper $dataHelper, @@ -56,9 +43,6 @@ public function __construct( /** * Load the zones. - * - * @param MagentoRequest $request - * @param MagentoResponse $response */ public function loadZones(MagentoRequest $request, MagentoResponse $response): void { @@ -96,8 +80,6 @@ public function getZones(): array /** * Do we have a warning? - * - * @return bool */ public function isWarning(): bool { @@ -115,7 +97,6 @@ public function isWarning(): bool /** * Get the toolbar id. * - * @return string * @throws RuntimeException */ public function getToolbarId(): string diff --git a/Block/Toolbars.php b/Block/Toolbars.php index b8aa54a..b08200d 100644 --- a/Block/Toolbars.php +++ b/Block/Toolbars.php @@ -14,16 +14,8 @@ */ class Toolbars extends MagentoTemplateBlock { - /** - * @var DataHelper - */ - protected $dataHelper; + protected DataHelper $dataHelper; - /** - * @param Context $context - * @param DataHelper $dataHelper - * @param array $data - */ public function __construct(Context $context, DataHelper $dataHelper, array $data = []) { parent::__construct($context, $data); diff --git a/Block/Zone/AbstractZone.php b/Block/Zone/AbstractZone.php index 2b64b39..3f85cda 100644 --- a/Block/Zone/AbstractZone.php +++ b/Block/Zone/AbstractZone.php @@ -16,37 +16,12 @@ */ abstract class AbstractZone extends MagentoTemplateBlock { - /** - * @var bool - */ - protected $warning = false; - - /** - * @var DataHelper - */ - protected $dataHelper; - - /** - * @var FormatterFactory - */ - protected $formatterFactory; + protected DataHelper $dataHelper; + protected FormatterFactory $formatterFactory; + protected Summary $summaryBlock; + protected bool $warning = false; + protected array $tablesToDisplay = []; - /** - * @var Summary - */ - protected $summaryBlock; - - /** - * @var array - */ - protected $tablesToDisplay = []; - - /** - * @param Context $context - * @param DataHelper $dataHelper - * @param FormatterFactory $formatterFactory - * @param array $data - */ public function __construct( Context $context, DataHelper $dataHelper, @@ -63,15 +38,11 @@ public function __construct( /** * Get the code. - * - * @return string */ abstract public function getCode(): string; /** * Get the title. - * - * @return string */ abstract public function getTitle(): string; @@ -85,12 +56,8 @@ public function toHtml() /** * Add the summary block. - * - * @param Summary $block - * - * @return $this */ - public function setSummaryBlock(Summary $block): AbstractZone + public function setSummaryBlock(Summary $block): self { $this->summaryBlock = $block; @@ -100,8 +67,6 @@ public function setSummaryBlock(Summary $block): AbstractZone /** * Add a value to the summary. * - * @param string $sectionName - * @param string $key * @param mixed $value */ public function addToSummary(string $sectionName, string $key, $value): void @@ -111,10 +76,8 @@ public function addToSummary(string $sectionName, string $key, $value): void /** * Set the warning flag. - * - * @return $this */ - public function hasWarning(): AbstractZone + public function hasWarning(): self { $this->warning = true; @@ -123,8 +86,6 @@ public function hasWarning(): AbstractZone /** * Have we a warning? - * - * @return bool */ public function isWarning(): bool { @@ -133,9 +94,6 @@ public function isWarning(): bool /** * Display sections. - * - * @param array $sections - * @return string */ public function displaySections(array $sections = []): string { @@ -163,9 +121,6 @@ public function displaySections(array $sections = []): string /** * Display sections. - * - * @param array $sections - * @return string */ public function displaySectionsGrouped(array $sections = []): string { @@ -198,7 +153,8 @@ public function displaySectionsGrouped(array $sections = []): string */ protected function getClassAndValue($value): array { - if (!is_array($value) + if ( + !is_array($value) || !array_key_exists('value', $value) || !array_key_exists('css_class', $value) ) { @@ -213,7 +169,6 @@ protected function getClassAndValue($value): array * * @param string|int $name * @param mixed $value - * @return string */ protected function displaySectionValue($name, $value): string { @@ -224,8 +179,6 @@ protected function displaySectionValue($name, $value): string /** * Get the toolbar id. - * - * @return string */ public function getToolbarId(): string { @@ -234,12 +187,6 @@ public function getToolbarId(): string /** * Display the table. - * - * @param string $title - * @param array $values - * @param array $columns - * @param string|null $additional - * @return string */ public function displayTable(string $title, array &$values, array $columns, ?string $additional = null): string { @@ -274,8 +221,6 @@ public function displayTable(string $title, array &$values, array $columns, ?str /** * Get the tables to display. - * - * @return array */ public function getTablesToDisplay(): array { @@ -284,9 +229,6 @@ public function getTablesToDisplay(): array /** * Get a timer. - * - * @param string $code - * @return float */ public function getTimer(string $code): float { @@ -297,10 +239,6 @@ public function getTimer(string $code): float * Format a value, using rules, and type. * * @param string|float $value - * @param array $rules - * @param string|null $type - * - * @return array */ public function formatValue($value, array $rules = [], ?string $type = null): array { diff --git a/Block/Zone/Cache.php b/Block/Zone/Cache.php index 0bb8e1d..834a047 100644 --- a/Block/Zone/Cache.php +++ b/Block/Zone/Cache.php @@ -15,24 +15,9 @@ */ class Cache extends AbstractZone { - /** - * @var DeploymentConfig - */ - protected $deployConfig; - - /** - * @var CacheHelper - */ - protected $cacheHelper; + protected DeploymentConfig $deployConfig; + protected CacheHelper $cacheHelper; - /** - * @param Context $context - * @param DataHelper $dataHelper - * @param FormatterFactory $formatterFactory - * @param DeploymentConfig $deployConfig - * @param CacheHelper $cacheHelper - * @param array $data - */ public function __construct( Context $context, DataHelper $dataHelper, @@ -64,8 +49,6 @@ public function getTitle(): string /** * Get the cache mode. - * - * @return string */ public function getCacheMode(): string { @@ -94,8 +77,6 @@ public function getCacheInfo() /** * Get the cache types. - * - * @return array */ public function getCacheTypes(): array { @@ -104,8 +85,6 @@ public function getCacheTypes(): array /** * Get the cache usage. - * - * @return array */ public function getCacheUsage(): array { @@ -114,8 +93,6 @@ public function getCacheUsage(): array /** * Get the usage per action. - * - * @return array */ public function getStatsPerAction(): array { @@ -124,9 +101,6 @@ public function getStatsPerAction(): array /** * Prepare calls for display in the table. - * - * @param array $calls - * @return string */ public function buildHtmlInfo(array $calls = []): string { diff --git a/Block/Zone/Generic.php b/Block/Zone/Generic.php index 4ef998d..645f6b8 100644 --- a/Block/Zone/Generic.php +++ b/Block/Zone/Generic.php @@ -17,30 +17,10 @@ */ class Generic extends AbstractZone { - /** - * @var ProductMetadataInterface - */ - protected $productMetadata; - - /** - * @var AppState - */ - protected $appState; + protected ProductMetadataInterface $productMetadata; + protected AppState $appState; + protected DeploymentConfig $deployConfig; - /** - * @var DeploymentConfig - */ - protected $deployConfig; - - /** - * @param Context $context - * @param DataHelper $dataHelper - * @param FormatterFactory $formatterFactory - * @param ProductMetadataInterface $productMetadata - * @param AppState $appState - * @param DeploymentConfig $deployConfig - * @param array $data - */ public function __construct( Context $context, DataHelper $dataHelper, @@ -74,8 +54,6 @@ public function getTitle(): string /** * Get the product name. - * - * @return string */ public function getProductName(): string { @@ -84,8 +62,6 @@ public function getProductName(): string /** * Get the product edition. - * - * @return string */ public function getProductEdition(): string { @@ -94,8 +70,6 @@ public function getProductEdition(): string /** * Get the product version. - * - * @return string */ public function getProductVersion(): string { @@ -104,8 +78,6 @@ public function getProductVersion(): string /** * Get the magento area. - * - * @return string */ public function getMagentoArea(): string { @@ -118,8 +90,6 @@ public function getMagentoArea(): string /** * Get the magento mode. - * - * @return string */ public function getMagentoMode(): string { @@ -128,8 +98,6 @@ public function getMagentoMode(): string /** * Get the session mode. - * - * @return string */ public function getSessionMode(): string { @@ -158,8 +126,6 @@ public function getSessionInfo() /** * Get the php version. - * - * @return string */ public function getPhpVersion(): string { @@ -168,8 +134,6 @@ public function getPhpVersion(): string /** * Get the php memory limit. - * - * @return int */ public function getPhpMemoryLimit(): int { @@ -194,8 +158,6 @@ public function getPhpMemoryLimit(): int /** * Get the php memory used. - * - * @return int */ public function getPhpMemoryUsed(): int { @@ -204,8 +166,6 @@ public function getPhpMemoryUsed(): int /** * Get the php max execution time. - * - * @return int */ public function getPhpMaxExecutionTime(): int { @@ -214,8 +174,6 @@ public function getPhpMaxExecutionTime(): int /** * Get the php max execution time. - * - * @return float */ public function getPhpExecutionTime(): float { diff --git a/Block/Zone/Layout.php b/Block/Zone/Layout.php index 3f36cce..f9807c1 100644 --- a/Block/Zone/Layout.php +++ b/Block/Zone/Layout.php @@ -14,18 +14,8 @@ */ class Layout extends AbstractZone { - /** - * @var LayoutHelper - */ - protected $layoutHelper; + protected LayoutHelper $layoutHelper; - /** - * @param Context $context - * @param DataHelper $dataHelper - * @param FormatterFactory $formatterFactory - * @param LayoutHelper $layoutHelper - * @param array $data - */ public function __construct( Context $context, DataHelper $dataHelper, @@ -55,8 +45,6 @@ public function getTitle(): string /** * Get the layout build. - * - * @return array */ public function getLayoutBuild(): array { @@ -65,8 +53,6 @@ public function getLayoutBuild(): array /** * Get the updated handles. - * - * @return array */ public function getHandles(): array { @@ -75,8 +61,6 @@ public function getHandles(): array /** * Display the layout table. - * - * @return string */ public function displayLayoutTable(): string { @@ -85,10 +69,6 @@ public function displayLayoutTable(): string /** * Display a recursive table. - * - * @param array $list - * @param int $level - * @return string */ protected function displayLayoutRecursive(array $list, int $level): string { @@ -103,10 +83,6 @@ protected function displayLayoutRecursive(array $list, int $level): string /** * Display a row of a recursive table. - * - * @param array $row - * @param int $level - * @return string */ protected function displayLayoutRecursiveRow(array $row, int $level): string { @@ -127,7 +103,7 @@ protected function displayLayoutRecursiveRow(array $row, int $level): string $html .= ' style="' . ($row['parent'] ? 'display: none' : '') . '"'; $html .= '>'; $html .= '
'; $html .= 'Type: ' . $row['type'] . "\n"; diff --git a/Block/Zone/Mysql.php b/Block/Zone/Mysql.php index ddc4514..85ff0dd 100644 --- a/Block/Zone/Mysql.php +++ b/Block/Zone/Mysql.php @@ -4,6 +4,7 @@ namespace Smile\DebugToolbar\Block\Zone; +use Magento\Framework\Filesystem\DirectoryList; use Magento\Framework\View\Element\Template\Context; use Smile\DebugToolbar\Formatter\FormatterFactory; use Smile\DebugToolbar\Helper\Data as DataHelper; @@ -14,27 +15,20 @@ */ class Mysql extends AbstractZone { - /** - * @var ResourceModel - */ - protected $resourceModel; + protected ResourceModel $resourceModel; + protected DirectoryList $directoryList; - /** - * @param Context $context - * @param DataHelper $dataHelper - * @param FormatterFactory $formatterFactory - * @param ResourceModel $resourceModel - * @param array $data - */ public function __construct( Context $context, DataHelper $dataHelper, FormatterFactory $formatterFactory, ResourceModel $resourceModel, + DirectoryList $directoryList, array $data = [] ) { parent::__construct($context, $dataHelper, $formatterFactory, $data); $this->resourceModel = $resourceModel; + $this->directoryList = $directoryList; } /** @@ -55,8 +49,6 @@ public function getTitle(): string /** * Get all the queries. - * - * @return array */ public function getQueries(): array { @@ -65,8 +57,6 @@ public function getQueries(): array /** * Get count per types. - * - * @return array */ public function getCountPerTypes(): array { @@ -75,8 +65,6 @@ public function getCountPerTypes(): array /** * Get time per types. - * - * @return array */ public function getTimePerTypes(): array { @@ -85,8 +73,6 @@ public function getTimePerTypes(): array /** * Get the Mysql version. - * - * @return string */ public function getMysqlVersion(): string { @@ -95,10 +81,6 @@ public function getMysqlVersion(): string /** * Prepare params and trace for display in the table. - * - * @param array $params - * @param array $trace - * @return string */ public function buildHtmlInfo(array $params = [], array $trace = []): string { @@ -138,7 +120,7 @@ public function buildHtmlInfo(array $params = [], array $trace = []): string $line = $match[2]; $code = $match[3]; } - $file = str_replace(BP . '/', '', $file); + $file = str_replace($this->directoryList->getRoot() . '/', '', $file); $html .= ""; $html .= " " . $this->_escaper->escapeHtml($file) . " "; $html .= "" . $this->_escaper->escapeHtml($line) . " "; diff --git a/Block/Zone/Observer.php b/Block/Zone/Observer.php index 06bd325..3515414 100644 --- a/Block/Zone/Observer.php +++ b/Block/Zone/Observer.php @@ -14,18 +14,8 @@ */ class Observer extends AbstractZone { - /** - * @var ObserverHelper - */ - protected $observerHelper; + protected ObserverHelper $observerHelper; - /** - * @param Context $context - * @param DataHelper $dataHelper - * @param FormatterFactory $formatterFactory - * @param ObserverHelper $observerHelper - * @param array $data - */ public function __construct( Context $context, DataHelper $dataHelper, @@ -55,8 +45,6 @@ public function getTitle(): string /** * Get the observer stats. - * - * @return array */ public function getObserverStats(): array { @@ -65,9 +53,6 @@ public function getObserverStats(): array /** * Prepare observers for display in the table. - * - * @param array $observers - * @return string */ public function buildHtmlInfo(array $observers = []): string { diff --git a/Block/Zone/Preference.php b/Block/Zone/Preference.php index a047c13..e5a9722 100644 --- a/Block/Zone/Preference.php +++ b/Block/Zone/Preference.php @@ -14,18 +14,8 @@ */ class Preference extends AbstractZone { - /** - * @var PreferenceHelper - */ - protected $preferenceHelper; + protected PreferenceHelper $preferenceHelper; - /** - * @param Context $context - * @param DataHelper $dataHelper - * @param FormatterFactory $formatterFactory - * @param PreferenceHelper $preferenceHelper - * @param array $data - */ public function __construct( Context $context, DataHelper $dataHelper, @@ -55,8 +45,6 @@ public function getTitle(): string /** * Get the plugin stats. - * - * @return array */ public function getPluginStats(): array { @@ -65,8 +53,6 @@ public function getPluginStats(): array /** * Get the preference stats. - * - * @return array */ public function getPreferenceStats(): array { @@ -77,7 +63,6 @@ public function getPreferenceStats(): array * Get html info. * * @param string[] $methods - * @return string */ public function buildPluginHtmlInfo(array $methods): string { diff --git a/Block/Zone/Profiler.php b/Block/Zone/Profiler.php index e3b0ee9..caed5a6 100644 --- a/Block/Zone/Profiler.php +++ b/Block/Zone/Profiler.php @@ -15,18 +15,8 @@ */ class Profiler extends AbstractZone { - /** - * @var ProfilerHelper - */ - protected $profilerHelper; + protected ProfilerHelper $profilerHelper; - /** - * @param Context $context - * @param DataHelper $dataHelper - * @param FormatterFactory $formatterFactory - * @param ProfilerHelper $profilerHelper - * @param array $data - */ public function __construct( Context $context, DataHelper $dataHelper, @@ -57,7 +47,6 @@ public function getTitle(): string /** * Get the profiler timers. * - * @return array * @throws RuntimeException */ public function getTimers(): array diff --git a/Block/Zone/Request.php b/Block/Zone/Request.php index 8452cb8..2a389cf 100644 --- a/Block/Zone/Request.php +++ b/Block/Zone/Request.php @@ -12,10 +12,7 @@ */ class Request extends AbstractZone { - /** - * @var MagentoRequest - */ - protected $request; + protected MagentoRequest $request; /** * @inheritdoc @@ -35,11 +32,8 @@ public function getTitle(): string /** * Set the request. - * - * @param MagentoRequest $request - * @return $this */ - public function setRequest(MagentoRequest $request): Request + public function setRequest(MagentoRequest $request): self { $this->request = $request; @@ -56,8 +50,6 @@ public function getRequest(): RequestInterface /** * Get the controller class name. - * - * @return string */ public function getControllerClassName(): string { diff --git a/Block/Zone/Response.php b/Block/Zone/Response.php index f2cc405..a7215d2 100644 --- a/Block/Zone/Response.php +++ b/Block/Zone/Response.php @@ -11,10 +11,7 @@ */ class Response extends AbstractZone { - /** - * @var MagentoResponse - */ - protected $response; + protected MagentoResponse $response; /** * @inheritdoc @@ -34,11 +31,8 @@ public function getTitle(): string /** * Set the response. - * - * @param MagentoResponse $response - * @return $this */ - public function setResponse(MagentoResponse $response): Response + public function setResponse(MagentoResponse $response): self { $this->response = $response; @@ -47,8 +41,6 @@ public function setResponse(MagentoResponse $response): Response /** * Get the response. - * - * @return MagentoResponse */ public function getResponse(): MagentoResponse { @@ -57,8 +49,6 @@ public function getResponse(): MagentoResponse /** * Get the Full Page Cache mode. - * - * @return string */ public function getFullPageCacheMode(): string { diff --git a/Block/Zone/Summary.php b/Block/Zone/Summary.php index 6265b73..8a80fc3 100644 --- a/Block/Zone/Summary.php +++ b/Block/Zone/Summary.php @@ -9,10 +9,7 @@ */ class Summary extends AbstractZone { - /** - * @var array - */ - protected $summary = []; + protected array $summary = []; /** * @inheritdoc @@ -32,8 +29,6 @@ public function getTitle(): string /** * Get the summary sections. - * - * @return array */ public function getSummarySections(): array { diff --git a/DB/Profiler.php b/DB/Profiler.php index ed9c489..b74847d 100644 --- a/DB/Profiler.php +++ b/DB/Profiler.php @@ -5,37 +5,22 @@ namespace Smile\DebugToolbar\DB; use Zend_Db_Profiler as OriginalProfiler; -use Zend_Db_Profiler_Exception; /** * DB profiler. */ class Profiler extends OriginalProfiler { - /** - * @var string - */ - protected $host = ''; - - /** - * @var string - */ - protected $type = ''; - - /** - * @var string|null - */ - protected $lastQueryId; - - /** - * @var array - */ - protected $queries; + protected ?array $queries = null; + protected string $host = ''; + protected string $type = ''; + /** @var string|int|null $lastQueryId */ + protected $lastQueryId = null; /** * @var string[] */ - protected $types = [ + protected array $types = [ self::CONNECT => 'connect', self::QUERY => 'query', self::INSERT => 'insert', @@ -47,11 +32,8 @@ class Profiler extends OriginalProfiler /** * Setter for host IP. - * - * @param string $host - * @return $this */ - public function setHost(string $host): Profiler + public function setHost(string $host): self { $this->host = $host; @@ -60,11 +42,8 @@ public function setHost(string $host): Profiler /** * Setter for database connection type. - * - * @param string $type - * @return $this */ - public function setType(string $type): Profiler + public function setType(string $type): self { $this->type = $type; @@ -72,11 +51,7 @@ public function setType(string $type): Profiler } /** - * Starts a query. Creates a new query profile object. - * - * @param string $queryText - * @param int|null $queryType - * @return int|null + * @inheritDoc */ public function queryStart($queryText, $queryType = null): ?int { @@ -100,9 +75,6 @@ public function queryStart($queryText, $queryType = null): ?int /** * Get the query type. - * - * @param string $queryText - * @return int */ protected function getTypeFromQuery(string $queryText): int { @@ -137,9 +109,6 @@ protected function getTypeFromQuery(string $queryText): int /** * Get a type from its id. - * - * @param int $typeId - * @return string */ protected function getTypeText(int $typeId): string { @@ -153,11 +122,7 @@ protected function getTypeText(int $typeId): string } /** - * Ends a query. Pass it the handle that was returned by queryStart(). - * - * @param int $queryId - * @return string - * @throws Zend_Db_Profiler_Exception + * @inheritDoc */ public function queryEnd($queryId): string { @@ -168,8 +133,6 @@ public function queryEnd($queryId): string /** * Get the queries as array. - * - * @return array */ public function getQueryProfilesAsArray(): array { @@ -192,9 +155,6 @@ public function getQueryProfilesAsArray(): array /** * Convert a query profile to a array. - * - * @param Profiler\Query $queryProfile - * @return array */ protected function convertQueryProfileToArray(Profiler\Query $queryProfile): array { @@ -221,8 +181,6 @@ public function getTypes(): array /** * Get a count per types. - * - * @return array */ public function getCountPerTypes(): array { @@ -244,8 +202,6 @@ public function getCountPerTypes(): array /** * Get a count per types. - * - * @return array */ public function getTimePerTypes(): array { diff --git a/DB/Profiler/Query.php b/DB/Profiler/Query.php index f68ba37..9bd2d09 100644 --- a/DB/Profiler/Query.php +++ b/DB/Profiler/Query.php @@ -15,7 +15,7 @@ class Query extends OriginalProfilerQuery /** * @var string[] */ - protected $trace; + protected array $trace; /** * @inheritdoc diff --git a/Formatter/Formatter.php b/Formatter/Formatter.php index 565cc3e..39930d4 100644 --- a/Formatter/Formatter.php +++ b/Formatter/Formatter.php @@ -23,47 +23,16 @@ class Formatter * @var mixed */ protected $value; + protected string $formattedValue; + protected string $type; + protected ?string $subType = null; + protected bool $warning = false; + protected Escaper $escaper; + protected array $rules; + protected array $cssClasses = []; /** - * @var string - */ - protected $formattedValue; - - /** - * @var string - */ - protected $type; - - /** - * @var string - */ - protected $subType; - - /** - * @var array - */ - protected $rules; - - /** - * @var bool - */ - protected $warning = false; - - /** - * @var array - */ - protected $cssClasses = []; - - /** - * @var Escaper - */ - protected $escaper; - - /** - * @param Escaper $escaper * @param mixed $value - * @param string|null $type - * @param array $rules */ public function __construct(Escaper $escaper, $value, ?string $type = null, array $rules = []) { @@ -78,7 +47,6 @@ public function __construct(Escaper $escaper, $value, ?string $type = null, arra * Prepare the value and type. * * @param mixed $value - * @param string|null $type */ protected function prepareValueAndType($value, ?string $type): void { @@ -106,8 +74,6 @@ protected function prepareValueAndType($value, ?string $type): void /** * Prepare the type. - * - * @param string|null $type */ protected function prepareType(?string $type): void { @@ -132,8 +98,6 @@ protected function prepareType(?string $type): void /** * Get the type from the value. - * - * @return string */ protected function getTypeFromValue(): string { @@ -161,8 +125,6 @@ protected function getTypeFromValue(): string /** * Compute the rules. * - * @param array $rules - * @return bool * @throws RuntimeException */ protected function computeRules(array $rules): bool @@ -187,9 +149,7 @@ protected function computeRules(array $rules): bool /** * Compute a rule. * - * @param string $ruleTest * @param mixed $ruleValue - * @return bool * @throws RuntimeException */ protected function computeRule(string $ruleTest, $ruleValue): bool @@ -251,9 +211,6 @@ protected function computeFormattedValue(): void /** * Display human size. - * - * @param int $value - * @return string */ protected function displayHumanSize(int $value): string { @@ -262,7 +219,7 @@ protected function displayHumanSize(int $value): string } if ($this->subType === 'mo') { - $value /= (1024. * 1024.); + $value /= 1024. * 1024.; } if ($this->subType === 'go') { @@ -293,9 +250,6 @@ protected function displayHumanSize(int $value): string /** * Display human time (in seconds). - * - * @param float $value - * @return string */ protected function displayHumanTime(float $value): string { @@ -370,8 +324,6 @@ public function getResult(): array /** * Do we have a warning? - * - * @return bool */ public function hasWarning(): bool { diff --git a/Helper/Cache.php b/Helper/Cache.php index b2160b8..8b19cb0 100644 --- a/Helper/Cache.php +++ b/Helper/Cache.php @@ -14,30 +14,11 @@ */ class Cache extends AbstractHelper { - /** - * @var TypeListInterface - */ - protected $cacheTypeList; + protected TypeListInterface $cacheTypeList; + protected ?array $cacheTypes = null; + protected array $cacheUsage = []; + protected array $cacheStats = []; - /** - * @var array - */ - protected $cacheTypes; - - /** - * @var array - */ - protected $cacheUsage = []; - - /** - * @var array - */ - protected $cacheStats = []; - - /** - * @param Context $context - * @param TypeListInterface $cacheTypeList - */ public function __construct(Context $context, TypeListInterface $cacheTypeList) { parent::__construct($context); @@ -68,11 +49,6 @@ public function __construct(Context $context, TypeListInterface $cacheTypeList) /** * Add a stat on cache usage. - * - * @param string $action - * @param string $identifier - * @param float $deltaTime - * @param int $size */ public function addStat(string $action, string $identifier, float $deltaTime = 0., int $size = 0): void { @@ -116,8 +92,6 @@ public function addStat(string $action, string $identifier, float $deltaTime = 0 /** * Get the cache usage. - * - * @return array */ public function getCacheUsage(): array { @@ -126,8 +100,6 @@ public function getCacheUsage(): array /** * Get the cache usage per action. - * - * @return array */ public function getStatsPerAction(): array { @@ -136,8 +108,6 @@ public function getStatsPerAction(): array /** * Get the cache types. - * - * @return array */ public function getCacheTypes(): array { @@ -146,7 +116,7 @@ public function getCacheTypes(): array $invalidated = $this->cacheTypeList->getInvalidated(); - /** @var DataObject $items */ + /** @var DataObject[] $items */ $items = $this->cacheTypeList->getTypes(); foreach ($items as $item) { diff --git a/Helper/Config.php b/Helper/Config.php index 42555a4..0f874d2 100644 --- a/Helper/Config.php +++ b/Helper/Config.php @@ -13,8 +13,6 @@ class Config extends AbstractHelper { /** * Check whether the module is enabled. - * - * @return bool */ public function isEnabled(): bool { @@ -23,8 +21,6 @@ public function isEnabled(): bool /** * Check whether the toolbar can be shown in the admin area. - * - * @return bool */ public function isEnabledAdmin(): bool { @@ -33,8 +29,6 @@ public function isEnabledAdmin(): bool /** * Get the config value for keep_last_execution. - * - * @return int */ public function getNbExecutionToKeep(): int { diff --git a/Helper/Data.php b/Helper/Data.php index 1b893d4..8dc161d 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -22,41 +22,13 @@ */ class Data extends AbstractHelper { - /** - * @var DirectoryList - */ - protected $directoryList; - - /** - * @var AppState - */ - protected $appState; - - /** - * @var float[] - */ - protected $timers = []; - - /** - * @var string - */ - protected $toolbarId; - - /** - * @var array - */ - protected $values = []; - - /** - * @var int - */ - protected $tableCount = 0; + protected DirectoryList $directoryList; + protected AppState $appState; + protected array $timers = []; + protected ?string $toolbarId = null; + protected array $values = []; + protected int $tableCount = 0; - /** - * @param Context $context - * @param DirectoryList $directoryList - * @param AppState $appState - */ public function __construct(Context $context, DirectoryList $directoryList, AppState $appState) { parent::__construct($context); @@ -66,11 +38,8 @@ public function __construct(Context $context, DirectoryList $directoryList, AppS /** * Start a timer. - * - * @param string $code - * @return $this */ - public function startTimer(string $code): Data + public function startTimer(string $code): self { $this->timers[$code] = [ 'start' => microtime(true), @@ -83,11 +52,8 @@ public function startTimer(string $code): Data /** * Stop a timer. - * - * @param string $code - * @return $this */ - public function stopTimer(string $code): Data + public function stopTimer(string $code): self { if (!array_key_exists($code, $this->timers)) { $this->startTimer($code); @@ -103,9 +69,6 @@ public function stopTimer(string $code): Data /** * Get a timer. - * - * @param string $code - * @return float */ public function getTimer(string $code): float { @@ -117,11 +80,9 @@ public function getTimer(string $code): float /** * Set a value. * - * @param string $key * @param mixed $value - * @return $this */ - public function setValue(string $key, $value): Data + public function setValue(string $key, $value): self { $this->values[$key] = $value; @@ -131,7 +92,6 @@ public function setValue(string $key, $value): Data /** * Get a value. * - * @param string $key * @param mixed $default * @return mixed */ @@ -147,8 +107,6 @@ public function getValue(string $key, $default = null) /** * Init the toolbar id. * - * @param string $actionName - * @return string * @throws RuntimeException * @throws LocalizedException * @SuppressWarnings(PMD.StaticAccess) @@ -178,7 +136,6 @@ public function initToolbarId(string $actionName): string /** * Get toolbar id. * - * @return string * @throws RuntimeException */ public function getToolbarId(): string @@ -192,8 +149,6 @@ public function getToolbarId(): string /** * Get a new table id. - * - * @return string */ public function getNewTableId(): string { @@ -205,7 +160,6 @@ public function getNewTableId(): string /** * Get the toolbar storage folder. * - * @return string * @throws FileSystemException * @throws RuntimeException */ @@ -223,7 +177,6 @@ public function getToolbarFolder(): string /** * Save the current toolbar. * - * @param Toolbar $toolbarBlock * @throws FileSystemException * @throws RuntimeException */ @@ -237,7 +190,6 @@ public function saveToolbar(Toolbar $toolbarBlock): void /** * Clean the old toolbars. * - * @param int $nbToKeep * @throws FileSystemException * @throws RuntimeException */ @@ -305,8 +257,6 @@ public function getContentToolbars(): array /** * Get the Full Page Cache mode. - * - * @return string */ public function getFullPageCacheMode(): string { diff --git a/Helper/Layout.php b/Helper/Layout.php index 76cac21..9c21c91 100644 --- a/Helper/Layout.php +++ b/Helper/Layout.php @@ -6,9 +6,10 @@ use Magento\Framework\App\Helper\AbstractHelper; use Magento\Framework\App\Helper\Context; +use Magento\Framework\Filesystem\DirectoryList; use Magento\Framework\View\Element\AbstractBlock; +use Magento\Framework\View\Layout as MagentoLayout; use Magento\Framework\View\Layout\Element; -use Magento\Framework\View\LayoutInterface as MagentoLayoutInterface; use ReflectionClass; use ReflectionException; use Smile\DebugToolbar\Layout\Builder; @@ -18,32 +19,24 @@ */ class Layout extends AbstractHelper { - /** - * @var MagentoLayoutInterface - */ - protected $layout; + protected MagentoLayout $layout; + protected DirectoryList $directoryList; - /** - * @param Context $context - * @param MagentoLayoutInterface $layout - * @param Builder $builder - */ public function __construct( Context $context, - MagentoLayoutInterface $layout, - Builder $builder + MagentoLayout $layout, + Builder $builder, + DirectoryList $directoryList ) { parent::__construct($context); - $this->layout = $layout; $this->layout->setBuilder($builder); + $this->directoryList = $directoryList; } /** * Build the layout. * - * @param string $parentNode - * @return array * @throws ReflectionException */ protected function buildLayout(string $parentNode): array @@ -99,9 +92,6 @@ protected function buildLayout(string $parentNode): array /** * Check if a template can be cached. - * - * @param string $blockName - * @return bool */ protected function isBlockCacheable(string $blockName): bool { @@ -114,9 +104,6 @@ protected function isBlockCacheable(string $blockName): bool /** * Clean a classname. - * - * @param string $classname - * @return string */ protected function cleanClassname(string $classname): string { @@ -125,20 +112,15 @@ protected function cleanClassname(string $classname): string /** * Clean a filename. - * - * @param string $filename - * @return string */ protected function cleanFilename(string $filename): string { - - return str_replace(BP . '/', '', $filename); + return str_replace($this->directoryList->getRoot() . '/', '', $filename); } /** * Get the event stats. * - * @return array * @throws ReflectionException */ public function getLayoutBuild(): array @@ -148,8 +130,6 @@ public function getLayoutBuild(): array /** * Get updated handles. - * - * @return array */ public function getHandles(): array { diff --git a/Helper/Observer.php b/Helper/Observer.php index ed5e2f9..cea4f9d 100644 --- a/Helper/Observer.php +++ b/Helper/Observer.php @@ -11,15 +11,10 @@ */ class Observer extends AbstractHelper { - /** - * @var array - */ - protected $eventStats = []; + protected array $eventStats = []; /** * Init event stat. - * - * @param string $eventName */ public function initEventStat(string $eventName): void { @@ -40,11 +35,6 @@ public function initEventStat(string $eventName): void /** * Init a stat on observer usage. - * - * @param string $eventName - * @param string $observerName - * @param string $observerInstance - * @param bool $observerDisabled */ public function initObserverStat( string $eventName, @@ -71,9 +61,6 @@ public function initObserverStat( /** * Add a stat on event usage. - * - * @param string $eventName - * @param float $deltaTime */ public function addEventStat(string $eventName, float $deltaTime): void { @@ -88,10 +75,6 @@ public function addEventStat(string $eventName, float $deltaTime): void /** * Add a stat on observer usage. - * - * @param string $eventName - * @param string $observerName - * @param float $deltaTime */ public function addObserverStat(string $eventName, string $observerName, float $deltaTime): void { @@ -106,8 +89,6 @@ public function addObserverStat(string $eventName, string $observerName, float $ /** * Get the event stats. - * - * @return array */ public function getEventStats(): array { diff --git a/Helper/Preference.php b/Helper/Preference.php index 1b16526..c030f9e 100644 --- a/Helper/Preference.php +++ b/Helper/Preference.php @@ -19,21 +19,9 @@ */ class Preference extends AbstractHelper { - /** - * @var PluginList - */ - protected $pluginList; - - /** - * @var ObjectManagerConfig - */ - protected $objectManagerConfig; + protected PluginList $pluginList; + protected ObjectManagerConfig $objectManagerConfig; - /** - * @param Context $context - * @param PluginList $pluginList - * @param ObjectManagerConfig $objectManagerConfig - */ public function __construct( Context $context, PluginList $pluginList, @@ -48,7 +36,6 @@ public function __construct( /** * Get the plugin stats. * - * @return array * @throws ReflectionException */ public function getPluginStats(): array @@ -56,9 +43,9 @@ public function getPluginStats(): array // Get some properties without rewrite but the properties are private $reflectionClass = new ReflectionClass($this->pluginList); - /** @var DefinitionInterface $definitions */ $property = $reflectionClass->getProperty('_definitions'); $property->setAccessible(true); + /** @var DefinitionInterface $definitions */ $definitions = $property->getValue($this->pluginList); $property = $reflectionClass->getProperty('_pluginInstances'); @@ -93,9 +80,6 @@ public function getPluginStats(): array /** * Get the plugin type. - * - * @param int $methodType - * @return string */ protected function getPluginType(int $methodType): string { @@ -116,7 +100,6 @@ protected function getPluginType(int $methodType): string /** * Get the preference stats. * - * @return array * @throws ReflectionException */ public function getPreferenceStats(): array diff --git a/Helper/Profiler.php b/Helper/Profiler.php index 882c918..a1a31d4 100644 --- a/Helper/Profiler.php +++ b/Helper/Profiler.php @@ -5,6 +5,8 @@ namespace Smile\DebugToolbar\Helper; use Magento\Framework\App\Helper\AbstractHelper; +use Magento\Framework\App\Helper\Context; +use Magento\Framework\Filesystem\DirectoryList; use Magento\Framework\Profiler\Driver\Standard\Stat; use RuntimeException; @@ -13,20 +15,19 @@ */ class Profiler extends AbstractHelper { - /** - * @var Stat - */ - protected static $stat; + protected DirectoryList $directoryList; + protected static ?Stat $stat = null; + protected ?array $timers = null; - /** - * @var array - */ - protected $timers; + public function __construct(Context $context, DirectoryList $directoryList) + { + parent::__construct($context); + $this->directoryList = $directoryList; + } /** * Set the profiler stat. * - * @param Stat $stat * phpcs:disable Magento2.Functions.StaticFunction.StaticFunction */ public static function setStat(Stat $stat): void @@ -37,7 +38,6 @@ public static function setStat(Stat $stat): void /** * Get the profiler stat object. * - * @return Stat * @throws RuntimeException */ public function getStat(): Stat @@ -66,7 +66,6 @@ public function computeStats(): void /** * Get the stat timers. * - * @return array * @throws RuntimeException */ public function getTimers(): array @@ -96,7 +95,7 @@ protected function prepareTimers(): void $level = count($explodedTimerId) - 1; $label = array_pop($explodedTimerId); - $label = str_replace(BP . '/', '', $label); + $label = str_replace($this->directoryList->getRoot() . '/', '', $label); $parent = implode('->', $explodedTimerId); $timer = [ @@ -132,8 +131,6 @@ protected function prepareTimers(): void /** * Remove the toolbar observer from the profiler timers. - * - * @return bool */ protected function removeToolbarObserverFromTimers(): bool { diff --git a/Layout/Builder.php b/Layout/Builder.php index 6eee75e..b0e20d5 100644 --- a/Layout/Builder.php +++ b/Layout/Builder.php @@ -12,14 +12,8 @@ */ class Builder implements BuilderInterface { - /** - * @var LayoutInterface - */ - protected $layout; + protected LayoutInterface $layout; - /** - * @param LayoutInterface $layout - */ public function __construct(LayoutInterface $layout) { $this->layout = $layout; diff --git a/Model/Profiler/Driver/Standard/Stat.php b/Model/Profiler/Driver/Standard/Stat.php index 23549bf..13d27ea 100644 --- a/Model/Profiler/Driver/Standard/Stat.php +++ b/Model/Profiler/Driver/Standard/Stat.php @@ -42,7 +42,8 @@ protected function _getOrderedTimerIds() /* Add to result all timers nested in the previous timer */ for ($j = $i + 1; $j < count($timerIds); $j++) { // REWRITE: check null value before calling strpos - if ($timerIds[$j] !== null + if ( + $timerIds[$j] !== null && strpos($timerIds[$j], $prevTimerId . Profiler::NESTING_SEPARATOR) === 0 ) { $result[] = $timerIds[$j]; diff --git a/Model/ResourceModel/Info.php b/Model/ResourceModel/Info.php index 8d5d5d6..7b6e740 100644 --- a/Model/ResourceModel/Info.php +++ b/Model/ResourceModel/Info.php @@ -18,18 +18,11 @@ class Info { /** - * @var ResourceConnection + * @var string[]|null */ - protected $resourceConnection; + protected ?array $version = null; + protected ResourceConnection $resourceConnection; - /** - * @var string[] - */ - protected $version; - - /** - * @param ResourceConnection $resourceConnection - */ public function __construct(ResourceConnection $resourceConnection) { $this->resourceConnection = $resourceConnection; @@ -37,8 +30,6 @@ public function __construct(ResourceConnection $resourceConnection) /** * Get the connection. - * - * @return AdapterInterface */ public function getConnection(): AdapterInterface { @@ -69,8 +60,6 @@ public function getMysqlVersions(): array /** * Get Mysql version. * - * @param string $key - * @return string * @throws Zend_Db_Statement_Exception */ public function getMysqlVersion(string $key = 'version'): string @@ -87,7 +76,6 @@ public function getMysqlVersion(string $key = 'version'): string /** * Get the executed queries. * - * @return array * @throws Exception */ public function getExecutedQueries(): array @@ -98,7 +86,6 @@ public function getExecutedQueries(): array /** * Get the count per types. * - * @return array * @throws Exception */ public function getCountPerTypes(): array @@ -109,7 +96,6 @@ public function getCountPerTypes(): array /** * Get the time per types. * - * @return array * @throws Exception */ public function getTimePerTypes(): array @@ -120,7 +106,6 @@ public function getTimePerTypes(): array /** * Get the profiler. * - * @return Profiler * @throws RuntimeException */ protected function getProfiler(): Profiler diff --git a/Observer/AddToolbar.php b/Observer/AddToolbar.php index 211b7cb..8254393 100644 --- a/Observer/AddToolbar.php +++ b/Observer/AddToolbar.php @@ -28,44 +28,13 @@ */ class AddToolbar implements ObserverInterface { - /** - * @var ToolbarFactory - */ - protected $blockToolbarFactory; - - /** - * @var ToolbarsFactory - */ - protected $blockToolbarsFactory; - - /** - * @var DataHelper - */ - protected $dataHelper; - - /** - * @var ConfigHelper - */ - protected $configHelper; + protected ToolbarFactory $blockToolbarFactory; + protected ToolbarsFactory $blockToolbarsFactory; + protected DataHelper $dataHelper; + protected ConfigHelper $configHelper; + protected ProfilerHelper $profilerHelper; + protected AppState $appState; - /** - * @var ProfilerHelper - */ - protected $profilerHelper; - - /** - * @var AppState - */ - protected $appState; - - /** - * @param ToolbarFactory $blockToolbarFactory - * @param ToolbarsFactory $blockToolbarsFactory - * @param DataHelper $dataHelper - * @param ConfigHelper $configHelper - * @param ProfilerHelper $profilerHelper - * @param AppState $appState - */ public function __construct( ToolbarFactory $blockToolbarFactory, ToolbarsFactory $blockToolbarsFactory, @@ -120,8 +89,6 @@ public function execute(Observer $observer) /** * Build the toolbar and add it to the response. * - * @param MagentoRequest $request - * @param MagentoResponse $response * @throws LocalizedException * @throws FileSystemException */ @@ -157,10 +124,6 @@ private function buildToolbar( /** * Generate the toolbar block for the current execution. - * - * @param MagentoRequest $request - * @param MagentoResponse $response - * @return Toolbar */ private function getCurrentExecutionToolbarBlock( MagentoRequest $request, @@ -175,8 +138,6 @@ private function getCurrentExecutionToolbarBlock( /** * Generate the toolbars block. - * - * @return Toolbars */ private function getToolbarsBlock(): Toolbars { diff --git a/Observer/AddZones.php b/Observer/AddZones.php index 083f553..3308131 100644 --- a/Observer/AddZones.php +++ b/Observer/AddZones.php @@ -25,22 +25,8 @@ */ class AddZones implements ObserverInterface { - /** - * @var array - */ - protected $blockFactories = []; + protected array $blockFactories = []; - /** - * @param CacheFactory $cacheBlockFactory - * @param GenericFactory $genericBlockFactory - * @param LayoutFactory $layoutBlockFactory - * @param MysqlFactory $mysqlBlockFactory - * @param ObserverFactory $observerBlockFactory - * @param PreferenceFactory $preferenceBlockFactory - * @param ProfilerFactory $profilerBlockFactory - * @param RequestFactory $requestBlockFactory - * @param ResponseFactory $responseBlockFactory - */ public function __construct( CacheFactory $cacheBlockFactory, GenericFactory $genericBlockFactory, diff --git a/Observer/EnableDbProfiler.php b/Observer/EnableDbProfiler.php index 11ca77c..fc5003c 100644 --- a/Observer/EnableDbProfiler.php +++ b/Observer/EnableDbProfiler.php @@ -19,26 +19,10 @@ */ class EnableDbProfiler implements ObserverInterface { - /** - * @var DeploymentConfigWriter - */ - protected $deploymentConfigWriter; - - /** - * @var DeploymentConfigWriter - */ - protected $deploymentConfigReader; + protected DeploymentConfigWriter $deploymentConfigWriter; + protected DeploymentConfigReader $deploymentConfigReader; + protected ConfigHelper $configHelper; - /** - * @var ConfigHelper - */ - protected $configHelper; - - /** - * @param DeploymentConfigWriter $deploymentConfigWriter - * @param DeploymentConfigReader $deploymentConfigReader - * @param ConfigHelper $configHelper - */ public function __construct( DeploymentConfigWriter $deploymentConfigWriter, DeploymentConfigReader $deploymentConfigReader, diff --git a/Plugin/App/Action/AbstractAction.php b/Plugin/App/Action/AbstractAction.php index 4e7d3dd..d8320ab 100644 --- a/Plugin/App/Action/AbstractAction.php +++ b/Plugin/App/Action/AbstractAction.php @@ -14,20 +14,9 @@ */ class AbstractAction { - /** - * @var DataHelper - */ - protected $dataHelper; + protected DataHelper $dataHelper; + protected ConfigHelper $configHelper; - /** - * @var ConfigHelper - */ - protected $configHelper; - - /** - * @param DataHelper $dataHelper - * @param ConfigHelper $configHelper - */ public function __construct(DataHelper $dataHelper, ConfigHelper $configHelper) { $this->dataHelper = $dataHelper; @@ -37,9 +26,6 @@ public function __construct(DataHelper $dataHelper, ConfigHelper $configHelper) /** * Plugin on dispatch action. * - * @param MagentoAction $subject - * @param RequestInterface $request - * @return array * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function beforeDispatch(MagentoAction $subject, RequestInterface $request): array diff --git a/Plugin/App/Cache.php b/Plugin/App/Cache.php index fef7f97..f0f7d7b 100644 --- a/Plugin/App/Cache.php +++ b/Plugin/App/Cache.php @@ -14,20 +14,9 @@ */ class Cache { - /** - * @var ConfigHelper - */ - protected $configHelper; + protected ConfigHelper $configHelper; + protected CacheHelper $cacheHelper; - /** - * @var CacheHelper - */ - protected $cacheHelper; - - /** - * @param ConfigHelper $configHelper - * @param CacheHelper $cacheHelper - */ public function __construct(ConfigHelper $configHelper, CacheHelper $cacheHelper) { $this->configHelper = $configHelper; @@ -37,13 +26,10 @@ public function __construct(ConfigHelper $configHelper, CacheHelper $cacheHelper /** * Add stats on load. * - * @param CacheInterface $subject - * @param Closure $closure - * @param string $identifier * @return string|bool * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundLoad(CacheInterface $subject, Closure $closure, $identifier) + public function aroundLoad(CacheInterface $subject, Closure $closure, string $identifier) { if (!$this->configHelper->isEnabled()) { return $closure($identifier); @@ -64,23 +50,16 @@ public function aroundLoad(CacheInterface $subject, Closure $closure, $identifie /** * Add stats on save. * - * @param CacheInterface $subject - * @param Closure $closure - * @param string $data - * @param string $identifier - * @param array $tags - * @param int|null $lifeTime - * @return bool * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function aroundSave( CacheInterface $subject, Closure $closure, - $data, - $identifier, - $tags = [], - $lifeTime = null - ) { + string $data, + string $identifier, + array $tags = [], + ?int $lifeTime = null + ): bool { if (!$this->configHelper->isEnabled()) { return $closure($data, $identifier, $tags, $lifeTime); } @@ -100,13 +79,9 @@ public function aroundSave( /** * Add stats on remove. * - * @param CacheInterface $subject - * @param Closure $closure - * @param string $identifier - * @return bool * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundRemove(CacheInterface $subject, Closure $closure, $identifier) + public function aroundRemove(CacheInterface $subject, Closure $closure, string $identifier): bool { if (!$this->configHelper->isEnabled()) { return $closure($identifier); diff --git a/Plugin/App/Http.php b/Plugin/App/Http.php index 7841d85..9a98c68 100644 --- a/Plugin/App/Http.php +++ b/Plugin/App/Http.php @@ -13,20 +13,9 @@ */ class Http { - /** - * @var DataHelper - */ - protected $dataHelper; + protected DataHelper $dataHelper; + protected ConfigHelper $configHelper; - /** - * @var ConfigHelper - */ - protected $configHelper; - - /** - * @param DataHelper $dataHelper - * @param ConfigHelper $configHelper - */ public function __construct(DataHelper $dataHelper, ConfigHelper $configHelper) { $this->dataHelper = $dataHelper; @@ -36,8 +25,6 @@ public function __construct(DataHelper $dataHelper, ConfigHelper $configHelper) /** * Add the start time. * - * @param MagentoHttp $subject - * @return array * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function beforeLaunch(MagentoHttp $subject): array diff --git a/Plugin/Event/Invoker.php b/Plugin/Event/Invoker.php index e8c8e6e..fea9edd 100644 --- a/Plugin/Event/Invoker.php +++ b/Plugin/Event/Invoker.php @@ -14,14 +14,8 @@ */ class Invoker { - /** - * @var ObserverHelper - */ - protected $observerHelper; + protected ObserverHelper $observerHelper; - /** - * @param ObserverHelper $observerHelper - */ public function __construct(ObserverHelper $observerHelper) { $this->observerHelper = $observerHelper; @@ -30,10 +24,6 @@ public function __construct(ObserverHelper $observerHelper) /** * Plugin on dispatch. * - * @param MagentoInvoker $subject - * @param Closure $closure - * @param array $configuration - * @param MagentoObserver $observer * @return mixed * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ diff --git a/Plugin/Event/Manager.php b/Plugin/Event/Manager.php index 9dab0f8..664f095 100644 --- a/Plugin/Event/Manager.php +++ b/Plugin/Event/Manager.php @@ -1,5 +1,7 @@ observerHelper = $observerHelper; @@ -27,17 +23,13 @@ public function __construct(ObserverHelper $observerHelper) /** * Plugin on dispatch. * - * @param MagentoManager $subject - * @param Closure $closure - * @param string $eventName - * @param array $data * @return mixed * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function aroundDispatch( MagentoManager $subject, Closure $closure, - $eventName, + string $eventName, array $data = [] ) { // Note: we can't check if the module is enabled, it could create an infinite loop when fetching cache data diff --git a/composer.json b/composer.json index 5c5589a..414ad9b 100644 --- a/composer.json +++ b/composer.json @@ -13,21 +13,17 @@ "license": "EPL-2.0", "config": { "allow-plugins": { - "dealerdirect/phpcodesniffer-composer-installer": true, - "magento/composer-dependency-version-audit-plugin": true + "magento/composer-dependency-version-audit-plugin": true, + "dealerdirect/phpcodesniffer-composer-installer": true }, "sort-packages": true }, + "minimum-stability": "dev", "require": { - "php": "^7.3 || ^8.1", + "php": "^7.4 || ^8.1", "magento/framework": ">=103.0.0", "magento/module-config": ">=101.2.0" }, - "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7.2", - "magento/magento-coding-standard": "^25.0", - "phpmd/phpmd": "^2.10" - }, "autoload": { "files": [ "registration.php" @@ -41,5 +37,8 @@ "type": "composer", "url": "https://repo.magento.com/" } - ] + ], + "require-dev": { + "smile/magento2-smilelab-quality-suite": "^3" + } } diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 76f5dc3..8501211 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -12,11 +12,10 @@- - +- - . ++ . vendor/* diff --git a/phpmd.xml.dist b/phpmd.xml.dist index cf3f1c2..8eadf89 100644 --- a/phpmd.xml.dist +++ b/phpmd.xml.dist @@ -4,18 +4,7 @@ xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"> -- - - - -- - -- -- + vendor/* diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..b5efc46 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,15 @@ +parameters: + level: 6 + phpVersion: 70400 + checkMissingIterableValueType: false + paths: + - . + excludePaths: + - 'vendor/*' + ignoreErrors: + - + message: '#Constant BP not found#' + path: registration.php + +includes: + - %currentWorkingDirectory%/vendor/smile/magento2-smilelab-phpstan/extension.neon diff --git a/registration.php b/registration.php index e3d36e6..d32c150 100644 --- a/registration.php +++ b/registration.php @@ -18,7 +18,7 @@ ], ]; - Profiler::applyConfig($options, BP, false); + Profiler::applyConfig($options, BP); SmileProfiler::setStat($options['drivers'][0]['stat']); } diff --git a/view/base/templates/zone/layout.phtml b/view/base/templates/zone/layout.phtml index 67492bb..ad88875 100644 --- a/view/base/templates/zone/layout.phtml +++ b/view/base/templates/zone/layout.phtml @@ -4,7 +4,7 @@ use Smile\DebugToolbar\Block\Zone\Layout; /** @var Layout $block */ $sections = [ - 'Handles' => $block->getHandles() + 'Handles' => $block->getHandles(), ]; ?> diff --git a/view/base/templates/zone/profiler.phtml b/view/base/templates/zone/profiler.phtml index 8630d9a..4c3076e 100644 --- a/view/base/templates/zone/profiler.phtml +++ b/view/base/templates/zone/profiler.phtml @@ -42,8 +42,8 @@ $timers = $block->getTimers(); style="= ($timer['parent'] ? 'display: none' : '') ?>" >0): ?>