Skip to content
Permalink
Browse files

Fixed type casting code style.

  • Loading branch information
corpsee committed Dec 20, 2019
1 parent da4b176 commit 2169b30528009c9c2f0fdb90bd2031b3ef747455
@@ -250,7 +250,7 @@ public function edit($userId)
// Only admins can promote/demote users.
$isAdmin = $user->getIsAdmin();
if ($currentUser->getIsAdmin()) {
$isAdmin = (bool) $this->getParam('is_admin', 0);
$isAdmin = (bool)$this->getParam('is_admin', 0);
}

$this->userService->updateUser($user, $name, $email, $password, $isAdmin);
@@ -61,7 +61,7 @@ public function __construct(Builder $builder, Build $build, array $options = [])
}

if (isset($options['args'])) {
$this->args = (string) $options['args'];
$this->args = (string)$options['args'];
}

/** @deprecated Option "path" is deprecated and will be deleted in version 2.0. Use the option "output_path" instead. */
@@ -49,20 +49,20 @@ public function __construct(Builder $builder, Build $build, array $options = [])
}

if (array_key_exists('prefer_dist', $options)) {
$this->preferDist = (bool) $options['prefer_dist'];
$this->preferDist = (bool)$options['prefer_dist'];
}

if (array_key_exists('prefer_source', $options)) {
$this->preferDist = false;
$this->preferSource = (bool) $options['prefer_source'];
$this->preferSource = (bool)$options['prefer_source'];
}

if (array_key_exists('no_dev', $options)) {
$this->noDev = (bool) $options['no_dev'];
$this->noDev = (bool)$options['no_dev'];
}

if (array_key_exists('ignore_platform_reqs', $options)) {
$this->ignorePlatformReqs = (bool) $options['ignore_platform_reqs'];
$this->ignorePlatformReqs = (bool)$options['ignore_platform_reqs'];
}
}

@@ -25,7 +25,7 @@ public static function pluginName()
{
return 'deployer';
}

/**
* {@inheritdoc}
*/
@@ -42,7 +42,7 @@ public function __construct(Builder $builder, Build $build, array $options = [])
$this->reason = $options['reason'];
}

$this->updateOnly = isset($options['update_only']) ? (bool) $options['update_only'] : true;
$this->updateOnly = isset($options['update_only']) ? (bool)$options['update_only'] : true;
}

/**
@@ -69,9 +69,9 @@ public function execute()
]
]
);

$status = (int)$response->getStatusCode();

return (
($status >= 200 && $status < 300)
? true
@@ -86,7 +86,7 @@ public function __construct(Builder $builder, Build $build, array $options = [])
*/
public function execute()
{
$allowPublicArtifacts = (bool) Config::getInstance()->get(
$allowPublicArtifacts = (bool)Config::getInstance()->get(
'php-censor.build.allow_public_artifacts',
false
);
@@ -106,7 +106,7 @@ protected function processReport($xmlString)
$warnings = 0;
foreach ($xml->duplication as $duplication) {
foreach ($duplication->file as $file) {
$fileName = (string) $file['path'];
$fileName = (string)$file['path'];
$fileName = str_replace($this->builder->buildPath, '', $fileName);

$message = <<<CPD
@@ -123,8 +123,8 @@ protected function processReport($xmlString)
$message,
BuildError::SEVERITY_NORMAL,
$fileName,
(int) $file['line'],
(int) $file['line'] + (int) $duplication['lines']
(int)$file['line'],
(int)$file['line'] + (int)$duplication['lines']
);
}

@@ -85,7 +85,7 @@ public function __construct(Builder $builder, Build $build, array $options = [])
$this->reportErrors = true;
}

$this->allowedWarnings = isset($options['allowed_warnings']) ? (int) $options['allowed_warnings'] : 0;
$this->allowedWarnings = isset($options['allowed_warnings']) ? (int)$options['allowed_warnings'] : 0;
}
}

@@ -68,7 +68,7 @@ public function execute()
if (preg_match_all('/\((LOC|CLOC|NCLOC|LLOC)\)\s+([0-9]+)/', $output, $matches)) {
$data = [];
foreach ($matches[1] as $k => $v) {
$data[$v] = (int) $matches[2][$k];
$data[$v] = (int)$matches[2][$k];
}

$this->build->storeMeta((self::pluginName() . '-data'), $data);
@@ -127,7 +127,7 @@ protected function processReport($xmlString)
$warnings = 0;

foreach ($xml->file as $file) {
$fileName = (string) $file['name'];
$fileName = (string)$file['name'];
$fileName = str_replace($this->builder->buildPath, '', $fileName);

foreach ($file->violation as $violation) {
@@ -136,11 +136,11 @@ protected function processReport($xmlString)
$this->build->reportError(
$this->builder,
self::pluginName(),
(string) $violation,
(string)$violation,
PHPCensor\Model\BuildError::SEVERITY_HIGH,
$fileName,
(int) $violation['beginline'],
(int) $violation['endline']
(int)$violation['beginline'],
(int)$violation['endline']
);
}
}
@@ -52,10 +52,10 @@ public function execute()
$xml = new SimpleXMLElement($output);
$attr = $xml->attributes();
$data = [
'time' => (float) $attr['time'],
'tests' => (int) $attr['tests'],
'failures' => (int) $attr['failures'],
'errors' => (int) $attr['errors'],
'time' => (float)$attr['time'],
'tests' => (int)$attr['tests'],
'failures' => (int)$attr['failures'],
'errors' => (int)$attr['errors'],
// now all the tests
'suites' => [],
];
@@ -66,12 +66,12 @@ public function execute()
foreach ($xml->xpath('testsuite') as $group) {
$attr = $group->attributes();
$suite = [
'name' => (String) $attr['name'],
'time' => (float) $attr['time'],
'tests' => (int) $attr['tests'],
'failures' => (int) $attr['failures'],
'errors' => (int) $attr['errors'],
'skipped' => (int) $attr['skipped'],
'name' => (string)$attr['name'],
'time' => (float)$attr['time'],
'tests' => (int)$attr['tests'],
'failures' => (int)$attr['failures'],
'errors' => (int)$attr['errors'],
'skipped' => (int)$attr['skipped'],
// now the cases
'cases' => [],
];
@@ -82,10 +82,10 @@ public function execute()
foreach ($group->xpath('testcase') as $child) {
$attr = $child->attributes();
$case = [
'name' => (String) $attr['name'],
'classname' => (String) $attr['classname'],
'time' => (float) $attr['time'],
'status' => (String) $attr['status'],
'name' => (string)$attr['name'],
'classname' => (string)$attr['classname'],
'time' => (float)$attr['time'],
'status' => (string)$attr['status'],
];

if ('failed' == $case['status']) {
@@ -97,12 +97,12 @@ public function execute()
*/
foreach ($child->xpath('failure') as $failure) {
$attr = $failure->attributes();
$error['type'] = (String) $attr['type'];
$error['message'] = (String) $attr['message'];
$error['type'] = (string)$attr['type'];
$error['message'] = (string)$attr['message'];
}

foreach ($child->xpath('system-err') as $systemError) {
$error['raw'] = (String) $systemError;
$error['raw'] = (string)$systemError;
}

$case['error'] = $error;
@@ -147,7 +147,7 @@ public function execute()
*/
protected function runConfig($directory, $configFile, $logFormat)
{
$allowPublicArtifacts = (bool) Config::getInstance()->get(
$allowPublicArtifacts = (bool)Config::getInstance()->get(
'php-censor.build.allow_public_artifacts',
false
);
@@ -63,7 +63,7 @@ public function __construct(Builder $builder, Build $build, array $options = [])
}

if (isset($options['show_status'])) {
$this->showStatus = (bool) $options['show_status'];
$this->showStatus = (bool)$options['show_status'];
} else {
$this->showStatus = true;
}
@@ -130,7 +130,7 @@ public function __construct(Builder $builder, Build $build, array $options = [])
}

if (array_key_exists('allowed_errors', $options) && $options['allowed_errors']) {
$this->allowedErrors = (int) $options['allowed_errors'];
$this->allowedErrors = (int)$options['allowed_errors'];
}
}

@@ -66,7 +66,7 @@ public function __construct(Builder $builder, Build $build, array $options = [])
$this->recipients = $options['recipients'];
}

$this->sendLog = isset($options['send_log']) && ((bool) $options['send_log'] !== false);
$this->sendLog = isset($options['send_log']) && ((bool)$options['send_log'] !== false);
}

/**
@@ -75,15 +75,15 @@ public function parse()
foreach ($testSuite->testcase as $testCase) {
$testResult = [
'suite' => (string)$testSuite['name'],
'file' => str_replace($this->builder->buildPath, '/', (string) $testCase['file']),
'file' => str_replace($this->builder->buildPath, '/', (string)$testCase['file']),
'name' => (string)$testCase['name'],
'feature' => (string)$testCase['feature'],
'assertions' => (int)$testCase['assertions'],
'time' => (float)$testCase['time']
];

if (isset($testCase['class'])) {
$testResult['class'] = (string) $testCase['class'];
$testResult['class'] = (string)$testCase['class'];
}

// PHPUnit testcases does not have feature field. Use class::method instead
@@ -25,10 +25,5 @@ public function test_wrong_action_name_return_json_with_error()
self::assertEquals('failed', $responseData['body']['status']);

self::assertEquals('application/json', $responseData['headers']['Content-Type']);

// @todo: we can't text the result is JSON file with
// self::assertJson((string) $error);
// since the flush method automatically add the header and break the
// testing framework.
}
}

0 comments on commit 2169b30

Please sign in to comment.
You can’t perform that action at this time.