Skip to content
Merged
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"jdorn/sql-formatter": "^1.2"
},
"require-dev": {
"cakephp/cakephp-codesniffer": "^3.0",
"cakephp/cakephp-codesniffer": "dev-next",
"phpunit/phpunit": "^7.0"
},
"autoload": {
Expand Down
12 changes: 3 additions & 9 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
<?xml version="1.0"?>
<ruleset name="CakePHP Core">
<rule ref="./vendor/cakephp/cakephp-codesniffer/CakePHP/ruleset.xml">
<!-- Exclude unwanted sniffs -->
<exclude name="Generic.Commenting.Todo.TaskFound"/> <!-- Excluded during 3.next development -->
</rule>
<ruleset name="CakePHP DebugKit">
<config name="installed_paths" value="../../cakephp/cakephp-codesniffer" />

<!-- Necessary for class aliases used for backwards compat -->
<rule ref="PSR1.Files.SideEffects.FoundWithSymbols">
<severity>0</severity>
</rule>
<rule ref="CakePHP" />
</ruleset>
6 changes: 3 additions & 3 deletions src/Cache/Engine/DebugEngine.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
Expand All @@ -24,7 +25,6 @@
*/
class DebugEngine extends CacheEngine
{

/**
* Proxied cache engine config.
*
Expand Down Expand Up @@ -75,7 +75,7 @@ public function init(array $config = []): bool

return true;
}
$registry = new CacheRegistry;
$registry = new CacheRegistry();
$this->_engine = $registry->load('spies', $this->_config);
unset($registry);

Expand Down Expand Up @@ -290,7 +290,7 @@ public function clearGroup(string $group): bool
public function __toString()
{
if (!empty($this->_engine)) {
list($ns, $class) = namespaceSplit(get_class($this->_engine));
[$ns, $class] = namespaceSplit(get_class($this->_engine));

return str_replace('Engine', '', $class);
}
Expand Down
16 changes: 8 additions & 8 deletions src/Command/BenchmarkCommand.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
Expand Down Expand Up @@ -32,7 +33,6 @@
*/
class BenchmarkCommand extends Command
{

/**
* The console io
*
Expand Down Expand Up @@ -88,20 +88,20 @@ protected function _results($times)
$this->io->out("");

$this->io->out(Text::insert(__d('debug_kit', 'Requests/Second: :rps req/sec'), [
'rps' => round($requests / $duration, 3)
'rps' => round($requests / $duration, 3),
]));

$this->io->out(Text::insert(__d('debug_kit', 'Average request time: :average-time seconds'), [
'average-time' => round($duration / $requests, 3)
'average-time' => round($duration / $requests, 3),
]));

$this->io->out(Text::insert(__d('debug_kit', 'Standard deviation of average request time: :std-dev'), [
'std-dev' => round($this->_deviation($times, true), 3)
'std-dev' => round($this->_deviation($times, true), 3),
]));

$this->io->out(Text::insert(__d('debug_kit', 'Longest/shortest request: :longest sec/:shortest sec'), [
'longest' => round(max($times), 3),
'shortest' => round(min($times), 3)
'shortest' => round(min($times), 3),
]));

$this->io->out("");
Expand Down Expand Up @@ -164,19 +164,19 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption
))
->addArgument('url', [
'help' => __d('debug_kit', 'The URL to request.'),
'required' => true
'required' => true,
])
->addOption('n', [
'default' => 10,
'help' => __d('debug_kit', 'Number of iterations to perform.')
'help' => __d('debug_kit', 'Number of iterations to perform.'),
])
->addOption('t', [
'default' => 100,
'help' => __d(
'debug_kit',
'Maximum total time for all iterations, in seconds.' .
'If a single iteration takes more than the timeout, only one request will be made'
)
),
])
->setEpilog(__d(
'debug_kit',
Expand Down
6 changes: 3 additions & 3 deletions src/Controller/ComposerController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
Expand Down Expand Up @@ -27,7 +28,6 @@
*/
class ComposerController extends Controller
{

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -95,8 +95,8 @@ public function checkDependencies()
}

/**
* @param ArrayInput $input An array describing the command input
* @return BufferedOutput Aa Console command buffered result
* @param \Symfony\Component\Console\Input\ArrayInput $input An array describing the command input
* @return \Symfony\Component\Console\Output\BufferedOutput Aa Console command buffered result
*/
private function executeComposerCommand(ArrayInput $input)
{
Expand Down
17 changes: 10 additions & 7 deletions src/Controller/MailPreviewController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
Expand All @@ -13,7 +14,6 @@
*/
namespace DebugKit\Controller;

use Cake\Collection\CollectionInterface;
use Cake\Controller\Controller;
use Cake\Core\App;
use Cake\Core\Configure;
Expand All @@ -25,8 +25,6 @@
use DebugKit\Mailer\AbstractResult;
use DebugKit\Mailer\PreviewResult;
use DebugKit\Mailer\SentMailResult;
use PDOException;
use Psr\Http\Message\ResponseInterface;

/**
* Provides access to the MailPreview classes for visually debugging email sending
Expand Down Expand Up @@ -192,7 +190,7 @@ protected function getMailPreviewClasses()
return collection([$appPaths])
->append($pluginPaths)
->unfold(function ($pairs) {
list($paths, $plugin) = $pairs;
[$paths, $plugin] = $pairs;
foreach ($paths as $path) {
yield $plugin => $path;
}
Expand All @@ -202,7 +200,7 @@ protected function getMailPreviewClasses()
$base = str_replace(".php", "", basename($file));
$class = App::className($plugin . $base, 'Mailer/Preview');
if ($class) {
yield ['plugin' => trim($plugin, '.'), 'class' => new $class];
yield ['plugin' => trim($plugin, '.'), 'class' => new $class()];
}
}
});
Expand Down Expand Up @@ -269,11 +267,16 @@ protected function findPreview($previewName, $emailName, $plugin = null)
if (!$realClass) {
throw new NotFoundException("Mailer preview ${previewName} not found");
}
$mailPreview = new $realClass;
$mailPreview = new $realClass();

$email = $mailPreview->find($emailName);
if (!$email) {
throw new NotFoundException(__d('debug_kit', "Mailer preview {0}::{1} not found", $previewName, $emailName));
throw new NotFoundException(__d(
'debug_kit',
"Mailer preview {0}::{1} not found",
$previewName,
$emailName
));
}

return new PreviewResult($mailPreview->$email(), $email);
Expand Down
3 changes: 2 additions & 1 deletion src/Controller/PanelsController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
Expand Down Expand Up @@ -85,7 +86,7 @@ public function index($requestId = null)
}
$this->set([
'_serialize' => ['panels'],
'panels' => $panels
'panels' => $panels,
]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Controller/RequestsController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
Expand All @@ -24,7 +25,6 @@
*/
class RequestsController extends Controller
{

/**
* Before filter handler.
*
Expand Down
1 change: 1 addition & 0 deletions src/Controller/ToolbarController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
Expand Down
10 changes: 4 additions & 6 deletions src/Database/Log/DebugLog.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
Expand Down Expand Up @@ -26,7 +27,6 @@
*/
class DebugLog extends QueryLogger
{

/**
* Logs from the current request.
*
Expand Down Expand Up @@ -166,7 +166,7 @@ public function log(LoggedQuery $query): void
$this->_queries[] = [
'query' => $query->query,
'took' => $query->took,
'rows' => $query->numRows
'rows' => $query->numRows,
];
}

Expand All @@ -180,8 +180,7 @@ protected function isSchemaQuery(LoggedQuery $query)
{
$querystring = $query->query;

return (
// Multiple engines
return // Multiple engines
strpos($querystring, 'FROM information_schema') !== false ||
// Postgres
strpos($querystring, 'FROM pg_catalog') !== false ||
Expand All @@ -194,7 +193,6 @@ protected function isSchemaQuery(LoggedQuery $query)
strpos($querystring, 'PRAGMA') === 0 ||
// Sqlserver
strpos($querystring, 'FROM INFORMATION_SCHEMA') !== false ||
strpos($querystring, 'FROM sys.') !== false
);
strpos($querystring, 'FROM sys.') !== false;
}
}
11 changes: 5 additions & 6 deletions src/DebugInclude.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
Expand All @@ -13,18 +14,14 @@
namespace DebugKit;

use Cake\Core\Plugin as CorePlugin;
use Cake\Event\Event;
use Cake\Utility\Hash;
use Composer\Json\JsonFile;
use DebugKit\DebugPanel;

/**
* Contains methods for Providing list of files.
*
*/
class DebugInclude
{

/**
* The list of plugins within the application
*
Expand All @@ -48,7 +45,7 @@ class DebugInclude
'Auth', 'Cache', 'Collection', 'Config', 'Configure', 'Console', 'Component', 'Controller',
'Behavior', 'Database', 'Datasource', 'Model', 'Template', 'View', 'Utility',
'Network', 'Routing', 'I18n', 'Log', 'Error', 'Event', 'Form', 'Filesystem',
'ORM', 'Filter', 'Validation'
'ORM', 'Filter', 'Validation',
];

/**
Expand All @@ -68,7 +65,9 @@ public function __construct()
$packages = array_merge($lockContent['packages'], $lockContent['packages-dev']);

foreach ($packages as $package) {
$this->_composerPaths[$package['name']] = $vendorDir . str_replace('/', DIRECTORY_SEPARATOR, $package['name']) . DIRECTORY_SEPARATOR;
$this->_composerPaths[$package['name']] = $vendorDir
. str_replace('/', DIRECTORY_SEPARATOR, $package['name'])
. DIRECTORY_SEPARATOR;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/DebugMemory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
Expand All @@ -21,7 +22,6 @@
*/
class DebugMemory
{

/**
* An array of recorded memory use points.
*
Expand Down
6 changes: 3 additions & 3 deletions src/DebugPanel.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
Expand All @@ -24,7 +25,6 @@
*/
class DebugPanel implements EventListenerInterface
{

/**
* Defines which plugin this panel is from so the element can be located.
*
Expand All @@ -46,7 +46,7 @@ class DebugPanel implements EventListenerInterface
*/
public function title()
{
list($ns, $name) = namespaceSplit(get_class($this));
[$ns, $name] = namespaceSplit(static::class);
$name = substr($name, 0, strlen('Panel') * -1);

return Inflector::humanize(Inflector::underscore($name));
Expand All @@ -59,7 +59,7 @@ public function title()
*/
public function elementName()
{
list($ns, $name) = namespaceSplit(get_class($this));
[$ns, $name] = namespaceSplit(static::class);
if ($this->plugin) {
return $this->plugin . '.' . Inflector::underscore($name);
}
Expand Down
Loading