Skip to content

Commit

Permalink
Move \bdk\Debug\Utility\Php::assertType to `\bdk\Debug\Utility:::as…
Browse files Browse the repository at this point in the history
…sertType`
  • Loading branch information
bkdotcom committed Oct 28, 2024
1 parent 58ebc63 commit 866f1bb
Show file tree
Hide file tree
Showing 56 changed files with 289 additions and 277 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
},
"require": {
"php": ">=5.4.0",
"bdk/http-message": "^1.3.2 || ^2.3.2 || ^3.3.2",
"bdk/http-message": "^1.3.3 || ^2.3.3 || ^3.3.3",
"jdorn/sql-formatter": "^1.2"
},
"require-dev": {
Expand Down
10 changes: 5 additions & 5 deletions src/CurlHttpMessage/Exception/RequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class RequestException extends RuntimeException
*/
public function __construct($message, RequestInterface $request, $response = null, $prevException = null)
{
\bdk\Debug\Utility\Php::assertType($response, 'Psr\Http\Message\ResponseInterface');
\bdk\Debug\Utility\Php::assertType($prevException, 'Exception');
\bdk\Debug\Utility::assertType($response, 'Psr\Http\Message\ResponseInterface');
\bdk\Debug\Utility::assertType($prevException, 'Exception');

$this->request = $request;
$this->response = $response;
Expand All @@ -51,8 +51,8 @@ public function __construct($message, RequestInterface $request, $response = nul
*/
public static function create(RequestInterface $request, $response = null, $prevException = null)
{
\bdk\Debug\Utility\Php::assertType($response, 'Psr\Http\Message\ResponseInterface');
\bdk\Debug\Utility\Php::assertType($prevException, 'Exception');
\bdk\Debug\Utility::assertType($response, 'Psr\Http\Message\ResponseInterface');
\bdk\Debug\Utility::assertType($prevException, 'Exception');

$level = $response
? (int) \floor($response->getStatusCode() / 100)
Expand Down Expand Up @@ -97,7 +97,7 @@ public function getResponse()
*/
private static function buildMessage(RequestInterface $request, $response = null)
{
\bdk\Debug\Utility\Php::assertType($response, 'Psr\Http\Message\ResponseInterface');
\bdk\Debug\Utility::assertType($response, 'Psr\Http\Message\ResponseInterface');

if (!$response) {
$label = 'Error completing request';
Expand Down
2 changes: 1 addition & 1 deletion src/CurlHttpMessage/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function buildResponse($code = 200, $reasonPhrase = '', $headers = array(
*/
public static function buildStack($handler = null)
{
\bdk\Debug\Utility\Php::assertType($handler, 'callable');
\bdk\Debug\Utility::assertType($handler, 'callable');
if ($handler === null) {
$syncHandler = new Curl();
$asyncHandler = new CurlMulti();
Expand Down
4 changes: 2 additions & 2 deletions src/CurlHttpMessage/Handler/Mock.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class Mock implements Countable
*/
public function __construct(array $queue = array(), $onFulfilled = null, $onRejected = null)
{
\bdk\Debug\Utility\Php::assertType($onFulfilled, 'callable');
\bdk\Debug\Utility\Php::assertType($onRejected, 'callable');
\bdk\Debug\Utility::assertType($onFulfilled, 'callable');
\bdk\Debug\Utility::assertType($onRejected, 'callable');

$this->onFulfilled = $onFulfilled;
$this->onRejected = $onRejected;
Expand Down
2 changes: 1 addition & 1 deletion src/Debug/AbstractDebug.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public function onCfgServiceProvider($val)
*/
public function publishBubbleEvent($eventName, Event $event, $debug = null)
{
$this->php->assertType($debug, 'bdk\Debug');
$this->utility->assertType($debug, 'bdk\Debug');
if ($debug === null) {
$subject = $event->getSubject();
/** @var Debug */
Expand Down
3 changes: 2 additions & 1 deletion src/Debug/Abstraction/Object/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use bdk\Debug\Abstraction\Abstraction;
use bdk\Debug\Abstraction\AbstractObject;
use bdk\Debug\Abstraction\Object\Abstraction as ObjectAbstraction;
use bdk\Debug\Utility;
use bdk\Debug\Utility\Php as PhpUtil;
use bdk\Debug\Utility\PhpDoc;
use ReflectionAttribute;
Expand Down Expand Up @@ -216,7 +217,7 @@ public static function getType($phpDocType, Reflector $reflector)
*/
protected static function getTypeString($type = null)
{
PhpUtil::assertType($type, 'ReflectionType');
Utility::assertType($type, 'ReflectionType');
if ($type === null) {
return null;
}
Expand Down
10 changes: 6 additions & 4 deletions src/Debug/Collector/AbstractAsyncMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
use bdk\Debug;
use bdk\Debug\AbstractComponent;
use bdk\Debug\LogEntry;
use bdk\Debug\Utility;
use bdk\HttpMessage\Utility\Stream as StreamUtility;
use Psr\Http\Message\MessageInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -58,7 +60,7 @@ class AbstractAsyncMiddleware extends AbstractComponent
*/
public function __construct($cfg = array(), $debug = null)
{
\bdk\Debug\Utility\Php::assertType($debug, 'bdk\Debug');
Utility::assertType($debug, 'bdk\Debug');
$this->setCfg($cfg);
if (!$debug) {
$debug = Debug::getChannel($this->cfg['label'], array('channelIcon' => $this->cfg['icon']));
Expand Down Expand Up @@ -213,7 +215,7 @@ protected function getBody(MessageInterface $msg)
$contentType = $contentType
? $contentType[0]
: null;
$body = $this->debug->utility->getStreamContents($bodyStream);
$body = StreamUtility::getContents($bodyStream);
if (\strlen($body) === 0) {
return '';
}
Expand Down Expand Up @@ -287,8 +289,8 @@ protected function logRequestBody(RequestInterface $request)
*/
protected function logResponse($response = null, array $requestInfo = array(), $rejectReason = null)
{
\bdk\Debug\Utility\Php::assertType($response, 'Psr\Http\Message\ResponseInterface');
\bdk\Debug\Utility\Php::assertType($rejectReason, 'Exception');
Utility::assertType($response, 'Psr\Http\Message\ResponseInterface');
Utility::assertType($rejectReason, 'Exception');

$duration = $this->debug->timeEnd($this->cfg['label'] . ':' . $requestInfo['requestId'], false);
$metaAppend = $requestInfo['isAsynchronous'] && $this->cfg['asyncResponseWithRequest']
Expand Down
2 changes: 1 addition & 1 deletion src/Debug/Collector/CurlHttpMessageMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CurlHttpMessageMiddleware extends AbstractAsyncMiddleware
*/
public function __construct($cfg = array(), $debug = null)
{
\bdk\Debug\Utility\Php::assertType($debug, 'bdk\Debug');
\bdk\Debug\Utility::assertType($debug, 'bdk\Debug');

$this->cfg = \array_merge($this->cfg, array(
'idPrefix' => 'curl_',
Expand Down
4 changes: 2 additions & 2 deletions src/Debug/Collector/DoctrineLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class DoctrineLogger implements SQLLoggerInterface
*/
public function __construct($connection = null, $debug = null)
{
\bdk\Debug\Utility\Php::assertType($connection, 'Doctrine\DBAL\Connection');
\bdk\Debug\Utility\Php::assertType($debug, 'bdk\Debug');
\bdk\Debug\Utility::assertType($connection, 'Doctrine\DBAL\Connection');
\bdk\Debug\Utility::assertType($debug, 'bdk\Debug');

if (!$debug) {
$debug = Debug::getChannel('Doctrine', array('channelIcon' => $this->icon));
Expand Down
2 changes: 1 addition & 1 deletion src/Debug/Collector/GuzzleMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class GuzzleMiddleware extends AbstractAsyncMiddleware
*/
public function __construct($cfg = array(), $debug = null)
{
\bdk\Debug\Utility\Php::assertType($debug, 'bdk\Debug');
\bdk\Debug\Utility::assertType($debug, 'bdk\Debug');

$this->cfg = \array_merge($this->cfg, array(
'idPrefix' => 'guzzle_',
Expand Down
2 changes: 1 addition & 1 deletion src/Debug/Collector/MySqli.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class MySqli extends mysqliBase
*/
public function __construct($host = null, $username = null, $passwd = null, $dbname = null, $port = null, $socket = null, $debug = null) // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter
{
\bdk\Debug\Utility\Php::assertType($debug, 'bdk\Debug');
\bdk\Debug\Utility::assertType($debug, 'bdk\Debug');

$this->doConstruct(\func_num_args()
? \array_slice(\func_get_args(), 0, 6)
Expand Down
2 changes: 1 addition & 1 deletion src/Debug/Collector/Pdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Pdo extends PdoBase
*/
public function __construct(PdoBase $pdo, $debug = null)
{
\bdk\Debug\Utility\Php::assertType($debug, 'bdk\Debug');
\bdk\Debug\Utility::assertType($debug, 'bdk\Debug');

if (!$debug) {
$debug = Debug::getChannel('PDO', array('channelIcon' => $this->icon));
Expand Down
2 changes: 1 addition & 1 deletion src/Debug/Collector/PhpCurlClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class PhpCurlClass extends Curl
*/
public function __construct($options = array(), $debug = null)
{
\bdk\Debug\Utility\Php::assertType($debug, 'bdk\Debug');
\bdk\Debug\Utility::assertType($debug, 'bdk\Debug');

$this->debugOptions = \array_merge($this->debugOptions, $options);
if (!$debug) {
Expand Down
2 changes: 1 addition & 1 deletion src/Debug/Collector/SimpleCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class SimpleCache implements CacheInterface
*/
public function __construct(CacheInterface $cache, $debug = null)
{
\bdk\Debug\Utility\Php::assertType($debug, 'bdk\Debug');
\bdk\Debug\Utility::assertType($debug, 'bdk\Debug');

if (!$debug) {
$debug = Debug::getChannel('SimpleCache', array('channelIcon' => $this->icon));
Expand Down
4 changes: 2 additions & 2 deletions src/Debug/Collector/SimpleCache/CallInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace bdk\Debug\Collector\SimpleCache;

use bdk\Debug\AbstractComponent;
use bdk\Debug\Utility\Php as PhpUtil;
use bdk\Debug\Utility;
use Exception;

/**
Expand Down Expand Up @@ -99,7 +99,7 @@ public function __debugInfo()
*/
public function end($exception = null)
{
PhpUtil::assertType($exception, 'Exception');
Utility::assertType($exception, 'Exception');

$this->exception = $exception;
$this->timeEnd = \microtime(true);
Expand Down
6 changes: 3 additions & 3 deletions src/Debug/Collector/SoapClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class SoapClient extends SoapClientBase
*/
public function __construct($wsdl, $options = array(), $debug = null)
{
\bdk\Debug\Utility\Php::assertType($debug, 'bdk\Debug');
\bdk\Debug\Utility::assertType($debug, 'bdk\Debug');

if (!$debug) {
$debug = Debug::getChannel('Soap', array('channelIcon' => $this->icon));
Expand Down Expand Up @@ -269,7 +269,7 @@ private function isViaCall()
*/
private function logConstruct($wsdl, $options, $exception = null)
{
\bdk\Debug\Utility\Php::assertType($exception, 'Exception');
\bdk\Debug\Utility::assertType($exception, 'Exception');

$this->debug->groupCollapsed('SoapClient::__construct', $wsdl ?: 'non-WSDL mode', $this->debug->meta('icon', $this->icon));
if ($wsdl && !empty($options['list_functions'])) {
Expand Down Expand Up @@ -305,7 +305,7 @@ private function logConstruct($wsdl, $options, $exception = null)
*/
private function logReqRes($action, $exception = null, $logParsedFault = false)
{
\bdk\Debug\Utility\Php::assertType($exception, 'Exception');
\bdk\Debug\Utility::assertType($exception, 'Exception');

$fault = null;
$xmlRequest = $this->debugGetXmlRequest($action);
Expand Down
6 changes: 3 additions & 3 deletions src/Debug/Collector/StatementInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ class StatementInfo extends AbstractComponent
*/
public function __construct($sql, $params = array(), $types = array())
{
\bdk\Debug\Utility\Php::assertType($params, 'array');
\bdk\Debug\Utility\Php::assertType($types, 'array');
\bdk\Debug\Utility::assertType($params, 'array');
\bdk\Debug\Utility::assertType($types, 'array');

$this->memoryStart = \memory_get_usage(false);
$this->params = $params ?: array();
Expand Down Expand Up @@ -180,7 +180,7 @@ public function appendLog(Debug $debug, array $metaOverride = array())
*/
public function end($exception = null, $rowCount = null)
{
\bdk\Debug\Utility\Php::assertType($exception, 'Exception');
\bdk\Debug\Utility::assertType($exception, 'Exception');

$this->exception = $exception;
$this->rowCount = $rowCount;
Expand Down
2 changes: 1 addition & 1 deletion src/Debug/Collector/SwiftMailerLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class SwiftMailerLogger implements
*/
public function __construct($debug = null)
{
\bdk\Debug\Utility\Php::assertType($debug, 'bdk\Debug');
\bdk\Debug\Utility::assertType($debug, 'bdk\Debug');

if (!$debug) {
$debug = Debug::getChannel('SwiftMailer', array('channelIcon' => $this->icon));
Expand Down
4 changes: 2 additions & 2 deletions src/Debug/Collector/TwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class TwigExtension extends ProfilerExtension
*/
public function __construct($debug = null, $profile = null)
{
\bdk\Debug\Utility\Php::assertType($debug, 'bdk\Debug');
\bdk\Debug\Utility\Php::assertType($profile, 'Twig\Profiler\Profile');
\bdk\Debug\Utility::assertType($debug, 'bdk\Debug');
\bdk\Debug\Utility::assertType($profile, 'Twig\Profiler\Profile');

if (!$debug) {
$debug = Debug::getChannel('Twig', array('channelIcon' => $this->icon));
Expand Down
2 changes: 1 addition & 1 deletion src/Debug/Dump/AbstractValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function __construct(Dumper $dumper)
*/
public function checkTimestamp($val, $abs = null)
{
\bdk\Debug\Utility\Php::assertType($abs, 'bdk\Debug\Abstraction\Abstraction');
$this->debug->utility->assertType($abs, 'bdk\Debug\Abstraction\Abstraction');

if ($abs && $abs['typeMore'] === Type::TYPE_TIMESTAMP) {
$datetime = new DateTime('@' . (int) $val);
Expand Down
8 changes: 4 additions & 4 deletions src/Debug/Dump/Base/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function markupIdentifier($val)
*/
protected function dumpArray(array $array, $abs = null)
{
\bdk\Debug\Utility\Php::assertType($abs, 'bdk\Debug\Abstraction\Abstraction');
$this->debug->utility->assertType($abs, 'bdk\Debug\Abstraction\Abstraction');

if ($this->optionGet('isMaxDepth')) {
return 'array *MAX DEPTH*';
Expand Down Expand Up @@ -93,7 +93,7 @@ protected function dumpCallable(Abstraction $abs)
*/
protected function dumpFloat($val, $abs = null)
{
\bdk\Debug\Utility\Php::assertType($abs, 'bdk\Debug\Abstraction\Abstraction');
$this->debug->utility->assertType($abs, 'bdk\Debug\Abstraction\Abstraction');

$date = $this->checkTimestamp($val, $abs);
return $date
Expand All @@ -118,7 +118,7 @@ protected function dumpIdentifier(Abstraction $abs)
*/
protected function dumpInt($val, $abs = null)
{
\bdk\Debug\Utility\Php::assertType($abs, 'bdk\Debug\Abstraction\Abstraction');
$this->debug->utility->assertType($abs, 'bdk\Debug\Abstraction\Abstraction');

$val = $this->dumpFloat($val, $abs);
return \is_string($val)
Expand Down Expand Up @@ -183,7 +183,7 @@ protected function dumpResource(Abstraction $abs)
*/
protected function dumpString($val, $abs = null)
{
\bdk\Debug\Utility\Php::assertType($abs, 'bdk\Debug\Abstraction\Abstraction');
$this->debug->utility->assertType($abs, 'bdk\Debug\Abstraction\Abstraction');

if (\is_numeric($val)) {
$date = $this->checkTimestamp($val, $abs);
Expand Down
2 changes: 1 addition & 1 deletion src/Debug/Dump/Html/HtmlArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct(ValDumper $valDumper)
*/
public function dump(array $array, $abs = null)
{
\bdk\Debug\Utility\Php::assertType($abs, 'bdk\Debug\Abstraction\Abstraction');
$this->debug->utility->assertType($abs, 'bdk\Debug\Abstraction\Abstraction');

$opts = $this->optionsGet();
if ($opts['isMaxDepth']) {
Expand Down
2 changes: 1 addition & 1 deletion src/Debug/Dump/Html/HtmlString.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function __get($property)
*/
public function dump($val, $abs = null)
{
\bdk\Debug\Utility\Php::assertType($abs, 'bdk\Debug\Abstraction\Abstraction');
$this->debug->utility->assertType($abs, 'bdk\Debug\Abstraction\Abstraction');

if (\is_numeric($val)) {
$this->valDumper->checkTimestamp($val, $abs);
Expand Down
6 changes: 3 additions & 3 deletions src/Debug/Dump/Html/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function __construct(Dumper $dumper)
*/
public function checkTimestamp($val, $abs = null)
{
\bdk\Debug\Utility\Php::assertType($abs, 'bdk\Debug\Abstraction\Abstraction');
$this->debug->utility->assertType($abs, 'bdk\Debug\Abstraction\Abstraction');

$date = parent::checkTimestamp($val, $abs);
if ($date) {
Expand Down Expand Up @@ -225,7 +225,7 @@ protected function dumpCallable(Abstraction $abs)
*/
protected function dumpFloat($val, $abs = null)
{
\bdk\Debug\Utility\Php::assertType($abs, 'bdk\Debug\Abstraction\Abstraction');
$this->debug->utility->assertType($abs, 'bdk\Debug\Abstraction\Abstraction');

if ($val === Type::TYPE_FLOAT_INF) {
return 'INF';
Expand Down Expand Up @@ -295,7 +295,7 @@ protected function dumpRecursion()
*/
protected function dumpString($val, $abs = null)
{
\bdk\Debug\Utility\Php::assertType($abs, 'bdk\Debug\Abstraction\Abstraction');
$this->debug->utility->assertType($abs, 'bdk\Debug\Abstraction\Abstraction');

return $this->string->dump($val, $abs);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Debug/Dump/Text/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected function addQuotes($val)
*/
protected function dumpArray(array $array, $abs = null)
{
\bdk\Debug\Utility\Php::assertType($abs, 'bdk\Debug\Abstraction\Abstraction');
$this->debug->utility->assertType($abs, 'bdk\Debug\Abstraction\Abstraction');

$isNested = $this->valDepth > 0;
$this->valDepth++;
Expand Down Expand Up @@ -120,7 +120,7 @@ protected function dumpBool($val)
*/
protected function dumpFloat($val, $abs = null)
{
\bdk\Debug\Utility\Php::assertType($abs, 'bdk\Debug\Abstraction\Abstraction');
$this->debug->utility->assertType($abs, 'bdk\Debug\Abstraction\Abstraction');

if ($val === Type::TYPE_FLOAT_INF) {
return 'INF';
Expand Down Expand Up @@ -166,7 +166,7 @@ protected function dumpObject(ObjectAbstraction $abs)
*/
protected function dumpString($val, $abs = null)
{
\bdk\Debug\Utility\Php::assertType($abs, 'bdk\Debug\Abstraction\Abstraction');
$this->debug->utility->assertType($abs, 'bdk\Debug\Abstraction\Abstraction');

$date = \is_numeric($val)
? $this->checkTimestamp($val, $abs)
Expand Down
Loading

0 comments on commit 866f1bb

Please sign in to comment.