From fa18efaa8b4e5ac7497858203ce5cf9157db615f Mon Sep 17 00:00:00 2001 From: Brad Kent Date: Tue, 21 May 2024 14:54:24 -0500 Subject: [PATCH] add cspell.json --- .editorconfig | 5 +++ .gitattributes | 1 + cspell.json | 39 +++++++++++++++++ src/Backtrace/Normalizer.php | 8 ++-- src/CurlHttpMessage/Factory.php | 2 +- src/CurlHttpMessage/Handler/CurlMulti.php | 4 +- src/Debug/Collector/Pdo/Statement.php | 6 +-- src/Debug/Collector/SwiftMailerLogger.php | 8 ++-- src/Debug/Route/Script.php | 2 +- src/Debug/Utility/ArrayUtil.php | 52 ++++++++++++++--------- src/Debug/Utility/HtmlParse.php | 2 +- 11 files changed, 94 insertions(+), 35 deletions(-) create mode 100644 cspell.json diff --git a/.editorconfig b/.editorconfig index 9027cd9a..02ddcbab 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,6 +12,11 @@ indent_size = 2 insert_final_newline = true trim_trailing_whitespace = true +[*.json] +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true + [*.md] trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes index 8decf06e..a112a892 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15,6 +15,7 @@ /.github export-ignore /.gitignore export-ignore /.stylelintrc.json export-ignore +/cspell.json export-ignore /dev export-ignore /phpcs.slevomat.xml export-ignore /phpcs.xml.dist export-ignore diff --git a/cspell.json b/cspell.json new file mode 100644 index 00000000..d4034b59 --- /dev/null +++ b/cspell.json @@ -0,0 +1,39 @@ +{ + "version": "0.2", + "language": "en-US", + "ignorePaths": [ + "./cspell.json", + "./src/Debug/js/**", + "*.min.*", + "**/charData.php", + "**/prism.js", + "**/tests/**" + ], + "useGitignore": true, + "words": [ + "autoloader", + "bitmask", + "callables", + "classname", + "hostnames", + "invokable", + "regexs", + "uncollapse", + "ungroup", + "unserialized", + "unsets", + "webroot" + ], + "ignoreWords": [ + "chromelogger", + "firephp", + "jdorn", + "mrkdwn", + "mysqli", + "phpcs", + "phpmd", + "slevomat", + "symfony", + "wamp" + ] +} diff --git a/src/Backtrace/Normalizer.php b/src/Backtrace/Normalizer.php index 7752883f..05355ce5 100644 --- a/src/Backtrace/Normalizer.php +++ b/src/Backtrace/Normalizer.php @@ -72,13 +72,13 @@ public static function normalize($backtrace) * Normalize file value * * @param array $frame current frame - * @param array $frameNext next frrame + * @param array $frameNext next frame * * @return array */ private static function normalizeFrameFile(array $frame, array &$frameNext) { - $regexEvaldCode = '/^(.+)\((\d+)\) : eval\(\)\'d code$/'; + $regexEvalCode = '/^(.+)\((\d+)\) : eval\(\)\'d code$/'; $matches = array(); if ($frame['file'] === null) { // use file/line from next frame @@ -87,14 +87,14 @@ private static function normalizeFrameFile(array $frame, array &$frameNext) \array_intersect_key($frameNext, \array_flip(array('file', 'line'))) ); } - if (\preg_match($regexEvaldCode, (string) $frame['file'], $matches)) { + if (\preg_match($regexEvalCode, (string) $frame['file'], $matches)) { // reported line = line within eval // line inside paren is the line `eval` is on $frame['evalLine'] = $frame['line']; $frame['file'] = $matches[1]; $frame['line'] = (int) $matches[2]; if (isset($frameNext['include_filename'])) { - // xdebug_get_function_stack puts the evaled code in include_filename + // xdebug_get_function_stack puts the eval'd code in include_filename $frameNext['params'] = array($frameNext['include_filename']); $frameNext['class'] = null; $frameNext['function'] = 'eval'; diff --git a/src/CurlHttpMessage/Factory.php b/src/CurlHttpMessage/Factory.php index 377e3fef..e7bc2134 100644 --- a/src/CurlHttpMessage/Factory.php +++ b/src/CurlHttpMessage/Factory.php @@ -67,7 +67,7 @@ public function __call($method, $args) } /** - * Build CuurlReqRes instance + * Build CurlReqRes instance * * @param RequestInterface $request Request instance * @param array $options options diff --git a/src/CurlHttpMessage/Handler/CurlMulti.php b/src/CurlHttpMessage/Handler/CurlMulti.php index 1ff3bb4a..f47e097e 100644 --- a/src/CurlHttpMessage/Handler/CurlMulti.php +++ b/src/CurlHttpMessage/Handler/CurlMulti.php @@ -232,8 +232,8 @@ protected function tick() ? $this->getDelay() : 0; if ($delay) { - $microsec = $delay * 1000; - \usleep((int) $microsec); + $microSec = $delay * 1000; + \usleep((int) $microSec); } // Step through the task queue which may add additional requests. diff --git a/src/Debug/Collector/Pdo/Statement.php b/src/Debug/Collector/Pdo/Statement.php index eee05ab6..f93eab67 100644 --- a/src/Debug/Collector/Pdo/Statement.php +++ b/src/Debug/Collector/Pdo/Statement.php @@ -48,14 +48,14 @@ protected function __construct(DebugCollectorPdo $pdo) * @param mixed $column Number of the column (1-indexed) or name of the column in the result set * @param mixed $param Name of the PHP variable to which the column will be bound. * @param int $type [optional] Data type of the parameter, specified by the PDO::PARAM_* constants. - * @param int $maxlen [optional] A hint for pre-allocation. - * @param mixed $driverdata [optional] Optional parameter(s) for the driver. + * @param int $maxLen [optional] A hint for pre-allocation. + * @param mixed $driverData [optional] Optional parameter(s) for the driver. * * @return bool * @link http://php.net/manual/en/pdostatement.bindcolumn.php */ #[\ReturnTypeWillChange] - public function bindColumn($column, &$param, $type = null, $maxlen = null, $driverdata = null) + public function bindColumn($column, &$param, $type = null, $maxLen = null, $driverData = null) { $this->boundParameters[$column] = $param; $this->boundParameterTypes[$column] = $type; diff --git a/src/Debug/Collector/SwiftMailerLogger.php b/src/Debug/Collector/SwiftMailerLogger.php index 424f0cd5..df60d194 100644 --- a/src/Debug/Collector/SwiftMailerLogger.php +++ b/src/Debug/Collector/SwiftMailerLogger.php @@ -87,7 +87,7 @@ public function beforeSendPerformed(Swift_Events_SendEvent $event) $msg = $event->getMessage(); $this->debug->groupCollapsed( 'sending email', - $this->formatEmailAddrs($msg->getTo()), + $this->formatEmailAddresses($msg->getTo()), $msg->getSubject(), $this->iconMeta ); @@ -293,14 +293,14 @@ public function exceptionThrown(Swift_Events_TransportExceptionEvent $evt) /** * Convert array of email addresses/names to string * - * @param array $addrs emailAddr->name pairs + * @param array $addresses emailAddr->name pairs * * @return string */ - protected function formatEmailAddrs($addrs) + protected function formatEmailAddresses($addresses) { $return = array(); - foreach ($addrs as $addr => $name) { + foreach ($addresses as $addr => $name) { $return[] = ($name ? $name . ' ' : '') . '<' . $addr . '>'; } return \implode(', ', $return); diff --git a/src/Debug/Route/Script.php b/src/Debug/Route/Script.php index 498d8880..340bb2e1 100644 --- a/src/Debug/Route/Script.php +++ b/src/Debug/Route/Script.php @@ -68,7 +68,7 @@ public function __construct(Debug $debug) * * @return string|void */ - public function processlogEntries(Event $event) + public function processLogEntries(Event $event) { $this->dumper->crateRaw = false; $this->data = $this->debug->data->get(); diff --git a/src/Debug/Utility/ArrayUtil.php b/src/Debug/Utility/ArrayUtil.php index b55fcbe8..6cebe00a 100644 --- a/src/Debug/Utility/ArrayUtil.php +++ b/src/Debug/Utility/ArrayUtil.php @@ -202,7 +202,7 @@ public static function pathGet(&$array, $path, $default = null) public static function pathSet(array &$array, $path, $val) { $path = \array_reverse(self::pathToArray($path)); - while ($path && \is_array($array)) { + while ($path) { $key = \array_pop($path); if (self::specialKey($key, $path, $array)) { continue; @@ -222,31 +222,22 @@ public static function pathSet(array &$array, $path, $val) /** * Searches array structure for value and returns the path to the first match * - * @param mixed $value value to search for (needle) - * @param array $array array structure to search (haystack) - * @param bool $inclKeys (false) whether to also match keys + * @param mixed $search Needle / value or key to search for + * @param array $array Haystack / array structure to search + * @param bool $byKey (false) whether to search for key vs value * - * @return array|false Returns empty array if value not found + * @return array|false */ - public static function searchRecursive($value, array $array, $inclKeys = false) + public static function searchRecursive($search, array $array, $byKey = false) { - $key = \array_search($value, $array, true); + $key = \array_search($search, $array, true); if ($key !== false) { return array($key); } - if ($inclKeys && self::isValidKey($value) && \array_key_exists($value, $array)) { - return array($value); + if ($byKey && self::isValidKey($search) && \array_key_exists($search, $array)) { + return array($search); } - foreach ($array as $key => $val) { - if (\is_array($val) === false) { - continue; - } - $pathTest = self::searchRecursive($value, $val, $inclKeys); - if ($pathTest) { - return \array_merge(array($key), $pathTest); - } - } - return false; + return self::searchRecursiveWalk($search, $array, $byKey); } /** @@ -318,4 +309,27 @@ public static function spliceAssoc(array &$array, $key, $length = null, $replace ); return $ret; } + + /** + * Iterate over haystack to find needle + * + * @param mixed $search Needle / value or key to search for + * @param array $array Haystack / array structure to search + * @param bool $byKey (false) whether to search for key vs value + * + * @return array|false + */ + private static function searchRecursiveWalk($search, array $array, $byKey) + { + foreach ($array as $key => $val) { + if (\is_array($val) === false) { + continue; + } + $pathTest = self::searchRecursive($search, $val, $byKey); + if ($pathTest) { + return \array_merge(array($key), $pathTest); + } + } + return false; + } } diff --git a/src/Debug/Utility/HtmlParse.php b/src/Debug/Utility/HtmlParse.php index 45268623..8bd49ad3 100644 --- a/src/Debug/Utility/HtmlParse.php +++ b/src/Debug/Utility/HtmlParse.php @@ -21,7 +21,7 @@ class HtmlParse * Parse attribute value * * @param string $name attribute name - * @param string $val value (assumed to be htmlspecialchar'd) + * @param string $val value (assumed to be html encoded) * @param int $options bitmask of Html::PARSE_ATTRIB_x FLAGS * * @return mixed