Add phan checks at max level

This commit is contained in:
2021-10-21 13:37:59 +09:00
parent c2721cb8d4
commit 507249c9ce
7 changed files with 103 additions and 12 deletions

97
.phan/config.php Normal file
View File

@@ -0,0 +1,97 @@
<?php
/**
* This configuration will be read and overlaid on top of the
* default configuration. Command line arguments will be applied
* after this file is read.
*
* @see src/Phan/Config.php
* See Config for all configurable options.
*
* A Note About Paths
* ==================
*
* Files referenced from this file should be defined as
*
* ```
* Config::projectPath('relative_path/to/file')
* ```
*
* where the relative path is relative to the root of the
* project which is defined as either the working directory
* of the phan executable or a path passed in via the CLI
* '-d' flag.
*/
// use Phan\Config;
return [
// If true, missing properties will be created when
// they are first seen. If false, we'll report an
// error message.
"allow_missing_properties" => false,
// Allow null to be cast as any type and for any
// type to be cast to null.
"null_casts_as_any_type" => false,
// Backwards Compatibility Checking
'backward_compatibility_checks' => true,
// Run a quick version of checks that takes less
// time
"quick_mode" => false,
// Only emit critical issues to start with
// (0 is low severity, 5 is normal severity, 10 is critical)
"minimum_severity" => 10,
// default false for include path check
"enable_include_path_checks" => true,
"include_paths" => [
],
'ignore_undeclared_variables_in_global_scope' => true,
"file_list" => [
],
// A list of directories that should be parsed for class and
// method information. After excluding the directories
// defined in exclude_analysis_directory_list, the remaining
// files will be statically analyzed for errors.
//
// Thus, both first-party and third-party code being used by
// your application should be included in this list.
'directory_list' => [
// Change this to include the folders you wish to analyze
// (and the folders of their dependencies)
'.'
// 'www',
// To speed up analysis, we recommend going back later and
// limiting this to only the vendor/ subdirectories your
// project depends on.
// `phan --init` will generate a list of folders for you
//'www/vendor',
],
// A list of directories holding code that we want
// to parse, but not analyze
"exclude_analysis_directory_list" => [
'vendor',
],
'exclude_file_list' => [
],
// what not to show as problem
'suppress_issue_types' => [
// 'PhanUndeclaredMethod',
'PhanEmptyFile',
],
// Override to hardcode existence and types of (non-builtin) globals in the global scope.
// Class names should be prefixed with `\`.
//
// (E.g. `['_FOO' => '\FooClass', 'page' => '\PageClass', 'userId' => 'int']`)
'globals_type_map' => [],
];

View File

@@ -13,10 +13,3 @@ parameters:
- -
message: '#Strict comparison using === between false and true will always evaluate to false.#' message: '#Strict comparison using === between false and true will always evaluate to false.#'
path: %currentWorkingDirectory%/test/aws_gift_card_tests.php path: %currentWorkingDirectory%/test/aws_gift_card_tests.php
#- 'error regex'
#-
# message: 'error regex'
# path: %currentWorkingDirectory%/www/some/*
# paths:
# - ...
# - ...

View File

@@ -321,7 +321,7 @@ class AWS
/** /**
* @param float $amount * @param float $amount
* @param string $creation_id * @param string|null $creation_id
* @return string * @return string
*/ */
public function getGiftCardPayload(float $amount, ?string $creation_id = null): string public function getGiftCardPayload(float $amount, ?string $creation_id = null): string

View File

@@ -54,7 +54,7 @@ final class AmazonIncentives
/** /**
* @param float $value * @param float $value
* @param string $creation_request_id AWS creationRequestId * @param string|null $creation_request_id AWS creationRequestId
* @return Response\CreateResponse * @return Response\CreateResponse
* *
* @throws AmazonErrors * @throws AmazonErrors

View File

@@ -55,7 +55,7 @@ class Client implements ClientInterface
$error_status = 'RESEND'; $error_status = 'RESEND';
$error_code = 'T001'; $error_code = 'T001';
$error_type = 'RateExceeded'; $error_type = 'RateExceeded';
$message = $result_ar['message']; $message = $result_ar['message'] ?? 'Rate exceeded';
} else { } else {
// for all other error messages // for all other error messages
$error_status = $result_ar['agcodResponse']['status'] ?? 'FAILURE'; $error_status = $result_ar['agcodResponse']['status'] ?? 'FAILURE';

View File

@@ -16,7 +16,7 @@ class AmazonDebug
*/ */
private static $debug = false; private static $debug = false;
/** /**
* @var string|null; * @var string|null
*/ */
private static $id = null; private static $id = null;
@@ -91,7 +91,7 @@ class AmazonDebug
if (self::$debug === false) { if (self::$debug === false) {
return; return;
} }
self::$log[self::getId()][] = $data; self::$log[self::getId() ?? ''][] = $data;
} }
/** /**

View File

@@ -249,6 +249,7 @@ if ($run_mocks === true) {
$mock_ok = '<span style="color:green;">MOCK OK</span>'; $mock_ok = '<span style="color:green;">MOCK OK</span>';
$mock_failure = '<span style="color:red;">MOCK FAILURE</span>'; $mock_failure = '<span style="color:red;">MOCK FAILURE</span>';
$mock_value = 500; $mock_value = 500;
$mock = [];
$mock['F0000'] = [ 'ret' => '', 'st' => 'SUCCESS']; // success mock $mock['F0000'] = [ 'ret' => '', 'st' => 'SUCCESS']; // success mock
$mock['F1000'] = [ 'ret' => 'F100', 'st' => 'FAILURE']; // SimpleAmountIsNull, etc $mock['F1000'] = [ 'ret' => 'F100', 'st' => 'FAILURE']; // SimpleAmountIsNull, etc