Skip to content
Open
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
52 changes: 52 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: PHP Composer

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
run:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ ubuntu-latest, macos-latest ] #windows-latest currently not working
php-versions: [ '8.1', '8.2']
composer-deps: ['lock']
composer-versions: [ 'composer:v2' ]
fail-fast: false
name: PHP ${{ matrix.php-versions }} @ ${{ matrix.operating-system }} with ${{ matrix.composer-versions }} ${{ matrix.composer-deps }}
steps:
- name: Checkout
uses: actions/checkout@master
- name: Install PHP
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php-versions }}
tools: ${{ matrix.composer-versions }}
extensions: xdebug, mbstring, posix
- name: Check Versions
run: |
php -v
php -m
composer --version
- name: Get composer cache directory
id: composercache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies (lock)
env:
COMPOSER_AUTH: '{"http-basic":{"repo.magento.com":{"username":"${{secrets.MAGENTO_AUTH_USER}}","password":"${{secrets.MAGENTO_AUTH_PASS}}"}}}'
run: |
composer install --no-progress --no-suggest
- name: Run the tests on unix
run: php vendor/bin/grumphp run --no-interaction
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.idea/
composer.lock
/vendor
.php-cs-fixer.cache
124 changes: 124 additions & 0 deletions .php-cs-fixer.project.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?php
use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$header = <<<EOF
Designed by Stanislav Matiavin
EOF;
$finder = (new Finder())
->ignoreDotFiles(false)
->ignoreVCSIgnored(true)
->exclude(['dev-tools/phpstan', 'tests/Fixtures'])
->in('.')
->name('*.phtml')
->notName(['autoload.php', 'bootstrap.php'])
->exclude('i18n')
->exclude('design')
->exclude('etc')
->exclude('vendor');

$rules = ['@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'concat_space' => ['spacing' => 'one'],
'include' => true,
'new_with_parentheses' => true,
'no_empty_statement' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_multiline_whitespace_around_double_arrow' => true,
'multiline_whitespace_before_semicolons' => true,
'no_unused_imports' => true,
'ordered_imports' => true,
'ternary_operator_spaces' => true,
'phpdoc_order' => true,
'phpdoc_types' => true,
'phpdoc_add_missing_param_annotation' => true,
'single_quote' => true,
'standardize_not_equals' => true,
'ternary_to_null_coalescing' => true,
'lowercase_cast' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'return_type_declaration' => true,
'no_useless_return' => true,
'align_multiline_comment' => true,
'array_indentation' => true,
'binary_operator_spaces' => true,
'blank_line_after_opening_tag' => true,
'blank_line_before_statement' => ['statements' => ["return", "throw", "try"]],
'cast_spaces' => true,
'class_attributes_separation' => true,
'explicit_indirect_variable' => true,
'explicit_string_variable' => true,
'type_declaration_spaces' => true,
'lowercase_static_reference' => true,
'method_chaining_indentation' => true,
'multiline_comment_opening_closing' => true,
'native_function_casing' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_extra_blank_lines' => [
'tokens' => ["break",
"continue",
"curly_brace_block",
"extra",
"parenthesis_brace_block",
"return",
"square_brace_block",
"throw",
"use"]
],
'no_short_bool_cast' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_around_offset' => true,
'no_superfluous_elseif' => true,
'no_trailing_comma_in_singleline' => true,
'no_useless_else' => true,
'no_whitespace_in_blank_line' => true,
'object_operator_without_whitespace' => true,
'ordered_class_elements' => [
'order' => ["use_trait",
"constant_public",
"constant_protected",
"constant_private",
"property_public",
"property_protected",
"property_private",
"construct",
"destruct",
"magic",
"phpunit",
"method_public",
"method_protected",
"method_private"]
],
'phpdoc_align' => ['align' => 'left'],
'phpdoc_indent' => true,
'phpdoc_return_self_reference' => true,
'phpdoc_scalar' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_trim' => true,
'phpdoc_types_order' => [
'null_adjustment' => 'always_last'
],
'return_assignment' => true,
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'declare_strict_types' => true,
'void_return' => true,
'whitespace_after_comma_in_array' => true];

if (null !== $header) {
$rules['header_comment'] = [
'comment_type' => 'PHPDoc',
'header' => $header,
'location' => 'after_open',
'separate' => 'bottom',
];
}

return (new Config())
->setRiskyAllowed(true)
->setFinder($finder)
->setRules($rules);
24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

7 changes: 5 additions & 2 deletions App/AbstractAction.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<?php
/**
* Designed by Stanislav Matiavin
*/

declare(strict_types=1);
namespace Daseraf\Debug\App;

use Magento\Framework\App\Action\Context;

abstract class AbstractAction extends \Magento\Framework\App\Action\Action
{

public function __construct(Context $context)
{
parent::__construct($context);
}

}
7 changes: 5 additions & 2 deletions App/Action/Context.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php
namespace Daseraf\Debug\App\Action;
/**
* Designed by Stanislav Matiavin
*/

use Magento\Framework\Controller\ResultFactory;
declare(strict_types=1);
namespace Daseraf\Debug\App\Action;

class Context extends \Magento\Framework\App\Action\Context
{
Expand Down
8 changes: 5 additions & 3 deletions App/Action/Frontend/Context.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php
namespace Daseraf\Debug\App\Action\Frontend;
/**
* Designed by Stanislav Matiavin
*/

use Magento\Framework\Controller\ResultFactory;
declare(strict_types=1);
namespace Daseraf\Debug\App\Action\Frontend;

class Context extends \Magento\Framework\App\Action\Context
{

}
25 changes: 16 additions & 9 deletions App/Area/FrontNameResolver.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<?php
/**
* Designed by Stanislav Matiavin
*/

declare(strict_types=1);

namespace Daseraf\Debug\App\Area;

use Magento\Backend\App\Config;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\DeploymentConfig;
use Magento\Store\Model\ScopeInterface;
Expand Down Expand Up @@ -37,13 +43,11 @@ class FrontNameResolver implements \Magento\Framework\App\Area\FrontNameResolver
*/
protected $config;


/** @var ScopeConfigInterface */
private $scopeConfig;

/**
* @param \Magento\Backend\App\Config $config
* @param DeploymentConfig $deploymentConfig
* @param Config $config
* @param ScopeConfigInterface $scopeConfig
*/
public function __construct(
Expand All @@ -58,17 +62,18 @@ public function __construct(
* Retrieve area front name
*
* @param bool $checkHost If true, verify front name is valid for this url (hostname is correct)
* @return string|bool
* @return bool|string
*/
public function getFrontName($checkHost = false)
{
if ($checkHost && !$this->isHostDebugBackend()) {
return false;
}
$isCustomPathUsed = (bool)(string)$this->config->getValue(self::XML_PATH_USE_CUSTOM_DEBUG_PATH);
$isCustomPathUsed = (bool) (string) $this->config->getValue(self::XML_PATH_USE_CUSTOM_DEBUG_PATH);
if ($isCustomPathUsed) {
return (string)$this->config->getValue(self::XML_PATH_CUSTOM_DEBUG_PATH);
return (string) $this->config->getValue(self::XML_PATH_CUSTOM_DEBUG_PATH);
}

return $this->defaultFrontName;
}

Expand All @@ -85,14 +90,15 @@ public function isHostDebugBackend()
$debugUrl = $this->scopeConfig->getValue(Store::XML_PATH_UNSECURE_BASE_URL, ScopeInterface::SCOPE_STORE);
}

$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
$host = $_SERVER['HTTP_HOST'] ?? '';

return stripos($this->getHostNameWithPort($debugUrl), $host) !== false;
}

/**
* Get host with port
*
* @param string $url
* @param mixed $debugUrl
* @return mixed|string
*/
private function getHostNameWithPort($debugUrl)
Expand All @@ -101,8 +107,9 @@ private function getHostNameWithPort($debugUrl)
$hostVar = parse_url(trim($debugUrl), PHP_URL_HOST);
$portVar = parse_url(trim($debugUrl), PHP_URL_PORT);
if (!$portVar) {
$portVar = isset($this->standardPorts[$schemeVar]) ? $this->standardPorts[$schemeVar] : null;
$portVar = $this->standardPorts[$schemeVar] ?? null;
}

return isset($portVar) ? $hostVar . ':' . $portVar : $hostVar;
}
}
9 changes: 8 additions & 1 deletion App/Config.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* Designed by Stanislav Matiavin
*/

declare(strict_types=1);

namespace Daseraf\Debug\App;

Expand Down Expand Up @@ -39,13 +44,14 @@ public function getValue($path)
if ($path) {
$configPath .= '/' . $path;
}

return $this->appConfig->get(System::CONFIG_TYPE, $configPath);
}

/**
* @inheritdoc
*/
public function setValue($path, $value)
public function setValue($path, $value): void
{
$this->data[$path] = $value;
}
Expand All @@ -59,6 +65,7 @@ public function isSetFlag($path)
if ($path) {
$configPath .= '/' . $path;
}

return (bool) $this->appConfig->get(System::CONFIG_TYPE, $configPath);
}
}
7 changes: 6 additions & 1 deletion App/ConfigInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* Designed by Stanislav Matiavin
*/

declare(strict_types=1);

namespace Daseraf\Debug\App;

Expand All @@ -22,7 +27,7 @@ public function getValue($path);
* @param mixed $value
* @return void
*/
public function setValue($path, $value);
public function setValue($path, $value): void;

/**
* Retrieve config flag
Expand Down
Loading
Loading