diff --git a/.github/workflows/check-lang.yml b/.github/workflows/check-lang.yml index cf6d18ee9..9ebee9cab 100644 --- a/.github/workflows/check-lang.yml +++ b/.github/workflows/check-lang.yml @@ -16,8 +16,9 @@ jobs: steps: - uses: actions/checkout@v4 with: - repository: ${{ env.DOCKER_EXMENT_REPOSITORY}} + repository: oreno4649/docker-exment path: ./docker-exment + ref: fix/mysql-warning - uses: actions/checkout@v4 with: diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 8d0842088..046c837d3 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -19,8 +19,9 @@ jobs: steps: - uses: actions/checkout@v4 with: - repository: ${{ env.DOCKER_EXMENT_REPOSITORY}} + repository: oreno4649/docker-exment path: ./docker-exment + ref: fix/mysql-warning - uses: actions/checkout@v4 with: diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index a8dbaabf6..7edf2a9d1 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -24,8 +24,9 @@ jobs: steps: - uses: actions/checkout@v4 with: - repository: ${{ env.DOCKER_EXMENT_REPOSITORY}} + repository: oreno4649/docker-exment path: ./docker-exment + ref: fix/mysql-warning - uses: actions/checkout@v4 with: diff --git a/database/migrations/2019_05_18_164730_support_for_v1_2.php b/database/migrations/2019_05_18_164730_support_for_v1_2.php index a45fdff10..980442dba 100644 --- a/database/migrations/2019_05_18_164730_support_for_v1_2.php +++ b/database/migrations/2019_05_18_164730_support_for_v1_2.php @@ -97,6 +97,7 @@ public function down() /** * drop custom table's table */ + // @phpstan-ignore-next-line protected function dropExmTables() { if (!Schema::hasColumn('custom_tables', 'deleted_at')) { @@ -112,6 +113,7 @@ protected function dropExmTables() /** * hard delete */ + // @phpstan-ignore-next-line protected function deleteRecord($table_name, $classname) { if (!Schema::hasColumn($table_name, 'deleted_at')) { @@ -126,6 +128,7 @@ protected function deleteRecord($table_name, $classname) /** * add key's index */ + // @phpstan-ignore-next-line protected function addIndex() { foreach (static::ADD_INDEX_TABLES as $table_name => $column_name) { @@ -144,6 +147,7 @@ protected function addIndex() /** * add deleted_at key's index */ + // @phpstan-ignore-next-line protected function addDeletedIndex() { // add deleted_at index in custom values table @@ -181,6 +185,7 @@ protected function addDeletedIndex() /** * drop deleted record */ + // @phpstan-ignore-next-line protected function dropDeletedRecord($table) { if (stripos($table, 'exm__') === 0 || $table == 'custom_values') { @@ -205,6 +210,7 @@ protected function dropDeletedRecord($table) /** * drop deleted record */ + // @phpstan-ignore-next-line protected function dropSuuidUnique($table) { $columns = \Schema::getUniqueDefinitions($table, 'suuid'); diff --git a/database/migrations/2020_02_20_155520_add_options_to_filters.php b/database/migrations/2020_02_20_155520_add_options_to_filters.php index abe0f3196..0aebda20d 100644 --- a/database/migrations/2020_02_20_155520_add_options_to_filters.php +++ b/database/migrations/2020_02_20_155520_add_options_to_filters.php @@ -19,7 +19,7 @@ public function up() $table->timestamp('deleted_at', 0)->nullable()->after('updated_at'); } if (!Schema::hasColumn('revisions', 'delete_user_id')) { - /** @phpstan-ignore-next-line unsignedInteger() expects bool, int given */ + // @phpstan-ignore-next-line $table->unsignedInteger('delete_user_id', 0)->nullable()->after('create_user_id'); } }); diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 7c01afbf2..0f6a22421 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -3,7 +3,7 @@ includes: parameters: paths: - vendor/exceedone/exment - level: 5 + level: 7 stubFiles: - exment/stubs/laravel/passport/Client.stub universalObjectCratesClasses: @@ -49,46 +49,6 @@ parameters: message: "#^Return type \\(Illuminate\\\\View\\\\View\\) of method Exceedone\\\\Exment\\\\Form\\\\Field\\\\NestedEmbeds::render\\(\\) should be compatible with return type \\(string\\) of method Illuminate\\\\Contracts\\\\Support\\\\Renderable::render\\(\\)#" path: vendor/exceedone/exment/src/* - - - message: "#^Static call to instance method Exceedone\\\\Exment\\\\Storage\\\\Adapter\\\\ExmentAdapterSftp::getMergeConfigKeys\\(\\).#" - path: vendor/exceedone/exment/src/* - - - - message: "#^Argument of an invalid type Exceedone\\\\Exment\\\\Storage\\\\Adapter\\\\ExmentAdapterSftp supplied for foreach, only iterables are supported.#" - path: vendor/exceedone/exment/src/* - - - - message: "#^Argument of an invalid type Exceedone\\\\Exment\\\\Storage\\\\Adapter\\\\ExmentAdapterS3 supplied for foreach, only iterables are supported.#" - path: vendor/exceedone/exment/src/* - - - - message: "#^Static call to instance method Exceedone\\\\Exment\\\\Storage\\\\Adapter\\\\ExmentAdapterS3::getMergeConfigKeys\\(\\).#" - path: vendor/exceedone/exment/src/* - - - - message: "#^Argument of an invalid type Exceedone\\\\Exment\\\\Storage\\\\Adapter\\\\ExmentAdapterLocal supplied for foreach, only iterables are supported.#" - path: vendor/exceedone/exment/src/* - - - - message: "#^Static call to instance method Exceedone\\\\Exment\\\\Storage\\\\Adapter\\\\ExmentAdapterLocal::getMergeConfigKeys\\(\\).#" - path: vendor/exceedone/exment/src/* - - - - message: "#^Argument of an invalid type Exceedone\\\\Exment\\\\Storage\\\\Adapter\\\\ExmentAdapterFtp supplied for foreach, only iterables are supported.#" - path: vendor/exceedone/exment/src/* - - - - message: "#^Static call to instance method Exceedone\\\\Exment\\\\Storage\\\\Adapter\\\\ExmentAdapterFtp::getMergeConfigKeys\\(\\).#" - path: vendor/exceedone/exment/src/* - - - - message: "#^Argument of an invalid type Exceedone\\\\Exment\\\\Storage\\\\Adapter\\\\ExmentAdapterAzure supplied for foreach, only iterables are supported.#" - path: vendor/exceedone/exment/src/* - - - - message: "#^Static call to instance method Exceedone\\\\Exment\\\\Storage\\\\Adapter\\\\ExmentAdapterAzure::getMergeConfigKeys\\(\\).#" - path: vendor/exceedone/exment/src/* - - message: "#^Call to an undefined method Illuminate\\\\Database\\\\Eloquent\\\\Model::setValueModel\\(\\)#" path: vendor/exceedone/exment/src/* @@ -140,3 +100,7 @@ parameters: - message: "#^Call to an undefined method Illuminate\\\\Contracts\\\\Auth\\\\Authenticatable::#" path: vendor/exceedone/exment/src/* + + - + message: "#^Part .* of encapsed string cannot be cast to string\\.#" + path: vendor/exceedone/exment/src/* diff --git a/src/Auth/ApiKeyGrant.php b/src/Auth/ApiKeyGrant.php index a5c71150a..8b36c5087 100644 --- a/src/Auth/ApiKeyGrant.php +++ b/src/Auth/ApiKeyGrant.php @@ -54,6 +54,9 @@ public function respondToAccessTokenRequest( return $responseType; } + /** + * @return UserEntityInterface + */ protected function validateUser(ServerRequestInterface $request, ClientEntityInterface $client) { $api_key = $this->getRequestParameter('api_key', $request); @@ -82,6 +85,8 @@ public function getIdentifier() /** * {@inheritdoc} + * @param string $api_key + * @return UserEntityInterface|null */ public function getUserEntityByUserCredentials($api_key) { diff --git a/src/Auth/ExmentPasswordBroker.php b/src/Auth/ExmentPasswordBroker.php index 6dcb6d935..095d95f2a 100644 --- a/src/Auth/ExmentPasswordBroker.php +++ b/src/Auth/ExmentPasswordBroker.php @@ -15,7 +15,7 @@ class ExmentPasswordBroker extends PasswordBroker /** * Get the user for the given credentials. * - * @param array $credentials + * @param array $credentials * @return \Illuminate\Contracts\Auth\CanResetPassword|null * * @throws \UnexpectedValueException diff --git a/src/Auth/HasPermissions.php b/src/Auth/HasPermissions.php index cb9fb83f6..cfaecb155 100644 --- a/src/Auth/HasPermissions.php +++ b/src/Auth/HasPermissions.php @@ -24,6 +24,7 @@ trait HasPermissions use Authenticatable; use CanResetPassword; + // @phpstan-ignore-next-line public function isAdministrator() { return collect(System::system_admin_users())->contains($this->getUserId()); @@ -34,6 +35,7 @@ public function isAdministrator() * $role_key * if set array, check whether either items. * @param array|string $role_key */ + // @phpstan-ignore-next-line public function hasPermission($role_key) { // if system doesn't use role, return true @@ -72,6 +74,7 @@ public function hasPermission($role_key) * Checking also each table. If there is even one, return true. * @param array|string $role_key */ + // @phpstan-ignore-next-line public function hasPermissionContainsTable($role_key) { // if system doesn't use role, return true @@ -104,6 +107,7 @@ public function hasPermissionContainsTable($role_key) * @param Plugin $plugin * @param array|string $role_key */ + // @phpstan-ignore-next-line public function hasPermissionPlugin($plugin, $role_key) { // if system doesn't use role, return true @@ -158,6 +162,7 @@ public function hasPermissionPlugin($plugin, $role_key) * whether user has no permission * if no permission, show message on dashboard */ + // @phpstan-ignore-next-line public function noPermission() { // if system doesn't use role, return false @@ -178,6 +183,7 @@ public function noPermission() * * @return Collection */ + // @phpstan-ignore-next-line public function allPermissions(): Collection { // get request session about role @@ -215,6 +221,7 @@ public function allPermissions(): Collection } /** @var Collection $collection */ + // @phpstan-ignore-next-line $collection = collect($permissions); return $collection; } @@ -225,6 +232,7 @@ public function allPermissions(): Collection * @param $role_key * @return Collection */ + // @phpstan-ignore-next-line public function allHasPermissionTables($role_key): Collection { $results = []; @@ -237,6 +245,7 @@ public function allHasPermissionTables($role_key): Collection } } /** @var Collection $collection */ + // @phpstan-ignore-next-line $collection = collect($results); return $collection; } @@ -250,6 +259,7 @@ public function allHasPermissionTables($role_key): Collection * * @return bool */ + // @phpstan-ignore-next-line public function visible($item, $target_tables = []): bool { if (is_string($item)) { @@ -304,6 +314,7 @@ public function visible($item, $target_tables = []): bool * https://exment.net/docs/#/ja/developing_memo * @return array */ + // @phpstan-ignore-next-line public function getOrganizationIdsForQuery($filterType = JoinedOrgFilterType::ALL) { return System::requestSession(Define::SYSTEM_KEY_SESSION_ORGANIZATION_IDS . '_' . $filterType, function () use ($filterType) { @@ -323,6 +334,7 @@ public function getOrganizationIdsForQuery($filterType = JoinedOrgFilterType::AL * @param string $filterType * @return array offset 0 : type, 1 : user or organization id. */ + // @phpstan-ignore-next-line public function getUserAndOrganizationIds($filterType = JoinedOrgFilterType::ALL) { $results = [[SystemTableName::USER, $this->getUserId()]]; @@ -339,6 +351,7 @@ public function getUserAndOrganizationIds($filterType = JoinedOrgFilterType::ALL /** * get permisson array. */ + // @phpstan-ignore-next-line protected function getPermissions() { $authority = System::requestSession(Define::SYSTEM_KEY_SESSION_AUTHORITY, function () { @@ -354,6 +367,7 @@ protected function getPermissions() /** * get all permissons for all custom tables. */ + // @phpstan-ignore-next-line protected function getCustomTablePermissions() { // get all permissons for system. -------------------------------------------------- @@ -412,6 +426,7 @@ protected function getCustomTablePermissions() /** * get Plugin permissons. */ + // @phpstan-ignore-next-line protected function getPluginPermissions() { // get all permissons for system. -------------------------------------------------- @@ -457,6 +472,7 @@ protected function getPluginPermissions() /** * get all permissons for system. */ + // @phpstan-ignore-next-line protected function getSystemPermissions() { // get all permissons for system. -------------------------------------------------- @@ -492,6 +508,7 @@ protected function getSystemPermissions() return $permissions; } + // @phpstan-ignore-next-line protected function getPermissionItems() { $enum = JoinedOrgFilterType::getEnum(System::org_joined_type_role_group(), JoinedOrgFilterType::ALL); diff --git a/src/Auth/PasswordBrokerManager.php b/src/Auth/PasswordBrokerManager.php index 686723a03..1086331af 100644 --- a/src/Auth/PasswordBrokerManager.php +++ b/src/Auth/PasswordBrokerManager.php @@ -17,6 +17,7 @@ protected function resolve($name) return new PasswordBroker( $this->createTokenRepository($config), + // @phpstan-ignore-next-line $this->app['auth']->createUserProvider($config['provider']) ); } diff --git a/src/Auth/PasswordGrant.php b/src/Auth/PasswordGrant.php index 0e9028cad..85ae5da2b 100644 --- a/src/Auth/PasswordGrant.php +++ b/src/Auth/PasswordGrant.php @@ -94,6 +94,7 @@ protected function validateUser(ServerRequestInterface $request, ClientEntityInt /** * {@inheritdoc} */ + // @phpstan-ignore-next-line public function getUserEntityByUserCredentials($username, $password, $login_type, $login_setting, $grantType, ClientEntityInterface $clientEntity) { $provider = config('auth.guards.api.provider'); @@ -110,14 +111,17 @@ public function getUserEntityByUserCredentials($username, $password, $login_type ]; if (method_exists($model, 'findForPassport')) { + // @phpstan-ignore-next-line $user = (new $model())->findForPassport($username, $credentials); } else { + // @phpstan-ignore-next-line $user = (new $model())->where('email', $username)->first(); } if (! $user) { return; } elseif (method_exists($user, 'validateForPassportPasswordGrant')) { + // @phpstan-ignore-next-line if (! $user->validateForPassportPasswordGrant($password, $credentials)) { return; } diff --git a/src/Auth/Permission.php b/src/Auth/Permission.php index 22fb62365..6ccf74297 100644 --- a/src/Auth/Permission.php +++ b/src/Auth/Permission.php @@ -35,6 +35,7 @@ class Permission * Summary of $permission_details * @var array */ + // @phpstan-ignore-next-line protected $permission_details; /** @@ -48,6 +49,7 @@ class Permission * * @param array $attributes */ + // @phpstan-ignore-next-line public function __construct(array $attributes = []) { $this->role_type = array_get($attributes, 'role_type'); @@ -56,21 +58,25 @@ public function __construct(array $attributes = []) $this->permission_details = array_get($attributes, 'permission_details', []); } + // @phpstan-ignore-next-line public function getRoleType() { return $this->role_type; } + // @phpstan-ignore-next-line public function getTableName() { return $this->table_name; } + // @phpstan-ignore-next-line public function getPluginId() { return $this->plugin_id; } + // @phpstan-ignore-next-line public function getPermissionDetails() { return $this->permission_details; @@ -79,14 +85,17 @@ public function getPermissionDetails() /** * @param callable $callback */ + // @phpstan-ignore-next-line public static function bootingShouldPass(callable $callback) { + // @phpstan-ignore-next-line static::$bootingShouldPasses[] = $callback; } /** * Send not found or deny error. */ + // @phpstan-ignore-next-line public static function notFoundOrDeny() { return AdminPermission::error(exmtrans('common.message.notfound_or_deny')); @@ -95,6 +104,7 @@ public static function notFoundOrDeny() /** * Send error response page. */ + // @phpstan-ignore-next-line public static function error($message = null) { return AdminPermission::error($message); @@ -103,6 +113,7 @@ public static function error($message = null) /** * Call the booting ShouldPasses for the exment application. */ + // @phpstan-ignore-next-line protected function fireShouldPasses($endpoint) { foreach (static::$bootingShouldPasses as $callable) { @@ -377,7 +388,7 @@ protected function getEndPoint(?string $endpoint): ?string ///// get last url. $uris = explode("/", $url); foreach ($uris as $k => $uri) { - /** @phpstan-ignore-next-line Call to function is_null() with string will always evaluate to false. */ + // @phpstan-ignore-next-line if (!is_null($uri) && mb_strlen($uri) == 0) { continue; } @@ -503,12 +514,14 @@ protected function checkAsAccessCustomValue($endpoint) protected function isNotAdminUrl(?string $endpoint): bool { $parse_url = parse_url_ex($endpoint); + // @phpstan-ignore-next-line if ($parse_url && array_has($parse_url, 'host') && strpos($endpoint, admin_url()) === false) { return true; } return false; } + // @phpstan-ignore-next-line protected function removeAfterQuery($url) { if (mb_strpos($url, '?') !== false) { diff --git a/src/Auth/ProviderAvatar.php b/src/Auth/ProviderAvatar.php index f8c720da7..1d7d83b46 100644 --- a/src/Auth/ProviderAvatar.php +++ b/src/Auth/ProviderAvatar.php @@ -8,5 +8,6 @@ interface ProviderAvatar * Get the User avatar. * @param mixed $token access token if necessary */ + // @phpstan-ignore-next-line public function getAvatar($token = null); } diff --git a/src/Auth/ThrottlesLogins.php b/src/Auth/ThrottlesLogins.php index ab43d9c4e..2ba19cdcb 100644 --- a/src/Auth/ThrottlesLogins.php +++ b/src/Auth/ThrottlesLogins.php @@ -50,6 +50,7 @@ protected function incrementLoginAttempts(Request $request) * @return void * @throws \Illuminate\Validation\ValidationException */ + // @phpstan-ignore-next-line protected function sendLockoutResponse(Request $request, $errorKey = null) { if (!isset($errorKey)) { diff --git a/src/ColumnItems/CommentItem.php b/src/ColumnItems/CommentItem.php index f394a3967..bdf6408ab 100644 --- a/src/ColumnItems/CommentItem.php +++ b/src/ColumnItems/CommentItem.php @@ -11,6 +11,7 @@ class CommentItem extends SystemItem /** * constructor */ + // @phpstan-ignore-next-line public function __construct($custom_table, $custom_value) { $this->custom_table = $custom_table; @@ -20,6 +21,7 @@ public function __construct($custom_table, $custom_value) $this->label = exmtrans("common.$this->column_name"); } + // @phpstan-ignore-next-line public static function getItem(...$args) { list($custom_table, $custom_value) = $args + [null, null]; @@ -27,18 +29,20 @@ public static function getItem(...$args) } /** - * Set where query for grid filter. + * Set where query for grid filter. * * @param \Illuminate\Database\Query\Builder|\Illuminate\Database\Schema\Builder|\Illuminate\Database\Eloquent\Builder $query * @param mixed $input * @return void */ + // @phpstan-ignore-next-line public function getAdminFilterWhereQuery($query, $input) { $tableName = getDBTableName($this->custom_table); $tableNameComment = getDBTableName(SystemTableName::COMMENT); $columnName = CustomColumn::getEloquent('comment_detail', SystemTableName::COMMENT)->getQueryKey(); + // @phpstan-ignore-next-line $query->whereExists(function ($subQuery) use ($input, $tableName, $tableNameComment, $columnName) { $subQuery->select(\DB::raw(1)) ->from($tableNameComment) diff --git a/src/ColumnItems/CustomColumns/AutoNumber.php b/src/ColumnItems/CustomColumns/AutoNumber.php index f4e5e7ee8..3498b8cbe 100644 --- a/src/ColumnItems/CustomColumns/AutoNumber.php +++ b/src/ColumnItems/CustomColumns/AutoNumber.php @@ -9,13 +9,16 @@ class AutoNumber extends CustomItem { + // @phpstan-ignore-next-line protected $required = false; + // @phpstan-ignore-next-line protected function getAdminFieldClass() { return Field\Display::class; } + // @phpstan-ignore-next-line protected function setAdminOptions(&$field) { if (!isset($this->id)) { @@ -36,6 +39,7 @@ protected function getGridFilterOption(): ?string /** * get auto number value */ + // @phpstan-ignore-next-line public function saved() { // already set value, break @@ -66,6 +70,7 @@ public function saved() /** * Create Auto Number value using format. */ + // @phpstan-ignore-next-line protected function createAutoNumberFormat($options) { // get format diff --git a/src/ColumnItems/CustomColumns/Boolean.php b/src/ColumnItems/CustomColumns/Boolean.php index 7ca512023..b42cf071c 100644 --- a/src/ColumnItems/CustomColumns/Boolean.php +++ b/src/ColumnItems/CustomColumns/Boolean.php @@ -14,8 +14,10 @@ class Boolean extends CustomItem /** * laravel-admin set required. if false, always not-set required */ + // @phpstan-ignore-next-line protected $required = false; + // @phpstan-ignore-next-line protected function _text($v) { if ($this->getTrueValue() == $v) { @@ -26,6 +28,7 @@ protected function _text($v) return null; } + // @phpstan-ignore-next-line public function saving() { // get custom_value's value. @@ -47,18 +50,21 @@ public function saving() } } + // @phpstan-ignore-next-line protected function getAdminFieldClass() { return Field\SwitchField::class; } + // @phpstan-ignore-next-line protected function setValidates(&$validates) { $option = $this->getImportValueOption(); $validates[] = new Validator\BooleanRule($option); } + // @phpstan-ignore-next-line protected function setAdminOptions(&$field) { $options = $this->custom_column->options; @@ -71,6 +77,7 @@ protected function setAdminOptions(&$field) $field->states($states); } + // @phpstan-ignore-next-line protected function setAdminFilterOptions(&$filter) { $column = $this->custom_column; @@ -81,6 +88,7 @@ protected function setAdminFilterOptions(&$filter) ]); } + // @phpstan-ignore-next-line protected function getRemoveValidates() { return [\Encore\Admin\Validator\HasOptionRule::class]; @@ -91,6 +99,7 @@ protected function getRemoveValidates() * * @return array */ + // @phpstan-ignore-next-line protected function getImportValueOption() { $column = $this->custom_column; @@ -148,10 +157,12 @@ public function setCustomColumnOptionForm(&$form) ->default(exmtrans("custom_column.options.false_label_default")); } + // @phpstan-ignore-next-line public function getFalseValue() { return array_get($this->custom_column, 'options.false_value'); } + // @phpstan-ignore-next-line public function getTrueValue() { return array_get($this->custom_column, 'options.true_value'); diff --git a/src/ColumnItems/CustomColumns/Currency.php b/src/ColumnItems/CustomColumns/Currency.php index 3ac11a873..6adc44526 100644 --- a/src/ColumnItems/CustomColumns/Currency.php +++ b/src/ColumnItems/CustomColumns/Currency.php @@ -7,6 +7,7 @@ class Currency extends Decimal { + // @phpstan-ignore-next-line protected function _text($v) { list($symbol, $value) = $this->getSymbolAndValue($v); @@ -17,6 +18,7 @@ protected function _text($v) return getCurrencySymbolLabel($symbol, false, $value); } + // @phpstan-ignore-next-line protected function _html($v) { list($symbol, $value) = $this->getSymbolAndValue($v); @@ -27,6 +29,7 @@ protected function _html($v) return getCurrencySymbolLabel($symbol, true, $value); } + // @phpstan-ignore-next-line protected function getSymbolAndValue($v) { if (is_null($v)) { @@ -38,9 +41,11 @@ protected function getSymbolAndValue($v) && !boolval(array_get($this->options, 'disable_number_format'))) { if (array_has($this->custom_column, 'options.decimal_digit')) { $digit = intval(array_get($this->custom_column, 'options.decimal_digit')); + // @phpstan-ignore-next-line $value = number_format($v, $digit); //$value = preg_replace("/\.?0+$/",'', $value); } else { + // @phpstan-ignore-next-line $value = number_format($v); } } else { @@ -61,6 +66,7 @@ protected function getSymbolAndValue($v) return [$symbol, $value]; } + // @phpstan-ignore-next-line protected function setAdminOptions(&$field) { parent::setAdminOptions($field); diff --git a/src/ColumnItems/CustomColumns/Date.php b/src/ColumnItems/CustomColumns/Date.php index 0c6a840b2..170865f53 100644 --- a/src/ColumnItems/CustomColumns/Date.php +++ b/src/ColumnItems/CustomColumns/Date.php @@ -13,8 +13,10 @@ class Date extends CustomItem { + // @phpstan-ignore-next-line protected $format = 'Y-m-d'; + // @phpstan-ignore-next-line protected function _text($v) { if ($this->displayDate() && boolval(array_get($this->options, 'public_form')) && !isset($v)) { @@ -45,16 +47,19 @@ protected function _text($v) /** * get cast Options */ + // @phpstan-ignore-next-line protected function getCastOptions() { return [DatabaseDataType::TYPE_DATE, true, []]; } + // @phpstan-ignore-next-line protected function getDisplayFormat() { return config('admin.date_format'); } + // @phpstan-ignore-next-line public function saving() { if ($this->autoDate()) { @@ -80,17 +85,19 @@ public function saving() * @param $format * @return string|null */ + // @phpstan-ignore-next-line protected function getDateUseValue($v, $format) { if (is_array($v)) { - /** @phpstan-ignore-next-line Expression on left side of ?? is not nullable. */ + // @phpstan-ignore-next-line return (new \Carbon\Carbon(array_get($v, 'date')))->format($format) ?? null; } - /** @phpstan-ignore-next-line Expression on left side of ?? is not nullable. */ + // @phpstan-ignore-next-line return (new \Carbon\Carbon($v))->format($format) ?? null; } + // @phpstan-ignore-next-line protected function getAdminFieldClass() { if ($this->displayDate()) { @@ -100,12 +107,14 @@ protected function getAdminFieldClass() } + // @phpstan-ignore-next-line protected function getCustomField($classname, $column_name_prefix = null) { $this->autoDate(); return parent::getCustomField($classname, $column_name_prefix); } + // @phpstan-ignore-next-line protected function setAdminOptions(&$field) { if ($this->displayDate()) { @@ -116,16 +125,19 @@ protected function setAdminOptions(&$field) } } + // @phpstan-ignore-next-line protected function setValidates(&$validates) { $validates[] = 'date'; } + // @phpstan-ignore-next-line protected function setAdminFilterOptions(&$filter) { $filter->date(); } + // @phpstan-ignore-next-line protected function getAdminFilterClass() { return ExmFilter\BetweenDate::class; @@ -202,6 +214,7 @@ public function isDate() /** * Compare two values. */ + // @phpstan-ignore-next-line public function compareTwoValues(CustomColumnMulti $compare_column, $this_value, $target_value) { try { diff --git a/src/ColumnItems/CustomColumns/Datetime.php b/src/ColumnItems/CustomColumns/Datetime.php index a9d7d922e..8ff6c3290 100644 --- a/src/ColumnItems/CustomColumns/Datetime.php +++ b/src/ColumnItems/CustomColumns/Datetime.php @@ -11,8 +11,10 @@ class Datetime extends Date { + // @phpstan-ignore-next-line protected $format = 'Y-m-d H:i:s'; + // @phpstan-ignore-next-line protected function getDisplayFormat() { if (FilterKind::useDate(array_get($this->options, 'filterKind'))) { @@ -22,6 +24,7 @@ protected function getDisplayFormat() } } + // @phpstan-ignore-next-line protected function getAdminFieldClass() { if ($this->displayDate()) { @@ -33,6 +36,7 @@ protected function getAdminFieldClass() return Field\Datetime::class; } + // @phpstan-ignore-next-line protected function getAdminFilterClass() { return ExmFilter\BetweenDatetime::class; @@ -41,6 +45,7 @@ protected function getAdminFilterClass() /** * get cast Options */ + // @phpstan-ignore-next-line protected function getCastOptions() { return [DatabaseDataType::TYPE_DATETIME, true, []]; diff --git a/src/ColumnItems/CustomColumns/Decimal.php b/src/ColumnItems/CustomColumns/Decimal.php index 2d0da5ff0..df23a4786 100644 --- a/src/ColumnItems/CustomColumns/Decimal.php +++ b/src/ColumnItems/CustomColumns/Decimal.php @@ -25,9 +25,11 @@ public function prepare() $this->value = $this->_format($this->value); } } + // @phpstan-ignore-next-line return $this; } + // @phpstan-ignore-next-line protected function _format($v) { $v = parseFloat($v); @@ -41,6 +43,7 @@ protected function _format($v) /** * get html(for display) */ + // @phpstan-ignore-next-line protected function _html($v) { // default escapes text @@ -54,6 +57,7 @@ protected function _html($v) return esc_html($text); } + // @phpstan-ignore-next-line protected function _text($v) { if (is_null($v)) { @@ -64,14 +68,17 @@ protected function _text($v) && !boolval(array_get($this->options, 'disable_number_format'))) { if (array_has($this->custom_column, 'options.decimal_digit')) { $digit = intval(array_get($this->custom_column, 'options.decimal_digit')); + // @phpstan-ignore-next-line $number = number_format($v, $digit); return preg_replace("/\.?0+$/", '', $number); } else { + // @phpstan-ignore-next-line return number_format($v); } } return $this->_value($v); } + // @phpstan-ignore-next-line public function saving() { $rmv = rmcomma($this->value); @@ -80,11 +87,13 @@ public function saving() } return strval($rmv); } + // @phpstan-ignore-next-line protected function getAdminFieldClass() { return Field\Text::class; } + // @phpstan-ignore-next-line protected function setAdminOptions(&$field) { $options = $this->custom_column->options; @@ -110,6 +119,7 @@ protected function setAdminOptions(&$field) } } + // @phpstan-ignore-next-line protected function getAdminFilterClass() { return ExmFilter\Between::class; @@ -127,12 +137,13 @@ public function getAdminFilterWhereQuery($query, $input) $this->getAdminFilterWhereQueryNumber($query, $input); } + // @phpstan-ignore-next-line protected function setValidates(&$validates) { $options = $this->custom_column->options; $decimal_digit = intval(array_get($options, 'decimal_digit')?? 2); $integer_digit = Define::MAX_FLOAT_PRECISION - $decimal_digit; - /** @phpstan-ignore-next-line str_repeat expects string, int given*/ + // @phpstan-ignore-next-line $max_size_number = floatval(str_repeat(9, $integer_digit) . '.' . str_repeat(9, $decimal_digit)); $min_size_number = -1 * $max_size_number; @@ -146,6 +157,7 @@ protected function setValidates(&$validates) $validates[] = new Validator\DecimalCommaRule(); } + // @phpstan-ignore-next-line protected function getRemoveValidates() { return ['integer', 'numeric']; @@ -154,6 +166,7 @@ protected function getRemoveValidates() /** * get cast Options */ + // @phpstan-ignore-next-line protected function getCastOptions() { if (array_has($this->custom_column, 'options.decimal_digit')) { diff --git a/src/ColumnItems/CustomColumns/Editor.php b/src/ColumnItems/CustomColumns/Editor.php index b96b4e30d..acb04a003 100644 --- a/src/ColumnItems/CustomColumns/Editor.php +++ b/src/ColumnItems/CustomColumns/Editor.php @@ -14,8 +14,10 @@ class Editor extends CustomItem { + // @phpstan-ignore-next-line protected $tmpfiles; + // @phpstan-ignore-next-line public function saving() { if (is_nullorempty($this->value)) { @@ -27,6 +29,7 @@ public function saving() return strval($value); } + // @phpstan-ignore-next-line public function saved() { if (is_nullorempty($this->tmpfiles)) { @@ -38,6 +41,7 @@ public function saved() } } + // @phpstan-ignore-next-line protected function _text($v) { // replace img html @@ -46,6 +50,7 @@ protected function _text($v) return $v; } + // @phpstan-ignore-next-line protected function _html($v) { $text = $this->_text($v); @@ -61,11 +66,13 @@ protected function _html($v) return '
'.replaceBreak(html_clean($text), false).'
'; } + // @phpstan-ignore-next-line protected function getAdminFieldClass() { return Field\Tinymce::class; } + // @phpstan-ignore-next-line protected function setAdminOptions(&$field) { $options = $this->custom_column->options; @@ -81,6 +88,7 @@ protected function setAdminOptions(&$field) } } + // @phpstan-ignore-next-line protected function setValidates(&$validates) { // value string @@ -97,6 +105,7 @@ protected function setValidates(&$validates) * @param ?string $v * @return string */ + // @phpstan-ignore-next-line public static function replaceImgUrl($v, $options = []) { // replace img html @@ -124,6 +133,7 @@ public static function replaceImgUrl($v, $options = []) } + // @phpstan-ignore-next-line protected function savedFileInEditor($value) { if (is_nullorempty($value)) { @@ -221,6 +231,7 @@ protected function savedFileInEditor($value) return $value; } + // @phpstan-ignore-next-line protected function getExtention($type) { if (is_nullorempty($type)) { diff --git a/src/ColumnItems/CustomColumns/Email.php b/src/ColumnItems/CustomColumns/Email.php index 65df31590..c32baca23 100644 --- a/src/ColumnItems/CustomColumns/Email.php +++ b/src/ColumnItems/CustomColumns/Email.php @@ -9,6 +9,7 @@ class Email extends CustomItem { + // @phpstan-ignore-next-line protected function getAdminFieldClass() { return Field\Email::class; diff --git a/src/ColumnItems/CustomColumns/File.php b/src/ColumnItems/CustomColumns/File.php index 0e0fbc36e..dac41c963 100644 --- a/src/ColumnItems/CustomColumns/File.php +++ b/src/ColumnItems/CustomColumns/File.php @@ -20,6 +20,7 @@ class File extends CustomItem { use SelectTrait; + // @phpstan-ignore-next-line public function saved() { $this->refreshTmpFile(); @@ -29,6 +30,7 @@ public function saved() /** * get file info */ + // @phpstan-ignore-next-line public function file() { return ExmentFile::getFile($this->fileValue($this->value)); @@ -37,6 +39,7 @@ public function file() /** * get text */ + // @phpstan-ignore-next-line protected function _text($v) { if (!is_null($name = $this->getPublicFileName($v))) { @@ -49,6 +52,7 @@ protected function _text($v) /** * get html. show link to file */ + // @phpstan-ignore-next-line protected function _html($v) { if (!is_null($name = $this->getPublicFileName($v))) { @@ -74,6 +78,7 @@ protected function _html($v) * @param array $setting * @return array|true[] */ + // @phpstan-ignore-next-line public function getImportValue($value, $setting = []) { if (is_nullorempty($value)) { @@ -93,6 +98,7 @@ public function getImportValue($value, $setting = []) } $file_path[] = $result; } + // @phpstan-ignore-next-line return [ 'result' => true, 'value' => $file_path @@ -113,6 +119,7 @@ public function getImportValue($value, $setting = []) ]; } + // @phpstan-ignore-next-line protected function getImportFilePath($value) { // Get file info by url @@ -129,6 +136,7 @@ protected function getImportFilePath($value) return $file->path; } + // @phpstan-ignore-next-line protected function getAdminFieldClass() { if ($this->isMultipleEnabled()) { @@ -138,6 +146,7 @@ protected function getAdminFieldClass() } + // @phpstan-ignore-next-line protected function setAdminOptions(&$field) { // set file options @@ -288,6 +297,7 @@ protected function getOriginalForDeleteFile() return $value; } + // @phpstan-ignore-next-line protected static function getFileOptions($custom_column, $id) { $options = [ @@ -320,6 +330,7 @@ protected static function getFileOptions($custom_column, $id) * * @return string|null */ + // @phpstan-ignore-next-line protected function fileValue($v) { if (is_null($v)) { @@ -333,6 +344,7 @@ protected function fileValue($v) return $v; } + // @phpstan-ignore-next-line protected function setValidates(&$validates) { $options = $this->custom_column->options; @@ -347,6 +359,7 @@ protected function setValidates(&$validates) $validates[] = new Validator\FileNameRule(); } + // @phpstan-ignore-next-line protected function getCustomField($classname, $column_name_prefix = null) { $field = parent::getCustomField($classname, $column_name_prefix); @@ -381,6 +394,7 @@ protected function getCustomField($classname, $column_name_prefix = null) * @param $input * @return void */ + // @phpstan-ignore-next-line public function getAdminFilterWhereQuery($query, $input) { list($mark, $value) = \Exment::getQueryMarkAndValue(true, $input); @@ -403,6 +417,7 @@ public function getAdminFilterWhereQuery($query, $input) * @param string|null $q * @return array */ + // @phpstan-ignore-next-line public function getSearchQueries($mark, $value, $takeCount, $q, $options = []) { // get values ids @@ -446,6 +461,7 @@ public function setSearchOrWhere(&$query, $mark, $value, $q) * @param string $value * @return Collection target custom values's id list */ + // @phpstan-ignore-next-line protected function getQueryIds($mark, $value) { ///// first, search document table diff --git a/src/ColumnItems/CustomColumns/Hidden.php b/src/ColumnItems/CustomColumns/Hidden.php index eb0830bc8..92e5fc1e6 100644 --- a/src/ColumnItems/CustomColumns/Hidden.php +++ b/src/ColumnItems/CustomColumns/Hidden.php @@ -7,6 +7,7 @@ class Hidden extends CustomItem { + // @phpstan-ignore-next-line protected function getAdminFieldClass() { return Field\Hidden::class; diff --git a/src/ColumnItems/CustomColumns/Image.php b/src/ColumnItems/CustomColumns/Image.php index 3c10f26b3..703061043 100644 --- a/src/ColumnItems/CustomColumns/Image.php +++ b/src/ColumnItems/CustomColumns/Image.php @@ -13,6 +13,7 @@ class Image extends File /** * get html. show link to image */ + // @phpstan-ignore-next-line protected function _html($v) { // If public form tmp file, return Only file name. @@ -31,6 +32,7 @@ protected function _html($v) ]); } + // @phpstan-ignore-next-line protected function getAdminFieldClass() { if ($this->isMultipleEnabled()) { @@ -39,6 +41,7 @@ protected function getAdminFieldClass() return Field\Image::class; } + // @phpstan-ignore-next-line protected function setAdminOptions(&$field) { parent::setAdminOptions($field); @@ -46,6 +49,7 @@ protected function setAdminOptions(&$field) $field->attribute(['accept' => "image/*"]); } + // @phpstan-ignore-next-line protected function setValidates(&$validates) { $validates[] = new \Exceedone\Exment\Validator\ImageRule(); diff --git a/src/ColumnItems/CustomColumns/ImportValueTrait.php b/src/ColumnItems/CustomColumns/ImportValueTrait.php index 6fb6b4eb0..6eba98f81 100644 --- a/src/ColumnItems/CustomColumns/ImportValueTrait.php +++ b/src/ColumnItems/CustomColumns/ImportValueTrait.php @@ -11,6 +11,7 @@ trait ImportValueTrait * @param array $setting * @return array */ + // @phpstan-ignore-next-line public function getImportValue($value, $setting = []) { $isMultiple = is_array($value) || boolval(array_get($this->custom_column, 'options.multiple_enabled')); @@ -19,6 +20,7 @@ public function getImportValue($value, $setting = []) ///// not default value check // to array + /** @phpstan-ignore-next-line */ $value = stringToArray($value); // replace value @@ -44,6 +46,7 @@ public function getImportValue($value, $setting = []) return [ 'result' => $result, 'value' => $value, + /** @phpstan-ignore-next-line */ 'message' => !$result ? exmtrans('custom_value.import.message.select_item_not_found', [ 'column_view_name' => $this->label(), 'value_options' => implode(exmtrans('common.separate_word'), collect($options)->keys()->toArray()) @@ -58,6 +61,7 @@ public function getImportValue($value, $setting = []) * @param array $options target options * @return string|null */ + // @phpstan-ignore-next-line protected function matchValue($v, $options) { // find value function diff --git a/src/ColumnItems/CustomColumns/Integer.php b/src/ColumnItems/CustomColumns/Integer.php index b2f3293bc..a7384da9c 100644 --- a/src/ColumnItems/CustomColumns/Integer.php +++ b/src/ColumnItems/CustomColumns/Integer.php @@ -14,6 +14,7 @@ class Integer extends CustomItem { use NumberTrait; + // @phpstan-ignore-next-line protected function _text($v) { if (is_null($v)) { @@ -23,11 +24,13 @@ protected function _text($v) if (boolval(array_get($this->custom_column, 'options.number_format')) && is_numeric($v) && !boolval(array_get($this->options, 'disable_number_format'))) { + // @phpstan-ignore-next-line return number_format($v); } return $v; } + // @phpstan-ignore-next-line public function saving() { $rmv = rmcomma($this->value); @@ -37,11 +40,13 @@ public function saving() return strval(intval($rmv)); } + // @phpstan-ignore-next-line protected function getAdminFieldClass() { return Field\Number::class; } + // @phpstan-ignore-next-line protected function setAdminOptions(&$field) { $options = $this->custom_column->options; @@ -64,6 +69,7 @@ protected function setAdminOptions(&$field) }); } + // @phpstan-ignore-next-line protected function getAdminFilterClass() { return ExmFilter\Between::class; @@ -81,6 +87,7 @@ public function getAdminFilterWhereQuery($query, $input) $this->getAdminFilterWhereQueryNumber($query, $input); } + // @phpstan-ignore-next-line protected function setValidates(&$validates) { $options = $this->custom_column->options; @@ -98,6 +105,7 @@ protected function setValidates(&$validates) $validates[] = new Validator\IntegerCommaRule(); } + // @phpstan-ignore-next-line protected function getRemoveValidates() { return ['integer', 'numeric']; @@ -106,6 +114,7 @@ protected function getRemoveValidates() /** * get cast Options */ + // @phpstan-ignore-next-line protected function getCastOptions() { return[DatabaseDataType::TYPE_INTEGER, true, []]; diff --git a/src/ColumnItems/CustomColumns/NumberTrait.php b/src/ColumnItems/CustomColumns/NumberTrait.php index 38144c50b..3c660b72a 100644 --- a/src/ColumnItems/CustomColumns/NumberTrait.php +++ b/src/ColumnItems/CustomColumns/NumberTrait.php @@ -23,14 +23,17 @@ public function isNumeric() /** * Compare two values. */ + // @phpstan-ignore-next-line public function compareTwoValues(CustomColumnMulti $compare_column, $this_value, $target_value) { + /** @phpstan-ignore-next-line */ switch ($compare_column->compare_type) { case FilterOption::COMPARE_GT: if ($this_value > $target_value) { return true; } + /** @phpstan-ignore-next-line */ return $compare_column->getCompareErrorMessage('validation.not_gt', $compare_column->compare_column1, $compare_column->compare_column2); case FilterOption::COMPARE_GTE: @@ -38,6 +41,7 @@ public function compareTwoValues(CustomColumnMulti $compare_column, $this_value, return true; } + /** @phpstan-ignore-next-line */ return $compare_column->getCompareErrorMessage('validation.not_gte', $compare_column->compare_column1, $compare_column->compare_column2); case FilterOption::COMPARE_LT: @@ -45,6 +49,7 @@ public function compareTwoValues(CustomColumnMulti $compare_column, $this_value, return true; } + /** @phpstan-ignore-next-line */ return $compare_column->getCompareErrorMessage('validation.not_lt', $compare_column->compare_column1, $compare_column->compare_column2); case FilterOption::COMPARE_LTE: @@ -52,6 +57,7 @@ public function compareTwoValues(CustomColumnMulti $compare_column, $this_value, return true; } + /** @phpstan-ignore-next-line */ return $compare_column->getCompareErrorMessage('validation.not_lte', $compare_column->compare_column1, $compare_column->compare_column2); } @@ -70,24 +76,33 @@ public function setCustomColumnOptionFormNumber(&$form) { $id = request()->route('id'); + /** @phpstan-ignore-next-line */ $form->number('number_min', exmtrans("custom_column.options.number_min")) ->disableUpdown() ->defaultEmpty(); + /** @phpstan-ignore-next-line */ $form->number('number_max', exmtrans("custom_column.options.number_max")) ->disableUpdown() ->defaultEmpty(); + /** @phpstan-ignore-next-line */ $form->switchbool('number_format', exmtrans("custom_column.options.number_format")) + /** @phpstan-ignore-next-line */ ->help(exmtrans("custom_column.help.number_format")); // calc + /** @phpstan-ignore-next-line */ $custom_table = $this->custom_table; + /** @phpstan-ignore-next-line */ $form->valueModal('calc_formula', exmtrans("custom_column.options.calc_formula")) + /** @phpstan-ignore-next-line */ ->help(exmtrans("custom_column.help.calc_formula") . \Exment::getMoreTag('column', 'custom_column.options.calc_formula')) + /** @phpstan-ignore-next-line */ ->ajax(admin_urls('column', $custom_table->table_name, $id, 'calcModal')) ->modalContentname('options_calc_formula') + /** @phpstan-ignore-next-line */ ->nullText(exmtrans('common.no_setting')) ->valueTextScript('Exment.CustomColumnEvent.GetSettingValText();') ->text(function ($value) use ($custom_table) { @@ -95,7 +110,9 @@ public function setCustomColumnOptionFormNumber(&$form) }) ; + /** @phpstan-ignore-next-line */ $form->switchbool('force_caculate', exmtrans("custom_column.options.force_caculate")) + /** @phpstan-ignore-next-line */ ->help(exmtrans("custom_column.help.force_caculate")); } } diff --git a/src/ColumnItems/CustomColumns/Organization.php b/src/ColumnItems/CustomColumns/Organization.php index 9d514207a..4b838e5f6 100644 --- a/src/ColumnItems/CustomColumns/Organization.php +++ b/src/ColumnItems/CustomColumns/Organization.php @@ -9,6 +9,7 @@ class Organization extends SelectTable { + // @phpstan-ignore-next-line public function __construct($custom_column, $custom_value, $view_column_target = null) { parent::__construct($custom_column, $custom_value, $view_column_target); diff --git a/src/ColumnItems/CustomColumns/Select.php b/src/ColumnItems/CustomColumns/Select.php index 675330a15..7ff5963fe 100644 --- a/src/ColumnItems/CustomColumns/Select.php +++ b/src/ColumnItems/CustomColumns/Select.php @@ -20,11 +20,13 @@ protected function _value($v) return $this->getResultForSelect($v, false); } + // @phpstan-ignore-next-line protected function _text($v) { return $this->getResultForSelect($v, true); } + // @phpstan-ignore-next-line protected function getResultForSelect($v, $label) { $select_options = $this->custom_column->createSelectOptions(); @@ -49,11 +51,13 @@ protected function getResultForSelect($v, $label) } } + // @phpstan-ignore-next-line protected function getReturnsValue($select_options, $val, $label) { return $val; } + // @phpstan-ignore-next-line protected function getAdminFieldClass() { if ($this->isMultipleEnabled()) { @@ -84,12 +88,14 @@ protected function getGridFilterOption(): ?string /** * get cast Options */ + // @phpstan-ignore-next-line protected function getCastOptions() { $type = $this->isMultipleEnabled() ? DatabaseDataType::TYPE_STRING_MULTIPLE : DatabaseDataType::TYPE_STRING; return [$type, false, []]; } + // @phpstan-ignore-next-line protected function setAdminOptions(&$field) { $options = $this->custom_column->createSelectOptions(); @@ -121,6 +127,7 @@ protected function setAdminOptions(&$field) } } + // @phpstan-ignore-next-line protected function setValidates(&$validates) { if (!$this->isFreeInput()) { @@ -129,11 +136,13 @@ protected function setValidates(&$validates) } } + // @phpstan-ignore-next-line protected function getRemoveValidates() { return [\Encore\Admin\Validator\HasOptionRule::class]; } + // @phpstan-ignore-next-line protected function setAdminFilterOptions(&$filter) { $options = $this->custom_column->createSelectOptions(); @@ -145,6 +154,7 @@ protected function setAdminFilterOptions(&$filter) * * @return array */ + // @phpstan-ignore-next-line protected function getImportValueOption() { return $this->custom_column->createSelectOptions(); @@ -156,6 +166,7 @@ public function isMultipleEnabled() return $this->isMultipleEnabledTrait(); } + // @phpstan-ignore-next-line public function isFreeInput() { if (boolval($this->custom_column->getOption('check_radio_enabled', false))) { @@ -167,6 +178,7 @@ public function isFreeInput() return boolval($this->custom_column->getOption('free_input', false)); } + // @phpstan-ignore-next-line protected function getFilterFieldClass() { if ($this->isMultipleEnabled()) { diff --git a/src/ColumnItems/CustomColumns/SelectTable.php b/src/ColumnItems/CustomColumns/SelectTable.php index f41bc5ae9..c3d67fb77 100644 --- a/src/ColumnItems/CustomColumns/SelectTable.php +++ b/src/ColumnItems/CustomColumns/SelectTable.php @@ -29,9 +29,12 @@ class SelectTable extends CustomItem { use SelectTrait; + // @phpstan-ignore-next-line protected $target_table; + // @phpstan-ignore-next-line protected $target_view; + // @phpstan-ignore-next-line public function __construct($custom_column, $custom_value, $view_column_target = null) { parent::__construct($custom_column, $custom_value, $view_column_target); @@ -40,6 +43,7 @@ public function __construct($custom_column, $custom_value, $view_column_target = $this->target_view = CustomView::getEloquent(array_get($custom_column, 'options.select_target_view')); } + // @phpstan-ignore-next-line public function saving() { if (is_nullorempty($this->value)) { @@ -60,12 +64,14 @@ public function saving() /** * get cast Options */ + // @phpstan-ignore-next-line protected function getCastOptions() { $type = $this->isMultipleEnabled() ? DatabaseDataType::TYPE_STRING_MULTIPLE : DatabaseDataType::TYPE_INTEGER; return [$type, false, []]; } + // @phpstan-ignore-next-line public function getSelectTable() { return $this->target_table; @@ -76,16 +82,19 @@ protected function _value($v) return $this->getValue($v, false, false); } + // @phpstan-ignore-next-line protected function _text($v) { return $this->getValue($v, true, false); } + // @phpstan-ignore-next-line protected function _html($v) { return $this->getValue($v, true, true); } + // @phpstan-ignore-next-line protected function getValue($v, $text, $html) { if (!isset($this->target_table)) { @@ -144,6 +153,7 @@ protected function getValue($v, $text, $html) } } + // @phpstan-ignore-next-line protected function getResult($model, $text, $html) { if ($text === false) { @@ -156,6 +166,7 @@ protected function getResult($model, $text, $html) } } + // @phpstan-ignore-next-line protected function getAdminFieldClass() { if ($this->isMultipleEnabled()) { @@ -175,6 +186,7 @@ protected function getGridFilterOption(): ?string return (string)FilterOption::SELECT_EXISTS; } + // @phpstan-ignore-next-line protected function setAdminOptions(&$field) { if (!isset($this->target_table)) { @@ -239,6 +251,7 @@ protected function setAdminOptions(&$field) ]); } + // @phpstan-ignore-next-line public function getSelectOptions($value, $field, array $selectOption = []) { $selectOption = array_merge( @@ -257,6 +270,7 @@ public function getSelectOptions($value, $field, array $selectOption = []) * @param \Closure|null $callback * @return array */ + // @phpstan-ignore-next-line protected function getSelectFieldOptions($callback = null) { return [ @@ -321,6 +335,7 @@ protected function isShowSearchButton($form_column_options): bool * * @return \Closure|null|void */ + // @phpstan-ignore-next-line protected function getRelationFilterCallback($linkage) { if (!isset($linkage)) { @@ -365,6 +380,7 @@ protected function getRelationParentValue($linkage) return null; } + // @phpstan-ignore-next-line protected function setAdminFilterOptions(&$filter) { if (!isset($this->target_table)) { @@ -382,12 +398,14 @@ protected function setAdminFilterOptions(&$filter) })->ajax($ajax); } + // @phpstan-ignore-next-line protected function setValidates(&$validates) { $validates[] = new Validator\SelectTableNumericRule(); $validates[] = new Validator\CustomValueRule($this->target_table, $this->custom_column->getOption('select_target_view')); } + // @phpstan-ignore-next-line protected function getRemoveValidates() { return [\Encore\Admin\Validator\HasOptionRule::class]; @@ -400,6 +418,7 @@ protected function getRemoveValidates() * @param array $setting * @return array */ + // @phpstan-ignore-next-line public function getImportValue($value, $setting = []) { $result = true; @@ -427,6 +446,7 @@ public function getImportValue($value, $setting = []) // if get as id and not numeric, set error if (!is_numeric($v)) { $result = false; + // @phpstan-ignore-next-line $message = trans('validation.integer', ['attribute' => $this->label()]); } } else { @@ -462,6 +482,7 @@ public function getImportValue($value, $setting = []) * @param string $key * @return array */ + // @phpstan-ignore-next-line public function getKeyAndIdList($datalist, $key) { if (is_nullorempty($datalist) || is_nullorempty($key)) { @@ -564,9 +585,11 @@ public function getPureValue($label) $label = preg_replace('/\s+/', ' ', $label); $items = preg_split('/[\s|\x{3000}]+/u', $label); + // @phpstan-ignore-next-line $searchAsId = $use_table_label_id && substr($items[0], 0, 1) == '#'; if ($searchAsId) { + // @phpstan-ignore-next-line $searchId = substr($items[0], 1); $query->where('id', $searchId); @@ -574,11 +597,13 @@ public function getPureValue($label) } $labelColumnIndex = 0; + // @phpstan-ignore-next-line for ($i = ($searchAsId ? 1 : 0); $i < count($items); $i++) { if (count($labelColumns) <= $labelColumnIndex) { return null; } + // @phpstan-ignore-next-line if ($this->setSelectTableQuery($query, array_get($labelColumns[$labelColumnIndex++], 'table_label_id'), $items[$i])) { $executeSearch = true; } @@ -594,6 +619,7 @@ public function getPureValue($label) return is_nullorempty($ids) ? null : ($this->isMultipleEnabled() ? $ids->toArray() : $ids->first()); } + // @phpstan-ignore-next-line protected function setSelectTableQuery($query, $custom_column_id, $value) { $custom_column = CustomColumn::getEloquent($custom_column_id); @@ -633,6 +659,7 @@ protected function setSelectTableQuery($query, $custom_column_id, $value) * @param array $options * @return array */ + // @phpstan-ignore-next-line public function getSearchQueries($mark, $value, $takeCount, $q, $options = []) { if (!$this->isMultipleEnabled()) { @@ -652,6 +679,7 @@ public function isMultipleEnabled() { return $this->isMultipleEnabledTrait(); } + // @phpstan-ignore-next-line protected function getFilterFieldClass() { if ($this->isMultipleEnabled()) { @@ -675,6 +703,7 @@ public function setCustomColumnOptionForm(&$form) } + // @phpstan-ignore-next-line protected function setCustomColumnOptionFormSelectTable(&$form, string $user_org = null) { $id = request()->route('id'); @@ -785,6 +814,7 @@ protected function setCustomColumnOptionFormSelectTable(&$form, string $user_org * * @return array */ + // @phpstan-ignore-next-line protected static function getImportExportColumnSelect($custom_table, $value, $field, $id, $column_type, $isImport = true) { if (is_nullorempty($field)) { @@ -794,7 +824,7 @@ protected static function getImportExportColumnSelect($custom_table, $value, $fi // whether column_type is user or org if (!is_null(old('column_type'))) { $model = CustomColumn::getEloquent(old('column_type'), $custom_table); - /** @phpstan-ignore-next-line Right side of || is always false. */ + // @phpstan-ignore-next-line } elseif (isset($id) || old('column_type')) { $model = CustomColumn::getEloquent($id); } diff --git a/src/ColumnItems/CustomColumns/SelectTrait.php b/src/ColumnItems/CustomColumns/SelectTrait.php index c5cd625da..f776e8dec 100644 --- a/src/ColumnItems/CustomColumns/SelectTrait.php +++ b/src/ColumnItems/CustomColumns/SelectTrait.php @@ -4,11 +4,13 @@ trait SelectTrait { + // @phpstan-ignore-next-line public function getSelectFilterQuery($query, $input) { return $query->whereInArrayString($this->index(), $input); } + // @phpstan-ignore-next-line public function isMultipleEnabledTrait() { return boolval(array_get($this->custom_column, 'options.multiple_enabled', false)); @@ -19,6 +21,7 @@ public function isMultipleEnabledTrait() * * @return array offset 0: type, 1: value */ + // @phpstan-ignore-next-line protected function getDefaultSetting() { list($default_type, $default) = parent::getDefaultSetting(); diff --git a/src/ColumnItems/CustomColumns/SelectValtext.php b/src/ColumnItems/CustomColumns/SelectValtext.php index 1fb4f3792..fdca36eb4 100644 --- a/src/ColumnItems/CustomColumns/SelectValtext.php +++ b/src/ColumnItems/CustomColumns/SelectValtext.php @@ -9,6 +9,7 @@ class SelectValtext extends Select { use ImportValueTrait; + // @phpstan-ignore-next-line protected function getReturnsValue($select_options, $val, $label) { // switch column_type and get return value @@ -25,12 +26,14 @@ protected function getReturnsValue($select_options, $val, $label) return $returns; } + // @phpstan-ignore-next-line protected function setValidates(&$validates) { $select_options = $this->custom_column->createSelectOptions(); $validates[] = new Validator\SelectValTextRule($select_options); } + // @phpstan-ignore-next-line public function saving() { $v = $this->getPureValue($this->value); @@ -44,6 +47,7 @@ public function saving() * * @return array */ + // @phpstan-ignore-next-line protected function getImportValueOption() { return $this->custom_column->createSelectOptions(); diff --git a/src/ColumnItems/CustomColumns/Text.php b/src/ColumnItems/CustomColumns/Text.php index a91f062f7..d08ec72a1 100644 --- a/src/ColumnItems/CustomColumns/Text.php +++ b/src/ColumnItems/CustomColumns/Text.php @@ -13,6 +13,7 @@ class Text extends CustomItem { use TextTrait; + // @phpstan-ignore-next-line public function saving() { if (is_nullorempty($this->value)) { @@ -21,11 +22,13 @@ public function saving() return strval($this->value); } + // @phpstan-ignore-next-line protected function getAdminFieldClass() { return Field\Text::class; } + // @phpstan-ignore-next-line protected function setAdminOptions(&$field) { // value size @@ -38,6 +41,7 @@ protected function setAdminOptions(&$field) } } + // @phpstan-ignore-next-line protected function setValidates(&$validates) { // value size @@ -64,6 +68,7 @@ protected function getAppendHelpText(): ?string } + // @phpstan-ignore-next-line protected function getAvailableCharactersInfo() { // // regex rules diff --git a/src/ColumnItems/CustomColumns/TextTrait.php b/src/ColumnItems/CustomColumns/TextTrait.php index 1acb31c4f..55610f9a7 100644 --- a/src/ColumnItems/CustomColumns/TextTrait.php +++ b/src/ColumnItems/CustomColumns/TextTrait.php @@ -10,6 +10,7 @@ trait TextTrait /** * get max length setting */ + // @phpstan-ignore-next-line protected function getMaxLength($options = null) { if (!isset($options)) { diff --git a/src/ColumnItems/CustomColumns/Textarea.php b/src/ColumnItems/CustomColumns/Textarea.php index 0f9081e0c..c0e5aab1a 100644 --- a/src/ColumnItems/CustomColumns/Textarea.php +++ b/src/ColumnItems/CustomColumns/Textarea.php @@ -12,6 +12,7 @@ class Textarea extends CustomItem { use TextTrait; + // @phpstan-ignore-next-line public function saving() { if (is_nullorempty($this->value)) { @@ -20,6 +21,7 @@ public function saving() return strval($this->value); } + // @phpstan-ignore-next-line protected function _html($v) { $text = $this->_text($v); @@ -33,11 +35,13 @@ protected function _html($v) // replace space to tag return preg_replace('/ /', '', $text); } + // @phpstan-ignore-next-line protected function getAdminFieldClass() { return Field\Textarea::class; } + // @phpstan-ignore-next-line protected function setAdminOptions(&$field) { $options = $this->custom_column->options; @@ -46,6 +50,7 @@ protected function setAdminOptions(&$field) $field->attribute(['maxlength' => $this->getMaxLength($options)]); } + // @phpstan-ignore-next-line protected function setValidates(&$validates) { // value size diff --git a/src/ColumnItems/CustomColumns/Time.php b/src/ColumnItems/CustomColumns/Time.php index 93bf27058..390a3a2c0 100644 --- a/src/ColumnItems/CustomColumns/Time.php +++ b/src/ColumnItems/CustomColumns/Time.php @@ -12,8 +12,10 @@ class Time extends Date { + // @phpstan-ignore-next-line protected $format = 'H:i:s'; + // @phpstan-ignore-next-line protected function getAdminFieldClass() { if ($this->displayDate()) { @@ -22,16 +24,19 @@ protected function getAdminFieldClass() return Field\Time::class; } + // @phpstan-ignore-next-line protected function setAdminFilterOptions(&$filter) { $filter->time(); } + // @phpstan-ignore-next-line protected function getDisplayFormat() { return config('admin.time_format'); } + // @phpstan-ignore-next-line protected function setValidates(&$validates) { $validates[] = new Validator\TimeRule(); @@ -40,6 +45,7 @@ protected function setValidates(&$validates) /** * get cast Options */ + // @phpstan-ignore-next-line protected function getCastOptions() { return [DatabaseDataType::TYPE_TIME, true, []]; diff --git a/src/ColumnItems/CustomColumns/Url.php b/src/ColumnItems/CustomColumns/Url.php index 05d6544ac..8bbf98f62 100644 --- a/src/ColumnItems/CustomColumns/Url.php +++ b/src/ColumnItems/CustomColumns/Url.php @@ -14,6 +14,7 @@ class Url extends CustomItem * get html(for display) * *this function calls from non-escaping value method. So please escape if not necessary unescape. */ + // @phpstan-ignore-next-line protected function _html($v) { $value = $this->_value($v); @@ -24,6 +25,7 @@ protected function _html($v) return \Exment::getUrlTag($url, $value, UrlTagType::BLANK); } + // @phpstan-ignore-next-line protected function getAdminFieldClass() { return Field\Url::class; diff --git a/src/ColumnItems/CustomColumns/User.php b/src/ColumnItems/CustomColumns/User.php index b7d9d6e53..42370aa55 100644 --- a/src/ColumnItems/CustomColumns/User.php +++ b/src/ColumnItems/CustomColumns/User.php @@ -10,6 +10,7 @@ class User extends SelectTable { + // @phpstan-ignore-next-line public function __construct($custom_column, $custom_value, $view_column_target = null) { parent::__construct($custom_column, $custom_value, $view_column_target); @@ -88,6 +89,7 @@ public function setCustomColumnDefaultValueForm(&$form, bool $asCustomForm = fal * * @return array offset 0: type, 1: value */ + // @phpstan-ignore-next-line protected function getDefaultSetting() { list($default_type, $default) = parent::getDefaultSetting(); diff --git a/src/ColumnItems/CustomColumns/Yesno.php b/src/ColumnItems/CustomColumns/Yesno.php index 1e5fcac34..46d9f5d7e 100644 --- a/src/ColumnItems/CustomColumns/Yesno.php +++ b/src/ColumnItems/CustomColumns/Yesno.php @@ -15,13 +15,16 @@ class Yesno extends CustomItem /** * laravel-admin set required. if false, always not-set required */ + // @phpstan-ignore-next-line protected $required = false; + // @phpstan-ignore-next-line protected function _text($v) { return getYesNo($v); } + // @phpstan-ignore-next-line public function saving() { // get custom_value's value. @@ -49,6 +52,7 @@ public function saving() return boolval($this->value) ? 1 : 0; } + // @phpstan-ignore-next-line protected function getAdminFieldClass() { if (boolval(array_get($this->custom_column, 'options.checkbox_enabled'))) { @@ -58,6 +62,7 @@ protected function getAdminFieldClass() } } + // @phpstan-ignore-next-line protected function setAdminOptions(&$field) { if (boolval(array_get($this->custom_column, 'options.checkbox_enabled'))) { @@ -71,16 +76,19 @@ protected function setAdminOptions(&$field) } } + // @phpstan-ignore-next-line protected function setAdminFilterOptions(&$filter) { $filter->radio(Define::YESNO_RADIO); } + // @phpstan-ignore-next-line protected function setValidates(&$validates) { $validates[] = new Validator\YesNoRule(); } + // @phpstan-ignore-next-line protected function getRemoveValidates() { return [\Encore\Admin\Validator\HasOptionRule::class]; @@ -91,6 +99,7 @@ protected function getRemoveValidates() * * @return array */ + // @phpstan-ignore-next-line public function getImportValueOption() { return [ @@ -155,10 +164,12 @@ public function setCustomColumnOptionForm(&$form) ->help(exmtrans("custom_column.help.required_yes")); } + // @phpstan-ignore-next-line public function getFalseValue() { return 0; } + // @phpstan-ignore-next-line public function getTrueValue() { return 1; diff --git a/src/ColumnItems/CustomItem.php b/src/ColumnItems/CustomItem.php index 3df8648d8..57482f96f 100644 --- a/src/ColumnItems/CustomItem.php +++ b/src/ColumnItems/CustomItem.php @@ -29,13 +29,16 @@ abstract class CustomItem implements ItemInterface use SummaryItemTrait; use ColumnOptionQueryTrait; + // @phpstan-ignore-next-line protected $custom_column; + // @phpstan-ignore-next-line protected $custom_value; /** * laravel-admin set required. if false, always not-set required */ + // @phpstan-ignore-next-line protected $required = true; /** @@ -43,9 +46,11 @@ abstract class CustomItem implements ItemInterface * * @var array */ + // @phpstan-ignore-next-line public static $availableFields = []; + // @phpstan-ignore-next-line public function __construct($custom_column, $custom_value, $view_column_target = null) { $this->custom_column = $custom_column; @@ -83,6 +88,7 @@ public static function extend($abstract, $class) /** * get column name */ + // @phpstan-ignore-next-line public function name() { return $this->custom_column->column_name; @@ -93,6 +99,7 @@ public function name() * Join table: false * Wrap: false */ + // @phpstan-ignore-next-line public function sqlname() { return $this->custom_column->getQueryKey(); @@ -101,6 +108,7 @@ public function sqlname() /** * get index name */ + // @phpstan-ignore-next-line public function index() { return $this->custom_column->getIndexColumnName(); @@ -119,6 +127,7 @@ public function apiName() /** * get Text(for display) */ + // @phpstan-ignore-next-line protected function _text($v) { return $v; @@ -127,6 +136,7 @@ protected function _text($v) /** * get html(for display) */ + // @phpstan-ignore-next-line protected function _html($v) { // default escapes text @@ -137,6 +147,7 @@ protected function _html($v) /** * get grid style */ + // @phpstan-ignore-next-line public function gridStyle() { $array = [ @@ -153,6 +164,7 @@ public function gridStyle() /** * get grid header style */ + // @phpstan-ignore-next-line public function gridHeaderStyle() { $array = []; @@ -170,6 +182,7 @@ public function gridHeaderStyle() /** * sortable for grid */ + // @phpstan-ignore-next-line public function sortable() { return $this->indexEnabled() && !$this->isMultipleEnabled(); @@ -179,11 +192,13 @@ public function sortable() * whether column is enabled index. * */ + // @phpstan-ignore-next-line public function indexEnabled() { return $this->custom_column->index_enabled; } + // @phpstan-ignore-next-line public function setCustomValue($custom_value) { $this->custom_value = $this->getTargetCustomValue($custom_value); @@ -197,6 +212,7 @@ public function setCustomValue($custom_value) return $this; } + // @phpstan-ignore-next-line public function getCustomColumn() { return $this->custom_column; @@ -213,6 +229,7 @@ public function getRelation() } + // @phpstan-ignore-next-line protected function getTargetValue($custom_value) { // if options has "summary" (for summary view) @@ -309,6 +326,7 @@ public function getDefaultValue() * * @return array offset 0: type, 1: value */ + // @phpstan-ignore-next-line protected function getDefaultSetting() { $default_type = array_get($this->form_column_options, 'default_type'); @@ -345,6 +363,7 @@ protected function getDefaultValueByQuery() if (is_nullorempty($default)) { return null; } + // @phpstan-ignore-next-line return $this->getPureValueByQuery($default); } @@ -371,6 +390,7 @@ protected function _getDefaultValue() } + // @phpstan-ignore-next-line public function getFilterField($value_type = null) { if (get_class($this) == AutoNumber::class) { @@ -411,11 +431,13 @@ public function isShowFilterNullCheck(): bool return true; } + // @phpstan-ignore-next-line protected function getFilterFieldClass() { return $this->getAdminFieldClass(); } + // @phpstan-ignore-next-line public function getAdminField($form_column = null, $column_name_prefix = null) { $form_column_options = $form_column->options ?? []; @@ -438,6 +460,7 @@ public function getAdminField($form_column = null, $column_name_prefix = null) return $this->getCustomField($classname, $column_name_prefix); } + // @phpstan-ignore-next-line protected function getCustomField($classname, $column_name_prefix = null) { $options = $this->custom_column->options; @@ -508,6 +531,7 @@ protected function getCustomField($classname, $column_name_prefix = null) /** * get view filter type */ + // @phpstan-ignore-next-line public function getViewFilterType() { // get column_type @@ -541,6 +565,7 @@ public function getViewFilterType() /** * get sort name */ + // @phpstan-ignore-next-line public function getSortName() { return $this->sqlUniqueTableName() .'.'. $this->custom_column->getQueryKey(); @@ -549,6 +574,7 @@ public function getSortName() /** * get cast name for sort */ + // @phpstan-ignore-next-line public function getCastName($is_summary = false) { list($type, $addOption, $options) = $this->getCastOptions(); @@ -571,6 +597,7 @@ public function getCastName($is_summary = false) /** * get cast name for virtual column database */ + // @phpstan-ignore-next-line public function getVirtualColumnTypeName() { list($type, $addOption, $options) = $this->getCastOptions(); @@ -610,6 +637,7 @@ protected function getOriginalValue() return array_get($this->custom_value->getOriginal(), 'value.' . $this->custom_column->column_name); } + // @phpstan-ignore-next-line protected function getCastOptions() { return [DatabaseDataType::TYPE_STRING, false, []]; @@ -618,6 +646,7 @@ protected function getCastOptions() /** * get value before saving */ + // @phpstan-ignore-next-line public function saving() { } @@ -625,10 +654,12 @@ public function saving() /** * get value after saving */ + // @phpstan-ignore-next-line public function saved() { } + // @phpstan-ignore-next-line protected function disableEdit() { if ($this->initonly()) { @@ -653,6 +684,7 @@ protected function disableEdit() * skip :Iif true, skip import this column. * value : Replaced value. */ + // @phpstan-ignore-next-line public function getImportValue($value, $options = []) { return [ @@ -661,16 +693,20 @@ public function getImportValue($value, $options = []) ]; } + // @phpstan-ignore-next-line abstract protected function getAdminFieldClass(); + // @phpstan-ignore-next-line protected function setAdminOptions(&$field) { } + // @phpstan-ignore-next-line protected function setAdminFilterOptions(&$filter) { } + // @phpstan-ignore-next-line protected function setValidates(&$validates) { } @@ -680,6 +716,7 @@ protected function getAppendHelpText(): ?string return null; } + // @phpstan-ignore-next-line protected function appendHelp(Field $field) { $text = $this->getAppendHelpText(); @@ -690,6 +727,7 @@ protected function appendHelp(Field $field) $field->appendHelp($text); } + // @phpstan-ignore-next-line public static function getItem(...$args) { list($custom_column, $custom_value, $view_column_target) = $args + [null, null, null]; @@ -737,6 +775,7 @@ public static function findItemClass($column_type) * @param Field $field * @return array */ + // @phpstan-ignore-next-line public function getColumnValidates(Field $field) { $options = array_get($this->custom_column, 'options'); @@ -772,6 +811,7 @@ public function getColumnValidates(Field $field) * Get remove validate array. * @return array if want to remove, append removing array. */ + // @phpstan-ignore-next-line protected function getRemoveValidates() { return []; @@ -781,12 +821,14 @@ protected function getRemoveValidates() /** * Compare two values. */ + // @phpstan-ignore-next-line public function compareTwoValues(CustomColumnMulti $compare_column, $this_value, $target_value) { return true; } + // @phpstan-ignore-next-line public function initonly() { $initOnly = boolval(array_get($this->custom_column->options, 'init_only')); @@ -794,21 +836,25 @@ public function initonly() return $initOnly && isset($this->value); } + // @phpstan-ignore-next-line public function readonly() { return array_boolval($this->form_column_options, 'read_only') || array_get($this->form_column_options, 'field_showing_type') == 'read_only'; } + // @phpstan-ignore-next-line public function viewonly() { return array_boolval($this->form_column_options, 'view_only') || array_get($this->form_column_options, 'field_showing_type') == 'view_only'; } + // @phpstan-ignore-next-line public function hidden() { return array_boolval($this->form_column_options, 'hidden') || array_get($this->form_column_options, 'field_showing_type') == 'hidden'; } + // @phpstan-ignore-next-line public function internal() { return array_boolval($this->form_column_options, 'internal') || array_get($this->form_column_options, 'field_showing_type') == 'internal'; @@ -837,6 +883,7 @@ public function disableDisplayWhenShow(): bool return false; } + // @phpstan-ignore-next-line public function required() { if ($this->initonly() || $this->viewonly() || $this->internal()) { diff --git a/src/ColumnItems/FormOtherItem.php b/src/ColumnItems/FormOtherItem.php index 13ba61d01..464cbbb51 100644 --- a/src/ColumnItems/FormOtherItem.php +++ b/src/ColumnItems/FormOtherItem.php @@ -8,12 +8,17 @@ use Exceedone\Exment\Enums\FormLabelType; use Encore\Admin\Show\Field as ShowField; +/** + * @property \Exceedone\Exment\Model\CustomColumn $custom_column + */ abstract class FormOtherItem implements ItemInterface { use ItemTrait; + // @phpstan-ignore-next-line protected $form_column; + // @phpstan-ignore-next-line protected $custom_value; /** @@ -21,8 +26,10 @@ abstract class FormOtherItem implements ItemInterface * * @var array */ + // @phpstan-ignore-next-line public static $availableFields = []; + // @phpstan-ignore-next-line public function __construct($form_column) { $this->form_column = $form_column; @@ -45,6 +52,7 @@ public static function extend($abstract, $class) /** * get column name */ + // @phpstan-ignore-next-line public function name() { return make_uuid(); @@ -53,6 +61,7 @@ public function name() /** * sqlname */ + // @phpstan-ignore-next-line public function sqlname() { return null; @@ -61,6 +70,7 @@ public function sqlname() /** * get index name */ + // @phpstan-ignore-next-line public function index() { return null; @@ -69,6 +79,7 @@ public function index() /** * get Text(for display) */ + // @phpstan-ignore-next-line protected function _text($v) { return array_get($this->form_column_options, 'text'); @@ -78,6 +89,7 @@ protected function _text($v) * get html(for display) * *Please escape */ + // @phpstan-ignore-next-line protected function _html($v) { // default escapes text @@ -87,6 +99,7 @@ protected function _html($v) /** * get grid style */ + // @phpstan-ignore-next-line public function gridStyle() { return $this->getStyleString(); @@ -95,27 +108,33 @@ public function gridStyle() /** * sortable for grid */ + // @phpstan-ignore-next-line public function sortable() { return false; } + // @phpstan-ignore-next-line public function setCustomValue($custom_value) { $this->custom_value = $custom_value; return $this; } + // @phpstan-ignore-next-line public function getCustomTable() { + /** @phpstan-ignore-next-line */ return $this->custom_column->custom_table; } + // @phpstan-ignore-next-line protected function getTargetValue($custom_value) { return null; } + // @phpstan-ignore-next-line public function getAdminField($form_column = null, $column_name_prefix = null) { if (is_array($form_column)) { @@ -134,8 +153,10 @@ public function getAdminField($form_column = null, $column_name_prefix = null) return $field; } + // @phpstan-ignore-next-line abstract protected function getAdminFieldClass(); + // @phpstan-ignore-next-line protected function setAdminOptions(&$field) { $field_label_type = $this->getLabelType(); @@ -160,12 +181,13 @@ protected function setAdminOptions(&$field) * @param array $options * @return void */ + // @phpstan-ignore-next-line public function setShowFieldOptions(ShowField $field, array $options = []) { $item = $this; $field->as(function ($v) use ($item) { - /** @phpstan-ignore-next-line Call to function is_null() with $this(Exceedone\Exment\ColumnItems\FormOtherItem) will always evaluate to false. */ + // @phpstan-ignore-next-line if (is_null($this)) { return ''; } @@ -180,6 +202,7 @@ public function setShowFieldOptions(ShowField $field, array $options = []) $field->setWidth(12, 0); } + // @phpstan-ignore-next-line public static function getItem(...$args) { list($form_column) = $args + [null]; @@ -219,6 +242,7 @@ public static function findItemClass($column_type) /** * get view filter type */ + // @phpstan-ignore-next-line public function getViewFilterType() { return FilterType::DEFAULT; diff --git a/src/ColumnItems/FormOthers/ExHtml.php b/src/ColumnItems/FormOthers/ExHtml.php index 24eea3504..4576f5c97 100644 --- a/src/ColumnItems/FormOthers/ExHtml.php +++ b/src/ColumnItems/FormOthers/ExHtml.php @@ -7,12 +7,14 @@ class ExHtml extends Html /** * get Text(for display) */ + // @phpstan-ignore-next-line protected function _text($v) { $format = array_get($this->form_column_options, 'html'); return replaceTextFromFormat($format, $v); } + // @phpstan-ignore-next-line public function setCustomValue($custom_value) { $this->value = $custom_value; diff --git a/src/ColumnItems/FormOthers/Explain.php b/src/ColumnItems/FormOthers/Explain.php index fb2967d6c..2de04b5bb 100644 --- a/src/ColumnItems/FormOthers/Explain.php +++ b/src/ColumnItems/FormOthers/Explain.php @@ -8,6 +8,7 @@ class Explain extends FormOtherItem { + // @phpstan-ignore-next-line protected function getAdminFieldClass() { return Field\Description::class; @@ -17,12 +18,14 @@ protected function getAdminFieldClass() * get html(for display) * *Please escape */ + // @phpstan-ignore-next-line public function _html($v) { // default escapes text return replaceBreakEsc($this->_text($v)); } + // @phpstan-ignore-next-line protected function setAdminOptions(&$field) { parent::setAdminOptions($field); diff --git a/src/ColumnItems/FormOthers/Header.php b/src/ColumnItems/FormOthers/Header.php index e4ae2d440..c1984ee43 100644 --- a/src/ColumnItems/FormOthers/Header.php +++ b/src/ColumnItems/FormOthers/Header.php @@ -10,17 +10,20 @@ class Header extends FormOtherItem /** * get html(for display) */ + // @phpstan-ignore-next-line protected function _html($v) { // default escapes text return esc_html($this->_text($v)); } + // @phpstan-ignore-next-line protected function getAdminFieldClass() { return Field\Header::class; } + // @phpstan-ignore-next-line protected function setAdminOptions(&$field) { parent::setAdminOptions($field); diff --git a/src/ColumnItems/FormOthers/Hr.php b/src/ColumnItems/FormOthers/Hr.php index 7220ec4e6..ef4d83e21 100644 --- a/src/ColumnItems/FormOthers/Hr.php +++ b/src/ColumnItems/FormOthers/Hr.php @@ -10,12 +10,14 @@ class Hr extends FormOtherItem /** * get Text(for display) */ + // @phpstan-ignore-next-line public function _html($v) { // Not escaping html whether html item return "
"; } + // @phpstan-ignore-next-line protected function getAdminFieldClass() { return Field\Html::class; diff --git a/src/ColumnItems/FormOthers/Html.php b/src/ColumnItems/FormOthers/Html.php index f7c1412cb..91ab033f3 100644 --- a/src/ColumnItems/FormOthers/Html.php +++ b/src/ColumnItems/FormOthers/Html.php @@ -10,6 +10,7 @@ class Html extends FormOtherItem /** * get Text(for display) */ + // @phpstan-ignore-next-line protected function _text($v) { return array_get($this->form_column_options, 'html'); @@ -19,6 +20,7 @@ protected function _text($v) /** * get Text(for display) */ + // @phpstan-ignore-next-line public function _html($v) { // Not escaping html whether html item @@ -28,11 +30,13 @@ public function _html($v) /** * get column name */ + // @phpstan-ignore-next-line public function name() { return $this->form_column->id; } + // @phpstan-ignore-next-line protected function getAdminFieldClass() { return Field\Html::class; diff --git a/src/ColumnItems/FormOthers/Image.php b/src/ColumnItems/FormOthers/Image.php index 5782af24e..4efd3b985 100644 --- a/src/ColumnItems/FormOthers/Image.php +++ b/src/ColumnItems/FormOthers/Image.php @@ -9,6 +9,7 @@ class Image extends FormOtherItem { + // @phpstan-ignore-next-line protected function getAdminFieldClass() { return Field\Html::class; @@ -18,6 +19,7 @@ protected function getAdminFieldClass() * get html(for display) * *Please escape */ + // @phpstan-ignore-next-line public function _html($v) { // Whether check image url(If preview, set) diff --git a/src/ColumnItems/ItemInterface.php b/src/ColumnItems/ItemInterface.php index 42dfd6853..3333a88f2 100644 --- a/src/ColumnItems/ItemInterface.php +++ b/src/ColumnItems/ItemInterface.php @@ -18,81 +18,97 @@ interface ItemInterface /** * get column key name */ + // @phpstan-ignore-next-line public function name(); /** * get column key sql name. */ + // @phpstan-ignore-next-line public function sqlname(); /** * get column index name */ + // @phpstan-ignore-next-line public function index(); /** * get value. (only this column's value. not custom_value) */ + // @phpstan-ignore-next-line public function value(); /** * get pure value. */ + // @phpstan-ignore-next-line public function pureValue(); /** * get text(for display) */ + // @phpstan-ignore-next-line public function text(); /** * get html */ + // @phpstan-ignore-next-line public function html(); /** * get grid style */ + // @phpstan-ignore-next-line public function gridStyle(); /** * get or set value's id. */ + // @phpstan-ignore-next-line public function id($id = null); /** * get or set header label. */ + // @phpstan-ignore-next-line public function label($label = null); /** * get or set option for convert */ + // @phpstan-ignore-next-line public function options($options = null); /** * sortable grid */ + // @phpstan-ignore-next-line public function sortable(); /** * set custom value */ + // @phpstan-ignore-next-line public function setCustomValue($custom_value); /** * prepare value */ + // @phpstan-ignore-next-line public function prepare(); /** * get custom table */ + // @phpstan-ignore-next-line public function getCustomTable(); /** * get view filter type */ + // @phpstan-ignore-next-line public function getViewFilterType(); /** @@ -107,10 +123,12 @@ public function convertFilterValue($value); /** * set admin filter for filtering grid. */ + // @phpstan-ignore-next-line public function setAdminFilter(&$filter); /** * get item model */ + // @phpstan-ignore-next-line public static function getItem(...$options); } diff --git a/src/ColumnItems/ItemTrait.php b/src/ColumnItems/ItemTrait.php index 89dde383a..9efd3155d 100644 --- a/src/ColumnItems/ItemTrait.php +++ b/src/ColumnItems/ItemTrait.php @@ -19,9 +19,15 @@ * * @property CustomTable $custom_table * @property CustomColumn $custom_column - * @method array getSummaryParams() + * @method array getSummaryParams() * @method mixed getSummaryCondition() * @method mixed getViewPivotCustomValue($custom_value, $options) + * @method string name() + * @method string sqlname() + * @method string index() + * @method mixed setCustomValue($custom_value) + * @method mixed _text($v) + * @method mixed _html($v) */ trait ItemTrait { @@ -35,24 +41,31 @@ trait ItemTrait /** * this column's target custom_table + * @var mixed */ protected $value; + /** + * @var string|null + */ protected $label; + /** + * @var mixed + */ protected $id; /** * Custom form column options * - * @var array + * @var array */ protected $form_column_options = []; /** * Custom form columns in same block. Use for getting other fields. * - * @var array + * @var array */ protected $other_form_columns = []; @@ -63,7 +76,7 @@ trait ItemTrait * 'public_form': If this form is public_form, set publcform model * 'as_confirm' : If this form is before confirm, set true. * ] - * @var array|null + * @var array */ protected $options = []; @@ -72,7 +85,7 @@ trait ItemTrait * Unique column name. * For use class name, laravel-admin grid (If not use this, get same field name, return wrong value.), etc. * - * @var string + * @var string|null */ protected $uniqueName; @@ -80,15 +93,22 @@ trait ItemTrait * Unique table name. * For use join relation(contains select_table). * - * @var string + * @var string|null */ protected $uniqueTableName; + /** + * @return CustomTable + */ public function getCustomTable() { return $this->custom_table; } + /** + * @param CustomTable $custom_table + * @return $this + */ public function setCustomTable(CustomTable $custom_table) { $this->custom_table = $custom_table; @@ -98,6 +118,8 @@ public function setCustomTable(CustomTable $custom_table) /** * set item label + * @param mixed $label + * @return string|null */ public function setLabel($label) { @@ -113,6 +135,7 @@ public function setLabel($label) /** * get value + * @return mixed */ public function value() { @@ -124,6 +147,7 @@ public function value() /** * get pure value. (In database value) * *Don't override this function + * @return mixed */ public function pureValue() { @@ -134,6 +158,7 @@ public function pureValue() /** * get text + * @return mixed */ public function text() { @@ -147,6 +172,7 @@ public function text() /** * get html(for display) * *this function calls from non-escaping value method. So please escape if not necessary unescape. + * @return mixed */ public function html() { @@ -157,6 +183,10 @@ public function html() return is_list($html) ? collect($html)->implode($this->getSeparateWord()) : $html; } + /** + * @param callable $singleValueCallback + * @return mixed + */ protected function _getMultipleValue($singleValueCallback) { $isList = is_list($this->value); @@ -180,6 +210,8 @@ protected function _getMultipleValue($singleValueCallback) /** * get value + * @param mixed $v + * @return mixed */ protected function _value($v) { @@ -189,6 +221,8 @@ protected function _value($v) /** * get pure value. (In database value) * *Don't override this function + * @param mixed $v + * @return mixed */ protected function _pureValue($v) { @@ -197,14 +231,18 @@ protected function _pureValue($v) /** * get or set option for convert + * @param array|null $options + * @return array|$this */ public function options($options = null) { if (!func_num_args()) { + // @phpstan-ignore-next-line return $this->options ?? []; } $this->options = array_merge( + // @phpstan-ignore-next-line $this->options ?? [], $options ); @@ -214,6 +252,8 @@ public function options($options = null) /** * get label. (user theader, form label etc...) + * @param string|null $label + * @return string|null|$this */ public function label($label = null) { @@ -228,6 +268,8 @@ public function label($label = null) /** * get value's id. + * @param mixed $id + * @return mixed|$this */ public function id($id = null) { @@ -238,6 +280,9 @@ public function id($id = null) return $this; } + /** + * @return void + */ public function prepare() { } @@ -245,6 +290,7 @@ public function prepare() /** * whether column is enabled index. * + * @return bool */ public function indexEnabled() { @@ -253,6 +299,7 @@ public function indexEnabled() /** * get cast name for sort + * @return string|null */ public function getCastName() { @@ -261,6 +308,7 @@ public function getCastName() /** * get sort name + * @return string */ public function getSortName() { @@ -292,7 +340,7 @@ public function uniqueName() /** * Set unique name. - * + * @param string $uniqueName * @return $this */ public function setUniqueName($uniqueName) @@ -301,6 +349,9 @@ public function setUniqueName($uniqueName) return $this; } + /** + * @return string + */ public function sqlAsName() { return $this->uniqueName(); @@ -308,6 +359,7 @@ public function sqlAsName() /** * get target table real db name. + * @return string */ public function sqlRealTableName() { @@ -318,6 +370,7 @@ public function sqlRealTableName() /** * get target table unique db name. * Maybe, sql join same db table, so we have to set unique table name. + * @return string */ public function sqlUniqueTableName() { @@ -348,6 +401,7 @@ public function setUniqueTableName(string $uniqueTableName) * @param \Exceedone\Exment\Model\CustomValue $custom_value * @return \Exceedone\Exment\Model\CustomValue|\Illuminate\Support\Collection|null */ + // @phpstan-ignore-next-line protected function getTargetCustomValue($custom_value) { // if summary, cannot get view_pivot_column, so return $custom_value. @@ -368,6 +422,7 @@ protected function getTargetCustomValue($custom_value) * * @return array */ + // @phpstan-ignore-next-line public function apiDefinitions() { $items = []; @@ -548,6 +603,7 @@ protected function getCastColumn(?string $column_name = null, bool $wrap = true, * @param array $array * @return string */ + // @phpstan-ignore-next-line public function getStyleString(array $array = []) { $array['word-wrap'] = 'break-word'; @@ -577,6 +633,7 @@ protected function getLabelType(): string * @param array $options * @return void */ + // @phpstan-ignore-next-line public function setShowFieldOptions(ShowField $field, array $options = []) { $options = array_merge([ @@ -605,6 +662,7 @@ public function setShowFieldOptions(ShowField $field, array $options = []) * * @return self|void */ + // @phpstan-ignore-next-line public function setFormColumnOptions($form_column_options) { if (is_null($form_column_options)) { @@ -625,6 +683,7 @@ public function setFormColumnOptions($form_column_options) * * @return self|void */ + // @phpstan-ignore-next-line public function setOtherFormColumns($other_form_columns) { if (is_null($other_form_columns)) { @@ -648,6 +707,7 @@ public function getRelation() /** * whether column is date * + * @return bool */ public function isDate() { @@ -657,6 +717,7 @@ public function isDate() /** * whether column is datetime * + * @return bool */ public function isDateTime() { @@ -666,12 +727,16 @@ public function isDateTime() /** * whether column is Numeric * + * @return bool */ public function isNumeric() { return false; } + /** + * @return bool + */ public function isMultipleEnabled() { return false; @@ -688,21 +753,33 @@ public function isPublicForm(): bool return !is_nullorempty(array_get($this->options, 'public_form')); } + /** + * @return bool + */ public function readonly() { return false; } + /** + * @return bool + */ public function viewonly() { return false; } + /** + * @return bool + */ public function hidden() { return false; } + /** + * @return bool + */ public function internal() { return false; @@ -725,7 +802,8 @@ public function disableDisplayWhenShow(): bool * @param string $value * @param int $takeCount * @param string|null $q - * @return array + * @param array $options + * @return array */ public function getSearchQueries($mark, $value, $takeCount, $q, $options = []) { @@ -773,6 +851,7 @@ public function getPureValue($label) return null; } + // @phpstan-ignore-next-line protected function getQueryMarkAndValue($mark, $value, $q, $options = []) { $options = array_merge([ @@ -811,6 +890,7 @@ public function convertFilterValue($value) } + // @phpstan-ignore-next-line protected function getAdminFilterClass() { return ExmFilter\Where::class; @@ -819,6 +899,7 @@ protected function getAdminFilterClass() /** * set admin filter for filtering grid. */ + // @phpstan-ignore-next-line public function setAdminFilter(&$filter) { $classname = $this->getAdminFilterClass(); @@ -835,10 +916,12 @@ public function setAdminFilter(&$filter) } if ($this->isShowFilterNullCheck()) { + // @phpstan-ignore-next-line $filteritem->showNullCheck(); } // set whereNull query + // @phpstan-ignore-next-line $filteritem->whereNull(function ($query) { $this->getAdminFilterWhereNullQuery($query); }); @@ -856,6 +939,7 @@ public function setAdminFilter(&$filter) * @param $filter * @return void */ + // @phpstan-ignore-next-line protected function setAdminFilterOptions(&$filter) { } @@ -877,10 +961,12 @@ protected function getGridFilterOption(): ?string * @param mixed $input * @return void */ + // @phpstan-ignore-next-line public function getAdminFilterWhereQuery($query, $input) { // get vieww filter item $viewFilterItem = ViewFilterBase::make($this->getGridFilterOption(), $this); + // @phpstan-ignore-next-line $viewFilterItem->setFilter($query, $input); } @@ -939,6 +1025,7 @@ public function getAdminFilterWhereQueryDate($query, $input) * * @return string|null */ + // @phpstan-ignore-next-line protected function getWeekdayFormat($val) { if (is_null($val)) return null; @@ -949,6 +1036,7 @@ protected function getWeekdayFormat($val) return exmtrans('common.weekday.' . array_get($weekdayNos, $val)); } + // @phpstan-ignore-next-line protected function getWeekdayNolist() { return [ @@ -1026,6 +1114,7 @@ public function getFontAwesomeClass(): ?string /** * get grid header style + * @return array */ public function gridHeaderStyle() { diff --git a/src/ColumnItems/ParentItem.php b/src/ColumnItems/ParentItem.php index 7e8f937b5..15334769b 100644 --- a/src/ColumnItems/ParentItem.php +++ b/src/ColumnItems/ParentItem.php @@ -9,6 +9,9 @@ use Exceedone\Exment\Enums\FilterType; use Exceedone\Exment\Enums\RelationType; +/** + * @property \Exceedone\Exment\Model\CustomColumn $custom_column + */ class ParentItem implements ItemInterface { use ItemTrait; @@ -16,18 +19,22 @@ class ParentItem implements ItemInterface /** * this column's parent table */ + // @phpstan-ignore-next-line protected $parent_table; /** * this custom relation */ + // @phpstan-ignore-next-line protected $custom_relation; /** * specifying the parent table */ + // @phpstan-ignore-next-line protected $target_parent = false; + // @phpstan-ignore-next-line public function __construct($custom_table, $custom_value, $parent_table = null, ?CustomRelation $custom_relation = null) { $this->custom_table = $custom_table; @@ -54,6 +61,7 @@ public function __construct($custom_table, $custom_value, $parent_table = null, /** * get column name */ + // @phpstan-ignore-next-line public function name() { if (array_get($this->options, 'grid_column')) { @@ -68,6 +76,7 @@ public function name() /** * get column name */ + // @phpstan-ignore-next-line public function sqlname() { return 'parent_id'; @@ -76,6 +85,7 @@ public function sqlname() /** * get parent_type column name */ + // @phpstan-ignore-next-line public function sqltypename() { return $this->sqlUniqueTableName() .'.parent_type'; @@ -84,6 +94,7 @@ public function sqltypename() /** * get target table real db name. */ + // @phpstan-ignore-next-line public function sqlRealTableName() { if ($this->custom_relation->relation_type == RelationType::ONE_TO_MANY) { @@ -96,6 +107,7 @@ public function sqlRealTableName() /** * get index name */ + // @phpstan-ignore-next-line public function index() { return $this->name(); @@ -104,6 +116,7 @@ public function index() /** * get text(for display) */ + // @phpstan-ignore-next-line protected function _text($v) { return isset($v) ? $v->getLabel() : null; @@ -113,6 +126,7 @@ protected function _text($v) * get html(for display) * *this function calls from non-escaping value method. So please escape if not necessary unescape. */ + // @phpstan-ignore-next-line protected function _html($v) { if (!isset($v)) { @@ -128,6 +142,7 @@ protected function _html($v) /** * get grid style */ + // @phpstan-ignore-next-line public function gridStyle() { return $this->getStyleString([ @@ -139,11 +154,13 @@ public function gridStyle() /** * sortable for grid */ + // @phpstan-ignore-next-line public function sortable() { return $this->custom_relation && $this->custom_relation->relation_type == RelationType::ONE_TO_MANY; } + // @phpstan-ignore-next-line public function setCustomValue($custom_value) { $this->value = $this->getTargetValue($custom_value); @@ -156,6 +173,7 @@ public function setCustomValue($custom_value) return $this; } + // @phpstan-ignore-next-line public function getCustomTable() { return $this->custom_table; @@ -171,6 +189,7 @@ public function getRelation() return $this->custom_relation; } + // @phpstan-ignore-next-line protected function getTargetValue($custom_value) { if (is_null($custom_value)) { @@ -196,6 +215,7 @@ protected function getTargetValue($custom_value) * @param array $setting * @return array */ + // @phpstan-ignore-next-line public function getImportValue($value, $setting = []) { $result = true; @@ -221,6 +241,7 @@ public function getImportValue($value, $setting = []) } + // @phpstan-ignore-next-line public function getFilterField() { if ($this->parent_table) { @@ -239,23 +260,27 @@ public function getFilterField() /** * get view filter type */ + // @phpstan-ignore-next-line public function getViewFilterType() { return FilterType::SELECT; } + // @phpstan-ignore-next-line public static function getItem(...$args) { list($custom_table, $custom_value, $parent_table) = $args + [null, null, null]; return new self($custom_table, $custom_value); } + // @phpstan-ignore-next-line public static function getItemWithParent(...$args) { list($custom_table, $parent_table) = $args + [null, null]; return new self($custom_table, null, $parent_table); } + // @phpstan-ignore-next-line public static function getItemWithRelation(...$args) { list($custom_table, $custom_relation) = $args + [null, null]; @@ -293,6 +318,7 @@ public function getGroupByWrapTableColumn(bool $asSelect = false, bool $asSqlAsN $group_condition = array_get($this->options, 'group_condition'); if (isset($group_condition)) { + /** @phpstan-ignore-next-line */ $result = \DB::getQueryGrammar()->getDateFormatString($group_condition, $table_column_name, !$asSelect); } // if sql server and created_at, set datetime cast @@ -315,8 +341,10 @@ public function getAdminFilterWhereQuery($query, $input) { $relation = $this->custom_relation; if ($relation->relation_type == RelationType::ONE_TO_MANY) { + // @phpstan-ignore-next-line RelationTable::setQueryOneMany($query, $relation->parent_custom_table, $relation->child_custom_table, $input); } else { + // @phpstan-ignore-next-line RelationTable::setQueryManyMany($query, $relation->parent_custom_table, $relation->child_custom_table, $input); } } @@ -327,6 +355,7 @@ public function getAdminFilterWhereQuery($query, $input) * @param $filter * @return void */ + // @phpstan-ignore-next-line protected function setAdminFilterOptions(&$filter) { $relation = $this->custom_relation; diff --git a/src/ColumnItems/SummaryItemTrait.php b/src/ColumnItems/SummaryItemTrait.php index e0c1e85a2..4d7bda19e 100644 --- a/src/ColumnItems/SummaryItemTrait.php +++ b/src/ColumnItems/SummaryItemTrait.php @@ -61,8 +61,10 @@ public function getSummaryWrapTableColumn(): string $wrapCastColumn = $this->getCastColumn($value_table_column, true, false); $result = "$summary_condition($wrapCastColumn)"; } elseif (isset($group_condition)) { + /** @phpstan-ignore-next-line */ $result = \DB::getQueryGrammar()->getDateFormatString($group_condition, $value_table_column, false); } else { + /** @phpstan-ignore-next-line */ $result = \Exment::wrapColumn($value_table_column); } @@ -86,14 +88,17 @@ public function getGroupByWrapTableColumn(bool $asSelect = false, bool $asSqlAsN $is_wrapped = $options['is_wrapped']; if (isset($group_condition) && !$asSqlAsName) { + /** @phpstan-ignore-next-line */ $result = \DB::getQueryGrammar()->getDateFormatString($group_condition, $value_table_column, !$asSelect); } else { + /** @phpstan-ignore-next-line */ $result = $is_wrapped? $value_table_column: \Exment::wrapColumn($value_table_column); } return $result; } + // @phpstan-ignore-next-line protected function getSummaryParams() { $group_condition = array_get($this->options, 'group_condition'); @@ -105,6 +110,7 @@ protected function getSummaryParams() $is_wrapped = false; if ($this->isMultipleEnabled()) { + /** @phpstan-ignore-next-line */ $value_table_column = \Exment::wrapColumn($value_table_column); $value_table_column = "CASE WHEN {$value_table_column} = '[]' THEN NULL ELSE {$value_table_column} END"; $is_wrapped = true; diff --git a/src/ColumnItems/SystemColumnItemTrait.php b/src/ColumnItems/SystemColumnItemTrait.php index e99f67992..6135e88f1 100644 --- a/src/ColumnItems/SystemColumnItemTrait.php +++ b/src/ColumnItems/SystemColumnItemTrait.php @@ -25,6 +25,7 @@ protected function getRelationTrait() return null; } + /** @phpstan-ignore-next-line */ return CustomRelation::getRelationByParentChild($this->custom_table, $view_pivot_table); } @@ -35,6 +36,7 @@ protected function getRelationTrait() * @param array $options * @return mixed */ + // @phpstan-ignore-next-line protected function getViewPivotValue($custom_value, $options) { $view_pivot_column = array_get($options, 'view_pivot_column'); @@ -42,6 +44,7 @@ protected function getViewPivotValue($custom_value, $options) $pivot_custom_value = $this->getViewPivotCustomValue($custom_value, $options); + /** @phpstan-ignore-next-line */ if (is_list($pivot_custom_value)) { return collect($pivot_custom_value)->map(function ($v) use ($valuekey) { return array_get($v, $valuekey); @@ -58,6 +61,7 @@ protected function getViewPivotValue($custom_value, $options) * @param array $options * @return mixed */ + // @phpstan-ignore-next-line protected function getViewPivotCustomValue($custom_value, $options) { $view_pivot_column = array_get($options, 'view_pivot_column'); @@ -65,6 +69,7 @@ protected function getViewPivotCustomValue($custom_value, $options) $valuekey = $this instanceof \Exceedone\Exment\ColumnItems\SystemItem ? $this->name() : 'value.'.$this->name(); // for relation ---------------------------------------------------- if ($view_pivot_column == SystemColumn::PARENT_ID) { + /** @phpstan-ignore-next-line */ $relation = CustomRelation::getRelationByParentChild($this->custom_table, array_get($options, 'view_pivot_table')); if (!isset($relation)) { return null; @@ -73,6 +78,7 @@ protected function getViewPivotCustomValue($custom_value, $options) $relation_name = $relation->getRelationName(); $relation_custom_value = $custom_value->{$relation_name}; + /** @phpstan-ignore-next-line */ if (is_list($relation_custom_value)) { return collect($relation_custom_value); } @@ -83,12 +89,15 @@ protected function getViewPivotCustomValue($custom_value, $options) $pivot_custom_column = CustomColumn::getEloquent($view_pivot_column); $pivot_id = array_get($custom_value, 'value.'.$pivot_custom_column->column_name); + /** @phpstan-ignore-next-line */ if (is_list($pivot_id)) { return collect($pivot_id)->map(function ($v) { + /** @phpstan-ignore-next-line */ $custom_value = $this->custom_table->getValueModel($v); return $custom_value; }); } else { + /** @phpstan-ignore-next-line */ $custom_value = $this->custom_table->getValueModel($pivot_id); return $custom_value; } diff --git a/src/ColumnItems/SystemItem.php b/src/ColumnItems/SystemItem.php index 6e2716ff2..2195103e3 100644 --- a/src/ColumnItems/SystemItem.php +++ b/src/ColumnItems/SystemItem.php @@ -19,6 +19,9 @@ use Exceedone\Exment\Model\CustomRelation; use Exceedone\Exment\Model\Traits\ColumnOptionQueryTrait; +/** + * @property \Exceedone\Exment\Model\CustomColumn $custom_column + */ class SystemItem implements ItemInterface { use ItemTrait{ @@ -28,10 +31,13 @@ class SystemItem implements ItemInterface use SummaryItemTrait; use ColumnOptionQueryTrait; + // @phpstan-ignore-next-line protected $column_name; + // @phpstan-ignore-next-line protected $custom_value; + // @phpstan-ignore-next-line public function __construct($custom_table, $table_column_name, $custom_value) { // if view_pivot(like select table), custom_table is target's table @@ -47,6 +53,7 @@ public function __construct($custom_table, $table_column_name, $custom_value) /** * get column name */ + // @phpstan-ignore-next-line public function name() { return $this->column_name; @@ -55,6 +62,7 @@ public function name() /** * get column key sql name. */ + // @phpstan-ignore-next-line public function sqlname() { return $this->getSqlColumnName(false); @@ -63,6 +71,7 @@ public function sqlname() /** * get sort name */ + // @phpstan-ignore-next-line public function getSortName() { return $this->getSqlColumnName(true); @@ -92,10 +101,12 @@ public function getSummaryWrapTableColumn(): string $table_column_name = \Exment::wrapColumn($table_column_name); $result = "$summary_condition($table_column_name)"; } elseif (isset($group_condition)) { + /** @phpstan-ignore-next-line */ $result = \DB::getQueryGrammar()->getDateFormatString($group_condition, $table_column_name, false); } // if sql server and created_at, set datetime cast elseif (\Exment::isSqlServer() && array_get($this->getSystemColumnOption(), 'type') == 'datetime') { + /** @phpstan-ignore-next-line */ $result = \DB::getQueryGrammar()->getDateFormatString(GroupCondition::YMDHIS, $table_column_name, true); } else { $result = \Exment::wrapColumn($table_column_name); @@ -121,10 +132,12 @@ public function getGroupByWrapTableColumn(bool $asSelect = false, bool $asSqlAsN $group_condition = array_get($this->options, 'group_condition'); if (isset($group_condition)) { + /** @phpstan-ignore-next-line */ $result = \DB::getQueryGrammar()->getDateFormatString($group_condition, $table_column_name, !$asSelect); } // if sql server and created_at, set datetime cast elseif (\Exment::isSqlServer() && array_get($this->getSystemColumnOption(), 'type') == 'datetime') { + /** @phpstan-ignore-next-line */ $result = \DB::getQueryGrammar()->getDateFormatString(GroupCondition::YMDHIS, $table_column_name, !$asSelect); } else { $result = \Exment::wrapColumn($table_column_name); @@ -158,6 +171,7 @@ protected function getSqlColumnName(bool $appendTable) /** * get index name */ + // @phpstan-ignore-next-line public function index() { $option = $this->getSystemColumnOption(); @@ -168,6 +182,7 @@ public function index() /** * get pure value. (In database value) */ + // @phpstan-ignore-next-line protected function _pureValue($v) { // convert to string if datetime @@ -183,6 +198,7 @@ protected function _pureValue($v) /** * get pure value. (In database value) */ + // @phpstan-ignore-next-line protected function _value($v) { return $v; @@ -191,6 +207,7 @@ protected function _value($v) /** * get text(for display) */ + // @phpstan-ignore-next-line protected function _text($v) { return $this->_pureValue($v); @@ -200,6 +217,7 @@ protected function _text($v) * get html(for display) * *this function calls from non-escaping value method. So please escape if not necessary unescape. */ + // @phpstan-ignore-next-line protected function _html($v) { $option = $this->getSystemColumnOption(); @@ -213,6 +231,7 @@ protected function _html($v) /** * get grid style */ + // @phpstan-ignore-next-line public function gridStyle() { $option = $this->getSystemColumnOption(); @@ -225,6 +244,7 @@ public function gridStyle() /** * sortable for grid */ + // @phpstan-ignore-next-line public function sortable() { return !array_key_value_exists('view_pivot_column', $this->options); @@ -233,6 +253,7 @@ public function sortable() /** * set item label */ + // @phpstan-ignore-next-line public function setLabel($label) { return $this->label = $label; @@ -242,6 +263,7 @@ public function setLabel($label) /** * set default label */ + // @phpstan-ignore-next-line protected function setDefaultLabel($params) { // get label. check not match $this->custom_table and pivot table @@ -257,6 +279,7 @@ protected function setDefaultLabel($params) } } + // @phpstan-ignore-next-line public function setCustomValue($custom_value) { // if contains uniqueName's value in $custom_value, set $custom_value as column name. @@ -277,6 +300,7 @@ public function setCustomValue($custom_value) return $this; } + // @phpstan-ignore-next-line public function getCustomTable() { return $this->custom_table; @@ -292,6 +316,7 @@ public function getRelation() return $this->getRelationTrait(); } + // @phpstan-ignore-next-line protected function getTargetValue($custom_value) { // if options has "summary" (for summary view) @@ -312,6 +337,7 @@ protected function getTargetValue($custom_value) return array_get($custom_value, $this->column_name); } + // @phpstan-ignore-next-line public function getAdminField($form_column = null, $column_name_prefix = null) { $field = new Field\Display($this->name(), [$this->label()]); @@ -320,6 +346,7 @@ public function getAdminField($form_column = null, $column_name_prefix = null) return $field; } + // @phpstan-ignore-next-line public function getFilterField($value_type = null) { if (is_null($value_type)) { @@ -362,6 +389,7 @@ public function getFilterField($value_type = null) * whether column is date * */ + // @phpstan-ignore-next-line public function isDate() { $option = $this->getSystemColumnOption(); @@ -374,6 +402,7 @@ public function isDate() * whether column is datetime * */ + // @phpstan-ignore-next-line public function isDateTime() { $option = $this->getSystemColumnOption(); @@ -386,6 +415,7 @@ public function isDateTime() /** * get view filter type */ + // @phpstan-ignore-next-line public function getViewFilterType() { switch ($this->column_name) { @@ -435,6 +465,7 @@ protected function getGridFilterOption(): ?string return null; } + // @phpstan-ignore-next-line protected function getAdminFilterClass() { switch ($this->column_name) { @@ -472,6 +503,7 @@ public function getAdminFilterWhereQuery($query, $input) * @param $filter * @return void */ + // @phpstan-ignore-next-line protected function setAdminFilterOptions(&$filter) { $option = $this->getSystemColumnOption(); @@ -493,12 +525,14 @@ protected function setAdminFilterOptions(&$filter) } + // @phpstan-ignore-next-line protected function getSystemColumnOption() { return SystemColumn::getOption(['name' => $this->column_name]); } + // @phpstan-ignore-next-line public static function getItem(...$args) { list($custom_table, $table_column_name, $custom_value) = $args + [null, null, null]; diff --git a/src/ColumnItems/WorkflowItem.php b/src/ColumnItems/WorkflowItem.php index 471672414..80e7cb22a 100644 --- a/src/ColumnItems/WorkflowItem.php +++ b/src/ColumnItems/WorkflowItem.php @@ -11,6 +11,7 @@ class WorkflowItem extends SystemItem { + // @phpstan-ignore-next-line protected $table_name = 'workflow_values'; /** @@ -26,6 +27,7 @@ protected function getWorkflow(): ?Workflow * whether column is enabled index. * */ + // @phpstan-ignore-next-line public function sortable() { return false; @@ -50,6 +52,7 @@ protected function getSqlColumnName(bool $appendTable) return $sqlname; } + // @phpstan-ignore-next-line public static function getItem(...$args) { list($custom_table, $column_name, $custom_value) = $args + [null, null, null]; @@ -59,6 +62,7 @@ public static function getItem(...$args) /** * get text(for display) */ + // @phpstan-ignore-next-line protected function _text($v) { return $this->getWorkflowValue($v, false); @@ -68,6 +72,7 @@ protected function _text($v) * get html(for display) * *this function calls from non-escaping value method. So please escape if not necessary unescape. */ + // @phpstan-ignore-next-line protected function _html($v) { return $this->getWorkflowValue($v, true); @@ -79,6 +84,7 @@ protected function _html($v) * @param bool $html is call as html, set true * @return string|null */ + // @phpstan-ignore-next-line protected function getWorkflowValue($val, $html) { if (boolval(array_get($this->options, 'summary'))) { @@ -109,6 +115,7 @@ protected function getWorkflowValue($val, $html) } } + // @phpstan-ignore-next-line public function getFilterField($value_type = null) { $field = new MultipleSelect($this->name(), [$this->label()]); @@ -126,6 +133,7 @@ public function getFilterField($value_type = null) /** * get */ + // @phpstan-ignore-next-line public function getTableName() { return $this->table_name; @@ -149,6 +157,7 @@ public function sqlRealTableName() * @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface */ + // @phpstan-ignore-next-line protected function setAdminFilterOptions(&$filter) { $option = $this->getSystemColumnOption(); diff --git a/src/ConditionItems/ColumnItem.php b/src/ConditionItems/ColumnItem.php index ec3eedeb8..500c5b09c 100644 --- a/src/ConditionItems/ColumnItem.php +++ b/src/ConditionItems/ColumnItem.php @@ -39,6 +39,7 @@ public function isMatchCondition(Condition $condition, CustomValue $custom_value /** * get Update Type Condition */ + // @phpstan-ignore-next-line public function getOperationUpdateType() { $isEnableSystem = false; @@ -60,6 +61,7 @@ public function getOperationUpdateType() /** * get Operation filter value for field, Call as Ajax */ + // @phpstan-ignore-next-line public function getOperationFilterValueAjax($target_key, $target_name, $show_condition_key = true) { $field = $this->getOperationFilterValue($target_key, $target_name, $show_condition_key); @@ -74,9 +76,10 @@ public function getOperationFilterValueAjax($target_key, $target_name, $show_con /** * get Operation filter value for field */ + // @phpstan-ignore-next-line public function getOperationFilterValue($target_key, $target_name, $show_condition_key = true) { - /** @phpstan-ignore-next-line constructor expects array, string|null given */ + // @phpstan-ignore-next-line $field = new ChangeField($this->className, $this->label); $field->rules([new ChangeFieldRule($this->custom_table, $this->label, $this->target)]); if ($target_key == Enums\OperationUpdateType::DEFAULT) { @@ -94,6 +97,7 @@ public function getOperationFilterValue($target_key, $target_name, $show_conditi /** * get Operation filter value for field */ + // @phpstan-ignore-next-line public function getOperationFilterValueChangeField($target_key, $target_name, $show_condition_key = true) { $item = $this->getFormColumnItem(); @@ -167,9 +171,11 @@ public function getConditionLabel(Condition $condition) public function hasAuthority(WorkflowAuthorityInterface $workflow_authority, ?CustomValue $custom_value, $targetUser) { $custom_column = CustomColumn::find($workflow_authority->related_id); + // @phpstan-ignore-next-line if (!ColumnType::isUserOrganization($custom_column->column_type)) { return false; } + // @phpstan-ignore-next-line $auth_values = array_get($custom_value, 'value.' . $custom_column->column_name); if (is_null($auth_values)) { return false; @@ -178,6 +184,7 @@ public function hasAuthority(WorkflowAuthorityInterface $workflow_authority, ?Cu $auth_values = [$auth_values]; } + // @phpstan-ignore-next-line switch ($custom_column->column_type) { case ColumnType::USER: return in_array($targetUser->id, $auth_values); @@ -216,6 +223,7 @@ public static function setWorkflowConditionQuery($query, $tableName, $custom_tab $ids = \Exment::user()->base_user->belong_organizations->pluck('id')->toArray(); foreach ($custom_columns as $custom_column) { + // @phpstan-ignore-next-line $query->orWhere(function ($query) use ($custom_column, $tableName, $ids) { $indexName = $custom_column->getIndexColumnName(); @@ -243,6 +251,7 @@ public static function setWorkflowConditionQuery($query, $tableName, $custom_tab * @param CustomViewSort $custom_view_sort * @return void */ + // @phpstan-ignore-next-line public function setQuerySort($query, CustomViewSort $custom_view_sort) { $column_item = $custom_view_sort->column_item; @@ -317,6 +326,7 @@ public function getColumnValueKey($column_type_target, $custom_column): ?string * * @return array offset 0 : column id, 1 : table id */ + // @phpstan-ignore-next-line public function getColumnAndTableId($column_name, $custom_table): array { $target_column = CustomColumn::getEloquent($column_name, $custom_table); diff --git a/src/ConditionItems/ColumnSystemItemTrait.php b/src/ConditionItems/ColumnSystemItemTrait.php index 1fb16596b..eb3f4849d 100644 --- a/src/ConditionItems/ColumnSystemItemTrait.php +++ b/src/ConditionItems/ColumnSystemItemTrait.php @@ -7,6 +7,7 @@ trait ColumnSystemItemTrait { + // @phpstan-ignore-next-line public function getFilterOption() { // get column item @@ -56,6 +57,7 @@ public function getChangeField($key, $show_condition_key = true) return $column_item->getFilterField($value_type); } + // @phpstan-ignore-next-line protected function getFormColumnItem() { return CustomViewFilter::getColumnItem($this->target, $this->custom_table) diff --git a/src/ConditionItems/ConditionItemBase.php b/src/ConditionItems/ConditionItemBase.php index a83ce1cd6..1e0e6b36e 100644 --- a/src/ConditionItems/ConditionItemBase.php +++ b/src/ConditionItems/ConditionItemBase.php @@ -25,7 +25,9 @@ */ abstract class ConditionItemBase implements ConditionItemInterface { + // @phpstan-ignore-next-line protected $custom_table; + // @phpstan-ignore-next-line protected $target; /** @@ -56,12 +58,14 @@ abstract class ConditionItemBase implements ConditionItemInterface */ protected $label; + // @phpstan-ignore-next-line public function __construct(?CustomTable $custom_table, $target) { $this->custom_table = $custom_table; $this->target = $target; } + // @phpstan-ignore-next-line public function setElement($elementName, $className, $label) { $this->elementName = $elementName; @@ -71,6 +75,7 @@ public function setElement($elementName, $className, $label) return $this; } + // @phpstan-ignore-next-line public function filterKind($filterKind = null) { if (isset($filterKind)) { @@ -84,6 +89,7 @@ public function filterKind($filterKind = null) /** * Get condition item */ + // @phpstan-ignore-next-line public static function getItem(?CustomTable $custom_table, string $target, string $target_column_id) { if (is_nullorempty($target)) { @@ -97,6 +103,7 @@ public static function getItem(?CustomTable $custom_table, string $target, strin /** * Get condition item by request */ + // @phpstan-ignore-next-line public static function getItemByRequest(?CustomTable $custom_table, ?string $target_query) { if (is_nullorempty($target_query)) { @@ -191,6 +198,7 @@ protected static function getConditionDetailItem(?CustomTable $custom_table, str /** * get filter condition */ + // @phpstan-ignore-next-line public function getFilterCondition() { $options = $this->getFilterOption(); @@ -203,6 +211,7 @@ public function getFilterCondition() /** * get Update Type Condition */ + // @phpstan-ignore-next-line public function getOperationUpdateType() { return collect([Enums\OperationUpdateType::DEFAULT])->map(function ($val) { @@ -213,6 +222,7 @@ public function getOperationUpdateType() /** * get Update Type Condition */ + // @phpstan-ignore-next-line public function getOperationFilterValue($target_key, $target_name, $show_condition_key = true) { return $this->getFilterValue($target_key, $target_name, $show_condition_key); @@ -221,6 +231,7 @@ public function getOperationFilterValue($target_key, $target_name, $show_conditi /** * get filter value */ + // @phpstan-ignore-next-line public function getFilterValueAjax($target_key, $target_name, $show_condition_key = true) { $field = $this->getFilterValue($target_key, $target_name, $show_condition_key); @@ -235,12 +246,13 @@ public function getFilterValueAjax($target_key, $target_name, $show_condition_ke /** * get filter value */ + // @phpstan-ignore-next-line public function getFilterValue($target_key, $target_name, $show_condition_key = true) { if (is_nullorempty($this->target) || is_nullorempty($target_key) || is_nullorempty($target_name)) { return null; } - /** @phpstan-ignore-next-line constructor expects array, string|null given */ + // @phpstan-ignore-next-line $field = new ChangeField($this->className, $this->label); $field->rules([new ChangeFieldRule($this->custom_table, $this->label, $this->target)]); $field->adminField(function () use ($target_key, $show_condition_key) { @@ -251,6 +263,7 @@ public function getFilterValue($target_key, $target_name, $show_condition_key = return $field; } + // @phpstan-ignore-next-line protected function getFilterOptionConditon() { return array_get(FilterOption::FILTER_OPTIONS(), FilterType::CONDITION); @@ -312,6 +325,7 @@ public function getQueryKey(Condition $condition): ?string * @param Model\CustomViewSort $custom_view_sort * @return void */ + // @phpstan-ignore-next-line public function setQuerySort($query, Model\CustomViewSort $custom_view_sort) { } @@ -361,6 +375,7 @@ public function getColumnValueKey($column_type_target, $custom_column): ?string * * @return array offset 0 : column id, 1 : table id */ + // @phpstan-ignore-next-line public function getColumnAndTableId($column_name, $custom_table): array { return [null, null]; diff --git a/src/ConditionItems/ConditionItemInterface.php b/src/ConditionItems/ConditionItemInterface.php index 6fb3208d7..aaa1b7284 100644 --- a/src/ConditionItems/ConditionItemInterface.php +++ b/src/ConditionItems/ConditionItemInterface.php @@ -8,6 +8,7 @@ interface ConditionItemInterface { + // @phpstan-ignore-next-line public function getFilterOption(); /** @@ -34,6 +35,7 @@ public function getConditionLabel(Condition $condition); */ public function getConditionText(Condition $condition); + // @phpstan-ignore-next-line public function getText($key, $value, $showFilter = true); /** diff --git a/src/ConditionItems/FormDataItem.php b/src/ConditionItems/FormDataItem.php index 16ec05394..807d377dc 100644 --- a/src/ConditionItems/FormDataItem.php +++ b/src/ConditionItems/FormDataItem.php @@ -12,6 +12,7 @@ class FormDataItem extends ConditionDetailBase implements ConditionItemInterface { + // @phpstan-ignore-next-line public function getFilterOption() { return $this->getFilterOptionConditon(); diff --git a/src/ConditionItems/LoginUserColumnItem.php b/src/ConditionItems/LoginUserColumnItem.php index 675d7ca27..d05388953 100644 --- a/src/ConditionItems/LoginUserColumnItem.php +++ b/src/ConditionItems/LoginUserColumnItem.php @@ -31,6 +31,7 @@ public static function setWorkflowConditionQuery($query, $tableName, $custom_tab $workflow = Workflow::getWorkflowByTable($custom_table); if (!$workflow) { /** @var ExtendedBuilder $query */ + // @phpstan-ignore-next-line $query->whereNotMatch(); return; } @@ -48,6 +49,7 @@ public static function setWorkflowConditionQuery($query, $tableName, $custom_tab }); $orgids = \Exment::user()->base_user->belong_organizations->pluck('id')->toArray(); + // @phpstan-ignore-next-line $query->orWhere(function ($query) use ($orgids, $workflow, $workflow_actions) { foreach ($workflow_actions as $workflow_action) { foreach ($workflow_action->work_targets as $work_target_key => $work_target) { @@ -108,9 +110,11 @@ public static function setWorkflowConditionQuery($query, $tableName, $custom_tab public function hasAuthorityOld(WorkflowAuthorityInterface $workflow_authority, ?CustomValue $custom_value, $targetUser) { $custom_column = CustomColumn::find($workflow_authority->related_id); + // @phpstan-ignore-next-line if (!ColumnType::isUserOrganization($custom_column->column_type)) { return false; } + // @phpstan-ignore-next-line $auth_values = array_get($custom_value, 'value.' . $custom_column->column_name); if (is_null($auth_values)) { return false; @@ -119,6 +123,7 @@ public function hasAuthorityOld(WorkflowAuthorityInterface $workflow_authority, $auth_values = [$auth_values]; } + // @phpstan-ignore-next-line switch ($custom_column->column_type) { case ColumnType::USER: return in_array($targetUser->id, $auth_values); @@ -168,6 +173,7 @@ public function hasAuthority(WorkflowAuthorityInterface $workflow_authority, ?Cu * @param bool $asNextAction This action calls as next action. Actually, this is showing dialog. * @return array */ + // @phpstan-ignore-next-line public static function getTargetUserAndOrg(CustomValue $custom_value, WorkflowAction $workflow_action, $custom_column_id, bool $asNextAction = false): array { $workflow = $workflow_action->workflow_cache; diff --git a/src/ConditionItems/OrganizationItem.php b/src/ConditionItems/OrganizationItem.php index bf5b8a217..0f53da2e5 100644 --- a/src/ConditionItems/OrganizationItem.php +++ b/src/ConditionItems/OrganizationItem.php @@ -15,6 +15,7 @@ class OrganizationItem extends ConditionDetailBase implements ConditionItemInter { use UserOrganizationItemTrait; + // @phpstan-ignore-next-line public function getFilterOption() { return $this->getFilterOptionConditon(); @@ -86,6 +87,7 @@ public function hasAuthority(WorkflowAuthorityInterface $workflow_authority, ?Cu return in_array($workflow_authority->related_id, $ids); } + // @phpstan-ignore-next-line public static function setWorkflowConditionQuery($query, $tableName, $custom_table) { $ids = \Exment::user()->base_user->belong_organizations->pluck('id')->toArray(); diff --git a/src/ConditionItems/ParentIdItem.php b/src/ConditionItems/ParentIdItem.php index 76b567fad..6f1d8d2cb 100644 --- a/src/ConditionItems/ParentIdItem.php +++ b/src/ConditionItems/ParentIdItem.php @@ -16,6 +16,7 @@ class ParentIdItem extends SystemItem * @param CustomViewSort $custom_view_sort * @return void */ + // @phpstan-ignore-next-line public function setQuerySort($query, CustomViewSort $custom_view_sort) { $column_item = $custom_view_sort->column_item; @@ -58,6 +59,7 @@ public function getSelectColumnText($custom_view_column, Model\CustomTable $cust * * @return array offset 0 : column id, 1 : table id */ + // @phpstan-ignore-next-line public function getColumnAndTableId($column_name, $custom_table): array { $target_column_id = Define::CUSTOM_COLUMN_TYPE_PARENT_ID; diff --git a/src/ConditionItems/RoleGroupItem.php b/src/ConditionItems/RoleGroupItem.php index c1e55f5d5..c29371d5e 100644 --- a/src/ConditionItems/RoleGroupItem.php +++ b/src/ConditionItems/RoleGroupItem.php @@ -12,6 +12,7 @@ class RoleGroupItem extends ConditionDetailBase implements ConditionItemInterface { + // @phpstan-ignore-next-line public function getFilterOption() { return $this->getFilterOptionConditon(); @@ -43,7 +44,7 @@ public function isMatchCondition(Condition $condition, CustomValue $custom_value public function getText($key, $value, $showFilter = true) { $model = RoleGroup::find($value); - /** @phpstan-ignore-next-line Instanceof between Exceedone\Exment\Model\RoleGroup|null and Illuminate\Database\Eloquent\Collection will always evaluate to false. */ + // @phpstan-ignore-next-line if ($model instanceof Collection) { $result = $model->map(function ($row) { return $row->role_group_view_name; diff --git a/src/ConditionItems/SystemItem.php b/src/ConditionItems/SystemItem.php index 36f20cfc1..e64593158 100644 --- a/src/ConditionItems/SystemItem.php +++ b/src/ConditionItems/SystemItem.php @@ -55,6 +55,7 @@ public function hasAuthority(WorkflowAuthorityInterface $workflow_authority, ?Cu return $workflow_authority->related_id == WorkflowTargetSystem::CREATED_USER && $custom_value->created_user_id == $targetUser->id; } + // @phpstan-ignore-next-line public static function setWorkflowConditionQuery($query, $tableName, $custom_table) { $query->orWhere(function ($query) use ($tableName) { @@ -72,6 +73,7 @@ public static function setWorkflowConditionQuery($query, $tableName, $custom_tab * @param CustomViewSort $custom_view_sort * @return void */ + // @phpstan-ignore-next-line public function setQuerySort($query, CustomViewSort $custom_view_sort) { $column_item = $custom_view_sort->column_item; @@ -129,6 +131,7 @@ public function getColumnValueKey($column_type_target, $custom_column): ?string * * @return array offset 0 : column id, 1 : table id */ + // @phpstan-ignore-next-line public function getColumnAndTableId($column_name, $custom_table): array { $target_column_id = SystemColumn::getOption(['name' => $column_name])['id'] ?? null; diff --git a/src/ConditionItems/UserItem.php b/src/ConditionItems/UserItem.php index 0f61d41d3..f808a64ef 100644 --- a/src/ConditionItems/UserItem.php +++ b/src/ConditionItems/UserItem.php @@ -16,6 +16,7 @@ class UserItem extends ConditionDetailBase implements ConditionItemInterface { use UserOrganizationItemTrait; + // @phpstan-ignore-next-line public function getFilterOption() { return $this->getFilterOptionConditon(); @@ -85,6 +86,7 @@ public function hasAuthority(WorkflowAuthorityInterface $workflow_authority, ?Cu return $workflow_authority->related_id == $targetUser->id; } + // @phpstan-ignore-next-line public static function setWorkflowConditionQuery($query, $tableName, $custom_table) { $query->orWhere(function ($query) { diff --git a/src/ConditionItems/UserOrganizationItemTrait.php b/src/ConditionItems/UserOrganizationItemTrait.php index 1f5ddceb0..f5a1e8f3c 100644 --- a/src/ConditionItems/UserOrganizationItemTrait.php +++ b/src/ConditionItems/UserOrganizationItemTrait.php @@ -7,6 +7,7 @@ trait UserOrganizationItemTrait { + // @phpstan-ignore-next-line protected function getChangeFieldUserOrg(CustomTable $target_table, $key, $show_condition_key = true) { $field = new Field\MultipleSelect($this->elementName, [$this->label]); diff --git a/src/ConditionItems/WorkflowItem.php b/src/ConditionItems/WorkflowItem.php index deb961724..0f993533a 100644 --- a/src/ConditionItems/WorkflowItem.php +++ b/src/ConditionItems/WorkflowItem.php @@ -11,6 +11,7 @@ class WorkflowItem extends SystemItem implements ConditionItemInterface { + // @phpstan-ignore-next-line public function getFilterOption() { $target = explode('?', $this->target)[0]; diff --git a/src/Console/BackupCommand.php b/src/Console/BackupCommand.php index f97a15945..14482ec15 100644 --- a/src/Console/BackupCommand.php +++ b/src/Console/BackupCommand.php @@ -27,6 +27,9 @@ class BackupCommand extends Command */ protected $description = 'Backup database definition, table data, files in selected folder'; + /** + * @var \Exceedone\Exment\Services\BackupRestore\Backup + */ protected $backup; /** @@ -52,12 +55,12 @@ public function handle() { try { $target = $this->option("target") ?? BackupTarget::arrays(); - /** @phpstan-ignore-next-line Expression on left side of ?? is not nullable. */ + // @phpstan-ignore-next-line $schedule = boolval($this->option("schedule") ?? false); if (is_string($target)) { $target = collect(explode(",", $target))->map(function ($t) { - /** @phpstan-ignore-next-line Expression on left side of ?? is not nullable. */ + // @phpstan-ignore-next-line return new BackupTarget($t) ?? null; })->filter()->toArray(); } diff --git a/src/Console/BatchCommand.php b/src/Console/BatchCommand.php index 2e44eff64..07de19d00 100644 --- a/src/Console/BatchCommand.php +++ b/src/Console/BatchCommand.php @@ -48,6 +48,8 @@ public function handle(): int /** * Execute Plugin Batch + * + * @return int */ protected function pluginBatch() { @@ -77,6 +79,11 @@ protected function pluginBatch() return $result; } + /** + * Find plugin by id, name, or uuid + * + * @return \Exceedone\Exment\Model\Plugin|null + */ protected function findPlugin() { // Execute batch. *Batch can execute if active_flg is false, so get value directly. diff --git a/src/Console/BulkInsertCommand.php b/src/Console/BulkInsertCommand.php index e422fd27d..b2b1931f2 100644 --- a/src/Console/BulkInsertCommand.php +++ b/src/Console/BulkInsertCommand.php @@ -29,7 +29,7 @@ class BulkInsertCommand extends Command /** * full path stored bulk insert files. * - * @var string + * @var string|null */ protected $directory; @@ -93,6 +93,9 @@ public function handle() /** * convert all csv files in target folder into tsv files * + * @param \SplFileInfo $file + * @param bool $include_sub + * @return string */ private function convertFile($file, $include_sub = false) { @@ -117,6 +120,9 @@ private function convertFile($file, $include_sub = false) /** * convert csv files to tsv files * + * @param string $tempdir + * @param \SplFileInfo $file + * @return string */ private function convertTsv($tempdir, $file) { @@ -150,6 +156,7 @@ private function convertTsv($tempdir, $file) ); // get locale + // @phpstan-ignore-next-line $locales = explode('.', setlocale(LC_CTYPE, '0')); // set locale UTF-8 (if sjis) if (count($locales) >= 2 && $locales[1] == '932') { @@ -169,6 +176,7 @@ private function convertTsv($tempdir, $file) // write all column names $records = $columns; } else { + // @phpstan-ignore-next-line $records = $this->getTsvLine($columns, $header, $line); } @@ -182,6 +190,10 @@ private function convertTsv($tempdir, $file) /** * edit tsv line * + * @param array $columns + * @param array $header + * @param array $line + * @return array */ private function getTsvLine($columns, $header, $line) { @@ -202,15 +214,21 @@ private function getTsvLine($columns, $header, $line) /** * edit tsv data item * + * @param string $field + * @param array $header + * @param array $line + * @return mixed */ private function getTsvData($field, $header, $line) { // extract header item that matches the field name $keys = preg_grep('/^'.$field.'(\..+)?$/i', $header); + // @phpstan-ignore-next-line if (count($keys) == 0) { return null; } $ary = []; + // @phpstan-ignore-next-line foreach ($keys as $key => $value) { $data = array_key_exists($key, $line) ? $line[$key] : ''; $targets = explode('.', $value); @@ -228,6 +246,7 @@ private function getTsvData($field, $header, $line) * * @param string $file temporary file path stored work tsv files */ + // @phpstan-ignore-next-line private function importTsv($file) { $file = new \SplFileInfo($file); diff --git a/src/Console/CheckLangCommand.php b/src/Console/CheckLangCommand.php index cae8faeae..ad8ffdc8f 100644 --- a/src/Console/CheckLangCommand.php +++ b/src/Console/CheckLangCommand.php @@ -59,6 +59,14 @@ public function handle(): int return $hasError ? 1 : 0; } + /** + * Check translation recursively + * + * @param array $keys + * @param mixed $jat + * @param string $lang + * @return bool + */ protected function checkTrans(array $keys, $jat, $lang) { $hasError = false; diff --git a/src/Console/ClientListCommand.php b/src/Console/ClientListCommand.php index 919ac2f7f..a1d5f69a2 100644 --- a/src/Console/ClientListCommand.php +++ b/src/Console/ClientListCommand.php @@ -68,6 +68,9 @@ protected function showClients() /** * get client type string + * + * @param Client $client + * @return string|null */ protected function getClientType(Client $client) { diff --git a/src/Console/DocumentImportCommand.php b/src/Console/DocumentImportCommand.php index b87692941..6a891076f 100644 --- a/src/Console/DocumentImportCommand.php +++ b/src/Console/DocumentImportCommand.php @@ -21,9 +21,12 @@ class DocumentImportCommand extends FileColumnImportCommand */ protected $description = 'Document Import Exment data'; + // @phpstan-ignore-next-line protected static $actionClassName = DataImportExport\Actions\Import\DocumentAction::class; + // @phpstan-ignore-next-line protected static $directoryName = 'document-import'; + // @phpstan-ignore-next-line protected static $files_name = 'documents'; } diff --git a/src/Console/ExportChunkCommand.php b/src/Console/ExportChunkCommand.php index 10bed241a..2907cca0c 100644 --- a/src/Console/ExportChunkCommand.php +++ b/src/Console/ExportChunkCommand.php @@ -46,6 +46,7 @@ public function __construct() $this->initExmentCommand(); } + // @phpstan-ignore-next-line protected function getParameters() { /** @var null|string $table_name */ @@ -118,7 +119,7 @@ public function handle() $message = null; $executeCount = 0; - /** @phpstan-ignore-next-line Expression on left side of ?? is not nullable. */ + // @phpstan-ignore-next-line for ($i = $options['start'] ?? 1; $i <= $options['end'] ?? 1000; $i++) { $grid = new Grid(new $classname()); // set data get range @@ -127,7 +128,7 @@ public function handle() if (isset($options['view']) && $options['view'] instanceof CustomView) { $options['view']->filterSortModel($grid->model()); } - /* @phpstan-ignore-next-line str_pad expects string, int given */ + // @phpstan-ignore-next-line $seq = str_pad($i, $options['seqlength'], 0, STR_PAD_LEFT); $service = (new DataImportExport\DataImportExportService()) diff --git a/src/Console/ExportCommand.php b/src/Console/ExportCommand.php index 60b2e6689..df9e5650b 100644 --- a/src/Console/ExportCommand.php +++ b/src/Console/ExportCommand.php @@ -31,7 +31,7 @@ class ExportCommand extends Command /** * full path stored export files. * - * @var string + * @var string|null */ protected $dirpath; @@ -47,6 +47,11 @@ public function __construct() $this->initExmentCommand(); } + /** + * Get command parameters + * + * @return array{0: \Exceedone\Exment\Model\CustomTable, 1: array} + */ protected function getParameters() { /** @var null|string $table_name */ diff --git a/src/Console/ExportCommandTrait.php b/src/Console/ExportCommandTrait.php index b6b71070e..9e8d1ef33 100644 --- a/src/Console/ExportCommandTrait.php +++ b/src/Console/ExportCommandTrait.php @@ -9,6 +9,11 @@ trait ExportCommandTrait { + /** + * Get common parameters for export commands + * + * @return array + */ protected function getParametersCommon() { /** @var null|string $table_name */ @@ -77,7 +82,7 @@ protected function getParametersCommon() * * @param CustomTable $custom_table * @param \Encore\Admin\Grid $grid - * @param array $options + * @param array $options * @return \Exceedone\Exment\Services\DataImportExport\Actions\Export\ActionInterface */ protected function getExportAction(CustomTable $custom_table, $grid, array $options) diff --git a/src/Console/FileColumnImportCommand.php b/src/Console/FileColumnImportCommand.php index 8a1191391..d6c01b0a9 100644 --- a/src/Console/FileColumnImportCommand.php +++ b/src/Console/FileColumnImportCommand.php @@ -17,6 +17,9 @@ class FileColumnImportCommand extends Command */ protected $signature = 'exment:file-import {dir}'; + /** + * @var string|null + */ protected $directory; /** @@ -27,10 +30,13 @@ class FileColumnImportCommand extends Command protected $description = 'File Import Exment data'; + // @phpstan-ignore-next-line protected static $actionClassName = DataImportExport\Actions\Import\FileColumnAction::class; + // @phpstan-ignore-next-line protected static $directoryName = 'file-import'; + // @phpstan-ignore-next-line protected static $files_name = 'files'; /** diff --git a/src/Console/ImportCommand.php b/src/Console/ImportCommand.php index b211025fe..662834758 100644 --- a/src/Console/ImportCommand.php +++ b/src/Console/ImportCommand.php @@ -27,7 +27,7 @@ class ImportCommand extends Command /** * full path stored bulk insert files. * - * @var string + * @var string|null */ protected $directory; diff --git a/src/Console/ImportTrait.php b/src/Console/ImportTrait.php index 30e1bf31f..5ccbced75 100644 --- a/src/Console/ImportTrait.php +++ b/src/Console/ImportTrait.php @@ -10,6 +10,9 @@ trait ImportTrait /** * get file names in target folder (filter extension) * + * @param string $ext + * @param bool $include_sub + * @return array */ private function getFiles($ext = 'tsv', $include_sub = false) { diff --git a/src/Console/InstallUpdateTrait.php b/src/Console/InstallUpdateTrait.php index f33f5ed30..f6088526f 100644 --- a/src/Console/InstallUpdateTrait.php +++ b/src/Console/InstallUpdateTrait.php @@ -46,6 +46,7 @@ protected function createExmentBootstrapFile() $contents = $this->getExmentStub('bootstrap'); + // @phpstan-ignore-next-line $this->laravel['files']->put($file, $contents); $this->line('Bootstrap file was created: '.str_replace(base_path(), '', $file)); } @@ -59,6 +60,7 @@ protected function createExmentBootstrapFile() */ protected function getExmentStub($name) { + // @phpstan-ignore-next-line return $this->laravel['files']->get(path_join(__DIR__, "stubs", "$name.stub")); } @@ -67,6 +69,7 @@ protected function getExmentStub($name) * * @param string $path */ + // @phpstan-ignore-next-line protected function makeExmentDir($path = '') { $dirpath = $this->directory; @@ -75,6 +78,7 @@ protected function makeExmentDir($path = '') return; } + // @phpstan-ignore-next-line $this->laravel['files']->makeDirectory($dirpath, 0755, true, true); } } diff --git a/src/Console/NotifyScheduleTrait.php b/src/Console/NotifyScheduleTrait.php index ff8a780f8..73d4de921 100644 --- a/src/Console/NotifyScheduleTrait.php +++ b/src/Console/NotifyScheduleTrait.php @@ -11,6 +11,7 @@ trait NotifyScheduleTrait /** * notify user flow */ + // @phpstan-ignore-next-line protected function notify() { // get notifies data for notify_trigger is 1(time), and notify_hour is executed time diff --git a/src/Console/PatchDataCommand.php b/src/Console/PatchDataCommand.php index dfad4c121..b78b4de0d 100644 --- a/src/Console/PatchDataCommand.php +++ b/src/Console/PatchDataCommand.php @@ -249,6 +249,7 @@ public function handle() /** * patch mail template * + * @param array $mail_key_names * @return void */ protected function patchMailTemplate($mail_key_names = []) @@ -524,6 +525,7 @@ protected function reAlterIndexAll() $this->reAlterIndex($index_custom_columns); } + // @phpstan-ignore-next-line protected function reAlterIndex($index_custom_columns) { foreach ($index_custom_columns as $index_custom_column) { @@ -632,6 +634,7 @@ protected function patchSystemFlgColumn() $json = json_decode_ex(\File::get($configPath), true); // re-loop columns. because we have to get other column id -------------------------------------------------- + // @phpstan-ignore-next-line foreach (array_get($json, "custom_tables", []) as $table) { // find tables. -------------------------------------------------- $obj_table = CustomTable::getEloquent(array_get($table, 'table_name')); @@ -752,6 +755,7 @@ protected function copyViewColumnAllDataView() + // @phpstan-ignore-next-line protected function patchSystemAuthoritable() { if (!\Schema::hasTable('system_authoritable')) { @@ -788,6 +792,7 @@ protected function patchSystemAuthoritable() System::system_admin_users(array_unique($system_admin_users)); } + // @phpstan-ignore-next-line protected function patchValueAuthoritable() { if (!\Schema::hasTable('roles') || !\Schema::hasTable('value_authoritable') || !\Schema::hasTable(CustomValueAuthoritable::getTableName())) { @@ -805,6 +810,7 @@ protected function patchValueAuthoritable() foreach ($valueRoles as $valueRole) { $val = (array)$valueRole; $permissions = json_decode_ex($val['permissions'], true); + // @phpstan-ignore-next-line if (array_has($permissions, 'custom_value_edit')) { $editRoles[] = $val['id']; } else { @@ -888,6 +894,7 @@ protected function initOnlyCodeColumn() * * @return void */ + // @phpstan-ignore-next-line protected function removeDeletedTableNotify($mail_key_names = []) { // get custom table id @@ -920,6 +927,7 @@ protected function movePluginFolder() * * @return void */ + // @phpstan-ignore-next-line protected function moveAppToStorageFolder($pathName, $diskName) { // get app/$pathName folder @@ -1004,6 +1012,7 @@ protected function patchParentOrg() $parent_organization->save(); } + // @phpstan-ignore-next-line protected function removeDeletedColumn() { $classes = [ @@ -1020,6 +1029,7 @@ protected function removeDeletedColumn() * @var Model\CustomViewColumn|Model\CustomViewSort|Model\CustomViewFilter|Model\CustomViewSummary|Model\CustomOperationColumn|Model\Condition|Model\CustomFormColumn $class * @var array $val */ + // @phpstan-ignore-next-line foreach ($classes as $class => $val) { $items = $class::where($val['type'], $val['whereval']) ->get(); @@ -1437,6 +1447,7 @@ protected function patchViewFilterSuuid() * * @return void */ + // @phpstan-ignore-next-line protected function patchViewSuuid(array $classes) { if (!canConnection() || !hasTable('custom_view_columns')) { @@ -1545,6 +1556,7 @@ protected function patchViewOnly() } + // @phpstan-ignore-next-line protected function updateNotifyDifinition() { Model\Notify::get() @@ -1683,6 +1695,7 @@ protected function updateCalcFormula() }); } + // @phpstan-ignore-next-line protected function patchFormColumnRowNo() { $columns = CustomFormColumn::all(); @@ -1840,7 +1853,7 @@ protected function deleteJunkFile() Model\File::where('parent_type', $custom_table->table_name) ->chunk(1000, function ($files) use ($custom_table) { foreach ($files as $file) { - /** @phpstan-ignore-next-line not found withTrashed method */ + // @phpstan-ignore-next-line $exists = $custom_table->getValueModel()->query() ->where('id', $file->parent_id) ->withoutGlobalScopes() @@ -1929,6 +1942,7 @@ protected function appendColumnMailCustomAttachments() $this->appendCustomColumn('mail_template', 'custom_attachments'); } + // @phpstan-ignore-next-line public function notifyTargetId() { Model\Notify::get() @@ -2123,17 +2137,17 @@ protected function patchNotifyTime() } // Set view pivot info - /** @phpstan-ignore-next-line maybe $notify not implement setOption method */ + // @phpstan-ignore-next-line $notify->setOption('view_pivot_table_id', $custom_table_id); // If select table, set pivot column info if (isMatchString($relation_table->searchType, Enums\SearchType::SELECT_TABLE)) { - /** @phpstan-ignore-next-line maybe $notify not implement setOption method */ + // @phpstan-ignore-next-line $notify->setOption('view_pivot_column_id', $relation_table->selectTablePivotColumn->id); } // relation, set "parent_id". else { - /** @phpstan-ignore-next-line maybe $notify not implement setOption method */ + // @phpstan-ignore-next-line $notify->setOption('view_pivot_column_id', Define::PARENT_ID_NAME); } $notify->save(); diff --git a/src/Console/ResetPasswordCommand.php b/src/Console/ResetPasswordCommand.php index 66d275140..51eed316e 100644 --- a/src/Console/ResetPasswordCommand.php +++ b/src/Console/ResetPasswordCommand.php @@ -38,6 +38,7 @@ public function __construct() $this->initExmentCommand(); } + // @phpstan-ignore-next-line protected function getParameters() { $options = []; diff --git a/src/Console/RestoreCommand.php b/src/Console/RestoreCommand.php index 82d226317..3c0b19d58 100644 --- a/src/Console/RestoreCommand.php +++ b/src/Console/RestoreCommand.php @@ -26,6 +26,7 @@ class RestoreCommand extends Command */ protected $description = 'Restore database definition, table data, files in selected folder'; + // @phpstan-ignore-next-line protected $restore; /** @@ -73,6 +74,7 @@ public function handle() return 0; } + // @phpstan-ignore-next-line protected function getFile() { $file = $this->argument("file"); diff --git a/src/Console/ScheduleCommand.php b/src/Console/ScheduleCommand.php index b550a859e..648ba4c52 100644 --- a/src/Console/ScheduleCommand.php +++ b/src/Console/ScheduleCommand.php @@ -52,6 +52,7 @@ public function handle() return 0; } + // @phpstan-ignore-next-line protected function backup() { if (!boolval(System::backup_enable_automatic())) { @@ -72,6 +73,7 @@ protected function backup() $term = System::backup_automatic_term(); // set date as minute and second is 0 $last_executed = Carbon::create($last_executed->year, $last_executed->month, $last_executed->day + $term, $last_executed->hour, 0, 0); + // @phpstan-ignore-next-line if ($last_executed->gt($nowHour)) { return; } @@ -99,6 +101,7 @@ protected function pluginBatch() } + // @phpstan-ignore-next-line protected function debugLog(string $log) { if (!boolval(config('exment.debugmode_schedule', false))) { diff --git a/src/Console/SetupDirCommand.php b/src/Console/SetupDirCommand.php index 4f2d743e8..357a14745 100644 --- a/src/Console/SetupDirCommand.php +++ b/src/Console/SetupDirCommand.php @@ -74,6 +74,7 @@ public function handle() } + // @phpstan-ignore-next-line protected function getGroup() { $group = $this->option('group'); @@ -81,6 +82,7 @@ protected function getGroup() // get current group $current_group = null; if (function_exists('posix_getgrgid')) { + // @phpstan-ignore-next-line $current_group = array_get(posix_getgrgid(filegroup(base_path(path_join('public', 'index.php')))), 'name'); } diff --git a/src/Controllers/AdminControllerBase.php b/src/Controllers/AdminControllerBase.php index 45f975e0e..8574b720d 100644 --- a/src/Controllers/AdminControllerBase.php +++ b/src/Controllers/AdminControllerBase.php @@ -31,8 +31,8 @@ public function index(Request $request, Content $content) * * @param Request $request * @param Content $content - * @param $id - * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * @param mixed $id + * @return Content|\Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function show(Request $request, Content $content, $id) { diff --git a/src/Controllers/AdminControllerTableBase.php b/src/Controllers/AdminControllerTableBase.php index 82563c526..bdce84f4b 100644 --- a/src/Controllers/AdminControllerTableBase.php +++ b/src/Controllers/AdminControllerTableBase.php @@ -19,16 +19,32 @@ abstract class AdminControllerTableBase extends Controller { use ExmentControllerTrait; + /** + * @var CustomTable|null + */ protected $custom_table; + + /** + * @var \Illuminate\Database\Eloquent\Collection|null + */ + // @phpstan-ignore-next-line protected $custom_columns; + + /** + * @var mixed + */ protected $custom_view; + + /** + * @var mixed + */ protected $custom_form; /** * @param CustomTable|null $custom_table * @param Request $request - * @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line public function __construct(?CustomTable $custom_table, Request $request) { $this->custom_table = $custom_table; @@ -47,7 +63,7 @@ public function __construct(?CustomTable $custom_table, Request $request) * Execute an action on the controller. * * @param string $method - * @param array $parameters + * @param array $parameters * @return \Symfony\Component\HttpFoundation\Response */ public function callAction($method, $parameters) @@ -59,6 +75,11 @@ public function callAction($method, $parameters) return $this->{$method}(...array_values($parameters)); } + /** + * @param mixed $column + * @param mixed $columnType + * @return bool + */ protected function validateEditColumnType($column, $columnType) { if (is_null($columnType) || $columnType !== $column->column_type) { @@ -73,6 +94,11 @@ protected function validateEditColumnType($column, $columnType) * ex. check /admin/column/user/1/edit * whether "1" is user's column * $isValue: whether + * + * @param string $className + * @param mixed $id + * @param mixed $endpoint + * @return bool */ protected function validateTableAndId($className, $id, $endpoint) { @@ -130,9 +156,9 @@ public function index(Request $request, Content $content) * * @param Request $request * @param Content $content - * @param $tableKey - * @param $id - * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * @param mixed $tableKey + * @param mixed $id + * @return Content|\Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function show(Request $request, Content $content, $tableKey, $id) { @@ -148,8 +174,10 @@ public function show(Request $request, Content $content, $tableKey, $id) /** * Edit interface. * - * @param mixed $id + * @param Request $request * @param Content $content + * @param mixed $tableKey + * @param mixed $id * @return Content */ public function edit(Request $request, Content $content, $tableKey, $id) @@ -160,6 +188,7 @@ public function edit(Request $request, Content $content, $tableKey, $id) /** * Create interface. * + * @param Request $request * @param Content $content * @return Content */ diff --git a/src/Controllers/ApiController.php b/src/Controllers/ApiController.php index d39229e18..f4e0d536f 100644 --- a/src/Controllers/ApiController.php +++ b/src/Controllers/ApiController.php @@ -32,6 +32,9 @@ class ApiController extends AdminControllerBase /** * get Exment version + * + * @param Request $request + * @return \Illuminate\Http\JsonResponse */ public function version(Request $request) { @@ -41,7 +44,7 @@ public function version(Request $request) /** * get login user info * @param Request $request - * @return array|null + * @return array|null */ public function me(Request $request) { @@ -151,6 +154,9 @@ public function indexcolumns(Request $request) /** * get column list + * + * @param Request $request + * @param bool $onlyIndex * @return mixed */ protected function _getcolumns(Request $request, $onlyIndex = true) @@ -238,6 +244,7 @@ public function table($tableKey, Request $request) */ public function column($id, Request $request) { + // @phpstan-ignore-next-line return $this->responseColumn($request, CustomColumn::find($id)); } @@ -267,6 +274,7 @@ public function view(Request $request, $idOrSuuid) * 3. get columns that belongs to target table * @param mixed $id select_table custon_column id */ + // @phpstan-ignore-next-line public function targetBelongsColumns($id) { if (!isset($id)) { @@ -296,6 +304,7 @@ public function targetBelongsColumns($id) /** * get auth logs */ + // @phpstan-ignore-next-line public function authLogs(Request $request) { $login_user = \Exment::user(); @@ -346,7 +355,7 @@ public function authLogs(Request $request) $query->orderBy('created_at', 'desc'); $paginator = $query->paginate($count); - /** @phpstan-ignore-next-line need Class Reflection Extension */ + // @phpstan-ignore-next-line $paginator->appends($request->all([ 'login_user_id', 'base_user_id', @@ -364,6 +373,7 @@ public function authLogs(Request $request) /** * get auth log */ + // @phpstan-ignore-next-line public function authLog(Request $request, $id) { $login_user = \Exment::user(); @@ -385,6 +395,7 @@ public function authLog(Request $request, $id) /** * create notify */ + // @phpstan-ignore-next-line public function notifyCreate(Request $request) { $is_single = false; @@ -483,6 +494,7 @@ public function notifyList(Request $request) * @param Request $request * @return array */ + // @phpstan-ignore-next-line public function notifyPage(Request $request) { // get notify NotifyNavbar list diff --git a/src/Controllers/ApiDataController.php b/src/Controllers/ApiDataController.php index 1fa4eab62..212dec457 100644 --- a/src/Controllers/ApiDataController.php +++ b/src/Controllers/ApiDataController.php @@ -39,6 +39,7 @@ class ApiDataController extends AdminControllerTableBase * @param array $parameters * @return \Symfony\Component\HttpFoundation\Response */ + // @phpstan-ignore-next-line public function callAction($method, $parameters) { if (!$this->custom_table) { @@ -57,6 +58,7 @@ public function callAction($method, $parameters) public function dataList(Request $request) { if (($code = $this->custom_table->enableAccess()) !== true) { + // @phpstan-ignore-next-line return abortJson(403, $code); } @@ -82,6 +84,7 @@ public function dataList(Request $request) $this->setQueryInfo($model); // set order by + // @phpstan-ignore-next-line $this->setOrderByQuery($model, $orderby_list); $paginator = $model->paginate($count); @@ -132,6 +135,7 @@ public function dataQuery(Request $request) public function dataQueryColumn(Request $request, $tableKey) { if (($code = $this->custom_table->enableAccess()) !== true) { + // @phpstan-ignore-next-line return abortJson(403, $code); } @@ -166,6 +170,7 @@ public function dataQueryColumn(Request $request, $tableKey) if (($orderby_list = $this->getOrderBy($request)) instanceof Response) { return $orderby_list; } + // @phpstan-ignore-next-line $this->setOrderByQuery($model, $orderby_list); $paginator = $model->paginate($count); @@ -185,6 +190,7 @@ public function dataQueryColumn(Request $request, $tableKey) * @param array $params * @return Response|boolean */ + // @phpstan-ignore-next-line protected function setParamsQueryColumn(Request $request, $query, $params) { if (empty($params)) { @@ -194,8 +200,10 @@ protected function setParamsQueryColumn(Request $request, $query, $params) $paramInfos = []; foreach ($params as $param) { $values = preg_split("/\s+/", trim($param), 3); + // @phpstan-ignore-next-line $column_name = $values[0]; + // @phpstan-ignore-next-line if (count($values) < 3 || !preg_match('/^eq|ne|gt|gte|lt|lte|like$/i', $values[1])) { return abortJson(400, ErrorCode::INVALID_PARAMS()); } @@ -211,6 +219,7 @@ protected function setParamsQueryColumn(Request $request, $query, $params) } $operator = '='; + // @phpstan-ignore-next-line switch ($values[1]) { case 'gt': $operator = '>'; @@ -231,6 +240,7 @@ protected function setParamsQueryColumn(Request $request, $query, $params) $operator = 'LIKE'; break; } + // @phpstan-ignore-next-line $paramInfos[] = [$column_name, $operator, $values[2]]; } @@ -250,6 +260,7 @@ protected function setParamsQueryColumn(Request $request, $query, $params) * @param mixed $id * @return mixed */ + // @phpstan-ignore-next-line public function dataFind(Request $request, $tableKey, $id) { return $this->_dataFind($request, $id); @@ -272,6 +283,7 @@ public function dataCreate(Request $request) * update data * @return mixed */ + // @phpstan-ignore-next-line public function dataUpdate(Request $request, $tableKey, $id) { if (!$this->custom_table->hasPermission(Permission::AVAILABLE_EDIT_CUSTOM_VALUE)) { @@ -283,6 +295,7 @@ public function dataUpdate(Request $request, $tableKey, $id) } if (($code = $custom_value->enableEdit()) !== true) { + // @phpstan-ignore-next-line return abortJson(403, $code); } @@ -294,6 +307,7 @@ public function dataUpdate(Request $request, $tableKey, $id) * delete data * @return mixed */ + // @phpstan-ignore-next-line public function dataDelete(Request $request, $tableKey, $id) { if (!$this->custom_table->hasPermission(Permission::AVAILABLE_EDIT_CUSTOM_VALUE)) { @@ -315,6 +329,7 @@ public function dataDelete(Request $request, $tableKey, $id) return $custom_value; } if (($code = $custom_value->enableDelete()) !== true) { + // @phpstan-ignore-next-line return abortJson(403, $code()); } if ($res = $this->custom_table->validateValueDestroy($i)) { @@ -363,6 +378,7 @@ public function dataDelete(Request $request, $tableKey, $id) * list all data * @return mixed */ + // @phpstan-ignore-next-line public function viewDataList(Request $request, $tableKey, $viewid) { $init = $this->viewDataInit($request, $viewid, true); @@ -400,6 +416,7 @@ public function viewDataList(Request $request, $tableKey, $viewid) * list view data * @return mixed */ + // @phpstan-ignore-next-line public function viewDataFind(Request $request, $tableKey, $viewid, $id) { $init = $this->viewDataInit($request, $viewid, false); @@ -441,6 +458,7 @@ public function viewDataFind(Request $request, $tableKey, $viewid, $id) * @param boolean $isList * @return Response|array if error, return response. or not, return list($custom_view, $valuetype, $count) */ + // @phpstan-ignore-next-line protected function viewDataInit(Request $request, $viewid, bool $isList) { // get view @@ -461,6 +479,7 @@ protected function viewDataInit(Request $request, $viewid, bool $isList) } if (($code = $this->custom_table->enableAccess()) !== true) { + // @phpstan-ignore-next-line return abortJson(403, trans('admin.deny'), $code); } @@ -478,6 +497,7 @@ protected function viewDataInit(Request $request, $viewid, bool $isList) return [$custom_view, $valuetype, $count]; } + // @phpstan-ignore-next-line protected function viewDataAfter($custom_view, $valuetype, $target) { list($headers, $bodies, $columnStyles, $columnClasses, $columnItems) = @@ -508,9 +528,11 @@ protected function viewDataAfter($custom_view, $valuetype, $target) * @param $id * @return \Exceedone\Exment\Model\CustomValue|\Illuminate\Config\Repository|\Illuminate\Contracts\Foundation\Application|\Illuminate\Database\Eloquent\Collection|\Illuminate\Pagination\AbstractPaginator|mixed|Response|null */ + // @phpstan-ignore-next-line public function getDocuments(Request $request, $tableKey, $id) { if (($code = $this->custom_table->enableAccess()) !== true) { + // @phpstan-ignore-next-line return abortJson(403, trans('admin.deny'), $code); } @@ -519,6 +541,7 @@ public function getDocuments(Request $request, $tableKey, $id) } if (($code = $custom_value->enableAccess()) !== true) { + // @phpstan-ignore-next-line return abortJson(403, trans('admin.deny'), $code); } @@ -532,10 +555,12 @@ public function getDocuments(Request $request, $tableKey, $id) 'paginate' => true, ]); + // @phpstan-ignore-next-line $documents->appends([ 'count' => $count ]); + // @phpstan-ignore-next-line $documents->getCollection()->transform(function ($document) { return $this->getDocumentArray($document); }); @@ -551,6 +576,7 @@ public function getDocuments(Request $request, $tableKey, $id) * @param $id * @return \Exceedone\Exment\Model\CustomValue|\Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response|Response */ + // @phpstan-ignore-next-line public function createDocument(Request $request, $tableKey, $id) { if (!$this->custom_table->hasPermission(Permission::AVAILABLE_EDIT_CUSTOM_VALUE)) { @@ -562,6 +588,7 @@ public function createDocument(Request $request, $tableKey, $id) } if (($code = $custom_value->enableEdit()) !== true) { + // @phpstan-ignore-next-line return abortJson(403, $code); } @@ -594,6 +621,7 @@ public function createDocument(Request $request, $tableKey, $id) * *search_type(required) : 1:n, n:n or select_table. * *q(required) : id that user selected. */ + // @phpstan-ignore-next-line public function relatedLinkage(Request $request) { return $this->_relatedLinkage($request); @@ -609,9 +637,11 @@ public function relatedLinkage(Request $request) */ public function columnData(Request $request, $tableKey, $column_name) { + // @phpstan-ignore-next-line return $this->_columnData($request, $column_name); } + // @phpstan-ignore-next-line protected function saveData($request, $custom_value = null) { $validator = Validator::make($request->all(), [ @@ -729,6 +759,7 @@ protected function saveData($request, $custom_value = null) * * @return array */ + // @phpstan-ignore-next-line protected function getRootValuesFromPost(Request $request, &$is_single) { $rootValues = []; @@ -777,6 +808,7 @@ protected function getRootValuesFromPost(Request $request, &$is_single) return $rootValues; } + // @phpstan-ignore-next-line protected function convertFindKeys(&$rootValues, $request) { if (is_null($findKeys = $request->get('findKeys'))) { @@ -811,6 +843,7 @@ protected function convertFindKeys(&$rootValues, $request) public function calendarList(Request $request) { if (($code = $this->custom_table->enableAccess()) !== true) { + // @phpstan-ignore-next-line return abortJson(403, $code); } @@ -896,6 +929,7 @@ public function calendarList(Request $request) * @return mixed * @throws \Exception */ + // @phpstan-ignore-next-line protected function getCalendarQuery($model, $start, $end, $target_start_column, $target_end_column) { $db_table_name = getDBTableName($this->custom_table); @@ -953,6 +987,7 @@ protected function getCalendarQuery($model, $start, $end, $target_start_column, * @param mixed $row * @return void */ + // @phpstan-ignore-next-line protected function setCalendarDate(&$task, $row, $target_start_column, $target_end_column) { $dt = $row->{$target_start_column}; @@ -990,6 +1025,7 @@ protected function setCalendarDate(&$task, $row, $target_start_column, $target_e * @param array $value input value * @return array Value after converting base64 encode file, and files value */ + // @phpstan-ignore-next-line protected function convertFileData($value) { // get file columns @@ -1017,6 +1053,7 @@ protected function convertFileData($value) } + // @phpstan-ignore-next-line protected function getFileValue(CustomColumn $file_column, $file_value): ?array { // whether is_vector, set as array @@ -1059,6 +1096,7 @@ protected function getFileValue(CustomColumn $file_column, $file_value): ?array * @param array $originalValue * @return void */ + // @phpstan-ignore-next-line protected function saveFile($custom_table, $files, &$value, $originalValue) { foreach ($files as $column_name => $fileInfos) { @@ -1094,6 +1132,7 @@ protected function saveFile($custom_table, $files, &$value, $originalValue) } + // @phpstan-ignore-next-line protected function getDocumentArray($document) { return [ @@ -1111,6 +1150,7 @@ protected function getDocumentArray($document) * @param Request $request * @return array|Response offset 0 : target column name, 1 : 'asc' or 'desc' */ + // @phpstan-ignore-next-line protected function getOrderBy(Request $request) { if (!$request->has('orderby')) { @@ -1123,7 +1163,9 @@ protected function getOrderBy(Request $request) foreach ($params as $param) { $values = preg_split("/\s+/", trim($param)); + // @phpstan-ignore-next-line $column_name = $values[0]; + // @phpstan-ignore-next-line if (count($values) > 1 && !preg_match('/^asc|desc$/i', $values[1])) { return abortJson(400, ErrorCode::INVALID_PARAMS()); } @@ -1137,6 +1179,7 @@ protected function getOrderBy(Request $request) } $column_name = $column->getIndexColumnName(); } + // @phpstan-ignore-next-line $orderby_list[] = [$column_name, count($values) > 1 ? $values[1] : 'asc']; } @@ -1150,6 +1193,7 @@ protected function getOrderBy(Request $request) * @param array $orderby_list * @return void */ + // @phpstan-ignore-next-line protected function setOrderByQuery($query, $orderby_list) { if (empty($orderby_list)) { @@ -1162,10 +1206,12 @@ protected function setOrderByQuery($query, $orderby_list) if ($item[0] == 'id') { $hasId = true; } + // @phpstan-ignore-next-line $query->orderBy($item[0], $item[1]); } if (!$hasId) { + // @phpstan-ignore-next-line $query->orderBy('id'); } } diff --git a/src/Controllers/ApiDataTrait.php b/src/Controllers/ApiDataTrait.php index dbdf0f140..ad116deca 100644 --- a/src/Controllers/ApiDataTrait.php +++ b/src/Controllers/ApiDataTrait.php @@ -36,6 +36,7 @@ trait ApiDataTrait protected function _dataFind(Request $request, $id) { if (($code = $this->custom_table->enableAccess()) !== true) { + /** @phpstan-ignore-next-line */ return abortJson(403, trans('admin.deny'), $code); } @@ -44,22 +45,28 @@ protected function _dataFind(Request $request, $id) // set query $this->setQueryInfo($query); + /** @phpstan-ignore-next-line */ $model = $query->where('id', $id)->first(); // not contains data, return empty data. if (!isset($model)) { $code = $this->custom_table->getNoDataErrorCode($id); if ($code == ErrorCode::PERMISSION_DENY) { + /** @phpstan-ignore-next-line */ return abortJson(403, $code); } else { // nodata + /** @phpstan-ignore-next-line */ return abortJson(400, $code); } } + // @phpstan-ignore-next-line if (($code = $model->enableAccess()) !== true) { + /** @phpstan-ignore-next-line */ return abortJson(403, trans('admin.deny'), $code); } + /** @phpstan-ignore-next-line */ return $this->modifyAfterGetValue($request, $model); } @@ -73,18 +80,22 @@ protected function _dataFind(Request $request, $id) protected function _columnData(Request $request, $column_name) { if (($code = $this->custom_table->enableAccess()) !== true) { + /** @phpstan-ignore-next-line */ return abortJson(403, $code); } $query = $request->get('query'); + /** @phpstan-ignore-next-line */ $custom_column = CustomColumn::getEloquent($column_name, $this->custom_table->table_name); $list = []; + /** @phpstan-ignore-next-line */ if ($custom_column->index_enabled) { $column_name = $custom_column->getIndexColumnName(); $list = $this->custom_table->searchValue($query, [ 'searchColumns' => collect([$column_name]), + /** @phpstan-ignore-next-line */ ])->pluck($column_name)->unique()->toArray(); } return json_encode($list); @@ -110,6 +121,7 @@ protected function _dataSelect(Request $request) $paginator->getCollection()->transform(function ($value) { return [ 'id' => $value->id, + /** @phpstan-ignore-next-line */ 'text' => $value->label, ]; }); @@ -126,9 +138,11 @@ protected function _dataSelect(Request $request) * *search_type(required) : 1:n, n:n or select_table. * *q(required) : id that user selected. */ + // @phpstan-ignore-next-line protected function _relatedLinkage(Request $request) { if (($code = $this->custom_table->enableAccess()) !== true) { + /** @phpstan-ignore-next-line */ return abortJson(403, $code); } @@ -158,12 +172,14 @@ protected function _relatedLinkage(Request $request) 'maxCount' => null, 'getLabel' => true, 'searchColumns' => $searchColumns ?? null, + /** @phpstan-ignore-next-line */ 'target_view' => CustomView::getEloquent($child_column->getOption('select_target_view')), 'display_table' => $request->get('display_table_id'), 'all' => $child_column->isGetAllUserOrganization(), ]; $datalist = $this->custom_table->searchRelationValue($searchType, $q, $child_select_table, $options); return collect($datalist)->map(function ($data) { + /** @phpstan-ignore-next-line */ return ['id' => $data->id, 'text' => $data->label]; }); } @@ -175,6 +191,7 @@ protected function _relatedLinkage(Request $request) * @param $options * @return array|CustomValue|\Illuminate\Pagination\LengthAwarePaginator|mixed|void */ + // @phpstan-ignore-next-line protected function modifyAfterGetValue(Request $request, $target, $options = []) { $options = array_merge( @@ -226,6 +243,7 @@ protected function modifyAfterGetValue(Request $request, $target, $options = []) } // set appends + /** @phpstan-ignore-next-line */ if (!is_nullorempty($appends)) { $target->appends($appends); } @@ -234,11 +252,15 @@ protected function modifyAfterGetValue(Request $request, $target, $options = []) } // as single model elseif ($target instanceof CustomValue) { + /** @phpstan-ignore-next-line */ $editor_cols = CustomColumn::where('custom_table_id', $this->custom_table->id)->where('column_type', ColumnType::EDITOR)->get(); foreach($editor_cols as $col) { + /** @phpstan-ignore-next-line */ $val = $target->getValue($col->column_name); + /** @phpstan-ignore-next-line */ $target->setValue($col->column_name, Editor::replaceImgUrl($val, ['dirName' => true])); } + /** @phpstan-ignore-next-line */ if (boolval($options['makeHidden'])) { $target = $target->makeHidden($this->custom_table->getMakeHiddenArray()); return $this->modifyCustomValue($request, $target); @@ -265,6 +287,7 @@ protected function modifyCustomValue(Request $request, $custom_value, $recursive } // Change relation key name + /** @phpstan-ignore-next-line */ if (!$recursive && $request->has('children') && boolval($request->get('children'))) { $custom_value = $this->modifyChildrenValue($request, $custom_value); } @@ -280,6 +303,7 @@ protected function modifyCustomValue(Request $request, $custom_value, $recursive $custom_value->setValueDirectly($custom_value->getValues(ValueType::getEnum($valuetype), ['asApi' => true])); } + /** @phpstan-ignore-next-line */ if ($request->has('dot') && boolval($request->get('dot'))) { $custom_value = array_dot($custom_value->toArray()); } @@ -295,9 +319,11 @@ protected function modifyCustomValue(Request $request, $custom_value, $recursive protected function isAppendLabel(Request $request) { if ($request->has('label')) { + /** @phpstan-ignore-next-line */ return boolval($request->get('label', false)); } + /** @phpstan-ignore-next-line */ if (boolval(config('exment.api_append_label', false))) { return true; } @@ -306,16 +332,20 @@ protected function isAppendLabel(Request $request) } + // @phpstan-ignore-next-line protected function executeQuery(Request $request, $count = null) { if (($code = $this->custom_table->enableAccess()) !== true) { + /** @phpstan-ignore-next-line */ return abortJson(403, $code); } + /** @phpstan-ignore-next-line */ $validator = Validator::make($request->all(), [ 'q' => 'required', ]); if ($validator->fails()) { + /** @phpstan-ignore-next-line */ return abortJson(400, [ 'errors' => $this->getErrorMessages($validator) ], ErrorCode::VALIDATION_ERROR()); @@ -342,6 +372,7 @@ protected function executeQuery(Request $request, $count = null) ///// If set linkage, filter relation. // get children table id $relationColumn = null; + /** @phpstan-ignore-next-line */ if (array_key_value_exists('linkage_column_id', $expand)) { $linkage_column_id = array_get($expand, 'linkage_column_id'); $linkage_column = CustomColumn::getEloquent($linkage_column_id); @@ -365,9 +396,11 @@ protected function executeQuery(Request $request, $count = null) 'relationColumnValue' => $linkage_value_id ?? null, 'display_table' => $request->get('display_table_id'), 'all' => $column ? $column->isGetAllUserOrganization() : false, + /** @phpstan-ignore-next-line */ 'withChildren' => boolval($request->get('children')) ? CustomRelation::getRelationsByParent($this->custom_table) : null, ]); + /** @phpstan-ignore-next-line */ return $this->modifyAfterGetValue($request, $paginator, [ 'appends' => [ 'q' => $q, @@ -387,6 +420,7 @@ protected function executeQuery(Request $request, $count = null) protected function setQueryInfo($query) { $request = request(); + /** @phpstan-ignore-next-line */ if ($request->has('children') && boolval($request->get('children'))) { $relations = CustomRelation::getRelationsByParent($this->custom_table); foreach ($relations as $relation) { @@ -409,6 +443,7 @@ protected function setQueryInfo($query) * @param Request $request * @return CustomValue $custom_value */ + // @phpstan-ignore-next-line protected function modifyChildrenValue(Request $request, $custom_value) { $relations = CustomRelation::getRelationsByParent($this->custom_table); @@ -428,6 +463,7 @@ protected function modifyChildrenValue(Request $request, $custom_value) return $relationValue; }); // Set key name + /** @phpstan-ignore-next-line */ $results[$relation->child_custom_table_cache->table_name] = $relationValues; unset($custom_value[$reltionName]); } @@ -443,6 +479,7 @@ protected function modifyChildrenValue(Request $request, $custom_value) * @param Request $request * @return CustomValue $custom_value */ + // @phpstan-ignore-next-line protected function modifyParentsValue(Request $request, $custom_value) { $relations = CustomRelation::getRelationsByChild($this->custom_table); diff --git a/src/Controllers/ApiSettingController.php b/src/Controllers/ApiSettingController.php index 58bfe3b25..d428233a3 100644 --- a/src/Controllers/ApiSettingController.php +++ b/src/Controllers/ApiSettingController.php @@ -76,6 +76,7 @@ protected function grid() * @param $id * @return Form|false */ + // @phpstan-ignore-next-line protected function form($id = null) { $form = new Form(new ApiClient()); @@ -102,6 +103,7 @@ protected function form($id = null) ///// toggle showing redirect // if create or password + // @phpstan-ignore-next-line if (!isset($client) || $client->client_type == ApiClientType::CLIENT_CREDENTIALS) { $form->url('redirect', exmtrans('api.redirect')) ->required() @@ -115,7 +117,9 @@ protected function form($id = null) ->attribute(['copyScript' => 1]) ->help(exmtrans('api.help.client_secret')); + // @phpstan-ignore-next-line if ($client->client_type == ApiClientType::API_KEY) { + // @phpstan-ignore-next-line $client_api_key = $client->client_api_key; $form->password('client_api_key.key', exmtrans('api.api_key'))->readonly()->toggleShowEvent() @@ -151,8 +155,10 @@ public function store() * @return Response * @throws \Exception */ + // @phpstan-ignore-next-line public function update($id) { + // @phpstan-ignore-next-line return $this->saveData($id); } @@ -165,12 +171,14 @@ public function update($id) * @throws \Psr\Container\NotFoundExceptionInterface * @throws \Throwable */ + // @phpstan-ignore-next-line protected function saveData($id = null) { $request = request(); // validation $form = $this->form($id); + // @phpstan-ignore-next-line if (($response = $form->validateRedirect($request->all())) instanceof \Illuminate\Http\RedirectResponse) { return $response; } @@ -188,6 +196,7 @@ protected function saveData($id = null) // create for CLIENT_CREDENTIALS if ($client_type == ApiClientType::CLIENT_CREDENTIALS) { $client = $clientRepository->create( + // @phpstan-ignore-next-line $user_id, $name, $request->get('redirect') @@ -196,12 +205,14 @@ protected function saveData($id = null) // create for password elseif ($client_type == ApiClientType::PASSWORD_GRANT) { $client = $clientRepository->createPasswordGrantClient( + // @phpstan-ignore-next-line $user_id, $name, 'http://localhost' ); } elseif ($client_type == ApiClientType::API_KEY) { $client = $clientRepository->createApiKey( + // @phpstan-ignore-next-line $user_id, $name, 'http://localhost' @@ -211,15 +222,20 @@ protected function saveData($id = null) // update info else { $client = ApiClient::find($id); + // @phpstan-ignore-next-line $client->name = $request->get('name'); + // @phpstan-ignore-next-line if ($client->client_type == ApiClientType::CLIENT_CREDENTIALS) { + // @phpstan-ignore-next-line $client->redirect = $request->get('redirect'); } + // @phpstan-ignore-next-line $client->save(); } DB::commit(); admin_toastr(trans('admin.update_succeeded')); + // @phpstan-ignore-next-line $url = admin_urls('api_setting', $client->id, 'edit'); return redirect($url); } catch (\Exception $ex) { diff --git a/src/Controllers/ApiTableController.php b/src/Controllers/ApiTableController.php index a23dc63ad..90b64ade0 100644 --- a/src/Controllers/ApiTableController.php +++ b/src/Controllers/ApiTableController.php @@ -24,6 +24,7 @@ class ApiTableController extends AdminControllerTableBase * @param array $parameters * @return \Symfony\Component\HttpFoundation\Response */ + // @phpstan-ignore-next-line public function callAction($method, $parameters) { if (!$this->custom_table) { @@ -37,9 +38,11 @@ public function callAction($method, $parameters) /** * get table columns */ + // @phpstan-ignore-next-line public function tableColumns(Request $request) { if (($code = $this->custom_table->enableAccess()) !== true) { + // @phpstan-ignore-next-line return abortJson(403, $code); } @@ -70,9 +73,11 @@ public function tableColumn(Request $request, $tableKey, $column_name) * @param $tableKey * @return Collection|\Symfony\Component\HttpFoundation\Response */ + // @phpstan-ignore-next-line public function views(Request $request, $tableKey) { if (($code = $this->custom_table->enableAccess()) !== true) { + // @phpstan-ignore-next-line return abortJson(403, $code); } @@ -96,6 +101,7 @@ public function views(Request $request, $tableKey) /** * get filter condition */ + // @phpstan-ignore-next-line public function getFilterCondition(Request $request) { $item = $this->getConditionItem($request, $request->get('q')); @@ -108,6 +114,7 @@ public function getFilterCondition(Request $request) /** * get filter condition */ + // @phpstan-ignore-next-line public function getFilterValue(Request $request) { $item = $this->getConditionItem($request, $request->get('target'), $request->get('filter_kind')); @@ -117,6 +124,7 @@ public function getFilterValue(Request $request) return $item->getFilterValueAjax($request->get('cond_key'), $request->get('cond_name'), boolval($request->get('show_condition_key'))); } + // @phpstan-ignore-next-line protected function getConditionItem(Request $request, $target, $filterKind = null) { $item = ConditionItemBase::getItemByRequest($this->custom_table, $target); @@ -137,6 +145,7 @@ protected function getConditionItem(Request $request, $target, $filterKind = nul /** * get updateTypeCondition condition */ + // @phpstan-ignore-next-line public function getOperationUpdateType(Request $request) { $item = $this->getConditionItem($request, $request->get('q')); @@ -149,6 +158,7 @@ public function getOperationUpdateType(Request $request) /** * get filter condition */ + // @phpstan-ignore-next-line public function getOperationFilterValue(Request $request) { $item = $this->getConditionItem($request, $request->get('target'), $request->get('filter_kind')); diff --git a/src/Controllers/ApiTrait.php b/src/Controllers/ApiTrait.php index 326cac65f..4a372b616 100644 --- a/src/Controllers/ApiTrait.php +++ b/src/Controllers/ApiTrait.php @@ -21,6 +21,7 @@ trait ApiTrait * @param \Exceedone\Exment\Validator\ExmentCustomValidator|Validator $validator * @return array error messages */ + // @phpstan-ignore-next-line protected function getErrorMessages($validator) { $errors = []; @@ -29,8 +30,10 @@ protected function getErrorMessages($validator) // remove "value." key $key = str_replace("value.", "", $key); if (is_array($message)) { + // @phpstan-ignore-next-line $errors[$key] = $message[0]; } else { + // @phpstan-ignore-next-line $errors[$key] = $message; } } @@ -47,10 +50,12 @@ protected function getErrorMessages($validator) protected function responseColumn(Request $request, ?CustomColumn $custom_column) { if (!isset($custom_column)) { + /** @phpstan-ignore-next-line */ return abortJson(400, ErrorCode::DATA_NOT_FOUND()); } if (!$custom_column->custom_table->hasPermission(Permission::AVAILABLE_ACCESS_CUSTOM_VALUE)) { + /** @phpstan-ignore-next-line */ return abortJson(403, ErrorCode::PERMISSION_DENY()); } @@ -74,6 +79,7 @@ protected function getCount(Request $request) $count = $request->get('count'); $maxcount = config('exment.api_max_data_count', 100); if (!preg_match('/^[0-9]+$/', $count) || intval($count) < 1 || intval($count) > $maxcount) { + /** @phpstan-ignore-next-line */ return abortJson(400, exmtrans('api.errors.over_maxcount', $maxcount), ErrorCode::INVALID_PARAMS()); } @@ -85,6 +91,7 @@ protected function getCount(Request $request) * @param Request $request * @param string $prefix */ + // @phpstan-ignore-next-line protected function getJoinTables(Request $request, $prefix) { $join_tables = []; @@ -116,6 +123,7 @@ protected function getJoinTables(Request $request, $prefix) */ protected function getCustomValue(CustomTable $custom_table, $id, bool $withTrashed = false) { + /** @phpstan-ignore-next-line */ $query = getModelName($custom_table->table_name)::query(); if ($withTrashed) { $query->withTrashed(); @@ -126,9 +134,11 @@ protected function getCustomValue(CustomTable $custom_table, $id, bool $withTras if (!isset($custom_value)) { $code = $custom_table->getNoDataErrorCode($id); if ($code == ErrorCode::PERMISSION_DENY) { + /** @phpstan-ignore-next-line */ return abortJson(403, $code); } else { // nodata + /** @phpstan-ignore-next-line */ return abortJson(400, $code); } } diff --git a/src/Controllers/ApiWorkflowController.php b/src/Controllers/ApiWorkflowController.php index 47ddcb921..49d2e990a 100644 --- a/src/Controllers/ApiWorkflowController.php +++ b/src/Controllers/ApiWorkflowController.php @@ -151,6 +151,7 @@ public function getValue($tableKey, $id, Request $request) } if (($code = $custom_table->enableAccess()) !== true) { + // @phpstan-ignore-next-line return abortJson(403, trans('admin.deny'), $code); } @@ -194,6 +195,7 @@ public function getWorkUsers($tableKey, $id, Request $request) } if (($code = $custom_table->enableAccess()) !== true) { + // @phpstan-ignore-next-line return abortJson(403, trans('admin.deny'), $code); } @@ -238,6 +240,7 @@ public function getActions($tableKey, $id, Request $request) } if (($code = $custom_table->enableAccess()) !== true) { + // @phpstan-ignore-next-line return abortJson(403, trans('admin.deny'), $code); } @@ -270,6 +273,7 @@ public function getHistories($tableKey, $id, Request $request) } if (($code = $custom_table->enableAccess()) !== true) { + // @phpstan-ignore-next-line return abortJson(403, trans('admin.deny'), $code); } @@ -305,6 +309,7 @@ public function execute($tableKey, $id, Request $request) } if (($code = $custom_table->enableAccess()) !== true) { + // @phpstan-ignore-next-line return abortJson(403, trans('admin.deny'), $code); } @@ -378,6 +383,7 @@ public function execute($tableKey, $id, Request $request) /** * create execute workflow params by request */ + // @phpstan-ignore-next-line protected function getExecuteParams(Request $request) { $params = []; diff --git a/src/Controllers/Auth2factorController.php b/src/Controllers/Auth2factorController.php index 930624631..b97651447 100644 --- a/src/Controllers/Auth2factorController.php +++ b/src/Controllers/Auth2factorController.php @@ -15,6 +15,7 @@ class Auth2factorController extends \Encore\Admin\Controllers\AuthController /** * User logout. */ + // @phpstan-ignore-next-line public function logout(Request $request) { $this->guard()->logout(); @@ -33,6 +34,7 @@ public function logout(Request $request) * * @throws \BadMethodCallException */ + // @phpstan-ignore-next-line public function __call($method, $parameters) { $provider = Auth2factorService::getProvider(); diff --git a/src/Controllers/AuthController.php b/src/Controllers/AuthController.php index 6a8d4fd91..cbebd7d2d 100644 --- a/src/Controllers/AuthController.php +++ b/src/Controllers/AuthController.php @@ -96,6 +96,7 @@ public function postLogin(Request $request) * @param LoginSetting|null $login_setting * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ + // @phpstan-ignore-next-line protected function executeLogin(Request $request, array $credentials, ?LoginSetting $login_setting = null) { $remember = boolval($request->get('remember', false)); @@ -116,6 +117,7 @@ protected function executeLogin(Request $request, array $credentials, ?LoginSett } $this->postVerifyEmail2factor(); + // @phpstan-ignore-next-line return $this->sendLoginResponse($request); } @@ -148,6 +150,7 @@ protected function executeLogin(Request $request, array $credentials, ?LoginSett * * @return bool if true, change password for first time. If false, continue. */ + // @phpstan-ignore-next-line protected function firstChangePassword($login_type) { if ($login_type != LoginType::PURE) { @@ -167,6 +170,7 @@ protected function firstChangePassword($login_type) * * @return bool if true, check password is OK. If false, user has to change password. */ + // @phpstan-ignore-next-line protected function checkPasswordLimit($login_type) { if ($login_type != LoginType::PURE) { @@ -224,6 +228,7 @@ public function getLogout(Request $request) return redirect(\URL::route('exment.login')); } + // @phpstan-ignore-next-line protected function postVerifyEmail2factor() { if (!boolval(config('exment.login_use_2factor', false)) || !boolval(System::login_use_2factor())) { @@ -237,6 +242,7 @@ protected function postVerifyEmail2factor() /** * file delete auth. */ + // @phpstan-ignore-next-line public function filedelete(Request $request) { $loginUser = \Exment::user(); diff --git a/src/Controllers/AuthOAuthController.php b/src/Controllers/AuthOAuthController.php index f1f6df297..134bba36d 100644 --- a/src/Controllers/AuthOAuthController.php +++ b/src/Controllers/AuthOAuthController.php @@ -29,6 +29,7 @@ public function __construct() * * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View */ + // @phpstan-ignore-next-line public function getLoginProvider(Request $request, $login_provider) { if ($this->guard()->check()) { @@ -68,6 +69,7 @@ public function getLoginProvider(Request $request, $login_provider) * @param $provider_name * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ + // @phpstan-ignore-next-line public function callback(Request $request, $provider_name) { if ($this->guard()->check()) { @@ -89,6 +91,7 @@ public function callback(Request $request, $provider_name) // set session access key LoginService::setToken(); + // @phpstan-ignore-next-line return $this->sendLoginResponse($request); } diff --git a/src/Controllers/AuthSamlController.php b/src/Controllers/AuthSamlController.php index cbe9b2368..18afd44fe 100644 --- a/src/Controllers/AuthSamlController.php +++ b/src/Controllers/AuthSamlController.php @@ -31,6 +31,7 @@ public function __construct() * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response * @throws \Exception */ + // @phpstan-ignore-next-line public function metadata(Request $request, $provider_name) { $saml2Auth = LoginSetting::getSamlAuth($provider_name); @@ -50,6 +51,7 @@ public function metadata(Request $request, $provider_name) * @param $provider_name * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|void */ + // @phpstan-ignore-next-line public function login(Request $request, $provider_name) { if ($this->guard()->check()) { @@ -89,6 +91,7 @@ public function login(Request $request, $provider_name) * @param $provider_name * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ + // @phpstan-ignore-next-line public function acs(Request $request, $provider_name) { if ($this->guard()->check()) { @@ -114,6 +117,7 @@ public function acs(Request $request, $provider_name) 'nameId' => $saml2Auth->getSaml2User()->getNameId(), ]]); + // @phpstan-ignore-next-line return $this->sendLoginResponse($request); } diff --git a/src/Controllers/AuthTrait.php b/src/Controllers/AuthTrait.php index ec3186e86..7d52e730d 100644 --- a/src/Controllers/AuthTrait.php +++ b/src/Controllers/AuthTrait.php @@ -20,29 +20,37 @@ trait AuthTrait { use ThrottlesLogins; + // @phpstan-ignore-next-line protected $maxAttempts; + // @phpstan-ignore-next-line protected $decayMinutes; + // @phpstan-ignore-next-line protected $throttle; + // @phpstan-ignore-next-line public function getLoginPageData($array = []) { $array['site_name'] = System::site_name(); $array['background_color'] = System::login_background_color(); $val = System::site_logo(); + /** @phpstan-ignore-next-line */ if (!boolval(config('exment.disable_login_header_logo', false)) && !is_nullorempty($val)) { $array['header_image'] = admin_url('auth/file/header'); } $val = System::login_page_image(); + /** @phpstan-ignore-next-line */ if (!is_nullorempty($val)) { $array['background_image'] = admin_url('auth/file/background'); } $val = System::login_page_image_type(); + /** @phpstan-ignore-next-line */ if (!is_nullorempty($val)) { $array['background_image_type'] = $val; } // if sso_disabled is true + /** @phpstan-ignore-next-line */ if (boolval(config('exment.custom_login_disabled', false))) { $array['login_providers'] = []; $array['form_providers'] = []; @@ -64,6 +72,7 @@ public function getLoginPageData($array = []) return $array; } + // @phpstan-ignore-next-line protected function logoutSso(Request $request, $login_user, $options = []) { switch ($login_user->login_type) { @@ -75,9 +84,12 @@ protected function logoutSso(Request $request, $login_user, $options = []) // Only if oauth provider type is 'other' // ( Because no other provider type has 'getLogoutUrl' ) + /** @phpstan-ignore-next-line */ if ( $oauth_setting->getOption('oauth_provider_type') == 'other' ) { $socialite_provider = LoginSetting::getSocialiteProvider($provider_name); + /** @phpstan-ignore-next-line */ if ( $oauth_setting->getOption('oauth_option_single_logout') == 1 && method_exists($socialite_provider, 'getLogoutUrl') ) { + /** @phpstan-ignore-next-line */ return redirect( $socialite_provider->getLogoutUrl( \URL::route('exment.login') ) ); } } @@ -86,6 +98,7 @@ protected function logoutSso(Request $request, $login_user, $options = []) break; } + /** @phpstan-ignore-next-line */ return redirect(\URL::route('exment.login')); } @@ -98,12 +111,15 @@ protected function logoutSso(Request $request, $login_user, $options = []) * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|void * @throws \OneLogin\Saml2\Error */ + // @phpstan-ignore-next-line protected function logoutSaml(Request $request, $provider_name, $options = []) { $login_setting = LoginSetting::getSamlSetting($provider_name); // if not set ssout_url, return login + /** @phpstan-ignore-next-line */ if (!isset($login_setting) || is_nullorempty($login_setting->getOption('saml_idp_ssout_url'))) { + /** @phpstan-ignore-next-line */ return redirect(\URL::route('exment.login')); } @@ -124,6 +140,7 @@ protected function logoutSaml(Request $request, $provider_name, $options = []) */ protected function sendLoginResponse(Request $request) { + /** @phpstan-ignore-next-line */ admin_toastr(trans('admin.login_successful')); $request->session()->regenerate(); @@ -137,6 +154,7 @@ protected function sendLoginResponse(Request $request) protected function getFailedLoginMessage() { if (Lang::has('exment::exment.error.login_failed')) { + /** @phpstan-ignore-next-line */ return exmtrans('error.login_failed'); } /* TODO:used in a class that does not implement `getFailedLoginMessage` in the parent. */ diff --git a/src/Controllers/BackupController.php b/src/Controllers/BackupController.php index 5e33ce7e3..8081ad091 100644 --- a/src/Controllers/BackupController.php +++ b/src/Controllers/BackupController.php @@ -19,7 +19,9 @@ class BackupController extends AdminControllerBase { + // @phpstan-ignore-next-line protected $backup; + // @phpstan-ignore-next-line protected $restore; public function __construct() @@ -52,6 +54,7 @@ public function index(Request $request, Content $content) } // get all archive files + // @phpstan-ignore-next-line $files = collect($disk->files('list'))->filter(function ($file) { return preg_match('/list\/' . Define::RULES_REGEX_BACKUP_FILENAME . '\.zip$/i', $file); })->sortByDesc(function ($file) use ($disk) { @@ -87,6 +90,7 @@ public function index(Request $request, Content $content) return $content; } + // @phpstan-ignore-next-line protected function settingFormBox() { $form = new WidgetForm(System::get_system_values()); @@ -118,7 +122,7 @@ protected function settingFormBox() ->min(0) ->attribute(['data-filter' => json_encode(['key' => 'backup_enable_automatic', 'value' => '1'])]); - /** @phpstan-ignore-next-line constructor expects string, Encore\Admin\Widgets\Form given. */ + // @phpstan-ignore-next-line return new Box(exmtrans("backup.setting_header"), $form); } @@ -225,6 +229,7 @@ public function save(Request $request) /** * Download file */ + // @phpstan-ignore-next-line public function download($arg) { $ymdhms = urldecode($arg); @@ -256,6 +261,7 @@ public function download($arg) * @param $file_key * @return \Symfony\Component\HttpFoundation\Response */ + // @phpstan-ignore-next-line protected function importModal($file_key = null) { $import_path = admin_url(url_join('backup', 'import')); @@ -311,6 +317,7 @@ protected function importModal($file_key = null) /** * Upload zip file */ + // @phpstan-ignore-next-line protected function import(Request $request) { \Exment::setTimeLimitLong(); @@ -352,6 +359,7 @@ protected function import(Request $request) // get upload file $file = $request->file('upload_zipfile'); // store uploaded file + // @phpstan-ignore-next-line $filename = $file->storeAs('', $file->getClientOriginalName(), Define::DISKNAME_ADMIN_TMP); try { $result = $this->restore->execute($filename, true); diff --git a/src/Controllers/ChangePasswordController.php b/src/Controllers/ChangePasswordController.php index 96e4a6194..416bbe346 100644 --- a/src/Controllers/ChangePasswordController.php +++ b/src/Controllers/ChangePasswordController.php @@ -17,6 +17,7 @@ class ChangePasswordController extends Controller * * @return array */ + // @phpstan-ignore-next-line protected function rules() { return [ diff --git a/src/Controllers/CodeTreeTrait.php b/src/Controllers/CodeTreeTrait.php index 5606a3f8c..c64e5bd6c 100644 --- a/src/Controllers/CodeTreeTrait.php +++ b/src/Controllers/CodeTreeTrait.php @@ -18,13 +18,16 @@ trait CodeTreeTrait * @param array $json * @param bool $root is root as. */ + // @phpstan-ignore-next-line protected function setDirectoryNodes($folder, $parent, &$json, bool $root = false) { + /** @phpstan-ignore-next-line */ $directory_node = "node_" . make_uuid(); $json[] = [ 'id' => $directory_node, 'parent' => $parent, 'path' => $folder, + /** @phpstan-ignore-next-line */ 'text' => isMatchString($folder, '/') ? '/' : basename($folder), 'state' => [ 'opened' => $parent == '#', @@ -40,8 +43,10 @@ protected function setDirectoryNodes($folder, $parent, &$json, bool $root = fals $files = $this->getFilePaths($folder); foreach ($files as $file) { $json[] = [ + /** @phpstan-ignore-next-line */ 'id' => "node_" . make_uuid(), 'parent' => $directory_node, + /** @phpstan-ignore-next-line */ 'path' => path_join($folder, basename($file)), 'icon' => 'jstree-file', 'text' => basename($file), @@ -59,11 +64,13 @@ protected function setDirectoryNodes($folder, $parent, &$json, bool $root = fals protected function getNodePath($nodeId): ?string { $nodelist = session(static::node_key); + /** @phpstan-ignore-next-line */ if (is_nullorempty($nodelist)) { return null; } foreach ($nodelist as $node) { + /** @phpstan-ignore-next-line */ if (!isMatchString($nodeId, array_get($node, 'id'))) { continue; } diff --git a/src/Controllers/CustomColumnController.php b/src/Controllers/CustomColumnController.php index 4f60468ee..25ab55b39 100644 --- a/src/Controllers/CustomColumnController.php +++ b/src/Controllers/CustomColumnController.php @@ -86,6 +86,7 @@ public function edit(Request $request, Content $content, $tableKey, $id) * * @return \Illuminate\Http\Response|void */ + // @phpstan-ignore-next-line public function update($tableKey, $id) { //Validation table value @@ -163,7 +164,7 @@ protected function grid() }); $grid->tools(function (Grid\Tools $tools) { - /** @phpstan-ignore-next-line append() expects Encore\Admin\Grid\Tools\AbstractTool|string, Exceedone\Exment\Form\Tools\CustomTableMenuButton given */ + // @phpstan-ignore-next-line $tools->append(new Tools\CustomTableMenuButton('column', $this->custom_table)); }); @@ -204,6 +205,7 @@ protected function grid() * @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface */ + // @phpstan-ignore-next-line protected function form($id = null) { $form = new Form(new CustomColumn()); @@ -375,12 +377,13 @@ protected function form($id = null) if (isset($id) && boolval(CustomColumn::getEloquent($id)->disabled_delete)) { $tools->disableDelete(); } - /** @phpstan-ignore-next-line add() expects string, Exceedone\Exment\Form\Tools\CustomTableMenuButton given */ + // @phpstan-ignore-next-line $tools->add(new Tools\CustomTableMenuButton('column', $custom_table)); }); return $form; } + // @phpstan-ignore-next-line public function calcModal(Request $request, $tableKey, $id = null) { // get other columns @@ -410,6 +413,7 @@ public function calcModal(Request $request, $tableKey, $id = null) /** * add column form and view after saved */ + // @phpstan-ignore-next-line protected function addColumnAfterSaved($model) { // set custom form columns -------------------------------------------------- @@ -434,7 +438,7 @@ protected function addColumnAfterSaved($model) $order++; // get width - /** @phpstan-ignore-next-line need test 'Called 'first' on Laravel collection, but could have been retrieved as a query.' */ + // @phpstan-ignore-next-line $width = $form_block->custom_form_columns() ->where('row_no', 1) ->where('column_no', 1) @@ -513,6 +517,7 @@ protected function addColumnAfterSaved($model) * @param Request $request * @return array */ + // @phpstan-ignore-next-line public function columnTypeHtml(Request $request) { $val = $request->get('val'); @@ -542,6 +547,7 @@ public function columnTypeHtml(Request $request) } + // @phpstan-ignore-next-line protected function getCustomItem(Request $request, $id, $column_type) { return CustomItem::getItem(new CustomColumn([ diff --git a/src/Controllers/CustomCopyController.php b/src/Controllers/CustomCopyController.php index e174929a4..153dc0464 100644 --- a/src/Controllers/CustomCopyController.php +++ b/src/Controllers/CustomCopyController.php @@ -90,7 +90,7 @@ protected function grid() $grid->column('from_custom_table.table_view_name', exmtrans("custom_copy.from_custom_table_view_name"))->sortable(); $grid->column('to_custom_table.table_view_name', exmtrans("custom_copy.to_custom_table_view_name"))->sortable(); $grid->column('label', exmtrans("plugin.options.label"))->sortable()->display(function ($value) { - /** @phpstan-ignore-next-line array_get expects array|ArrayAccess, $this(Exceedone\Exment\Controllers\CustomCopyController) given */ + // @phpstan-ignore-next-line return array_get($this, 'options.label'); }); @@ -104,7 +104,7 @@ protected function grid() 'url' => admin_urls('copy', $this->custom_table->table_name, 'newModal') ])); //$tools->append($this->createNewModal()); - /** @phpstan-ignore-next-line append() expects Encore\Admin\Grid\Tools\AbstractTool|string, Exceedone\Exment\Form\Tools\CustomTableMenuButton given */ + // @phpstan-ignore-next-line $tools->append(new Tools\CustomTableMenuButton('copy', $this->custom_table)); }); @@ -134,6 +134,7 @@ protected function grid() * * @return array|null child copy options */ + // @phpstan-ignore-next-line protected function getChildCopyOptions($to_table) { if (isset($to_table)) { @@ -162,6 +163,7 @@ protected function getChildCopyOptions($to_table) * * @return Form */ + // @phpstan-ignore-next-line protected function form($id = null) { $form = new Form(new CustomCopy()); @@ -234,7 +236,7 @@ protected function form($id = null) ->descriptionHtml(exmtrans("custom_copy.input_column_description")); $form->tools(function (Form\Tools $tools) use ($custom_table) { - /** @phpstan-ignore-next-line add() expects string, Exceedone\Exment\Form\Tools\CustomTableMenuButton given */ + // @phpstan-ignore-next-line $tools->add(new Tools\CustomTableMenuButton('copy', $custom_table)); }); @@ -274,6 +276,7 @@ protected function form($id = null) /** * Create new button for modal. */ + // @phpstan-ignore-next-line protected function newModal() { $table_name = $this->custom_table->table_name; diff --git a/src/Controllers/CustomFormController.php b/src/Controllers/CustomFormController.php index 01eba8788..df08e588a 100644 --- a/src/Controllers/CustomFormController.php +++ b/src/Controllers/CustomFormController.php @@ -332,6 +332,7 @@ public function create(Request $request, Content $content) * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|null * @throws \Exception */ + // @phpstan-ignore-next-line public function update(Request $request, $tableKey, $id) { $validator = $this->saveformValidate($request, $id); @@ -399,7 +400,7 @@ protected function grid() $custom_table = $this->custom_table; $grid->tools(function (Grid\Tools $tools) { - /**@phpstan-ignore-next-line append() expects Encore\Admin\Grid\Tools\AbstractTool|string, Exceedone\Exment\Form\Tools\CustomTableMenuButton given */ + // @phpstan-ignore-next-line $tools->append(new Tools\CustomTableMenuButton('form', $this->custom_table)); $tools->batch(function (Grid\Tools\BatchActions $actions) { $actions->disableDelete(); @@ -461,6 +462,7 @@ protected function grid() * @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface */ + // @phpstan-ignore-next-line protected function createForm($content, $id = null, $copy_id = null) { // get form @@ -506,7 +508,7 @@ protected function createForm($content, $id = null, $copy_id = null) protected function getHeaderBox(?CustomForm $custom_form, string $formroot) { ///// set default setting - /** @phpstan-ignore-next-line constructor expects array, Exceedone\Exment\Model\CustomForm|null given */ + // @phpstan-ignore-next-line $form = new WidgetForm($custom_form); $form->disableSubmit()->disableReset()->onlyRenderFields(); @@ -529,7 +531,7 @@ protected function getHeaderBox(?CustomForm $custom_form, string $formroot) ->help(exmtrans('custom_form.help.form_label_type')) ->default(FormLabelType::HORIZONTAL) ->options(FormLabelType::transArrayFilter('custom_form.form_label_type_options', FormLabelType::getFormLabelTypes())); - /** @phpstan-ignore-next-line constructor expects string, Encore\Admin\Widgets\Form given */ + // @phpstan-ignore-next-line $box = new Box(exmtrans('custom_form.header_basic_setting'), $form); $box->tools(view('exment::tools.button', [ 'href' => 'javascript:void(0);', @@ -549,6 +551,7 @@ protected function getHeaderBox(?CustomForm $custom_form, string $formroot) } + // @phpstan-ignore-next-line protected function getFormBlocks($form) { // Loop using CustomFormBlocks @@ -598,6 +601,7 @@ protected function getFormBlocks($form) * * @return array|\Illuminate\Support\Collection */ + // @phpstan-ignore-next-line protected function getFormBlockItems($form) { // get custom_form_blocks from request @@ -622,6 +626,7 @@ protected function getFormBlockItems($form) /** * validate before update or store */ + // @phpstan-ignore-next-line protected function saveformValidate($request, $id = null) { //not required check, confirm on display. @@ -667,6 +672,7 @@ protected function saveformValidate($request, $id = null) /** * Store form data */ + // @phpstan-ignore-next-line protected function saveform(Request $request, $id = null) { $saveData = $this->getModelFromRequest($request, $id); @@ -727,6 +733,7 @@ protected function saveform(Request $request, $id = null) * 'deletes' => [(column_ids)], * ] */ + // @phpstan-ignore-next-line protected function getModelFromRequest(Request $request, $id = null, $isPrepareOptions = true): array { $result = [ @@ -763,8 +770,11 @@ protected function getModelFromRequest(Request $request, $id = null, $isPrepareO } else { $block = CustomFormBlock::findOrFail($key); } + // @phpstan-ignore-next-line $block->available = array_get($value, 'available') ?? 0; + // @phpstan-ignore-next-line $block->form_block_view_name = array_get($value, 'form_block_view_name'); + // @phpstan-ignore-next-line $block->options = array_get($value, 'options', []); // create columns -------------------------------------------------- @@ -791,6 +801,7 @@ protected function getModelFromRequest(Request $request, $id = null, $isPrepareO continue; } elseif ($new_column) { $column = new CustomFormColumn(); + // @phpstan-ignore-next-line $column->custom_form_block_id = $block->id; $column->form_column_type = array_get($column_value, 'form_column_type'); if (is_null(array_get($column_value, 'form_column_target_id'))) { @@ -801,6 +812,7 @@ protected function getModelFromRequest(Request $request, $id = null, $isPrepareO $column = CustomFormColumn::findOrFail($column_key); } + // @phpstan-ignore-next-line $column_item = FormSetting\FormColumn\ColumnBase::make($column); // if change row_no and calc_no, increment no's. @@ -816,18 +828,24 @@ protected function getModelFromRequest(Request $request, $id = null, $isPrepareO $real_before_row_no = array_get($column_value, 'row_no', 1); $real_before_column_no = array_get($column_value, 'column_no', 1); + // @phpstan-ignore-next-line $column->row_no = $before_row_no; + // @phpstan-ignore-next-line $column->column_no = $before_column_no; + // @phpstan-ignore-next-line $column->width = array_get($column_value, 'width', 1); $form_options = jsonToArray(array_get($column_value, 'options', "[]")); if ($isPrepareOptions) { + // @phpstan-ignore-next-line $column->options = $column_item->prepareSavingOptions($form_options); } // if preview, options set directrly. else { + // @phpstan-ignore-next-line $column->options = $form_options; } + // @phpstan-ignore-next-line $column->order = $order++; $result_block['custom_form_columns'][] = $column; @@ -851,6 +869,7 @@ protected function getModelFromRequest(Request $request, $id = null, $isPrepareO // create form because we need for delete + // @phpstan-ignore-next-line protected function form($id = null) { return Admin::form(CustomForm::class, function (Form $form) { @@ -884,7 +903,7 @@ public function settingModal(Request $request) return getAjaxResponse([ 'body' => $form->render(), - /** @phpstan-ignore-next-line Result of method Encore\Admin\Widgets\Form::getScript() (void) is used. need to fix laravel-admin */ + // @phpstan-ignore-next-line 'script' => $form->getScript(), 'title' => trans('admin.setting'), 'modalSize' => 'modal-xl', @@ -900,6 +919,7 @@ public function settingModal(Request $request) * * @return void */ + // @phpstan-ignore-next-line protected function saveAndStoreImage(array $new_columns) { $files = request()->files->all(); @@ -927,6 +947,7 @@ protected function saveAndStoreImage(array $new_columns) * * @return void */ + // @phpstan-ignore-next-line protected function deleteImage($deletes) { collect($deletes)->map(function ($delete) { diff --git a/src/Controllers/CustomFormPriorityController.php b/src/Controllers/CustomFormPriorityController.php index 8df5b14b8..ba60c815b 100644 --- a/src/Controllers/CustomFormPriorityController.php +++ b/src/Controllers/CustomFormPriorityController.php @@ -40,12 +40,13 @@ public function index(Request $request, Content $content) * * @return Form */ + // @phpstan-ignore-next-line protected function form($id = null) { $form = new Form(new CustomFormPriority()); $custom_table = $this->custom_table; $form->select('custom_form_id', exmtrans("custom_form_priority.custom_form_id"))->required() - /** @phpstan-ignore-next-line :options() expects array, Closure given */ + // @phpstan-ignore-next-line ->options(function ($value) use ($custom_table) { return $custom_table->custom_forms->mapWithKeys(function ($item) { return [$item['id'] => $item['form_view_name']]; @@ -85,7 +86,7 @@ protected function form($id = null) ->option(exmtrans("condition.condition_reverse_options")); $form->tools(function (Form\Tools $tools) use ($custom_table) { - /** @phpstan-ignore-next-line add() expects string, Exceedone\Exment\Form\Tools\CustomTableMenuButton given */ + // @phpstan-ignore-next-line $tools->add(new Tools\CustomTableMenuButton('form', $custom_table)); $tools->setListPath(admin_urls('form', $custom_table->table_name)); }); diff --git a/src/Controllers/CustomFormPublicController.php b/src/Controllers/CustomFormPublicController.php index 26cafdc2c..e6ed12220 100644 --- a/src/Controllers/CustomFormPublicController.php +++ b/src/Controllers/CustomFormPublicController.php @@ -35,6 +35,7 @@ class CustomFormPublicController extends AdminControllerTableBase use HasResourceTableActions; use NotifyTrait; + // @phpstan-ignore-next-line protected $mailTemplates = []; public function __construct(?CustomTable $custom_table, Request $request) @@ -60,6 +61,7 @@ public function index(Request $request, Content $content) * * @return Form */ + // @phpstan-ignore-next-line protected function form($id = null) { if (!isset($id) && request()->has('template')) { @@ -86,6 +88,7 @@ public function store() * * @return Form|void */ + // @phpstan-ignore-next-line protected function basicForm($id = null) { if (!$this->validateTable($this->custom_table, Permission::EDIT_CUSTOM_FORM_PUBLIC)) { @@ -104,10 +107,12 @@ protected function basicForm($id = null) $form->descriptionHtml(exmtrans('common.help.more_help')); if (isset($public_form)) { + // @phpstan-ignore-next-line if ($public_form->active_flg) { $form->url('share_url', exmtrans('custom_form_public.share_url')) ->attribute(['copyScript' => 1]) ->help(exmtrans('custom_form_public.help.share_url')) + // @phpstan-ignore-next-line ->default($public_form->getUrl()) ->readonly(); $form->ignore('share_url'); @@ -458,7 +463,7 @@ protected function importForm() $form->select('custom_form_id', exmtrans("custom_form_public.custom_form_id")) ->requiredRule() ->help(exmtrans("custom_form_public.help.custom_form_id")) - /** @phpstan-ignore-next-line Parameter #1 $options of method Encore\Admin\Form\Field::options() expects array, Closure given. need to fix laravel-admin */ + // @phpstan-ignore-next-line ->options(function ($value) use ($custom_table) { return $custom_table->custom_forms->mapWithKeys(function ($item) { return [$item['id'] => $item['form_view_name']]; @@ -487,6 +492,7 @@ protected function importForm() } + // @phpstan-ignore-next-line protected function setFormInfo($form, $id, $public_form, $preview = true) { $custom_table = $this->custom_table; @@ -510,7 +516,7 @@ protected function setFormInfo($form, $id, $public_form, $preview = true) $form->disableEditingCheck(false); $form->tools(function (Form\Tools $tools) use ($custom_table, $id, $public_form, $preview) { - /** @phpstan-ignore-next-line add() expects string, Exceedone\Exment\Form\Tools\CustomTableMenuButton given */ + // @phpstan-ignore-next-line $tools->add(new Tools\CustomTableMenuButton('form', $custom_table)); $tools->setListPath(admin_urls('form', $custom_table->table_name)); @@ -594,6 +600,7 @@ protected function setFormInfo($form, $id, $public_form, $preview = true) } + // @phpstan-ignore-next-line protected function setNotifyMailTemplate($form, string $field_name, ?string $notify_mail_template, string $filter_key_name) { if (\is_nullorempty($this->mailTemplates)) { @@ -659,6 +666,7 @@ protected function importFormStore() * @return PublicContent * @throws PublicFormNotFoundException */ + // @phpstan-ignore-next-line public function preview(Request $request, $tableKey, $id = null) { $original_public_form = PublicForm::find($id); @@ -700,6 +708,7 @@ public function preview(Request $request, $tableKey, $id = null) /** * file delete. Now only header_logo, If other file, todo refactor. */ + // @phpstan-ignore-next-line public function filedelete(Request $request, $tableKey, $id) { // If not id, sot saving, so return nothing doing. @@ -716,6 +725,7 @@ public function filedelete(Request $request, $tableKey, $id) return $trueResult; } + // @phpstan-ignore-next-line $uri = $original_public_form->getOption('header_logo'); if (!$uri) { return $trueResult; @@ -723,6 +733,7 @@ public function filedelete(Request $request, $tableKey, $id) ExmentFile::deleteFileInfo($uri); + // @phpstan-ignore-next-line $original_public_form->forgetOption('header_logo') ->save(); @@ -737,6 +748,7 @@ public function filedelete(Request $request, $tableKey, $id) /** * get copy modal */ + // @phpstan-ignore-next-line public function activeModal(Request $request, $tableKey, $id) { $public_form = PublicForm::find($id); @@ -746,6 +758,7 @@ public function activeModal(Request $request, $tableKey, $id) // create form fields $form = new ModalForm(); + // @phpstan-ignore-next-line $form->action(admin_urls("formpublic", $this->custom_table->table_name, $public_form->id, "activate")); $form->method('POST'); @@ -754,6 +767,7 @@ public function activeModal(Request $request, $tableKey, $id) ->displayText(exmtrans('custom_form_public.help.activate_modal_header')) ->escape(false); + // @phpstan-ignore-next-line $tableUseds = $public_form->getListOfTablesUsed(); $html = "
    " . $tableUseds->map(function ($tableUsed) { return "
  • " . esc_html($tableUsed->table_view_name) . "
  • "; @@ -780,6 +794,7 @@ public function activeModal(Request $request, $tableKey, $id) * @param string|int|null $id * @return \Symfony\Component\HttpFoundation\Response */ + // @phpstan-ignore-next-line public function activate(Request $request, $tableKey, $id) { return $this->toggleActivate($request, $id, true); @@ -792,6 +807,7 @@ public function activate(Request $request, $tableKey, $id) * @param string|int|null $id * @return \Symfony\Component\HttpFoundation\Response */ + // @phpstan-ignore-next-line public function deactivate(Request $request, $tableKey, $id) { return $this->toggleActivate($request, $id, false); @@ -805,6 +821,7 @@ public function deactivate(Request $request, $tableKey, $id) * @param $id * @return \Symfony\Component\HttpFoundation\BinaryFileResponse */ + // @phpstan-ignore-next-line public function export(Request $request, $tableKey, $id) { $public_form = PublicForm::find($id); @@ -812,12 +829,15 @@ public function export(Request $request, $tableKey, $id) // execute export return TemplateImportExport\TemplateExporter::exportTemplate( make_uuid(), + // @phpstan-ignore-next-line $public_form->public_form_view_name, null, null, [ 'export_target' => [TemplateExportTarget::PUBLIC_FORM], + // @phpstan-ignore-next-line 'public_form_uuid' => $public_form->uuid, + // @phpstan-ignore-next-line 'zip_name' => $public_form->public_form_view_name, ] ); @@ -831,6 +851,7 @@ public function export(Request $request, $tableKey, $id) * @param bool $active_flg * @return \Symfony\Component\HttpFoundation\Response|void */ + // @phpstan-ignore-next-line protected function toggleActivate(Request $request, $id, bool $active_flg) { if (!$this->validateTable($this->custom_table, Permission::EDIT_CUSTOM_FORM_PUBLIC)) { @@ -838,7 +859,9 @@ protected function toggleActivate(Request $request, $id, bool $active_flg) } $public_form = PublicForm::find($id); + // @phpstan-ignore-next-line $public_form->active_flg = $active_flg; + // @phpstan-ignore-next-line $public_form->save(); return getAjaxResponse([ @@ -848,6 +871,7 @@ protected function toggleActivate(Request $request, $id, bool $active_flg) } + // @phpstan-ignore-next-line public function notify_action_target(Request $request) { $options = NotifyService::getNotifyTargetColumns($this->custom_table, $request->get('q'), [ @@ -861,6 +885,7 @@ public function notify_action_target(Request $request) } + // @phpstan-ignore-next-line protected static function getFileOptions($custom_table, $id) { return array_merge( @@ -882,6 +907,7 @@ protected static function getFileOptions($custom_table, $id) * validation table * @param mixed $table id or customtable */ + // @phpstan-ignore-next-line protected function validateTable($table, $role_name) { $table = CustomTable::getEloquent($table); diff --git a/src/Controllers/CustomNotifyController.php b/src/Controllers/CustomNotifyController.php index 08d902177..4d803c115 100644 --- a/src/Controllers/CustomNotifyController.php +++ b/src/Controllers/CustomNotifyController.php @@ -95,7 +95,7 @@ protected function grid() ->whereIn('notify_trigger', NotifyTrigger::CUSTOM_TABLES()); $grid->tools(function (Grid\Tools $tools) { - /** @phpstan-ignore-next-line append() expects Encore\Admin\Grid\Tools\AbstractTool|string, Exceedone\Exment\Form\Tools\CustomTableMenuButton given */ + // @phpstan-ignore-next-line $tools->append(new Tools\CustomTableMenuButton('notify', $this->custom_table)); }); @@ -131,6 +131,7 @@ protected function grid() * @param $copy_id * @return Form|false|void */ + // @phpstan-ignore-next-line protected function form($id = null, $copy_id = null) { if (!$this->hasPermissionEdit($id)) { @@ -139,6 +140,7 @@ protected function form($id = null, $copy_id = null) $form = new Form(new Notify()); $notify = Notify::find($id); + // @phpstan-ignore-next-line if ($notify && !in_array($notify->notify_trigger, NotifyTrigger::CUSTOM_TABLES())) { Checker::error(exmtrans('common.message.wrongdata')); return false; @@ -149,6 +151,7 @@ protected function form($id = null, $copy_id = null) $form->internal('target_id')->default($this->custom_table->id); $form->display('custom_table.table_view_name', exmtrans("custom_table.table"))->default($this->custom_table->table_view_name); + // @phpstan-ignore-next-line $this->setBasicForm($form, $notify); $form->exmheader(exmtrans('notify.header_trigger'))->hr(); @@ -252,15 +255,18 @@ protected function form($id = null, $copy_id = null) ->help(exmtrans("notify.help.notify_action")) ; + // @phpstan-ignore-next-line $this->setActionForm($form, $notify, $custom_table); })->required()->disableHeader(); + // @phpstan-ignore-next-line $this->setMailTemplateForm($form, $notify); + // @phpstan-ignore-next-line $this->setFooterForm($form, $notify); $form->tools(function (Form\Tools $tools) use ($custom_table) { - /** @phpstan-ignore-next-line add() expects string, Exceedone\Exment\Form\Tools\CustomTableMenuButton given */ + // @phpstan-ignore-next-line $tools->add(new Tools\CustomTableMenuButton('notify', $custom_table)); }); @@ -269,6 +275,7 @@ protected function form($id = null, $copy_id = null) + // @phpstan-ignore-next-line public function notify_action_target(Request $request) { $options = NotifyService::getNotifyTargetColumns($this->custom_table, $request->get('q'), [ @@ -278,6 +285,7 @@ public function notify_action_target(Request $request) return $options; } + // @phpstan-ignore-next-line protected function getTargetDateColumnOptions($custom_table_id, $table_name = null) { return CustomColumn::where('custom_table_id', $custom_table_id) @@ -291,6 +299,7 @@ protected function getTargetDateColumnOptions($custom_table_id, $table_name = nu }); } + // @phpstan-ignore-next-line protected function getTargetColumnOptions($custom_table) { $custom_table = CustomTable::getEloquent($custom_table); @@ -316,6 +325,7 @@ protected function getTargetColumnOptions($custom_table) return $options->pluck('text', 'id'); } + // @phpstan-ignore-next-line public function getNotifyTriggerTemplate(Request $request) { $keyName = 'mail_template_id'; diff --git a/src/Controllers/CustomOperationController.php b/src/Controllers/CustomOperationController.php index f13eb24c5..54e93d07a 100644 --- a/src/Controllers/CustomOperationController.php +++ b/src/Controllers/CustomOperationController.php @@ -119,7 +119,7 @@ protected function grid() }); $grid->tools(function (Grid\Tools $tools) { - /** @phpstan-ignore-next-line append() expects Encore\Admin\Grid\Tools\AbstractTool|string, Exceedone\Exment\Form\Tools\CustomTableMenuButton given */ + // @phpstan-ignore-next-line $tools->append(new Tools\CustomTableMenuButton('operation', $this->custom_table)); }); @@ -302,7 +302,7 @@ protected function form($id = null) }); $form->tools(function (Form\Tools $tools) use ($custom_table) { - /** @phpstan-ignore-next-line add() expects string, Exceedone\Exment\Form\Tools\CustomTableMenuButton given */ + // @phpstan-ignore-next-line $tools->add(new Tools\CustomTableMenuButton('operation', $custom_table)); }); $form->disableEditingCheck(false); @@ -310,6 +310,7 @@ protected function form($id = null) return $form; } + // @phpstan-ignore-next-line protected function hasSystemPermission() { return $this->custom_table->hasPermission([Permission::CUSTOM_TABLE, Permission::CUSTOM_VIEW]); @@ -318,6 +319,7 @@ protected function hasSystemPermission() /** * get filter condition */ + // @phpstan-ignore-next-line public function getFilterValue(Request $request) { if ($request->has('target_name') && $request->has('target_val')) { @@ -340,6 +342,7 @@ public function getFilterValue(Request $request) $field->setElementName($element_name); $view = $field->render(); + // @phpstan-ignore-next-line return \json_encode(['html' => $view->render(), 'script' => $field->getScript()]); } } diff --git a/src/Controllers/CustomRelationController.php b/src/Controllers/CustomRelationController.php index 2fc9453bf..973d5d676 100644 --- a/src/Controllers/CustomRelationController.php +++ b/src/Controllers/CustomRelationController.php @@ -98,7 +98,7 @@ protected function grid() } $grid->tools(function (Grid\Tools $tools) { - /** @phpstan-ignore-next-line append() expects Encore\Admin\Grid\Tools\AbstractTool|string, Exceedone\Exment\Form\Tools\CustomTableMenuButton given */ + // @phpstan-ignore-next-line $tools->append(new Tools\CustomTableMenuButton('relation', $this->custom_table)); }); @@ -128,6 +128,7 @@ protected function grid() * * @return Form */ + // @phpstan-ignore-next-line protected function form($id = null) { $form = new Form(new CustomRelation()); @@ -142,7 +143,9 @@ protected function form($id = null) if (isset($id)) { $custom_relation = CustomRelation::find($id); + // @phpstan-ignore-next-line $child_table = $custom_relation->child_custom_table_cache; + // @phpstan-ignore-next-line $relation_type = $custom_relation->relation_type; $form->display('child_custom_table_id', exmtrans("custom_relation.child_custom_table")) ->displayText($child_table->table_view_name); @@ -198,7 +201,7 @@ protected function form($id = null) $custom_table = $this->custom_table; $form->tools(function (Form\Tools $tools) use ($custom_table) { - /** @phpstan-ignore-next-line add() expects string, Exceedone\Exment\Form\Tools\CustomTableMenuButton given */ + // @phpstan-ignore-next-line $tools->add(new Tools\CustomTableMenuButton('relation', $custom_table)); }); return $form; diff --git a/src/Controllers/CustomTableController.php b/src/Controllers/CustomTableController.php index 339bceede..9eba43ab5 100644 --- a/src/Controllers/CustomTableController.php +++ b/src/Controllers/CustomTableController.php @@ -45,6 +45,7 @@ class CustomTableController extends AdminControllerBase { use HasResourceActions; + // @phpstan-ignore-next-line protected $exists = false; public function __construct() @@ -61,7 +62,7 @@ public function index(Request $request, Content $content) { $content = $this->AdminContent($content); - /** @phpstan-ignore-next-line constructor expects string, Encore\Admin\Grid given*/ + // @phpstan-ignore-next-line $row = new Row($this->grid()); $row->class(['block_custom_table']); @@ -76,6 +77,7 @@ public function index(Request $request, Content $content) */ protected function qrcodeActivate(Request $request, $id) { + // @phpstan-ignore-next-line return $this->toggleActivateQr($request, $id, true); } @@ -88,6 +90,7 @@ protected function qrcodeActivate(Request $request, $id) */ protected function qrcodeDeactivate(Request $request, $id) { + // @phpstan-ignore-next-line return $this->toggleActivateQr($request, $id, false); } /** @@ -119,6 +122,7 @@ protected function toggleActivateQr(Request $request, $id, $active_qr_flg) */ protected function jancodeActivate(Request $request, $id) { + // @phpstan-ignore-next-line return $this->toggleActivateJancode($request, $id, true); } @@ -131,6 +135,7 @@ protected function jancodeActivate(Request $request, $id) */ protected function jancodeDeactivate(Request $request, $id) { + // @phpstan-ignore-next-line return $this->toggleActivateJancode($request, $id, false); } /** @@ -167,7 +172,7 @@ protected function grid() $grid->tools(function (Grid\Tools $tools) { $tools->disableBatchActions(); - /** @phpstan-ignore-next-line append() expects Encore\Admin\Grid\Tools\AbstractTool|string, Exceedone\Exment\Form\Tools\CustomTableMenuAjaxButton given */ + // @phpstan-ignore-next-line $tools->append(new Tools\CustomTableMenuAjaxButton()); }); @@ -202,7 +207,7 @@ protected function grid() // add data if ($custom_table->hasPermission(Permission::AVAILABLE_VIEW_CUSTOM_VALUE)) { $linker = (new Linker()) - /** @phpstan-ignore-next-line Cannot call method getGridUrl() on stdClass. */ + // @phpstan-ignore-next-line ->url($actions->row->getGridUrl()) ->icon('fa-database') ->tooltip(exmtrans('change_page_menu.custom_value')); @@ -240,6 +245,7 @@ protected function grid() * * @return Form */ + // @phpstan-ignore-next-line protected function form($id = null) { $form = new Form(new CustomTable()); @@ -386,7 +392,7 @@ protected function form($id = null) $form->saved(function (Form $form) { // create or drop index -------------------------------------------------- $model = $form->model(); - /** @phpstan-ignore-next-line fix laravel-admin documentation */ + // @phpstan-ignore-next-line $model->createTable(); // redirect custom column page @@ -407,6 +413,7 @@ protected function form($id = null) * * @return ?string */ + // @phpstan-ignore-next-line protected function confirmDeleteButton($id = null) { if (is_null($id)) { @@ -466,6 +473,7 @@ protected function confirmDeleteButton($id = null) * * @return Form */ + // @phpstan-ignore-next-line protected function formMultiColumn($id = null) { $form = new Form(new CustomTable()); @@ -609,6 +617,7 @@ protected function formMultiColumn($id = null) * * @return Form */ + // @phpstan-ignore-next-line protected function formQrCodeSetting($id = null) { $form = new Form(new CustomTable()); @@ -688,6 +697,7 @@ protected function formQrCodeSetting($id = null) * * @return Form */ + // @phpstan-ignore-next-line protected function formJanCodeSetting($id = null) { $form = new Form(new CustomTable()); @@ -746,6 +756,7 @@ protected function formJanCodeSetting($id = null) * @param array $selectOptions * @return array|mixed[] */ + // @phpstan-ignore-next-line protected function getColumnsSelectOptions($custom_table, $selectOptions = []) { $options = collect(CompareColumnType::transArray('custom_table.custom_column_multi.compare_column_options')) @@ -812,6 +823,7 @@ public function update($id) /** * add menu after saved */ + // @phpstan-ignore-next-line protected function addMenuAfterSaved($model) { // if has value 'add_parent_menu', add menu @@ -852,6 +864,7 @@ protected function addMenuAfterSaved($model) /** * add notofy after saved */ + // @phpstan-ignore-next-line protected function addNotifyAfterSaved($model) { // if has value 'add_parent_menu', add menu @@ -889,6 +902,7 @@ protected function addNotifyAfterSaved($model) * validate before delete. * @param int|string $id */ + // @phpstan-ignore-next-line protected function validateDestroy($id) { return CustomTable::validateDestroy($id); @@ -968,6 +982,7 @@ public function copyModal(Request $request, $id) * @param $id * @return Response */ + // @phpstan-ignore-next-line public function copyTable(Request $request, $id) { /** @var ExmentCustomValidator $validator */ diff --git a/src/Controllers/CustomValueController.php b/src/Controllers/CustomValueController.php index 5f36b0823..0d372cc96 100644 --- a/src/Controllers/CustomValueController.php +++ b/src/Controllers/CustomValueController.php @@ -82,6 +82,7 @@ public function __construct(?CustomTable $custom_table, Request $request) * @param int $id * @return bool|Response|\Illuminate\Http\RedirectResponse|\Illuminate\Http\Response|\Illuminate\Routing\Redirector */ + // @phpstan-ignore-next-line public function update($tableKey, $id) { $request = request(); @@ -112,6 +113,7 @@ public function store() * @param int $id * @return bool|Response|\Illuminate\Http\RedirectResponse|\Illuminate\Http\Response|\Illuminate\Routing\Redirector */ + // @phpstan-ignore-next-line public function destroy($tableKey, $id) { $request = request(); @@ -183,7 +185,7 @@ public function index(Request $request, Content $content) } $form = $this->form($id)->edit($id); $form->setAction(admin_url("data/{$this->custom_table->table_name}/$id")); - /** @phpstan-ignore-next-line constructor expects string, Encore\Admin\Form given */ + // @phpstan-ignore-next-line $row = new Row($form); } // no record @@ -195,7 +197,7 @@ public function index(Request $request, Content $content) } $form = $this->form(null); $form->setAction(admin_url("data/{$this->custom_table->table_name}")); - /** @phpstan-ignore-next-line constructor expects string, Encore\Admin\Form given*/ + // @phpstan-ignore-next-line $row = new Row($form); } @@ -319,7 +321,7 @@ public function create(Request $request, Content $content) } } - /** @phpstan-ignore-next-line constructor expects string, Encore\Admin\Form given */ + // @phpstan-ignore-next-line $row = new Row($form); $row->class([static::CLASSNAME_CUSTOM_VALUE_FORM, static::CLASSNAME_CUSTOM_VALUE_PREFIX . $this->custom_table->table_name]); $row->attribute([ @@ -364,7 +366,7 @@ public function edit(Request $request, Content $content, $tableKey, $id) 'page_type' => PluginPageType::EDIT, 'custom_value' => $custom_value ]); - /** @phpstan-ignore-next-line constructor expects string, Encore\Admin\Form given */ + // @phpstan-ignore-next-line $row = new Row($this->form($id)->edit($id)); $row->class([static::CLASSNAME_CUSTOM_VALUE_FORM, static::CLASSNAME_CUSTOM_VALUE_PREFIX . $this->custom_table->table_name]); $row->attribute([ @@ -441,6 +443,7 @@ public function show(Request $request, Content $content, $tableKey, $id) /** * compare */ + // @phpstan-ignore-next-line public function compare(Request $request, Content $content, $tableKey, $id) { $this->firstFlow($request, CustomValuePageType::SHOW, $id); @@ -455,6 +458,7 @@ public function compare(Request $request, Content $content, $tableKey, $id) /** * get compare item for pjax */ + // @phpstan-ignore-next-line public function compareitem(Request $request, Content $content, $tableKey, $id) { $this->firstFlow($request, CustomValuePageType::SHOW, $id); @@ -467,6 +471,7 @@ public function compareitem(Request $request, Content $content, $tableKey, $id) /** * restore data */ + // @phpstan-ignore-next-line public function restoreRevision(Request $request, $tableKey, $id) { $this->firstFlow($request, CustomValuePageType::EDIT, $id); @@ -481,6 +486,7 @@ public function restoreRevision(Request $request, $tableKey, $id) /** * for file upload function. */ + // @phpstan-ignore-next-line public function fileupload(Request $request, $tableKey, $id) { if (($response = $this->firstFlow($request, CustomValuePageType::SHOW, $id)) instanceof Response) { @@ -493,6 +499,7 @@ public function fileupload(Request $request, $tableKey, $id) /** * file delete custom column. */ + // @phpstan-ignore-next-line public function filedelete(Request $request, $tableKey, $id) { if (($response = $this->firstFlow($request, CustomValuePageType::EDIT, $id)) instanceof Response) { @@ -506,6 +513,7 @@ public function filedelete(Request $request, $tableKey, $id) /** * add comment. */ + // @phpstan-ignore-next-line public function addComment(Request $request, $tableKey, $id) { if (($response = $this->firstFlow($request, CustomValuePageType::SHOW, $id)) instanceof Response) { @@ -521,6 +529,7 @@ public function addComment(Request $request, $tableKey, $id) /** * remove comment. */ + // @phpstan-ignore-next-line public function deleteComment(Request $request, $tableKey, $id, $suuid) { if (($response = $this->firstFlow($request, CustomValuePageType::SHOW, $id)) instanceof Response) { @@ -535,6 +544,7 @@ public function deleteComment(Request $request, $tableKey, $id, $suuid) /** * @param Request $request */ + // @phpstan-ignore-next-line public function import(Request $request) { if (($response = $this->firstFlow($request, CustomValuePageType::IMPORT)) instanceof Response) { @@ -548,6 +558,7 @@ public function import(Request $request) /** * get import modal */ + // @phpstan-ignore-next-line public function importModal(Request $request, $tableKey) { if (($response = $this->firstFlow($request, CustomValuePageType::IMPORT)) instanceof Response) { @@ -565,6 +576,7 @@ public function importModal(Request $request, $tableKey) * @param Request $request * @return Response */ + // @phpstan-ignore-next-line public function pluginClick(Request $request, $tableKey, $id = null) { if ($request->input('uuid') === null) { @@ -612,6 +624,7 @@ public function pluginClick(Request $request, $tableKey, $id = null) * @param $id * @return array|Response */ + // @phpstan-ignore-next-line public function operationClick(Request $request, $tableKey, $id = null) { $ids = !is_nullorempty($id) ? $id : $request->input('id'); @@ -659,6 +672,7 @@ public function operationClick(Request $request, $tableKey, $id = null) * @param $id * @return bool|Response|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|Response */ + // @phpstan-ignore-next-line public function workflowHistoryModal(Request $request, $tableKey, $id = null) { if (($response = $this->firstFlow($request, CustomValuePageType::SHOW, $id)) instanceof Response) { @@ -682,6 +696,7 @@ public function workflowHistoryModal(Request $request, $tableKey, $id = null) /** * get action modal */ + // @phpstan-ignore-next-line public function actionModal(Request $request, $tableKey, $id) { if (is_null($id) || $request->input('action_id') === null) { @@ -693,6 +708,7 @@ public function actionModal(Request $request, $tableKey, $id) abort(404); } + // @phpstan-ignore-next-line return $action->actionModal($this->custom_table->getValueModel($id)); } @@ -704,6 +720,7 @@ public function actionModal(Request $request, $tableKey, $id) * @param $id * @return array */ + // @phpstan-ignore-next-line public function actionClick(Request $request, $tableKey, $id) { if (is_null($id) || $request->input('action_id') === null) { @@ -720,6 +737,7 @@ public function actionClick(Request $request, $tableKey, $id) //validation $workflow_actions = $custom_value->getWorkflowActions(true); if (!$workflow_actions->contains(function($workflow_action) use($action){ + // @phpstan-ignore-next-line return $workflow_action->id == $action->id; })) { return ([ @@ -728,6 +746,7 @@ public function actionClick(Request $request, $tableKey, $id) ]); } + // @phpstan-ignore-next-line $action->executeAction($custom_value, [ 'comment' => $request->get('comment'), 'next_work_users' => $request->get('next_work_users'), @@ -743,6 +762,7 @@ public function actionClick(Request $request, $tableKey, $id) /** * get copy modal */ + // @phpstan-ignore-next-line public function copyModal(Request $request, $tableKey, $id) { if ($request->input('uuid') === null) { @@ -797,6 +817,7 @@ public function copyModal(Request $request, $tableKey, $id) /** * get operation modal */ + // @phpstan-ignore-next-line public function operationModal(Request $request, $tableKey, $id = null) { if ($request->input('suuid') === null) { @@ -864,6 +885,7 @@ public function operationModal(Request $request, $tableKey, $id = null) * @param $id * @return Response */ + // @phpstan-ignore-next-line public function copyClick(Request $request, $tableKey, $id = null) { if ($request->input('uuid') === null) { @@ -889,6 +911,7 @@ public function copyClick(Request $request, $tableKey, $id = null) /** * create notify mail send form */ + // @phpstan-ignore-next-line public function notifyClick(Request $request, $tableKey, $id = null) { $targetid = $request->get('targetid'); @@ -922,6 +945,7 @@ public function notifyClick(Request $request, $tableKey, $id = null) /** * create share form */ + // @phpstan-ignore-next-line public function shareClick(Request $request, $tableKey, $id) { // get customvalue @@ -938,6 +962,7 @@ public function shareClick(Request $request, $tableKey, $id) /** * restore trashed value */ + // @phpstan-ignore-next-line public function restoreClick(Request $request, $tableKey, $id) { return $this->restore($request, $tableKey, $id); @@ -946,6 +971,7 @@ public function restoreClick(Request $request, $tableKey, $id) /** * restore trashed value */ + // @phpstan-ignore-next-line public function rowRestore(Request $request, $tableKey) { return $this->restore($request, $tableKey, $request->get('id')); @@ -954,6 +980,7 @@ public function rowRestore(Request $request, $tableKey) /** * set notify target users and get form */ + // @phpstan-ignore-next-line public function sendTargetUsers(Request $request, $tableKey, $id = null) { $service = $this->getNotifyService($tableKey, $id); @@ -974,6 +1001,7 @@ public function sendTargetUsers(Request $request, $tableKey, $id = null) /** * send mail */ + // @phpstan-ignore-next-line public function sendMail(Request $request, $tableKey, $id = null) { $service = $this->getNotifyService($tableKey, $id); @@ -985,6 +1013,7 @@ public function sendMail(Request $request, $tableKey, $id = null) /** * set share users organizations */ + // @phpstan-ignore-next-line public function sendShares(Request $request, $tableKey, $id) { // get customvalue @@ -1004,6 +1033,7 @@ protected function form($id = null) return $form_item->id($id)->form(); } + // @phpstan-ignore-next-line protected function restore(Request $request, $tableKey, $id) { $ids = stringToArray($id); @@ -1045,6 +1075,7 @@ protected function restore(Request $request, $tableKey, $id) ]); } + // @phpstan-ignore-next-line protected function getNotifyService($tableKey, $id) { $targetid = request()->get('mail_template_id'); @@ -1064,6 +1095,7 @@ protected function getNotifyService($tableKey, $id) /** * Check whether user has edit permission */ + // @phpstan-ignore-next-line protected function redirectShow($id) { if (!$this->custom_table->hasPermissionEditData($id)) { @@ -1076,6 +1108,7 @@ protected function redirectShow($id) * First flow. check role and set form and view id etc. * different logic for new, update or show */ + // @phpstan-ignore-next-line protected function firstFlow(Request $request, $formActionType, $id = null) { // if this custom_table doesn't have custom_columns, redirect custom_column's page(admin) or back @@ -1102,6 +1135,7 @@ protected function firstFlow(Request $request, $formActionType, $id = null) $code = $custom_value ? $custom_value->enableEdit(true) : $this->custom_table->getNoDataErrorCode($id); } elseif ($formActionType == CustomValuePageType::SHOW) { $custom_value = $this->custom_table->getValueModel($id, $trashed && $this->custom_table->enableShowTrashed() === true); + // @phpstan-ignore-next-line $code = $custom_value ? $custom_value->enableAccess(true) : $this->custom_table->getNoDataErrorCode($id); } elseif ($formActionType == CustomValuePageType::GRID) { $code = $this->custom_table->enableView(); @@ -1118,6 +1152,7 @@ protected function firstFlow(Request $request, $formActionType, $id = null) } if ($code !== true) { + // @phpstan-ignore-next-line Checker::error($code->getMessage()); return false; } @@ -1128,6 +1163,7 @@ protected function firstFlow(Request $request, $formActionType, $id = null) /** * validate before delete. */ + // @phpstan-ignore-next-line protected function validateDestroy($id) { return $this->custom_table->validateValueDestroy($id); @@ -1137,6 +1173,7 @@ protected function validateDestroy($id) * set view and form info. * use session etc */ + // @phpstan-ignore-next-line protected function setFormViewInfo(Request $request, $formActionType, $id = null) { // set view @@ -1171,6 +1208,7 @@ protected function filterCopyColumn(CustomValue $custom_value) /** * create qrcode form */ + // @phpstan-ignore-next-line protected function formCreateQrcode(Request $request, $table_id) { $form = new ModalForm(); @@ -1190,6 +1228,7 @@ protected function formCreateQrcode(Request $request, $table_id) /** * create qrcode and assign to data */ + // @phpstan-ignore-next-line protected function createQrCode(Request $request, $table_id) { $qr_number = $request->get('qr_number'); @@ -1225,6 +1264,7 @@ protected function createQrCode(Request $request, $table_id) /** * download qrcode to pdf */ + // @phpstan-ignore-next-line protected function qrcodeDownload(Request $request, $table_id) { $selected_custom_value_id = $request->get('select_ids'); @@ -1241,6 +1281,7 @@ protected function qrcodeDownload(Request $request, $table_id) /** * download qrcode response */ + // @phpstan-ignore-next-line protected function qrCreateOrDownloadResponse($tmpPath, $fileName, $isCreate = false, $table_id = null) { if (isset($tmpPath) && $table_id) { @@ -1273,6 +1314,7 @@ protected function qrCreateOrDownloadResponse($tmpPath, $fileName, $isCreate = f * * @return array */ + // @phpstan-ignore-next-line protected function createPdf($selected_custom_value_id, $table_id) { $selected_custom_values = CustomTable::getEloquent($table_id)->getValueModel()->whereIn('id', $selected_custom_value_id)->get(); @@ -1321,9 +1363,9 @@ protected function createPdf($selected_custom_value_id, $table_id) $tmpPath = getFullpath($fileName, Define::DISKNAME_ADMIN_TMP); /** @phpstan-ignore-next-line Instantiated class Elibyy\TCPDF\Facades\TCPDF not found. */ $pdf = new TCPDF; - /** @phpstan-ignore-next-line Call to static method setAutoPageBreak() on an unknown class Elibyy\TCPDF\Facades\TCPDF. */ + // @phpstan-ignore-next-line $pdf::setAutoPageBreak(true, 0); - /** @phpstan-ignore-next-line Call to static method AddPage() on an unknown class Elibyy\TCPDF\Facades\TCPDF. */ + // @phpstan-ignore-next-line $pdf::AddPage('P', 'mm', array(210, 297), true, 'UTF-8', false); $count = 0; @@ -1332,7 +1374,7 @@ protected function createPdf($selected_custom_value_id, $table_id) if (($checkWidth + 1) * $_img_width <= (210 - $margin_left * 2 - ($col_per_page - 1) * $col_spacing)) { $pos_x = ($margin_left + ($_img_width + $col_spacing) * $checkWidth); $pos_y = ($margin_top + ($_img_height + $row_spacing) * $count); - /** @phpstan-ignore-next-line Call to static method Image() on an unknown class Elibyy\TCPDF\Facades\TCPDF. */ + // @phpstan-ignore-next-line $pdf::Image($img, $pos_x, $pos_y, $_img_width, $_img_height); $checkWidth++; } else { @@ -1340,16 +1382,16 @@ protected function createPdf($selected_custom_value_id, $table_id) $count++; if (($count + 1) * $_img_height > 297 - $margin_top * 2 - ($row_per_page - 1) * $row_spacing) { $count = 0; - /** @phpstan-ignore-next-line Call to static method AddPage() on an unknown class Elibyy\TCPDF\Facades\TCPDF. */ + // @phpstan-ignore-next-line $pdf::AddPage('P', 'mm', array(210, 297), true, 'UTF-8', false); } $pos_x = $margin_left; $pos_y = ($margin_top + ($_img_height + $row_spacing) * $count); - /** @phpstan-ignore-next-line Call to static method Image() on an unknown class Elibyy\TCPDF\Facades\TCPDF. */ + // @phpstan-ignore-next-line $pdf::Image($img, $pos_x, $pos_y, $_img_width, $_img_height); } } - /** @phpstan-ignore-next-line Call to static method Output() on an unknown class Elibyy\TCPDF\Facades\TCPDF. */ + // @phpstan-ignore-next-line $pdf::Output($tmpPath, 'F'); foreach ($img_arr as $value) { @@ -1369,6 +1411,7 @@ protected function createPdf($selected_custom_value_id, $table_id) * * @return array */ + // @phpstan-ignore-next-line protected function createStickerImg($selected_id, $sticker_img_width, $sticker_img_height, $selected_custom_value, $refer_column_value = null) { $qr_file_name = 'qrcode_id-' . $selected_id . '_' . Carbon::now()->format('YmdHis') . '.png'; @@ -1388,15 +1431,19 @@ protected function createStickerImg($selected_id, $sticker_img_width, $sticker_i $sticker_file_path = getFullpath($sticker_file_name, Define::DISKNAME_ADMIN_TMP); $sticker_img = imagecreatetruecolor($sticker_img_width, $sticker_img_height); + // @phpstan-ignore-next-line $white = imagecolorallocate($sticker_img, 255, 255, 255); + // @phpstan-ignore-next-line $black = imagecolorallocate($sticker_img, 0, 0, 0); $font = base_path('public/font/MS_Gothic.ttf'); imagefilledrectangle( + // @phpstan-ignore-next-line $sticker_img, 0, 0, $sticker_img_width, $sticker_img_height, + // @phpstan-ignore-next-line $white ); $text_center_x = $sticker_img_width - ($sticker_img_width - $qr_img_width - $img_margin_top_right) / 2; @@ -1412,11 +1459,13 @@ protected function createStickerImg($selected_id, $sticker_img_width, $sticker_i $x_cordinate = $text_center_x - $width_ww / 2; $font_size = ($sticker_img_width > 280) ? (floor($size_ww * 0.6)) : (floor($size_ww * 0.5)); imagettftext( + // @phpstan-ignore-next-line $sticker_img, $font_size, 0, intval($x_cordinate), intval(($sticker_img_height + $height_ww) / 3), + // @phpstan-ignore-next-line $black, $font, $text_qr @@ -1424,17 +1473,20 @@ protected function createStickerImg($selected_id, $sticker_img_width, $sticker_i if ($refer_column_value) { $y_cordinate = ($sticker_img_height - $img_margin_top_right) / 3 * 2; $bbox = imagettfbbox($font_size, 0, $font, $refer_column_value); + // @phpstan-ignore-next-line $text_width = floor(strlen($refer_column_value) / ($bbox[2] / ($sticker_img_width / 2))); $wrapped_text = wordwrap($refer_column_value, $text_width > 24 ? 24 : 15, "\n", true); $lines = explode("\n", $wrapped_text); foreach ($lines as $key => $line) { if ($key < 2) { imagettftext( + // @phpstan-ignore-next-line $sticker_img, $font_size, 0, intval($x_cordinate), intval($y_cordinate), + // @phpstan-ignore-next-line $black, $font, $line @@ -1444,7 +1496,9 @@ protected function createStickerImg($selected_id, $sticker_img_width, $sticker_i } } imagecopyresized( + // @phpstan-ignore-next-line $sticker_img, + // @phpstan-ignore-next-line $qr_img, intval($img_margin_top_right), intval($img_margin_top_right), @@ -1455,9 +1509,12 @@ protected function createStickerImg($selected_id, $sticker_img_width, $sticker_i 200, 200 ); + // @phpstan-ignore-next-line imagepng($sticker_img, $sticker_file_path); + // @phpstan-ignore-next-line imagedestroy($sticker_img); + // @phpstan-ignore-next-line imagedestroy($qr_img); $this->deleteTmpFile($qr_file_path); @@ -1470,6 +1527,7 @@ protected function createStickerImg($selected_id, $sticker_img_width, $sticker_i * * @return void */ + // @phpstan-ignore-next-line protected function deleteTmpFile($file_path) { if (\File::exists($file_path)) { @@ -1485,6 +1543,7 @@ protected function deleteTmpFile($file_path) * * @return string */ + // @phpstan-ignore-next-line protected function createQRUrl($selected_id) { $url = admin_urls('qr-code', $this->custom_table->table_name, $selected_id); @@ -1496,6 +1555,7 @@ protected function createQRUrl($selected_id) * * @return float */ + // @phpstan-ignore-next-line protected function mmToPixel($mmVal) { $one_mm_to_pixel = 3.7795275591; @@ -1507,6 +1567,7 @@ protected function mmToPixel($mmVal) * * @param Content $content */ + // @phpstan-ignore-next-line protected function setHiddens($content) { $gridrow_select_transition = $this->custom_table->getOption('gridrow_select_transition'); diff --git a/src/Controllers/CustomViewController.php b/src/Controllers/CustomViewController.php index 846b1b933..eb14c73d6 100644 --- a/src/Controllers/CustomViewController.php +++ b/src/Controllers/CustomViewController.php @@ -128,7 +128,7 @@ protected function grid() $grid->disableExport(); $grid->actions(function (Grid\Displayers\Actions $actions) use ($custom_table) { $table_name = $custom_table->table_name; - /** @phpstan-ignore-next-line Cannot call method hasEditPermission() on stdClass. */ + // @phpstan-ignore-next-line if (boolval($actions->row->hasEditPermission())) { if (boolval($actions->row->disabled_delete)) { $actions->disableDelete(); @@ -170,9 +170,9 @@ protected function grid() $grid->disableCreateButton(); $grid->tools(function (Grid\Tools $tools) { - /** @phpstan-ignore-next-line append() expects Encore\Admin\Grid\Tools\AbstractTool|string, Exceedone\Exment\Form\Tools\CustomViewMenuButton given */ + // @phpstan-ignore-next-line $tools->append(new Tools\CustomViewMenuButton($this->custom_table, null, false)); - /** @phpstan-ignore-next-line expects Encore\Admin\Grid\Tools\AbstractTool|string, Exceedone\Exment\Form\Tools\CustomTableMenuButton given */ + // @phpstan-ignore-next-line $tools->append(new Tools\CustomTableMenuButton('view', $this->custom_table)); }); @@ -196,6 +196,7 @@ protected function grid() * * @return Form */ + // @phpstan-ignore-next-line protected function form($id = null, $copy_id = null) { // get request @@ -243,6 +244,7 @@ protected function form($id = null, $copy_id = null) if ($request->has('plugin')) { $plugin = $request->get('plugin'); } elseif (isset($model) && $view_kind_type == ViewKindType::PLUGIN) { + // @phpstan-ignore-next-line $plugin = Plugin::find($model->getOption('plugin_id'))->uuid; } @@ -325,7 +327,7 @@ protected function form($id = null, $copy_id = null) if (request()->has('plugin') && !is_null($plugin = request()->get('plugin'))) { $plugin = Plugin::getPluginByUUID($plugin); if (isset($plugin)) { - /** @phpstan-ignore-next-line fix laravel-admin documentation */ + // @phpstan-ignore-next-line $form->model()->setOption('plugin_id', $plugin->id); } } @@ -347,7 +349,7 @@ protected function form($id = null, $copy_id = null) }); $form->tools(function (Form\Tools $tools) use ($id, $suuid, $custom_table, $view_type, $view_kind_type) { - /** @phpstan-ignore-next-line add() expects string, Exceedone\Exment\Form\Tools\CustomTableMenuButton given */ + // @phpstan-ignore-next-line $tools->add((new Tools\CustomTableMenuButton('view', $custom_table))); if ($view_type == Enums\ViewType::USER) { @@ -375,6 +377,7 @@ protected function form($id = null, $copy_id = null) /** * get filter condition */ + // @phpstan-ignore-next-line public function getSummaryCondition(Request $request) { $view_column_target = $request->get('q'); @@ -398,6 +401,7 @@ public function getSummaryCondition(Request $request) }); } + // @phpstan-ignore-next-line public function getGroupCondition(Request $request) { return DataGrid\SummaryGrid::getGroupCondition($request->get('q')); @@ -407,6 +411,7 @@ public function getGroupCondition(Request $request) * validation table * @param mixed $table id or customtable */ + // @phpstan-ignore-next-line protected function validateTable($table, $role_name) { if (!$this->custom_table->hasViewPermission()) { @@ -419,6 +424,7 @@ protected function validateTable($table, $role_name) /** * get filter condition */ + // @phpstan-ignore-next-line public function getFilterCondition(Request $request) { $item = $this->getConditionItem($request, $request->get('q')); @@ -428,6 +434,7 @@ public function getFilterCondition(Request $request) return $item->getFilterCondition(); } + // @phpstan-ignore-next-line protected function getConditionItem(Request $request, $target) { $item = ConditionItemBase::getItemByRequest($this->custom_table, $target); @@ -447,6 +454,7 @@ protected function getConditionItem(Request $request, $target) /** * create share form */ + // @phpstan-ignore-next-line public function shareClick(Request $request, $tableKey, $id) { // get custom view @@ -464,6 +472,7 @@ public function shareClick(Request $request, $tableKey, $id) /** * set share users organizations */ + // @phpstan-ignore-next-line public function sendShares(Request $request, $tableKey, $id) { // get custom view @@ -475,6 +484,7 @@ public function sendShares(Request $request, $tableKey, $id) * validate before delete. * @param int|string $id */ + // @phpstan-ignore-next-line protected function validateDestroy($id) { return CustomView::validateDestroy($id); diff --git a/src/Controllers/DashboardBoxController.php b/src/Controllers/DashboardBoxController.php index 871f8de7e..4b581d89f 100644 --- a/src/Controllers/DashboardBoxController.php +++ b/src/Controllers/DashboardBoxController.php @@ -19,9 +19,13 @@ class DashboardBoxController extends AdminControllerBase { use HasResourceActions; + // @phpstan-ignore-next-line protected $dashboard; + // @phpstan-ignore-next-line protected $dashboard_box_type; + // @phpstan-ignore-next-line protected $row_no; + // @phpstan-ignore-next-line protected $column_no; public function __construct() @@ -46,6 +50,7 @@ public function index(Request $request, Content $content) * @param $suuid * @return \Illuminate\Http\JsonResponse */ + // @phpstan-ignore-next-line public function delete(Request $request, $suuid) { // get suuid @@ -67,6 +72,7 @@ public function delete(Request $request, $suuid) /** * get box html from ajax */ + // @phpstan-ignore-next-line public function getHtml($suuid) { // get dashboardbox object @@ -95,6 +101,7 @@ public function getHtml($suuid) * @param $id * @return Form|\Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ + // @phpstan-ignore-next-line protected function form($id = null) { $form = new Form(new DashboardBox()); @@ -138,6 +145,7 @@ protected function form($id = null) return $form; } + // @phpstan-ignore-next-line protected function manageFormSaving($form) { // before saving @@ -157,6 +165,7 @@ protected function manageFormSaving($form) /** * get dashboard info using id, or query */ + // @phpstan-ignore-next-line protected function getDashboardInfo($id) { // set info with query -------------------------------------------------- @@ -220,6 +229,7 @@ protected function getDashboardInfo($id) * @param $dashboard_type * @return array|Collection */ + // @phpstan-ignore-next-line public function tableViews(Request $request, $dashboard_type) { $id = $request->get('q'); @@ -253,6 +263,7 @@ public function tableViews(Request $request, $dashboard_type) return array('id' => $value->id, 'text' => $value->view_view_name); }); // if count > 0, return value. + // @phpstan-ignore-next-line if (!is_null($views) && count($views) > 0) { return $views; } @@ -270,6 +281,7 @@ public function tableViews(Request $request, $dashboard_type) * @param $axis_type * @return array */ + // @phpstan-ignore-next-line public function chartAxis(Request $request, $axis_type) { $id = $request->get('q'); @@ -282,6 +294,7 @@ public function chartAxis(Request $request, $axis_type) return $custom_view->getViewColumnsSelectOptions($axis_type == 'y'); } + // @phpstan-ignore-next-line protected function rednerHtml($item) { return $item instanceof \Illuminate\Contracts\Support\Renderable ? $item->render() : $item; diff --git a/src/Controllers/DashboardController.php b/src/Controllers/DashboardController.php index 8d4cdf571..5067b62a9 100644 --- a/src/Controllers/DashboardController.php +++ b/src/Controllers/DashboardController.php @@ -25,6 +25,7 @@ class DashboardController extends AdminControllerBase { use HasResourceActions; + // @phpstan-ignore-next-line protected $dashboard; public function __construct() @@ -32,6 +33,7 @@ public function __construct() $this->setPageInfo(exmtrans("dashboard.header"), exmtrans("dashboard.header"), null, 'fa-home'); } + // @phpstan-ignore-next-line protected function setDashboardInfo(Request $request) { $this->dashboard = Dashboard::getDefault(); @@ -87,6 +89,7 @@ public function create(Request $request, Content $content) return parent::create($request, $content); } + // @phpstan-ignore-next-line public function home(Request $request, Content $content) { // check permission. if not permission, show message @@ -239,6 +242,7 @@ function loadDashboardBox(suuid, url){ * * @return Form */ + // @phpstan-ignore-next-line protected function form($id = null) { $form = new Form(new Dashboard()); @@ -410,6 +414,7 @@ protected function setDashboardBox($content, $row_column_count, $row_no) }); } + // @phpstan-ignore-next-line protected function showVersionUpdate() { // if system admin, check version @@ -431,6 +436,7 @@ protected function showVersionUpdate() /** * create share form */ + // @phpstan-ignore-next-line public function shareClick(Request $request, $id) { $model = Dashboard::getEloquent($id); @@ -447,6 +453,7 @@ public function shareClick(Request $request, $id) /** * set share users organizations */ + // @phpstan-ignore-next-line public function sendShares(Request $request, $id) { // get custom view diff --git a/src/Controllers/ErrorController.php b/src/Controllers/ErrorController.php index ba6a26513..f4da7fcd9 100644 --- a/src/Controllers/ErrorController.php +++ b/src/Controllers/ErrorController.php @@ -19,9 +19,10 @@ class ErrorController extends Controller /** * Index interface. */ + // @phpstan-ignore-next-line public function error(Request $request, $exception) { - /** @phpstan-ignore-next-line response expects array|Illuminate\Contracts\View\View|string|null, Encore\Admin\Layout\Content given */ + // @phpstan-ignore-next-line return response(Admin::content(function (Content $content) use ($exception) { $content->header(exmtrans('error.header')); $content->description(exmtrans('error.description')); @@ -53,12 +54,13 @@ public function error(Request $request, $exception) ->default(exmtrans("error.check_error_log")) ; } - /** @phpstan-ignore-next-line constructor expects string, Encore\Admin\Widgets\Form given */ + // @phpstan-ignore-next-line $content->row(new Box(exmtrans("error.header"), $form)); })); } + // @phpstan-ignore-next-line public function maintenance() { return response(view('exment::exception.maintenance', [ diff --git a/src/Controllers/ExmentControllerTrait.php b/src/Controllers/ExmentControllerTrait.php index ecad57600..f7d0593bc 100644 --- a/src/Controllers/ExmentControllerTrait.php +++ b/src/Controllers/ExmentControllerTrait.php @@ -7,11 +7,16 @@ trait ExmentControllerTrait { + // @phpstan-ignore-next-line protected $title; + // @phpstan-ignore-next-line protected $header; + // @phpstan-ignore-next-line protected $description; + // @phpstan-ignore-next-line protected $headericon; + // @phpstan-ignore-next-line protected function setPageInfo($title = null, $header = null, $description = null, $headericon = null) { if (isset($header)) { @@ -28,6 +33,7 @@ protected function setPageInfo($title = null, $header = null, $description = nul } } + // @phpstan-ignore-next-line protected function AdminContent($content) { if (isset($this->header)) { @@ -48,6 +54,7 @@ protected function AdminContent($content) * validation table * @param mixed $table id or customtable */ + // @phpstan-ignore-next-line protected function validateTable($table, $role_name) { $table = CustomTable::getEloquent($table); diff --git a/src/Controllers/FileController.php b/src/Controllers/FileController.php index c477fb688..359b6409d 100644 --- a/src/Controllers/FileController.php +++ b/src/Controllers/FileController.php @@ -23,6 +23,7 @@ class FileController extends AdminControllerBase /** * Download file (call as web) */ + // @phpstan-ignore-next-line public function download(Request $request, $uuid) { return static::downloadFile($uuid); @@ -31,6 +32,7 @@ public function download(Request $request, $uuid) /** * Download file (call as publicform) */ + // @phpstan-ignore-next-line public function downloadPublicForm(Request $request, $publicFormUuid, $uuid) { return static::downloadFile($uuid); @@ -39,6 +41,7 @@ public function downloadPublicForm(Request $request, $publicFormUuid, $uuid) /** * Download file (call as web) */ + // @phpstan-ignore-next-line public function downloadTable(Request $request, $tableKey, $uuid) { return static::downloadFile(url_join($tableKey, $uuid)); @@ -47,6 +50,7 @@ public function downloadTable(Request $request, $tableKey, $uuid) /** * Delete file (call as web) */ + // @phpstan-ignore-next-line public function delete(Request $request, $uuid) { return static::deleteFile($uuid); @@ -55,6 +59,7 @@ public function delete(Request $request, $uuid) /** * Delete file (call as web) */ + // @phpstan-ignore-next-line public function deleteTable(Request $request, $tableKey, $uuid) { return static::deleteFile(url_join($tableKey, $uuid)); @@ -65,6 +70,7 @@ public function deleteTable(Request $request, $tableKey, $uuid) /** * Download file (call as Api) */ + // @phpstan-ignore-next-line public function downloadApi(Request $request, $uuid) { return static::downloadFile( @@ -79,6 +85,7 @@ public function downloadApi(Request $request, $uuid) /** * Download file (call as Api) */ + // @phpstan-ignore-next-line public function downloadTableApi(Request $request, $tableKey, $uuid) { return static::downloadFile( @@ -93,6 +100,7 @@ public function downloadTableApi(Request $request, $tableKey, $uuid) /** * Delete file (call as Api) */ + // @phpstan-ignore-next-line public function deleteApi(Request $request, $uuid) { return static::deleteFile( @@ -106,6 +114,7 @@ public function deleteApi(Request $request, $uuid) /** * Delete file (call as Api) */ + // @phpstan-ignore-next-line public function deleteTableApi(Request $request, $tableKey, $uuid) { return static::deleteFile( @@ -120,6 +129,7 @@ public function deleteTableApi(Request $request, $tableKey, $uuid) /** * Download favicon image */ + // @phpstan-ignore-next-line public function downloadFavicon() { return static::downloadFileByKey('site_favicon'); @@ -128,6 +138,7 @@ public function downloadFavicon() /** * Download Login image */ + // @phpstan-ignore-next-line public function downloadLoginBackground() { return static::downloadFileByKey('login_page_image'); @@ -136,6 +147,7 @@ public function downloadLoginBackground() /** * Download Login Header */ + // @phpstan-ignore-next-line public function downloadLoginHeader() { return static::downloadFileByKey('site_logo'); @@ -162,6 +174,7 @@ public static function downloadFileByKey(string $key) /** * Download file */ + // @phpstan-ignore-next-line public static function downloadFile($uuid, $options = []) { $options = array_merge( @@ -218,6 +231,7 @@ public static function downloadFile($uuid, $options = []) // create response $response = Response::make($file, 200); + // @phpstan-ignore-next-line $response->header("Content-Type", $type); // Disposition is attachment because inline is SVG XSS. @@ -230,6 +244,7 @@ public static function downloadFile($uuid, $options = []) /** * Download temporary upload file */ + // @phpstan-ignore-next-line public static function downloadTemp($uuid, $options = []) { $filename = pathinfo($uuid, PATHINFO_FILENAME); @@ -247,6 +262,7 @@ public static function downloadTemp($uuid, $options = []) // create response $response = Response::make($file, 200); + // @phpstan-ignore-next-line $response->header("Content-Type", $type); // Disposition is attachment because inline is SVG XSS. @@ -258,6 +274,7 @@ public static function downloadTemp($uuid, $options = []) /** * Delete file and document info */ + // @phpstan-ignore-next-line public static function deleteFile($uuid, $options = []) { $options = array_merge( @@ -315,6 +332,7 @@ public static function deleteFile($uuid, $options = []) $custom_value = $custom_table->getValueModel()->find($data->parent_id); } if (isset($custom_value) && isset($custom_column)) { + // @phpstan-ignore-next-line $current_val = $custom_value->getValue($custom_column->column_name); if($custom_column->column_type == ColumnType::IMAGE || $custom_column->column_type == ColumnType::FILE) { if($current_val instanceof \Illuminate\Support\Collection) { @@ -341,7 +359,9 @@ public static function deleteFile($uuid, $options = []) } } } + // @phpstan-ignore-next-line $custom_value->setValue($custom_column->column_name, $current_val); + // @phpstan-ignore-next-line $custom_value->save(); } return response(null, 204); @@ -356,6 +376,7 @@ public static function deleteFile($uuid, $options = []) /** * Delete temporary files that are one day old */ + // @phpstan-ignore-next-line protected function removeTempFiles() { $disk = Storage::disk(Define::DISKNAME_TEMP_UPLOAD); @@ -388,6 +409,7 @@ protected function removeTempFiles() /** * check if used in dashboard editor */ + // @phpstan-ignore-next-line protected function usedInDashboardEditor($file, &$contents) { if (is_null($contents)) { @@ -411,6 +433,7 @@ protected function usedInDashboardEditor($file, &$contents) /** * upload file as temporary */ + // @phpstan-ignore-next-line protected function uploadTempFile(Request $request) { return $this->_uploadTempFile($request, false); @@ -419,6 +442,7 @@ protected function uploadTempFile(Request $request) /** * upload Image as temporary */ + // @phpstan-ignore-next-line protected function uploadTempImage(Request $request) { return $this->_uploadTempFile($request, true); @@ -427,6 +451,7 @@ protected function uploadTempImage(Request $request) /** * upload Image as temporary */ + // @phpstan-ignore-next-line protected function uploadTempImagePublicForm(Request $request, $publicFormUuid) { $public_form = PublicForm::getPublicFormByUuid($publicFormUuid); @@ -436,6 +461,7 @@ protected function uploadTempImagePublicForm(Request $request, $publicFormUuid) /** * upload file as temporary */ + // @phpstan-ignore-next-line protected function _uploadTempFile(Request $request, bool $isImage, ?PublicForm $public_form = null) { // delete old temporary files @@ -456,9 +482,11 @@ protected function _uploadTempFile(Request $request, bool $isImage, ?PublicForm // get upload file $file = $request->file('file'); + // @phpstan-ignore-next-line $original_name = $file->getClientOriginalName(); $uuid = make_uuid(); // store uploaded file + // @phpstan-ignore-next-line $filename = $file->storeAs('', $uuid, Define::DISKNAME_TEMP_UPLOAD); try { $request->session()->put($uuid, $original_name); @@ -467,8 +495,10 @@ protected function _uploadTempFile(Request $request, bool $isImage, ?PublicForm // If this request is as public_form, return as url if ($public_form) { + // @phpstan-ignore-next-line $localtion = $public_form->getUrl('tmpfiles', basename($filename)); } else { + // @phpstan-ignore-next-line $localtion = admin_urls('tmpfiles', basename($filename)); } return json_encode(['location' => $localtion]); @@ -477,6 +507,7 @@ protected function _uploadTempFile(Request $request, bool $isImage, ?PublicForm /** * Download temporary saved file */ + // @phpstan-ignore-next-line public function downloadTempFile(Request $request, $uuid) { // delete old temporary files @@ -488,6 +519,7 @@ public function downloadTempFile(Request $request, $uuid) /** * Download temporary saved file */ + // @phpstan-ignore-next-line public function downloadTempFilePublicForm(Request $request, $publicFormUuid, $uuid) { // delete old temporary files @@ -503,6 +535,7 @@ public function downloadTempFilePublicForm(Request $request, $publicFormUuid, $u * @param mixed $data * @return true|\Symfony\Component\HttpFoundation\Response */ + // @phpstan-ignore-next-line protected static function checkParentPermission($data, array $options = []) { $options = array_merge( diff --git a/src/Controllers/ForgetPasswordController.php b/src/Controllers/ForgetPasswordController.php index 1e8e4aba4..7c31cff4e 100644 --- a/src/Controllers/ForgetPasswordController.php +++ b/src/Controllers/ForgetPasswordController.php @@ -36,6 +36,7 @@ public function showLinkRequestForm() } //defining which password broker to use, in our case its the exment + // @phpstan-ignore-next-line protected function broker() { return Password::broker('exment_admins'); diff --git a/src/Controllers/HasResourceActions.php b/src/Controllers/HasResourceActions.php index 1dec4d667..b7779f483 100644 --- a/src/Controllers/HasResourceActions.php +++ b/src/Controllers/HasResourceActions.php @@ -9,6 +9,7 @@ trait HasResourceActions { use ParentResourceActions; + // @phpstan-ignore-next-line protected $isDeleteForce = false; /** @@ -49,9 +50,11 @@ public function destroy($id) if (method_exists($this, 'getModel')) { $model = $this->getModel($id); } else { + // @phpstan-ignore-next-line $model = $this->form($id)->setIsForceDelete($this->isDeleteForce)->model()->find($id); } + /** @phpstan-ignore-next-line */ if (boolval(array_get($model, 'disabled_delete'))) { $disabled_delete = true; } @@ -61,6 +64,7 @@ public function destroy($id) if ($disabled_delete) { return response()->json([ 'status' => false, + /** @phpstan-ignore-next-line */ 'message' => exmtrans('error.disable_delete_row'), 'reload' => false, ]); @@ -75,6 +79,7 @@ public function destroy($id) } } else { /** @var \Illuminate\Http\Response|bool $response */ + // @phpstan-ignore-next-line $response = $this->form($id)->setIsForceDelete($this->isDeleteForce)->destroy($id); if ($response === false) { $result = false; @@ -83,7 +88,9 @@ public function destroy($id) // if response instanceof Response, and status is false, result is false elseif ($response instanceof Response) { + /** @phpstan-ignore-next-line */ $content = jsonToArray($response->content()); + /** @phpstan-ignore-next-line */ if (is_array($content) && !boolval(array_get($content, 'status', true))) { $result = false; return; @@ -95,11 +102,13 @@ public function destroy($id) if ($result) { $data = [ 'status' => true, + /** @phpstan-ignore-next-line */ 'message' => trans('admin.delete_succeeded'), ]; } else { $data = [ 'status' => false, + /** @phpstan-ignore-next-line */ 'message' => exmtrans('error.delete_failed'), ]; } diff --git a/src/Controllers/HasResourceTableActions.php b/src/Controllers/HasResourceTableActions.php index 3bb401b55..a874376e3 100644 --- a/src/Controllers/HasResourceTableActions.php +++ b/src/Controllers/HasResourceTableActions.php @@ -19,6 +19,7 @@ trait HasResourceTableActions * * @return \Illuminate\Http\Response */ + // @phpstan-ignore-next-line public function update($tableKey, $id) { return $this->form($id)->update($id); @@ -41,6 +42,7 @@ public function store() * @param $id * @return \Illuminate\Http\JsonResponse */ + // @phpstan-ignore-next-line public function destroy($tableKey, $id) { if (method_exists($this, 'validateDestroy')) { @@ -58,6 +60,7 @@ public function destroy($tableKey, $id) if (!$disabled_delete) { $model = $this->form($id)->model()->find($id); + /** @phpstan-ignore-next-line */ if (boolval(array_get($model, 'disabled_delete'))) { $disabled_delete = true; } @@ -67,6 +70,7 @@ public function destroy($tableKey, $id) if ($disabled_delete) { return response()->json([ 'status' => false, + /** @phpstan-ignore-next-line */ 'message' => exmtrans('error.disable_delete_row'), 'reload' => false, ]); @@ -80,6 +84,7 @@ public function destroy($tableKey, $id) $data = $res->getData(); if ($data->status === false) { $result = false; + /** @phpstan-ignore-next-line */ $messages[] = $data->message; return; } @@ -92,6 +97,7 @@ public function destroy($tableKey, $id) if ($result) { $data = [ 'status' => true, + /** @phpstan-ignore-next-line */ 'message' => trans('admin.delete_succeeded'), ]; } else { @@ -103,9 +109,11 @@ public function destroy($tableKey, $id) } else { $data = [ 'status' => false, + /** @phpstan-ignore-next-line */ 'message' => trans('admin.delete_failed'), ]; } + /** @phpstan-ignore-next-line */ if ($rows->count() !== count($messages)) { $data['forceRedirect'] = true; } diff --git a/src/Controllers/InitializeController.php b/src/Controllers/InitializeController.php index 095be974b..5f697e16e 100644 --- a/src/Controllers/InitializeController.php +++ b/src/Controllers/InitializeController.php @@ -23,6 +23,7 @@ public function index(Request $request) * submit * @param Request $request */ + // @phpstan-ignore-next-line public function post(Request $request) { return InstallService::post(); diff --git a/src/Controllers/InstallController.php b/src/Controllers/InstallController.php index a8d10c596..2b5605760 100644 --- a/src/Controllers/InstallController.php +++ b/src/Controllers/InstallController.php @@ -37,6 +37,7 @@ public function reset(Request $request) * submit * @param Request $request */ + // @phpstan-ignore-next-line public function post(Request $request) { \Exment::setTimeLimitLong(); diff --git a/src/Controllers/JanCodeController.php b/src/Controllers/JanCodeController.php index 843658631..fe91f161a 100644 --- a/src/Controllers/JanCodeController.php +++ b/src/Controllers/JanCodeController.php @@ -22,6 +22,7 @@ class JanCodeController extends Controller * @param $id * @return string */ + // @phpstan-ignore-next-line protected function scanRedirect(Request $request, $id) { $jan_code = DB::table("jan_codes") @@ -30,7 +31,9 @@ protected function scanRedirect(Request $request, $id) ->first(); $url = ''; if ($jan_code) { + // @phpstan-ignore-next-line $table_id = $jan_code->table_id; + // @phpstan-ignore-next-line $target_id = $jan_code->target_id; if ($table_id) { $custom_table = CustomTable::getEloquent($table_id); @@ -74,6 +77,7 @@ protected function scanRedirect(Request $request, $id) } } + // @phpstan-ignore-next-line return redirect($url); } @@ -83,6 +87,7 @@ protected function scanRedirect(Request $request, $id) * @param Request $request * @param $id */ + // @phpstan-ignore-next-line protected function listTable(Request $request, $id, Content $content) { $grid = $this->grid($id); @@ -100,6 +105,7 @@ protected function listTable(Request $request, $id, Content $content) * * @return Grid */ + // @phpstan-ignore-next-line protected function grid($id) { $grid = new Grid(new CustomTable()); @@ -137,6 +143,7 @@ protected function grid($id) * * @param Request $request */ + // @phpstan-ignore-next-line protected function assignJancode(Request $request) { $table_id = $request->get('table_id'); @@ -156,6 +163,7 @@ protected function assignJancode(Request $request) * @param $id * @param $table_id */ + // @phpstan-ignore-next-line protected function generateCreateUrl($id, $table_id) { $custom_table = CustomTable::getEloquent($table_id); diff --git a/src/Controllers/LogController.php b/src/Controllers/LogController.php index 579ff39d6..f35e95e72 100644 --- a/src/Controllers/LogController.php +++ b/src/Controllers/LogController.php @@ -68,7 +68,7 @@ protected function grid() $grid->tools(function (Grid\Tools $tools) use ($grid) { $button = new Tools\ExportImportButton(admin_url('loginuser'), $grid, false, true, false); $button->setBaseKey('common'); - /** @phpstan-ignore-next-line append() expects Encore\Admin\Grid\Tools\AbstractTool|string, Exceedone\Exment\Form\Tools\ExportImportButton given */ + // @phpstan-ignore-next-line $tools->append($button); }); @@ -84,6 +84,7 @@ protected function grid() protected function detail($id) { $model = OperationLog::findOrFail($id); + // @phpstan-ignore-next-line return new Show($model, function (Show $show) { $show->field('user.user_name', exmtrans('operation_log.user_name'))->as(function ($foo, $model) { return ($model->user ? $model->user->user_name : null); @@ -93,6 +94,7 @@ protected function detail($id) $show->field('ip', exmtrans('operation_log.ip')); $show->field('input', exmtrans('operation_log.input'))->as(function ($input) { $input = json_decode_ex($input, true); + // @phpstan-ignore-next-line $input = Arr::except($input, ['_pjax', '_token', '_method', '_previous_']); if (empty($input)) { return '{}'; @@ -132,6 +134,7 @@ public function destroy($id) return response()->json($data); } + // @phpstan-ignore-next-line protected function getImportExportService($grid = null) { // create exporter diff --git a/src/Controllers/LoginSettingController.php b/src/Controllers/LoginSettingController.php index 40a423a51..4427f6114 100644 --- a/src/Controllers/LoginSettingController.php +++ b/src/Controllers/LoginSettingController.php @@ -101,6 +101,7 @@ protected function grid() * * @return Form */ + // @phpstan-ignore-next-line protected function form($id = null) { $form = new Form(new LoginSetting()); @@ -232,6 +233,7 @@ protected function form($id = null) } elseif ($request->get('login_type') == LoginType::OAUTH) { $provider_name = array_get($request->all(), 'options.oauth_provider_type') == 'other' ? array_get($request->all(), 'options.oauth_provider_name') : array_get($request->all(), 'options.oauth_provider_type'); } elseif ($request->old('login_type') == LoginType::OAUTH) { + // @phpstan-ignore-next-line $provider_name = array_get($request->old(), 'options.oauth_provider_type') == 'other' ? array_get($request->old(), 'options.oauth_provider_name') : array_get($request->old(), 'options.oauth_provider_type'); } if (!is_nullorempty($provider_name)) { @@ -282,6 +284,7 @@ protected function form($id = null) * * @return \Illuminate\Support\Collection */ + // @phpstan-ignore-next-line protected function checkLibraries() { $errors = []; @@ -298,6 +301,7 @@ protected function checkLibraries() } /** @var Collection $collection */ + // @phpstan-ignore-next-line $collection = collect($errors)->mapWithKeys(function ($error) { return [$error->getValue() => '' . exmtrans('login.message.not_install_library', [ 'name' => $error->transKey('login.login_type_options'), @@ -316,7 +320,7 @@ protected function checkLibraries() protected function globalSettingBox(Request $request) { $form = $this->globalSettingForm($request); - /** @phpstan-ignore-next-line constructor expects string, Encore\Admin\Widgets\Form given */ + // @phpstan-ignore-next-line $box = new Box(exmtrans('common.detail_setting'), $form); return $box; } @@ -536,6 +540,7 @@ public function loginTestCallback(Request $request, Content $content, $id) } + // @phpstan-ignore-next-line protected function getEditUrl($id, $testCallback = false) { $uri = route('exment.login_setting.edit', ['id' => $id]); @@ -555,6 +560,7 @@ protected function getEditUrl($id, $testCallback = false) */ public function activate(Request $request, $id) { + // @phpstan-ignore-next-line return $this->toggleActivate($request, $id, true); } @@ -567,6 +573,7 @@ public function activate(Request $request, $id) */ public function deactivate(Request $request, $id) { + // @phpstan-ignore-next-line return $this->toggleActivate($request, $id, false); } @@ -635,6 +642,7 @@ protected function get2factorSettingForm(): WidgetForm * Send data * @param Request $request */ + // @phpstan-ignore-next-line public function post2factor(Request $request) { $login_2factor_verify_code = $request->get('login_2factor_verify_code'); @@ -741,6 +749,7 @@ public function auth_2factor_verify() * @param Request $request * @return array */ + // @phpstan-ignore-next-line public function loginOptionHtml(Request $request) { $val = $request->get('val'); diff --git a/src/Controllers/LoginUserController.php b/src/Controllers/LoginUserController.php index 00e46feb5..724ea918b 100644 --- a/src/Controllers/LoginUserController.php +++ b/src/Controllers/LoginUserController.php @@ -88,7 +88,7 @@ protected function grid() $button = new Tools\ExportImportButton(admin_url('loginuser'), $grid, false, true); $button->setBaseKey('common'); - /** @phpstan-ignore-next-line append() expects Encore\Admin\Grid\Tools\AbstractTool|string, Exceedone\Exment\Form\Tools\ExportImportButton given */ + // @phpstan-ignore-next-line $tools->append($button); $tools->batch(function (Grid\Tools\BatchActions $actions) { $actions->disableDelete(); @@ -102,12 +102,14 @@ protected function grid() /** * get import modal */ + // @phpstan-ignore-next-line public function importModal(Request $request) { $service = $this->getImportExportService(); return $service->getImportModal(); } + // @phpstan-ignore-next-line protected function getImportExportService($grid = null) { // create exporter @@ -128,6 +130,7 @@ protected function getImportExportService($grid = null) * * @return Form */ + // @phpstan-ignore-next-line protected function form($id = null) { $classname = getModelName(SystemTableName::USER); @@ -155,6 +158,7 @@ protected function form($id = null) * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Http\Response|\Illuminate\Routing\Redirector|Response * @throws \Throwable */ + // @phpstan-ignore-next-line public function update($id) { DB::beginTransaction(); @@ -181,6 +185,7 @@ public function update($id) /** * @param Request $request */ + // @phpstan-ignore-next-line public function import(Request $request) { // create exporter @@ -198,6 +203,7 @@ public function import(Request $request) return getAjaxResponse($result); } + // @phpstan-ignore-next-line protected function response() { $message = trans('admin.update_succeeded'); @@ -215,6 +221,7 @@ protected function response() return redirect($url); } + // @phpstan-ignore-next-line protected function getLoginUser($user) { $login_user = $user->login_users()->whereNull('login_provider')->first(); diff --git a/src/Controllers/MenuController.php b/src/Controllers/MenuController.php index dd1dcb307..8aba21b75 100644 --- a/src/Controllers/MenuController.php +++ b/src/Controllers/MenuController.php @@ -51,7 +51,7 @@ public function index(Request $request, Content $content) $this->createMenuForm($form); $form->hidden('_token')->default(csrf_token()); - /** @phpstan-ignore-next-line constructor expects string, Encore\Admin\Widgets\Form given */ + // @phpstan-ignore-next-line $column->append((new Box(trans('admin.new'), $form))->style('success')); }); }); @@ -139,6 +139,7 @@ protected function treeView() * * @return Form */ + // @phpstan-ignore-next-line public function form($id = null) { return Menu::form(function (Form $form) use ($id) { @@ -146,6 +147,7 @@ public function form($id = null) }); } + // @phpstan-ignore-next-line protected function createMenuForm($form, $id = null) { // get setting menu object @@ -263,6 +265,7 @@ protected function createMenuForm($form, $id = null) // menu_type and menutargetvalue -------------------------------------------------- // get menu type(calling from menu_type) + // @phpstan-ignore-next-line public function menutype(Request $request) { $type = $request->input('q'); @@ -270,6 +273,7 @@ public function menutype(Request $request) } // get menu target view(calling from menu_target) + // @phpstan-ignore-next-line public function menutargetview(Request $request) { $menu_target = $request->input('q'); @@ -286,6 +290,7 @@ public function menutargetview(Request $request) * @param bool $isApi * @return array|mixed[] */ + // @phpstan-ignore-next-line protected function getViewList($custom_table, $isApi) { $custom_table = CustomTable::getEloquent($custom_table); @@ -314,6 +319,7 @@ protected function getViewList($custom_table, $isApi) * @param string $type string * @param boolean $isApi is api. if true, return id and value array. if false, return array(key:id, value:name) */ + // @phpstan-ignore-next-line protected function getMenuType($type, $isApi) { $options = []; @@ -347,6 +353,7 @@ protected function getMenuType($type, $isApi) return collect($options)->pluck('text', 'id')->toArray(); } + // @phpstan-ignore-next-line public function menutargetvalue(Request $request) { $type = $request->input('menu_type'); @@ -442,6 +449,7 @@ protected function isAddSystemMenuOptions($k, $value) } + // @phpstan-ignore-next-line protected function getMenuTypeValue($field, $menu = null) { // get menu type diff --git a/src/Controllers/NotifyController.php b/src/Controllers/NotifyController.php index 611b36494..9bd20a16e 100644 --- a/src/Controllers/NotifyController.php +++ b/src/Controllers/NotifyController.php @@ -12,8 +12,8 @@ class NotifyController extends AdminControllerBase { /** * @param Request $request - * @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line public function __construct(Request $request) { $this->setPageInfo(exmtrans("notify.header"), exmtrans("notify.header"), exmtrans("notify.description"), 'fa-bell'); @@ -27,6 +27,7 @@ public function index(Request $request, Content $content) } + // @phpstan-ignore-next-line public function getNotifyTriggerTemplate(Request $request) { $keyName = 'mail_template_id'; diff --git a/src/Controllers/NotifyNavbarController.php b/src/Controllers/NotifyNavbarController.php index a04c03238..817a062d9 100644 --- a/src/Controllers/NotifyNavbarController.php +++ b/src/Controllers/NotifyNavbarController.php @@ -46,7 +46,7 @@ protected function grid() $grid->disableExport(); $grid->tools(function (Grid\Tools $tools) { - /** @phpstan-ignore-next-line append() expects Encore\Admin\Grid\Tools\AbstractTool|string, Exceedone\Exment\Form\Tools\SwalMenuButton given */ + // @phpstan-ignore-next-line $tools->append(new SwalMenuButton($this->getMenuList())); $tools->batch(function (Grid\Tools\BatchActions $batch) { $batch->add(exmtrans('notify_navbar.all_check'), new BatchCheck()); @@ -92,6 +92,7 @@ protected function grid() * * @return array */ + // @phpstan-ignore-next-line protected function getMenuList(): array { $menulist = []; @@ -130,6 +131,7 @@ protected function getMenuList(): array * * @return Form */ + // @phpstan-ignore-next-line protected function form($id = null) { return new Form(new NotifyNavbar()); @@ -149,7 +151,9 @@ protected function detail($id) abort(404); } + // @phpstan-ignore-next-line if ($model->read_flg == 0) { + // @phpstan-ignore-next-line $model->update(['read_flg' => true]); } @@ -162,6 +166,7 @@ protected function detail($id) } } + // @phpstan-ignore-next-line return new Show($model, function (Show $show) use ($id, $parent_type, $custom_value, $custom_table) { if (isset($parent_type)) { $show->field('parent_type', exmtrans('notify_navbar.parent_type'))->as(function ($parent_type) use ($custom_table) { @@ -246,6 +251,7 @@ public function batchAll(Request $request, String $type): \Symfony\Component\Htt * * @param mixed $id */ + // @phpstan-ignore-next-line public function redirectTargetData(Request $request, $id = null) { $model = NotifyNavbar::find($id); @@ -255,16 +261,20 @@ public function redirectTargetData(Request $request, $id = null) } // update read_flg + // @phpstan-ignore-next-line if ($model->read_flg == 0) { + // @phpstan-ignore-next-line $model->update(['read_flg' => true]); } + // @phpstan-ignore-next-line $custom_table = getModelName($model->parent_type); if (is_nullorempty($custom_table)) { return back(); } + // @phpstan-ignore-next-line $custom_value = $custom_table::find($model->parent_id); if (!isset($custom_value)) { @@ -280,6 +290,7 @@ public function redirectTargetData(Request $request, $id = null) * * @param mixed $id */ + // @phpstan-ignore-next-line public function rowCheck(Request $request, $id = null) { if (!isset($id)) { diff --git a/src/Controllers/NotifyTrait.php b/src/Controllers/NotifyTrait.php index 94a271255..54a761ccb 100644 --- a/src/Controllers/NotifyTrait.php +++ b/src/Controllers/NotifyTrait.php @@ -24,9 +24,12 @@ trait NotifyTrait /** * Make a grid builder. */ + // @phpstan-ignore-next-line protected function setBasicGrid($grid) { + /** @phpstan-ignore-next-line */ $grid->column('notify_view_name', exmtrans("notify.notify_view_name"))->sortable(); + /** @phpstan-ignore-next-line */ $grid->column('notify_trigger', exmtrans("notify.notify_trigger"))->sortable()->display(function ($val) { $enum = NotifyTrigger::getEnum($val); return $enum ? $enum->transKey('notify.notify_trigger_options') : null; @@ -37,57 +40,74 @@ protected function setBasicGrid($grid) /** * Make a grid builder. */ + // @phpstan-ignore-next-line protected function setFilterGrid($grid, ?\Closure $callback = null) { $grid->disableExport(); $grid->filter(function ($filter) use ($callback) { $filter->disableIdFilter(); + /** @phpstan-ignore-next-line */ $filter->like('notify_name', exmtrans("notify.notify_name")); + /** @phpstan-ignore-next-line */ $filter->like('notify_view_name', exmtrans("notify.notify_view_name")); if ($callback) { $callback($filter); } + /** @phpstan-ignore-next-line */ $filter->equal('active_flg', exmtrans("plugin.active_flg"))->radio(\Exment::getYesNoAllOption()); }); } + // @phpstan-ignore-next-line protected function setBasicForm(Form $form, ?Notify $notify) { + /** @phpstan-ignore-next-line */ if (!isset($notify) || is_nullorempty($notify->notify_name)) { + /** @phpstan-ignore-next-line */ $form->text('notify_name', exmtrans("notify.notify_name")) ->rules("max:30|nullable|unique:".Notify::getTableName()."|regex:/".Define::RULES_REGEX_SYSTEM_NAME."/") + /** @phpstan-ignore-next-line */ ->help(sprintf(exmtrans('common.help.max_length'), 30) . exmtrans('common.help_code')); } else { + /** @phpstan-ignore-next-line */ $form->display('notify_name', exmtrans("notify.notify_name")); } + /** @phpstan-ignore-next-line */ $form->text('notify_view_name', exmtrans("notify.notify_view_name"))->required()->rules("max:40"); // TODO: only role tables + /** @phpstan-ignore-next-line */ $form->switchbool('active_flg', exmtrans("plugin.active_flg")) + /** @phpstan-ignore-next-line */ ->help(exmtrans("notify.help.active_flg")) ->default(true); } + // @phpstan-ignore-next-line protected function setActionForm($form, ?Notify $notify, $custom_table = null, $workflow = null, array $options = []) { if ($workflow) { $custom_table = $workflow->target_table; } + /** @phpstan-ignore-next-line */ $form->url('webhook_url', exmtrans("notify.webhook_url")) ->required() ->rules(["max:300"]) + /** @phpstan-ignore-next-line */ ->help(exmtrans("notify.help.webhook_url", getManualUrl('notify_webhook'))) ->attribute([ 'data-filter' => json_encode(['key' => 'notify_action', 'value' => [NotifyAction::SLACK, NotifyAction::MICROSOFT_TEAMS]]) ]); + /** @phpstan-ignore-next-line */ $form->switchbool('mention_here', exmtrans("notify.mention_here")) + /** @phpstan-ignore-next-line */ ->help(exmtrans("notify.help.mention_here")) ->attribute(['data-filter' => json_encode(['key' => 'notify_action', 'value' => [NotifyAction::SLACK]]) ]); @@ -95,13 +115,19 @@ protected function setActionForm($form, ?Notify $notify, $custom_table = null, $ $system_slack_user_column = CustomColumn::getEloquent(System::system_slack_user_column()); $notify_action_target_filter = isset($system_slack_user_column) ? [NotifyAction::EMAIL, NotifyAction::SHOW_PAGE, NotifyAction::SLACK] : [NotifyAction::EMAIL, NotifyAction::SHOW_PAGE]; + /** @phpstan-ignore-next-line */ $help = exmtrans("notify.help.notify_action_target"); + /** @phpstan-ignore-next-line */ if (!is_nullorempty($workflow)) { + /** @phpstan-ignore-next-line */ $help .= exmtrans("notify.help.notify_action_target_add_workflow"); } + /** @phpstan-ignore-next-line */ $form->multipleSelect('notify_action_target', exmtrans("notify.notify_action_target")) + /** @phpstan-ignore-next-line */ ->options(function ($val, $field, $notify) use ($custom_table, $workflow, $options) { $options = array_merge([ + /** @phpstan-ignore-next-line */ 'as_workflow' => !is_nullorempty($workflow), 'workflow' => $workflow, 'get_realtion_email' => true, @@ -110,6 +136,7 @@ protected function setActionForm($form, ?Notify $notify, $custom_table = null, $ $custom_table ?? null, array_get($field->data(), 'notify_action'), $options + /** @phpstan-ignore-next-line */ ))->pluck('text', 'id'); }) ->attribute([ @@ -120,9 +147,11 @@ protected function setActionForm($form, ?Notify $notify, $custom_table = null, $ ]) ->help($help); + /** @phpstan-ignore-next-line */ $form->textarea('target_emails', exmtrans("notify.target_emails")) ->required() ->rows(3) + /** @phpstan-ignore-next-line */ ->help(exmtrans("notify.help.target_emails")) ->rules([new EmailMultiline()]) ->attribute([ @@ -143,7 +172,9 @@ protected function setActionForm($form, ?Notify $notify, $custom_table = null, $ 'selected_value'=> $selected_value ]); + /** @phpstan-ignore-next-line */ $field = $form->multipleSelect('target_users', exmtrans('notify.target_users')) + /** @phpstan-ignore-next-line */ ->options($users) ->ajax($ajax) ->attribute([ @@ -153,8 +184,11 @@ protected function setActionForm($form, ?Notify $notify, $custom_table = null, $ ]); if ($custom_table) { + /** @phpstan-ignore-next-line */ $field->help(exmtrans('workflow.help.target_user_org', [ + /** @phpstan-ignore-next-line */ 'table_view_name' => esc_html($custom_table->table_view_name), + /** @phpstan-ignore-next-line */ 'type' => exmtrans('menu.system_definitions.user'), ])); } @@ -170,7 +204,9 @@ protected function setActionForm($form, ?Notify $notify, $custom_table = null, $ 'selected_value'=> $selected_value ]); + /** @phpstan-ignore-next-line */ $field = $form->multipleSelect('target_organizations', exmtrans('notify.target_organizations')) + /** @phpstan-ignore-next-line */ ->options($organizations) ->ajax($ajax) ->attribute(['data-filter' => json_encode(['key' => 'notify_action_target', 'value' => [NotifyActionTarget::FIXED_ORGANIZATION]])]) @@ -178,15 +214,20 @@ protected function setActionForm($form, ?Notify $notify, $custom_table = null, $ // Set help if has $custom_table if ($custom_table) { + /** @phpstan-ignore-next-line */ $field->help(exmtrans('workflow.help.target_user_org', [ + /** @phpstan-ignore-next-line */ 'table_view_name' => esc_html($custom_table->table_view_name), + /** @phpstan-ignore-next-line */ 'type' => exmtrans('menu.system_definitions.organization'), ])); } } if (!isset($system_slack_user_column)) { + /** @phpstan-ignore-next-line */ $form->display('notify_action_target_text', exmtrans("notify.notify_action_target")) + /** @phpstan-ignore-next-line */ ->displayText(exmtrans('notify.help.slack_user_column_not_setting') . \Exment::getMoreTag('notify_webhook', 'notify.mention_setting_manual_id')) ->attribute([ 'data-filter' => json_encode([ @@ -198,10 +239,14 @@ protected function setActionForm($form, ?Notify $notify, $custom_table = null, $ } } + // @phpstan-ignore-next-line protected function setMailTemplateForm($form, ?Notify $notify, $mail_template_id = null) { + /** @phpstan-ignore-next-line */ $form->select('mail_template_id', exmtrans("notify.mail_template_id"))->options(function ($val) { + /** @phpstan-ignore-next-line */ return getModelName(SystemTableName::MAIL_TEMPLATE)::all()->pluck('label', 'id'); + /** @phpstan-ignore-next-line */ })->help(exmtrans("notify.help.mail_template_id")) ->disableClear() ->default($mail_template_id) @@ -209,6 +254,7 @@ protected function setMailTemplateForm($form, ?Notify $notify, $mail_template_id } + // @phpstan-ignore-next-line protected function setFooterForm(Form $form, ?Notify $notify) { $form->saving(function (Form $form) { @@ -218,6 +264,7 @@ protected function setFooterForm(Form $form, ?Notify $notify) } else { $cnt = collect($form->action_settings)->filter(function ($value) { return $value[Form::REMOVE_FLAG_NAME] != 1; + /** @phpstan-ignore-next-line */ })->count(); if ($cnt == 0) { $error = true; @@ -225,6 +272,7 @@ protected function setFooterForm(Form $form, ?Notify $notify) } // if($error){ + /** @phpstan-ignore-next-line */ // admin_toastr(sprintf(exmtrans("common.message.exists_row"), exmtrans("notify.header_action")), 'error'); // return back()->withInput(); // } @@ -234,6 +282,7 @@ protected function setFooterForm(Form $form, ?Notify $notify) } + // @phpstan-ignore-next-line public function getNotifyTriggerTemplate(Request $request) { $keyName = 'mail_template_id'; @@ -255,6 +304,7 @@ public function getNotifyTriggerTemplate(Request $request) $mail_template = CustomTable::getEloquent(SystemTableName::MAIL_TEMPLATE) ->getValueModel() ->where('value->mail_key_name', $mailKeyName) + /** @phpstan-ignore-next-line */ ->first(); if (!isset($mail_template)) { @@ -279,12 +329,15 @@ protected function hasPermissionEdit($id) } // filter only custom table user has permission custom table + /** @phpstan-ignore-next-line */ if (\Exment::user()->isAdministrator()) { return true; } + /** @phpstan-ignore-next-line */ $notify = Notify::find($id); + /** @phpstan-ignore-next-line */ $custom_tables = CustomTable::filterList()->pluck('id')->toArray(); if (!in_array($notify->target_id, $custom_tables)) { diff --git a/src/Controllers/PluginCodeController.php b/src/Controllers/PluginCodeController.php index 094578493..75d9fe943 100644 --- a/src/Controllers/PluginCodeController.php +++ b/src/Controllers/PluginCodeController.php @@ -18,6 +18,7 @@ class PluginCodeController extends AdminControllerBase { use CodeTreeTrait; + // @phpstan-ignore-next-line protected $plugin; protected const node_key = Define::SYSTEM_KEY_SESSION_FILE_NODELIST; @@ -70,6 +71,7 @@ public function edit(Request $request, Content $content, $id) return $content; } + // @phpstan-ignore-next-line protected function getJsTreeBox($id) { $view = view('exment::widgets.jstree', [ @@ -91,6 +93,7 @@ protected function getJsTreeBox($id) * @param $id * @return false|\Illuminate\Http\JsonResponse */ + // @phpstan-ignore-next-line public function getTreeData(Request $request, $id) { $this->plugin = Plugin::getEloquent($id); @@ -130,6 +133,7 @@ protected function getTreeDataJson(Request $request) * @return false|\Illuminate\Http\RedirectResponse * @throws FileNotFoundException */ + // @phpstan-ignore-next-line public function fileupload(Request $request, $id) { $this->plugin = Plugin::getEloquent($id); @@ -152,6 +156,7 @@ public function fileupload(Request $request, $id) $upload_files = $request->file('fileUpload'); + // @phpstan-ignore-next-line foreach ($upload_files as $upload_file) { $filename = $upload_file->getClientOriginalName(); @@ -174,6 +179,7 @@ public function fileupload(Request $request, $id) * @return array * @throws \Exception */ + // @phpstan-ignore-next-line public function getFileEditForm(Request $request, $id) { $this->plugin = Plugin::getEloquent($id); @@ -197,6 +203,7 @@ public function getFileEditForm(Request $request, $id) * @return array|void * @throws \Exception */ + // @phpstan-ignore-next-line protected function getFileEditFormView(Request $request, $id) { $validator = \Validator::make($request->all(), [ @@ -267,6 +274,7 @@ protected function getFileEditFormView(Request $request, $id) * @param string $nodepath * @return array [CodeMirror mode, image extension, deletable flg] */ + // @phpstan-ignore-next-line protected function getPluginFileType($nodepath) { // exclude config.json @@ -315,6 +323,7 @@ protected function getPluginFileType($nodepath) * @return false|Response * @throws FileNotFoundException */ + // @phpstan-ignore-next-line public function delete(Request $request, $id) { $this->plugin = Plugin::getEloquent($id); @@ -357,6 +366,7 @@ public function delete(Request $request, $id) * @return false|Response * @throws FileNotFoundException */ + // @phpstan-ignore-next-line public function store(Request $request, $id) { $this->plugin = Plugin::getEloquent($id); @@ -407,12 +417,14 @@ protected function updatePluginDatetime() } + // @phpstan-ignore-next-line protected function getDirectoryPaths($folder) { return $this->plugin->getPluginDirPaths($folder, false); } + // @phpstan-ignore-next-line protected function getFilePaths($folder) { return $this->plugin->getPluginFilePaths($folder, false); diff --git a/src/Controllers/PluginController.php b/src/Controllers/PluginController.php index 739a6283b..09ccc04a5 100644 --- a/src/Controllers/PluginController.php +++ b/src/Controllers/PluginController.php @@ -58,6 +58,7 @@ public function index(Request $request, Content $content) * @param $id * @return false|\Illuminate\Http\RedirectResponse */ + // @phpstan-ignore-next-line public function executeBatch(Request $request, $id) { if (!\Exment::user()->hasPermission(Permission::PLUGIN_ACCESS)) { @@ -123,6 +124,7 @@ protected function grid() } //Function use to upload file and update or add new record + // @phpstan-ignore-next-line protected function store(Request $request) { //Check file existed in Request @@ -134,9 +136,11 @@ protected function store(Request $request) } //Delete record from database (one or multi records) + // @phpstan-ignore-next-line protected function destroy($id) { foreach (stringToArray($id) as $i) { + // @phpstan-ignore-next-line if ($this->form($i, true)->destroy($i)) { $this->deleteFolder($i); } else { @@ -153,6 +157,7 @@ protected function destroy($id) } //Delete one or multi folder corresponds to the plugins + // @phpstan-ignore-next-line protected function deleteFolder($id) { $idlist = explode(",", $id); @@ -172,6 +177,7 @@ protected function deleteFolder($id) } //Check request when edit record to delete null values in event_triggers + // @phpstan-ignore-next-line protected function update(Request $request, $id) { $plugin = Plugin::getEloquent($id); @@ -183,11 +189,12 @@ protected function update(Request $request, $id) if (isset($request->get('options')['event_triggers']) === true) { $event_triggers = $request->get('options')['event_triggers']; $options = $request->get('options'); - /** @phpstan-ignore-next-line array_filter expects (callable(mixed): bool)|null, 'strlen' given */ + // @phpstan-ignore-next-line $event_triggers = array_filter($event_triggers, 'strlen'); $options['event_triggers'] = $event_triggers; $request->merge(['options' => $options]); } + // @phpstan-ignore-next-line return $this->form($id)->update($id); } @@ -198,6 +205,7 @@ protected function update(Request $request, $id) * @param $isDelete * @return Form|false */ + // @phpstan-ignore-next-line protected function form($id = null, $isDelete = false) { $plugin = Plugin::getEloquent($id); @@ -397,6 +405,7 @@ protected function form($id = null, $isDelete = false) * @param Plugin|null $plugin * @return void */ + // @phpstan-ignore-next-line protected function setCustomOptionForm($plugin, &$form) { $pluginClass = $this->getPluginClass($plugin); @@ -421,6 +430,7 @@ protected function setCustomOptionForm($plugin, &$form) * * @return mixed */ + // @phpstan-ignore-next-line protected function getPluginClass($plugin) { if (!isset($plugin)) { diff --git a/src/Controllers/PublicFormApiDataController.php b/src/Controllers/PublicFormApiDataController.php index 43ff46cc0..3225e56e4 100644 --- a/src/Controllers/PublicFormApiDataController.php +++ b/src/Controllers/PublicFormApiDataController.php @@ -16,6 +16,7 @@ class PublicFormApiDataController extends AdminControllerTableBase { use ApiDataTrait; + // @phpstan-ignore-next-line protected $public_form; public function __construct(?CustomTable $custom_table, ?PublicForm $public_form, Request $request) @@ -33,6 +34,7 @@ public function __construct(?CustomTable $custom_table, ?PublicForm $public_form * @param array $parameters * @return \Symfony\Component\HttpFoundation\Response */ + // @phpstan-ignore-next-line public function callAction($method, $parameters) { if (!$this->custom_table || !$this->public_form) { @@ -48,6 +50,7 @@ public function callAction($method, $parameters) * @param mixed $id * @return mixed */ + // @phpstan-ignore-next-line public function dataFind(Request $request, $uuid, $tableKey, $id) { if (($response = $this->checkContainsCustomTableInForm($request)) !== true) { @@ -77,11 +80,13 @@ public function dataSelect(Request $request) * @param string $column_name * @return Response */ + // @phpstan-ignore-next-line public function columnData(Request $request, $uuid, $tableKey, $column_name) { if (($response = $this->checkContainsCustomTableInForm($request)) !== true) { return $response; } + // @phpstan-ignore-next-line return $this->_columnData($request, $column_name); } @@ -93,6 +98,7 @@ public function columnData(Request $request, $uuid, $tableKey, $column_name) * *search_type(required) : 1:n, n:n or select_table. * *q(required) : id that user selected. */ + // @phpstan-ignore-next-line public function relatedLinkage(Request $request) { if (($response = $this->checkContainsCustomTableInForm($request)) !== true) { diff --git a/src/Controllers/PublicFormController.php b/src/Controllers/PublicFormController.php index 21699723e..f1dffa71b 100644 --- a/src/Controllers/PublicFormController.php +++ b/src/Controllers/PublicFormController.php @@ -28,6 +28,7 @@ class PublicFormController extends Controller /** */ + // @phpstan-ignore-next-line protected $form_item; /** @@ -60,6 +61,7 @@ public function __construct(?PublicForm $public_form) * @param array $parameters * @return \Symfony\Component\HttpFoundation\Response */ + // @phpstan-ignore-next-line public function callAction($method, $parameters) { // if public_form is null or not active, throw new \Exceedone\Exment\Exceptions\PublicFormNotFoundException(); @@ -84,6 +86,7 @@ public function index(Request $request) return $this->getInputContent($request); } + // @phpstan-ignore-next-line public function redirect(Request $request) { admin_error(exmtrans('common.error'), exmtrans('error.expired_error_reinput')); @@ -230,7 +233,7 @@ public function create(Request $request) $public_form->setContentOption($content, ['isContainer' => true]); $content->row($public_form->getCompleteView($request, $form->model())); - /** @phpstan-ignore-next-line response expects array|Illuminate\Contracts\View\View|string|null, Exceedone\Exment\Form\PublicContent given */ + // @phpstan-ignore-next-line return response($content); }); @@ -254,6 +257,7 @@ public function create(Request $request) * @param array $inputs * @return array */ + // @phpstan-ignore-next-line protected function removeUploadedFile(array $inputs): array { foreach ($inputs as &$input) { diff --git a/src/Controllers/QrCodeController.php b/src/Controllers/QrCodeController.php index 772f0ec6b..ed16e2ce9 100644 --- a/src/Controllers/QrCodeController.php +++ b/src/Controllers/QrCodeController.php @@ -17,6 +17,7 @@ class QrCodeController extends Controller * @param $table_name * @param $id */ + // @phpstan-ignore-next-line protected function scanRedirect(Request $request, $table_name, $id) { $custom_table = CustomTable::getEloquent($table_name); diff --git a/src/Controllers/ResetPasswordController.php b/src/Controllers/ResetPasswordController.php index ed4eedf1e..a0826afc3 100644 --- a/src/Controllers/ResetPasswordController.php +++ b/src/Controllers/ResetPasswordController.php @@ -19,7 +19,9 @@ class ResetPasswordController extends Controller use ResetsPasswords; use \Exceedone\Exment\Controllers\AuthTrait; + // @phpstan-ignore-next-line protected $login_user; + // @phpstan-ignore-next-line protected $redirectTo; /** @@ -37,6 +39,7 @@ public function __construct() * * @return array */ + // @phpstan-ignore-next-line protected function rules() { return [ @@ -53,6 +56,7 @@ protected function rules() * @param $token * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ + // @phpstan-ignore-next-line public function showResetForm(Request $request, $token) { // get email @@ -149,11 +153,13 @@ protected function resetPassword(LoginUser $user, $password) } //defining which password broker to use, in our case its the exment + // @phpstan-ignore-next-line protected function broker() { return Password::broker('exment_admins'); } + // @phpstan-ignore-next-line protected function guard() { return Auth::guard('admin'); @@ -164,6 +170,7 @@ protected function guard() * * @return string|null */ + // @phpstan-ignore-next-line protected function getEmailByToken($token) { $broker = $this->broker(); diff --git a/src/Controllers/RoleGroupController.php b/src/Controllers/RoleGroupController.php index 657232470..09ce0eb20 100644 --- a/src/Controllers/RoleGroupController.php +++ b/src/Controllers/RoleGroupController.php @@ -110,6 +110,7 @@ protected function grid() return $grid; } + // @phpstan-ignore-next-line protected function getImportExportService($grid = null) { // create exporter @@ -135,7 +136,7 @@ public function create(Request $request, Content $content) { $isRolePermissionPage = $request->get('form_type') != 2; $form = $isRolePermissionPage ? $this->form() : $this->formUserOrganization(); - /** @phpstan-ignore-next-line Encore\Admin\Widgets\Box constructor expects string, Encore\Admin\Widgets\Form given */ + // @phpstan-ignore-next-line $box = new Box(trans('admin.create'), $form); $this->appendTools($box, null, $isRolePermissionPage); return $this->AdminContent($content)->body($box); @@ -165,6 +166,7 @@ public function edit(Request $request, Content $content, $id) * * @return Form */ + // @phpstan-ignore-next-line protected function form($id = null) { $model = isset($id) ? RoleGroup::with(['role_group_permissions'])->findOrFail($id) : new RoleGroup(); @@ -209,6 +211,7 @@ protected function form($id = null) // System -------------------------------------------------------- + // @phpstan-ignore-next-line $values = $model->role_group_permissions->first(function ($role_group_permission) { return $role_group_permission->role_group_permission_type == RoleType::SYSTEM && $role_group_permission->role_group_target_id == SystemRoleType::SYSTEM; })->permissions ?? []; @@ -233,6 +236,7 @@ protected function form($id = null) // Role -------------------------------------------------------- + // @phpstan-ignore-next-line $values = $model->role_group_permissions->first(function ($role_group_permission) { return $role_group_permission->role_group_permission_type == RoleType::SYSTEM && $role_group_permission->role_group_target_id == SystemRoleType::ROLE_GROUP; })->permissions ?? []; @@ -263,7 +267,9 @@ protected function form($id = null) $form->exmheader(exmtrans('role_group.role_type_options.plugin') . exmtrans('role_group.permission_setting'))->hr(); $items = []; + // @phpstan-ignore-next-line foreach ($plugins as $plugin) { + // @phpstan-ignore-next-line $values = $model->role_group_permissions->first(function ($role_group_permission) use ($plugin) { return $role_group_permission->role_group_permission_type == RoleType::PLUGIN && $role_group_permission->role_group_target_id == $plugin->id; })->permissions ?? []; @@ -301,6 +307,7 @@ protected function form($id = null) $tables = $this->getTables(true); foreach ($tables as $table) { + // @phpstan-ignore-next-line $values = $model->role_group_permissions->first(function ($role_group_permission) use ($table) { return $role_group_permission->role_group_permission_type == RoleType::TABLE && $role_group_permission->role_group_target_id == $table->id; })->permissions ?? []; @@ -332,6 +339,7 @@ protected function form($id = null) $tables = $this->getTables(false); foreach ($tables as $table) { + // @phpstan-ignore-next-line $values = $model->role_group_permissions->first(function ($role_group_permission) use ($table) { return $role_group_permission->role_group_permission_type == RoleType::TABLE && $role_group_permission->role_group_target_id == $table->id; })->permissions ?? []; @@ -378,6 +386,7 @@ protected function form($id = null) * * @return Form|false */ + // @phpstan-ignore-next-line protected function formUserOrganization($id = null) { if (!$this->hasPermission_UserOrganization()) { @@ -397,6 +406,7 @@ protected function formUserOrganization($id = null) $form->display('role_group_view_name', exmtrans('role_group.role_group_view_name')); // get options + // @phpstan-ignore-next-line $default = $model->role_group_user_organizations->map(function ($item) { return array_get($item, 'role_group_user_org_type') . '_' . array_get($item, 'role_group_target_id'); })->toArray(); @@ -468,6 +478,7 @@ public function store() return $this->saveRolePermission(); } + // @phpstan-ignore-next-line protected function saveRolePermission($id = null) { if (!$this->hasPermission_Permission()) { @@ -494,11 +505,16 @@ protected function saveRolePermission($id = null) try { $role_group = isset($id) ? RoleGroup::findOrFail($id) : new RoleGroup(); if (!isset($id)) { + // @phpstan-ignore-next-line $role_group->role_group_name = $request->get('role_group_name'); } + // @phpstan-ignore-next-line $role_group->role_group_view_name = $request->get('role_group_view_name'); + // @phpstan-ignore-next-line $role_group->description = $request->get('description'); + // @phpstan-ignore-next-line $role_group->role_group_order = $request->get('role_group_order'); + // @phpstan-ignore-next-line $role_group->save(); $items = [ @@ -517,6 +533,7 @@ protected function saveRolePermission($id = null) foreach ($requestItems as $requestItem) { $relation = [ + // @phpstan-ignore-next-line 'role_group_id' => $role_group->id, 'role_group_permission_type' => $item['role_group_permission_type'], 'role_group_target_id' => array_get($requestItem, 'id'), @@ -533,8 +550,10 @@ protected function saveRolePermission($id = null) admin_toastr(trans('admin.save_succeeded')); if ($request->get('after-save', 0) == 1) { + // @phpstan-ignore-next-line return redirect(admin_urls('role_group', $role_group->id, 'edit?form_type=1')); } elseif ($request->get('after-save', 0) === 'form_type_2') { + // @phpstan-ignore-next-line return redirect(admin_urls('role_group', $role_group->id, 'edit?form_type=2')); } else { return redirect(admin_url('role_group')); @@ -546,6 +565,7 @@ protected function saveRolePermission($id = null) } } + // @phpstan-ignore-next-line protected function saveUserOrganization($id = null) { if (!$this->hasPermission_UserOrganization()) { @@ -557,6 +577,7 @@ protected function saveUserOrganization($id = null) // validation $form = $this->formUserOrganization($id); + // @phpstan-ignore-next-line if (($response = $form->validateRedirect($request)) instanceof \Illuminate\Http\RedirectResponse) { return $response; } @@ -621,6 +642,7 @@ protected function saveUserOrganization($id = null) * @param string|int|null $id * @return array */ + // @phpstan-ignore-next-line protected function getProgressInfo($isSelectTarget, $id = null) { $steps[] = [ @@ -639,6 +661,7 @@ protected function getProgressInfo($isSelectTarget, $id = null) return $steps; } + // @phpstan-ignore-next-line protected function validateForm($isRolePermissionPage = true) { if ($isRolePermissionPage) { @@ -664,6 +687,7 @@ protected function validateForm($isRolePermissionPage = true) * @param string|int $id * @return array */ + // @phpstan-ignore-next-line protected function validateAccessable(Request $request, $id) { $result = []; @@ -742,16 +766,19 @@ protected function appendTools($box, $id = null, $isRolePermissionPage = true) } } + // @phpstan-ignore-next-line protected function getModel($id) { return RoleGroup::find($id); } + // @phpstan-ignore-next-line protected function widgetDestroy($id) { try { collect(explode(',', $id))->filter()->each(function ($id) { $model = RoleGroup::findOrFail($id); + // @phpstan-ignore-next-line $model->delete(); }); @@ -767,6 +794,7 @@ protected function widgetDestroy($id) * * @return \Illuminate\Support\Collection */ + // @phpstan-ignore-next-line protected function getTables(bool $isMaster) { return CustomTable::filterList(null, ['checkPermission' => false, 'filter' => function ($model) use ($isMaster) { @@ -776,10 +804,12 @@ protected function getTables(bool $isMaster) }]); } + // @phpstan-ignore-next-line protected function hasPermission_Permission() { return \Exment::user()->hasPermission([Permission::ROLE_GROUP_ALL, Permission::ROLE_GROUP_PERMISSION]); } + // @phpstan-ignore-next-line protected function hasPermission_UserOrganization() { return \Exment::user()->hasPermission([Permission::ROLE_GROUP_ALL, Permission::ROLE_GROUP_USER_ORGANIZATION]); @@ -788,6 +818,7 @@ protected function hasPermission_UserOrganization() /** * get import modal */ + // @phpstan-ignore-next-line public function importModal(Request $request) { $service = $this->getImportExportService(); @@ -797,6 +828,7 @@ public function importModal(Request $request) /** * @param Request $request */ + // @phpstan-ignore-next-line public function import(Request $request) { // create exporter @@ -805,6 +837,7 @@ public function import(Request $request) if ($service->format() == 'csv') { $file = $request->file('custom_table_file'); + // @phpstan-ignore-next-line $file_name = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME); $service->filebasename($file_name); } diff --git a/src/Controllers/SearchController.php b/src/Controllers/SearchController.php index a18814f0d..092dea8c7 100644 --- a/src/Controllers/SearchController.php +++ b/src/Controllers/SearchController.php @@ -17,6 +17,7 @@ class SearchController extends AdminControllerBase { + // @phpstan-ignore-next-line protected $custom_table; @@ -25,6 +26,7 @@ class SearchController extends AdminControllerBase /** * Rendering search header for adminLTE header */ + // @phpstan-ignore-next-line public static function renderSearchHeader() { // create searching javascript @@ -40,6 +42,7 @@ public static function renderSearchHeader() * @param Request $request * @return array */ + // @phpstan-ignore-next-line public function header(Request $request) { $q = $request->input('query'); @@ -89,8 +92,10 @@ public function header(Request $request) public function index(Request $request, Content $content) { if ($request->has('table_name') && $request->has('value_id')) { + // @phpstan-ignore-next-line return $this->getRelationSearch($request, $content); } else { + // @phpstan-ignore-next-line return $this->getFreeWord($request, $content); } } @@ -125,6 +130,7 @@ protected function getFreeWord(Request $request, Content $content) /** * Get Search enabled table list */ + // @phpstan-ignore-next-line protected function getSearchTargetTable($value_table = null) { $results = []; @@ -156,6 +162,7 @@ protected function getSearchTargetTable($value_table = null) /** * Get search results using query */ + // @phpstan-ignore-next-line public function getLists(Request $request) { $q = $request->input('query'); @@ -173,6 +180,7 @@ public function getLists(Request $request) /** * Get search results using query */ + // @phpstan-ignore-next-line public function getList(Request $request) { $q = $request->input('query'); @@ -184,6 +192,7 @@ public function getList(Request $request) /** * Get search results item using query */ + // @phpstan-ignore-next-line protected function getListItem(Request $request, $q, $table_name) { $custom_table = CustomTable::getEloquent($table_name); @@ -288,6 +297,7 @@ protected function getRelationSearch(Request $request, Content $content) /** * get query relation value */ + // @phpstan-ignore-next-line public function getRelationList(Request $request) { // value_id is the id user selected. @@ -363,6 +373,7 @@ public function getRelationList(Request $request) * Get Search enabled relation table list. * It contains search_type(self, select_table, one_to_many, many_to_many) */ + // @phpstan-ignore-next-line protected function getSearchTargetRelationTable($value_table) { $results = []; @@ -384,6 +395,7 @@ protected function getSearchTargetRelationTable($value_table) } return $results; } + // @phpstan-ignore-next-line protected function getTableArray($table, $search_type = null) { $array = [ @@ -405,6 +417,7 @@ protected function getTableArray($table, $search_type = null) $array['box_key'] = short_uuid(); return $array; } + // @phpstan-ignore-next-line protected function getBoxHeaderHtml($custom_table, $query = []) { // boxheader @@ -429,6 +442,7 @@ protected function getBoxHeaderHtml($custom_table, $query = []) /** * set common script for list or relation search */ + // @phpstan-ignore-next-line protected function setCommonScript(bool $isList) { // create searching javascript diff --git a/src/Controllers/SystemController.php b/src/Controllers/SystemController.php index 8fe36b5b6..c222ef9bb 100644 --- a/src/Controllers/SystemController.php +++ b/src/Controllers/SystemController.php @@ -63,7 +63,7 @@ protected function formBasicBox(Request $request, Content $content) { $this->AdminContent($content); $form = $this->formBasic($request); - /** @phpstan-ignore-next-line Encore\Admin\Widgets\Box constructor expects string, Encore\Admin\Widgets\Form given */ + // @phpstan-ignore-next-line $box = new Box(exmtrans('common.basic_setting'), $form); $box->tools(new Tools\SystemChangePageMenu()); @@ -127,7 +127,7 @@ protected function formAdvancedBox(Request $request, Content $content) $this->AdminContent($content); $form = $this->formAdvanced($request); - /** @phpstan-ignore-next-line Encore\Admin\Widgets\Box constructor expects string, Encore\Admin\Widgets\Form given */ + // @phpstan-ignore-next-line $box = new Box(exmtrans('common.detail_setting'), $form); $box->tools(new Tools\SystemChangePageMenu()); diff --git a/src/Controllers/TemplateController.php b/src/Controllers/TemplateController.php index cc7f50b93..7b858e07e 100644 --- a/src/Controllers/TemplateController.php +++ b/src/Controllers/TemplateController.php @@ -38,6 +38,7 @@ public function index(Request $request, Content $content) /** * search template */ + // @phpstan-ignore-next-line public function searchTemplate(Request $request) { // search from exment api @@ -89,6 +90,7 @@ public function searchTemplate(Request $request) if (is_null($array)) { $array = []; } + // @phpstan-ignore-next-line $no_thumbnail_file = base64_encode(file_get_contents(exment_package_path('templates/noimage.png'))); $datalist = []; @@ -152,10 +154,11 @@ public function searchTemplate(Request $request) /** * create export box */ + // @phpstan-ignore-next-line protected function exportBox(Content $content) { $form = $this->exportBoxForm(); - /** @phpstan-ignore-next-line Encore\Admin\Widgets\Box constructor expects string, Encore\Admin\Widgets\Form given */ + // @phpstan-ignore-next-line $content->row((new Box(exmtrans('template.header_export'), $form))->style('info')); } @@ -214,6 +217,7 @@ protected function exportBoxForm() /** * create import box */ + // @phpstan-ignore-next-line protected function importBox(Content $content) { $form = new \Encore\Admin\Widgets\Form(); @@ -223,13 +227,14 @@ protected function importBox(Content $content) $form->descriptionHtml(exmtrans('template.description_import')); $this->addTemplateTile($form); $form->hidden('_token')->default(csrf_token()); - /** @phpstan-ignore-next-line Encore\Admin\Widgets\Box constructor expects string, Encore\Admin\Widgets\Form given */ + // @phpstan-ignore-next-line $content->row((new Box(exmtrans('template.header_import'), $form))->style('info')); } /** * export */ + // @phpstan-ignore-next-line public function export(Request $request) { // validation @@ -255,6 +260,7 @@ public function export(Request $request) /** * import */ + // @phpstan-ignore-next-line public function import(Request $request) { \Exment::setTimeLimitLong(); @@ -275,6 +281,7 @@ public function import(Request $request) /** * delete template */ + // @phpstan-ignore-next-line public function delete(Request $request) { // install templates selected tiles. diff --git a/src/Controllers/WorkflowController.php b/src/Controllers/WorkflowController.php index b987a4838..c51d53ac9 100644 --- a/src/Controllers/WorkflowController.php +++ b/src/Controllers/WorkflowController.php @@ -45,6 +45,7 @@ class WorkflowController extends AdminControllerBase HasResourceActions::destroy as destroyTrait; } + // @phpstan-ignore-next-line protected $exists = false; public function __construct() @@ -106,7 +107,7 @@ protected function grid() ))->render()); } - /** @phpstan-ignore-next-line Cannot call method canActivate() on stdClass. */ + // @phpstan-ignore-next-line if ($actions->row->canActivate()) { $actions->prepend((new Tools\ModalLink( admin_urls('workflow', $actions->row->id, 'activateModal'), @@ -176,6 +177,7 @@ protected function grid() * @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface */ + // @phpstan-ignore-next-line protected function form($id = null) { if (!isset($id)) { @@ -200,6 +202,7 @@ protected function form($id = null) * * @return Form */ + // @phpstan-ignore-next-line public function action(Request $request, Content $content, $id) { return $this->AdminContent($content)->body($this->actionForm($id)->edit($id)); @@ -211,6 +214,7 @@ public function action(Request $request, Content $content, $id) * @param $id * @return \Illuminate\Http\JsonResponse */ + // @phpstan-ignore-next-line public function destroy($id) { $this->isDeleteForce = true; @@ -222,6 +226,7 @@ public function destroy($id) * * @return Form */ + // @phpstan-ignore-next-line protected function statusForm($id = null) { $workflow = Workflow::getEloquent($id); @@ -379,6 +384,7 @@ protected function statusForm($id = null) * * @return Form */ + // @phpstan-ignore-next-line protected function actionForm($id) { $workflow = Workflow::getEloquent($id); @@ -596,7 +602,7 @@ protected function beginningForm() $results = []; - /** @phpstan-ignore-next-line Call to function is_null() with mixed will always evaluate to false. */ + // @phpstan-ignore-next-line if (is_null($results = old('workflow_tables'))) { $workflowTables = WorkflowTable::with(['workflow', 'custom_table'])->get() ->filter(function ($workflowTable) { @@ -673,7 +679,7 @@ protected function beginningForm() $form->html(view('exment::workflow.beginning', [ 'items' => $results ])->render()); - /** @phpstan-ignore-next-line constructor expects string, Encore\Admin\Widgets\Form given */ + // @phpstan-ignore-next-line $box = new Box(exmtrans('workflow.beginning'), $form); $box->tools(view('exment::tools.button', [ 'href' => admin_url('workflow'), @@ -761,6 +767,7 @@ protected function beginningPost(Request $request) return back(); } + // @phpstan-ignore-next-line public function appendActivateButton($workflow, $tools) { if (isset($workflow) && $workflow->canActivate()) { @@ -778,6 +785,7 @@ public function appendActivateButton($workflow, $tools) /** * Append table setting button */ + // @phpstan-ignore-next-line public function appendTableSettingButton($workflow, $tools) { if (isset($workflow) && boolval($workflow->setting_completed_flg)) { @@ -790,6 +798,7 @@ public function appendTableSettingButton($workflow, $tools) } } + // @phpstan-ignore-next-line public function disableDelete($workflow, $tools) { if (isset($workflow) && $workflow->disabled_delete) { @@ -817,6 +826,7 @@ public function disableDelete($workflow, $tools) * @param $id * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|Response */ + // @phpstan-ignore-next-line public function activate(Request $request, $id) { $workflow = Workflow::getEloquent($id); @@ -858,6 +868,7 @@ public function activate(Request $request, $id) * @param $id * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|Response */ + // @phpstan-ignore-next-line public function deactivate(Request $request, $id) { $workflow = Workflow::getEloquent($id); @@ -889,6 +900,7 @@ public function deactivate(Request $request, $id) ]); } + // @phpstan-ignore-next-line protected function appendWorkflowNotify($workflow) { // get mail template @@ -915,6 +927,7 @@ protected function appendWorkflowNotify($workflow) /** * validate before save. */ + // @phpstan-ignore-next-line protected function validateData(Form $form) { $request = request(); @@ -1041,6 +1054,7 @@ protected function validateData(Form $form) * @param $id * @return Response */ + // @phpstan-ignore-next-line public function targetModal(Request $request, $id) { $workflow = Workflow::getEloquent($id); @@ -1133,6 +1147,7 @@ public function targetModal(Request $request, $id) * @param $id * @return Response */ + // @phpstan-ignore-next-line public function conditionModal(Request $request, $id) { $workflow = Workflow::getEloquent($id); @@ -1239,6 +1254,7 @@ public function conditionModal(Request $request, $id) * @param $id * @return Response */ + // @phpstan-ignore-next-line public function activateModal(Request $request, $id) { $workflow = Workflow::getEloquent($id); @@ -1271,6 +1287,7 @@ public function activateModal(Request $request, $id) * @param $id * @return Response */ + // @phpstan-ignore-next-line public function deactivateModal(Request $request, $id) { $workflow = Workflow::getEloquent($id); @@ -1301,6 +1318,7 @@ public function deactivateModal(Request $request, $id) * * @return ModalForm */ + // @phpstan-ignore-next-line protected function getUserOrgModalForm(?CustomTable $custom_table, ?Workflow $workflow, $value = [], $options = []) { $options = array_merge([ diff --git a/src/Controllers/WorkflowNotifyController.php b/src/Controllers/WorkflowNotifyController.php index 3022298fa..fe8761149 100644 --- a/src/Controllers/WorkflowNotifyController.php +++ b/src/Controllers/WorkflowNotifyController.php @@ -29,6 +29,7 @@ class WorkflowNotifyController extends Controller use WorkflowTrait; use ExmentControllerTrait; + // @phpstan-ignore-next-line protected $workflow; public function __construct() @@ -44,6 +45,7 @@ public function __construct() * @param array $parameters * @return \Symfony\Component\HttpFoundation\Response */ + // @phpstan-ignore-next-line public function callAction($method, $parameters) { $this->workflow = Workflow::getEloquent(array_get($parameters, 'workflow_id')); @@ -62,6 +64,7 @@ public function callAction($method, $parameters) public function create(Request $request, Content $content) { if (!is_null($copy_id = $request->get('copy_id'))) { + // @phpstan-ignore-next-line return $this->AdminContent($content)->body($this->form(null, $copy_id)->replicate($copy_id, ['notify_view_name'])); } @@ -140,6 +143,7 @@ protected function grid() * @param $copy_id * @return Form|false|void */ + // @phpstan-ignore-next-line protected function form($id = null, $copy_id = null) { if (!$this->hasPermissionEdit($id)) { @@ -150,6 +154,7 @@ protected function form($id = null, $copy_id = null) $form->progressTracker()->options($this->getProgressInfo($this->workflow, 3)); $notify = Notify::find($id); + // @phpstan-ignore-next-line if ($notify && $notify->notify_trigger != NotifyTrigger::WORKFLOW) { Checker::error(exmtrans('common.message.wrongdata')); return false; @@ -161,6 +166,7 @@ protected function form($id = null, $copy_id = null) $form->display('workflow_view_name', exmtrans("workflow.workflow_view_name")) ->default($this->workflow->workflow_view_name); + // @phpstan-ignore-next-line $this->setBasicForm($form, $notify); $form->exmheader(exmtrans('notify.header_trigger'))->hr(); @@ -197,6 +203,7 @@ protected function form($id = null, $copy_id = null) ->help(exmtrans("notify.help.notify_action")) ; + // @phpstan-ignore-next-line $this->setActionForm($form, $notify, null, $this->workflow); })->required()->disableHeader(); @@ -205,8 +212,10 @@ protected function form($id = null, $copy_id = null) ->where('value->mail_key_name', MailKeyName::WORKFLOW_NOTIFY) ->first(); + // @phpstan-ignore-next-line $this->setMailTemplateForm($form, $notify, $mail_template ? $mail_template->id : null); + // @phpstan-ignore-next-line $this->setFooterForm($form, $notify); $form->tools(function (Form\Tools $tools) use ($workflow) { @@ -233,6 +242,7 @@ protected function form($id = null, $copy_id = null) } + // @phpstan-ignore-next-line public function notify_action_target(Request $request, $workflow_id) { $options = NotifyService::getNotifyTargetColumns(null, $request->get('q'), [ @@ -263,6 +273,7 @@ public function index(Request $request, Content $content) * @param $id * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ + // @phpstan-ignore-next-line public function show(Request $request, Content $content, $workflow_id, $id) { if (method_exists($this, 'detail')) { @@ -281,8 +292,10 @@ public function show(Request $request, Content $content, $workflow_id, $id) * @param Content $content * @return Content */ + // @phpstan-ignore-next-line public function edit(Request $request, Content $content, $workflow_id, $id) { + // @phpstan-ignore-next-line return $this->AdminContent($content)->body($this->form($id)->edit($id)); } @@ -293,8 +306,10 @@ public function edit(Request $request, Content $content, $workflow_id, $id) * * @return \Illuminate\Http\Response */ + // @phpstan-ignore-next-line public function update($workflow_id, $id) { + // @phpstan-ignore-next-line return $this->form($id)->update($id); } @@ -305,6 +320,7 @@ public function update($workflow_id, $id) * * @return \Illuminate\Http\JsonResponse */ + // @phpstan-ignore-next-line public function destroy($workflow_id, $id) { return $this->destroyTrait($id); diff --git a/src/Controllers/WorkflowTrait.php b/src/Controllers/WorkflowTrait.php index aa99541af..3dfea630c 100644 --- a/src/Controllers/WorkflowTrait.php +++ b/src/Controllers/WorkflowTrait.php @@ -6,6 +6,7 @@ trait WorkflowTrait { + // @phpstan-ignore-next-line protected function getProgressInfo($workflow, $action) { $id = $workflow->id ?? null; @@ -16,7 +17,9 @@ protected function getProgressInfo($workflow, $action) $workflow_status_url = null; if (isset($id)) { $hasAction = WorkflowAction::where('workflow_id', $id)->count() > 0; + /** @phpstan-ignore-next-line */ $workflow_action_url = admin_urls('workflow', $id, 'edit?action=2'); + /** @phpstan-ignore-next-line */ $workflow_status_url = admin_urls('workflow', $id, 'edit'); } @@ -24,6 +27,7 @@ protected function getProgressInfo($workflow, $action) 'active' => ($action == 1), 'complete' => false, 'url' => ($action != 1) ? $workflow_status_url : null, + /** @phpstan-ignore-next-line */ 'description' => exmtrans('workflow.workflow_statuses') ]; @@ -31,14 +35,18 @@ protected function getProgressInfo($workflow, $action) 'active' => ($action == 2), 'complete' => false, 'url' => ($action != 2) ? $workflow_action_url : null, + /** @phpstan-ignore-next-line */ 'description' => exmtrans('workflow.workflow_actions') ]; + /** @phpstan-ignore-next-line */ if (isset($workflow) && boolval($workflow->setting_completed_flg)) { $steps[] = [ 'active' => ($action == 3), 'complete' => false, + /** @phpstan-ignore-next-line */ 'url' => ($action != 3) ? admin_urls("workflow", $workflow->id, "notify") : null, + /** @phpstan-ignore-next-line */ 'description' => exmtrans('notify.header'), ]; @@ -46,6 +54,7 @@ protected function getProgressInfo($workflow, $action) 'active' => ($action == 4), 'complete' => false, 'url' => ($action != 4) ? admin_url('workflow/beginning') : null, + /** @phpstan-ignore-next-line */ 'description' => exmtrans('workflow.beginning'), ]; } diff --git a/src/DashboardBoxItems/CalendarItem.php b/src/DashboardBoxItems/CalendarItem.php index b762d3ae7..eac8ceb27 100644 --- a/src/DashboardBoxItems/CalendarItem.php +++ b/src/DashboardBoxItems/CalendarItem.php @@ -14,13 +14,17 @@ class CalendarItem implements ItemInterface { use TableItemTrait; + // @phpstan-ignore-next-line protected $dashboard_box; + // @phpstan-ignore-next-line protected $custom_table; + // @phpstan-ignore-next-line protected $custom_view; + // @phpstan-ignore-next-line public function __construct($dashboard_box) { $this->dashboard_box = $dashboard_box; @@ -41,6 +45,7 @@ public function __construct($dashboard_box) /** * get header */ + // @phpstan-ignore-next-line public function header() { return $this->tableheader(); @@ -49,6 +54,7 @@ public function header() /** * get footer */ + // @phpstan-ignore-next-line public function footer() { return null; @@ -57,6 +63,7 @@ public function footer() /** * saving event */ + // @phpstan-ignore-next-line public static function saving(&$form) { } @@ -65,6 +72,7 @@ public static function saving(&$form) * get html(for display) * *this function calls from non-value method. So please escape if not necessary unescape. */ + // @phpstan-ignore-next-line public function body() { if (($result = $this->hasPermission()) !== true) { @@ -90,6 +98,7 @@ public function body() /** * set laravel admin embeds option */ + // @phpstan-ignore-next-line public static function setAdminOptions(&$form, $dashboard) { $form->select('calendar_type', exmtrans("dashboard.dashboard_box_options.calendar_type")) @@ -117,6 +126,7 @@ public static function setAdminOptions(&$form, $dashboard) }); } + // @phpstan-ignore-next-line public static function getItem(...$args) { list($dashboard_box) = $args + [null]; diff --git a/src/DashboardBoxItems/ChartItem.php b/src/DashboardBoxItems/ChartItem.php index 1aa7317b1..8ad576d45 100644 --- a/src/DashboardBoxItems/ChartItem.php +++ b/src/DashboardBoxItems/ChartItem.php @@ -18,24 +18,34 @@ class ChartItem implements ItemInterface { use TableItemTrait; + // @phpstan-ignore-next-line protected $dashboard_box; + // @phpstan-ignore-next-line protected $custom_table; + // @phpstan-ignore-next-line protected $custom_view; + // @phpstan-ignore-next-line protected $axis_x; + // @phpstan-ignore-next-line protected $axis_y; + // @phpstan-ignore-next-line protected $chart_type; + // @phpstan-ignore-next-line protected $chart_options; + // @phpstan-ignore-next-line protected $chart_axis_label; + // @phpstan-ignore-next-line protected $chart_axis_name; + // @phpstan-ignore-next-line public function __construct($dashboard_box) { $this->dashboard_box = $dashboard_box; @@ -59,6 +69,7 @@ public function __construct($dashboard_box) /** * get header */ + // @phpstan-ignore-next-line public function header() { return $this->tableheader(); @@ -67,6 +78,7 @@ public function header() /** * get footer */ + // @phpstan-ignore-next-line public function footer() { return null; @@ -76,6 +88,7 @@ public function footer() * get html(for display) * *this function calls from non-value method. So please escape if not necessary unescape. */ + // @phpstan-ignore-next-line public function body() { if (($result = $this->hasPermission()) !== true) { @@ -122,6 +135,7 @@ public function body() /** * get chart data from list-view */ + // @phpstan-ignore-next-line protected function getListData() { $view_column_x = CustomViewSummary::getSummaryViewColumn($this->axis_x); @@ -166,6 +180,7 @@ protected function getListData() /** * get chart data from aggregate-view */ + // @phpstan-ignore-next-line protected function getAggregateData() { $view_column_x_list = $this->custom_view->custom_view_columns; @@ -213,6 +228,7 @@ protected function getAggregateData() /** * set laravel admin embeds option */ + // @phpstan-ignore-next-line public static function setAdminOptions(&$form, $dashboard) { $form->select('chart_type', exmtrans("dashboard.dashboard_box_options.chart_type")) @@ -316,6 +332,7 @@ function setChartOptions(val) { /** * saving event */ + // @phpstan-ignore-next-line public static function saving(&$form) { // except fields not visible @@ -347,6 +364,7 @@ public static function saving(&$form) * * @return array Chart color array */ + // @phpstan-ignore-next-line protected function getChartColor($datacnt) { $chart_color = config('exment.chart_backgroundColor'); @@ -367,6 +385,7 @@ protected function getChartColor($datacnt) } } + // @phpstan-ignore-next-line public static function getItem(...$args) { list($dashboard_box) = $args + [null]; diff --git a/src/DashboardBoxItems/ItemInterface.php b/src/DashboardBoxItems/ItemInterface.php index 653c83d29..b977dbd0b 100644 --- a/src/DashboardBoxItems/ItemInterface.php +++ b/src/DashboardBoxItems/ItemInterface.php @@ -7,30 +7,36 @@ interface ItemInterface /** * get header */ + // @phpstan-ignore-next-line public function header(); /** * get body */ + // @phpstan-ignore-next-line public function body(); /** * get footer */ + // @phpstan-ignore-next-line public function footer(); /** * set laravel admin embeds option */ + // @phpstan-ignore-next-line public static function setAdminOptions(&$form, $dashboard); /** * saving event */ + // @phpstan-ignore-next-line public static function saving(&$form); /** * get item model */ + // @phpstan-ignore-next-line public static function getItem(...$options); } diff --git a/src/DashboardBoxItems/ListItem.php b/src/DashboardBoxItems/ListItem.php index cf3948f08..8171bfd39 100644 --- a/src/DashboardBoxItems/ListItem.php +++ b/src/DashboardBoxItems/ListItem.php @@ -15,14 +15,19 @@ class ListItem implements ItemInterface { use TableItemTrait; + // @phpstan-ignore-next-line protected $dashboard_box; + // @phpstan-ignore-next-line protected $custom_table; + // @phpstan-ignore-next-line protected $custom_view; + // @phpstan-ignore-next-line protected $paginate; + // @phpstan-ignore-next-line public function __construct($dashboard_box) { $this->dashboard_box = $dashboard_box; @@ -46,6 +51,7 @@ public function __construct($dashboard_box) /** * get header */ + // @phpstan-ignore-next-line public function header() { return $this->tableheader(); @@ -55,6 +61,7 @@ public function header() * get body * *this function calls from non-value method. So please escape if not necessary unescape. */ + // @phpstan-ignore-next-line public function body() { // get paginate @@ -91,6 +98,7 @@ public function body() * get footer * *this function calls from non-value method. So please escape if not necessary unescape. */ + // @phpstan-ignore-next-line public function footer() { // get paginate @@ -108,6 +116,7 @@ public function footer() /** * set laravel admin embeds option */ + // @phpstan-ignore-next-line public static function setAdminOptions(&$form, $dashboard) { $form->select('pager_count', trans("admin.show")) @@ -136,10 +145,12 @@ public static function setAdminOptions(&$form, $dashboard) /** * saving event */ + // @phpstan-ignore-next-line public static function saving(&$form) { } + // @phpstan-ignore-next-line public static function getItem(...$args) { list($dashboard_box) = $args + [null]; @@ -149,6 +160,7 @@ public static function getItem(...$args) /** * set paginate */ + // @phpstan-ignore-next-line protected function setPaginate() { if (isset($this->paginate)) { diff --git a/src/DashboardBoxItems/PluginItem.php b/src/DashboardBoxItems/PluginItem.php index 3f17073a7..d7787ab67 100644 --- a/src/DashboardBoxItems/PluginItem.php +++ b/src/DashboardBoxItems/PluginItem.php @@ -8,10 +8,14 @@ class PluginItem implements ItemInterface { + // @phpstan-ignore-next-line protected $dashboard_box; + // @phpstan-ignore-next-line protected $plugin; + // @phpstan-ignore-next-line protected $pluginItem; + // @phpstan-ignore-next-line public function __construct($dashboard_box) { $this->dashboard_box = $dashboard_box; @@ -29,6 +33,7 @@ public function __construct($dashboard_box) /** * get header */ + // @phpstan-ignore-next-line public function header() { if (($result = $this->hasPermission()) !== true) { @@ -41,6 +46,7 @@ public function header() /** * get html body */ + // @phpstan-ignore-next-line public function body() { if (($result = $this->hasPermission()) !== true) { @@ -53,6 +59,7 @@ public function body() /** * get footer */ + // @phpstan-ignore-next-line public function footer() { if (($result = $this->hasPermission()) !== true) { @@ -67,6 +74,7 @@ public function footer() * * @return array */ + // @phpstan-ignore-next-line public function attributes() { return [ @@ -80,6 +88,7 @@ public function attributes() /** * set laravel admin embeds option */ + // @phpstan-ignore-next-line public static function setAdminOptions(&$form, $dashboard) { // show plugin list @@ -96,10 +105,12 @@ public static function setAdminOptions(&$form, $dashboard) /** * saving event */ + // @phpstan-ignore-next-line public static function saving(&$form) { } + // @phpstan-ignore-next-line public static function getItem(...$args) { list($dashboard_box) = $args + [null]; @@ -111,6 +122,7 @@ public static function getItem(...$args) * * @return array|\Illuminate\Contracts\Translation\Translator|string|true|null */ + // @phpstan-ignore-next-line protected function hasPermission() { // if table not found, break diff --git a/src/DashboardBoxItems/SystemItem.php b/src/DashboardBoxItems/SystemItem.php index 4ec840930..12d11a455 100644 --- a/src/DashboardBoxItems/SystemItem.php +++ b/src/DashboardBoxItems/SystemItem.php @@ -11,9 +11,12 @@ class SystemItem implements ItemInterface { + // @phpstan-ignore-next-line protected $dashboard_box; + // @phpstan-ignore-next-line protected $systemItem; + // @phpstan-ignore-next-line public function __construct($dashboard_box) { $this->dashboard_box = $dashboard_box; @@ -33,6 +36,7 @@ public function __construct($dashboard_box) /** * get header */ + // @phpstan-ignore-next-line public function header() { return $this->systemItem->header(); @@ -41,6 +45,7 @@ public function header() /** * get footer */ + // @phpstan-ignore-next-line public function footer() { return $this->systemItem->footer(); @@ -49,6 +54,7 @@ public function footer() /** * get html body */ + // @phpstan-ignore-next-line public function body() { return $this->systemItem->body(); @@ -59,6 +65,7 @@ public function body() * * @return array */ + // @phpstan-ignore-next-line public function attributes() { $target_system_id = $this->dashboard_box->getOption('target_system_id'); @@ -73,6 +80,7 @@ public function attributes() /** * set laravel admin embeds option */ + // @phpstan-ignore-next-line public static function setAdminOptions(&$form, $dashboard) { // show system item list @@ -100,10 +108,12 @@ public static function setAdminOptions(&$form, $dashboard) /** * saving event */ + // @phpstan-ignore-next-line public static function saving(&$form) { } + // @phpstan-ignore-next-line public static function getItem(...$args) { list($dashboard_box) = $args + [null]; diff --git a/src/DashboardBoxItems/SystemItems/Barcode.php b/src/DashboardBoxItems/SystemItems/Barcode.php index 38a5e3d2e..64b7e13e0 100644 --- a/src/DashboardBoxItems/SystemItems/Barcode.php +++ b/src/DashboardBoxItems/SystemItems/Barcode.php @@ -9,6 +9,7 @@ class Barcode /** * get header */ + // @phpstan-ignore-next-line public function header() { return null; @@ -17,6 +18,7 @@ public function header() /** * get footer */ + // @phpstan-ignore-next-line public function footer() { return null; @@ -25,12 +27,13 @@ public function footer() /** * get html body */ + // @phpstan-ignore-next-line public function body() { $current_locale = App::getLocale(); $text_button = config("exment.text_scan_button_{$current_locale}"); $label = exmtrans("custom_table.qr_code.reading", $text_button ?? exmtrans('dashboard.dashboard_box_system_pages.barcode')); - /** @phpstan-ignore-next-line Expression on left side of ?? is not nullable. */ + // @phpstan-ignore-next-line return view('exment::dashboard.system.camera', [ 'label' => $label, ])->render() ?? null; diff --git a/src/DashboardBoxItems/SystemItems/Editor.php b/src/DashboardBoxItems/SystemItems/Editor.php index 551215fb4..0ed4fa8d8 100644 --- a/src/DashboardBoxItems/SystemItems/Editor.php +++ b/src/DashboardBoxItems/SystemItems/Editor.php @@ -7,6 +7,7 @@ class Editor { + // @phpstan-ignore-next-line protected $dashboard_box; public function __construct(?DashboardBox $dashboard_box) @@ -17,6 +18,7 @@ public function __construct(?DashboardBox $dashboard_box) /** * get header */ + // @phpstan-ignore-next-line public function header() { return null; @@ -25,6 +27,7 @@ public function header() /** * get footer */ + // @phpstan-ignore-next-line public function footer() { return null; @@ -33,6 +36,7 @@ public function footer() /** * get html body */ + // @phpstan-ignore-next-line public function body() { // escape script. @@ -42,6 +46,7 @@ public function body() /** * set laravel admin embeds option */ + // @phpstan-ignore-next-line public static function setAdminOptions(&$form, $dashboard) { $form->tinymce('content', exmtrans('dashboard.dashboard_box_options.content')) diff --git a/src/DashboardBoxItems/SystemItems/Guideline.php b/src/DashboardBoxItems/SystemItems/Guideline.php index 1bd858548..10555e6e8 100644 --- a/src/DashboardBoxItems/SystemItems/Guideline.php +++ b/src/DashboardBoxItems/SystemItems/Guideline.php @@ -7,6 +7,7 @@ class Guideline /** * get header */ + // @phpstan-ignore-next-line public function header() { return null; @@ -15,6 +16,7 @@ public function header() /** * get footer */ + // @phpstan-ignore-next-line public function footer() { return null; @@ -23,9 +25,10 @@ public function footer() /** * get html body */ + // @phpstan-ignore-next-line public function body() { - /** @phpstan-ignore-next-line Expression on left side of ?? is not nullable. */ + // @phpstan-ignore-next-line return view('exment::dashboard.system.guideline')->render() ?? null; } } diff --git a/src/DashboardBoxItems/SystemItems/Html.php b/src/DashboardBoxItems/SystemItems/Html.php index 86dcb866d..357d4ee9f 100644 --- a/src/DashboardBoxItems/SystemItems/Html.php +++ b/src/DashboardBoxItems/SystemItems/Html.php @@ -7,6 +7,7 @@ class Html { + // @phpstan-ignore-next-line protected $dashboard_box; public function __construct(?DashboardBox $dashboard_box) @@ -17,6 +18,7 @@ public function __construct(?DashboardBox $dashboard_box) /** * get header */ + // @phpstan-ignore-next-line public function header() { return null; @@ -25,6 +27,7 @@ public function header() /** * get footer */ + // @phpstan-ignore-next-line public function footer() { return null; @@ -33,6 +36,7 @@ public function footer() /** * get html body */ + // @phpstan-ignore-next-line public function body() { // not escape. @@ -42,6 +46,7 @@ public function body() /** * set laravel admin embeds option */ + // @phpstan-ignore-next-line public static function setAdminOptions(&$form, $dashboard) { $form->textarea('html', exmtrans('dashboard.dashboard_box_options.html')) diff --git a/src/DashboardBoxItems/SystemItems/News.php b/src/DashboardBoxItems/SystemItems/News.php index e739abddb..e351f70c8 100644 --- a/src/DashboardBoxItems/SystemItems/News.php +++ b/src/DashboardBoxItems/SystemItems/News.php @@ -14,8 +14,10 @@ class News * * @var array */ + // @phpstan-ignore-next-line protected $items = []; + // @phpstan-ignore-next-line protected $outputApi = true; public function __construct() @@ -29,6 +31,7 @@ public function __construct() /** * get header */ + // @phpstan-ignore-next-line public function header() { return null; @@ -37,6 +40,7 @@ public function header() /** * get footer */ + // @phpstan-ignore-next-line public function footer() { if (!$this->outputApi) { @@ -50,6 +54,7 @@ public function footer() /** * get html body */ + // @phpstan-ignore-next-line public function body() { if (!$this->outputApi) { @@ -77,7 +82,7 @@ public function body() $widgetTable = new WidgetTable($headers, $bodies); - /** @phpstan-ignore-next-line Expression on left side of ?? is not nullable. */ + // @phpstan-ignore-next-line return $widgetTable->render() ?? null; } @@ -88,6 +93,7 @@ public function body() * @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface */ + // @phpstan-ignore-next-line protected function getQuery() { $request = request(); @@ -123,10 +129,12 @@ protected function setItems() // if already executed if (isset($update_news)) { $update_news = json_decode_ex($update_news, true); + // @phpstan-ignore-next-line $update_time = array_get($update_news, 'update_time'); if (isset($update_time)) { $update_time = new Carbon($update_time); if ($update_time->diffInMinutes(Carbon::now()) <= 60) { + // @phpstan-ignore-next-line $contents = array_get($update_news, 'contents'); } } @@ -153,6 +161,7 @@ protected function setItems() } // get wordpress items + // @phpstan-ignore-next-line $this->items = json_decode_ex($contents, true); } catch (\Exception $ex) { \Log::error($ex); diff --git a/src/DashboardBoxItems/SystemItems/NotifyNavbar.php b/src/DashboardBoxItems/SystemItems/NotifyNavbar.php index 99d7c2cb6..06e62b191 100644 --- a/src/DashboardBoxItems/SystemItems/NotifyNavbar.php +++ b/src/DashboardBoxItems/SystemItems/NotifyNavbar.php @@ -13,6 +13,7 @@ class NotifyNavbar { + // @phpstan-ignore-next-line protected $dashboard_box; /** @@ -20,6 +21,7 @@ class NotifyNavbar * * @var array|Collection */ + // @phpstan-ignore-next-line protected $items = []; public function __construct(?DashboardBox $dashboard_box) @@ -30,6 +32,7 @@ public function __construct(?DashboardBox $dashboard_box) /** * get header */ + // @phpstan-ignore-next-line public function header() { return null; @@ -38,6 +41,7 @@ public function header() /** * get footer */ + // @phpstan-ignore-next-line public function footer() { $link = admin_url('notify_navbar'); @@ -48,6 +52,7 @@ public function footer() /** * get html body */ + // @phpstan-ignore-next-line public function body() { $this->setItems(); @@ -104,7 +109,7 @@ public function body() $widgetTable = new WidgetTable($headers, $bodies); $widgetTable->class('table table-hover'); - /** @phpstan-ignore-next-line Expression on left side of ?? is not nullable. */ + // @phpstan-ignore-next-line return $widgetTable->render() ?? null; } @@ -134,6 +139,7 @@ protected function setItems() /** * set laravel admin embeds option */ + // @phpstan-ignore-next-line public static function setAdminOptions(&$form, $dashboard) { $grid_per_pages = stringToArray(config('exment.grid_per_pages')); diff --git a/src/DashboardBoxItems/TableItemTrait.php b/src/DashboardBoxItems/TableItemTrait.php index 61be26903..166035322 100644 --- a/src/DashboardBoxItems/TableItemTrait.php +++ b/src/DashboardBoxItems/TableItemTrait.php @@ -16,10 +16,12 @@ trait TableItemTrait * * @return array|string|boolean */ + // @phpstan-ignore-next-line protected function hasPermission() { // if table not found, break if (!isset($this->custom_table) || !isset($this->custom_view)) { + /** @phpstan-ignore-next-line */ return exmtrans('dashboard.message.not_exists_table'); } @@ -31,6 +33,7 @@ protected function hasPermission() return true; } + // @phpstan-ignore-next-line protected function tableheader() { if (($result = $this->hasPermission()) !== true) { @@ -57,6 +60,7 @@ protected function tableheader() * * @return array */ + // @phpstan-ignore-next-line public function attributes() { return [ @@ -66,8 +70,10 @@ public function attributes() ]; } + // @phpstan-ignore-next-line public static function getCustomViewSelectOptions($value, $field, $model, $dashboard, bool $isCalendar = false): array { + /** @phpstan-ignore-next-line */ if (is_nullorempty($field)) { return []; } @@ -77,6 +83,7 @@ public static function getCustomViewSelectOptions($value, $field, $model, $dashb if (isset($value)) { $custom_view = CustomView::getEloquent($value); $custom_table = $custom_view ? $custom_view->custom_table : null; + /** @phpstan-ignore-next-line */ } elseif (!is_nullorempty($field->data())) { $custom_table = CustomTable::getEloquent(array_get($field->data(), 'target_table_id')); } diff --git a/src/DataItems/Form/DefaultForm.php b/src/DataItems/Form/DefaultForm.php index 34328753c..5feedf491 100644 --- a/src/DataItems/Form/DefaultForm.php +++ b/src/DataItems/Form/DefaultForm.php @@ -31,6 +31,7 @@ class DefaultForm extends FormBase { + // @phpstan-ignore-next-line public function __construct($custom_table, $custom_form) { $this->custom_table = $custom_table; @@ -218,11 +219,13 @@ function ($form, $model = null) use ($custom_form_block, $relation, $relation_na /** * set custom form columns */ + // @phpstan-ignore-next-line protected function setCustomFormColumns($form, $custom_form_block) { $custom_form_columns = $custom_form_block->custom_form_columns; // setting fields. // $target_id = $this->id; if (method_exists($form, 'getDataKey')) { + // @phpstan-ignore-next-line $data_key = $form->getDataKey(); if (is_numeric($data_key)) { $target_id = $data_key; @@ -296,6 +299,7 @@ protected function getCustomFormColumns($form, $custom_form_block, $target_custo /** * set custom form columns */ + // @phpstan-ignore-next-line protected function setCustomFormEvents(&$calc_formula_array, &$changedata_array, &$relatedlinkage_array, &$force_caculate_column) { foreach ($this->custom_form->custom_form_blocks as $custom_form_block) { @@ -338,6 +342,7 @@ protected function setCustomFormEvents(&$calc_formula_array, &$changedata_array, } + // @phpstan-ignore-next-line protected function manageFormSaving($form) { // before saving @@ -429,6 +434,7 @@ protected function manageFormSaving($form) }); } + // @phpstan-ignore-next-line protected function manageFormSaved($form, $select_parent = null) { // after saving @@ -568,6 +574,7 @@ protected function manageFormToolButton($form, $custom_table, $custom_form) * "changedata_target_column_id" : trigger column when user select * "changedata_column_id" : set column when getting selected value */ + // @phpstan-ignore-next-line protected function setChangeDataArray(CustomColumn $column, CustomFormBlock $custom_form_block, array $form_column_options, $options, &$changedata_array) { // get this table @@ -647,6 +654,7 @@ protected function setChangeDataArray(CustomColumn $column, CustomFormBlock $cus * set related linkage array. * "related linkage": When selecting a value, change the choices of other list. It's for 1:n relation. */ + // @phpstan-ignore-next-line protected function setRelatedLinkageArray($custom_form_block, $form_column, &$relatedlinkage_array) { // if config "select_relation_linkage_disabled" is true, return @@ -705,6 +713,7 @@ protected function setRelatedLinkageArray($custom_form_block, $form_column, &$re } } + // @phpstan-ignore-next-line protected function setParentSelect($request, $form, $select_parent) { // add parent select @@ -724,6 +733,7 @@ protected function setParentSelect($request, $form, $select_parent) } } + // @phpstan-ignore-next-line protected function setParentSelectOneToMany($request, $form, $select_parent, $relation) { $parent_custom_table = $relation->parent_custom_table; @@ -781,6 +791,7 @@ protected function setParentSelectOneToMany($request, $form, $select_parent, $re } } + // @phpstan-ignore-next-line protected function setParentSelectManyToMany($request, $form, $relation) { $parent_custom_table = $relation->parent_custom_table; @@ -827,6 +838,7 @@ protected function setParentSelectManyToMany($request, $form, $relation) * @param ItemInterface $column_item * @return void */ + // @phpstan-ignore-next-line protected function setColumnItemOption(ItemInterface $column_item, $custom_form_columns) { $column_item->setCustomForm($this->custom_form); diff --git a/src/DataItems/Form/FormBase.php b/src/DataItems/Form/FormBase.php index e6f395728..76ff16963 100644 --- a/src/DataItems/Form/FormBase.php +++ b/src/DataItems/Form/FormBase.php @@ -4,9 +4,13 @@ abstract class FormBase { + // @phpstan-ignore-next-line protected $custom_table; + // @phpstan-ignore-next-line protected $custom_form; + // @phpstan-ignore-next-line protected $id; + // @phpstan-ignore-next-line protected $custom_value; /** @@ -52,6 +56,7 @@ abstract class FormBase protected $asConfirm = false; + // @phpstan-ignore-next-line public static function getItem(...$args) { list($custom_table, $custom_form) = $args + [null, null]; @@ -61,6 +66,7 @@ public static function getItem(...$args) return new static($custom_table, $custom_form); } + // @phpstan-ignore-next-line public function id($id = null) { $this->id = $id; @@ -137,6 +143,7 @@ public function setAsConfirm(bool $asConfirm) return $this; } + // @phpstan-ignore-next-line abstract public function form(); /** diff --git a/src/DataItems/Form/PublicFormForm.php b/src/DataItems/Form/PublicFormForm.php index eaeb63fce..921ac21d7 100644 --- a/src/DataItems/Form/PublicFormForm.php +++ b/src/DataItems/Form/PublicFormForm.php @@ -59,6 +59,7 @@ public function setPublicForm(PublicForm $public_form) * @param ItemInterface $column_item * @return void */ + // @phpstan-ignore-next-line protected function setColumnItemOption(ItemInterface $column_item, $custom_form_columns) { $column_item->options(['public_form' => $this->public_form]); diff --git a/src/DataItems/Grid/CalendarGrid.php b/src/DataItems/Grid/CalendarGrid.php index ff6e3a79d..39b0b3775 100644 --- a/src/DataItems/Grid/CalendarGrid.php +++ b/src/DataItems/Grid/CalendarGrid.php @@ -10,12 +10,14 @@ class CalendarGrid extends GridBase { + // @phpstan-ignore-next-line public function __construct($custom_table, $custom_view) { $this->custom_table = $custom_table; $this->custom_view = $custom_view; } + // @phpstan-ignore-next-line public function grid() { $table_name = $this->custom_table->table_name; @@ -51,6 +53,7 @@ public function grid() * @param CustomTable $custom_table * @return void */ + // @phpstan-ignore-next-line public static function setViewForm($view_kind_type, $form, $custom_table, array $options = []) { static::setViewInfoboxFields($form); diff --git a/src/DataItems/Grid/DefaultGrid.php b/src/DataItems/Grid/DefaultGrid.php index 087ca1141..8d6a5281d 100644 --- a/src/DataItems/Grid/DefaultGrid.php +++ b/src/DataItems/Grid/DefaultGrid.php @@ -31,6 +31,7 @@ class DefaultGrid extends GridBase { + // @phpstan-ignore-next-line public function __construct($custom_table, $custom_view) { $this->custom_table = $custom_table; @@ -89,6 +90,7 @@ public function grid() * @param array $options * @return \Illuminate\Database\Query\Builder|\Illuminate\Database\Schema\Builder */ + // @phpstan-ignore-next-line public function getQuery($query, array $options = []) { // Now only execute filter Model @@ -99,6 +101,7 @@ public function getQuery($query, array $options = []) /** * set laravel-admin grid using custom_view */ + // @phpstan-ignore-next-line public function setGrid($grid) { $custom_table = $this->custom_table; @@ -136,7 +139,7 @@ public function setGrid($grid) ->setClasses($className) ->setHeaderStyle($item->gridHeaderStyle()) ->display(function ($v) use ($item) { - /** @phpstan-ignore-next-line Call to function is_null() with $this(Exceedone\Exment\DataItems\Grid\DefaultGrid) will always evaluate to false. */ + // @phpstan-ignore-next-line if (is_null($this)) { return ''; } @@ -167,6 +170,7 @@ public function setGrid($grid) * * @return void */ + // @phpstan-ignore-next-line protected function gridFilterForModal($grid, $filter_func) { // set request session data url disabled; @@ -232,6 +236,7 @@ protected function getFilterUrl(): string * * @return array offset 0 : html, 1 : script */ + // @phpstan-ignore-next-line public function getFilterHtml() { $classname = getModelName($this->custom_table); @@ -251,12 +256,14 @@ public function getFilterHtml() /** * set grid filter */ + // @phpstan-ignore-next-line protected function setCustomGridFilters($grid, $ajax = false) { $grid->quickSearch(function ($model, $input) { $eloquent = $model->eloquent(); // Only call setSearchQueryOrWhere if exists. (If export, sometimes $eloquent is not Model.) if (method_exists($eloquent, 'setSearchQueryOrWhere')) { + // @phpstan-ignore-next-line $eloquent->setSearchQueryOrWhere($model, $input, ['searchDocument' => true,]); } }, 'left'); @@ -302,6 +309,7 @@ protected function setCustomGridFilters($grid, $ajax = false) /** * Get filter showing columns */ + // @phpstan-ignore-next-line protected function getFilterColumns($filter): \Illuminate\Support\Collection { $filterItems = []; @@ -318,6 +326,7 @@ protected function getFilterColumns($filter): \Illuminate\Support\Collection } /** @var Collection $collection */ + // @phpstan-ignore-next-line $collection = collect($filterItems); return $collection; } @@ -374,6 +383,7 @@ protected function getFilterColumns($filter): \Illuminate\Support\Collection * * @return void */ + // @phpstan-ignore-next-line protected function setRelationFilter(&$filterItems) { // check relation @@ -401,6 +411,7 @@ protected function setRelationFilter(&$filterItems) * * @return void */ + // @phpstan-ignore-next-line protected function setColumnFilter(&$filterItems) { // if modal, skip @@ -434,6 +445,7 @@ protected function setColumnFilter(&$filterItems) * Manage Grid Tool Button * And Manage Batch Action */ + // @phpstan-ignore-next-line protected function manageMenuToolButton($grid) { if ($this->modal) { @@ -460,7 +472,7 @@ protected function manageMenuToolButton($grid) if ($import === true || $export === true) { // todo 通常ビューの場合のみプラグインエクスポートを有効にするための修正です $button = new Tools\ExportImportButton(admin_urls('data', $this->custom_table->table_name), $grid, $export === true, $export === true, $import === true, $export === true); - /** @phpstan-ignore-next-line append() expects Encore\Admin\Grid\Tools\AbstractTool|string, Exceedone\Exment\Form\Tools\ExportImportButton given */ + // @phpstan-ignore-next-line $tools->append($button->setCustomTable($this->custom_table)); } @@ -470,11 +482,11 @@ protected function manageMenuToolButton($grid) // add page change button(contains view seting) if ($this->custom_table->enableTableMenuButton()) { - /** @phpstan-ignore-next-line append() expects Encore\Admin\Grid\Tools\AbstractTool|string, Exceedone\Exment\Form\Tools\CustomTableMenuButton given */ + // @phpstan-ignore-next-line $tools->append(new Tools\CustomTableMenuButton('data', $this->custom_table)); } if ($this->custom_table->enableViewMenuButton()) { - /** @phpstan-ignore-next-line append() expects Encore\Admin\Grid\Tools\AbstractTool|string, Exceedone\Exment\Form\Tools\CustomViewMenuButton given */ + // @phpstan-ignore-next-line $tools->append(new Tools\CustomViewMenuButton($this->custom_table, $this->custom_view)); } @@ -511,6 +523,7 @@ protected function manageMenuToolButton($grid) /** * Management row action */ + // @phpstan-ignore-next-line protected function manageRowAction($grid) { if ($this->modal) { @@ -657,6 +670,7 @@ protected function manageRowAction($grid) /** * @param Request $request */ + // @phpstan-ignore-next-line public function import(Request $request) { $service = $this->getImportExportService() @@ -668,6 +682,7 @@ public function import(Request $request) } // create import and exporter + // @phpstan-ignore-next-line public function getImportExportService($grid = null) { $service = (new DataImportExport\DataImportExportService()) @@ -697,6 +712,7 @@ public function getImportExportService($grid = null) return $service; } + // @phpstan-ignore-next-line public function renderModalFrame() { // get target column id or class @@ -737,6 +753,7 @@ public function renderModalFrame() ]); } + // @phpstan-ignore-next-line public function renderModal($grid) { return view('exment::widgets.partialindex', [ @@ -770,6 +787,7 @@ protected function appendSelectItemButton($grid) * @param CustomTable $custom_table * @return void */ + // @phpstan-ignore-next-line public static function setViewForm($view_kind_type, $form, $custom_table, array $options = []) { if (in_array($view_kind_type, [Enums\ViewKindType::DEFAULT, Enums\ViewKindType::ALLDATA])) { @@ -817,6 +835,7 @@ public static function setViewForm($view_kind_type, $form, $custom_table, array * @param CustomTable $custom_table * @return void */ + // @phpstan-ignore-next-line public static function setGridFilterFields(&$form, $custom_table, array $column_options = []) { // columns setting diff --git a/src/DataItems/Grid/GridBase.php b/src/DataItems/Grid/GridBase.php index 99c4930c6..f42f6b3d6 100644 --- a/src/DataItems/Grid/GridBase.php +++ b/src/DataItems/Grid/GridBase.php @@ -19,11 +19,16 @@ abstract class GridBase { + // @phpstan-ignore-next-line protected $custom_table; + // @phpstan-ignore-next-line protected $custom_view; + // @phpstan-ignore-next-line protected $modal = false; + // @phpstan-ignore-next-line protected $callback; + // @phpstan-ignore-next-line public static function getItem(...$args) { list($custom_table, $custom_view) = $args + [null, null]; @@ -33,6 +38,7 @@ public static function getItem(...$args) return new static($custom_table, $custom_view); } + // @phpstan-ignore-next-line public function modal(bool $modal) { $this->modal = $modal; @@ -40,6 +46,7 @@ public function modal(bool $modal) return $this; } + // @phpstan-ignore-next-line public function callback($callback) { $this->callback = $callback; @@ -47,6 +54,7 @@ public function callback($callback) return $this; } + // @phpstan-ignore-next-line public function renderModal($grid) { return []; @@ -59,6 +67,7 @@ public function renderModal($grid) * @param array $options * @return \Illuminate\Database\Query\Builder|\Illuminate\Database\Schema\Builder */ + // @phpstan-ignore-next-line public function getQuery($query, array $options = []) { return $query; @@ -67,6 +76,7 @@ public function getQuery($query, array $options = []) /** * set laravel-admin grid using custom_view */ + // @phpstan-ignore-next-line public function setGrid($grid) { } @@ -93,6 +103,7 @@ public function getCallbackFilter() $group_view->setSearchService($service); $filters = []; + // @phpstan-ignore-next-line foreach ($group_keys as $key => $value) { $custom_view_column = CustomViewColumn::findByCkey($key); $column_item = $custom_view_column->column_item; @@ -152,6 +163,7 @@ public function getCallbackFilter() } + // @phpstan-ignore-next-line protected static function setViewInfoboxFields(&$form) { // view input area ---------------------------------------------------- @@ -170,11 +182,13 @@ protected static function setViewInfoboxFields(&$form) ->attribute(['data-filter' => json_encode(['key' => 'use_view_infobox', 'value' => '1'])]); } + // @phpstan-ignore-next-line protected static function convertGroups($targetOptions, $defaultCustomTable) { $options = collect($targetOptions)->mapToDictionary(function ($item, $query) { $keys = preg_split('/\?/', $query, 2); $items = preg_split('/\:/', $item); + // @phpstan-ignore-next-line return [$keys[1] => [$query => trim($items[count($items)-1])]]; })->map(function ($item, $key) use ($defaultCustomTable) { if (empty($key)) { @@ -258,6 +272,7 @@ public static function setFilterFields(&$form, $custom_table, $is_aggregate = fa * @param CustomTable $custom_table * @return void */ + // @phpstan-ignore-next-line public static function setColumnFields(&$form, $custom_table, array $column_options = []) { // columns setting @@ -331,6 +346,7 @@ public static function setSortFields(&$form, $custom_table, $include_parent = fa * * @return void */ + // @phpstan-ignore-next-line protected function setTableMenuButton(&$tools) { if ($this->custom_table->enableTableMenuButton()) { @@ -343,6 +359,7 @@ protected function setTableMenuButton(&$tools) * * @return void */ + // @phpstan-ignore-next-line protected function setViewMenuButton(&$tools) { if ($this->custom_table->enableViewMenuButton()) { @@ -355,6 +372,7 @@ protected function setViewMenuButton(&$tools) * * @return void */ + // @phpstan-ignore-next-line protected function setNewButton(&$tools) { if ($this->custom_table->enableCreate(true) === true) { @@ -363,5 +381,6 @@ protected function setNewButton(&$tools) } + // @phpstan-ignore-next-line abstract public function grid(); } diff --git a/src/DataItems/Grid/PluginGrid.php b/src/DataItems/Grid/PluginGrid.php index 42a7a8639..c948c42c2 100644 --- a/src/DataItems/Grid/PluginGrid.php +++ b/src/DataItems/Grid/PluginGrid.php @@ -11,9 +11,12 @@ class PluginGrid extends GridBase { + // @phpstan-ignore-next-line protected $plugin; + // @phpstan-ignore-next-line protected $pluginClass; + // @phpstan-ignore-next-line public function __construct($custom_table, $custom_view) { $this->custom_table = $custom_table; @@ -34,6 +37,7 @@ public function __construct($custom_table, $custom_view) * Make a grid builder. * */ + // @phpstan-ignore-next-line public function grid() { $grid = $this->pluginClass->grid(); @@ -57,6 +61,7 @@ public function grid() * * @return array */ + // @phpstan-ignore-next-line protected function getBoxTools(): array { $tools = []; @@ -88,6 +93,7 @@ protected function getBoxTools(): array * @param CustomTable $custom_table * @return void */ + // @phpstan-ignore-next-line public static function setViewForm($view_kind_type, $form, $custom_table, array $options = []) { $plugin_uuid = array_get($options, 'plugin'); diff --git a/src/DataItems/Grid/SummaryGrid.php b/src/DataItems/Grid/SummaryGrid.php index f3b9391ee..f321c4ae6 100644 --- a/src/DataItems/Grid/SummaryGrid.php +++ b/src/DataItems/Grid/SummaryGrid.php @@ -22,12 +22,14 @@ class SummaryGrid extends GridBase { + // @phpstan-ignore-next-line public function __construct($custom_table, $custom_view) { $this->custom_table = $custom_table; $this->custom_view = $custom_view; } + // @phpstan-ignore-next-line public function grid() { $classname = getModelName($this->custom_table); @@ -92,7 +94,7 @@ public function grid() $edit_flg = $this->custom_table->enableEdit(true) === true; if ($edit_flg && $this->custom_table->enableExport() === true) { $button = new Tools\ExportImportButton(admin_urls('data', $this->custom_table->table_name), $grid, false, true, false); - /** @phpstan-ignore-next-line append expects Encore\Admin\Grid\Tools\AbstractTool|string, Exceedone\Exment\Form\Tools\ExportImportButton given */ + // @phpstan-ignore-next-line $tools->append($button->setCustomTable($this->custom_table)); } @@ -102,11 +104,11 @@ public function grid() } if ($this->custom_table->enableTableMenuButton()) { - /** @phpstan-ignore-next-line expects Encore\Admin\Grid\Tools\AbstractTool|string, Exceedone\Exment\Form\Tools\CustomTableMenuButton given */ + // @phpstan-ignore-next-line $tools->append(new Tools\CustomTableMenuButton('data', $this->custom_table)); } if ($this->custom_table->enableViewMenuButton()) { - /** @phpstan-ignore-next-line expects Encore\Admin\Grid\Tools\AbstractTool|string, Exceedone\Exment\Form\Tools\CustomViewMenuButton given */ + // @phpstan-ignore-next-line $tools->append(new Tools\CustomViewMenuButton($this->custom_table, $this->custom_view)); } }); @@ -117,6 +119,7 @@ public function grid() /** * set summary grid */ + // @phpstan-ignore-next-line public function setSummaryGrid($grid) { $query = $grid->model(); @@ -127,6 +130,7 @@ public function setSummaryGrid($grid) /** * set laravel-admin grid using custom_view */ + // @phpstan-ignore-next-line public function setGrid($grid) { // set with @@ -137,6 +141,7 @@ public function setGrid($grid) /** * get query for summary */ + // @phpstan-ignore-next-line public function getQuery($query, array $options = []) { $options = array_merge([ @@ -250,6 +255,7 @@ protected function setSummaryItem($column) } + // @phpstan-ignore-next-line protected function isShowViewSummaryDetail() { if (boolval(request()->get('execute_filter'))) { @@ -272,6 +278,7 @@ protected function isShowViewSummaryDetail() * @param CustomTable $custom_table * @return void */ + // @phpstan-ignore-next-line public static function setViewForm($view_kind_type, $form, $custom_table, array $options = []) { static::setViewInfoboxFields($form); @@ -386,6 +393,7 @@ public static function setViewForm($view_kind_type, $form, $custom_table, array * @param CustomTable $custom_table * @return void */ + // @phpstan-ignore-next-line public static function setGridFilterFields(&$form, $custom_table, array $column_options = []) { // columns setting @@ -424,6 +432,7 @@ public static function setGridFilterFields(&$form, $custom_table, array $column_ /** * get group condition */ + // @phpstan-ignore-next-line public static function getGroupCondition($view_column_target = null) { if (!isset($view_column_target)) { @@ -448,6 +457,7 @@ public static function getGroupCondition($view_column_target = null) } + // @phpstan-ignore-next-line public function getCallbackGroupKeys($model) { $keys = []; @@ -471,6 +481,7 @@ public function getCallbackGroupKeys($model) /** * set grid filter */ + // @phpstan-ignore-next-line protected function setCustomGridFilters($grid, $ajax = false) { $grid->filter(function ($filter) use ($ajax) { @@ -525,6 +536,7 @@ protected function getFilterUrl(): string * * @return array offset 0 : html, 1 : script */ + // @phpstan-ignore-next-line public function getFilterHtml() { $classname = getModelName($this->custom_table); @@ -544,6 +556,7 @@ public function getFilterHtml() /** * Get filter showing columns */ + // @phpstan-ignore-next-line protected function getFilterColumns($filter): Collection { $filterItems = []; @@ -562,6 +575,7 @@ protected function getFilterColumns($filter): Collection } /** @var Collection $collection */ + // @phpstan-ignore-next-line $collection = collect($filterItems); return $collection; } @@ -616,6 +630,7 @@ protected function getFilterColumns($filter): Collection * * @return void */ + // @phpstan-ignore-next-line protected function setRelationFilter(&$filterItems) { // check relation @@ -634,6 +649,7 @@ protected function setRelationFilter(&$filterItems) * * @return void */ + // @phpstan-ignore-next-line protected function setColumnFilter(&$filterItems) { // if modal, skip diff --git a/src/DataItems/Show/DefaultShow.php b/src/DataItems/Show/DefaultShow.php index a3afdb806..9234436ab 100644 --- a/src/DataItems/Show/DefaultShow.php +++ b/src/DataItems/Show/DefaultShow.php @@ -43,6 +43,7 @@ /** @phpstan-consistent-constructor */ class DefaultShow extends ShowBase { + // @phpstan-ignore-next-line protected static $showClassName = \Exceedone\Exment\Form\Show::class; /** @@ -52,6 +53,7 @@ class DefaultShow extends ShowBase */ protected $rowCount = 0; + // @phpstan-ignore-next-line public function __construct($custom_table, $custom_form) { $this->custom_table = $custom_table; @@ -63,6 +65,7 @@ public function __construct($custom_table, $custom_form) * set option boxes. * contains file uploads, revisions */ + // @phpstan-ignore-next-line public function setOptionBoxes($row) { $this->setChildBlockBox($row); @@ -82,10 +85,11 @@ public function setOptionBoxes($row) * @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface */ + // @phpstan-ignore-next-line protected function setSystemValues($show) { $trashed = boolval(request()->get('trashed')); - /** @phpstan-ignore-next-line class Encore\Admin\Show\Field constructor expects string, null given */ + // @phpstan-ignore-next-line $field = (new ShowField(null, null))->system_values([ 'withTrashed' => $trashed])->setWidth(12, 0); @@ -101,6 +105,7 @@ protected function setSystemValues($show) /** * create show form list */ + // @phpstan-ignore-next-line public function createShowForm() { return new static::$showClassName($this->custom_value, function ($show) { @@ -123,7 +128,7 @@ public function createShowForm() $field = new ShowField($item->name(), $item->label()); $field->as(function ($v) use ($item) { - /** @phpstan-ignore-next-line Call to function is_null() with $this(Exceedone\Exment\DataItems\Show\DefaultShow) will always evaluate to false. */ + // @phpstan-ignore-next-line if (is_null($this)) { return ''; } @@ -455,7 +460,7 @@ protected function setChildBlockBox($row) 'add_id' => true, ])); }); - /** @phpstan-ignore-next-line column() expects int, array given */ + // @phpstan-ignore-next-line $row->column(['xs' => 12, 'sm' => 12], $grid->render()); } } @@ -464,6 +469,7 @@ protected function setChildBlockBox($row) /** * get revision compare. */ + // @phpstan-ignore-next-line public function getRevisionCompare($revision_suuid = null, $pjax = false) { $table_name = $this->custom_table->table_name; @@ -542,6 +548,7 @@ public function getRevisionCompare($revision_suuid = null, $pjax = false) return view("exment::custom-value.revision-compare", $prms); } + // @phpstan-ignore-next-line protected function setRevisionBox($row) { $revisions = $this->getRevisions(); @@ -565,13 +572,14 @@ protected function setRevisionBox($row) 'No.'.($revision->revision_no) )->setWidth(9, 2); } - /** @phpstan-ignore-next-line Encore\Admin\Widgets\Box constructor expects string, Encore\Admin\Widgets\Form given */ + // @phpstan-ignore-next-line $row->column(['xs' => 12, 'sm' => 6], (new Box(exmtrans('revision.update_history'), $form))->style('info')); } /** * whether file upload field */ + // @phpstan-ignore-next-line protected function useFileUpload() { // if no permission, return @@ -585,11 +593,13 @@ protected function useFileUpload() /** * whether comment field */ + // @phpstan-ignore-next-line protected function useComment() { return !$this->modal && boolval($this->custom_table->getOption('comment_flg') ?? true); } + // @phpstan-ignore-next-line protected function getDocuments() { if ($this->modal) { @@ -598,6 +608,7 @@ protected function getDocuments() return $this->custom_value->getDocuments(); } + // @phpstan-ignore-next-line protected function setDocumentBox($row) { $documents = $this->getDocuments(); @@ -668,10 +679,11 @@ protected function setDocumentBox($row) Admin::script($script); } - /** @phpstan-ignore-next-line Encore\Admin\Widgets\Box constructor expects string, Encore\Admin\Widgets\Form given */ + // @phpstan-ignore-next-line $row->column(['xs' => 12, 'sm' => 6], (new Box(exmtrans("common.attachment"), $form))->style('info')); } + // @phpstan-ignore-next-line protected function getComments() { if ($this->modal) { @@ -682,6 +694,7 @@ protected function getComments() ->get(); } + // @phpstan-ignore-next-line protected function setCommentBox($row) { $useComment = $this->useComment(); @@ -720,10 +733,11 @@ protected function setCommentBox($row) ->setLabelClass(['d-none']) ->setWidth(12, 0); } - /** @phpstan-ignore-next-line Encore\Admin\Widgets\Box constructor expects string, Encore\Admin\Widgets\Form given */ + // @phpstan-ignore-next-line $row->column(['xs' => 12, 'sm' => 6], (new Box(exmtrans("common.comment"), $form))->style('info')); } + // @phpstan-ignore-next-line public function getWorkflowHistory() { $workflows = $this->custom_value->getWorkflowHistories(true)->toArray(); @@ -759,6 +773,7 @@ public function getWorkflowHistory() /** * restore data */ + // @phpstan-ignore-next-line public function restoreRevision($revision_suuid) { $this->custom_value->setRevision($revision_suuid)->restore_revision()->save(); @@ -768,6 +783,7 @@ public function restoreRevision($revision_suuid) /** * get target data revisions */ + // @phpstan-ignore-next-line protected function getRevisions($all = false) { if ($this->modal || !boolval($this->custom_table->getOption('revision_flg', true))) { @@ -798,6 +814,7 @@ protected function getRevisions($all = false) /** * for file upload function. */ + // @phpstan-ignore-next-line public function fileupload($httpfiles) { if (is_nullorempty($httpfiles)) { @@ -831,6 +848,7 @@ public function fileupload($httpfiles) /** * file delete custom column. */ + // @phpstan-ignore-next-line public function filedelete(Request $request, $form) { // get file delete flg column name @@ -861,6 +879,7 @@ public function filedelete(Request $request, $form) /** * add comment. */ + // @phpstan-ignore-next-line public function addComment($comment) { if (!empty($comment)) { @@ -888,6 +907,7 @@ public function addComment($comment) /** * delete comment. */ + // @phpstan-ignore-next-line public function deleteComment($id, $suuid) { if (!empty($suuid)) { diff --git a/src/DataItems/Show/PublicFormShow.php b/src/DataItems/Show/PublicFormShow.php index 32539a563..6c5b0a49d 100644 --- a/src/DataItems/Show/PublicFormShow.php +++ b/src/DataItems/Show/PublicFormShow.php @@ -13,6 +13,7 @@ class PublicFormShow extends DefaultShow { + // @phpstan-ignore-next-line protected static $showClassName = PublicShow\PublicShow::class; /** @@ -42,6 +43,7 @@ public function setPublicForm(PublicForm $public_form) * @param mixed $show default show's model. Use for n:n relation. * @return array */ + // @phpstan-ignore-next-line public function getChildRelationShows(array $relationInputs, $show) { // get relations @@ -99,6 +101,7 @@ public function getChildRelationShows(array $relationInputs, $show) * @param array $relationInputs * @return array */ + // @phpstan-ignore-next-line protected function getRelationModels(array $relationInputs) { $relations = []; @@ -107,6 +110,7 @@ protected function getRelationModels(array $relationInputs) continue; } + // @phpstan-ignore-next-line $relation = call_user_func([$this->custom_value, $column]); if ($relation instanceof Relations\Relation) { diff --git a/src/DataItems/Show/ShowBase.php b/src/DataItems/Show/ShowBase.php index e74f4f2f5..bcf3cc943 100644 --- a/src/DataItems/Show/ShowBase.php +++ b/src/DataItems/Show/ShowBase.php @@ -4,13 +4,19 @@ abstract class ShowBase { + // @phpstan-ignore-next-line protected $custom_table; + // @phpstan-ignore-next-line protected $custom_form; + // @phpstan-ignore-next-line protected $custom_value; + // @phpstan-ignore-next-line protected $modal = false; + // @phpstan-ignore-next-line abstract public function __construct($custom_table, $custom_form); + // @phpstan-ignore-next-line public static function getItem(...$args) { list($custom_table, $custom_form) = $args + [null, null, null]; @@ -18,6 +24,7 @@ public static function getItem(...$args) return new static($custom_table, $custom_form); } + // @phpstan-ignore-next-line public function custom_value($custom_value) { $this->custom_value = $custom_value; @@ -25,6 +32,7 @@ public function custom_value($custom_value) return $this; } + // @phpstan-ignore-next-line public function id($id) { $this->custom_value = $this->custom_table->getValueModel($id, boolval(request()->get('trashed'))); @@ -32,6 +40,7 @@ public function id($id) return $this; } + // @phpstan-ignore-next-line public function modal(bool $modal) { $this->modal = $modal; diff --git a/src/Database/ConnectionInterface.php b/src/Database/ConnectionInterface.php index 45be9e688..97096adf3 100644 --- a/src/Database/ConnectionInterface.php +++ b/src/Database/ConnectionInterface.php @@ -47,12 +47,15 @@ public function restoreDatabase($dirFullPath); * * @param string $dirFullPath restore file path */ + // @phpstan-ignore-next-line public function importTsv($dirFullPath); + // @phpstan-ignore-next-line public function createView($viewName, $query); + // @phpstan-ignore-next-line public function dropView($viewName); } diff --git a/src/Database/ConnectionTrait.php b/src/Database/ConnectionTrait.php index 32f077952..9b638c927 100644 --- a/src/Database/ConnectionTrait.php +++ b/src/Database/ConnectionTrait.php @@ -18,6 +18,7 @@ trait ConnectionTrait * * @return \Exceedone\Exment\Database\Query\ExtendedBuilder */ + // @phpstan-ignore-next-line public function query() { return new \Exceedone\Exment\Database\Query\ExtendedBuilder( @@ -57,6 +58,7 @@ public function isSqlServer() return $this->getSchemaBuilder()->isSqlServer(); } + // @phpstan-ignore-next-line public function canConnection() { try { diff --git a/src/Database/Connectors/MariaDBConnectionFactory.php b/src/Database/Connectors/MariaDBConnectionFactory.php index e374a8334..d0ad51bf8 100644 --- a/src/Database/Connectors/MariaDBConnectionFactory.php +++ b/src/Database/Connectors/MariaDBConnectionFactory.php @@ -7,11 +7,13 @@ class MariaDBConnectionFactory extends \Illuminate\Database\Connectors\ConnectionFactory { + // @phpstan-ignore-next-line public function createConnector(array $config) { return new MySqlConnector(); } + // @phpstan-ignore-next-line protected function createConnection($driver, $connection, $database, $prefix = '', array $config = []) { return new MariaDBConnection($connection, $database, $prefix, $config); diff --git a/src/Database/Eloquent/ExtendedBuilder.php b/src/Database/Eloquent/ExtendedBuilder.php index f19ac5d5e..5a681a568 100644 --- a/src/Database/Eloquent/ExtendedBuilder.php +++ b/src/Database/Eloquent/ExtendedBuilder.php @@ -26,6 +26,7 @@ class ExtendedBuilder extends Builder * * @throws \InvalidArgumentException */ + // @phpstan-ignore-next-line public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null) { $page = $page ?: Paginator::resolveCurrentPage($pageName); @@ -47,6 +48,7 @@ public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', ]); } + // @phpstan-ignore-next-line protected function executeQuery($page, $perPage, $columns) { if (isset($this->query->groups) && count($this->query->groups) > 0) { @@ -57,6 +59,7 @@ protected function executeQuery($page, $perPage, $columns) $sql = $_query->select($table . '.id as sid')->forPage($page, $perPage)->toSql(); $bindings = $this->getBindings(); if (count($bindings) > 0) { + // @phpstan-ignore-next-line $query = preg_replace_callback('/\?/', function() use (&$bindings) { $binding = array_shift($bindings); return is_numeric($binding) ? $binding : "'" . addslashes($binding) . "'"; diff --git a/src/Database/ExtendedBlueprint.php b/src/Database/ExtendedBlueprint.php index 584af40dc..fbd380fcc 100644 --- a/src/Database/ExtendedBlueprint.php +++ b/src/Database/ExtendedBlueprint.php @@ -9,6 +9,7 @@ class ExtendedBlueprint extends Blueprint /** * set created_user, updated_user, deleted_user */ + // @phpstan-ignore-next-line public function timeusers($precision = 0) { $this->unsignedInteger('created_user_id', $precision)->nullable(); @@ -22,6 +23,7 @@ public function timeusers($precision = 0) * * @param array|mixed $columns */ + // @phpstan-ignore-next-line public function dropColumn($columns) { $columns = is_array($columns) ? $columns : func_get_args(); diff --git a/src/Database/ExtendedBuilderTrait.php b/src/Database/ExtendedBuilderTrait.php index a8c576354..7e9455caa 100644 --- a/src/Database/ExtendedBuilderTrait.php +++ b/src/Database/ExtendedBuilderTrait.php @@ -64,14 +64,18 @@ public function updateRemovingJsonKey(string $key) * @param mixed $value * @param string $boolean */ + // @phpstan-ignore-next-line public function whereOrIn($column, $operator = null, $value = null, $boolean = 'and') { // if arg is array or list, execute whereIn $checkArray = (func_num_args() == 3 ? $value : $operator); + /** @phpstan-ignore-next-line */ if (is_list($checkArray)) { if (func_num_args() == 3 && $operator == '<>') { + /** @phpstan-ignore-next-line */ return $this->whereNotIn($column, toArray($checkArray)); } + /** @phpstan-ignore-next-line */ return $this->whereIn($column, toArray($checkArray)); } @@ -86,14 +90,18 @@ public function whereOrIn($column, $operator = null, $value = null, $boolean = ' * @param mixed $value * @param string $boolean */ + // @phpstan-ignore-next-line public function orWhereOrIn($column, $operator = null, $value = null, $boolean = 'and') { // if arg is array or list, execute whereIn $checkArray = (func_num_args() == 3 ? $value : $operator); + /** @phpstan-ignore-next-line */ if (is_list($checkArray)) { if (func_num_args() == 3 && $operator == '<>') { + /** @phpstan-ignore-next-line */ return $this->orWhereNotIn($column, toArray($checkArray)); } + /** @phpstan-ignore-next-line */ return $this->orWhereIn($column, toArray($checkArray)); } @@ -110,6 +118,7 @@ public function orWhereOrIn($column, $operator = null, $value = null, $boolean = * @return Eloquent\ExtendedBuilder|Query\ExtendedBuilder|Query\JoinClause * @throws \Exception */ + // @phpstan-ignore-next-line public function whereInMultiple(array $columns, $values, bool $zeroQueryIfEmpty = false) { if (count($columns) !== 2) { @@ -132,6 +141,7 @@ public function whereInMultiple(array $columns, $values, bool $zeroQueryIfEmpty // if not suport where in multiple, first getting target id, and add query. ---------------------------------------------------- $tableName = $this->_getTableExment(); + /** @phpstan-ignore-next-line */ $subquery = \DB::table($tableName); // group "$values" index. @@ -165,6 +175,7 @@ public function whereInMultiple(array $columns, $values, bool $zeroQueryIfEmpty * * @return \Illuminate\Database\Query\Builder */ + // @phpstan-ignore-next-line public function whereInArrayString($column, $values) { return $this->_whereInArrayString($column, $values, false, false); @@ -179,6 +190,7 @@ public function whereInArrayString($column, $values) * * @return \Illuminate\Database\Query\Builder */ + // @phpstan-ignore-next-line public function orWhereInArrayString($column, $values) { return $this->_whereInArrayString($column, $values, true, false); @@ -193,6 +205,7 @@ public function orWhereInArrayString($column, $values) * * @return \Illuminate\Database\Query\Builder */ + // @phpstan-ignore-next-line public function whereNotInArrayString($column, $values) { return $this->_whereInArrayString($column, $values, false, true); @@ -207,12 +220,14 @@ public function whereNotInArrayString($column, $values) * * @return \Illuminate\Database\Query\Builder */ + // @phpstan-ignore-next-line public function orWhereNotInArrayString($column, $values) { return $this->_whereInArrayString($column, $values, true, true); } + // @phpstan-ignore-next-line protected function _whereInArrayString($column, $values, bool $isOr = false, bool $isNot = false) { if (is_null($values)) { @@ -283,6 +298,7 @@ public function orWhereNotInArrayColumn($baseColumn, $column) } + // @phpstan-ignore-next-line protected function _whereInArrayColumn($baseColumn, $column, bool $isOr = false, bool $isNot = false) { $tableName = $this->_getTableExment(); @@ -298,6 +314,7 @@ protected function _whereInArrayColumn($baseColumn, $column, bool $isOr = false, * @param array $values * @return Eloquent\ExtendedBuilder|Query\ExtendedBuilder|Query\JoinClause */ + // @phpstan-ignore-next-line public function whereBetweenQuery($column, array $values) { return $this->_between($column, $values, '>=', '<='); @@ -310,12 +327,14 @@ public function whereBetweenQuery($column, array $values) * @param array $values * @return Eloquent\ExtendedBuilder|Query\ExtendedBuilder|Query\JoinClause */ + // @phpstan-ignore-next-line public function whereBetweenLt($column, array $values) { return $this->_between($column, $values, '>=', '<'); } + // @phpstan-ignore-next-line protected function _between($column, array $values, $startMark, $endMark, bool $isOr = false) { $values = array_values($values); @@ -372,6 +391,7 @@ public function orWhereDateExment(string $column, $value, bool $isDatetime) * * @return \Illuminate\Database\Query\Builder */ + // @phpstan-ignore-next-line public function whereDateMarkExment(string $column, $value, $mark, bool $isDatetime) { return $this->_whereDateMark($column, $value, $mark, $isDatetime, false); @@ -384,6 +404,7 @@ public function whereDateMarkExment(string $column, $value, $mark, bool $isDatet * * @return \Illuminate\Database\Query\Builder */ + // @phpstan-ignore-next-line public function orWhereDateMarkExment(string $column, $value, $mark, bool $isDatetime) { return $this->_whereDateMark($column, $value, $mark, $isDatetime, true); @@ -441,6 +462,7 @@ public function orWhereYearExment(string $column, $value, bool $isDatetime) } + // @phpstan-ignore-next-line protected function _whereDate(string $column, $value, bool $isDatetime, bool $isOr = false) { if (is_null($value)) { @@ -457,6 +479,7 @@ protected function _whereDate(string $column, $value, bool $isDatetime, bool $is ], $isDatetime, $isOr); } + // @phpstan-ignore-next-line protected function _whereYear(string $column, $value, bool $isDatetime, bool $isOr = false) { if (is_null($value)) { @@ -478,6 +501,7 @@ protected function _whereYear(string $column, $value, bool $isDatetime, bool $is } + // @phpstan-ignore-next-line protected function _whereYearMonth(string $column, $value, bool $isDatetime, bool $isOr = false) { if (is_null($value)) { @@ -489,12 +513,14 @@ protected function _whereYearMonth(string $column, $value, bool $isDatetime, boo } return $this->_setWhereDate($column, [ + // @phpstan-ignore-next-line 'date' => [Carbon::create($value->year, $value->month, 1), Carbon::create($value->year, $value->month + 1, 1)->addDays(-1)], 'datetime' => [Carbon::create($value->year, $value->month, 1), Carbon::create($value->year, $value->month + 1, 1)], ], $isDatetime, $isOr); } + // @phpstan-ignore-next-line protected function _setWhereDate(string $column, $values, bool $isDatetime, bool $isOr = false) { if ($isDatetime) { @@ -517,6 +543,7 @@ protected function _setWhereDate(string $column, $values, bool $isDatetime, bool } + // @phpstan-ignore-next-line protected function _whereDateMark(string $column, $value, $mark, bool $isDatetime, bool $isOr = false) { if (is_null($value)) { diff --git a/src/Database/MariaDBConnection.php b/src/Database/MariaDBConnection.php index 5bd49d81f..e100851b5 100644 --- a/src/Database/MariaDBConnection.php +++ b/src/Database/MariaDBConnection.php @@ -19,7 +19,7 @@ class MariaDBConnection extends MySqlConnection */ public function getSchemaBuilder() { - /** @phpstan-ignore-next-line Call to function is_null() with Illuminate\Database\Schema\Grammars\Grammar will always evaluate to false. */ + // @phpstan-ignore-next-line if (is_null($this->schemaGrammar)) { $this->useDefaultSchemaGrammar(); } diff --git a/src/Database/MySqlConnection.php b/src/Database/MySqlConnection.php index 69cb7c087..234ffc155 100644 --- a/src/Database/MySqlConnection.php +++ b/src/Database/MySqlConnection.php @@ -14,6 +14,7 @@ class MySqlConnection extends BaseConnection implements ConnectionInterface { use ConnectionTrait; + // @phpstan-ignore-next-line protected static $isContainsColumnStatistics = null; /** @@ -23,7 +24,7 @@ class MySqlConnection extends BaseConnection implements ConnectionInterface */ public function getSchemaBuilder() { - /** @phpstan-ignore-next-line Call to function is_null() with Illuminate\Database\Schema\Grammars\Grammar will always evaluate to false. */ + // @phpstan-ignore-next-line if (is_null($this->schemaGrammar)) { $this->useDefaultSchemaGrammar(); } @@ -84,6 +85,7 @@ protected function dumpDatabase($tempDir, $table = null) $mysqldump = static::getMysqlDumpPath(); $ls_output = shell_exec($mysqldump . ' --help'); + // @phpstan-ignore-next-line if (strpos($ls_output, '--set-gtid-purged') !== false) { $set_gtid = ' --set-gtid-purged=OFF'; } else { @@ -207,6 +209,7 @@ public function backupDatabase($tempDir) * @param $table * @return void */ + // @phpstan-ignore-next-line protected function backupTable($tempDir, $table) { // create tsv file @@ -304,9 +307,11 @@ public function restoreDatabase($dirFullPath) * * @param string $dirFullPath restore file path */ + // @phpstan-ignore-next-line public function importTsv($dirFullPath) { // get tsv files in target folder + /** @phpstan-ignore-next-line */ $files = array_filter(\File::files($dirFullPath), function ($file) { return preg_match('/.+\.tsv$/i', $file); }); @@ -352,6 +357,7 @@ public function importTsv($dirFullPath) + // @phpstan-ignore-next-line public function createView($viewName, $query) { $viewName = $this->getQueryGrammar()->wrapTable($viewName); @@ -360,6 +366,7 @@ public function createView($viewName, $query) AS " . $query->toSql(), $query->getBindings()); } + // @phpstan-ignore-next-line public function dropView($viewName) { $viewName = $this->getQueryGrammar()->wrapTable($viewName); @@ -367,11 +374,13 @@ public function dropView($viewName) } + // @phpstan-ignore-next-line protected static function getMysqlPath() { return path_join_os(config('exment.backup_info.mysql_dir', ''), 'mysql'); } + // @phpstan-ignore-next-line protected static function getMysqlDumpPath() { return path_join_os(config('exment.backup_info.mysql_dir', ''), 'mysqldump'); diff --git a/src/Database/Query/Grammars/GrammarInterface.php b/src/Database/Query/Grammars/GrammarInterface.php index 206a277ea..343e95fe0 100644 --- a/src/Database/Query/Grammars/GrammarInterface.php +++ b/src/Database/Query/Grammars/GrammarInterface.php @@ -24,6 +24,7 @@ public function isSupportWhereInMultiple(): bool; * @param bool $isOr * @return \Illuminate\Database\Query\Builder */ + // @phpstan-ignore-next-line public function whereInArrayString($builder, string $tableName, string $column, $values, bool $isOr = false, bool $isNot = false); /** @@ -38,6 +39,7 @@ public function whereInArrayString($builder, string $tableName, string $column, */ public function whereInArrayColumn($builder, string $tableName, string $baseColumn, string $column, bool $isOr = false, bool $isNot = false); + // @phpstan-ignore-next-line public function wrapWhereInMultiple(array $columns); /** @@ -45,6 +47,7 @@ public function wrapWhereInMultiple(array $columns); * * @return array offset 0: bind string for wherein (?, ?, ) */ + // @phpstan-ignore-next-line public function bindValueWhereInMultiple(array $values); /** @@ -52,6 +55,7 @@ public function bindValueWhereInMultiple(array $values); * * @return string */ + // @phpstan-ignore-next-line public function getCastColumn($type, $column, $options = []); /** @@ -59,6 +63,7 @@ public function getCastColumn($type, $column, $options = []); * * @return string */ + // @phpstan-ignore-next-line public function getColumnTypeString($type); /** @@ -66,6 +71,7 @@ public function getColumnTypeString($type); * * @return string */ + // @phpstan-ignore-next-line public function getCastString($type, $addOption = false, $options = []); /** @@ -77,6 +83,7 @@ public function getCastString($type, $addOption = false, $options = []); * * @return string|null */ + // @phpstan-ignore-next-line public function getDateFormatString($groupCondition, $column, $groupBy = false, $wrap = true); /** diff --git a/src/Database/Query/Grammars/GrammarTrait.php b/src/Database/Query/Grammars/GrammarTrait.php index e1c9b52d8..1cb6bca5e 100644 --- a/src/Database/Query/Grammars/GrammarTrait.php +++ b/src/Database/Query/Grammars/GrammarTrait.php @@ -4,6 +4,7 @@ trait GrammarTrait { + // @phpstan-ignore-next-line public function wrapWhereInMultiple(array $columns) { return array_map(function ($column) { @@ -16,6 +17,7 @@ public function wrapWhereInMultiple(array $columns) * * @return array offset 0: bind string for wherein (?, ?, ) */ + // @phpstan-ignore-next-line public function bindValueWhereInMultiple(array $values) { $count = 0; diff --git a/src/Database/Query/Grammars/MySqlGrammar.php b/src/Database/Query/Grammars/MySqlGrammar.php index 213c6b2ac..ecd69cb9f 100644 --- a/src/Database/Query/Grammars/MySqlGrammar.php +++ b/src/Database/Query/Grammars/MySqlGrammar.php @@ -11,6 +11,7 @@ class MySqlGrammar extends BaseGrammar implements GrammarInterface use GrammarTrait; + // @phpstan-ignore-next-line public function compileUpdateRemovingJsonKey($query, string $key): string { $table = $this->wrapTable($query->from); @@ -31,6 +32,7 @@ public function compileUpdateRemovingJsonKey($query, string $key): string $joins = ''; if (isset($query->joins)) { + // @phpstan-ignore-next-line $joins = ' '.$this->compileJoins($query, $query->joins); } @@ -63,6 +65,7 @@ public function isSupportWhereInMultiple(): bool * @param array $values * @return \Illuminate\Database\Query\Builder */ + // @phpstan-ignore-next-line public function whereInArrayString($builder, string $tableName, string $column, $values, bool $isOr = false, bool $isNot = false) { $index = $this->wrap($column); @@ -122,6 +125,7 @@ public function whereInArrayColumn($builder, string $tableName, string $baseColu * * @return string */ + // @phpstan-ignore-next-line public function getCastColumn($type, $column, $options = []) { $cast = $this->getCastString($type, $column, $options); @@ -136,6 +140,7 @@ public function getCastColumn($type, $column, $options = []) * * @return string */ + // @phpstan-ignore-next-line public function getColumnTypeString($type) { switch ($type) { @@ -161,6 +166,7 @@ public function getColumnTypeString($type) * * @return string */ + // @phpstan-ignore-next-line public function getCastString($type, $addOption = false, $options = []) { $cast = ''; @@ -216,6 +222,7 @@ public function getCastString($type, $addOption = false, $options = []) * * @return string|null */ + // @phpstan-ignore-next-line public function getDateFormatString($groupCondition, $column, $groupBy = false, $wrap = true) { if ($wrap) { diff --git a/src/Database/Query/Grammars/SqlServerGrammar.php b/src/Database/Query/Grammars/SqlServerGrammar.php index 794746552..26c4725c8 100644 --- a/src/Database/Query/Grammars/SqlServerGrammar.php +++ b/src/Database/Query/Grammars/SqlServerGrammar.php @@ -33,6 +33,7 @@ public function isSupportWhereInMultiple(): bool * @param array $values * @return \Illuminate\Database\Query\Builder */ + // @phpstan-ignore-next-line public function whereInArrayString($builder, string $tableName, string $column, $values, bool $isOr = false, bool $isNot = false) { $index = $this->wrap($column); @@ -120,9 +121,10 @@ public function whereInArrayColumn($builder, string $tableName, string $baseColu * @param array $options * @return string */ + // @phpstan-ignore-next-line public function getCastColumn($type, $column, $options = []) { - /** @phpstan-ignore-next-line getCastString() expects bool, string given */ + // @phpstan-ignore-next-line $cast = $this->getCastString($type, $column, $options); $column = $this->wrap($column); @@ -135,6 +137,7 @@ public function getCastColumn($type, $column, $options = []) * * @return string */ + // @phpstan-ignore-next-line public function getColumnTypeString($type) { switch ($type) { @@ -165,6 +168,7 @@ public function getColumnTypeString($type) * @param array $options * @return string */ + // @phpstan-ignore-next-line public function getCastString($type, $addOption = false, $options = []) { $cast = ''; @@ -219,6 +223,7 @@ public function getCastString($type, $addOption = false, $options = []) * @param bool $groupBy if group by query, return true * @return string|null */ + // @phpstan-ignore-next-line public function getDateFormatString($groupCondition, $column, $groupBy = false, $wrap = true) { if ($wrap) { @@ -286,6 +291,7 @@ public function convertCarbonDateFormat($groupCondition, $carbon) * * @return string */ + // @phpstan-ignore-next-line protected function getWeekdayCaseWhenQuery($str) { $queries = []; @@ -303,6 +309,7 @@ protected function getWeekdayCaseWhenQuery($str) return "(case {$str} {$when} end)"; } + // @phpstan-ignore-next-line protected function getWeekdayNolist() { // fixed mysql server @@ -325,6 +332,7 @@ protected function getWeekdayNolist() * @param string $sequence * @return string */ + // @phpstan-ignore-next-line public function compileInsertGetId(Builder $query, $values, $sequence) { if (strtoupper($sequence) == 'ID' && array_has($values, $sequence) && isset($values[$sequence])) { diff --git a/src/Database/Query/Processors/MySqlProcessor.php b/src/Database/Query/Processors/MySqlProcessor.php index dba76fbf0..a52c6c49b 100644 --- a/src/Database/Query/Processors/MySqlProcessor.php +++ b/src/Database/Query/Processors/MySqlProcessor.php @@ -12,6 +12,7 @@ class MySqlProcessor extends BaseMySqlProcessor * @param array $results * @return string */ + // @phpstan-ignore-next-line public function processGetVersion($results) { $versionArray = $this->versionAray($results); @@ -25,6 +26,7 @@ public function processGetVersion($results) * @param array $results * @return array|bool */ + // @phpstan-ignore-next-line public function processIsMariaDB($results) { $versionArray = $this->versionAray($results); @@ -36,6 +38,7 @@ public function processIsMariaDB($results) return strtolower($versionArray[1]) == 'mariadb'; } + // @phpstan-ignore-next-line protected function versionAray($results) { $version = collect(collect($results)->first())->first(); @@ -48,6 +51,7 @@ protected function versionAray($results) * @param array $results * @return array */ + // @phpstan-ignore-next-line public function processTableListing($results) { return array_map(function ($result) { @@ -61,6 +65,7 @@ public function processTableListing($results) * @param array $results * @return array */ + // @phpstan-ignore-next-line public function processColumnDefinitions($tableName, $results) { return collect($results)->map(function ($result) use ($tableName) { @@ -80,6 +85,7 @@ public function processColumnDefinitions($tableName, $results) * @param array $results * @return array */ + // @phpstan-ignore-next-line public function processIndexDefinitions($tableName, $results) { return collect($results)->map(function ($result) use ($tableName) { diff --git a/src/Database/Query/Processors/SqlServerProcessor.php b/src/Database/Query/Processors/SqlServerProcessor.php index d889b7343..4c3bb0aea 100644 --- a/src/Database/Query/Processors/SqlServerProcessor.php +++ b/src/Database/Query/Processors/SqlServerProcessor.php @@ -12,6 +12,7 @@ class SqlServerProcessor extends BaseSqlServerProcessor * @param array $results * @return string|null */ + // @phpstan-ignore-next-line public function processGetVersion($results) { $string = collect((array)$results[0])->first(); @@ -30,6 +31,7 @@ public function processGetVersion($results) * @param array $results * @return array */ + // @phpstan-ignore-next-line public function processTableListing($results) { return array_map(function ($result) { @@ -43,6 +45,7 @@ public function processTableListing($results) * @param array $results * @return array */ + // @phpstan-ignore-next-line public function processColumnDefinitions($tableName, $results) { return collect($results)->map(function ($result) { @@ -62,6 +65,7 @@ public function processColumnDefinitions($tableName, $results) * @param array $results * @return array */ + // @phpstan-ignore-next-line public function processIndexDefinitions($tableName, $results) { return collect($results)->map(function ($result) use ($tableName) { @@ -80,6 +84,7 @@ public function processIndexDefinitions($tableName, $results) * @param array $results * @return array */ + // @phpstan-ignore-next-line public function processConstraints($results) { return collect($results)->map(function ($result) { diff --git a/src/Database/Schema/BuilderTrait.php b/src/Database/Schema/BuilderTrait.php index e0b5a7ba9..692d97481 100644 --- a/src/Database/Schema/BuilderTrait.php +++ b/src/Database/Schema/BuilderTrait.php @@ -15,6 +15,7 @@ trait BuilderTrait * * @return array Inserted data */ + // @phpstan-ignore-next-line public function insertDelete($table, $values, $settings = []) { $settings = array_merge( @@ -35,6 +36,7 @@ public function insertDelete($table, $values, $settings = []) $matchFilter = $settings['matchFilter']; // get DB values + /** @phpstan-ignore-next-line */ $dbValueQuery = \DB::table($table); if ($dbValueFilter) { @@ -53,6 +55,7 @@ public function insertDelete($table, $values, $settings = []) return $matchFilter($dbValue, $value); })) { $inserts[] = $value; + /** @phpstan-ignore-next-line */ \DB::table($table)->insert($value); } } @@ -62,6 +65,7 @@ public function insertDelete($table, $values, $settings = []) if (!collect($values)->first(function ($value, $k) use ($dbValue, $matchFilter) { return $matchFilter($dbValue, $value); })) { + /** @phpstan-ignore-next-line */ $dbDeleteQuery = \DB::table($table); if (!$dbDeleteFilter) { continue; @@ -108,6 +112,7 @@ public function isSqlServer() return false; } + // @phpstan-ignore-next-line public function hasCustomIndex($tableName, $columnName, $indexName) { $indexes = $this->getIndexDefinitions($tableName, $columnName); @@ -126,6 +131,7 @@ public function hasCustomIndex($tableName, $columnName, $indexName) * * @return array */ + // @phpstan-ignore-next-line public function getTableListing() { $results = $this->connection->selectFromWriteConnection($this->grammar->compileGetTableListing()); @@ -138,6 +144,7 @@ public function getTableListing() * * @return array */ + // @phpstan-ignore-next-line public function getColumnDefinitions($table) { $baseTable = $table; @@ -154,8 +161,10 @@ public function getColumnDefinitions($table) * @param string $columnName * @return array|null index key list */ + // @phpstan-ignore-next-line public function getIndexDefinitions($tableName, $columnName) { + // @phpstan-ignore-next-line return $this->getUniqueIndexDefinitions($tableName, $columnName, false); } @@ -166,8 +175,10 @@ public function getIndexDefinitions($tableName, $columnName) * @param string $columnName * @return array|null unique key list */ + // @phpstan-ignore-next-line public function getUniqueDefinitions($tableName, $columnName) { + // @phpstan-ignore-next-line return $this->getUniqueIndexDefinitions($tableName, $columnName, true); } @@ -179,8 +190,10 @@ public function getUniqueDefinitions($tableName, $columnName) * @param bool $unique * @return \Illuminate\Support\Collection|\Tightenco\Collect\Support\Collection|array|null */ + // @phpstan-ignore-next-line protected function getUniqueIndexDefinitions($tableName, $columnName, $unique) { + /** @phpstan-ignore-next-line */ if (!\Schema::hasTable($tableName)) { return collect([]); } @@ -202,8 +215,10 @@ protected function getUniqueIndexDefinitions($tableName, $columnName, $unique) * @param string $columnName * @return array */ + // @phpstan-ignore-next-line protected function getConstraints($tableName, $columnName): array { + /** @phpstan-ignore-next-line */ if (!\Schema::hasTable($tableName)) { return []; } @@ -261,6 +276,7 @@ public function createRelationValueTable($table) */ public function alterIndexColumn($db_table_name, $db_column_name, $index_name, $json_column_name, CustomColumn $custom_column) { + /** @phpstan-ignore-next-line */ if (!\Schema::hasTable($db_table_name)) { return; } @@ -284,6 +300,7 @@ public function alterIndexColumn($db_table_name, $db_column_name, $index_name, $ */ public function dropIndexColumn($db_table_name, $db_column_name, $index_name) { + /** @phpstan-ignore-next-line */ if (!\Schema::hasTable($db_table_name)) { return; } @@ -291,14 +308,18 @@ public function dropIndexColumn($db_table_name, $db_column_name, $index_name) $db_table_name = $this->connection->getTablePrefix().$db_table_name; // check index name + /** @phpstan-ignore-next-line */ if (\Schema::hasCustomIndex($db_table_name, $db_column_name, $index_name)) { + /** @phpstan-ignore-next-line */ \Schema::table($db_table_name, function (Blueprint $table) use ($index_name) { $table->dropIndex($index_name); }); } // check column name + /** @phpstan-ignore-next-line */ if (\Schema::hasColumn($db_table_name, $db_column_name)) { + /** @phpstan-ignore-next-line */ \Schema::table($db_table_name, function (Blueprint $table) use ($db_column_name) { $table->dropColumn($db_column_name); }); @@ -315,6 +336,7 @@ public function dropIndexColumn($db_table_name, $db_column_name, $index_name) */ public function dropConstraints($tableName, $columnName): void { + /** @phpstan-ignore-next-line */ if (!\Schema::hasTable($tableName)) { return; } diff --git a/src/Database/Schema/Grammars/GrammarInterface.php b/src/Database/Schema/Grammars/GrammarInterface.php index 1a42fc61d..25d5da951 100644 --- a/src/Database/Schema/Grammars/GrammarInterface.php +++ b/src/Database/Schema/Grammars/GrammarInterface.php @@ -25,6 +25,7 @@ public function compileGetTableListing(); * * @return string */ + // @phpstan-ignore-next-line public function compileColumnDefinitions($tableName); /** @@ -41,9 +42,12 @@ public function compileCreateValueTable(string $tableName); */ public function compileCreateRelationValueTable(string $tableName); + // @phpstan-ignore-next-line public function compileAlterIndexColumn($db_table_name, $db_column_name, $index_name, $json_column_name, CustomColumn $custom_column); + // @phpstan-ignore-next-line public function compileGetIndex($tableName); + // @phpstan-ignore-next-line public function compileGetUnique($tableName); } diff --git a/src/Database/Schema/Grammars/MariaDBGrammar.php b/src/Database/Schema/Grammars/MariaDBGrammar.php index 94feebafa..f0a5c1f71 100644 --- a/src/Database/Schema/Grammars/MariaDBGrammar.php +++ b/src/Database/Schema/Grammars/MariaDBGrammar.php @@ -15,12 +15,15 @@ public function __construct() if (!in_array('Check', $this->modifiers)) { array_splice( $this->modifiers, + // @phpstan-ignore-next-line array_search('After', $this->modifiers), count($this->modifiers), + // @phpstan-ignore-next-line array_merge(['Check'], array_slice($this->modifiers, array_search('After', $this->modifiers))) ); } } + // @phpstan-ignore-next-line protected function modifyCheck(Blueprint $blueprint, Fluent $column) { if ($this->getType($column) == 'json') { diff --git a/src/Database/Schema/Grammars/MySqlGrammar.php b/src/Database/Schema/Grammars/MySqlGrammar.php index 8130cc366..7d0bc2077 100644 --- a/src/Database/Schema/Grammars/MySqlGrammar.php +++ b/src/Database/Schema/Grammars/MySqlGrammar.php @@ -32,6 +32,7 @@ public function compileGetTableListing() * * @return string */ + // @phpstan-ignore-next-line public function compileColumnDefinitions($tableName) { return "show columns from {$this->wrapTable($tableName)}"; @@ -57,6 +58,7 @@ public function compileCreateRelationValueTable(string $tableName) return "create table if not exists {$this->wrapTable($tableName)} like custom_relation_values"; } + // @phpstan-ignore-next-line public function compileAlterIndexColumn($db_table_name, $db_column_name, $index_name, $json_column_name, CustomColumn $custom_column) { // ALTER TABLE @@ -68,21 +70,25 @@ public function compileAlterIndexColumn($db_table_name, $db_column_name, $index_ ]; } + // @phpstan-ignore-next-line public function compileGetIndex($tableName) { return $this->_compileGetIndex($tableName, false); } + // @phpstan-ignore-next-line public function compileGetUnique($tableName) { return $this->_compileGetIndex($tableName, true); } + // @phpstan-ignore-next-line protected function _compileGetIndex($tableName, $unique) { return "show index from {$this->wrapTable($tableName)} where non_unique = :non_unique and column_name = :column_name"; } + // @phpstan-ignore-next-line public function compileGetConstraint($tableName) { return null; diff --git a/src/Database/Schema/Grammars/SqlServerGrammar.php b/src/Database/Schema/Grammars/SqlServerGrammar.php index 4e082da0f..58db903d0 100644 --- a/src/Database/Schema/Grammars/SqlServerGrammar.php +++ b/src/Database/Schema/Grammars/SqlServerGrammar.php @@ -34,6 +34,7 @@ public function compileGetTableListing() * * @return string */ + // @phpstan-ignore-next-line public function compileColumnDefinitions($tableName) { return "SELECT @@ -75,6 +76,7 @@ public function compileCreateRelationValueTable(string $tableName) return "if object_id('{$this->wrapTable($tableName)}') is null select * into {$this->wrapTable($tableName)} from custom_relation_values"; } + // @phpstan-ignore-next-line public function compileAlterIndexColumn($db_table_name, $db_column_name, $index_name, $json_column_name, CustomColumn $custom_column) { // ALTER TABLE @@ -90,22 +92,26 @@ public function compileAlterIndexColumn($db_table_name, $db_column_name, $index_ ]; } + // @phpstan-ignore-next-line public function compileAlterPrimaryKey($db_table_name, $db_column_name = 'id') { // ALTER TABLE return "alter table {$db_table_name} add primary key ({$db_column_name})"; } + // @phpstan-ignore-next-line public function compileGetIndex($tableName) { return $this->_compileGetIndex($tableName, false); } + // @phpstan-ignore-next-line public function compileGetUnique($tableName) { return $this->_compileGetIndex($tableName, true); } + // @phpstan-ignore-next-line protected function _compileGetIndex($tableName, $unique) { return "select @@ -125,6 +131,7 @@ protected function _compileGetIndex($tableName, $unique) and COL_NAME(ic.object_id, ic.column_id) = :column_name"; } + // @phpstan-ignore-next-line public function compileGetConstraint($tableName) { return "SELECT @@ -141,6 +148,7 @@ public function compileGetConstraint($tableName) * * @return string */ + // @phpstan-ignore-next-line public function compileDropConstraint($tableName, $contraintName) { $tableName = $this->wrapTable($tableName); @@ -154,6 +162,7 @@ public function compileDropConstraint($tableName, $contraintName) * @param \Illuminate\Support\Fluent $command * @return string */ + // @phpstan-ignore-next-line public function compileDropDefaultConstraint(Blueprint $blueprint, Fluent $command) { $columns = "'".implode("','", $command->columns)."'"; diff --git a/src/Database/Schema/MySqlBuilder.php b/src/Database/Schema/MySqlBuilder.php index b6e2cb137..09848f1f9 100644 --- a/src/Database/Schema/MySqlBuilder.php +++ b/src/Database/Schema/MySqlBuilder.php @@ -8,6 +8,7 @@ class MySqlBuilder extends BaseBuilder { use BuilderTrait; + // @phpstan-ignore-next-line protected function getUniqueIndexDefinitionsSelect($sql, $tableName, $columnName, $unique) { return $this->connection->select($sql, ['column_name' => $columnName, 'non_unique' => !$unique]); diff --git a/src/Database/Schema/SqlServerBuilder.php b/src/Database/Schema/SqlServerBuilder.php index e86349ee3..6f23c5a08 100644 --- a/src/Database/Schema/SqlServerBuilder.php +++ b/src/Database/Schema/SqlServerBuilder.php @@ -8,6 +8,7 @@ class SqlServerBuilder extends BaseBuilder { use BuilderTrait; + // @phpstan-ignore-next-line protected function getUniqueIndexDefinitionsSelect($sql, $tableName, $columnName, $unique) { return $this->connection->select($sql, ['column_name' => $columnName, 'is_unique' => $unique]); @@ -38,6 +39,7 @@ public function isSqlServer() * * @return array */ + // @phpstan-ignore-next-line public function getColumnDefinitions($table) { $baseTable = $table; diff --git a/src/Database/Seeder/TestDataSeeder.php b/src/Database/Seeder/TestDataSeeder.php index 4ab6b67b9..94d800fdc 100644 --- a/src/Database/Seeder/TestDataSeeder.php +++ b/src/Database/Seeder/TestDataSeeder.php @@ -176,7 +176,7 @@ protected function createUserOrg() \DB::table($relationName)->insert($inserts); } - /** @phpstan-ignore-next-line Right side of && is always true. */ + // @phpstan-ignore-next-line if (isset($rolegroups[$type][$user_key]) && is_array($rolegroups[$type][$user_key])) { foreach ($rolegroups[$type][$user_key] as $rolegroup) { $roleGroupUserOrg = new RoleGroupUserOrganization(); @@ -1186,6 +1186,7 @@ protected function getDateValue($user_id, $new_id): ?string case 0: break; case 1: + // @phpstan-ignore-next-line $result = $date->addDays($new_id-4); break; case 2: @@ -1213,11 +1214,13 @@ protected function getDateValue($user_id, $new_id): ?string $result = $date; break; default: + // @phpstan-ignore-next-line $result = \Carbon\Carbon::create(2019, 12, 28)->addDays($new_id); break; } if (isset($result)) { + // @phpstan-ignore-next-line return $result->format('Y-m-d'); } return null; @@ -1576,9 +1579,10 @@ protected function createView($custom_table, $custom_columns, $createCustomView, $custom_view = $this->createCustomView($custom_table, ViewType::SYSTEM, ViewKindType::AGGREGATE, $custom_table->table_name . '-view-summary', []); collect($custom_columns)->filter(function ($custom_column) { return $custom_column->indexEnabled && $custom_column->column_type == ColumnType::DATE; - /** @phpstan-ignore-next-line Illuminate\Support\Collection<(int|string),mixed>::first() expects + /** Illuminate\Support\Collection<(int|string),mixed>::first() expects * (callable(mixed, int|string): bool)|null, Closure(mixed, mixed): void * given. */ + // @phpstan-ignore-next-line })->first(function ($custom_column, $index) use ($custom_view, $custom_table) { /** @phpstan-ignore-next-line */ return $this->createViewColumn($custom_view->id, $custom_table->id, $custom_column->id, $index + 1, [ @@ -1587,20 +1591,22 @@ protected function createView($custom_table, $custom_columns, $createCustomView, }); collect($custom_columns)->filter(function ($custom_column) { return $custom_column->column_type == ColumnType::INTEGER; - /** @phpstan-ignore-next-line Parameter #1 $callback of method + /** Parameter #1 $callback of method * Illuminate\Support\Collection<(int|string),mixed>::first() expects * (callable(mixed, int|string): bool)|null, Closure(mixed, mixed): void * given. */ + // @phpstan-ignore-next-line })->first(function ($custom_column, $index) use ($custom_view, $custom_table) { /** @phpstan-ignore-next-line */ return $this->createSummaryColumn($custom_view->id, $custom_table->id, $custom_column->id, SummaryCondition::SUM); }); collect($custom_columns)->filter(function ($custom_column) { return $custom_column->indexEnabled && $custom_column->column_name == 'select'; - /** @phpstan-ignore-next-line Parameter #1 $callback of method + /** Parameter #1 $callback of method * Illuminate\Support\Collection<(int|string),mixed>::first() expects * (callable(mixed, int|string): bool)|null, Closure(mixed, mixed): void * given. */ + // @phpstan-ignore-next-line })->first(function ($custom_column, $index) use ($custom_view, $custom_table) { /** @phpstan-ignore-next-line */ return $this->createCustomViewFilter( @@ -1858,6 +1864,7 @@ protected function createPlugin() } // copy file + // @phpstan-ignore-next-line PluginInstaller::copySavePlugin($config_paths[0], pathinfo($testPluginDir, PATHINFO_BASENAME), $diskService); } } diff --git a/src/Database/Seeder/TestDataTrait.php b/src/Database/Seeder/TestDataTrait.php index c8511771d..27ad15342 100644 --- a/src/Database/Seeder/TestDataTrait.php +++ b/src/Database/Seeder/TestDataTrait.php @@ -213,8 +213,10 @@ protected function getMailTemplateFromKey($mail_template): ?CustomValue $result = null; if (is_numeric($mail_template)) { + /** @phpstan-ignore-next-line */ $result = getModelName(SystemTableName::MAIL_TEMPLATE)::find($mail_template); } else { + /** @phpstan-ignore-next-line */ $result = getModelName(SystemTableName::MAIL_TEMPLATE)::where('value->mail_key_name', $mail_template)->first(); } // if not found, return exception diff --git a/src/Database/Seeder/WorkflowTestDataSeeder.php b/src/Database/Seeder/WorkflowTestDataSeeder.php index d02077a7a..194249218 100644 --- a/src/Database/Seeder/WorkflowTestDataSeeder.php +++ b/src/Database/Seeder/WorkflowTestDataSeeder.php @@ -480,12 +480,14 @@ protected function createWorkflow($users) $workflowstatus = new WorkflowStatus(); $workflowstatus->workflow_id = $workflowObj->id; + // @phpstan-ignore-next-line foreach ($status as $key => $item) { $workflowstatus->{$key} = $item; } $workflowstatus->order = $index; $workflowstatus->save(); + // @phpstan-ignore-next-line $status['id'] = $workflowstatus->id; $status['index'] = $index; } @@ -496,14 +498,16 @@ protected function createWorkflow($users) $workflowaction = new WorkflowAction(); $workflowaction->workflow_id = $workflowObj->id; + // @phpstan-ignore-next-line $workflowaction->action_name = $action['action_name']; $workflowaction->ignore_work = $action['ignore_work']?? 0; + // @phpstan-ignore-next-line if ($action['status_from'] === 'start') { $workflowaction->status_from = $action['status_from']; $actionStatusFromTo['status_from'] = null; } else { - /** @phpstan-ignore-next-line Because an error occurs in SQLServer's UT when the 'id' is set */ + // @phpstan-ignore-next-line $workflowaction->status_from = $workflow['statuses'][$action['status_from']]['id']; $actionStatusFromTo['status_from'] = $workflowaction->status_from; } @@ -517,6 +521,7 @@ protected function createWorkflow($users) foreach ($action['authorities'] as $key => $item) { $item['workflow_action_id'] = $workflowaction->id; if ($item['related_type'] == 'column') { + // @phpstan-ignore-next-line $custom_column = CustomColumn::getEloquent($item['related_id'], $workflow['tables'][0]['custom_table']); $item['related_id'] = $custom_column->id; } @@ -532,7 +537,7 @@ protected function createWorkflow($users) $header->status_to = $item['status_to']; $actionStatusFromTo['status_to'] = null; } else { - /** @phpstan-ignore-next-line Because an error occurs in SQLServer's UT when the 'id' is set */ + // @phpstan-ignore-next-line $header->status_to = $workflow['statuses'][$item['status_to']]['id']; $actionStatusFromTo['status_to'] = $header->status_to; } @@ -549,7 +554,9 @@ protected function createWorkflow($users) $conditions['morph_id'] = $header->id; // @phpstan-ignore-next-line if (isset($conditions['target_column_id'])) { + /** @phpstan-ignore-next-line */ \Log::debug($workflow['tables'][0]['custom_table']); + // @phpstan-ignore-next-line $target_column = CustomColumn::getEloquent($conditions['target_column_id'], $workflow['tables'][0]['custom_table']); $conditions['target_column_id'] = $target_column->id; } @@ -564,6 +571,7 @@ protected function createWorkflow($users) foreach ($workflow['tables'] as &$table) { $wfTable = new WorkflowTable(); $wfTable->workflow_id = $workflowObj->id; + // @phpstan-ignore-next-line $wfTable->custom_table_id = CustomTable::getEloquent($table['custom_table'])->id; $wfTable->active_flg = true; $wfTable->save(); @@ -591,6 +599,7 @@ protected function createWorkflow($users) 'password' => array_get($user, 'password') ]); + // @phpstan-ignore-next-line $custom_value = CustomTable::getEloquent($table['custom_table'])->getValueModel(); $custom_value->setValue("text", "test_$userKey"); $custom_value->setValue("index_text", "index_$userKey"); @@ -605,6 +614,7 @@ protected function createWorkflow($users) $latest_flg = count($wfValueStatuses) - 1 === $index; + // @phpstan-ignore-next-line if ($table['custom_table'] == 'custom_value_edit_all') { if ($index === 1) { $latest_flg = true; @@ -615,12 +625,14 @@ protected function createWorkflow($users) // get target $actionStatusFromTo $actionStatusFromTo = collect($actionStatusFromTos)->first(function ($actionStatusFromTo) use ($wfValueStatuses, $index) { + // @phpstan-ignore-next-line return $wfValueStatuses[$index - 1]['id'] == $actionStatusFromTo['status_from'] && $wfValueStatuses[$index]['id'] == $actionStatusFromTo['status_to']; }); if (!isset($actionStatusFromTo)) { continue; } + // @phpstan-ignore-next-line $user = $users[$wfUserKeys[$index - 1]]; \Auth::guard('admin')->attempt([ 'username' => array_get($user, 'value.user_code'), diff --git a/src/Database/SqlServerConnection.php b/src/Database/SqlServerConnection.php index 9291acdeb..9242af35b 100644 --- a/src/Database/SqlServerConnection.php +++ b/src/Database/SqlServerConnection.php @@ -22,7 +22,7 @@ class SqlServerConnection extends BaseConnection implements ConnectionInterface */ public function getSchemaBuilder() { - /** @phpstan-ignore-next-line Call to function is_null() with Illuminate\Database\Schema\Grammars\Grammar will always evaluate to false. */ + // @phpstan-ignore-next-line if (is_null($this->schemaGrammar)) { $this->useDefaultSchemaGrammar(); } @@ -106,11 +106,13 @@ public function restoreDatabase($dirFullPath) * * @param string $dirFullPath restore file path */ + // @phpstan-ignore-next-line public function importTsv($dirFullPath) { } + // @phpstan-ignore-next-line public function createView($viewName, $query) { $viewName = $this->getQueryGrammar()->wrapTable($viewName); @@ -125,6 +127,7 @@ public function createView($viewName, $query) } + // @phpstan-ignore-next-line public function dropView($viewName) { $viewName = $this->getQueryGrammar()->wrapTable($viewName); diff --git a/src/Database/View/WorkflowStartView.php b/src/Database/View/WorkflowStartView.php index 694ba2c69..ebf098c33 100644 --- a/src/Database/View/WorkflowStartView.php +++ b/src/Database/View/WorkflowStartView.php @@ -10,6 +10,7 @@ class WorkflowStartView /** * create workflow view sql */ + // @phpstan-ignore-next-line public static function createWorkflowStartView() { /////// first query. not has workflow value's custom value diff --git a/src/Database/View/WorkflowValueView.php b/src/Database/View/WorkflowValueView.php index adaa9173d..8e8e7153c 100644 --- a/src/Database/View/WorkflowValueView.php +++ b/src/Database/View/WorkflowValueView.php @@ -11,6 +11,7 @@ class WorkflowValueView /** * create workflow view sql */ + // @phpstan-ignore-next-line public static function createWorkflowValueUnionView() { // get sub query for first executed workflow value's id. diff --git a/src/Enums/ApiScope.php b/src/Enums/ApiScope.php index b64157cb6..50f0a9ba3 100644 --- a/src/Enums/ApiScope.php +++ b/src/Enums/ApiScope.php @@ -22,6 +22,7 @@ class ApiScope extends EnumBase /** * get scope string for middleware */ + // @phpstan-ignore-next-line public static function getScopeString($addScope, ...$scopes) { if (!$addScope) { diff --git a/src/Enums/BackupTarget.php b/src/Enums/BackupTarget.php index 242a85a46..b65c44b31 100644 --- a/src/Enums/BackupTarget.php +++ b/src/Enums/BackupTarget.php @@ -18,6 +18,7 @@ class BackupTarget extends EnumBase * @param string|array $target * @return array|null */ + // @phpstan-ignore-next-line public static function dirOrDisk($target) { if (is_array($target)) { diff --git a/src/Enums/ColumnDefaultType.php b/src/Enums/ColumnDefaultType.php index c457714ca..214c07afa 100644 --- a/src/Enums/ColumnDefaultType.php +++ b/src/Enums/ColumnDefaultType.php @@ -18,6 +18,7 @@ class ColumnDefaultType extends EnumBase public const SELECT_USER = 'select_user'; + // @phpstan-ignore-next-line public static function COLUMN_DEFAULT_TYPE_DATE() { return [ @@ -26,6 +27,7 @@ public static function COLUMN_DEFAULT_TYPE_DATE() ]; } + // @phpstan-ignore-next-line public static function COLUMN_DEFAULT_TYPE_TIME() { return [ @@ -34,6 +36,7 @@ public static function COLUMN_DEFAULT_TYPE_TIME() ]; } + // @phpstan-ignore-next-line public static function COLUMN_DEFAULT_TYPE_DATETIME() { return [ @@ -43,6 +46,7 @@ public static function COLUMN_DEFAULT_TYPE_DATETIME() ]; } + // @phpstan-ignore-next-line public static function COLUMN_DEFAULT_TYPE_USER() { return [ diff --git a/src/Enums/ColumnType.php b/src/Enums/ColumnType.php index b143d6d02..f6760d01a 100644 --- a/src/Enums/ColumnType.php +++ b/src/Enums/ColumnType.php @@ -28,6 +28,7 @@ class ColumnType extends EnumBase public const USER = 'user'; public const ORGANIZATION = 'organization'; + // @phpstan-ignore-next-line public static function COLUMN_TYPE_CALC() { return [ @@ -37,6 +38,7 @@ public static function COLUMN_TYPE_CALC() ]; } + // @phpstan-ignore-next-line public static function COLUMN_TYPE_DATETIME() { return [ @@ -46,6 +48,7 @@ public static function COLUMN_TYPE_DATETIME() ]; } + // @phpstan-ignore-next-line public static function COLUMN_TYPE_DATE() { return [ @@ -54,6 +57,7 @@ public static function COLUMN_TYPE_DATE() ]; } + // @phpstan-ignore-next-line public static function COLUMN_TYPE_ATTACHMENT() { return [ @@ -62,6 +66,7 @@ public static function COLUMN_TYPE_ATTACHMENT() ]; } + // @phpstan-ignore-next-line public static function COLUMN_TYPE_URL() { return [ @@ -72,6 +77,7 @@ public static function COLUMN_TYPE_URL() ]; } + // @phpstan-ignore-next-line public static function COLUMN_TYPE_USER_ORGANIZATION() { return [ @@ -80,6 +86,7 @@ public static function COLUMN_TYPE_USER_ORGANIZATION() ]; } + // @phpstan-ignore-next-line public static function COLUMN_TYPE_SELECT_TABLE() { return [ @@ -89,6 +96,7 @@ public static function COLUMN_TYPE_SELECT_TABLE() ]; } + // @phpstan-ignore-next-line public static function COLUMN_TYPE_SELECT_FORM() { return [ @@ -100,6 +108,7 @@ public static function COLUMN_TYPE_SELECT_FORM() ]; } + // @phpstan-ignore-next-line public static function COLUMN_TYPE_2VALUE_SELECT() { return [ @@ -108,6 +117,7 @@ public static function COLUMN_TYPE_2VALUE_SELECT() ]; } + // @phpstan-ignore-next-line public static function COLUMN_TYPE_MULTIPLE_ENABLED() { return [ @@ -121,6 +131,7 @@ public static function COLUMN_TYPE_MULTIPLE_ENABLED() ]; } + // @phpstan-ignore-next-line public static function COLUMN_TYPE_SHOW_NOT_ESCAPE() { return [ @@ -133,6 +144,7 @@ public static function COLUMN_TYPE_SHOW_NOT_ESCAPE() ]; } + // @phpstan-ignore-next-line public static function COLUMN_TYPE_IMPORT_REPLACE() { return [ @@ -142,6 +154,7 @@ public static function COLUMN_TYPE_IMPORT_REPLACE() ]; } + // @phpstan-ignore-next-line public static function COLUMN_TYPE_OPERATION_ENABLE_SYSTEM() { return [ @@ -153,60 +166,73 @@ public static function COLUMN_TYPE_OPERATION_ENABLE_SYSTEM() ]; } + // @phpstan-ignore-next-line public static function isCalc($column_type) { return static::_isMatchColumnType($column_type, static::COLUMN_TYPE_CALC()); } + // @phpstan-ignore-next-line public static function isDate($column_type) { return static::_isMatchColumnType($column_type, static::COLUMN_TYPE_DATE()); } + // @phpstan-ignore-next-line public static function isDateTime($column_type) { return static::_isMatchColumnType($column_type, static::COLUMN_TYPE_DATETIME()); } + // @phpstan-ignore-next-line public static function isUrl($column_type) { return static::_isMatchColumnType($column_type, static::COLUMN_TYPE_URL()); } + // @phpstan-ignore-next-line public static function isAttachment($column_type) { return static::_isMatchColumnType($column_type, static::COLUMN_TYPE_ATTACHMENT()); } + // @phpstan-ignore-next-line public static function isUserOrganization($column_type) { return static::_isMatchColumnType($column_type, static::COLUMN_TYPE_USER_ORGANIZATION()); } + // @phpstan-ignore-next-line public static function isSelectTable($column_type) { return static::_isMatchColumnType($column_type, static::COLUMN_TYPE_SELECT_TABLE()); } + // @phpstan-ignore-next-line public static function is2ValueSelect($column_type) { return static::_isMatchColumnType($column_type, static::COLUMN_TYPE_2VALUE_SELECT()); } + // @phpstan-ignore-next-line public static function isMultipleEnabled($column_type) { return static::_isMatchColumnType($column_type, static::COLUMN_TYPE_MULTIPLE_ENABLED()); } + // @phpstan-ignore-next-line public static function isNotEscape($column_type) { return static::_isMatchColumnType($column_type, static::COLUMN_TYPE_SHOW_NOT_ESCAPE()); } + // @phpstan-ignore-next-line public static function isSelectForm($column_type) { return static::_isMatchColumnType($column_type, static::COLUMN_TYPE_SELECT_FORM()); } + // @phpstan-ignore-next-line public static function isOperationEnableSystem($column_type) { return static::_isMatchColumnType($column_type, static::COLUMN_TYPE_OPERATION_ENABLE_SYSTEM()); } + // @phpstan-ignore-next-line protected static function _isMatchColumnType($column_type, array $types): bool { if ($column_type instanceof CustomColumn) { @@ -220,6 +246,7 @@ protected static function _isMatchColumnType($column_type, array $types): bool * get text is date, or datetime * @return string|null */ + // @phpstan-ignore-next-line public static function getDateType($text) { if (is_null($text)) { @@ -294,6 +321,7 @@ public static function getFontAwesomeClass($column_type) } + // @phpstan-ignore-next-line public static function getHtml($column_type) { if ($column_type instanceof CustomColumn) { diff --git a/src/Enums/CompareColumnType.php b/src/Enums/CompareColumnType.php index c33bd1605..a6809eecf 100644 --- a/src/Enums/CompareColumnType.php +++ b/src/Enums/CompareColumnType.php @@ -8,6 +8,7 @@ class CompareColumnType extends EnumBase { public const SYSTEM_DATE = 'system_date'; + // @phpstan-ignore-next-line public static function getCompareValue($compare_type) { switch ($compare_type) { diff --git a/src/Enums/ConditionType.php b/src/Enums/ConditionType.php index 783780bed..aa3e5574b 100644 --- a/src/Enums/ConditionType.php +++ b/src/Enums/ConditionType.php @@ -19,6 +19,7 @@ class ConditionType extends EnumBase public const CONDITION = "4"; public const COMMENT = "5"; + // @phpstan-ignore-next-line public static function isTableItem($condition_type) { return in_array($condition_type, [ @@ -34,6 +35,7 @@ public static function isTableItem($condition_type) * * @return string|null */ + // @phpstan-ignore-next-line public static function getEnumByTargetKey($target): ?string { $systemEnum = SystemColumn::getEnum($target, null, false); diff --git a/src/Enums/ConditionTypeDetail.php b/src/Enums/ConditionTypeDetail.php index d25321880..16c198847 100644 --- a/src/Enums/ConditionTypeDetail.php +++ b/src/Enums/ConditionTypeDetail.php @@ -30,6 +30,7 @@ class ConditionTypeDetail extends EnumBase public const LOGIN_USER_COLUMN = "8"; public const COLUMN = "9"; + // @phpstan-ignore-next-line public static function CONDITION_OPTIONS() { return [ @@ -39,6 +40,7 @@ public static function CONDITION_OPTIONS() ]; } + // @phpstan-ignore-next-line public static function SYSTEM_TABLE_OPTIONS($form_priority_type) { $result = []; diff --git a/src/Enums/CurrencySymbol.php b/src/Enums/CurrencySymbol.php index 19270eec6..99c1eba7c 100644 --- a/src/Enums/CurrencySymbol.php +++ b/src/Enums/CurrencySymbol.php @@ -9,6 +9,7 @@ class CurrencySymbol extends EnumBase public const USD = 'USD'; public const EUR = 'EUR'; + // @phpstan-ignore-next-line protected static $options = [ 'JPY1' => ['text' => '¥', 'html' => '¥', 'type' => 'before'], 'JPY2' => ['text' => '円', 'html' => '円', 'type' => 'after'], @@ -16,11 +17,13 @@ class CurrencySymbol extends EnumBase 'EUR' => ['text' => '€', 'html' => '€', 'type' => 'after'], ]; + // @phpstan-ignore-next-line public function getOption() { return array_get(static::$options, $this->getValue()); } + // @phpstan-ignore-next-line public static function getEnum($value, $default = null) { $enum = parent::getEnum($value, $default); diff --git a/src/Enums/CustomValuePageType.php b/src/Enums/CustomValuePageType.php index 6a37dc02f..2eed59c9f 100644 --- a/src/Enums/CustomValuePageType.php +++ b/src/Enums/CustomValuePageType.php @@ -16,6 +16,7 @@ class CustomValuePageType extends EnumBase public const GRIDMODAL = 'gridmodal'; + // @phpstan-ignore-next-line public static function getFormDataType($pageType) { switch ($pageType) { diff --git a/src/Enums/DashboardBoxSystemPage.php b/src/Enums/DashboardBoxSystemPage.php index 13a4ad5cd..fbd257758 100644 --- a/src/Enums/DashboardBoxSystemPage.php +++ b/src/Enums/DashboardBoxSystemPage.php @@ -12,6 +12,7 @@ class DashboardBoxSystemPage extends EnumBase public const HTML = 4; public const NOTIFY_NAVBAR = 4; + // @phpstan-ignore-next-line protected static $options = [ 'guideline' => ['id' => 1, 'name' => 'guideline', 'class' => SystemItems\Guideline::class], 'news' => ['id' => 2, 'name' => 'news', 'class' => SystemItems\News::class], @@ -21,16 +22,19 @@ class DashboardBoxSystemPage extends EnumBase 'barcode' => ['id' => 6, 'name' => 'barcode', 'class' => SystemItems\Barcode::class], ]; + // @phpstan-ignore-next-line public function option() { return array_get(static::$options, $this->lowerKey()); } + // @phpstan-ignore-next-line public static function options() { return static::$options; } + // @phpstan-ignore-next-line public static function getEnum($value, $default = null) { $enum = parent::getEnum($value, $default); diff --git a/src/Enums/DashboardBoxType.php b/src/Enums/DashboardBoxType.php index 2768f859a..387202c05 100644 --- a/src/Enums/DashboardBoxType.php +++ b/src/Enums/DashboardBoxType.php @@ -12,6 +12,7 @@ class DashboardBoxType extends EnumBase public const CALENDAR = 'calendar'; public const PLUGIN = 'plugin'; + // @phpstan-ignore-next-line public static function DASHBOARD_BOX_TYPE_OPTIONS() { return @@ -24,6 +25,7 @@ public static function DASHBOARD_BOX_TYPE_OPTIONS() ]; } + // @phpstan-ignore-next-line public function getDashboardBoxItemClass() { switch ($this) { diff --git a/src/Enums/Driver.php b/src/Enums/Driver.php index 89bc9fbb5..52152b317 100644 --- a/src/Enums/Driver.php +++ b/src/Enums/Driver.php @@ -14,6 +14,7 @@ class Driver extends EnumBase public const FTP = 'ftp'; public const SFTP = 'sftp'; + // @phpstan-ignore-next-line public static $customDrivers = []; @@ -39,6 +40,7 @@ public static function extend($abstract, $class) * @param string $driverKey * @return Filesystem|FilesystemAdapter */ + // @phpstan-ignore-next-line public static function getExmentDriver($app, $config, $driverKey) { $c = config("exment.driver.$driverKey", 'local'); diff --git a/src/Enums/EditableUserInfoType.php b/src/Enums/EditableUserInfoType.php index 95241d69e..d2ca52fe8 100644 --- a/src/Enums/EditableUserInfoType.php +++ b/src/Enums/EditableUserInfoType.php @@ -8,6 +8,7 @@ class EditableUserInfoType extends EnumBase public const VIEW = 'view'; public const EDIT = 'edit'; + // @phpstan-ignore-next-line public static function showSettingForm($editableType) { switch ($editableType) { diff --git a/src/Enums/EnumBase.php b/src/Enums/EnumBase.php index 21f5737be..b1b3a5114 100644 --- a/src/Enums/EnumBase.php +++ b/src/Enums/EnumBase.php @@ -4,11 +4,13 @@ use MyCLabs\Enum\Enum; +// @phpstan-ignore-next-line class EnumBase extends Enum { /** * get lower key Name */ + // @phpstan-ignore-next-line public function lowerKey() { return strtolower($this->getKey()); @@ -17,11 +19,13 @@ public function lowerKey() /** * get upper key Name */ + // @phpstan-ignore-next-line public function upperKey() { return strtoupper($this->getKey()); } + // @phpstan-ignore-next-line public function toString() { return $this->__toString(); @@ -32,6 +36,7 @@ public function toString() * value is enum value. * text translates using enum value. */ + // @phpstan-ignore-next-line public static function transArray($base_key, $isExment = true) { return getTransArray(static::arrays(), $base_key, $isExment); @@ -42,6 +47,7 @@ public static function transArray($base_key, $isExment = true) * value is enum value. * text translates using enum value. */ + // @phpstan-ignore-next-line public static function transArrayFilter($base_key, $targetEnums, $isExment = true) { $arrays = collect(static::arrays())->filter(function ($arr) use ($targetEnums) { @@ -55,6 +61,7 @@ public static function transArrayFilter($base_key, $targetEnums, $isExment = tru * value is enum value. * text translates using enum key. */ + // @phpstan-ignore-next-line public static function transKeyArray($base_key, $isExment = true) { $array = []; @@ -69,6 +76,7 @@ public static function transKeyArray($base_key, $isExment = true) * value is enum value. * text translates using enum key. */ + // @phpstan-ignore-next-line public static function transKeyArrayFilter($base_key, $targetEnums, $isExment = true) { $array = []; @@ -84,6 +92,7 @@ public static function transKeyArrayFilter($base_key, $targetEnums, $isExment = /** * convert trans. use enum key (and convert key snake_case) */ + // @phpstan-ignore-next-line public function transKey($base_key, $isExment = true) { $key = $base_key.'.'.$this->lowerKey(); @@ -93,11 +102,13 @@ public function transKey($base_key, $isExment = true) return trans($key); } + // @phpstan-ignore-next-line public static function arrays() { return array_flatten(static::toArray()); } + // @phpstan-ignore-next-line public static function getEnum($value, $default = null) { if ($value instanceof Enum) { @@ -126,6 +137,7 @@ public static function getEnum($value, $default = null) /** * get enum, and return value */ + // @phpstan-ignore-next-line public static function getEnumValue($value, $default = null) { $enum = static::getEnum($value, $default); diff --git a/src/Enums/EnumOptionTrait.php b/src/Enums/EnumOptionTrait.php index 21b159973..06fe75ba8 100644 --- a/src/Enums/EnumOptionTrait.php +++ b/src/Enums/EnumOptionTrait.php @@ -9,12 +9,14 @@ */ trait EnumOptionTrait { + // @phpstan-ignore-next-line public function option() { /** @phpstan-ignore-next-line array_get expects array|ArrayAccess, static(Exceedone\Exment\Enums\SystemColumn) given */ return array_get(static::$options, $this->lowerKey(), null); } + // @phpstan-ignore-next-line public static function getOptions($filters = []) { $options = static::$options; @@ -26,6 +28,7 @@ public static function getOptions($filters = []) return collect($options)->toArray(); } + // @phpstan-ignore-next-line public static function getOption($filters = []) { return collect(static::getOptions($filters))->first() ?? null; diff --git a/src/Enums/ErrorCode.php b/src/Enums/ErrorCode.php index ba1691b5b..c90c38e9e 100644 --- a/src/Enums/ErrorCode.php +++ b/src/Enums/ErrorCode.php @@ -51,6 +51,7 @@ class ErrorCode extends EnumBase public const DISAPPROVAL_IP = '301'; public const NOT_CONTAINS_CUSTOM_FORM = '401'; + // @phpstan-ignore-next-line public function getMessage() { if ($this == static::PERMISSION_DENY) { diff --git a/src/Enums/FilterKind.php b/src/Enums/FilterKind.php index 489ab0c4f..271fac19a 100644 --- a/src/Enums/FilterKind.php +++ b/src/Enums/FilterKind.php @@ -9,6 +9,7 @@ class FilterKind extends EnumBase public const FORM = 'form'; public const OPERATION = 'operation'; + // @phpstan-ignore-next-line public static function FILTER_KIND_USE_DATE() { return [ @@ -18,6 +19,7 @@ public static function FILTER_KIND_USE_DATE() ]; } + // @phpstan-ignore-next-line public static function useDate($filter_kind) { return in_array($filter_kind, static::FILTER_KIND_USE_DATE()); diff --git a/src/Enums/FilterOption.php b/src/Enums/FilterOption.php index 1cb4c7333..937671cb0 100644 --- a/src/Enums/FilterOption.php +++ b/src/Enums/FilterOption.php @@ -60,6 +60,7 @@ class FilterOption extends EnumBase public const WORKFLOW_NE_STATUS = 6002; public const WORKFLOW_EQ_WORK_USER = 6003; + // @phpstan-ignore-next-line public static function VALUE_TYPE($filter_option) { switch ($filter_option) { @@ -101,6 +102,7 @@ public static function VALUE_TYPE($filter_option) * * @return array */ + // @phpstan-ignore-next-line public static function FILTER_OPTIONS() { $options = [ @@ -200,6 +202,7 @@ public static function FILTER_OPTIONS() } + // @phpstan-ignore-next-line protected static function getTransName($key) { switch ($key) { @@ -254,6 +257,7 @@ protected static function getTransName($key) /** * get condition key text (for form condition only) */ + // @phpstan-ignore-next-line public static function getConditionKeyText($condition_key) { $enum = $condition_key; diff --git a/src/Enums/FormColumnType.php b/src/Enums/FormColumnType.php index 2ab68d8a8..80c3cd0a8 100644 --- a/src/Enums/FormColumnType.php +++ b/src/Enums/FormColumnType.php @@ -15,6 +15,7 @@ class FormColumnType extends EnumBase * * @var array[] */ + // @phpstan-ignore-next-line protected static $options = [ 1 => ['id' => 1, 'column_name' => 'header'], 2 => ['id' => 2, 'column_name' => 'explain'], @@ -24,13 +25,13 @@ class FormColumnType extends EnumBase 6 => ['id' => 6, 'column_name' => 'hr'], ]; + // @phpstan-ignore-next-line public static function getEnum($value, $default = null) { $enum = parent::getEnum($value, $default); if (isset($enum)) { return $enum; } - foreach (self::$options as $key => $v) { if (array_get($v, 'id') == $value) { return parent::getEnum($key); diff --git a/src/Enums/FormLabelType.php b/src/Enums/FormLabelType.php index 7e604502a..cbc65a7ea 100644 --- a/src/Enums/FormLabelType.php +++ b/src/Enums/FormLabelType.php @@ -9,6 +9,7 @@ class FormLabelType extends EnumBase public const VERTICAL = "vertical"; public const HIDDEN = "hidden"; + // @phpstan-ignore-next-line public static function getFormLabelTypes() { return [ @@ -18,6 +19,7 @@ public static function getFormLabelTypes() ]; } + // @phpstan-ignore-next-line public static function getFieldLabelTypes() { return [ diff --git a/src/Enums/GroupCondition.php b/src/Enums/GroupCondition.php index 3b0f9701c..8b94a66f3 100644 --- a/src/Enums/GroupCondition.php +++ b/src/Enums/GroupCondition.php @@ -21,6 +21,7 @@ class GroupCondition extends EnumBase * * @var array[] */ + // @phpstan-ignore-next-line protected static $options = [ ['id' => 'y', 'name' => 'y'], ['id' => 'ym', 'name' => 'ym'], diff --git a/src/Enums/JoinedMultiUserFilterType.php b/src/Enums/JoinedMultiUserFilterType.php index 6a2aba8d0..74e0f565d 100644 --- a/src/Enums/JoinedMultiUserFilterType.php +++ b/src/Enums/JoinedMultiUserFilterType.php @@ -28,6 +28,7 @@ class JoinedMultiUserFilterType extends EnumBase public const ONLY_JOIN = '0'; + // @phpstan-ignore-next-line public static function getOptions() { if (boolval(System::organization_available())) { diff --git a/src/Enums/JoinedOrgFilterType.php b/src/Enums/JoinedOrgFilterType.php index 0f8b7b061..b650fc1f1 100644 --- a/src/Enums/JoinedOrgFilterType.php +++ b/src/Enums/JoinedOrgFilterType.php @@ -15,6 +15,7 @@ class JoinedOrgFilterType extends EnumBase /** * whether getting upper line organization */ + // @phpstan-ignore-next-line public static function isGetUpper($filterType) { $enum = static::getEnum($filterType); @@ -24,6 +25,7 @@ public static function isGetUpper($filterType) /** * whether getting down line organization */ + // @phpstan-ignore-next-line public static function isGetDowner($filterType) { $enum = static::getEnum($filterType); diff --git a/src/Enums/LoginType.php b/src/Enums/LoginType.php index c404275ec..d72b62c27 100644 --- a/src/Enums/LoginType.php +++ b/src/Enums/LoginType.php @@ -19,6 +19,7 @@ class LoginType extends EnumBase public const SAML = 'saml'; public const LDAP = 'ldap'; + // @phpstan-ignore-next-line public static function SETTING() { return [LoginType::OAUTH(), LoginType::SAML(), LoginType::LDAP()]; @@ -29,6 +30,7 @@ public static function SETTING() * * @return string */ + // @phpstan-ignore-next-line public static function getLoginServiceClassName($login_type): string { switch ($login_type) { diff --git a/src/Enums/NotifyAction.php b/src/Enums/NotifyAction.php index 946c94e9e..d2618cb9e 100644 --- a/src/Enums/NotifyAction.php +++ b/src/Enums/NotifyAction.php @@ -17,6 +17,7 @@ class NotifyAction extends EnumBase * @param string|array $action_setting * @return boolean */ + // @phpstan-ignore-next-line public static function isChatMessage($action_setting): bool { if (is_nullorempty($action_setting)) { @@ -38,6 +39,7 @@ public static function isChatMessage($action_setting): bool * @param string|array $action_setting * @return boolean */ + // @phpstan-ignore-next-line public static function isUserTarget($action_setting): bool { if (is_nullorempty($action_setting)) { @@ -51,6 +53,7 @@ public static function isUserTarget($action_setting): bool return false; } + // @phpstan-ignore-next-line public static function getColumnGettingOptions($notify_action) { switch ($notify_action) { diff --git a/src/Enums/NotifyActionTarget.php b/src/Enums/NotifyActionTarget.php index ce1f77670..8bc3eace0 100644 --- a/src/Enums/NotifyActionTarget.php +++ b/src/Enums/NotifyActionTarget.php @@ -16,6 +16,7 @@ class NotifyActionTarget extends EnumBase public const FIXED_ORGANIZATION = 'fixed_organization'; public const ACTION_USER = 'action_user'; + // @phpstan-ignore-next-line public static function ACTION_TARGET_CUSTOM_TABLE() { $targets = [ @@ -32,6 +33,7 @@ public static function ACTION_TARGET_CUSTOM_TABLE() return $targets; } + // @phpstan-ignore-next-line public static function ACTION_TARGET_WORKFLOW() { $targets = [ diff --git a/src/Enums/NotifyTargetType.php b/src/Enums/NotifyTargetType.php index b27ca6694..3b94445cb 100644 --- a/src/Enums/NotifyTargetType.php +++ b/src/Enums/NotifyTargetType.php @@ -9,6 +9,7 @@ class NotifyTargetType extends EnumBase public const USER = "3"; public const ORGANIZATION = "4"; + // @phpstan-ignore-next-line public static function getNotifyFuncByTable($table_name) { switch ($table_name) { diff --git a/src/Enums/NotifyTrigger.php b/src/Enums/NotifyTrigger.php index 49b644e2f..6aceeace2 100644 --- a/src/Enums/NotifyTrigger.php +++ b/src/Enums/NotifyTrigger.php @@ -12,6 +12,7 @@ class NotifyTrigger extends EnumBase public const PUBLIC_FORM_COMPLETE_ADMIN = "6"; public const PUBLIC_FORM_ERROR = "7"; + // @phpstan-ignore-next-line public static function CUSTOM_TABLES() { return [ @@ -21,6 +22,7 @@ public static function CUSTOM_TABLES() ]; } + // @phpstan-ignore-next-line public static function PUBLIC_FORMS() { return [ @@ -30,6 +32,7 @@ public static function PUBLIC_FORMS() ]; } + // @phpstan-ignore-next-line public function getDefaultMailKeyName() { switch ($this->getValue()) { diff --git a/src/Enums/OperationValueType.php b/src/Enums/OperationValueType.php index f79f9d1ee..e52de4f83 100644 --- a/src/Enums/OperationValueType.php +++ b/src/Enums/OperationValueType.php @@ -13,6 +13,7 @@ class OperationValueType extends EnumBase public const BERONG_ORGANIZATIONS = 'berong_organizations'; + // @phpstan-ignore-next-line public static function getOperationValueOptions($operation_update_type, $custom_column) { if ($operation_update_type != OperationUpdateType::SYSTEM) { @@ -38,6 +39,7 @@ public static function getOperationValueOptions($operation_update_type, $custom_ * @param mixed $operation_update_type * @return mixed */ + // @phpstan-ignore-next-line public static function getOperationValue(CustomColumn $custom_column, $operation_update_type, $custom_value) { switch ($operation_update_type) { diff --git a/src/Enums/PluginType.php b/src/Enums/PluginType.php index 558919d40..bee180916 100644 --- a/src/Enums/PluginType.php +++ b/src/Enums/PluginType.php @@ -47,6 +47,7 @@ class PluginType extends EnumBase * Plugin type. Can call from endpoint. * @return array */ + // @phpstan-ignore-next-line public static function PLUGIN_TYPE_PUBLIC_CLASS() { return [ @@ -64,6 +65,7 @@ public static function PLUGIN_TYPE_PUBLIC_CLASS() * plugin page types. Needs Page's endpoint. * @return array */ + // @phpstan-ignore-next-line public static function PLUGIN_TYPE_PLUGIN_PAGE() { return [ @@ -79,6 +81,7 @@ public static function PLUGIN_TYPE_PLUGIN_PAGE() * plugin show menu. Needs Page's endpoint. * @return array */ + // @phpstan-ignore-next-line public static function PLUGIN_TYPE_SHOW_MENU() { return [ @@ -91,6 +94,7 @@ public static function PLUGIN_TYPE_SHOW_MENU() * Get plugin scripts and styles. Needs script and css endpoint, and read public file. * @return array */ + // @phpstan-ignore-next-line public static function PLUGIN_TYPE_SCRIPT_STYLE() { return [ @@ -106,6 +110,7 @@ public static function PLUGIN_TYPE_SCRIPT_STYLE() * plugin types. Can read resource view. * @return array */ + // @phpstan-ignore-next-line public static function PLUGIN_TYPE_PLUGIN_USE_VIEW() { return [ @@ -120,6 +125,7 @@ public static function PLUGIN_TYPE_PLUGIN_USE_VIEW() * * @return array */ + // @phpstan-ignore-next-line public static function PLUGIN_TYPE_CUSTOM_TABLE() { return [ @@ -139,6 +145,7 @@ public static function PLUGIN_TYPE_CUSTOM_TABLE() * * @return array */ + // @phpstan-ignore-next-line public static function PLUGIN_TYPE_FILTER_ACCESSIBLE() { return [ @@ -160,6 +167,7 @@ public static function PLUGIN_TYPE_FILTER_ACCESSIBLE() * * @return array */ + // @phpstan-ignore-next-line public static function PLUGIN_TYPE_BUTTON() { return [ @@ -174,6 +182,7 @@ public static function PLUGIN_TYPE_BUTTON() * * @return array */ + // @phpstan-ignore-next-line public static function PLUGIN_TYPE_EVENT() { return [ @@ -187,6 +196,7 @@ public static function PLUGIN_TYPE_EVENT() * * @return array */ + // @phpstan-ignore-next-line public static function PLUGIN_TYPE_URL() { return [ @@ -205,6 +215,7 @@ public static function PLUGIN_TYPE_URL() * @param array $options * @return mixed */ + // @phpstan-ignore-next-line public static function getPluginClass($plugin_type, $plugin, $options = []) { $options = array_merge([ @@ -293,6 +304,7 @@ public static function getPluginClass($plugin_type, $plugin, $options = []) * @param array $options * @return ?string */ + // @phpstan-ignore-next-line public static function getPluginClassName($plugin_type, $plugin, $options = []): ?string { $options = array_merge([ @@ -308,7 +320,6 @@ public static function getPluginClassName($plugin_type, $plugin, $options = []): $classname = $plugin->getNameSpace($classShortName); $fuleFullPath = $plugin->getFullPath($classShortName . '.php'); - if (\File::exists($fuleFullPath) && class_exists($classname)) { return $classname; } @@ -332,6 +343,7 @@ public static function getPluginClassName($plugin_type, $plugin, $options = []): * @param array $options * @return string */ + // @phpstan-ignore-next-line public static function getPluginClassShortName($plugin_type, $plugin, $options = []) { $options = array_merge([ @@ -343,7 +355,6 @@ public static function getPluginClassShortName($plugin_type, $plugin, $options = if (boolval($options['as_setting'])) { return 'PluginSetting'; } - return 'Plugin' . pascalize(strtolower($plugin_type->getKey())); } diff --git a/src/Enums/RoleGroupType.php b/src/Enums/RoleGroupType.php index 37a87606e..d6ccb8824 100644 --- a/src/Enums/RoleGroupType.php +++ b/src/Enums/RoleGroupType.php @@ -21,6 +21,7 @@ class RoleGroupType extends EnumBase public const PLUGIN = "plugin"; public const ROLE_GROUP = "role_group"; + // @phpstan-ignore-next-line public function getRoleGroupOptions() { $permissions = $this->getRoleGroupPermissions(); @@ -29,6 +30,7 @@ public function getRoleGroupOptions() }); } + // @phpstan-ignore-next-line public function getRoleGroupHelps() { $permissions = $this->getRoleGroupPermissions(); @@ -37,6 +39,7 @@ public function getRoleGroupHelps() }); } + // @phpstan-ignore-next-line public function getRoleGroupPermissions() { switch ($this->lowerKey()) { diff --git a/src/Enums/SearchType.php b/src/Enums/SearchType.php index c317c8788..e1e1b6c78 100644 --- a/src/Enums/SearchType.php +++ b/src/Enums/SearchType.php @@ -15,19 +15,23 @@ class SearchType extends EnumBase public const SUMMARY_MANY_TO_MANY = 52; public const SUMMARY_SELECT_TABLE = 53; + // @phpstan-ignore-next-line public static function isSummarySearchType($search_type) { return in_array($search_type, [static::SUMMARY_ONE_TO_MANY, static::SUMMARY_MANY_TO_MANY, static::SUMMARY_SELECT_TABLE]); } + // @phpstan-ignore-next-line public static function isOneToMany($search_type) { return in_array($search_type, [static::ONE_TO_MANY, static::SUMMARY_ONE_TO_MANY]); } + // @phpstan-ignore-next-line public static function isManyToMany($search_type) { return in_array($search_type, [static::MANY_TO_MANY, static::SUMMARY_MANY_TO_MANY]); } + // @phpstan-ignore-next-line public static function isSelectTable($search_type) { return in_array($search_type, [static::SELECT_TABLE, static::SUMMARY_SELECT_TABLE]); diff --git a/src/Enums/ShowPositionType.php b/src/Enums/ShowPositionType.php index 8a45ce337..0060f46e0 100644 --- a/src/Enums/ShowPositionType.php +++ b/src/Enums/ShowPositionType.php @@ -9,6 +9,7 @@ class ShowPositionType extends EnumBase public const BOTTOM = 'bottom'; public const HIDE = 'hide'; + // @phpstan-ignore-next-line public static function SYSTEM_SETTINGS() { return [ diff --git a/src/Enums/SummaryCondition.php b/src/Enums/SummaryCondition.php index 1c981b93b..1febb3fdb 100644 --- a/src/Enums/SummaryCondition.php +++ b/src/Enums/SummaryCondition.php @@ -16,6 +16,7 @@ class SummaryCondition extends EnumBase * @var array[] * We should use `const OPTIONS` instead of `protected static $options`. */ + // @phpstan-ignore-next-line protected static $options = [ "1" => ['id' => "1", 'name' => 'sum', 'numeric' => true, 'countable' => true], //2 => ['id' => 2, 'name' => 'avg', 'numeric' => true], diff --git a/src/Enums/SystemColumn.php b/src/Enums/SystemColumn.php index 5248c5bda..8103e11bc 100644 --- a/src/Enums/SystemColumn.php +++ b/src/Enums/SystemColumn.php @@ -41,6 +41,7 @@ class SystemColumn extends EnumBase * * @var array[] */ + // @phpstan-ignore-next-line protected static $options = [ 'id' => ['id' => 1, 'name' => 'id', 'sqlname' => 'id', 'default' => true, 'order' => 1, 'header' => true, 'summary' => true, 'min_width' => 30, 'max_width' => 100, 'grid_filter' => true, 'grid_filter_system' => true], 'suuid' => ['id' => 2, 'name' => 'suuid', 'sqlname' => 'suuid', 'default' => false, 'order' => 2, 'header' => true, 'min_width' => 100, 'max_width' => 300], @@ -57,26 +58,31 @@ class SystemColumn extends EnumBase 'comment' => ['id' => 301, 'name' => 'comment', 'tagname' => 'comment_tag', 'default' => false, 'grid_filter' => true, 'grid_filter_system' => false], ]; + // @phpstan-ignore-next-line public function id() { return array_get($this->option(), 'id'); } + // @phpstan-ignore-next-line public function name() { return $this->lowerKey(); } + // @phpstan-ignore-next-line public static function isWorkflow($key) { return in_array($key, [static::WORKFLOW_STATUS, static::WORKFLOW_WORK_USERS]); } + // @phpstan-ignore-next-line public static function isComment($key) { return in_array($key, [static::COMMENT]); } + // @phpstan-ignore-next-line public static function getEnum($value, $default = null, $include_id = true) { $enum = parent::getEnum($value, $default); @@ -94,6 +100,7 @@ public static function getEnum($value, $default = null, $include_id = true) return $default; } + // @phpstan-ignore-next-line public static function isSqlValid($value) { foreach (self::$options as $key => $v) { diff --git a/src/Enums/SystemLocale.php b/src/Enums/SystemLocale.php index 53138a937..969df5cf5 100644 --- a/src/Enums/SystemLocale.php +++ b/src/Enums/SystemLocale.php @@ -12,6 +12,7 @@ class SystemLocale extends EnumBase * * @return array */ + // @phpstan-ignore-next-line public static function getLocaleOptions() { // get expand system locale diff --git a/src/Enums/SystemTableName.php b/src/Enums/SystemTableName.php index d5f238cf7..bb3922236 100644 --- a/src/Enums/SystemTableName.php +++ b/src/Enums/SystemTableName.php @@ -45,6 +45,7 @@ class SystemTableName extends EnumBase public const VIEW_WORKFLOW_VALUE_UNION = 'view_workflow_value_unions'; public const VIEW_WORKFLOW_START = 'view_workflow_start'; + // @phpstan-ignore-next-line public static function SYSTEM_TABLE_NAME_IGNORE_SAVED_AUTHORITY() { return [ @@ -55,6 +56,7 @@ public static function SYSTEM_TABLE_NAME_IGNORE_SAVED_AUTHORITY() ]; } + // @phpstan-ignore-next-line public static function SYSTEM_TABLE_NAME_MASTER() { return [ diff --git a/src/Enums/TemplateExportTarget.php b/src/Enums/TemplateExportTarget.php index 59fefea38..8f975c89f 100644 --- a/src/Enums/TemplateExportTarget.php +++ b/src/Enums/TemplateExportTarget.php @@ -10,6 +10,7 @@ class TemplateExportTarget extends EnumBase public const ROLE_GROUP = 'role_group'; public const PUBLIC_FORM = 'public_form'; + // @phpstan-ignore-next-line public static function TEMPLATE_EXPORT_OPTIONS() { return [ diff --git a/src/Enums/ValueType.php b/src/Enums/ValueType.php index 1d9ff6c6b..43719e0c9 100644 --- a/src/Enums/ValueType.php +++ b/src/Enums/ValueType.php @@ -50,6 +50,7 @@ public function getCustomValue(?ItemInterface $item, ?CustomValue $custom_value) * * @return boolean */ + // @phpstan-ignore-next-line public static function filterApiValueType($valueType) { $enum = static::getEnum($valueType); @@ -67,6 +68,7 @@ public static function filterApiValueType($valueType) * * @return boolean */ + // @phpstan-ignore-next-line public static function isRegetApiCustomValue($valueType) { $enum = static::getEnum($valueType); diff --git a/src/Enums/ViewKindType.php b/src/Enums/ViewKindType.php index 8ca6de1ff..5b997652a 100644 --- a/src/Enums/ViewKindType.php +++ b/src/Enums/ViewKindType.php @@ -38,6 +38,7 @@ public static function acceptApiData($view_kind_type) return static::acceptApi($view_kind_type, [static::DEFAULT, static::ALLDATA]); } + // @phpstan-ignore-next-line protected static function acceptApi($view_kind_type, array $acceptTypes) { $enum = static::getEnum($view_kind_type); @@ -49,6 +50,7 @@ protected static function acceptApi($view_kind_type, array $acceptTypes) } + // @phpstan-ignore-next-line public static function getGridItemClassName($view_kind_type) { switch ($view_kind_type) { diff --git a/src/Enums/WorkflowWorkTargetType.php b/src/Enums/WorkflowWorkTargetType.php index 8f7380dad..d390a7023 100644 --- a/src/Enums/WorkflowWorkTargetType.php +++ b/src/Enums/WorkflowWorkTargetType.php @@ -16,6 +16,7 @@ class WorkflowWorkTargetType extends EnumBase public const FIX = "fix"; + // @phpstan-ignore-next-line public static function getTargetTypeDefault($index) { $result = [ @@ -29,6 +30,7 @@ public static function getTargetTypeDefault($index) return json_encode($result); } + // @phpstan-ignore-next-line public static function getTargetTypeNameDefault($index) { $targetTypeDefault = jsonToArray(static::getTargetTypeDefault($index)); diff --git a/src/Exceptions/NoMailTemplateException.php b/src/Exceptions/NoMailTemplateException.php index 450f6a471..f5097a344 100644 --- a/src/Exceptions/NoMailTemplateException.php +++ b/src/Exceptions/NoMailTemplateException.php @@ -4,6 +4,7 @@ class NoMailTemplateException extends \Exception { + // @phpstan-ignore-next-line public function __construct($mail_key_name) { parent::__construct("No MailTemplate. Please set mail template. mail_template:$mail_key_name"); diff --git a/src/Exceptions/PublicFormNotFoundException.php b/src/Exceptions/PublicFormNotFoundException.php index 443d2d962..6dea4fc19 100644 --- a/src/Exceptions/PublicFormNotFoundException.php +++ b/src/Exceptions/PublicFormNotFoundException.php @@ -10,6 +10,7 @@ class PublicFormNotFoundException extends \Exception * @param $request * @return array|\Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\Translation\Translator|mixed|string|null */ + // @phpstan-ignore-next-line public function render($request) { return exmtrans('error.public_form_not_found'); diff --git a/src/Exceptions/SsoLoginErrorException.php b/src/Exceptions/SsoLoginErrorException.php index 513e3310e..455a083a9 100644 --- a/src/Exceptions/SsoLoginErrorException.php +++ b/src/Exceptions/SsoLoginErrorException.php @@ -6,11 +6,16 @@ class SsoLoginErrorException extends \Exception { + // @phpstan-ignore-next-line protected $sso_login_error_type; + // @phpstan-ignore-next-line protected $displayMessage; + // @phpstan-ignore-next-line protected $adminMessage; + // @phpstan-ignore-next-line protected $hasAdminError; + // @phpstan-ignore-next-line public function __construct($sso_login_error_type, $displayMessage, $adminMessage = null) { $this->sso_login_error_type = SsoLoginErrorType::getEnum($sso_login_error_type); @@ -22,11 +27,13 @@ public function __construct($sso_login_error_type, $displayMessage, $adminMessag $this->message = $this->adminMessage; } + // @phpstan-ignore-next-line public function getSsoErrorMessage() { return $this->displayMessage; } + // @phpstan-ignore-next-line public function getSsoAdminErrorMessage() { return $this->adminMessage; diff --git a/src/Exment.php b/src/Exment.php index ed5859c41..066795040 100644 --- a/src/Exment.php +++ b/src/Exment.php @@ -73,6 +73,7 @@ public function classLoader() * * @return array */ + // @phpstan-ignore-next-line public function menu() { return (new Menu())->toTree(); @@ -95,6 +96,7 @@ public function error($request, $exception, $callback) try { // Api is default callback if ($this->isApiEndpoint()) { + // @phpstan-ignore-next-line return $callback($request, $exception); } @@ -115,6 +117,7 @@ public function error($request, $exception, $callback) } if ($this->isPublicFormEndpoint()) { + // @phpstan-ignore-next-line return $callback($request, $exception); } @@ -128,27 +131,33 @@ public function error($request, $exception, $callback) ]); } + // @phpstan-ignore-next-line return $callback($request, $exception); } // whether has User $user = \Exment::user(); if (!$user) { + // @phpstan-ignore-next-line return $callback($request, $exception); } $errorController = app(\Exceedone\Exment\Controllers\ErrorController::class); return $errorController->error($request, $exception); } catch (\Exception $ex) { + // @phpstan-ignore-next-line return $callback($request, $exception); } catch (\Throwable $e) { + // @phpstan-ignore-next-line return $callback($request, $exception); } } /** + // Laravel facade Auth not recognized * get user. Use "Auth::shouldUse", so get only logined user. */ + // @phpstan-ignore-next-line public function user($guards = null) { return \Auth::guard($this->guard)->user(); @@ -158,6 +167,7 @@ public function user($guards = null) /** * set gurad info. */ + // @phpstan-ignore-next-line public function setGuard(string $guard) { $this->guard = $guard; @@ -181,6 +191,7 @@ public function getUserId() } + // @phpstan-ignore-next-line public function getRender($grid): ?string { if ($grid instanceof Renderable) { @@ -198,6 +209,7 @@ public function getRender($grid): ?string /** * get exment version */ + // @phpstan-ignore-next-line public function version($getFromComposer = true) { list($latest, $current) = $this->getExmentVersion($getFromComposer); @@ -210,6 +222,7 @@ public function version($getFromComposer = true) * * @return array $latest: new version in package, $current: this version in server */ + // @phpstan-ignore-next-line public function getExmentVersion($getFromComposer = true) { try { @@ -222,7 +235,9 @@ public function getExmentVersion($getFromComposer = true) $current = null; if (isset($version_json)) { $version = json_decode_ex($version_json, true); + // @phpstan-ignore-next-line $latest = array_get($version, 'latest'); + // @phpstan-ignore-next-line $current = array_get($version, 'current'); } @@ -240,6 +255,7 @@ public function getExmentVersion($getFromComposer = true) } // get exment info + // @phpstan-ignore-next-line $packages = array_get($json, 'packages'); $exment = collect($packages)->filter(function ($package) { return array_get($package, 'name') == Define::COMPOSER_PACKAGE_NAME; @@ -278,6 +294,7 @@ public function getExmentVersion($getFromComposer = true) if (!$json) { return [null, null]; } + // @phpstan-ignore-next-line $packages = array_get($json, 'package.versions'); if (!$packages) { return [null, null]; @@ -353,6 +370,7 @@ public function checkLatestVersion() // Helper logic ---------------------------------------------------- + // @phpstan-ignore-next-line public function getUrlTag(?string $url, ?string $label, $urlTagType, array $attributes = [], array $options = []) { $options = array_merge( @@ -407,6 +425,7 @@ public function getUrlTag(?string $url, ?string $label, $urlTagType, array $attr * @param array $options * @return array */ + // @phpstan-ignore-next-line public function get_password_rule($required = true, ?LoginUser $login_user = null, array $options = []) { $options = array_merge([ @@ -464,6 +483,7 @@ public function get_password_help() /** * get Data from excel sheet */ + // @phpstan-ignore-next-line public function getDataFromSheet($sheet, $keyvalue = false, $isGetMerge = false) { /** @var PhpSpreadSheet $format */ @@ -475,6 +495,7 @@ public function getDataFromSheet($sheet, $keyvalue = false, $isGetMerge = false) /** * get cell value */ + // @phpstan-ignore-next-line public function getCellValue($cell, $sheet, $isGetMerge = false) { /** @var PhpSpreadSheet $format */ @@ -490,6 +511,7 @@ public function getCellValue($cell, $sheet, $isGetMerge = false) * @param string $q search string * @return array */ + // @phpstan-ignore-next-line public function getQueryMarkAndValue($isLike, $q) { // if all search @@ -507,6 +529,7 @@ public function getQueryMarkAndValue($isLike, $q) /** * search document */ + // @phpstan-ignore-next-line public function getSearchDocumentQuery(CustomTable $target_custom_table, ?string $q, $query = null) { if (empty($query)) { @@ -552,6 +575,7 @@ public static function getSelectOptionHtml(?string $font_awesome, ?string $text) * @param $item * @return Collection */ + // @phpstan-ignore-next-line public function pushCollection(Collection $collect, $item): Collection { if ($item instanceof Collection) { @@ -607,6 +631,7 @@ public function getMoreTag(?string $uri = null, ?string $id_transkey = null): st /** * get true mark. If $val is true, output mark */ + // @phpstan-ignore-next-line public function getTrueMark($val) { if (!boolval($val)) { @@ -622,6 +647,7 @@ public function getTrueMark($val) * * @return array */ + // @phpstan-ignore-next-line public function getYesNoAllOption(): array { return [ @@ -631,16 +657,19 @@ public function getYesNoAllOption(): array ]; } + // @phpstan-ignore-next-line public function wrapValue($string) { return app('db')->getPdo()->quote($string); } + // @phpstan-ignore-next-line public function wrapColumn($string) { return \DB::getQueryGrammar()->wrap($string); } + // @phpstan-ignore-next-line public function wrapTable($string) { return \DB::getQueryGrammar()->wrapTable($string); @@ -651,6 +680,7 @@ public function wrapTable($string) * * @return string */ + // @phpstan-ignore-next-line public function formatAttributes($attributes) { $html = []; @@ -666,6 +696,7 @@ public function formatAttributes($attributes) /** * this url is ApiEndpoint */ + // @phpstan-ignore-next-line public function isApiEndpoint() { $basePath = ltrim(admin_base_path(), '/'); @@ -676,6 +707,7 @@ public function isApiEndpoint() /** * this url is Public form endpoint */ + // @phpstan-ignore-next-line public function isPublicFormEndpoint() { $route = public_form_base_path(); @@ -687,6 +719,7 @@ public function isPublicFormEndpoint() * get tmp folder path. Uses for * @param string $type "plugin", "template", "backup", "data". */ + // @phpstan-ignore-next-line public function getTmpFolderPath($type, $fullpath = true) { $path = path_join('tmp', $type, short_uuid()); @@ -732,6 +765,7 @@ public function replaceOsSeparator($path): string /** * Set time limit long */ + // @phpstan-ignore-next-line public function setTimeLimitLong($time = 6000) { $max_execution_time = ini_get('max_execution_time'); @@ -766,13 +800,14 @@ public function getUploadMaxFileSize() * @param $val * @return int */ + // @phpstan-ignore-next-line public function getFileMegaSizeValue($val) { $val = strtolower(strval($val)); $val = str_replace('m', '', $val); if (strpos($val, 'g') !== false) { - /** @phpstan-ignore-next-line Maybe error? */ + // @phpstan-ignore-next-line $val = str_replace('g', '', $val) * 1024; } return intval($val); @@ -798,6 +833,7 @@ public function makeDirectory(?string $path, int $mode = 0775) * @param string|null $path * @return void */ + // @phpstan-ignore-next-line public function makeDirectoryDisk($disk, ?string $path, int $mode = 0775) { if (!$disk) { @@ -816,6 +852,7 @@ public function makeDirectoryDisk($disk, ?string $path, int $mode = 0775) * @param string $directory * @return array */ + // @phpstan-ignore-next-line public function allDirectories($directory) { $directories = []; @@ -871,6 +908,7 @@ public function getComposerPath(): string * @param \Carbon\Carbon $carbon * @return array */ + // @phpstan-ignore-next-line public function carbonToArray(\Carbon\Carbon $carbon): array { return [ @@ -892,6 +930,7 @@ public function getCarbonOnlyDay($value): ?Carbon return null; } $carbon = Carbon::parse($value); + // @phpstan-ignore-next-line return Carbon::create($carbon->year, $carbon->month, $carbon->day); } @@ -903,6 +942,7 @@ public function getCarbonOnlyDay($value): ?Carbon * @param array|Collection $targetArr * @return boolean */ + // @phpstan-ignore-next-line public function isContains2Array($testArr, $targetArr): bool { foreach ($testArr as $arrKey => $arrValue) { @@ -994,6 +1034,7 @@ public function setFileRequestSession(ExmentFile $exmentfile, string $column_nam * @param array $options * @return string */ + // @phpstan-ignore-next-line public function getOptionKey($column_key, $append_table = true, $table_id = null, $options = []) { $options = array_merge( @@ -1051,6 +1092,7 @@ public function getOptionKey($column_key, $append_table = true, $table_id = null * * @return Collection */ + // @phpstan-ignore-next-line public static function uniqueCustomValues(...$collections): Collection { $result = collect(); @@ -1091,6 +1133,7 @@ public static function uniqueCustomValues(...$collections): Collection * * @return string prefixed path */ + // @phpstan-ignore-next-line public function getPathPrefix($adapeer, string $path): string { return $this->getPrefixer($adapeer)->prefixPath($path); @@ -1102,12 +1145,14 @@ public function getPathPrefix($adapeer, string $path): string * * @return PathPrefixer */ + // @phpstan-ignore-next-line protected function getPrefixer($adapter): PathPrefixer { $reflectionClass = new \ReflectionClass($adapter); try { $property = $reflectionClass->getProperty('prefixer'); } catch (\ReflectionException $ex) { + // @phpstan-ignore-next-line $property = $reflectionClass->getParentClass()->getProperty('prefixer'); } $property->setAccessible(true); diff --git a/src/ExmentServiceProvider.php b/src/ExmentServiceProvider.php index 53679eefb..09d3176ab 100644 --- a/src/ExmentServiceProvider.php +++ b/src/ExmentServiceProvider.php @@ -40,6 +40,7 @@ class ExmentServiceProvider extends ServiceProvider * * @var array */ + // @phpstan-ignore-next-line protected $policies = [ 'Exceedone\Exment\Model' => 'App\Policies\ModelPolicy', ]; @@ -49,6 +50,7 @@ class ExmentServiceProvider extends ServiceProvider * * @var array */ + // @phpstan-ignore-next-line protected $serviceProviders = [ ExmentProviders\RouteServiceProvider::class, ExmentProviders\Route2factorServiceProvider::class, @@ -61,6 +63,7 @@ class ExmentServiceProvider extends ServiceProvider /** * @var array commands */ + // @phpstan-ignore-next-line protected $commands = [ \Exceedone\Exment\Console\VersionCommand::class, \Exceedone\Exment\Console\InstallCommand::class, @@ -101,6 +104,7 @@ class ExmentServiceProvider extends ServiceProvider * * @var array */ + // @phpstan-ignore-next-line protected $middleware = [ \Exceedone\Exment\Middleware\TrustProxies::class, \Exceedone\Exment\Middleware\ExmentDebug::class, @@ -112,6 +116,7 @@ class ExmentServiceProvider extends ServiceProvider * * @var array */ + // @phpstan-ignore-next-line protected $routeMiddleware = [ 'admin.auth' => \Exceedone\Exment\Middleware\Authenticate::class, 'log.exec.time' => \Exceedone\Exment\Middleware\LogRouteExecutionTime::class, @@ -149,6 +154,7 @@ class ExmentServiceProvider extends ServiceProvider * * @var array */ + // @phpstan-ignore-next-line protected $middlewareGroups = [ // Exment web page default 'admin' => [ @@ -354,6 +360,7 @@ public function register() Passport::ignoreMigrations(); } + // @phpstan-ignore-next-line protected function publish() { $this->publishes([__DIR__.'/../config' => config_path()]); @@ -364,6 +371,7 @@ protected function publish() $this->publishes([__DIR__.'/../resources/lang_vendor' => resource_path('lang')], 'lang_vendor'); } + // @phpstan-ignore-next-line protected function load() { $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); @@ -383,6 +391,7 @@ protected function load() } } + // @phpstan-ignore-next-line protected function bootApp() { foreach ($this->serviceProviders as $serviceProvider) { @@ -397,6 +406,7 @@ protected function bootApp() if (config('admin.https') || config('admin.secure')) { \URL::forceScheme('https'); + // @phpstan-ignore-next-line $this->app['request']->server->set('HTTPS', true); } if (boolval(config('admin.use_app_url', false))) { @@ -404,6 +414,7 @@ protected function bootApp() } } + // @phpstan-ignore-next-line protected function bootSchedule() { if (!$this->app->runningInConsole()) { @@ -432,6 +443,7 @@ protected function bootSchedule() }); } + // @phpstan-ignore-next-line protected function bootPassport() { // adding rule for laravel-passport @@ -446,6 +458,7 @@ protected function bootPassport() } + // @phpstan-ignore-next-line protected function bootSetting() { Initialize::requireBootstrap(); @@ -518,6 +531,7 @@ public function registerPolicies() * * @return array */ + // @phpstan-ignore-next-line public function policies() { return $this->policies; @@ -529,6 +543,7 @@ public function policies() * * @return array */ + // @phpstan-ignore-next-line public function getMiddlewareGroups() { ////// register middleware group. @@ -572,13 +587,16 @@ public function getMiddlewareGroups() * @param array $config * @return \Illuminate\Auth\RequestGuard */ + // @phpstan-ignore-next-line protected function makeGuard(array $config) { return new RequestGuard(function ($request) use ($config) { return (new PublicFormGuard( Auth::createUserProvider($config['provider']), + // @phpstan-ignore-next-line $this->app['request'] ))->user(); + // @phpstan-ignore-next-line }, $this->app['request']); } } diff --git a/src/Form/EmbeddedForm.php b/src/Form/EmbeddedForm.php index 20a961626..918a3ce22 100644 --- a/src/Form/EmbeddedForm.php +++ b/src/Form/EmbeddedForm.php @@ -57,7 +57,7 @@ class EmbeddedForm extends EmbeddedFormBase * 'options' => [], // Set row no, column no, width * 'field' => AdminField, // Set adminfield * ] - * @var array + * @var array> */ protected $fieldAndOptions = []; @@ -65,7 +65,7 @@ class EmbeddedForm extends EmbeddedFormBase * Push field and set for grid * * @param Field $field - * @param array $options + * @param array $options * @return $this */ public function pushFieldAndOption(Field $field, array $options) @@ -83,7 +83,7 @@ public function pushFieldAndOption(Field $field, array $options) /** * Get field and options * - * @return array + * @return array> */ public function getFieldAndOptions() { @@ -97,6 +97,7 @@ public function getFieldAndOptions() * * @return mixed */ + // @phpstan-ignore-next-line public function prepare($input, bool $asConfirm = false) { if (is_null($input)) { diff --git a/src/Form/Field/AjaxButton.php b/src/Form/Field/AjaxButton.php index b0a372434..5750a6bf5 100644 --- a/src/Form/Field/AjaxButton.php +++ b/src/Form/Field/AjaxButton.php @@ -8,21 +8,31 @@ class AjaxButton extends Field { protected $view = 'exment::form.field.ajax-button'; + // @phpstan-ignore-next-line protected $url; + // @phpstan-ignore-next-line protected $button_label; + // @phpstan-ignore-next-line protected $button_class; + // @phpstan-ignore-next-line protected $beforesubmit_events; + // @phpstan-ignore-next-line protected $send_params; + // @phpstan-ignore-next-line protected $confirm; + // @phpstan-ignore-next-line protected $confirm_title; + // @phpstan-ignore-next-line protected $confirm_text; + // @phpstan-ignore-next-line protected $confirm_error; + // @phpstan-ignore-next-line public function url($url) { $this->url = $url; @@ -30,6 +40,7 @@ public function url($url) return $this; } + // @phpstan-ignore-next-line public function button_label($button_label) { $this->button_label = $button_label; @@ -37,6 +48,7 @@ public function button_label($button_label) return $this; } + // @phpstan-ignore-next-line public function button_class($button_class) { $this->button_class = $button_class; @@ -44,6 +56,7 @@ public function button_class($button_class) return $this; } + // @phpstan-ignore-next-line public function beforesubmit_events($beforesubmit_events) { $this->beforesubmit_events = $beforesubmit_events; @@ -51,6 +64,7 @@ public function beforesubmit_events($beforesubmit_events) return $this; } + // @phpstan-ignore-next-line public function send_params($params) { $this->send_params = $params; @@ -205,6 +219,7 @@ public function render() }); SCRIPT; + // @phpstan-ignore-next-line return parent::render()->with([ 'button_label' => $this->button_label, 'button_class' => $this->button_class, diff --git a/src/Form/Field/BcrPassword.php b/src/Form/Field/BcrPassword.php index 2f53f12ce..a21dd8738 100644 --- a/src/Form/Field/BcrPassword.php +++ b/src/Form/Field/BcrPassword.php @@ -28,6 +28,7 @@ public function prepare($value) * Format value by passing custom formater. * Always null. */ + // @phpstan-ignore-next-line protected function formatValue() { $this->value = null; diff --git a/src/Form/Field/ChangeField.php b/src/Form/Field/ChangeField.php index 4d3ddc7e6..9ced2acc5 100644 --- a/src/Form/Field/ChangeField.php +++ b/src/Form/Field/ChangeField.php @@ -75,8 +75,10 @@ class ChangeField extends Field */ protected $allowNull = false; + // @phpstan-ignore-next-line protected static $scripts = []; + // @phpstan-ignore-next-line protected function getElementClass() { if (preg_match('/(^[^\[\]]+)\[([^\[\]]+)\]\[([^\[\]]+)\]$/', $this->elementName, $array_result)) { @@ -87,6 +89,7 @@ protected function getElementClass() return []; } + // @phpstan-ignore-next-line public function filterKind($filterKind = null) { if (isset($filterKind)) { @@ -96,6 +99,7 @@ public function filterKind($filterKind = null) return $this; } + // @phpstan-ignore-next-line public function ajax($ajax) { $this->ajax = $ajax; @@ -103,6 +107,7 @@ public function ajax($ajax) return $this; } + // @phpstan-ignore-next-line public function allowNull($allowNull = true) { $this->allowNull = $allowNull; @@ -164,6 +169,7 @@ public function hasManyTableClass($hasManyTableClass) /** */ + // @phpstan-ignore-next-line public function replaceSearch($replaceSearch) { $this->replaceSearch = $replaceSearch; @@ -173,6 +179,7 @@ public function replaceSearch($replaceSearch) /** */ + // @phpstan-ignore-next-line public function replaceWord($replaceWord) { $this->replaceWord = $replaceWord; @@ -180,6 +187,7 @@ public function replaceWord($replaceWord) return $this; } + // @phpstan-ignore-next-line protected function script() { $ajax = $this->ajax; @@ -239,12 +247,14 @@ public function render() } } + // @phpstan-ignore-next-line public function adminField($adminField): self { $this->adminField = $adminField; return $this; } + // @phpstan-ignore-next-line public function prepareRecord($value, $record) { if (isset($this->adminField)) { diff --git a/src/Form/Field/CheckboxTable.php b/src/Form/Field/CheckboxTable.php index 35ec34d96..650bdda86 100644 --- a/src/Form/Field/CheckboxTable.php +++ b/src/Form/Field/CheckboxTable.php @@ -8,12 +8,18 @@ class CheckboxTable extends Checkbox { protected $view = 'exment::form.field.checkboxtable'; + // @phpstan-ignore-next-line protected $checkWidth = 100; + // @phpstan-ignore-next-line protected $scrollx = false; + // @phpstan-ignore-next-line protected $items = []; + // @phpstan-ignore-next-line protected $headerHelps = []; + // @phpstan-ignore-next-line protected $headerEsacape = true; + // @phpstan-ignore-next-line public function checkWidth($checkWidth) { $this->checkWidth = $checkWidth; @@ -21,6 +27,7 @@ public function checkWidth($checkWidth) return $this; } + // @phpstan-ignore-next-line public function scrollx($scrollx) { $this->scrollx = $scrollx; @@ -40,6 +47,7 @@ public function scrollx($scrollx) * @param array $items * @return $this */ + // @phpstan-ignore-next-line public function items($items) { $this->items = $items; @@ -48,6 +56,7 @@ public function items($items) } + // @phpstan-ignore-next-line public function headerEsacape(bool $escape) { $this->headerEsacape = $escape; @@ -59,6 +68,7 @@ public function headerEsacape(bool $escape) * * @return array */ + // @phpstan-ignore-next-line protected function getItems() { $result = []; @@ -108,6 +118,7 @@ public function headerHelp($headerHelps) public function render() { // get items error message + // @phpstan-ignore-next-line return parent::render()->with([ 'checkWidth' => $this->checkWidth, 'scrollx' => $this->scrollx, diff --git a/src/Form/Field/Checkboxone.php b/src/Form/Field/Checkboxone.php index e1f7f818f..ebfa260f6 100644 --- a/src/Form/Field/Checkboxone.php +++ b/src/Form/Field/Checkboxone.php @@ -9,16 +9,21 @@ class Checkboxone extends Field { protected $view = 'exment::form.field.checkboxone'; + // @phpstan-ignore-next-line protected static $css = [ '/vendor/laravel-admin/AdminLTE/plugins/iCheck/all.css', ]; + // @phpstan-ignore-next-line protected static $js = [ '/vendor/laravel-admin/AdminLTE/plugins/iCheck/icheck.min.js', ]; + // @phpstan-ignore-next-line protected $check_label = ''; + // @phpstan-ignore-next-line protected $check_value = ''; + // @phpstan-ignore-next-line protected $options = []; @@ -29,6 +34,7 @@ class Checkboxone extends Field * @param $column * @param array $arguments */ + // @phpstan-ignore-next-line public function __construct($column = '', $arguments = []) { parent::__construct($column, $arguments); @@ -43,12 +49,16 @@ public function __construct($column = '', $arguments = []) * * @return $this|mixed */ + // @phpstan-ignore-next-line public function option($option = []) { + // @phpstan-ignore-next-line $this->options = $option; + // @phpstan-ignore-next-line if (count($option) == 0) { return $this; } + // @phpstan-ignore-next-line foreach ($option as $k => $v) { $this->check_value = $k; $this->check_label = $v; @@ -57,6 +67,7 @@ public function option($option = []) return $this; } + // @phpstan-ignore-next-line public function getOptions() { return $this->options; @@ -69,6 +80,7 @@ public function render() { $this->script = "$('{$this->getElementClassSelector()}').iCheck({checkboxClass:'icheckbox_minimal-blue'});"; + // @phpstan-ignore-next-line return parent::render()->with(['check_value' => $this->check_value, 'check_label' => $this->check_label]); } } diff --git a/src/Form/Field/CodeEditor.php b/src/Form/Field/CodeEditor.php index ccac8bdab..d0a227475 100644 --- a/src/Form/Field/CodeEditor.php +++ b/src/Form/Field/CodeEditor.php @@ -8,15 +8,19 @@ class CodeEditor extends Textarea { protected $view = 'admin::form.textarea'; + // @phpstan-ignore-next-line protected $mode = 'txt'; + // @phpstan-ignore-next-line protected $height; + // @phpstan-ignore-next-line public function mode($mode) { $this->mode = $mode; return $this; } + // @phpstan-ignore-next-line public function height(int $height) { $this->height = $height; diff --git a/src/Form/Field/Description.php b/src/Form/Field/Description.php index 047f29033..15681cb9e 100644 --- a/src/Form/Field/Description.php +++ b/src/Form/Field/Description.php @@ -15,6 +15,7 @@ class Description extends Field\Display */ protected $escape = true; + // @phpstan-ignore-next-line public function __construct($label) { $this->label = $label; @@ -39,6 +40,7 @@ public function render() $offset = array_get($this->getViewElementClasses(), 'label'); $offset = str_replace("col-sm-", "col-sm-offset-", $offset); $offset = str_replace("col-md-", "col-md-offset-", $offset); + // @phpstan-ignore-next-line return parent::render()->with( [ 'offset' => $offset, diff --git a/src/Form/Field/Embeds.php b/src/Form/Field/Embeds.php index ded929fe1..830ca22c0 100644 --- a/src/Form/Field/Embeds.php +++ b/src/Form/Field/Embeds.php @@ -11,8 +11,10 @@ class Embeds extends AdminField\Embeds protected $view = 'exment::form.field.embeds'; + // @phpstan-ignore-next-line protected $enableHeader = true; + // @phpstan-ignore-next-line protected $footer_hr = false; /** @@ -22,6 +24,7 @@ class Embeds extends AdminField\Embeds */ protected $gridEmbeds = false; + // @phpstan-ignore-next-line public function disableHeader() { $this->enableHeader = false; @@ -29,6 +32,7 @@ public function disableHeader() return $this; } + // @phpstan-ignore-next-line public function footerHr($footer_hr = true) { $this->footer_hr = $footer_hr; @@ -50,6 +54,7 @@ public function gridEmbeds() /** * get fields in NestedEmbeddedForm */ + // @phpstan-ignore-next-line public function fields() { return $this->buildEmbeddedForm()->fields(); @@ -62,6 +67,7 @@ public function fields() */ protected function buildEmbeddedForm() { + // @phpstan-ignore-next-line $form = new EmbeddedForm($this->column); return $this->setFormField($form); } diff --git a/src/Form/Field/EncPassword.php b/src/Form/Field/EncPassword.php index 61478ea78..395dc0fae 100644 --- a/src/Form/Field/EncPassword.php +++ b/src/Form/Field/EncPassword.php @@ -10,6 +10,7 @@ class EncPassword extends Password /** * @bool update if empty flag */ + // @phpstan-ignore-next-line protected $updateIfEmpty = false; /** @@ -33,6 +34,7 @@ public function prepare($value) * Format value by passing custom formater. * Always null. */ + // @phpstan-ignore-next-line protected function formatValue() { $this->value = trydecrypt($this->value); @@ -41,6 +43,7 @@ protected function formatValue() /** * set flag update if empty. */ + // @phpstan-ignore-next-line public function updateIfEmpty(bool $updateIfEmpty = true) { $this->updateIfEmpty = $updateIfEmpty; diff --git a/src/Form/Field/Favicon.php b/src/Form/Field/Favicon.php index 905ac0e2a..5ed3dcb34 100644 --- a/src/Form/Field/Favicon.php +++ b/src/Form/Field/Favicon.php @@ -8,16 +8,18 @@ class Favicon extends \Encore\Admin\Form\Field\Image * Validation rules. * * @var array - * @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line protected $rules = []; /** * @return array|string */ + // @phpstan-ignore-next-line protected function getRules() { /** @var array $rules */ + // @phpstan-ignore-next-line $rules = parent::getRules(); $rules[] = new \Exceedone\Exment\Validator\FaviconRule(); return $rules; diff --git a/src/Form/Field/FieldGroupTrait.php b/src/Form/Field/FieldGroupTrait.php index e86badde0..b90097b80 100644 --- a/src/Form/Field/FieldGroupTrait.php +++ b/src/Form/Field/FieldGroupTrait.php @@ -60,6 +60,7 @@ trait FieldGroupTrait * @param array $fieldOptions * @return \Illuminate\Support\Collection */ + // @phpstan-ignore-next-line protected function convertRowColumnGroups(array $fieldOptions) { $fieldGroups = collect($fieldOptions)->sortBy(function ($fieldOption, $index) { @@ -122,9 +123,11 @@ protected function convertRowColumnGroups(array $fieldOptions) // Set col_md width using total width. ---------------------------------------------------- /** @var Collection $fieldGroups */ + // @phpstan-ignore-next-line $fieldGroups = $fieldGroups->map(function ($fieldGroups) use ($totalWidth) { $columnCount = count($fieldGroups['columns']); /** @var Collection $fieldGroups */ + // @phpstan-ignore-next-line $fieldGroups['columns'] = collect($fieldGroups['columns'])->map(function ($fieldOption) use ($columnCount, $totalWidth) { // if $totalWidth is 1 and vertical then col_md is 8 and offset is 2. $fieldOption['col_md'] = ($fieldOption['width'] * 3 * (4 / $totalWidth)); diff --git a/src/Form/Field/HasMany.php b/src/Form/Field/HasMany.php index b1ce770eb..f5a850be8 100644 --- a/src/Form/Field/HasMany.php +++ b/src/Form/Field/HasMany.php @@ -31,6 +31,7 @@ public function render() // specify a view to render. $this->view = $this->views[$this->viewMode]; + // @phpstan-ignore-next-line $form = $this->buildNestedForm($this->column, $this->builder); list($template, $script) = $this->getTemplateHtmlAndScript($form); @@ -50,6 +51,7 @@ public function render() * TODO: I don't know the best way * set html and script. It has bug about nested */ + // @phpstan-ignore-next-line protected function getTemplateHtmlAndScript($form) { list($template, $script) = $form->getTemplateHtmlAndScript(); @@ -134,6 +136,7 @@ protected function setupScriptForDefaultView($templateScript) public function getScript() { + // @phpstan-ignore-next-line list($template, $script) = $this->buildNestedForm($this->column, $this->builder) ->getTemplateHtmlAndScript(); @@ -147,8 +150,10 @@ public function getScript() * * @return bool|\Illuminate\Contracts\Validation\Validator */ + // @phpstan-ignore-next-line public function getValidator(array $input) { + // @phpstan-ignore-next-line if (!array_key_exists($this->column, $input)) { return false; } @@ -178,6 +183,7 @@ public function getValidator(array $input) $column = $field->column(); // if NestedEmbeds, loop hasmany items if ($field instanceof NestedEmbeds) { + // @phpstan-ignore-next-line $nestedValues = Arr::get($input, $this->column); if (!is_array($nestedValues)) { continue; @@ -186,6 +192,7 @@ public function getValidator(array $input) if (!$fieldRules = $field->getRules()) { continue; } + // @phpstan-ignore-next-line foreach ($fieldRules as $key => $fieldRule) { $r = Arr::has($rules, "$column.$key") ? $rules["$column.$key"]['rules'] : []; $r[$nestedKey] = $fieldRule; @@ -266,7 +273,7 @@ protected function getHasManyCount() } if (!empty($v = $this->getOld())) { - /** @phpstan-ignore-next-line Parameter #1 $value of function count expects array|Countable, string given. need to fix laravel-admin */ + // @phpstan-ignore-next-line return count($v); } @@ -274,6 +281,7 @@ protected function getHasManyCount() } + // @phpstan-ignore-next-line protected function getParentRenderClass() { return get_parent_class(get_parent_class($this)); diff --git a/src/Form/Field/HasManyJson.php b/src/Form/Field/HasManyJson.php index 923766bda..5a1b2f8ce 100644 --- a/src/Form/Field/HasManyJson.php +++ b/src/Form/Field/HasManyJson.php @@ -25,6 +25,7 @@ protected function getKeyName() } + // @phpstan-ignore-next-line public function prepare($input) { return $this->prepareTrait($input); @@ -37,17 +38,20 @@ public function prepare($input) * * @return array */ + // @phpstan-ignore-next-line protected function buildRelatedForms() { return $this->buildRelatedFormsTrait(); } + // @phpstan-ignore-next-line protected function buildNestedForm($column, \Closure $builder, $key = null, $index = null) { return $this->buildNestedFormTrait($column, $builder, $key, $index); } + // @phpstan-ignore-next-line protected function getParentRenderClass() { return get_parent_class(get_parent_class(get_parent_class($this))); diff --git a/src/Form/Field/HasManyJsonTable.php b/src/Form/Field/HasManyJsonTable.php index 7d5065fef..d6aa80891 100644 --- a/src/Form/Field/HasManyJsonTable.php +++ b/src/Form/Field/HasManyJsonTable.php @@ -37,17 +37,20 @@ public function prepare($input) * * @return array */ + // @phpstan-ignore-next-line protected function buildRelatedForms() { return $this->buildRelatedFormsTrait(); } + // @phpstan-ignore-next-line protected function buildNestedForm($column, \Closure $builder, $key = null, $index = null) { return $this->buildNestedFormTrait($column, $builder, $key, $index); } + // @phpstan-ignore-next-line protected function getParentRenderClass() { return get_parent_class(get_parent_class(get_parent_class(get_parent_class($this)))); diff --git a/src/Form/Field/HasManyJsonTrait.php b/src/Form/Field/HasManyJsonTrait.php index 2cef0d466..89f6c7623 100644 --- a/src/Form/Field/HasManyJsonTrait.php +++ b/src/Form/Field/HasManyJsonTrait.php @@ -21,6 +21,7 @@ protected function getKeyName() } + // @phpstan-ignore-next-line public function prepare($input) { $input = parent::prepare($input); @@ -32,9 +33,11 @@ public function prepare($input) return $item; })->filter(function ($item) { + /** @phpstan-ignore-next-line */ return !is_nullorempty($item); })->values(); + /** @phpstan-ignore-next-line */ if (is_nullorempty($values)) { return null; } @@ -49,6 +52,7 @@ public function prepare($input) * * @return array */ + // @phpstan-ignore-next-line protected function buildRelatedForms() { $forms = []; @@ -56,6 +60,7 @@ protected function buildRelatedForms() /** @phpstan-ignore-next-line Call to function is_null() with array will always evaluate to false. */ if (!is_null($this->relatedValue)) { foreach ($this->relatedValue as $index => $data) { + // @phpstan-ignore-next-line $forms[$index] = $this->buildNestedForm($this->column, $this->builder, null, $index) ->fill($data, $index); } @@ -68,11 +73,12 @@ protected function buildRelatedForms() $model = $this->form->model(); - /** @phpstan-ignore-next-line Call to function is_null() with array will always evaluate to false. */ + // @phpstan-ignore-next-line if (is_null($this->value)) { $this->value = []; - /** @phpstan-ignore-next-line Left side of && is always false. */ + /** @phpstan-ignore-next-line */ } elseif (is_string($this->value) && is_json($this->value)) { + /** @phpstan-ignore-next-line */ $this->value = json_decode_ex($this->value, true); } @@ -83,6 +89,7 @@ protected function buildRelatedForms() * * Else get data from database. */ + // @phpstan-ignore-next-line if ($values = old($this->column)) { $index = 0; foreach ($values as $key => $data) { @@ -95,6 +102,7 @@ protected function buildRelatedForms() $forms = []; } + // @phpstan-ignore-next-line $forms[$key] = $this->buildNestedForm($this->column, $this->builder, $key, $index) ->fill($data, $index); $index++; @@ -102,6 +110,7 @@ protected function buildRelatedForms() } else { foreach ($this->value as $index => $data) { if (is_int($index)) { + /** @phpstan-ignore-next-line */ $key = make_uuid(); } else { $key = $index; @@ -119,6 +128,7 @@ protected function buildRelatedForms() // $forms[$key] = $this->buildNestedForm($this->column, $this->builder, $data, $index) // ->fill($data, $index); + // @phpstan-ignore-next-line $forms[] = $this->buildNestedForm($this->column, $this->builder, $key, $index) ->fill($data, $index); } @@ -128,6 +138,7 @@ protected function buildRelatedForms() } + // @phpstan-ignore-next-line protected function buildNestedForm($column, \Closure $builder, $key = null, $index = null) { $form = new NestedForm($column); diff --git a/src/Form/Field/HasManyTable.php b/src/Form/Field/HasManyTable.php index 07f7fc33a..51dd3e8e4 100644 --- a/src/Form/Field/HasManyTable.php +++ b/src/Form/Field/HasManyTable.php @@ -14,8 +14,11 @@ */ class HasManyTable extends HasMany { + // @phpstan-ignore-next-line protected $tablecolumnwidths = []; + // @phpstan-ignore-next-line protected $count = null; + // @phpstan-ignore-next-line protected $enableHeader = true; /** @@ -45,6 +48,7 @@ class HasManyTable extends HasMany * * @var array */ + // @phpstan-ignore-next-line protected $options = [ 'allowCreate' => true, 'allowDelete' => true, @@ -56,6 +60,7 @@ class HasManyTable extends HasMany * * @var array */ + // @phpstan-ignore-next-line protected $tablewidth = [ 'offset' => 1, 'width' => 10, @@ -64,16 +69,19 @@ class HasManyTable extends HasMany /** * display description */ + // @phpstan-ignore-next-line protected $description; /** * whether escape description */ + // @phpstan-ignore-next-line protected $escapeDescription = true; /** * set bootstrap table width */ + // @phpstan-ignore-next-line public function setTableWidth($width = 8, $offset = 2) { $this->tablewidth['width'] = $width; @@ -85,18 +93,21 @@ public function setTableWidth($width = 8, $offset = 2) /** * set bootstrap table Column width */ + // @phpstan-ignore-next-line public function setTableColumnWidth(...$width) { $this->tablecolumnwidths = $width; return $this; } + // @phpstan-ignore-next-line public function description($description) { $this->description = $description; return $this; } + // @phpstan-ignore-next-line public function descriptionHtml($description) { $this->escapeDescription = false; @@ -118,6 +129,7 @@ public function rowUpDown($rowUpDown, $power = 1) return $this; } + // @phpstan-ignore-next-line public function disableHeader() { $this->enableHeader = false; @@ -142,6 +154,7 @@ public function disableOptions() * * @var array */ + // @phpstan-ignore-next-line protected $views = [ 'default' => 'exment::form.field.hasmanytable', 'tab' => 'admin::form.hasmanytable', // TODO:for tab @@ -150,6 +163,7 @@ public function disableOptions() /** * set table header and body from fields */ + // @phpstan-ignore-next-line protected function getTableItem(&$form) { $tableitems = []; @@ -175,6 +189,7 @@ protected function getTableItem(&$form) /** * set table field item to header, body, hidden */ + // @phpstan-ignore-next-line protected function setTableFieldItem(&$field, &$tableitems, &$hiddens, &$requires, &$helps) { // if internal, skip field @@ -361,6 +376,7 @@ public function render() $this->view = $this->views[$this->viewMode]; // set header and body info + // @phpstan-ignore-next-line $form = $this->buildNestedForm($this->column, $this->builder); list($template, $script) = $this->getTemplateHtmlAndScript($form); @@ -404,6 +420,7 @@ public function render() } + // @phpstan-ignore-next-line protected function getParentRenderClass() { return get_parent_class(get_parent_class(get_parent_class($this))); diff --git a/src/Form/Field/Header.php b/src/Form/Field/Header.php index ee303148f..fb561ec80 100644 --- a/src/Form/Field/Header.php +++ b/src/Form/Field/Header.php @@ -8,8 +8,10 @@ class Header extends Field\Display { protected $view = 'exment::form.field.header'; + // @phpstan-ignore-next-line protected $no; + // @phpstan-ignore-next-line protected $hr; /** @@ -19,6 +21,7 @@ class Header extends Field\Display */ protected $escape = true; + // @phpstan-ignore-next-line public function __construct($label) { $this->no = 4; @@ -41,6 +44,7 @@ public function hr() * * @return $this|mixed */ + // @phpstan-ignore-next-line public function no($no) { $this->no = $no; @@ -62,6 +66,7 @@ public function escape(bool $escape = true) public function render() { + // @phpstan-ignore-next-line return parent::render()->with([ 'no' => $this->no, 'hr' => $this->hr, diff --git a/src/Form/Field/Image.php b/src/Form/Field/Image.php index f3c216b0a..75d5e4e90 100644 --- a/src/Form/Field/Image.php +++ b/src/Form/Field/Image.php @@ -6,16 +6,18 @@ class Image extends \Encore\Admin\Form\Field\Image { /** * Validation rules. - * @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line protected $rules = []; /** * @return array|string */ + // @phpstan-ignore-next-line protected function getRules() { /** @var array $rules */ + // @phpstan-ignore-next-line $rules = parent::getRules(); $rules[] = new \Exceedone\Exment\Validator\ImageRule(); return $rules; diff --git a/src/Form/Field/InitOnly.php b/src/Form/Field/InitOnly.php index 048188183..da3a40474 100644 --- a/src/Form/Field/InitOnly.php +++ b/src/Form/Field/InitOnly.php @@ -12,14 +12,17 @@ class InitOnly extends Display { protected $view = 'exment::form.field.init_only'; + // @phpstan-ignore-next-line protected $prepareDefault = false; + // @phpstan-ignore-next-line public function prepareDefault() { $this->prepareDefault = true; return $this; } + // @phpstan-ignore-next-line public function prepare($value) { // Even if set value, return always default. @@ -31,6 +34,7 @@ public function prepare($value) */ public function render() { + // @phpstan-ignore-next-line return parent::render()->with([ 'prepareDefault' => $this->prepareDefault, 'default' => $this->default, diff --git a/src/Form/Field/Internal.php b/src/Form/Field/Internal.php index 8b74ecc76..6ea560829 100644 --- a/src/Form/Field/Internal.php +++ b/src/Form/Field/Internal.php @@ -18,6 +18,7 @@ class Internal extends Field * * @return mixed */ + // @phpstan-ignore-next-line public function prepare($value) { return $this->getDefault() ?? $this->original(); diff --git a/src/Form/Field/Link.php b/src/Form/Field/Link.php index bd329f62b..1fbbd8469 100644 --- a/src/Form/Field/Link.php +++ b/src/Form/Field/Link.php @@ -8,14 +8,19 @@ class Link extends Field { protected $view = 'exment::form.field.link'; + // @phpstan-ignore-next-line protected $icon = ''; + // @phpstan-ignore-next-line protected $button = ''; + // @phpstan-ignore-next-line protected $text = ''; + // @phpstan-ignore-next-line protected $target = ''; + // @phpstan-ignore-next-line protected $emptyText = ''; /** @@ -23,6 +28,7 @@ class Link extends Field * * @return $this|mixed */ + // @phpstan-ignore-next-line public function target($target) { $this->target = $target; @@ -34,6 +40,7 @@ public function target($target) * * @return $this|mixed */ + // @phpstan-ignore-next-line public function icon($icon) { $this->icon = $icon; @@ -45,6 +52,7 @@ public function icon($icon) * * @return $this|mixed */ + // @phpstan-ignore-next-line public function button($buttonClass = 'btn-default') { $this->button = $buttonClass; @@ -56,6 +64,7 @@ public function button($buttonClass = 'btn-default') * * @return $this|mixed */ + // @phpstan-ignore-next-line public function text($text) { $this->text = $text; @@ -67,6 +76,7 @@ public function text($text) * * @return $this|mixed */ + // @phpstan-ignore-next-line public function emptyText($text) { $this->emptyText = $text; @@ -75,6 +85,7 @@ public function emptyText($text) public function render() { + // @phpstan-ignore-next-line return parent::render()->with([ 'button' => $this->button, 'icon' => $this->icon, diff --git a/src/Form/Field/MultipleImage.php b/src/Form/Field/MultipleImage.php index 59f22429b..0bf4d0f7b 100644 --- a/src/Form/Field/MultipleImage.php +++ b/src/Form/Field/MultipleImage.php @@ -6,8 +6,8 @@ class MultipleImage extends \Encore\Admin\Form\Field\MultipleImage { /** * Validation rules. - * @phpstan-ignore-next-line Need to fix laravel-admin */ + // @phpstan-ignore-next-line protected $rules = []; /** @@ -24,7 +24,7 @@ public function render() protected function getRules() { $rules = parent::getRules(); - /** @phpstan-ignore-next-line Cannot assign new offset to string. */ + // @phpstan-ignore-next-line $rules[] = new \Exceedone\Exment\Validator\ImageRule(); return $rules; } diff --git a/src/Form/Field/NestedEmbeds.php b/src/Form/Field/NestedEmbeds.php index d8d126738..cd49a6e97 100644 --- a/src/Form/Field/NestedEmbeds.php +++ b/src/Form/Field/NestedEmbeds.php @@ -9,10 +9,13 @@ class NestedEmbeds extends Embeds { protected $view = 'exment::form.field.embeds'; + // @phpstan-ignore-next-line protected $nestedForm; + // @phpstan-ignore-next-line protected $relationName; + // @phpstan-ignore-next-line protected $data_key; /** @@ -21,6 +24,7 @@ class NestedEmbeds extends Embeds * @param string $column * @param array $arguments */ + // @phpstan-ignore-next-line public function __construct($column, $arguments = []) { $this->data_key = Arr::get($arguments, 0, ''); @@ -41,6 +45,7 @@ protected function buildEmbeddedForm() return $this->nestedForm; } + // @phpstan-ignore-next-line public function setRelationName($relationName) { $this->relationName = $relationName; @@ -51,6 +56,7 @@ public function setRelationName($relationName) /** * @return array|string */ + // @phpstan-ignore-next-line protected function getRules() { $rules = []; @@ -66,13 +72,13 @@ protected function getRules() /** * @return array - * @phpstan-ignore-next-line Return type (array) of method Exceedone\Exment\Form\Field\NestedEmbeds::getAttributes() should be compatible with return type (string) of method Encore\Admin\Form\Field::getAttributes() - * it needs to fix laravel-admin */ + // @phpstan-ignore-next-line public function getAttributes() { $attributes = []; foreach ($this->buildEmbeddedForm()->fields() as $field) { + // @phpstan-ignore-next-line $attributes[$this->column . '.'. $field->column] = $field->label(); } return $attributes; @@ -88,6 +94,7 @@ public function getAttributes() * * @return array */ + // @phpstan-ignore-next-line protected function getEmbeddedData() { $keyName = "{$this->relationName}.{$this->column}"; @@ -100,6 +107,7 @@ protected function getEmbeddedData() } if (is_string($this->value)) { + // @phpstan-ignore-next-line return json_decode_ex($this->value, true); } @@ -117,9 +125,11 @@ public function render() $render = parent::render(); $script = $this->buildEmbeddedForm()->getScripts(); if (!is_nullorempty($script)) { + // @phpstan-ignore-next-line $this->script = $script; } + // @phpstan-ignore-next-line return $render; } } diff --git a/src/Form/Field/Number.php b/src/Form/Field/Number.php index 872ccf7be..fb2db8b5b 100644 --- a/src/Form/Field/Number.php +++ b/src/Form/Field/Number.php @@ -6,22 +6,28 @@ class Number extends \Encore\Admin\Form\Field\Number { //protected $rules = []; + // @phpstan-ignore-next-line protected $disableUpdown = false; + // @phpstan-ignore-next-line protected $defaultEmpty = false; + // @phpstan-ignore-next-line protected $fieldWidth = 100; + // @phpstan-ignore-next-line public function disableUpdown() { $this->disableUpdown = true; return $this; } + // @phpstan-ignore-next-line public function defaultEmpty() { $this->defaultEmpty = true; return $this; } + // @phpstan-ignore-next-line public function setFieldWidth($fieldWidth) { $this->fieldWidth = $fieldWidth; diff --git a/src/Form/Field/NumberRange.php b/src/Form/Field/NumberRange.php index a148b75a3..f223cfeba 100644 --- a/src/Form/Field/NumberRange.php +++ b/src/Form/Field/NumberRange.php @@ -13,6 +13,7 @@ class NumberRange extends Field // 'end' => ['nullable', 'numeric'], // ]; + // @phpstan-ignore-next-line protected $rules = ['nullable', 'numeric']; /** @@ -20,8 +21,10 @@ class NumberRange extends Field * * @var array */ + // @phpstan-ignore-next-line protected $column = []; + // @phpstan-ignore-next-line public function __construct($column, $arguments) { $this->column['start'] = $column; @@ -54,6 +57,7 @@ public function value($value = null) /** * {@inheritdoc} */ + // @phpstan-ignore-next-line public function prepare($value) { if ($value === '') { diff --git a/src/Form/Field/Password.php b/src/Form/Field/Password.php index 5ddb1cc5d..cd006cd25 100644 --- a/src/Form/Field/Password.php +++ b/src/Form/Field/Password.php @@ -4,11 +4,13 @@ class Password extends \Encore\Admin\Form\Field\Password { + // @phpstan-ignore-next-line protected $showToggleIcon = false; /** * set toggle icon password display */ + // @phpstan-ignore-next-line public function toggleShowEvent() { $this->showToggleIcon = true; diff --git a/src/Form/Field/PivotMultiSelect.php b/src/Form/Field/PivotMultiSelect.php index e2d101a37..17da003f8 100644 --- a/src/Form/Field/PivotMultiSelect.php +++ b/src/Form/Field/PivotMultiSelect.php @@ -12,8 +12,10 @@ class PivotMultiSelect extends MultipleSelect /** * @var array */ + // @phpstan-ignore-next-line protected $pivot; + // @phpstan-ignore-next-line public function __construct($column, $arguments = array()) { parent::__construct($column, $arguments); @@ -27,6 +29,7 @@ public function __construct($column, $arguments = array()) * * @return mixed */ + // @phpstan-ignore-next-line public function pivot($pivot) { $this->pivot = $pivot; diff --git a/src/Form/Field/ProgressTracker.php b/src/Form/Field/ProgressTracker.php index babced1aa..a7561056e 100644 --- a/src/Form/Field/ProgressTracker.php +++ b/src/Form/Field/ProgressTracker.php @@ -11,12 +11,15 @@ class ProgressTracker extends Field\Display { protected $view = 'exment::form.field.progresstracker'; + // @phpstan-ignore-next-line protected static $css = [ '/vendor/exment/css/progresstracker.css', ]; + // @phpstan-ignore-next-line protected $steps = null; + // @phpstan-ignore-next-line public function __construct($label) { $this->label = $label; @@ -30,12 +33,14 @@ public function __construct($label) * * @return $this|mixed */ + // @phpstan-ignore-next-line public function options($options = []) { if ($options instanceof \Illuminate\Contracts\Support\Arrayable) { $options = $options->toArray(); } + // @phpstan-ignore-next-line foreach ($options as $index => $option) { $class = ''; if (isset($option['active']) && $option['active']) { @@ -55,6 +60,7 @@ public function options($options = []) } public function render() { + // @phpstan-ignore-next-line return parent::render()->with([ 'steps' => $this->options, ]); diff --git a/src/Form/Field/RadioButton.php b/src/Form/Field/RadioButton.php index 0bd10ebbc..b13b678e0 100644 --- a/src/Form/Field/RadioButton.php +++ b/src/Form/Field/RadioButton.php @@ -8,6 +8,7 @@ class RadioButton extends Radio { protected $view = 'exment::form.field.radiobutton'; + // @phpstan-ignore-next-line protected $addEmpty = false; /** diff --git a/src/Form/Field/ReCaptcha.php b/src/Form/Field/ReCaptcha.php index 398029047..76fd64106 100644 --- a/src/Form/Field/ReCaptcha.php +++ b/src/Form/Field/ReCaptcha.php @@ -16,15 +16,14 @@ class ReCaptcha extends Hidden /** * @var string - * @phpstan-ignore-next-line Property Exceedone\Exment\Form\Field\ReCaptcha::$rules (array|Closure) does not accept default value of type 'required'. - * it need to fix laravel-admin */ + // @phpstan-ignore-next-line protected $rules = 'required'; /** * @param $arguments - * @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line public function __construct($arguments = []) { // if (!\Exment::isAvailableGoogleRecaptcha()) { @@ -49,6 +48,7 @@ protected function getRules() public function setForm($form = null) { + // @phpstan-ignore-next-line $this->form = $form; $this->form->ignore($this->column); diff --git a/src/Form/Field/SwitchBoolField.php b/src/Form/Field/SwitchBoolField.php index 6a91a315d..40e01a326 100644 --- a/src/Form/Field/SwitchBoolField.php +++ b/src/Form/Field/SwitchBoolField.php @@ -6,6 +6,7 @@ class SwitchBoolField extends SwitchField { protected $view = 'exment::form.field.switchfield'; + // @phpstan-ignore-next-line protected $states = [ 'on' => ['value' => '1', 'text' => 'YES', 'color' => 'primary'], 'off' => ['value' => '0', 'text' => 'NO', 'color' => 'default'], @@ -21,6 +22,7 @@ public function render() return parent::render(); } + // @phpstan-ignore-next-line protected function getParentClassname() { return get_parent_class(get_parent_class(get_parent_class($this))); diff --git a/src/Form/Field/SwitchField.php b/src/Form/Field/SwitchField.php index 5ae9c2434..dbb524617 100644 --- a/src/Form/Field/SwitchField.php +++ b/src/Form/Field/SwitchField.php @@ -8,6 +8,7 @@ class SwitchField extends AdminSwitchField { protected $view = 'exment::form.field.switchfield'; + // @phpstan-ignore-next-line protected $states = [ 'on' => ['value' => '1', 'text' => 'YES', 'color' => 'primary'], 'off' => ['value' => '0', 'text' => 'NO', 'color' => 'default'], @@ -15,7 +16,7 @@ class SwitchField extends AdminSwitchField public function render() { - /** @phpstan-ignore-next-line Call to function is_null() with string will always evaluate to false. it needs to fix laravel-admin */ + // @phpstan-ignore-next-line if (is_null($this->value()) && is_null($this->getOld())) { $this->value = $this->states['off']['value']; } @@ -52,6 +53,7 @@ public function render() ]); } + // @phpstan-ignore-next-line protected function getParentClassname() { return get_parent_class(get_parent_class($this)); diff --git a/src/Form/Field/Tile.php b/src/Form/Field/Tile.php index a2c6d1986..7b18d63b8 100644 --- a/src/Form/Field/Tile.php +++ b/src/Form/Field/Tile.php @@ -9,6 +9,7 @@ class Tile extends Field { protected $view = 'exment::form.field.tile'; + // @phpstan-ignore-next-line protected $multipled; /** @@ -18,6 +19,7 @@ class Tile extends Field */ protected $overlay = false; + // @phpstan-ignore-next-line public function __construct($column, $arguments = array()) { parent::__construct($column, $arguments); @@ -32,6 +34,7 @@ public function __construct($column, $arguments = array()) * * @return $this|mixed */ + // @phpstan-ignore-next-line public function options($options = []) { // remote options @@ -44,6 +47,7 @@ public function options($options = []) } if (is_callable($options)) { + // @phpstan-ignore-next-line $this->options = $options; } else { $this->options = (array) $options; @@ -52,6 +56,7 @@ public function options($options = []) return $this; } + // @phpstan-ignore-next-line public function overlay($overlay = true) { $this->overlay = $overlay; @@ -59,6 +64,7 @@ public function overlay($overlay = true) return $this; } + // @phpstan-ignore-next-line public function multiple() { $this->multipled = true; @@ -69,6 +75,7 @@ public function multiple() /** * {@inheritdoc} */ + // @phpstan-ignore-next-line public function prepare($value) { //if (is_array($value) && !Arr::isAssoc($value)) { @@ -79,9 +86,9 @@ public function prepare($value) } public function render() { - /** @phpstan-ignore-next-line Instanceof between array and Closure will always evaluate to false. it needs to fix laravel-admin */ + // @phpstan-ignore-next-line if ($this->options instanceof \Closure) { - /** @phpstan-ignore-next-line Left side of && is always true and Right side of && is always true */ + // @phpstan-ignore-next-line if ($this->form && $this->form->model()) { $this->options = $this->options->bindTo($this->form->model()); } @@ -121,6 +128,7 @@ public function render() EOT; + // @phpstan-ignore-next-line return parent::render()->with([ 'options' => $this->options, 'overlay' => $this->overlay, diff --git a/src/Form/Field/Tinymce.php b/src/Form/Field/Tinymce.php index 4c22f043c..a3e4ba321 100644 --- a/src/Form/Field/Tinymce.php +++ b/src/Form/Field/Tinymce.php @@ -9,12 +9,15 @@ class Tinymce extends Textarea { protected $view = 'admin::form.textarea'; + // @phpstan-ignore-next-line protected static $js = [ '/vendor/exment/tinymce/tinymce.min.js', ]; + // @phpstan-ignore-next-line protected $config = []; + // @phpstan-ignore-next-line protected $disableImage = false; /** @@ -61,6 +64,7 @@ public function readonly() return parent::readonly(); } + // @phpstan-ignore-next-line protected function getValidElements() { $tags = Define::HTML_ALLOWED_EDITOR_DEFAULT; diff --git a/src/Form/Field/ValueModal.php b/src/Form/Field/ValueModal.php index 089fa8cda..b1b91601a 100644 --- a/src/Form/Field/ValueModal.php +++ b/src/Form/Field/ValueModal.php @@ -13,11 +13,13 @@ class ValueModal extends Field { protected $view = 'exment::form.field.valuemodal'; + // @phpstan-ignore-next-line protected $valueTextScript; /** * @var string|array|\Closure|Collection */ + // @phpstan-ignore-next-line protected $text; /** @@ -55,11 +57,13 @@ class ValueModal extends Field */ protected $ajax; + // @phpstan-ignore-next-line protected $escape = true; /** * @var array modal ajax posting names */ + // @phpstan-ignore-next-line protected $post_names = []; /** @@ -71,6 +75,7 @@ class ValueModal extends Field */ public function text($text = '') { + // @phpstan-ignore-next-line $this->text = $text; return $this; } @@ -153,6 +158,7 @@ public function buttonClass($buttonClass) return $this; } + // @phpstan-ignore-next-line public function escape(bool $escape = true) { $this->escape = $escape; @@ -160,6 +166,7 @@ public function escape(bool $escape = true) return $this; } + // @phpstan-ignore-next-line protected function script() { $classname = $this->getElementClassSelector(); @@ -259,7 +266,7 @@ public function render() { // set text if ($this->text instanceof \Closure) { - /** @phpstan-ignore-next-line Left side of && is always true and Right side of && is always true. */ + // @phpstan-ignore-next-line if ($this->form && $this->form->model()) { $this->text = $this->text->bindTo($this->form->model()); } @@ -302,6 +309,7 @@ public function render() // set script $this->script(); + // @phpstan-ignore-next-line return parent::render()->with([ 'text' => $this->text, 'hidden' => $hidden, @@ -319,9 +327,11 @@ public function render() * * @return string */ + // @phpstan-ignore-next-line protected function convertString($value) { if (is_array($value)) { + // @phpstan-ignore-next-line return json_encode($value); } diff --git a/src/Form/Field/Workflow/Options.php b/src/Form/Field/Workflow/Options.php index 3630f95eb..220fee674 100644 --- a/src/Form/Field/Workflow/Options.php +++ b/src/Form/Field/Workflow/Options.php @@ -14,13 +14,14 @@ class Options extends Select * * @var array */ + // @phpstan-ignore-next-line protected $column = []; /** * @param $column * @param $arguments - * @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line public function __construct($column = '', $arguments = []) { $this->column['comment_type'] = 'comment_type'; @@ -41,6 +42,7 @@ public function __construct($column = '', $arguments = []) * * @return $this */ + // @phpstan-ignore-next-line public function setElementClass($class) { $classItem = collect($class)->map(function ($c) { @@ -53,6 +55,7 @@ public function setElementClass($class) return $this; } + // @phpstan-ignore-next-line public function prepare($value) { if (!array_has($value, 'ignore_work')) { @@ -89,9 +92,10 @@ public function render() $options = WorkflowCommentType::transArray('workflow.comment_options'); - /** @phpstan-ignore-next-line array_filter expects (callable(mixed): bool)|null, 'strlen' given. */ + // @phpstan-ignore-next-line $options = array_filter($options, 'strlen'); + // @phpstan-ignore-next-line return parent::render()->with([ 'optionsCommentType' => $options, 'defaultCommentType' => WorkflowCommentType::NULLABLE, diff --git a/src/Form/Field/Workflow/StatusSelects.php b/src/Form/Field/Workflow/StatusSelects.php index 4ded88c65..0e7f826d5 100644 --- a/src/Form/Field/Workflow/StatusSelects.php +++ b/src/Form/Field/Workflow/StatusSelects.php @@ -13,13 +13,14 @@ class StatusSelects extends Select * * @var array */ + // @phpstan-ignore-next-line protected $column = []; /** * @param $column * @param $arguments - * @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line public function __construct($column = '', $arguments = []) { $this->column['action_name'] = 'action_name'; @@ -38,6 +39,7 @@ public function __construct($column = '', $arguments = []) * * @return $this */ + // @phpstan-ignore-next-line public function setElementClass($class) { $classItem = collect($class)->map(function ($c) { @@ -69,16 +71,16 @@ public function render() $this->script = "$('.workflow_actions_status_from').select2($configs);"; } - /** @phpstan-ignore-next-line Instanceof between array and Closure will always evaluate to false. */ + // @phpstan-ignore-next-line if ($this->options instanceof \Closure) { - /** @phpstan-ignore-next-line Left side of && is always true. and Right side of && is always true. */ + // @phpstan-ignore-next-line if ($this->form && $this->form->model()) { $this->options = $this->options->bindTo($this->form->model()); } $this->options(call_user_func($this->options, $this->value, $this, $this->form->model())); } - /** @phpstan-ignore-next-line array_filter expects (callable(mixed): bool)|null, 'strlen' given */ + // @phpstan-ignore-next-line $this->options = array_filter($this->options, 'strlen'); // Whether is show id @@ -87,6 +89,7 @@ public function render() $action_id = array_get($this->data, 'id'); } + // @phpstan-ignore-next-line return parent::render()->with([ 'options' => $this->options, 'action_id' => $action_id, diff --git a/src/Form/Navbar/Hidden.php b/src/Form/Navbar/Hidden.php index 270151935..5ab629466 100644 --- a/src/Form/Navbar/Hidden.php +++ b/src/Form/Navbar/Hidden.php @@ -31,6 +31,7 @@ public function render() } + // @phpstan-ignore-next-line public static function getHiddenItemsCommon() { return [ diff --git a/src/Form/NestedEmbeddedForm.php b/src/Form/NestedEmbeddedForm.php index ec84e6f63..837222e2b 100644 --- a/src/Form/NestedEmbeddedForm.php +++ b/src/Form/NestedEmbeddedForm.php @@ -7,6 +7,7 @@ class NestedEmbeddedForm extends EmbeddedForm { + // @phpstan-ignore-next-line protected $data_key; /** @@ -14,6 +15,7 @@ class NestedEmbeddedForm extends EmbeddedForm * * @param string $column */ + // @phpstan-ignore-next-line public function __construct($column, $data_key = null) { $this->data_key = $data_key; @@ -47,7 +49,9 @@ protected function formatField(Field $field) $errorKey = "$errPrefix.$jsonKey"; } + // @phpstan-ignore-next-line $field->setElementName($elementName) + // @phpstan-ignore-next-line ->setErrorKey($errorKey); // set class @@ -78,6 +82,7 @@ protected function formatField(Field $field) * * @return string|array */ + // @phpstan-ignore-next-line public function getScripts() { $scripts = []; @@ -88,6 +93,7 @@ public function getScripts() $field->render(); /* + // Laravel Admin facade not recognized * Get and remove the last script of Admin::$script stack. */ if ($field->getScript()) { @@ -106,6 +112,7 @@ public function getScripts() * * @return $this */ + // @phpstan-ignore-next-line public function setOriginal($data) { if (empty($data)) { diff --git a/src/Form/PublicContent.php b/src/Form/PublicContent.php index 57771f0b0..5ce60b560 100644 --- a/src/Form/PublicContent.php +++ b/src/Form/PublicContent.php @@ -17,19 +17,31 @@ class PublicContent implements Renderable */ protected $rows = []; + // @phpstan-ignore-next-line protected $header_logo_url; + // @phpstan-ignore-next-line protected $header_label; + // @phpstan-ignore-next-line protected $use_header = true; + // @phpstan-ignore-next-line protected $use_footer = true; + // @phpstan-ignore-next-line protected $background_color = '#FFFFFF'; + // @phpstan-ignore-next-line protected $background_color_outer = '#F9FAFC'; + // @phpstan-ignore-next-line protected $header_background_color = '#3C8DBC'; + // @phpstan-ignore-next-line protected $footer_background_color = '#FFFFFF'; + // @phpstan-ignore-next-line protected $header_text_color = '#FFFFFF'; + // @phpstan-ignore-next-line protected $footer_text_color = '#000000'; + // @phpstan-ignore-next-line protected $container = false; + // @phpstan-ignore-next-line protected $analytics; /** @@ -49,6 +61,7 @@ public function __construct(\Closure $callback = null) * * @return self */ + // @phpstan-ignore-next-line public function setBackgroundColor($background_color) { $this->background_color = $background_color; @@ -61,6 +74,7 @@ public function setBackgroundColor($background_color) * * @return self */ + // @phpstan-ignore-next-line public function setBackgroundColorOuter($background_color_outer) { $this->background_color_outer = $background_color_outer; @@ -73,6 +87,7 @@ public function setBackgroundColorOuter($background_color_outer) * * @return self */ + // @phpstan-ignore-next-line public function setHeaderBackgroundColor($header_background_color) { $this->header_background_color = $header_background_color; @@ -85,6 +100,7 @@ public function setHeaderBackgroundColor($header_background_color) * * @return self */ + // @phpstan-ignore-next-line public function setFooterBackgroundColor($footer_background_color) { $this->footer_background_color = $footer_background_color; @@ -97,6 +113,7 @@ public function setFooterBackgroundColor($footer_background_color) * * @return self */ + // @phpstan-ignore-next-line public function setUseHeader($use_header) { $this->use_header = $use_header; @@ -109,6 +126,7 @@ public function setUseHeader($use_header) * * @return self */ + // @phpstan-ignore-next-line public function setUseFooter($use_footer) { $this->use_footer = $use_footer; @@ -121,6 +139,7 @@ public function setUseFooter($use_footer) * * @return self */ + // @phpstan-ignore-next-line public function setFooterTextColor($footer_text_color) { $this->footer_text_color = $footer_text_color; @@ -145,6 +164,7 @@ public function setIsContainer(bool $container) * * @return self */ + // @phpstan-ignore-next-line public function setHeaderLabel($header_label) { $this->header_label = $header_label; @@ -158,6 +178,7 @@ public function setHeaderLabel($header_label) * * @return self */ + // @phpstan-ignore-next-line public function setHeaderLogoUrl($header_logo_url) { $this->header_logo_url = $header_logo_url; @@ -170,6 +191,7 @@ public function setHeaderLogoUrl($header_logo_url) * * @return self */ + // @phpstan-ignore-next-line public function setAnalytics($analytics) { $this->analytics = $analytics; @@ -198,6 +220,7 @@ public function body($content) * * @return $this */ + // @phpstan-ignore-next-line public function row($content) { if ($content instanceof Closure) { @@ -221,6 +244,7 @@ public function row($content) * * @return $this */ + // @phpstan-ignore-next-line public function view($view, $data) { return $this->body(view($view, $data)); @@ -231,6 +255,7 @@ public function view($view, $data) * * @param Row $row */ + // @phpstan-ignore-next-line protected function addRow(Row $row) { $this->rows[] = $row; @@ -253,6 +278,7 @@ public function build() ob_end_clean(); + // @phpstan-ignore-next-line return $contents; } diff --git a/src/Form/PublicFormFooter.php b/src/Form/PublicFormFooter.php index e010f7686..8f150bf39 100644 --- a/src/Form/PublicFormFooter.php +++ b/src/Form/PublicFormFooter.php @@ -66,7 +66,7 @@ public function useRecaptchaV3() */ public function render() { - /** @phpstan-ignore-next-line Maybe mistake laravel-admin type */ + // @phpstan-ignore-next-line return parent::render()->with([ 'useRecaptchaV2' => $this->useRecaptchaV2, 'useRecaptchaV3' => $this->useRecaptchaV3, diff --git a/src/Form/Show.php b/src/Form/Show.php index b55653c3f..180b27fe3 100644 --- a/src/Form/Show.php +++ b/src/Form/Show.php @@ -14,6 +14,7 @@ class Show extends AdminShow /** * Initialize panel. */ + // @phpstan-ignore-next-line protected function initPanel() { $this->panel = new GridShowPanel($this); @@ -22,7 +23,7 @@ protected function initPanel() /** * Whether grid shows * - * @var boolean + * @var bool */ protected $gridShows = false; @@ -33,7 +34,7 @@ protected function initPanel() * 'options' => [], // Set row no, column no, width * 'field' => AdminField, // Set adminfield * ] - * @var array + * @var array> */ protected $fieldAndOptions = []; @@ -65,7 +66,7 @@ public function getMaxRow() * Push field and set for grid * * @param Field $field - * @param array $options + * @param array $options * @return Field */ public function addFieldAndOption($field, array $options) @@ -80,6 +81,10 @@ public function addFieldAndOption($field, array $options) return $field; } + /** + * @param mixed $data + * @return mixed + */ protected function renderView($data) { if (!$this->gridShows) { diff --git a/src/Form/Show/PublicShow.php b/src/Form/Show/PublicShow.php index 8db5e1407..669dafca6 100644 --- a/src/Form/Show/PublicShow.php +++ b/src/Form/Show/PublicShow.php @@ -11,12 +11,14 @@ class PublicShow extends \Exceedone\Exment\Form\Show /** * Initialize panel. */ + // @phpstan-ignore-next-line protected function initPanel() { $this->panel = new PublicShowPanel($this); } + // @phpstan-ignore-next-line public function setAction(string $action) { $this->panel->setAction($action); @@ -24,6 +26,7 @@ public function setAction(string $action) return $this; } + // @phpstan-ignore-next-line public function setBackAction(string $back_action) { $this->panel->setBackAction($back_action); @@ -36,6 +39,7 @@ public function setBackAction(string $back_action) * * @return self */ + // @phpstan-ignore-next-line public function setConfirmTitle($confirm_title) { $this->panel->setConfirmTitle($confirm_title); @@ -48,6 +52,7 @@ public function setConfirmTitle($confirm_title) * * @return self */ + // @phpstan-ignore-next-line public function setConfirmText($confirm_text) { $this->panel->setConfirmText($confirm_text); @@ -60,6 +65,7 @@ public function setConfirmText($confirm_text) * * @return self */ + // @phpstan-ignore-next-line public function setChildRelationShows($childRelationShows) { $this->panel->setChildRelationShows($childRelationShows); diff --git a/src/Form/Show/PublicShowChild.php b/src/Form/Show/PublicShowChild.php index f0236098e..0aba41393 100644 --- a/src/Form/Show/PublicShowChild.php +++ b/src/Form/Show/PublicShowChild.php @@ -7,6 +7,7 @@ class PublicShowChild extends \Exceedone\Exment\Form\Show /** * Initialize panel. */ + // @phpstan-ignore-next-line protected function initPanel() { $this->panel = new PublicShowPanelChild($this); diff --git a/src/Form/Show/PublicShowPanel.php b/src/Form/Show/PublicShowPanel.php index 2e206d884..6c36d6c01 100644 --- a/src/Form/Show/PublicShowPanel.php +++ b/src/Form/Show/PublicShowPanel.php @@ -19,13 +19,19 @@ class PublicShowPanel extends \Encore\Admin\Show\Panel */ protected $view = 'exment::public-form.confirmpanel'; + // @phpstan-ignore-next-line protected $action; + // @phpstan-ignore-next-line protected $back_action; + // @phpstan-ignore-next-line protected $confirm_title; + // @phpstan-ignore-next-line protected $confirm_text; + // @phpstan-ignore-next-line protected $relations = []; + // @phpstan-ignore-next-line public function setAction(string $action) { $this->action = $action; @@ -33,6 +39,7 @@ public function setAction(string $action) return $this; } + // @phpstan-ignore-next-line public function setBackAction(string $back_action) { $this->back_action = $back_action; @@ -46,6 +53,7 @@ public function setBackAction(string $back_action) * * @return self */ + // @phpstan-ignore-next-line public function setConfirmTitle($confirm_title) { $this->confirm_title = $confirm_title; @@ -58,6 +66,7 @@ public function setConfirmTitle($confirm_title) * * @return self */ + // @phpstan-ignore-next-line public function setConfirmText($confirm_text) { $this->confirm_text = $confirm_text; @@ -71,6 +80,7 @@ public function setConfirmText($confirm_text) * * @return self */ + // @phpstan-ignore-next-line public function setChildRelationShows($relations) { $this->relations = $relations; @@ -83,7 +93,7 @@ public function setChildRelationShows($relations) */ public function render() { - /** @phpstan-ignore-next-line Need laravel-admin php doc. */ + // @phpstan-ignore-next-line return parent::render()->with([ 'action' => $this->action, 'back_action' => $this->back_action, diff --git a/src/Form/Show/PublicShowPanelChild.php b/src/Form/Show/PublicShowPanelChild.php index eb3a0247d..7c41a0408 100644 --- a/src/Form/Show/PublicShowPanelChild.php +++ b/src/Form/Show/PublicShowPanelChild.php @@ -23,7 +23,7 @@ class PublicShowPanelChild extends \Encore\Admin\Show\Panel */ public function render() { - /** @phpstan-ignore-next-line Need laravel-admin php doc. */ + // @phpstan-ignore-next-line return parent::render()->with([ ]); } diff --git a/src/Form/Show/PublicShowRelation.php b/src/Form/Show/PublicShowRelation.php index cfe6737ea..b711cd96d 100644 --- a/src/Form/Show/PublicShowRelation.php +++ b/src/Form/Show/PublicShowRelation.php @@ -25,13 +25,16 @@ public function __construct() */ protected $view = 'exment::public-form.confirmpanel-relation'; + // @phpstan-ignore-next-line protected $title; + // @phpstan-ignore-next-line protected $children = []; /** * Get the value of title */ + // @phpstan-ignore-next-line public function getTitle() { return $this->title; @@ -42,6 +45,7 @@ public function getTitle() * * @return self */ + // @phpstan-ignore-next-line public function setTitle($title) { $this->title = $title; @@ -52,6 +56,7 @@ public function setTitle($title) /** * Get the value of children */ + // @phpstan-ignore-next-line public function getChildren() { return $this->children; @@ -62,6 +67,7 @@ public function getChildren() * * @return self */ + // @phpstan-ignore-next-line public function addChildren($children) { $this->children[] = $children; diff --git a/src/Form/Show/SystemValues.php b/src/Form/Show/SystemValues.php index 8f858beed..8f942a836 100644 --- a/src/Form/Show/SystemValues.php +++ b/src/Form/Show/SystemValues.php @@ -11,6 +11,7 @@ class SystemValues extends AbstractField public $escape = false; + // @phpstan-ignore-next-line public function render($options = []) { if (boolval(array_get($options, 'withTrashed'))) { diff --git a/src/Form/SystemValuesTrait.php b/src/Form/SystemValuesTrait.php index 07b9e2a80..7be7e19cf 100644 --- a/src/Form/SystemValuesTrait.php +++ b/src/Form/SystemValuesTrait.php @@ -8,8 +8,10 @@ trait SystemValuesTrait { + // @phpstan-ignore-next-line public $withTrashed = false; + // @phpstan-ignore-next-line public function renderSystemItem(CustomValue|Model|null $custom_value) { if (!isset($custom_value) || !isset($custom_value->id)) { @@ -52,6 +54,7 @@ public function renderSystemItem(CustomValue|Model|null $custom_value) ]); } + // @phpstan-ignore-next-line protected function getValues($custom_value, $items) { $result = []; @@ -75,6 +78,7 @@ protected function getValues($custom_value, $items) if (boolval(array_get($options, 'getOld'))) { $value = old($param); } + /** @phpstan-ignore-next-line */ if (is_nullorempty($value)) { $value = $custom_value->{$param}; } @@ -84,6 +88,7 @@ protected function getValues($custom_value, $items) } $result[] = [ + /** @phpstan-ignore-next-line */ 'label' => exmtrans("common.$key"), 'value' => $value ]; @@ -92,6 +97,7 @@ protected function getValues($custom_value, $items) return $result; } + // @phpstan-ignore-next-line protected function showWorkflowHistories($custom_value) { $workflowHistories = $custom_value->getWorkflowHistories(); @@ -99,11 +105,13 @@ protected function showWorkflowHistories($custom_value) return null; } + /** @phpstan-ignore-next-line */ $link = url_join($custom_value->getUrl(), 'workflowHistoryModal'); if ($this->withTrashed) { $link .= '?trashed=1'; } return [ + /** @phpstan-ignore-next-line */ 'label' => exmtrans('common.history'), 'value' => '' . trans('admin.show') . '' ]; diff --git a/src/Form/Tools/ConditionHasManyTable.php b/src/Form/Tools/ConditionHasManyTable.php index 2a1345b2d..6b12073f9 100644 --- a/src/Form/Tools/ConditionHasManyTable.php +++ b/src/Form/Tools/ConditionHasManyTable.php @@ -31,8 +31,11 @@ class ConditionHasManyTable * @var string|null */ protected $linkage; + // @phpstan-ignore-next-line protected $targetOptions; + // @phpstan-ignore-next-line protected $targetGroups; + // @phpstan-ignore-next-line protected $name; /** @@ -41,10 +44,14 @@ class ConditionHasManyTable * @var CustomTable */ protected $custom_table; + // @phpstan-ignore-next-line protected $label; + // @phpstan-ignore-next-line protected $useJoinOptions = true; + // @phpstan-ignore-next-line protected $useJoinOptionAttribute; + // @phpstan-ignore-next-line protected $callbackField; /** @@ -89,6 +96,7 @@ class ConditionHasManyTable */ protected $condition_value_label; + // @phpstan-ignore-next-line protected $condition_join_name = 'condition_join'; /** @@ -119,6 +127,7 @@ class ConditionHasManyTable */ protected $valueCallback = null; + // @phpstan-ignore-next-line public function __construct(&$form, $options = []) { $this->form = $form; @@ -141,6 +150,7 @@ public function __construct(&$form, $options = []) } } + // @phpstan-ignore-next-line public function render() { // get key name @@ -236,6 +246,7 @@ public function render() } } + // @phpstan-ignore-next-line public function callbackField($callbackField) { $this->callbackField = $callbackField; diff --git a/src/Form/Tools/CopyMenuButton.php b/src/Form/Tools/CopyMenuButton.php index 5d95b4ed9..d2721f790 100644 --- a/src/Form/Tools/CopyMenuButton.php +++ b/src/Form/Tools/CopyMenuButton.php @@ -10,10 +10,14 @@ */ class CopyMenuButton implements Renderable { + // @phpstan-ignore-next-line protected $copy; + // @phpstan-ignore-next-line protected $custom_table; + // @phpstan-ignore-next-line protected $id; + // @phpstan-ignore-next-line public function __construct($copy, $custom_table, $id = null) { $this->copy = $copy; @@ -21,6 +25,7 @@ public function __construct($copy, $custom_table, $id = null) $this->id = $id; } + // @phpstan-ignore-next-line protected function scriptSwal($uuid, $label) { $table_name = array_get($this->custom_table, 'table_name'); @@ -50,6 +55,7 @@ protected function scriptSwal($uuid, $label) EOT; } + // @phpstan-ignore-next-line protected function scriptModal($uuid) { $table_name = array_get($this->custom_table, 'table_name'); diff --git a/src/Form/Tools/CustomTableMenuAjaxButton.php b/src/Form/Tools/CustomTableMenuAjaxButton.php index bfe61581c..bcc7703a2 100644 --- a/src/Form/Tools/CustomTableMenuAjaxButton.php +++ b/src/Form/Tools/CustomTableMenuAjaxButton.php @@ -27,11 +27,13 @@ public function __construct() $this->modal_title = exmtrans("change_page_menu.change_page_label"); } + // @phpstan-ignore-next-line public function id($id) { $this->custom_table = CustomTable::getEloquent($id); } + // @phpstan-ignore-next-line protected function script() { $uuid = $this->uuid; diff --git a/src/Form/Tools/CustomTableMenuButton.php b/src/Form/Tools/CustomTableMenuButton.php index 1d9dddbef..8f79fd986 100644 --- a/src/Form/Tools/CustomTableMenuButton.php +++ b/src/Form/Tools/CustomTableMenuButton.php @@ -9,6 +9,7 @@ class CustomTableMenuButton extends ModalTileMenuButton { use CustomTableMenuTrait; + // @phpstan-ignore-next-line public function __construct($page_name, $custom_table, $page_name_sub = null) { $this->page_name = $page_name; diff --git a/src/Form/Tools/CustomTableMenuTrait.php b/src/Form/Tools/CustomTableMenuTrait.php index 0789d4fad..b090f36be 100644 --- a/src/Form/Tools/CustomTableMenuTrait.php +++ b/src/Form/Tools/CustomTableMenuTrait.php @@ -10,10 +10,14 @@ */ trait CustomTableMenuTrait { + // @phpstan-ignore-next-line protected $page_name; + // @phpstan-ignore-next-line protected $page_name_sub; + // @phpstan-ignore-next-line protected $custom_table; + // @phpstan-ignore-next-line protected function getItems() { $items = []; @@ -27,6 +31,7 @@ protected function getItems() // if this page_name is table and grid, check role if ($this->page_name == 'table' && !isset($this->custom_table)) { // if user dont't has role system + /** @phpstan-ignore-next-line */ if (!Admin::user()->hasPermission(array_get($menu, 'roles'))) { continue; } @@ -51,6 +56,7 @@ protected function getItems() ->map(function ($button) { return [ 'icon' => array_get($button, 'icon'), + /** @phpstan-ignore-next-line */ 'label' => exmtrans(array_get($button, 'exmtrans')), 'href' => admin_url(str_replace(':id', $this->custom_table->id, array_get($button, 'href'))), ]; @@ -58,9 +64,12 @@ protected function getItems() $items[] = [ + // @phpstan-ignore-next-line 'href' => admin_url($url), 'icon' => array_get($menu, 'icon'), + /** @phpstan-ignore-next-line */ 'header' => exmtrans(array_get($menu, 'exmtrans')), + /** @phpstan-ignore-next-line */ 'description' => exmtrans(array_get($menu, 'description')), 'buttons' => $buttons, ]; diff --git a/src/Form/Tools/CustomViewMenuButton.php b/src/Form/Tools/CustomViewMenuButton.php index 0e2f73974..8aa95e53d 100644 --- a/src/Form/Tools/CustomViewMenuButton.php +++ b/src/Form/Tools/CustomViewMenuButton.php @@ -9,14 +9,19 @@ class CustomViewMenuButton extends ModalTileMenuButton { + // @phpstan-ignore-next-line protected $custom_table; + // @phpstan-ignore-next-line protected $current_custom_view; + // @phpstan-ignore-next-line protected $addMenuList = true; // this views items, if already get, set this params. if this value is null, not init items. + // @phpstan-ignore-next-line protected $items = null; + // @phpstan-ignore-next-line public function __construct($custom_table, $current_custom_view = null, $addMenuList = true) { $this->custom_table = $custom_table; @@ -139,6 +144,7 @@ public function html() } + // @phpstan-ignore-next-line protected function getCompare(int $sort_options) { switch ($sort_options) { @@ -185,6 +191,7 @@ protected function getCompare(int $sort_options) } + // @phpstan-ignore-next-line protected function getItems() { if (!is_null($this->items)) { diff --git a/src/Form/Tools/DashboardMenu.php b/src/Form/Tools/DashboardMenu.php index 519f628a1..a2ffed3b0 100644 --- a/src/Form/Tools/DashboardMenu.php +++ b/src/Form/Tools/DashboardMenu.php @@ -7,13 +7,16 @@ class DashboardMenu { + // @phpstan-ignore-next-line protected $current_dashboard; + // @phpstan-ignore-next-line public function __construct($current_dashboard) { $this->current_dashboard = $current_dashboard; } + // @phpstan-ignore-next-line public function render() { $systemdashboards = []; diff --git a/src/Form/Tools/DeleteButton.php b/src/Form/Tools/DeleteButton.php index fbff2d8c4..554b7a6a3 100644 --- a/src/Form/Tools/DeleteButton.php +++ b/src/Form/Tools/DeleteButton.php @@ -9,13 +9,16 @@ */ class DeleteButton { + // @phpstan-ignore-next-line protected $url; + // @phpstan-ignore-next-line public function __construct($url) { $this->url = $url; } + // @phpstan-ignore-next-line protected function script($id) { $url = $this->url; @@ -34,6 +37,7 @@ protected function script($id) EOT; } + // @phpstan-ignore-next-line public function render() { $id = 'btn' . short_uuid(); diff --git a/src/Form/Tools/ExportImportButton.php b/src/Form/Tools/ExportImportButton.php index 24ed7b5ac..1064d9e7d 100644 --- a/src/Form/Tools/ExportImportButton.php +++ b/src/Form/Tools/ExportImportButton.php @@ -13,14 +13,22 @@ */ class ExportImportButton extends ModalTileMenuButton { + // @phpstan-ignore-next-line protected $grid; + // @phpstan-ignore-next-line protected $endpoint; + // @phpstan-ignore-next-line protected $total_export_flg; + // @phpstan-ignore-next-line protected $export_flg; + // @phpstan-ignore-next-line protected $import_flg; + // @phpstan-ignore-next-line protected $view_flg; // todo 通常ビューの場合のみプラグインエクスポートを有効にするための修正です + // @phpstan-ignore-next-line protected $plugin_flg; + // @phpstan-ignore-next-line protected $base_key = 'custom_value'; /** @@ -31,6 +39,7 @@ class ExportImportButton extends ModalTileMenuButton protected $custom_table; // todo 通常ビューの場合のみプラグインエクスポートを有効にするための修正です + // @phpstan-ignore-next-line public function __construct($endpoint, $grid, $view_flg = false, $export_flg = true, $import_flg = true, $plugin_flg = false) { $this->grid = $grid; @@ -278,6 +287,7 @@ public function render() return parent::render(); } + // @phpstan-ignore-next-line protected function disabledButton() { if (boolval(config('exment.export_view_disabled', false)) && boolval(config('exment.export_disabled', false)) && boolval(config('exment.import_disabled', false))) { @@ -291,6 +301,7 @@ protected function disabledButton() return false; } + // @phpstan-ignore-next-line protected function getPluginExports() { if (!isset($this->custom_table)) { diff --git a/src/Form/Tools/ModalButton.php b/src/Form/Tools/ModalButton.php index 4dc56316d..a325a1c65 100644 --- a/src/Form/Tools/ModalButton.php +++ b/src/Form/Tools/ModalButton.php @@ -9,12 +9,17 @@ */ class ModalButton { + // @phpstan-ignore-next-line protected $url; + // @phpstan-ignore-next-line protected $label; + // @phpstan-ignore-next-line protected $btn_class; + // @phpstan-ignore-next-line protected $icon; + // @phpstan-ignore-next-line public function __construct($options = []) { foreach ($options as $key => $value) { @@ -24,6 +29,7 @@ public function __construct($options = []) } } + // @phpstan-ignore-next-line public function render() { // get uuid diff --git a/src/Form/Tools/ModalLink.php b/src/Form/Tools/ModalLink.php index 7a6005a08..daf131e93 100644 --- a/src/Form/Tools/ModalLink.php +++ b/src/Form/Tools/ModalLink.php @@ -9,16 +9,26 @@ */ class ModalLink implements Renderable { + // @phpstan-ignore-next-line protected $url; + // @phpstan-ignore-next-line protected $label; + // @phpstan-ignore-next-line protected $expand; + // @phpstan-ignore-next-line protected $link_class; + // @phpstan-ignore-next-line protected $icon; + // @phpstan-ignore-next-line protected $html; + // @phpstan-ignore-next-line protected $modal_title; + // @phpstan-ignore-next-line protected $uuid; + // @phpstan-ignore-next-line protected $attributes = []; + // @phpstan-ignore-next-line public function __construct($url, $options = []) { $this->url = $url; diff --git a/src/Form/Tools/ModalMenuButton.php b/src/Form/Tools/ModalMenuButton.php index 0f48ed439..0e8becde7 100644 --- a/src/Form/Tools/ModalMenuButton.php +++ b/src/Form/Tools/ModalMenuButton.php @@ -9,14 +9,23 @@ */ class ModalMenuButton implements Renderable { + // @phpstan-ignore-next-line protected $url; + // @phpstan-ignore-next-line protected $label; + // @phpstan-ignore-next-line protected $expand; + // @phpstan-ignore-next-line protected $button_class; + // @phpstan-ignore-next-line protected $icon; + // @phpstan-ignore-next-line protected $html; + // @phpstan-ignore-next-line protected $modal_title; + // @phpstan-ignore-next-line protected $uuid; + // @phpstan-ignore-next-line protected $attributes = []; /** @@ -24,8 +33,10 @@ class ModalMenuButton implements Renderable * * @var array */ + // @phpstan-ignore-next-line protected $menulist = []; + // @phpstan-ignore-next-line public function __construct($url, $options = []) { $this->url = $url; diff --git a/src/Form/Tools/ModalTileAjaxMenuButton.php b/src/Form/Tools/ModalTileAjaxMenuButton.php index a14e7bb30..3939a413a 100644 --- a/src/Form/Tools/ModalTileAjaxMenuButton.php +++ b/src/Form/Tools/ModalTileAjaxMenuButton.php @@ -7,6 +7,7 @@ */ class ModalTileAjaxMenuButton extends ModalTileMenuButton { + // @phpstan-ignore-next-line public function __construct($url, $options = []) { parent::__construct($options); @@ -17,6 +18,7 @@ public function __construct($url, $options = []) /** * Get tile html */ + // @phpstan-ignore-next-line public function ajaxHtml() { return $this->html(); diff --git a/src/Form/Tools/ModalTileMenuButton.php b/src/Form/Tools/ModalTileMenuButton.php index 8c910be5b..40ee1a10a 100644 --- a/src/Form/Tools/ModalTileMenuButton.php +++ b/src/Form/Tools/ModalTileMenuButton.php @@ -7,8 +7,10 @@ */ class ModalTileMenuButton extends ModalMenuButton { + // @phpstan-ignore-next-line protected $groups = []; + // @phpstan-ignore-next-line public function __construct($options = []) { parent::__construct(null, $options); @@ -29,6 +31,7 @@ public function __construct($options = []) * @param $groups * @return $this */ + // @phpstan-ignore-next-line public function groups($groups) { $this->groups = $groups; diff --git a/src/Form/Tools/NotifyButton.php b/src/Form/Tools/NotifyButton.php index 884ca52ba..840c46000 100644 --- a/src/Form/Tools/NotifyButton.php +++ b/src/Form/Tools/NotifyButton.php @@ -9,10 +9,14 @@ */ class NotifyButton { + // @phpstan-ignore-next-line protected $notify; + // @phpstan-ignore-next-line protected $custom_table; + // @phpstan-ignore-next-line protected $id; + // @phpstan-ignore-next-line public function __construct($notify, $custom_table, $id = null) { $this->notify = $notify; @@ -20,6 +24,7 @@ public function __construct($notify, $custom_table, $id = null) $this->id = $id; } + // @phpstan-ignore-next-line protected function script($suuid, $label) { $table_name = array_get($this->custom_table, 'table_name'); @@ -49,6 +54,7 @@ protected function script($suuid, $label) EOT; } + // @phpstan-ignore-next-line public function render() { // get label diff --git a/src/Form/Tools/OperationButton.php b/src/Form/Tools/OperationButton.php index d9cc1267e..6269c4d96 100644 --- a/src/Form/Tools/OperationButton.php +++ b/src/Form/Tools/OperationButton.php @@ -10,12 +10,17 @@ */ class OperationButton { + // @phpstan-ignore-next-line protected $operation; + // @phpstan-ignore-next-line protected $custom_table; + // @phpstan-ignore-next-line protected $id; // set this operation type + // @phpstan-ignore-next-line protected $operation_type; + // @phpstan-ignore-next-line public function __construct($listButton, $custom_table, $id = null) { if ($listButton instanceof CustomOperation) { @@ -29,6 +34,7 @@ public function __construct($listButton, $custom_table, $id = null) $this->id = $id; } + // @phpstan-ignore-next-line protected function script($suuid, $label) { $table_name = array_get($this->custom_table, 'table_name'); @@ -63,6 +69,7 @@ protected function script($suuid, $label) EOT; } + // @phpstan-ignore-next-line protected function scriptModal($suuid) { $table_name = array_get($this->custom_table, 'table_name'); @@ -83,6 +90,7 @@ protected function scriptModal($suuid) EOT; } + // @phpstan-ignore-next-line public function render() { $label = array_get($this->operation, 'options.button_label') ?? diff --git a/src/Form/Tools/PluginMenuButton.php b/src/Form/Tools/PluginMenuButton.php index b9ed298c1..64d414b3c 100644 --- a/src/Form/Tools/PluginMenuButton.php +++ b/src/Form/Tools/PluginMenuButton.php @@ -10,12 +10,17 @@ */ class PluginMenuButton { + // @phpstan-ignore-next-line protected $plugin; + // @phpstan-ignore-next-line protected $custom_table; + // @phpstan-ignore-next-line protected $id; // set this plugin type + // @phpstan-ignore-next-line protected $plugin_type; + // @phpstan-ignore-next-line public function __construct($listButton, $custom_table, $id = null) { if ($listButton instanceof Plugin) { @@ -29,6 +34,7 @@ public function __construct($listButton, $custom_table, $id = null) $this->id = $id; } + // @phpstan-ignore-next-line protected function script($uuid, $label) { $table_name = array_get($this->custom_table, 'table_name'); @@ -63,6 +69,7 @@ protected function script($uuid, $label) EOT; } + // @phpstan-ignore-next-line public function render() { // get label @@ -71,17 +78,20 @@ public function render() 'id' => $this->id, ]); + // @phpstan-ignore-next-line if (method_exists($pluginClass, 'enableRender') && !$pluginClass->enableRender()) { return null; } // if render method has and not null, return. + // @phpstan-ignore-next-line $render = method_exists($pluginClass, 'render') ? $pluginClass->render() : null; if (!is_null($render)) { return $render; } if (method_exists($pluginClass, 'getButtonLabel')) { + // @phpstan-ignore-next-line $label = $pluginClass->getButtonLabel(); } else { $label = $this->plugin->plugin_view_name; diff --git a/src/Form/Tools/ShareButton.php b/src/Form/Tools/ShareButton.php index cc50a38cc..ae17449d0 100644 --- a/src/Form/Tools/ShareButton.php +++ b/src/Form/Tools/ShareButton.php @@ -9,15 +9,19 @@ */ class ShareButton { + // @phpstan-ignore-next-line protected $id; + // @phpstan-ignore-next-line protected $url; + // @phpstan-ignore-next-line public function __construct($id, $url) { $this->id = $id; $this->url = $url; } + // @phpstan-ignore-next-line protected function script($suuid, $label) { $confirm = trans('admin.confirm'); @@ -40,6 +44,7 @@ protected function script($suuid, $label) EOT; } + // @phpstan-ignore-next-line public function render() { // get label diff --git a/src/Form/Tools/SwalInputButton.php b/src/Form/Tools/SwalInputButton.php index 9a78aea33..62654aeef 100644 --- a/src/Form/Tools/SwalInputButton.php +++ b/src/Form/Tools/SwalInputButton.php @@ -9,21 +9,36 @@ */ class SwalInputButton { + // @phpstan-ignore-next-line protected $title; + // @phpstan-ignore-next-line protected $text; + // @phpstan-ignore-next-line protected $html; + // @phpstan-ignore-next-line protected $url; + // @phpstan-ignore-next-line protected $label; + // @phpstan-ignore-next-line protected $input; + // @phpstan-ignore-next-line protected $redirectUrl; + // @phpstan-ignore-next-line protected $confirmKeyword; + // @phpstan-ignore-next-line protected $icon; + // @phpstan-ignore-next-line protected $confirmError; + // @phpstan-ignore-next-line protected $btn_class; + // @phpstan-ignore-next-line protected $showCancelButton = true; + // @phpstan-ignore-next-line protected $type = 'warning'; + // @phpstan-ignore-next-line protected $method = 'POST'; + // @phpstan-ignore-next-line public function __construct($options = []) { foreach ($options as $key => $value) { @@ -33,6 +48,7 @@ public function __construct($options = []) } } + // @phpstan-ignore-next-line protected function script($suuid) { $url = $this->url; @@ -85,6 +101,7 @@ protected function script($suuid) Admin::script($script); } + // @phpstan-ignore-next-line public function render() { // get uuid diff --git a/src/Form/Tools/SwalMenuButton.php b/src/Form/Tools/SwalMenuButton.php index d673c71ab..2fb0488a7 100644 --- a/src/Form/Tools/SwalMenuButton.php +++ b/src/Form/Tools/SwalMenuButton.php @@ -9,6 +9,7 @@ */ class SwalMenuButton implements Renderable { + // @phpstan-ignore-next-line protected $label; /** @@ -16,10 +17,13 @@ class SwalMenuButton implements Renderable * * @var array */ + // @phpstan-ignore-next-line protected $menulist = []; + // @phpstan-ignore-next-line protected $attributes = []; + // @phpstan-ignore-next-line public function __construct(array $menulist = [], array $options = []) { $this->menulist = $menulist; diff --git a/src/Form/Tools/SystemChangePageMenu.php b/src/Form/Tools/SystemChangePageMenu.php index 58e9a394a..6571e2e9c 100644 --- a/src/Form/Tools/SystemChangePageMenu.php +++ b/src/Form/Tools/SystemChangePageMenu.php @@ -36,6 +36,7 @@ public function render() return parent::render(); } + // @phpstan-ignore-next-line protected function getMenuItems() { return collect([ diff --git a/src/Form/Widgets/InfoBox.php b/src/Form/Widgets/InfoBox.php index de7c94820..523266127 100644 --- a/src/Form/Widgets/InfoBox.php +++ b/src/Form/Widgets/InfoBox.php @@ -27,6 +27,7 @@ public function __construct($name, $icon, $color, $link, $info) $this->target(); } + // @phpstan-ignore-next-line public function showLink($showLink = true) { $this->data['showLink'] = $showLink; @@ -34,6 +35,7 @@ public function showLink($showLink = true) return $this; } + // @phpstan-ignore-next-line public function linkText($linkText) { $this->data['linkText'] = $linkText; @@ -41,6 +43,7 @@ public function linkText($linkText) return $this; } + // @phpstan-ignore-next-line public function target($target = '_self') { $this->data['target'] = $target; diff --git a/src/Form/Widgets/Modal.php b/src/Form/Widgets/Modal.php index 2204ae7cc..90583b52c 100644 --- a/src/Form/Widgets/Modal.php +++ b/src/Form/Widgets/Modal.php @@ -9,13 +9,16 @@ class Modal { use ModalTrait; + // @phpstan-ignore-next-line protected $modalBody; + // @phpstan-ignore-next-line public function body($modalBody) { $this->modalBody = $modalBody; } + // @phpstan-ignore-next-line public static function widgetModalRender() { // add modal for showmodal diff --git a/src/Form/Widgets/ModalForm.php b/src/Form/Widgets/ModalForm.php index 1d89aebe9..486fa6b74 100644 --- a/src/Form/Widgets/ModalForm.php +++ b/src/Form/Widgets/ModalForm.php @@ -20,6 +20,7 @@ class ModalForm extends WidgetForm * * @var array */ + // @phpstan-ignore-next-line protected $buttons = []; /** @@ -27,6 +28,7 @@ class ModalForm extends WidgetForm * * @return array */ + // @phpstan-ignore-next-line public function getScript() { return collect($this->fields)->map(function ($field) { diff --git a/src/Form/Widgets/ModalTrait.php b/src/Form/Widgets/ModalTrait.php index 73996e517..a013923ec 100644 --- a/src/Form/Widgets/ModalTrait.php +++ b/src/Form/Widgets/ModalTrait.php @@ -7,10 +7,12 @@ trait ModalTrait /** * @var array */ + // @phpstan-ignore-next-line protected $modalAttributes = []; /** * @var array */ + // @phpstan-ignore-next-line protected $modalInnerAttributes = []; /** @@ -40,6 +42,7 @@ public function modalHeader($header) * * @return $this */ + // @phpstan-ignore-next-line public function modalAttribute($attr, $value = '') { return $this->modal_attribute('modalAttributes', $attr, $value); @@ -52,6 +55,7 @@ public function modalAttribute($attr, $value = '') * * @return $this */ + // @phpstan-ignore-next-line public function modalInnerAttribute($attr, $value = '') { return $this->modal_attribute('modalInnerAttributes', $attr, $value); @@ -64,6 +68,7 @@ public function modalInnerAttribute($attr, $value = '') * * @return $this */ + // @phpstan-ignore-next-line protected function modal_attribute($arrayName, $attr, $value = '') { if (is_array($attr)) { @@ -80,6 +85,7 @@ protected function modal_attribute($arrayName, $attr, $value = '') * @param $attributes * @return string */ + // @phpstan-ignore-next-line protected function convert_attribute($attributes) { $html = []; @@ -90,6 +96,7 @@ protected function convert_attribute($attributes) return implode(' ', $html) ?: ''; } + // @phpstan-ignore-next-line protected function setModalAttributes() { $this->modalAttributes = array_merge([ diff --git a/src/Form/Widgets/ProgressTracker.php b/src/Form/Widgets/ProgressTracker.php index 8c9204c5f..a6f0fc8bb 100644 --- a/src/Form/Widgets/ProgressTracker.php +++ b/src/Form/Widgets/ProgressTracker.php @@ -9,6 +9,7 @@ */ class ProgressTracker implements Renderable { + // @phpstan-ignore-next-line protected $steps; public function __construct() @@ -23,12 +24,14 @@ public function __construct() * * @return $this|mixed */ + // @phpstan-ignore-next-line public function options($options = []) { if ($options instanceof \Illuminate\Contracts\Support\Arrayable) { $options = $options->toArray(); } + // @phpstan-ignore-next-line foreach ($options as $index => $option) { $class = ''; if (isset($option['active']) && $option['active']) { diff --git a/src/Form/Widgets/SelectItemBox.php b/src/Form/Widgets/SelectItemBox.php index e627cd206..d473c89f5 100644 --- a/src/Form/Widgets/SelectItemBox.php +++ b/src/Form/Widgets/SelectItemBox.php @@ -8,9 +8,13 @@ */ class SelectItemBox implements Renderable { + // @phpstan-ignore-next-line protected $iframe_url; + // @phpstan-ignore-next-line protected $target_class; + // @phpstan-ignore-next-line protected $widgetmodal_uuid; + // @phpstan-ignore-next-line protected $items; /** @@ -41,6 +45,7 @@ class SelectItemBox implements Renderable * @param string $iframe_url * @param array $items */ + // @phpstan-ignore-next-line public function __construct($iframe_url, $target_class, $widgetmodal_uuid, array $items) { $this->iframe_url = $iframe_url; diff --git a/src/Grid/Filter/Between.php b/src/Grid/Filter/Between.php index 2d16bcc4f..f2c34d57e 100644 --- a/src/Grid/Filter/Between.php +++ b/src/Grid/Filter/Between.php @@ -13,7 +13,7 @@ class Between extends \Encore\Admin\Grid\Filter\Between * * @param \Closure $query * @param string $label - * @param string $column + * @param string|null $column */ public function __construct(\Closure $query, $label, $column = null) { @@ -28,9 +28,9 @@ public function __construct(\Closure $query, $label, $column = null) /** * Get condition of this filter. * - * @param array $inputs + * @param array $inputs * - * @return array|mixed|void + * @return array|mixed|null */ public function condition($inputs) { @@ -56,6 +56,12 @@ public function condition($inputs) }); } + /** + * Convert value. + * + * @param mixed $value + * @return mixed + */ protected function convertValue($value) { return $value; diff --git a/src/Grid/Filter/BetweenDate.php b/src/Grid/Filter/BetweenDate.php index b3ad12112..659bbfa65 100644 --- a/src/Grid/Filter/BetweenDate.php +++ b/src/Grid/Filter/BetweenDate.php @@ -8,6 +8,7 @@ class BetweenDate extends Between /** * {@inheritdoc} + * @var string */ protected $view = 'admin::filter.betweenDatetime'; } diff --git a/src/Grid/Filter/BetweenTrait.php b/src/Grid/Filter/BetweenTrait.php index e39c8a529..132edaadd 100644 --- a/src/Grid/Filter/BetweenTrait.php +++ b/src/Grid/Filter/BetweenTrait.php @@ -18,6 +18,14 @@ trait BetweenTrait */ protected $whereNull; + /** + * Construct the filter. + * + * @param \Closure $query + * @param string $label + * @param string|null $column + * @return void + */ protected function construct(\Closure $query, $label, $column = null) { $this->where = $query; @@ -59,7 +67,7 @@ public static function getQueryHash(\Closure $closure, $label = '') /** * Get query where null condition from filter. * - * @return array|array[]|mixed|null + * @return array|mixed|null */ public function whereNullCondition() { diff --git a/src/Grid/Filter/Where.php b/src/Grid/Filter/Where.php index 713590dd5..94d8b63fe 100644 --- a/src/Grid/Filter/Where.php +++ b/src/Grid/Filter/Where.php @@ -29,9 +29,9 @@ public function whereNull($whereNull) /** * Get condition of this filter. * - * @param array $inputs + * @param array $inputs * - * @return array|mixed|void + * @return array|mixed|null */ public function condition($inputs) { @@ -52,7 +52,7 @@ public function condition($inputs) /** * Get query where null condition from filter. * - * @return array|array[]|mixed|null + * @return array|mixed|null */ public function whereNullCondition() { @@ -70,9 +70,9 @@ public function whereNullCondition() /** * Get query condition from filter. * - * @param array $inputs + * @param array $inputs * - * @return array|mixed|null + * @return array|mixed|null */ public function getCondition($inputs) { diff --git a/src/Grid/Tools/BatchCheck.php b/src/Grid/Tools/BatchCheck.php index 49d428299..0032c7a54 100644 --- a/src/Grid/Tools/BatchCheck.php +++ b/src/Grid/Tools/BatchCheck.php @@ -8,6 +8,8 @@ class BatchCheck extends BatchAction { /** * Script of batch delete action. + * + * @return string */ public function script() { diff --git a/src/Grid/Tools/BatchDelete.php b/src/Grid/Tools/BatchDelete.php index 3f7e6cb81..ebbbe6b58 100644 --- a/src/Grid/Tools/BatchDelete.php +++ b/src/Grid/Tools/BatchDelete.php @@ -8,6 +8,8 @@ class BatchDelete extends BatchDeleteBase { /** * Script of batch delete action. + * + * @return string */ public function script() { diff --git a/src/Grid/Tools/BatchHardDelete.php b/src/Grid/Tools/BatchHardDelete.php index e9f828a37..e5614b667 100644 --- a/src/Grid/Tools/BatchHardDelete.php +++ b/src/Grid/Tools/BatchHardDelete.php @@ -6,6 +6,11 @@ class BatchHardDelete extends BatchAction { + /** + * Constructor. + * + * @param string $title + */ public function __construct($title) { $this->title = $title; @@ -13,6 +18,8 @@ public function __construct($title) /** * Script of batch delete action. + * + * @return string */ public function script() { diff --git a/src/Grid/Tools/BatchRestore.php b/src/Grid/Tools/BatchRestore.php index 5f45fa5ce..3b5bd634e 100644 --- a/src/Grid/Tools/BatchRestore.php +++ b/src/Grid/Tools/BatchRestore.php @@ -15,6 +15,8 @@ public function __construct() /** * Script of batch delete action. + * + * @return string */ public function script() { diff --git a/src/Grid/Tools/BatchUpdate.php b/src/Grid/Tools/BatchUpdate.php index 879b29ee4..cf4c1d242 100644 --- a/src/Grid/Tools/BatchUpdate.php +++ b/src/Grid/Tools/BatchUpdate.php @@ -6,10 +6,15 @@ class BatchUpdate extends BatchAction { + /** + * @var mixed + */ protected $operation; /** * Create a new Tools instance. + * + * @param mixed $operation */ public function __construct($operation) { @@ -18,6 +23,8 @@ public function __construct($operation) /** * Script of batch delete action. + * + * @return string */ public function script() { @@ -38,7 +45,7 @@ public function script() * * @param string $title * - * @return $this + * @return static */ public function setTitle($title) { @@ -47,6 +54,12 @@ public function setTitle($title) return $this; } + /** + * Generate script for Swal dialog. + * + * @param string $suuid + * @return string + */ protected function scriptSwal($suuid) { $url = url($this->resource); @@ -79,6 +92,12 @@ protected function scriptSwal($suuid) EOT; } + /** + * Generate script for Modal dialog. + * + * @param string $suuid + * @return string + */ protected function scriptModal($suuid) { $url = url($this->resource); diff --git a/src/Jobs/MailSendJob.php b/src/Jobs/MailSendJob.php index 1d9dc0d33..4dcd1bb10 100644 --- a/src/Jobs/MailSendJob.php +++ b/src/Jobs/MailSendJob.php @@ -28,10 +28,13 @@ class MailSendJob extends Notification implements ShouldQueue * @var MailHistory */ protected $mailHistory; + // @phpstan-ignore-next-line protected $userId; + // @phpstan-ignore-next-line protected $finalUser; + // @phpstan-ignore-next-line public function __construct($userId = null, $finalUser = false) { $this->userId = $userId; @@ -44,6 +47,7 @@ public function __construct($userId = null, $finalUser = false) * @param mixed $notifiable * @return array */ + // @phpstan-ignore-next-line public function via($notifiable) { return [MailChannel::class]; @@ -93,6 +97,7 @@ public function setMailHistory(MailHistory $mailHistory) /** * Handle a job failure. */ + // @phpstan-ignore-next-line public function failed($exception) { $mail_template = CustomTable::getEloquent(SystemTableName::MAIL_TEMPLATE) diff --git a/src/Jobs/MicrosoftTeamsJob.php b/src/Jobs/MicrosoftTeamsJob.php index cadfc4185..ce7ba983c 100644 --- a/src/Jobs/MicrosoftTeamsJob.php +++ b/src/Jobs/MicrosoftTeamsJob.php @@ -11,7 +11,9 @@ class MicrosoftTeamsJob extends Notification implements ShouldQueue { use JobTrait; + // @phpstan-ignore-next-line protected $content; + // @phpstan-ignore-next-line protected $subject; /** @@ -19,6 +21,7 @@ class MicrosoftTeamsJob extends Notification implements ShouldQueue * * @return void */ + // @phpstan-ignore-next-line public function __construct($subject, $content) { $this->content = $content; @@ -31,6 +34,7 @@ public function __construct($subject, $content) * @param mixed $notifiable * @return array */ + // @phpstan-ignore-next-line public function via($notifiable) { return [MicrosoftTeamsChannel::class]; @@ -55,6 +59,7 @@ public function toChat($notifiable) * @param mixed $notifiable * @return array */ + // @phpstan-ignore-next-line public function toArray($notifiable) { return [ diff --git a/src/Jobs/NavbarJob.php b/src/Jobs/NavbarJob.php index a5957ca42..08f81a75a 100644 --- a/src/Jobs/NavbarJob.php +++ b/src/Jobs/NavbarJob.php @@ -11,9 +11,12 @@ class NavbarJob extends Notification implements ShouldQueue { use JobTrait; + // @phpstan-ignore-next-line protected $content; + // @phpstan-ignore-next-line protected $subject; + // @phpstan-ignore-next-line protected $notify_id; /** @@ -49,6 +52,7 @@ class NavbarJob extends Notification implements ShouldQueue * * @return void */ + // @phpstan-ignore-next-line public function __construct($subject, $content, $notify_id, $target_user_id, $trigger_user_id, $parent_id, $parent_type) { $this->content = $content; @@ -66,6 +70,7 @@ public function __construct($subject, $content, $notify_id, $target_user_id, $tr * @param mixed $notifiable * @return array */ + // @phpstan-ignore-next-line public function via($notifiable) { return [NavbarChannel::class]; @@ -76,6 +81,7 @@ public function via($notifiable) * * @param mixed $notifiable */ + // @phpstan-ignore-next-line public function toNavbar($notifiable) { // save data @@ -97,6 +103,7 @@ public function toNavbar($notifiable) * @param mixed $notifiable * @return array */ + // @phpstan-ignore-next-line public function toArray($notifiable) { return [ diff --git a/src/Jobs/SlackSendJob.php b/src/Jobs/SlackSendJob.php index be863fa84..95c0b9543 100644 --- a/src/Jobs/SlackSendJob.php +++ b/src/Jobs/SlackSendJob.php @@ -10,8 +10,11 @@ class SlackSendJob extends Notification implements ShouldQueue { use JobTrait; + // @phpstan-ignore-next-line protected $name; + // @phpstan-ignore-next-line protected $icon; + // @phpstan-ignore-next-line protected $content; /** @@ -19,6 +22,7 @@ class SlackSendJob extends Notification implements ShouldQueue * * @return void */ + // @phpstan-ignore-next-line public function __construct($name, $icon, $content) { $this->name = $name; @@ -32,6 +36,7 @@ public function __construct($name, $icon, $content) * @param mixed $notifiable * @return array */ + // @phpstan-ignore-next-line public function via($notifiable) { return ['slack']; @@ -56,6 +61,7 @@ public function toSlack($notifiable) * @param mixed $notifiable * @return array */ + // @phpstan-ignore-next-line public function toArray($notifiable) { return [ diff --git a/src/Middleware/ApiIPFilter.php b/src/Middleware/ApiIPFilter.php index 9a5b8667b..439f28f4c 100644 --- a/src/Middleware/ApiIPFilter.php +++ b/src/Middleware/ApiIPFilter.php @@ -11,11 +11,18 @@ */ class ApiIPFilter extends IpFilterBase { + /** + * @param \Closure(Request): mixed $next + * @return mixed + */ public function handle(Request $request, \Closure $next) { return $this->handleBase($request, $next, 'api_ip_filters'); } + /** + * @return mixed + */ protected function returnError() { return abortJson(400, ErrorCode::DISAPPROVAL_IP()); diff --git a/src/Middleware/AuthenticatePluginApi.php b/src/Middleware/AuthenticatePluginApi.php index a5f47c325..5d6393ad6 100644 --- a/src/Middleware/AuthenticatePluginApi.php +++ b/src/Middleware/AuthenticatePluginApi.php @@ -49,7 +49,14 @@ public function handle($request, Closure $next) */ protected function getPlugin($request) { - $name = $request->route()->getName(); + $route = $request->route(); + if (!$route) { + return null; + } + + /** @var string|null $name */ + // @phpstan-ignore-next-line + $name = is_string($route) ? $route : $route->getName(); if (!isset($name)) { return null; } diff --git a/src/Middleware/AuthenticatePublicForm.php b/src/Middleware/AuthenticatePublicForm.php index 35d8b4311..49039810b 100644 --- a/src/Middleware/AuthenticatePublicForm.php +++ b/src/Middleware/AuthenticatePublicForm.php @@ -11,7 +11,7 @@ class AuthenticatePublicForm extends Middleware * Determine if the user is logged in to any of the given guards. * * @param \Illuminate\Http\Request $request - * @param array $guards + * @param array $guards * @return void * * @throws \Illuminate\Auth\AuthenticationException diff --git a/src/Middleware/Bootstrap.php b/src/Middleware/Bootstrap.php index e15b08037..5e0cadc3a 100644 --- a/src/Middleware/Bootstrap.php +++ b/src/Middleware/Bootstrap.php @@ -15,6 +15,10 @@ class Bootstrap { use BootstrapTrait; + /** + * @param \Closure(Request): mixed $next + * @return mixed + */ public function handle(Request $request, \Closure $next) { $this->setCssJs($request, $next); @@ -106,7 +110,7 @@ protected function setCssJs(Request $request, \Closure $next) if (!isset($ver)) { $ver = date('YmdHis'); } - /** @phpstan-ignore-next-line jslast() expects null, string given */ + // @phpstan-ignore-next-line Ad::jslast(asset('vendor/exment/js/customscript.js?ver='.$ver)); // delete object diff --git a/src/Middleware/BootstrapPublicForm.php b/src/Middleware/BootstrapPublicForm.php index f775b848f..70d78fdc5 100644 --- a/src/Middleware/BootstrapPublicForm.php +++ b/src/Middleware/BootstrapPublicForm.php @@ -14,6 +14,10 @@ class BootstrapPublicForm { use BootstrapTrait; + /** + * @param \Closure(Request): mixed $next + * @return mixed + */ public function handle(Request $request, \Closure $next) { $this->setCssJs($request, $next); @@ -84,6 +88,9 @@ protected function setCssJs(Request $request, \Closure $next) } + /** + * @return void + */ public static function setPublicFormCssJs(?PublicForm $public_form) { if ($public_form) { diff --git a/src/Middleware/BootstrapTrait.php b/src/Middleware/BootstrapTrait.php index dc1caa366..930270aa8 100644 --- a/src/Middleware/BootstrapTrait.php +++ b/src/Middleware/BootstrapTrait.php @@ -8,8 +8,16 @@ trait BootstrapTrait { + /** + * @param array $list + * @param bool $isCss + * @param bool $isLast + * @return void + * @phpstan-ignore-next-line + */ protected static function setCssJsList(array $list, bool $isCss, bool $isLast = false) { + /** @phpstan-ignore-next-line */ $ver = \Exment::getExmentCurrentVersion(); if (!isset($ver)) { $ver = date('YmdHis'); @@ -25,6 +33,10 @@ protected static function setCssJsList(array $list, bool $isCss, bool $isLast = } + /** + * @param mixed $request + * @return bool + */ protected function isStaticRequest($request) { $pathInfo = $request->getPathInfo(); @@ -35,10 +47,11 @@ protected function isStaticRequest($request) /** * append Style and sript to page * - * @param $pl + * @param mixed $pl * @param bool $asPublicForm * @return void * @throws \Exception + * @phpstan-ignore-next-line */ protected static function appendStyleScript($pl, bool $asPublicForm = false) { @@ -60,9 +73,11 @@ protected static function appendStyleScript($pl, bool $asPublicForm = false) } // get scripts + /** @phpstan-ignore-next-line */ $cdns = array_get($plugin, 'options.cdns', []); foreach ($cdns as $cdn) { $ext = pathinfo($cdn, PATHINFO_EXTENSION); + /** @phpstan-ignore-next-line */ $p = isMatchString($ext, 'js') ? 'js' : (isMatchString($ext, 'css') ? 'css' : null); if (!$p) { continue; diff --git a/src/Middleware/Browser.php b/src/Middleware/Browser.php index c0c89c873..58d8a63fb 100644 --- a/src/Middleware/Browser.php +++ b/src/Middleware/Browser.php @@ -10,8 +10,13 @@ */ class Browser { + /** + * @param \Closure(Request): mixed $next + * @return mixed + */ public function handle(Request $request, \Closure $next) { + // @phpstan-ignore-next-line $browser = strtolower($request->server('HTTP_USER_AGENT')); if (mb_strstr($browser, 'trident') || mb_strstr($browser, 'msie')) { diff --git a/src/Middleware/ExmentDebug.php b/src/Middleware/ExmentDebug.php index 97987d933..fba2be1ee 100644 --- a/src/Middleware/ExmentDebug.php +++ b/src/Middleware/ExmentDebug.php @@ -11,6 +11,9 @@ class ExmentDebug { + /** + * @return mixed + */ public function handle(Request $request, \Closure $next) { static::handleLog($request); @@ -19,6 +22,9 @@ public function handle(Request $request, \Closure $next) } + /** + * @return void + */ public static function handleLog(?Request $request = null) { // Check if database is initialized before accessing System settings @@ -38,6 +44,9 @@ public static function handleLog(?Request $request = null) } } + /** + * @var array + */ protected static $queryLogs = []; /** @@ -77,6 +86,7 @@ protected static function logDatabase() /** * Output log request * + * @param Request $request * @return void */ protected static function logRequest($request) @@ -97,6 +107,10 @@ protected static function logRequest($request) \Log::debug("\nIP : {$ip}\nURL : $url\nInput : $input\nHeaders --------------------------------------\n$headers"); } + /** + * @param bool $oneFunction + * @return string + */ protected static function getFunctionName($oneFunction = false) { $bt = debug_backtrace(); @@ -104,6 +118,7 @@ protected static function getFunctionName($oneFunction = false) $i = 0; foreach ($bt as $b) { if ($i > 1 && strpos_ex(array_get($b, 'class'), 'Exceedone') !== false) { + // @phpstan-ignore-next-line $functions[] = $b['class'] . '->' . $b['function'] . '.' . array_get($b, 'line'); } diff --git a/src/Middleware/Initialize.php b/src/Middleware/Initialize.php index 853fb1498..78eb10fc9 100644 --- a/src/Middleware/Initialize.php +++ b/src/Middleware/Initialize.php @@ -29,6 +29,10 @@ */ class Initialize { + /** + * @param \Closure(Request): mixed $next + * @return mixed + */ public function handle(Request $request, \Closure $next) { if (!canConnection() || !hasTable(SystemTableName::SYSTEM)) { @@ -83,6 +87,10 @@ protected function isInstallPath(Request $request) } + /** + * @param bool $setDatabase + * @return void + */ public static function initializeConfig($setDatabase = true) { //// set from env @@ -438,6 +446,9 @@ public static function initializeConfig($setDatabase = true) } } + /** + * @return void + */ public static function requireBootstrap() { $file = config('exment.bootstrap', exment_app_path('bootstrap.php')); @@ -449,13 +460,14 @@ public static function requireBootstrap() /** * set laravel-admin + * @return void */ public static function registeredLaravelAdmin() { Grid::init(function (Grid $grid) { $grid->disableColumnSelector(); - /** @phpstan-ignore-next-line Left side of && is always true. it needs to fix laravel-admin */ + // @phpstan-ignore-next-line if ($grid->model() && ($grid->model()->eloquent() instanceof Model\CustomValue)) { if (!is_null($value = System::grid_pager_count())) { $grid->paginate($value); diff --git a/src/Middleware/IpFilterBase.php b/src/Middleware/IpFilterBase.php index 96a2d63cf..fed7a0161 100644 --- a/src/Middleware/IpFilterBase.php +++ b/src/Middleware/IpFilterBase.php @@ -13,6 +13,12 @@ */ abstract class IpFilterBase { + /** + * @param Request $request + * @param \Closure $next + * @param string $filterFuncName + * @return mixed + */ public function handleBase(Request $request, \Closure $next, $filterFuncName) { if (config('exment.ip_filter_disabled', false)) { @@ -40,5 +46,8 @@ public function handleBase(Request $request, \Closure $next, $filterFuncName) return $next($request); } + /** + * @return mixed + */ abstract protected function returnError(); } diff --git a/src/Middleware/LogOperation.php b/src/Middleware/LogOperation.php index adf062f06..dac81ae65 100644 --- a/src/Middleware/LogOperation.php +++ b/src/Middleware/LogOperation.php @@ -28,6 +28,7 @@ public function handle(Request $request, \Closure $next) 'path' => substr($request->path(), 0, 255), 'method' => $request->method(), 'ip' => $request->getClientIp(), + // @phpstan-ignore-next-line 'input' => $this->hidePasswords(json_encode($request->input())), ]; @@ -83,6 +84,9 @@ protected function hidePasswords($stringToLog) return preg_replace('#("(' . $columns . ')"\s*:\s*")([^"]*)"#', '\1***"', $stringToLog); } + /** + * @return array + */ public static function getHideColumns(): array { return [ diff --git a/src/Middleware/Login.php b/src/Middleware/Login.php index 8bcedd946..37b3d6793 100644 --- a/src/Middleware/Login.php +++ b/src/Middleware/Login.php @@ -10,6 +10,10 @@ */ class Login { + /** + * @param \Closure(Request): mixed $next + * @return mixed + */ public function handle(Request $request, \Closure $next) { // check whether SSO url redirect @@ -17,6 +21,7 @@ public function handle(Request $request, \Closure $next) && !is_null($exment_login_url = LoginSetting::getRedirectSSOForceUrl())) { $errors = $request->session()->get('errors'); if (\is_nullorempty($errors)) { + // @phpstan-ignore-next-line return redirect($exment_login_url); } } diff --git a/src/Middleware/Morph.php b/src/Middleware/Morph.php index 861dee3a4..1135d6afe 100644 --- a/src/Middleware/Morph.php +++ b/src/Middleware/Morph.php @@ -14,6 +14,10 @@ */ class Morph { + /** + * @param \Closure(Request): mixed $next + * @return mixed + */ public function handle(Request $request, \Closure $next) { static::defineMorphMap(); @@ -23,6 +27,7 @@ public function handle(Request $request, \Closure $next) /** * define morph map. this called from command. * + * @return void */ public static function defineMorphMap() { @@ -46,7 +51,7 @@ public static function defineMorphMap() /** * return Morph maps * - * @return array + * @return array */ public static function getMorphs() { @@ -70,6 +75,7 @@ public static function getMorphs() getModelName($table_name); } + // @phpstan-ignore-next-line return $morphMaps; } } diff --git a/src/Middleware/WebIPFilter.php b/src/Middleware/WebIPFilter.php index 4592722af..cef0fb5c4 100644 --- a/src/Middleware/WebIPFilter.php +++ b/src/Middleware/WebIPFilter.php @@ -10,11 +10,18 @@ */ class WebIPFilter extends IpFilterBase { + /** + * @param \Closure(Request): mixed $next + * @return mixed + */ public function handle(Request $request, \Closure $next) { return $this->handleBase($request, $next, 'web_ip_filters'); } + /** + * @return mixed + */ protected function returnError() { return response(view('exment::exception.ipfilter')); diff --git a/src/Model/ApiClient.php b/src/Model/ApiClient.php index 71eb6dfbe..ce530bd59 100644 --- a/src/Model/ApiClient.php +++ b/src/Model/ApiClient.php @@ -28,22 +28,30 @@ class ApiClient extends Client * * @var array */ + + // @phpstan-ignore-next-line protected $hidden = [ //'secret', ]; protected $keyType = 'string'; + + // @phpstan-ignore-next-line public function client_api_key() { return $this->hasOne(ApiKey::class, 'client_id'); } + + // @phpstan-ignore-next-line public function getApiKeyStringAttribute() { return $this->client_api_key->key ?? null; } + + // @phpstan-ignore-next-line public function getClientTypeAttribute() { if (boolval($this->api_key_client)) { @@ -52,12 +60,15 @@ public function getClientTypeAttribute() if (boolval($this->password_client)) { return ApiClientType::PASSWORD_GRANT; } - /** @phpstan-ignore-next-line Negated boolean expression is always true. */ + + // @phpstan-ignore-next-line if (!boolval($this->personal_access_client) && !boolval($this->password_client)) { return ApiClientType::CLIENT_CREDENTIALS; } } + + // @phpstan-ignore-next-line public function getClientTypeTextAttribute() { $client_type = $this->client_type; diff --git a/src/Model/ApiKey.php b/src/Model/ApiKey.php index 1d8aaa045..eaab75747 100644 --- a/src/Model/ApiKey.php +++ b/src/Model/ApiKey.php @@ -18,6 +18,8 @@ class ApiKey extends Model public $timestamps = false; + + // @phpstan-ignore-next-line protected $primary_key = 'key'; protected $keyType = 'string'; @@ -30,6 +32,8 @@ class ApiKey extends Model * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ + + // @phpstan-ignore-next-line public function client() { return $this->belongsTo(Passport::clientModel()); diff --git a/src/Model/Condition.php b/src/Model/Condition.php index ad48e0b98..39be60d29 100644 --- a/src/Model/Condition.php +++ b/src/Model/Condition.php @@ -29,20 +29,30 @@ class Condition extends ModelBase protected $guarded = ['id']; protected $appends = ['condition_target']; + + // @phpstan-ignore-next-line protected $condition_type_key = 'condition_type'; + + // @phpstan-ignore-next-line protected $condition_column_key = 'target_column_id'; + + // @phpstan-ignore-next-line public function getCustomTable() { if ($this->morph_type == 'custom_form_priority') { $parent_table = CustomFormPriority::find($this->morph_id); if (isset($parent_table)) { + + // @phpstan-ignore-next-line return $parent_table->custom_form->custom_table; } } return null; } + + // @phpstan-ignore-next-line public function getConditionTargetAttribute() { return $this->getConditionTarget(); @@ -51,6 +61,8 @@ public function getConditionTargetAttribute() /** * set condition_target. */ + + // @phpstan-ignore-next-line public function setConditionTargetAttribute($condition_target) { $params = $this->getViewColumnTargetItems($condition_target, null); @@ -72,6 +84,8 @@ public function getConditionTarget() /** * get priority condition text. */ + + // @phpstan-ignore-next-line public function getConditionTextAttribute() { if (!isset($this->condition_item)) { @@ -85,6 +99,8 @@ public function getConditionTextAttribute() /** * get edited condition_value_text. */ + + // @phpstan-ignore-next-line public function getConditionValueAttribute() { $condition_value = array_get($this->attributes, 'condition_value'); @@ -107,6 +123,8 @@ public function getConditionValueAttribute() * set condition_value_text. * * we have to convert int if view_filter_condition_value is array* */ + + // @phpstan-ignore-next-line public function setConditionValueAttribute($condition_value) { if (is_array($condition_value)) { @@ -122,6 +140,8 @@ public function setConditionValueAttribute($condition_value) /** * check if custom_value and user(organization, role) match for conditions. */ + + // @phpstan-ignore-next-line public function isMatchCondition($custom_value) { $item = ConditionItemBase::getItem($custom_value->custom_table, $this->condition_type, $this->target_column_id); @@ -139,6 +159,8 @@ public function isMatchCondition($custom_value) * @param array $work_conditions * @return array */ + + // @phpstan-ignore-next-line public static function getWorkConditions($work_conditions) { $work_conditions = jsonToArray($work_conditions); diff --git a/src/Model/CustomColumn.php b/src/Model/CustomColumn.php index 0ce1b1359..2cf608c06 100644 --- a/src/Model/CustomColumn.php +++ b/src/Model/CustomColumn.php @@ -45,6 +45,8 @@ class CustomColumn extends ModelBase implements Interfaces\TemplateImporterInter protected $guarded = ['id', 'suuid']; // protected $with = ['custom_table']; + + // @phpstan-ignore-next-line private $_column_item; @@ -52,9 +54,13 @@ class CustomColumn extends ModelBase implements Interfaces\TemplateImporterInter * $custom available_characters * @var array */ + + // @phpstan-ignore-next-line protected static $customAvailableCharacters = []; + + // @phpstan-ignore-next-line public static $templateItems = [ 'excepts' => ['suuid', 'required', 'index_enabled', 'unique', 'custom_table'], 'uniqueKeys' => [ @@ -114,69 +120,93 @@ class CustomColumn extends ModelBase implements Interfaces\TemplateImporterInter ] ]; + + // @phpstan-ignore-next-line public function custom_table(): BelongsTo { return $this->belongsTo(CustomTable::class, 'custom_table_id'); } + + // @phpstan-ignore-next-line public function custom_form_columns(): HasMany { return $this->hasMany(CustomFormColumn::class, 'form_column_target_id') ->where('form_column_type', FormColumnType::COLUMN); } + + // @phpstan-ignore-next-line public function custom_view_columns(): HasMany { return $this->hasMany(CustomViewColumn::class, 'view_column_target_id') ->where('view_column_type', ConditionType::COLUMN); } + + // @phpstan-ignore-next-line public function custom_view_sorts(): HasMany { return $this->hasMany(CustomViewSort::class, 'view_column_target_id') ->where('view_column_type', ConditionType::COLUMN); } + + // @phpstan-ignore-next-line public function custom_view_filters(): HasMany { return $this->hasMany(CustomViewFilter::class, 'view_column_target_id') ->where('view_column_type', ConditionType::COLUMN); } + + // @phpstan-ignore-next-line public function custom_view_summaries(): HasMany { return $this->hasMany(CustomViewSummary::class, 'view_column_target_id') ->where('view_column_type', ConditionType::COLUMN); } + + // @phpstan-ignore-next-line public function custom_view_grid_filters(): HasMany { return $this->hasMany(CustomViewGridFilter::class, 'view_column_target_id') ->where('view_column_type', ConditionType::COLUMN); } + + // @phpstan-ignore-next-line public function custom_operation_columns(): HasMany { return $this->hasMany(CustomOperationColumn::class, 'view_column_target_id') ->where('view_column_type', ConditionType::COLUMN); } + + // @phpstan-ignore-next-line public function conditions(): HasMany { return $this->hasMany(Condition::class, 'target_column_id') ->where('condition_type', ConditionType::COLUMN); } + + // @phpstan-ignore-next-line public function scopeIndexEnabled($query) { return $query->whereIn('options->index_enabled', [1, "1", true]); } + + // @phpstan-ignore-next-line public function scopeRequired($query) { return $query->whereIn('options->required', [1, "1", true]); } + + // @phpstan-ignore-next-line public function scopeSelectTargetTable($query, $custom_table_id) { // check user or org table. @@ -189,11 +219,15 @@ public function scopeSelectTargetTable($query, $custom_table_id) return $query->whereIn('options->select_target_table', [$custom_table_id, strval($custom_table_id)]); } + + // @phpstan-ignore-next-line public function getCustomTableCacheAttribute() { return CustomTable::getEloquent($this); } + + // @phpstan-ignore-next-line public function getColumnItemAttribute() { if (isset($this->_column_item)) { @@ -204,6 +238,8 @@ public function getColumnItemAttribute() return $this->_column_item; } + + // @phpstan-ignore-next-line public function getSelectTargetTableAttribute() { if (ColumnType::isUserOrganization($this->column_type)) { @@ -211,41 +247,57 @@ public function getSelectTargetTableAttribute() } return CustomTable::getEloquent($this->getOption('select_target_table')); } + + // @phpstan-ignore-next-line public function getSelectTargetViewAttribute() { return CustomView::getEloquent($this->getOption('select_target_view')); } + + // @phpstan-ignore-next-line public function getRequiredAttribute() { return $this->getOption('required', false); } + + // @phpstan-ignore-next-line public function getIndexEnabledAttribute() { return $this->getOption('index_enabled', false); } + + // @phpstan-ignore-next-line public function getUniqueAttribute() { return $this->getOption('unique', false); } + + // @phpstan-ignore-next-line public function setRequiredAttribute($value) { return $this->setOption('required', $value); } + + // @phpstan-ignore-next-line public function setIndexEnabledAttribute($value) { return $this->setOption('index_enabled', $value); } + + // @phpstan-ignore-next-line public function setUniqueAttribute($value) { return $this->setOption('unique', $value); } + + // @phpstan-ignore-next-line public function getSelectImportColumnAttribute() { return CustomColumn::getEloquent($this->getOption('select_import_column_id')); @@ -261,6 +313,8 @@ public function getDisabledDeleteAttribute() return boolval($this->system_flg); } + + // @phpstan-ignore-next-line public function deletingChildren() { $this->custom_form_columns()->delete(); @@ -356,6 +410,8 @@ protected static function boot() /** * get custom column eloquent. (use table) */ + + // @phpstan-ignore-next-line public static function getEloquent($column_obj, $table_obj = null) { if (!isset($column_obj)) { @@ -393,7 +449,8 @@ public static function getEloquent($column_obj, $table_obj = null) return $record->column_name == $column_obj && $record->custom_table_id == $table_obj->id; })->first(); } - /** @phpstan-ignore-next-line unreachable statement */ + + // @phpstan-ignore-next-line return null; } @@ -402,6 +459,8 @@ public static function getEloquent($column_obj, $table_obj = null) * For add table virtual column * @param bool $forceDropIndex drop index. calling when remove column. */ + + // @phpstan-ignore-next-line public function alterColumn($forceDropIndex = false) { // Create index -------------------------------------------------- @@ -509,6 +568,8 @@ public function isMultipleEnabled() * @param array $array * @return void */ + + // @phpstan-ignore-next-line public static function customAvailableCharacters(array $array) { static::$customAvailableCharacters = array_merge($array, static::$customAvailableCharacters); @@ -520,6 +581,8 @@ public static function customAvailableCharacters(array $array) * * @return \Illuminate\Support\Collection */ + + // @phpstan-ignore-next-line public static function getAvailableCharacters() { ///// get system definitions @@ -533,6 +596,8 @@ public static function getAvailableCharacters() ///// add user definitions /** @var Collection $results */ + + // @phpstan-ignore-next-line $results = $results->merge( collect(static::$customAvailableCharacters)->map(function ($val) { return [ @@ -548,6 +613,8 @@ public static function getAvailableCharacters() /** * Create laravel-admin select box options. for column_type "select", "select_valtext" */ + + // @phpstan-ignore-next-line public function createSelectOptions() { // get value @@ -585,6 +652,8 @@ public function createSelectOptions() /** * Create laravel-admin select box option item. */ + + // @phpstan-ignore-next-line protected function setSelectOptionItem($item, &$options, $isValueText) { if (is_string($item)) { @@ -602,6 +671,8 @@ protected function setSelectOptionItem($item, &$options, $isValueText) } } + + // @phpstan-ignore-next-line protected function importSetValue(&$json, $options = []) { // set characters @@ -617,6 +688,8 @@ protected function importSetValue(&$json, $options = []) return ['options.available_characters']; } + + // @phpstan-ignore-next-line public function importSaved($json, $options = []) { if (!$this->index_enabled) { @@ -630,6 +703,8 @@ public function importSaved($json, $options = []) /** * import template (for setting other custom column id) */ + + // @phpstan-ignore-next-line public static function importTemplateLinkage($json, $is_update, $options = []) { $custom_table = array_get($options, 'parent'); @@ -660,6 +735,8 @@ public static function importTemplateLinkage($json, $is_update, $options = []) /** * import template (for setting other custom view id) */ + + // @phpstan-ignore-next-line public static function importTemplateTargetView($json, $is_update, $options = []) { $custom_table = array_get($options, 'parent'); diff --git a/src/Model/CustomColumnMulti.php b/src/Model/CustomColumnMulti.php index b4b8c832c..85f8effcf 100644 --- a/src/Model/CustomColumnMulti.php +++ b/src/Model/CustomColumnMulti.php @@ -26,11 +26,15 @@ class CustomColumnMulti extends ModelBase implements Interfaces\TemplateImporter protected $guarded = ['id', 'suuid']; protected $table = 'custom_column_multisettings'; + + // @phpstan-ignore-next-line public function custom_table(): BelongsTo { return $this->belongsTo(CustomTable::class, 'custom_table_id'); } + + // @phpstan-ignore-next-line public static $templateItems = [ 'excepts' => [ 'export' => [ @@ -142,96 +146,134 @@ public function custom_table(): BelongsTo ] ]; + + // @phpstan-ignore-next-line public function getUnique1Attribute() { return $this->getOption('unique1_id'); } + + // @phpstan-ignore-next-line public function setUnique1Attribute($unique1) { $this->setOption('unique1_id', $unique1); return $this; } + + // @phpstan-ignore-next-line public function getUnique2Attribute() { return $this->getOption('unique2_id'); } + + // @phpstan-ignore-next-line public function setUnique2Attribute($unique2) { $this->setOption('unique2_id', $unique2); return $this; } + + // @phpstan-ignore-next-line public function getUnique3Attribute() { return $this->getOption('unique3_id'); } + + // @phpstan-ignore-next-line public function setUnique3Attribute($unique3) { $this->setOption('unique3_id', $unique3); return $this; } + + // @phpstan-ignore-next-line public function getShareTriggerTypeAttribute() { return $this->getOption('share_trigger_type'); } + + // @phpstan-ignore-next-line public function setShareTriggerTypeAttribute($share_trigger_type) { $this->setOption('share_trigger_type', $share_trigger_type); return $this; } + + // @phpstan-ignore-next-line public function getShareColumnIdAttribute() { return $this->getOption('share_column_id'); } + + // @phpstan-ignore-next-line public function setShareColumnIdAttribute($share_column_id) { $this->setOption('share_column_id', $share_column_id); return $this; } + + // @phpstan-ignore-next-line public function getSharePermissionAttribute() { return $this->getOption('share_permission'); } + + // @phpstan-ignore-next-line public function setSharePermissionAttribute($share_permission) { $this->setOption('share_permission', $share_permission); return $this; } + + // @phpstan-ignore-next-line public function getCompareColumn1IdAttribute() { return $this->getOption('compare_column1_id'); } + + // @phpstan-ignore-next-line public function setCompareColumn1IdAttribute($compare_column) { $this->setOption('compare_column1_id', $compare_column); return $this; } + + // @phpstan-ignore-next-line public function getCompareColumn2IdAttribute() { return $this->getOption('compare_column2_id'); } + + // @phpstan-ignore-next-line public function setCompareColumn2IdAttribute($compare_column) { $this->setOption('compare_column2_id', $compare_column); return $this; } + + // @phpstan-ignore-next-line public function getShareColumnAttribute() { return CustomColumn::getEloquent($this->share_column_id); } + + // @phpstan-ignore-next-line public function getCompareColumn1Attribute() { return CustomColumn::getEloquent($this->compare_column1_id); } + + // @phpstan-ignore-next-line public function getCompareColumn2Attribute() { if (in_array($this->compare_column2_id, CompareColumnType::arrays())) { @@ -240,10 +282,14 @@ public function getCompareColumn2Attribute() return CustomColumn::getEloquent($this->compare_column2_id); } + + // @phpstan-ignore-next-line public function getCompareTypeAttribute() { return $this->getOption('compare_type'); } + + // @phpstan-ignore-next-line public function setCompareTypeAttribute($unique1) { $this->setOption('compare_type', $unique1); @@ -251,10 +297,14 @@ public function setCompareTypeAttribute($unique1) } + + // @phpstan-ignore-next-line public function getTableLabelIdAttribute() { return $this->getOption('table_label_id'); } + + // @phpstan-ignore-next-line public function setTableLabelIdAttribute($value) { $this->setOption('table_label_id', $value); @@ -269,6 +319,8 @@ public function setTableLabelIdAttribute($value) * @param CustomValue|null $custom_value * @return bool */ + + // @phpstan-ignore-next-line public function compareValue($input, $custom_value = null, array $options = []) { $column1 = $this->compare_column1; @@ -343,6 +395,8 @@ public function compareValue($input, $custom_value = null, array $options = []) } } + + // @phpstan-ignore-next-line public function getCompareErrorMessage($transKey, $column1, $column2) { $attribute1 = null; @@ -373,6 +427,8 @@ public function getCompareErrorMessage($transKey, $column1, $column2) * @param array $json * @param array $options */ + + // @phpstan-ignore-next-line protected static function importReplaceJson(&$json, $options = []) { static::importReplaceJsonTableColumn('unique1', $json); @@ -392,6 +448,8 @@ protected static function importReplaceJson(&$json, $options = []) * @param string|null $set_key_name * @return void */ + + // @phpstan-ignore-next-line protected static function importReplaceJsonTableColumn($key, &$json, $set_key_name = null) { $table_name = array_get($json, "options.{$key}_table_name"); diff --git a/src/Model/CustomCopy.php b/src/Model/CustomCopy.php index bdf81fb98..a8eaed282 100644 --- a/src/Model/CustomCopy.php +++ b/src/Model/CustomCopy.php @@ -24,6 +24,8 @@ class CustomCopy extends ModelBase implements Interfaces\TemplateImporterInterfa protected $casts = ['options' => 'json']; + + // @phpstan-ignore-next-line public static $templateItems = [ 'excepts' => ['from_custom_table', 'to_custom_table', 'target_copy_name'], 'langs' => [ @@ -56,22 +58,30 @@ class CustomCopy extends ModelBase implements Interfaces\TemplateImporterInterfa ], ]; + + // @phpstan-ignore-next-line public function from_custom_table(): BelongsTo { return $this->belongsTo(CustomTable::class, 'from_custom_table_id'); } + + // @phpstan-ignore-next-line public function to_custom_table(): BelongsTo { return $this->belongsTo(CustomTable::class, 'to_custom_table_id'); } + + // @phpstan-ignore-next-line public function custom_copy_columns(): HasMany { return $this->hasMany(CustomCopyColumn::class, 'custom_copy_id') ->where('copy_column_type', CopyColumnType::DEFAULT); } + + // @phpstan-ignore-next-line public function custom_copy_input_columns(): HasMany { return $this->hasMany(CustomCopyColumn::class, 'custom_copy_id') @@ -81,6 +91,8 @@ public function custom_copy_input_columns(): HasMany /** * execute data copy with request parameter */ + + // @phpstan-ignore-next-line public function executeRequest($from_custom_value, $request = null) { return $this->execute($from_custom_value, $request->all()); @@ -89,6 +101,8 @@ public function executeRequest($from_custom_value, $request = null) /** * execute data copy */ + + // @phpstan-ignore-next-line public function execute($from_custom_value, $inputs = null) { $to_custom_value = null; @@ -137,6 +151,8 @@ public function execute($from_custom_value, $inputs = null) ]; } + + // @phpstan-ignore-next-line protected static function saveCopyModel( $custom_copy_columns, $custom_copy_input_columns, @@ -196,6 +212,8 @@ protected static function saveCopyModel( return $to_custom_value; } + + // @phpstan-ignore-next-line protected static function getColumnValueKey($condition_item, $column_type_target, $custom_column) { return $condition_item ? $condition_item->getColumnValueKey($column_type_target, $custom_column) : null; @@ -205,11 +223,15 @@ protected static function getColumnValueKey($condition_item, $column_type_target * get eloquent using request settion. * now only support only id. */ + + // @phpstan-ignore-next-line public static function getEloquent($id, $withs = []) { return static::getEloquentDefault($id, $withs); } + + // @phpstan-ignore-next-line public function deletingChildren() { $this->custom_copy_columns()->delete(); diff --git a/src/Model/CustomCopyColumn.php b/src/Model/CustomCopyColumn.php index 5ad480eb1..b9bad497b 100644 --- a/src/Model/CustomCopyColumn.php +++ b/src/Model/CustomCopyColumn.php @@ -34,6 +34,8 @@ class CustomCopyColumn extends ModelBase implements Interfaces\TemplateImporterI use Traits\TemplateTrait; protected $appends = ['from_column_target', 'to_column_target']; + + // @phpstan-ignore-next-line public static $templateItems = [ //'excepts' => ['custom_copy_id', 'from_custom_column', 'to_custom_column', 'from_column_target', 'to_column_target', 'from_column_target_id', 'to_column_target_id', 'from_column_table_id', 'to_column_table_id'], 'excepts' => [ @@ -73,36 +75,50 @@ class CustomCopyColumn extends ModelBase implements Interfaces\TemplateImporterI ] ]; + + // @phpstan-ignore-next-line public function custom_copy(): BelongsTo { return $this->belongsTo(CustomCopy::class, 'custom_copy_id'); } + + // @phpstan-ignore-next-line public function from_custom_column(): BelongsTo { return $this->belongsTo(CustomColumn::class, 'from_column_target_id'); } + + // @phpstan-ignore-next-line public function to_custom_column(): BelongsTo { return $this->belongsTo(CustomColumn::class, 'to_column_target_id'); } + + // @phpstan-ignore-next-line public function from_custom_table(): BelongsTo { return $this->belongsTo(CustomTable::class, 'from_column_table_id'); } + + // @phpstan-ignore-next-line public function to_custom_table(): BelongsTo { return $this->belongsTo(CustomTable::class, 'to_column_table_id'); } + + // @phpstan-ignore-next-line public function getFromCustomTableCacheAttribute() { return CustomTable::getEloquent($this->from_column_table_id); } + + // @phpstan-ignore-next-line public function getToCustomTableCacheAttribute() { return CustomTable::getEloquent($this->to_column_table_id); @@ -112,6 +128,8 @@ public function getToCustomTableCacheAttribute() * get CopyColumnTarget. * * we have to convert string if view_column_type is system for custom view form-display* */ + + // @phpstan-ignore-next-line public function getFromColumnTargetAttribute() { return $this->getViewColumnTarget('from_column_table_id', 'from_column_type', 'from_column_target_id'); @@ -121,6 +139,8 @@ public function getFromColumnTargetAttribute() * set CopyColumnTarget. * * we have to convert int if view_column_type is system for custom view form-display* */ + + // @phpstan-ignore-next-line public function setFromColumnTargetAttribute($copy_column_target) { $this->setViewColumnTarget($copy_column_target, 'custom_copy', 'from_column_table_id', 'from_column_type', 'from_column_target_id'); @@ -130,6 +150,8 @@ public function setFromColumnTargetAttribute($copy_column_target) * get ViewColumnTarget. * * we have to convert string if view_column_type is system for custom view form-display* */ + + // @phpstan-ignore-next-line public function getToColumnTargetAttribute() { return $this->getViewColumnTarget('to_column_table_id', 'to_column_type', 'to_column_target_id'); @@ -139,6 +161,8 @@ public function getToColumnTargetAttribute() * set ViewColumnTarget. * * we have to convert int if view_column_type is system for custom view form-display* */ + + // @phpstan-ignore-next-line public function setToColumnTargetAttribute($copy_column_target) { $this->setViewColumnTarget($copy_column_target, 'custom_copy', 'to_column_table_id', 'to_column_type', 'to_column_target_id'); @@ -147,6 +171,8 @@ public function setToColumnTargetAttribute($copy_column_target) /** * get Table And Column Name */ + + // @phpstan-ignore-next-line protected function getFromUniqueKeyValues() { return $this->getCopyColumnUniqueKeyValues('from_custom_table', 'from_custom_column', 'from_column_type', 'from_column_target_id'); @@ -155,6 +181,8 @@ protected function getFromUniqueKeyValues() /** * get Table And Column Name */ + + // @phpstan-ignore-next-line protected function getToUniqueKeyValues() { return $this->getCopyColumnUniqueKeyValues('to_custom_table', 'to_custom_column', 'to_column_type', 'to_column_target_id'); @@ -163,6 +191,8 @@ protected function getToUniqueKeyValues() /** * getConditionTypeFromItemAttribute */ + + // @phpstan-ignore-next-line public function getFromConditionItemAttribute() { return ConditionItemBase::getItem($this->from_custom_table_cache, $this->from_column_type, $this->from_column_target_id); @@ -171,6 +201,8 @@ public function getFromConditionItemAttribute() /** * getConditionTypeFromItemAttribute */ + + // @phpstan-ignore-next-line public function getToConditionItemAttribute() { return ConditionItemBase::getItem($this->to_custom_table_cache, $this->to_column_type, $this->to_column_target_id); @@ -180,6 +212,8 @@ public function getToConditionItemAttribute() /** * get Table And Column Name for custom copy column */ + + // @phpstan-ignore-next-line protected function getCopyColumnUniqueKeyValues($column_table_key, $column_column_key, $column_type_key, $column_target_id_key) { // get custom table. @@ -212,6 +246,8 @@ protected function getCopyColumnUniqueKeyValues($column_table_key, $column_colum return []; } + + // @phpstan-ignore-next-line public static function importReplaceJson(&$json, $options = []) { $custom_copy = array_get($options, 'parent'); diff --git a/src/Model/CustomForm.php b/src/Model/CustomForm.php index 7580c2181..1df540689 100644 --- a/src/Model/CustomForm.php +++ b/src/Model/CustomForm.php @@ -32,6 +32,8 @@ class CustomForm extends ModelBase implements Interfaces\TemplateImporterInterfa protected $casts = ['options' => 'json']; + + // @phpstan-ignore-next-line public static $templateItems = [ 'excepts' => ['custom_table', 'form_name'], 'langs' => [ @@ -75,36 +77,50 @@ class CustomForm extends ModelBase implements Interfaces\TemplateImporterInterfa */ private $_show_item; + + // @phpstan-ignore-next-line public function custom_table(): BelongsTo { return $this->belongsTo(CustomTable::class, 'custom_table_id'); } + + // @phpstan-ignore-next-line public function custom_form_blocks(): HasMany { return $this->hasMany(CustomFormBlock::class, 'custom_form_id'); } + + // @phpstan-ignore-next-line public function custom_form_priorities(): HasMany { return $this->hasMany(CustomFormPriority::class, 'custom_form_id'); } + + // @phpstan-ignore-next-line public function public_forms(): HasMany { return $this->hasMany(PublicForm::class, 'custom_form_id'); } + + // @phpstan-ignore-next-line public function custom_form_columns(): HasManyThrough { return $this->hasManyThrough(CustomFormColumn::class, CustomFormBlock::class, 'custom_form_id', 'custom_form_block_id'); } + + // @phpstan-ignore-next-line public function getCustomTableCacheAttribute() { return CustomTable::getEloquent($this->custom_table_id); } + + // @phpstan-ignore-next-line public function getCustomFormBlocksCacheAttribute() { return $this->hasManyCache(CustomFormBlock::class, 'custom_form_id'); @@ -142,19 +158,27 @@ public function getFormItemAttribute() return $this->_form_item; } + + // @phpstan-ignore-next-line public function getFormLabelTypeAttribute() { return $this->getOption('form_label_type', FormLabelType::HORIZONTAL); } + + // @phpstan-ignore-next-line public function setFormLabelTypeAttribute($form_label_type) { $this->setOption('form_label_type', $form_label_type); return $this; } + + // @phpstan-ignore-next-line public function getShowGridTypeAttribute() { return $this->getOption('show_grid_type', ShowGridType::GRID); } + + // @phpstan-ignore-next-line public function setShowGridTypeAttribute($form_label_type) { $this->setOption('show_grid_type', $form_label_type); @@ -193,6 +217,8 @@ public static function getDefault($tableObj) } // get form block + + // @phpstan-ignore-next-line $form_block = $form->custom_form_blocks() ->where('form_block_type', FormBlockType::DEFAULT) ->first(); @@ -202,12 +228,16 @@ public static function getDefault($tableObj) $form_block->form_block_type = FormBlockType::DEFAULT; $form_block->form_block_target_table_id = $tableObj->id; $form_block->available = true; + + // @phpstan-ignore-next-line $form->custom_form_blocks()->save($form_block); // add columns. $form_columns = []; // get target block as default. + + // @phpstan-ignore-next-line $form_block = $form->custom_form_blocks() ->where('form_block_type', FormBlockType::DEFAULT) ->first(); @@ -226,9 +256,13 @@ public static function getDefault($tableObj) $form_block->custom_form_columns()->saveMany($form_columns); // re-get form + + // @phpstan-ignore-next-line $form = static::find($form->id); } + + // @phpstan-ignore-next-line return $form; } @@ -236,11 +270,15 @@ public static function getDefault($tableObj) * get eloquent using request settion. * now only support only id. */ + + // @phpstan-ignore-next-line public static function getEloquent($id, $withs = []) { return static::getEloquentDefault($id, $withs); } + + // @phpstan-ignore-next-line public function deletingChildren() { foreach ($this->custom_form_blocks as $item) { diff --git a/src/Model/CustomFormBlock.php b/src/Model/CustomFormBlock.php index 897a4a878..6b1b3dd89 100644 --- a/src/Model/CustomFormBlock.php +++ b/src/Model/CustomFormBlock.php @@ -35,6 +35,8 @@ class CustomFormBlock extends ModelBase implements Interfaces\TemplateImporterIn */ protected $_request_key; + + // @phpstan-ignore-next-line public static $templateItems = [ 'excepts' => ['custom_form_id', 'target_table'], 'langs' => [ @@ -67,47 +69,65 @@ class CustomFormBlock extends ModelBase implements Interfaces\TemplateImporterIn ], ]; + + // @phpstan-ignore-next-line public function custom_form(): BelongsTo { return $this->belongsTo(CustomForm::class, 'custom_form_id'); } + + // @phpstan-ignore-next-line public function custom_form_columns(): HasMany { return $this->hasMany(CustomFormColumn::class, 'custom_form_block_id'); } + + // @phpstan-ignore-next-line public function target_table(): BelongsTo { return $this->belongsTo(CustomTable::class, 'form_block_target_table_id'); } + + // @phpstan-ignore-next-line public function getCustomFormCacheAttribute() { return CustomForm::getEloquent($this->custom_form_id); } + + // @phpstan-ignore-next-line public function getTargetTableCacheAttribute() { return CustomTable::getEloquent($this->form_block_target_table_id); } + + // @phpstan-ignore-next-line public function getFormTableCacheAttribute() { $custom_form = $this->custom_form_cache; return $custom_form ? $custom_form->custom_table_cache : null; } + + // @phpstan-ignore-next-line public function getCustomFormColumnsCacheAttribute() { return $this->hasManyCache(CustomFormColumn::class, 'custom_form_block_id'); } + + // @phpstan-ignore-next-line public function getRequestKeyAttribute() { return $this->_request_key ?? $this->id; } + + // @phpstan-ignore-next-line public function setRequestKeyAttribute($request_key) { $this->_request_key = $request_key; @@ -115,6 +135,8 @@ public function setRequestKeyAttribute($request_key) } + + // @phpstan-ignore-next-line public function isMultipleColumn() { foreach ($this->custom_form_columns as $custom_form_column) { @@ -131,6 +153,8 @@ public function isMultipleColumn() * * @return array offset 0 : CustomRelation, 1:relation name, 2:block label. */ + + // @phpstan-ignore-next-line public function getRelationInfo(?CustomTable $custom_form_table = null) { $target_table = $this->target_table; @@ -162,6 +186,8 @@ public function getRelationInfo(?CustomTable $custom_form_table = null) return [$relation, $relation_name, $block_label]; } + + // @phpstan-ignore-next-line protected static function importReplaceJson(&$json, $options = []) { // get custom table @@ -192,6 +218,8 @@ protected static function importReplaceJson(&$json, $options = []) } } + + // @phpstan-ignore-next-line protected function importSetValue(&$json, $options = []) { if (!$this->exists) { @@ -199,6 +227,8 @@ protected function importSetValue(&$json, $options = []) } } + + // @phpstan-ignore-next-line public function deletingChildren() { $this->custom_form_columns()->withoutGlobalScope('remove_system_column')->delete(); diff --git a/src/Model/CustomFormColumn.php b/src/Model/CustomFormColumn.php index f1725c497..a2e19ba09 100644 --- a/src/Model/CustomFormColumn.php +++ b/src/Model/CustomFormColumn.php @@ -32,6 +32,8 @@ class CustomFormColumn extends ModelBase implements Interfaces\TemplateImporterI protected $casts = ['options' => 'json']; protected $appends = ['form_column_target']; + + // @phpstan-ignore-next-line protected $with = ['custom_column']; /** @@ -48,6 +50,8 @@ class CustomFormColumn extends ModelBase implements Interfaces\TemplateImporterI */ protected $_request_key; + + // @phpstan-ignore-next-line public static $templateItems = [ 'excepts' => ['custom_column', 'form_column_target', 'options.changedata_target_column_id', 'options.changedata_column_id', 'options.relation_filter_target_column_id'], 'langs' => [ @@ -113,16 +117,22 @@ class CustomFormColumn extends ModelBase implements Interfaces\TemplateImporterI ] ]; + + // @phpstan-ignore-next-line public function custom_form_block(): BelongsTo { return $this->belongsTo(CustomFormBlock::class, 'custom_form_block_id'); } + + // @phpstan-ignore-next-line public function custom_column(): BelongsTo { return $this->belongsTo(CustomColumn::class, 'form_column_target_id'); } + + // @phpstan-ignore-next-line protected function getFormColumnTargetAttribute() { if ($this->form_column_type == FormColumnType::COLUMN) { @@ -133,6 +143,8 @@ protected function getFormColumnTargetAttribute() return null; } + + // @phpstan-ignore-next-line public function getColumnItemAttribute() { // if tagret is number, column type is column. @@ -145,11 +157,15 @@ public function getColumnItemAttribute() } } + + // @phpstan-ignore-next-line protected function getCustomFormBlockCacheAttribute() { return CustomFormBlock::getEloquentDefault($this->custom_form_block_id); } + + // @phpstan-ignore-next-line protected function getCustomColumnCacheAttribute() { if ($this->form_column_type != FormColumnType::COLUMN) { @@ -159,35 +175,47 @@ protected function getCustomColumnCacheAttribute() return CustomColumn::getEloquent($this->form_column_target_id); } + + // @phpstan-ignore-next-line public function getTargetTableCacheAttribute() { $custom_form_block = $this->custom_form_block_cache ?: $this->custom_form_block; return $custom_form_block ? $custom_form_block->target_table_cache : null; } + + // @phpstan-ignore-next-line public function getFormTableCacheAttribute() { $custom_form_block = $this->custom_form_block_cache ?: $this->custom_form_block; return $custom_form_block ? $custom_form_block->form_table_cache : null; } + + // @phpstan-ignore-next-line protected function getDeleteFlgAttribute() { return $this->_delete_flg; } + + // @phpstan-ignore-next-line protected function setDeleteFlgAttribute($delete_flg) { $this->_delete_flg = $delete_flg; return $this; } + + // @phpstan-ignore-next-line public function getRequestKeyAttribute() { return $this->_request_key ?? $this->id; } + + // @phpstan-ignore-next-line public function setRequestKeyAttribute($request_key) { $this->_request_key = $request_key; @@ -198,6 +226,8 @@ public function setRequestKeyAttribute($request_key) /** * get Table And Column Name */ + + // @phpstan-ignore-next-line protected function getUniqueKeyValuesFormColumn() { switch ($this->form_column_type) { @@ -213,6 +243,8 @@ protected function getUniqueKeyValuesFormColumn() return []; } + + // @phpstan-ignore-next-line protected static function importReplaceJson(&$json, $options = []) { // set form column type @@ -254,6 +286,8 @@ protected static function importReplaceJson(&$json, $options = []) * @param string $column_key_id * @return void */ + + // @phpstan-ignore-next-line protected static function replaceChangedata(&$json, $table_key_name, $column_key_name, $column_key_id) { // set changedata_custom_table_id @@ -283,6 +317,8 @@ protected static function replaceChangedata(&$json, $table_key_name, $column_key array_forget($json, $column_key_name); } + + // @phpstan-ignore-next-line protected function importSetValue(&$json, $options = []) { if (!$this->exists) { diff --git a/src/Model/CustomFormPriority.php b/src/Model/CustomFormPriority.php index a42eeec3e..dd9f3555c 100644 --- a/src/Model/CustomFormPriority.php +++ b/src/Model/CustomFormPriority.php @@ -17,11 +17,15 @@ class CustomFormPriority extends ModelBase protected $appends = ['form_priority_text', 'condition_join', 'condition_reverse']; protected $casts = ['options' => 'json']; + + // @phpstan-ignore-next-line public function custom_form() { return $this->belongsTo(CustomForm::class, 'custom_form_id'); } + + // @phpstan-ignore-next-line public function custom_form_priority_conditions() { return $this->morphMany(Condition::class, 'morph', 'morph_type', 'morph_id'); @@ -30,6 +34,8 @@ public function custom_form_priority_conditions() /** * check if custom_value and user(organization, role) match for conditions(with reverse option). */ + + // @phpstan-ignore-next-line public function isMatchCondition($custom_value) { $result = $this->_isMatchCondition($custom_value); @@ -42,6 +48,8 @@ public function isMatchCondition($custom_value) /** * check if custom_value and user(organization, role) match for conditions. */ + + // @phpstan-ignore-next-line protected function _isMatchCondition($custom_value) { $is_or = $this->condition_join == 'or'; @@ -62,6 +70,8 @@ protected function _isMatchCondition($custom_value) /** * get filter condition text for grid. */ + + // @phpstan-ignore-next-line public function getFormPriorityTextAttribute() { if (isset($this->custom_form_priority_conditions)) { @@ -69,7 +79,8 @@ public function getFormPriorityTextAttribute() foreach ($this->custom_form_priority_conditions as $condition) { $list[] = $condition->condition_text; } - /** @phpstan-ignore-next-line Expression on left side of ?? is not nullable. probably it will not show 'and'. */ + + // @phpstan-ignore-next-line $glue = exmtrans('common.join_'.$this->condition_join??'and'); $text = implode($glue, $list); if (boolval($this->condition_reverse)) { @@ -80,11 +91,15 @@ public function getFormPriorityTextAttribute() return ''; } + + // @phpstan-ignore-next-line public function getConditionJoinAttribute() { return $this->getOption('condition_join'); } + + // @phpstan-ignore-next-line public function setConditionJoinAttribute($val) { $this->setOption('condition_join', $val); @@ -92,11 +107,15 @@ public function setConditionJoinAttribute($val) return $this; } + + // @phpstan-ignore-next-line public function getConditionReverseAttribute() { return $this->getOption('condition_reverse'); } + + // @phpstan-ignore-next-line public function setConditionReverseAttribute($val) { $this->setOption('condition_reverse', $val); @@ -104,6 +123,8 @@ public function setConditionReverseAttribute($val) return $this; } + + // @phpstan-ignore-next-line public function deletingChildren() { $this->custom_form_priority_conditions()->delete(); diff --git a/src/Model/CustomOperation.php b/src/Model/CustomOperation.php index 93f9c330a..6333f936b 100644 --- a/src/Model/CustomOperation.php +++ b/src/Model/CustomOperation.php @@ -32,28 +32,38 @@ class CustomOperation extends ModelBase protected $appends = ['condition_join', 'active_flg', 'condition_reverse']; + + // @phpstan-ignore-next-line public function custom_table(): BelongsTo { return $this->belongsTo(CustomTable::class, 'custom_table_id'); } + + // @phpstan-ignore-next-line public function custom_operation_columns(): HasMany { return $this->hasMany(CustomOperationColumn::class, 'custom_operation_id') ->where('operation_column_type', CopyColumnType::DEFAULT); } + + // @phpstan-ignore-next-line public function custom_operation_input_columns(): HasMany { return $this->hasMany(CustomOperationColumn::class, 'custom_operation_id') ->where('operation_column_type', CopyColumnType::INPUT); } + + // @phpstan-ignore-next-line public function custom_operation_conditions(): MorphMany { return $this->morphMany(Condition::class, 'morph', 'morph_type', 'morph_id'); } + + // @phpstan-ignore-next-line public function getCustomTableCacheAttribute() { return CustomTable::getEloquent($this->custom_table_id); @@ -63,16 +73,22 @@ public function getCustomTableCacheAttribute() * get eloquent using request settion. * now only support only id. */ + + // @phpstan-ignore-next-line public static function getEloquent($id, $withs = []) { return static::getEloquentDefault($id, $withs); } + + // @phpstan-ignore-next-line public function getConditionJoinAttribute() { return $this->getOption('condition_join'); } + + // @phpstan-ignore-next-line public function setConditionJoinAttribute($val) { $this->setOption('condition_join', $val); @@ -80,11 +96,15 @@ public function setConditionJoinAttribute($val) return $this; } + + // @phpstan-ignore-next-line public function getConditionReverseAttribute() { return $this->getOption('condition_reverse'); } + + // @phpstan-ignore-next-line public function setConditionReverseAttribute($val) { $this->setOption('condition_reverse', $val); @@ -92,12 +112,16 @@ public function setConditionReverseAttribute($val) return $this; } + + // @phpstan-ignore-next-line public function getActiveFlgAttribute() { $active_flg = $this->getOption('active_flg'); return is_null($active_flg) || $active_flg; } + + // @phpstan-ignore-next-line public function setActiveFlgAttribute($val) { $this->setOption('active_flg', $val); @@ -105,6 +129,8 @@ public function setActiveFlgAttribute($val) return $this; } + + // @phpstan-ignore-next-line public function deletingChildren() { $this->custom_operation_columns()->delete(); @@ -128,6 +154,8 @@ protected static function boot() * @param CustomOperationType|array $operation_types * @return boolean is match operation type and conditions. */ + + // @phpstan-ignore-next-line public function isOperationTarget($custom_value, $operation_types) { if (!$this->matchOperationType($operation_types)) { @@ -142,6 +170,8 @@ public function isOperationTarget($custom_value, $operation_types) * @param CustomOperationType|array $operation_types * @return bool is match operation type. if $operation_types is multiple, whether contains. */ + + // @phpstan-ignore-next-line public function matchOperationType($operation_types) { $operation_types = toArray($operation_types); @@ -198,6 +228,8 @@ public function _isMatchCondition($custom_value) * @param CustomValue $custom_value * @param boolean $is_save */ + + // @phpstan-ignore-next-line public static function operationExecuteEvent($operation_types, &$custom_value, $is_save = false) { $custom_table = $custom_value->custom_table; @@ -228,6 +260,8 @@ public static function operationExecuteEvent($operation_types, &$custom_value, $ * @param array $inputs input from dialog form * @return bool success or not */ + + // @phpstan-ignore-next-line public function execute($custom_table, $id, $inputs = null) { $ids = stringToArray($id); @@ -256,7 +290,8 @@ public function execute($custom_table, $id, $inputs = null) } catch (\Exception $ex) { \DB::rollback(); if ($ex instanceof ValidationException) { - /** @phpstan-ignore-next-line */ + + // @phpstan-ignore-next-line return array_first(array_flatten($ex->validator->getMessages())); } throw $ex; @@ -272,8 +307,12 @@ public function execute($custom_table, $id, $inputs = null) * @param array $inputs * @return array "value"'s array. */ + + // @phpstan-ignore-next-line protected function getUpdateValues($model, $inputs = null) { + + // @phpstan-ignore-next-line $updates = collect($this->custom_operation_columns)->mapWithKeys(function ($operation_column) use ($model) { $custom_column = $operation_column->custom_column; if (is_nullorempty($custom_column)) { diff --git a/src/Model/CustomOperationColumn.php b/src/Model/CustomOperationColumn.php index 7454f1b34..27c50c080 100644 --- a/src/Model/CustomOperationColumn.php +++ b/src/Model/CustomOperationColumn.php @@ -25,10 +25,14 @@ class CustomOperationColumn extends ModelBase protected $appends = ['view_column_target', 'operation_update_type']; protected $casts = ['options' => 'json']; + + // @phpstan-ignore-next-line public function custom_operation() { return $this->belongsTo(CustomOperation::class, 'custom_operation_id'); } + + // @phpstan-ignore-next-line public function getViewColumnTableIdAttribute() { $parent = $this->custom_operation; @@ -39,6 +43,8 @@ public function getViewColumnTableIdAttribute() * set ViewColumnTarget. * * we have to convert int if view_column_type is system for custom view form-display* */ + + // @phpstan-ignore-next-line public function setViewColumnTargetAttribute($view_column_target) { list($column_type, $column_table_id, $column_type_target) = $this->getViewColumnTargetItems($view_column_target, 'custom_operation'); @@ -50,6 +56,8 @@ public function setViewColumnTargetAttribute($view_column_target) /** * get edited view_filter_condition_value_text. */ + + // @phpstan-ignore-next-line public function getUpdateValueTextAttribute() { $update_value_text = array_get($this->attributes, 'update_value_text'); @@ -72,6 +80,8 @@ public function getUpdateValueTextAttribute() * set view_filter_condition_value_text. * * we have to convert int if view_filter_condition_value is array* */ + + // @phpstan-ignore-next-line public function setUpdateValueTextAttribute($update_value) { if (is_array($update_value)) { @@ -84,11 +94,15 @@ public function setUpdateValueTextAttribute($update_value) } } + + // @phpstan-ignore-next-line public function getOperationUpdateTypeAttribute() { return $this->getOption('operation_update_type'); } + + // @phpstan-ignore-next-line public function setOperationUpdateTypeAttribute($operation_update_type) { return $this->setOption('operation_update_type', $operation_update_type); @@ -98,6 +112,8 @@ public function setOperationUpdateTypeAttribute($operation_update_type) * get eloquent using request settion. * now only support only id. */ + + // @phpstan-ignore-next-line public static function getEloquent($id, $withs = []) { return static::getEloquentDefault($id, $withs); diff --git a/src/Model/CustomRelation.php b/src/Model/CustomRelation.php index ab18a7f97..68e8841ae 100644 --- a/src/Model/CustomRelation.php +++ b/src/Model/CustomRelation.php @@ -26,6 +26,8 @@ class CustomRelation extends ModelBase implements Interfaces\TemplateImporterInt //protected $with = ['parent_custom_table', 'child_custom_table']; protected $casts = ['options' => 'json']; + + // @phpstan-ignore-next-line public static $templateItems = [ 'excepts' => ['parent_custom_table', 'child_custom_table'], 'langs' => [ @@ -80,20 +82,28 @@ class CustomRelation extends ModelBase implements Interfaces\TemplateImporterInt ] ]; + + // @phpstan-ignore-next-line public function parent_custom_table(): BelongsTo { return $this->belongsTo(CustomTable::class, 'parent_custom_table_id'); } + + // @phpstan-ignore-next-line public function child_custom_table(): BelongsTo { return $this->belongsTo(CustomTable::class, 'child_custom_table_id'); } + + // @phpstan-ignore-next-line public function getParentCustomTableCacheAttribute() { return CustomTable::getEloquent($this->parent_custom_table_id); } + + // @phpstan-ignore-next-line public function getChildCustomTableCacheAttribute() { return CustomTable::getEloquent($this->child_custom_table_id); @@ -102,6 +112,8 @@ public function getChildCustomTableCacheAttribute() /** * get relations by parent table */ + + // @phpstan-ignore-next-line public static function getRelationsByParent($parent_table, $relation_type = null, $reget_database = false) { $parent_table = CustomTable::getEloquent($parent_table); @@ -120,6 +132,8 @@ public static function getRelationsByParent($parent_table, $relation_type = null /** * get relation by child table. (Only one record) */ + + // @phpstan-ignore-next-line public static function getRelationByChild($child_table, $relation_type = null, $reget_database = false) { $items = static::getRelationsByChild($child_table, $relation_type, $reget_database); @@ -132,6 +146,8 @@ public static function getRelationByChild($child_table, $relation_type = null, $ /** * get relation by child table. */ + + // @phpstan-ignore-next-line public static function getRelationsByChild($child_table, $relation_type = null, $reget_database = false) { $child_table = CustomTable::getEloquent($child_table); @@ -151,6 +167,8 @@ public static function getRelationsByChild($child_table, $relation_type = null, /** * get relation by parent and child table. */ + + // @phpstan-ignore-next-line public static function getRelationByParentChild($parent_table, $child_table, $relation_type = null, $reget_database = false) { $parent_table = CustomTable::getEloquent($parent_table); @@ -203,6 +221,8 @@ public static function getRelationNamebyTables($parent, $child) * @param boolean $isCallAsParent * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany|\Illuminate\Database\Eloquent\Relations\MorphMany|\Illuminate\Database\Eloquent\Relations\BelongsTo */ + + // @phpstan-ignore-next-line public function getDynamicRelationValue(CustomValue $custom_value, bool $isCallAsParent) { if ($isCallAsParent) { @@ -218,6 +238,7 @@ public function getDynamicRelationValue(CustomValue $custom_value, bool $isCallA else { // Create pivot table if (!hasTable($pivot_table_name)) { + // Laravel facade Schema not recognized \Schema::createRelationValueTable($pivot_table_name); } @@ -236,6 +257,7 @@ public function getDynamicRelationValue(CustomValue $custom_value, bool $isCallA else { // Create pivot table if (!hasTable($pivot_table_name)) { + // Laravel facade Schema not recognized \Schema::createRelationValueTable($pivot_table_name); } @@ -247,6 +269,8 @@ public function getDynamicRelationValue(CustomValue $custom_value, bool $isCallA /** * get sheet name for excel, csv */ + + // @phpstan-ignore-next-line public function getSheetName() { if ($this->relation_type == RelationType::MANY_TO_MANY) { @@ -267,21 +291,29 @@ public function getSheetName() * get eloquent using request settion. * now only support only id. */ + + // @phpstan-ignore-next-line public static function getEloquent($id, $withs = []) { return static::getEloquentCache($id, $withs); } + + // @phpstan-ignore-next-line public function getParentImportColumnAttribute() { return CustomColumn::getEloquent($this->getOption('parent_import_column_id')); } + + // @phpstan-ignore-next-line public function getParentExportColumnAttribute() { return CustomColumn::getEloquent($this->getOption('parent_export_column_id')); } + + // @phpstan-ignore-next-line public static function importReplaceJson(&$json, $options = []) { static::importReplaceJsonCustomColumn($json, 'options.parent_import_column_id', 'options.parent_import_column_name', 'options.parent_import_table_name', $options); @@ -332,6 +364,8 @@ protected static function boot() /** * Delete children items */ + + // @phpstan-ignore-next-line public function deletingChildren() { $target = $this->parent_custom_table; diff --git a/src/Model/CustomTable.php b/src/Model/CustomTable.php index a27056130..658e3c69d 100644 --- a/src/Model/CustomTable.php +++ b/src/Model/CustomTable.php @@ -48,6 +48,16 @@ * @property mixed $showlist_flg * @property mixed $table_view_name * @property mixed $options + * @property-read \Illuminate\Database\Eloquent\Collection $custom_columns + * @property-read \Illuminate\Database\Eloquent\Collection $custom_columns_cache + * @property-read \Illuminate\Database\Eloquent\Collection $custom_views + * @property-read \Illuminate\Database\Eloquent\Collection $custom_forms + * @property-read \Illuminate\Database\Eloquent\Collection $from_custom_copies + * @property-read \Illuminate\Database\Eloquent\Collection $to_custom_copies + * @property-read \Illuminate\Database\Eloquent\Collection $custom_form_block_target_tables + * @property-read \Illuminate\Database\Eloquent\Collection $operations + * @property-read \Illuminate\Database\Eloquent\Collection $custom_form_priorities + * @property-read \Illuminate\Database\Eloquent\Collection $table_labels * @method static int count($columns = '*') * @method static ExtendedBuilder orderBy($column, $direction = 'asc') * @method static ExtendedBuilder whereNotIn($column, $values, $boolean = 'and') @@ -66,6 +76,8 @@ class CustomTable extends ModelBase implements Interfaces\TemplateImporterInterf protected $casts = ['options' => 'json']; protected $guarded = ['id', 'suuid', 'system_flg']; + + // @phpstan-ignore-next-line public static $templateItems = [ 'excepts' => ['suuid'], 'uniqueKeys' => ['table_name'], @@ -83,13 +95,19 @@ class CustomTable extends ModelBase implements Interfaces\TemplateImporterInterf /** * Getted custom columns. if call attributes "custom_columns_cache", already called, return this value. */ + + // @phpstan-ignore-next-line protected $cached_custom_columns = []; + + // @phpstan-ignore-next-line public function custom_columns(): HasMany { return $this->hasMany(CustomColumn::class, 'custom_table_id'); } + + // @phpstan-ignore-next-line public function custom_views(): HasMany { return $this->hasMany(CustomView::class, 'custom_table_id') @@ -97,36 +115,50 @@ public function custom_views(): HasMany ->orderBy('id'); } + + // @phpstan-ignore-next-line public function custom_forms(): HasMany { return $this->hasMany(CustomForm::class, 'custom_table_id'); } + + // @phpstan-ignore-next-line public function custom_operations(): HasMany { return $this->hasMany(CustomOperation::class, 'custom_table_id'); } + + // @phpstan-ignore-next-line public function custom_relations(): HasMany { return $this->hasMany(CustomRelation::class, 'parent_custom_table_id'); } + + // @phpstan-ignore-next-line public function child_custom_relations(): HasMany { return $this->hasMany(CustomRelation::class, 'child_custom_table_id'); } + + // @phpstan-ignore-next-line public function from_custom_copies(): HasMany { return $this->hasMany(CustomCopy::class, 'from_custom_table_id'); } + + // @phpstan-ignore-next-line public function to_custom_copies(): HasMany { return $this->hasMany(CustomCopy::class, 'to_custom_table_id'); } + + // @phpstan-ignore-next-line public function notifies(): HasMany { return $this->hasMany(Notify::class, 'target_id') @@ -134,55 +166,78 @@ public function notifies(): HasMany ->where('active_flg', 1); } + /** + * @return HasMany + */ + + // @phpstan-ignore-next-line public function notify_all() { return $this->hasMany(Notify::class, 'target_id') ->whereIn('notify_trigger', NotifyTrigger::CUSTOM_TABLES()); } + + // @phpstan-ignore-next-line public function operations(): HasMany { return $this->hasMany(CustomOperation::class, 'custom_table_id'); } + + // @phpstan-ignore-next-line public function custom_form_block_target_tables(): HasMany { return $this->hasMany(CustomFormBlock::class, 'form_block_target_table_id'); } + + // @phpstan-ignore-next-line public function custom_column_multisettings(): HasMany { return $this->hasMany(CustomColumnMulti::class, 'custom_table_id'); } + + // @phpstan-ignore-next-line public function custom_form_priorities(): HasManyThrough { return $this->hasManyThrough(CustomFormPriority::class, CustomForm::class, 'custom_table_id', 'custom_form_id'); } + + // @phpstan-ignore-next-line public function workflow_tables(): HasMany { return $this->hasMany(WorkflowTable::class, 'custom_table_id'); } + + // @phpstan-ignore-next-line public function multi_uniques(): HasMany { return $this->hasMany(CustomColumnMulti::class, 'custom_table_id') ->where('multisetting_type', MultisettingType::MULTI_UNIQUES); } + + // @phpstan-ignore-next-line public function table_labels(): HasMany { return $this->hasMany(CustomColumnMulti::class, 'custom_table_id') ->where('multisetting_type', MultisettingType::TABLE_LABELS); } + + // @phpstan-ignore-next-line public function compare_columns(): HasMany { return $this->hasMany(CustomColumnMulti::class, 'custom_table_id') ->where('multisetting_type', MultisettingType::COMPARE_COLUMNS); } + + // @phpstan-ignore-next-line public function share_settings(): HasMany { return $this->hasMany(CustomColumnMulti::class, 'custom_table_id') @@ -207,6 +262,8 @@ public function getDisabledDeleteAttribute() * @param int|string $id * @return array [boolean, string] status, error message. */ + + // @phpstan-ignore-next-line public static function validateDestroy($id) { // check select_table @@ -236,6 +293,8 @@ public static function validateDestroy($id) /** * get Custom columns using cache */ + + // @phpstan-ignore-next-line public function getCustomColumnsCacheAttribute() { if (!empty($this->cached_custom_columns)) { @@ -253,6 +312,8 @@ public function getCustomColumnsCacheAttribute() * @param string|array|Collection $column_types * @return Collection */ + + // @phpstan-ignore-next-line public function getFilteredTypeColumns($column_types) { return $this->custom_columns_cache->filter(function (CustomColumn $custom_column) use ($column_types) { @@ -273,17 +334,23 @@ public function getFilteredTypeColumns($column_types) /** * Get Columns where select_target_table's id is this table. */ + + // @phpstan-ignore-next-line public function getSelectedItems() { return CustomColumn::where('options->select_target_table', $this->id) ->get(); } + + // @phpstan-ignore-next-line public function scopeSearchEnabled($query) { return $query->whereIn('options->search_enabled', [1, "1", true]); } + + // @phpstan-ignore-next-line public function getSelectTables() { $list = $this->custom_columns_cache->mapWithKeys(function ($item) { @@ -334,6 +401,8 @@ public function getPriorityForm($id = null) * @param bool $skipSelf if true, skip column for relation target is self. * @return Collection */ + + // @phpstan-ignore-next-line public function getSelectTableColumns($select_target_table = null, bool $skipSelf = false) { return $this->custom_columns_cache->filter(function ($custom_column) use ($skipSelf, $select_target_table) { @@ -369,6 +438,8 @@ public function getSelectTableColumns($select_target_table = null, bool $skipSel * * @return Collection|string */ + + // @phpstan-ignore-next-line public function getLabelColumns() { $key = 'custom_table_use_label_flg_' . $this->table_name; @@ -388,6 +459,8 @@ public function getLabelColumns() * * @return array */ + + // @phpstan-ignore-next-line public function getSelectedTables() { return $this->getSelectedTableColumns()->mapWithKeys(function ($custom_column, $key) { @@ -404,6 +477,8 @@ public function getSelectedTables() * @param bool $skipSelf if true, skip column for relation target is self. * @return Collection */ + + // @phpstan-ignore-next-line public function getSelectedTableColumns(bool $skipSelf = true, bool $index_enabled_only = false) { return CustomColumn::allRecords(function ($custom_column) use ($skipSelf, $index_enabled_only) { @@ -432,6 +507,8 @@ public function getSelectedTableColumns(bool $skipSelf = true, bool $index_enabl * * @return \Illuminate\Support\Collection */ + + // @phpstan-ignore-next-line protected function getUniqueColumns() { $results = collect(); @@ -483,6 +560,8 @@ protected function getUniqueColumns() return $results; } + + // @phpstan-ignore-next-line public function getCompareColumns() { return CustomColumnMulti::allRecords(function ($val) { @@ -502,6 +581,8 @@ public function getCompareColumns() /** * Delete children items */ + + // @phpstan-ignore-next-line public function deletingChildren() { foreach ($this->custom_columns as $item) { @@ -578,6 +659,8 @@ protected static function boot() * @param ?CustomValue $custom_value matched custom_value * @return mixed */ + + // @phpstan-ignore-next-line public function validateValue($value, $custom_value = null, array $options = []) { $options = array_merge([ @@ -648,6 +731,8 @@ public function validateValue($value, $custom_value = null, array $options = []) /** * get validation custom attribute */ + + // @phpstan-ignore-next-line public function getValidateCustomAttributes($systemColumn = false, $column_name_prefix = null, $appendKeyName = true) { $customAttributes = []; @@ -683,6 +768,8 @@ public function getValidateCustomAttributes($systemColumn = false, $column_name_ * @param array $options * @return void */ + + // @phpstan-ignore-next-line protected function setColumnsName(&$value, ?CustomValue $custom_value = null, array $options = []) { $options = array_merge([ @@ -712,6 +799,8 @@ protected function setColumnsName(&$value, ?CustomValue $custom_value = null, ar /** * get validation rules */ + + // @phpstan-ignore-next-line public function getValidateRules($value, $custom_value = null, array $options = []) { $options = array_merge([ @@ -788,6 +877,8 @@ public function getValidateRules($value, $custom_value = null, array $options = * @param array $input * @return array error messages */ + + // @phpstan-ignore-next-line public function validatorUnnecessaryColumn($input, array $options = []) { $options = array_merge([ @@ -824,6 +915,8 @@ public function validatorUnnecessaryColumn($input, array $options = []) * @param array $options * @return array */ + + // @phpstan-ignore-next-line public function validatorUniques($input, ?CustomValue $custom_value = null, array $options = []) { $options = array_merge([ @@ -982,6 +1075,8 @@ public function validatorUniques($input, ?CustomValue $custom_value = null, arra /** * Validation comparing 2 columns */ + + // @phpstan-ignore-next-line public function validatorCompareColumns($input, $custom_value = null, array $options = []) { $options = array_merge([ @@ -1009,6 +1104,8 @@ public function validatorCompareColumns($input, $custom_value = null, array $opt return $errors; } + + // @phpstan-ignore-next-line public function validatorLock($input, $custom_value = null, bool $asApi = false) { if (!array_key_value_exists('updated_at', $input)) { @@ -1040,6 +1137,8 @@ public function validatorLock($input, $custom_value = null, bool $asApi = false) /** * validator using plugin */ + + // @phpstan-ignore-next-line public function validatorPlugin($input, $custom_value = null, array $options = []) { return Plugin::pluginValidator($this, [ @@ -1057,6 +1156,8 @@ public function validatorPlugin($input, $custom_value = null, array $options = [ * @param array $value input value * @return array Value after assigning default value */ + + // @phpstan-ignore-next-line public function setDefaultValue($value) { // get fields for validation @@ -1077,6 +1178,8 @@ public function setDefaultValue($value) /** * get CustomTable by url */ + + // @phpstan-ignore-next-line public static function findByEndpoint($endpoint = null, $withs = []) { // get table info @@ -1108,6 +1211,8 @@ public static function findByEndpoint($endpoint = null, $withs = []) * @param bool $addFilter append filter url * @param array|null $options Options to execute this function */ + + // @phpstan-ignore-next-line public function getGridUrl($addFilter = false, $options = []) { $path = 'data/' . $this->table_name; @@ -1121,12 +1226,17 @@ public function getGridUrl($addFilter = false, $options = []) } // get page settings + // Exment helper class not recognized $settings = \Exment::user()->getSettingValue($path)?? '[]'; $settings = json_decode_ex($settings, true); // get view settings $parameters = []; + + // @phpstan-ignore-next-line if (isset($view) && array_key_exists($view, $settings)) { + + // @phpstan-ignore-next-line $parameters = array_get($settings, $view); } @@ -1161,9 +1271,12 @@ public function saveGridParameter($path) $inputs = Arr::except(Request::all(), ['view', '_pjax', '_token', '_method', '_previous_', '_export_', 'format', 'group_key', 'group_view']); + // Exment helper class not recognized $parameters = \Exment::user()->getSettingValue($path)?? '[]'; $parameters = json_decode_ex($parameters, true); + + // @phpstan-ignore-next-line $parameters[$view] = $inputs; Admin::user()->setSettingValue($path, json_encode($parameters)); @@ -1176,6 +1289,8 @@ public function saveGridParameter($path) * @param mixed $obj id table_name CustomTable_object CustomValue_object. * @return null|CustomTable matched custom_table. */ + + // @phpstan-ignore-next-line public static function getEloquent($obj, $withs = []) { if ($obj instanceof CustomTable) { @@ -1226,6 +1341,8 @@ public static function getEloquent($obj, $withs = []) * Get only has role * showlist_flg is true */ + + // @phpstan-ignore-next-line public static function filterList($model = null, $options = []) { $options = array_merge( @@ -1272,6 +1389,8 @@ public static function filterList($model = null, $options = []) /** * get 'with' array for get eloquent */ + + // @phpstan-ignore-next-line protected static function getWiths($withs) { if (is_array($withs)) { @@ -1286,6 +1405,8 @@ protected static function getWiths($withs) /** * set lazy load and return */ + + // @phpstan-ignore-next-line protected static function withLoad($obj, $withs = []) { $withs = static::getWiths($withs); @@ -1295,6 +1416,8 @@ protected static function withLoad($obj, $withs = []) return $obj; } + + // @phpstan-ignore-next-line protected function importSetValue(&$json, $options = []) { $system_flg = array_get($options, 'system_flg', false); @@ -1314,6 +1437,8 @@ protected function importSetValue(&$json, $options = []) return ['system_flg', 'showlist_flg']; } + + // @phpstan-ignore-next-line public function importSaved($json, $options = []) { $this->createTable(); @@ -1324,6 +1449,8 @@ public function importSaved($json, $options = []) /** * search value */ + + // @phpstan-ignore-next-line public function searchValue($q, $options = []) { $options = array_merge( @@ -1396,9 +1523,11 @@ public function searchValue($q, $options = []) $paginates->setCollection($query->get()); if (boolval($options['makeHidden'])) { - /** @phpstan-ignore-next-line */ + + // @phpstan-ignore-next-line $data = $paginates->makeHidden($this->getMakeHiddenArray()); - /** @phpstan-ignore-next-line */ + + // @phpstan-ignore-next-line $paginates->data = $data; } @@ -1442,6 +1571,8 @@ public function searchValue($q, $options = []) /** * search relation value */ + + // @phpstan-ignore-next-line public function searchRelationValue($search_type, $parent_value_id, $child_table, &$options = []) { $options = array_merge( @@ -1542,6 +1673,8 @@ public function searchRelationValue($search_type, $parent_value_id, $child_table * * @return void */ + + // @phpstan-ignore-next-line public function setQueryWith($query, $custom_view = null) { if (!method_exists($query, 'with')) { @@ -1551,8 +1684,12 @@ public function setQueryWith($query, $custom_view = null) // set query workflow if (!is_null(Workflow::getWorkflowByTable($this))) { //WorkflowItem::getStatusSubquery($query, $this); + + // @phpstan-ignore-next-line $query->with(['workflow_value', 'workflow_value.workflow_status']); } + + // @phpstan-ignore-next-line $this->appendSubQuery($query, $custom_view); } @@ -1561,6 +1698,8 @@ public function setQueryWith($query, $custom_view = null) * * @return void */ + + // @phpstan-ignore-next-line protected function setQueryWithRelation($query, $relations) { if (!method_exists($query, 'with') || !$relations) { @@ -1572,6 +1711,8 @@ protected function setQueryWithRelation($query, $relations) } foreach ($relations as $relation) { + + // @phpstan-ignore-next-line $query->with($relation->getRelationName()); } } @@ -1583,6 +1724,8 @@ protected function setQueryWithRelation($query, $relations) * @param CustomView|null $custom_view * @return void */ + + // @phpstan-ignore-next-line public function appendSubQuery($query, ?CustomView $custom_view) { $this->appendWorkflowSubQuery($query, $custom_view); @@ -1604,6 +1747,8 @@ public function appendSubQuery($query, ?CustomView $custom_view) if ($relations->count() > 0) { $relations->each(function ($r) use ($query) { if ($r->relation_type == RelationType::MANY_TO_MANY) { + + // @phpstan-ignore-next-line $query->with($r->getRelationName()); } }); @@ -1619,6 +1764,8 @@ public function appendSubQuery($query, ?CustomView $custom_view) * @param CustomView|null $custom_view * @return void */ + + // @phpstan-ignore-next-line public function appendWorkflowSubQuery($query, ?CustomView $custom_view) { if ($custom_view && System::requestSession(Define::SYSTEM_KEY_SESSION_WORLFLOW_STATUS_CHECK) === true) { @@ -1635,6 +1782,8 @@ public function appendWorkflowSubQuery($query, ?CustomView $custom_view) /** * Set selectTable value's and relations. for after calling from select_table object */ + + // @phpstan-ignore-next-line public function setSelectRelationValues(?\Illuminate\Database\Eloquent\Collection $customValueCollection) { $this->setSelectTableValues($customValueCollection); @@ -1648,6 +1797,8 @@ public function setSelectRelationValues(?\Illuminate\Database\Eloquent\Collectio * @param \Illuminate\Support\Collection|\Tightenco\Collect\Support\Collection|null $customValueCollection * @return void */ + + // @phpstan-ignore-next-line public function setSelectTableValues(\Illuminate\Support\Collection|\Tightenco\Collect\Support\Collection|null $customValueCollection) { if (empty($customValueCollection)) { @@ -1675,6 +1826,8 @@ public function setSelectTableValues(\Illuminate\Support\Collection|\Tightenco\C /** * Set relation value's. for after calling from select_table object */ + + // @phpstan-ignore-next-line public function setRelationValues(?\Illuminate\Database\Eloquent\Collection $customValueCollection) { if (empty($customValueCollection)) { @@ -1704,6 +1857,8 @@ public function setRelationValues(?\Illuminate\Database\Eloquent\Collection $cus * @param array|Collection $ids * @return void */ + + // @phpstan-ignore-next-line public function setCustomValueModels($ids) { // value sometimes array, so flatten value. maybe has best way.. @@ -1741,6 +1896,8 @@ public function setCustomValueModels($ids) * @param string $keyName database key name * @return array key-value's. "key" is value, "value" matched custom_value. */ + + // @phpstan-ignore-next-line public function getMatchedCustomValues($values, $keyName = 'id', $withTrashed = false) { $result = []; @@ -1764,7 +1921,8 @@ public function getMatchedCustomValues($values, $keyName = 'id', $withTrashed = $query->whereIn($databaseKeyName, $chunk); if ($withTrashed) { - /** @phpstan-ignore-next-line */ + + // @phpstan-ignore-next-line $query->withTrashed(); } @@ -1786,6 +1944,8 @@ public function getMatchedCustomValues($values, $keyName = 'id', $withTrashed = /** * Get search-enabled columns. */ + + // @phpstan-ignore-next-line public function getSearchEnabledColumns() { return CustomColumn::allRecords(function ($custom_column) { @@ -1804,6 +1964,8 @@ public function getSearchEnabledColumns() /** * Get freeword-search columns. */ + + // @phpstan-ignore-next-line public function getFreewordSearchColumns() { return CustomColumn::allRecords(function ($custom_column) { @@ -1842,6 +2004,8 @@ public function createTable() System::clearCache(); } + + // @phpstan-ignore-next-line public function dropTable() { $table_name = getDBTableName($this); @@ -1872,6 +2036,8 @@ public function getIndexColumnName($column_name) * * @param array $options */ + + // @phpstan-ignore-next-line public function isGetOptions($options = []) { $options = array_merge( @@ -1910,6 +2076,8 @@ public function isGetOptions($options = []) * Get all accessible users on this table. (only get id, consider performance) * *Not check "loginuser"'s permission. */ + + // @phpstan-ignore-next-line public function getAccessibleUserIds() { return $this->getAccessibleUserOrganizationIds(SystemTableName::USER); @@ -1919,6 +2087,8 @@ public function getAccessibleUserIds() * Get all accessible users on this table. (get model) * *Not check "loginuser"'s permission. */ + + // @phpstan-ignore-next-line public function getAccessibleUsers() { $target_ids = $this->getAccessibleUserOrganizationIds(SystemTableName::USER); @@ -1928,6 +2098,8 @@ public function getAccessibleUsers() /** * Filter all accessible users on this table. */ + + // @phpstan-ignore-next-line public function filterAccessibleUsers($userIds): \Illuminate\Support\Collection { if (is_nullorempty($userIds)) { @@ -1951,6 +2123,8 @@ public function filterAccessibleUsers($userIds): \Illuminate\Support\Collection /** * Filter all accessible orgs on this table. */ + + // @phpstan-ignore-next-line public function filterAccessibleOrganizations($organizationIds): \Illuminate\Support\Collection { if (is_nullorempty($organizationIds)) { @@ -1975,6 +2149,8 @@ public function filterAccessibleOrganizations($organizationIds): \Illuminate\Sup * Get all accessible organizations on this table. (only get id, consider performance) * *Not check "loginuser"'s permission. */ + + // @phpstan-ignore-next-line public function getAccessibleOrganizationIds() { return $this->getAccessibleUserOrganizationIds(SystemTableName::ORGANIZATION); @@ -1983,6 +2159,8 @@ public function getAccessibleOrganizationIds() /** * Get all accessible organizations. (only get id, consider performance) */ + + // @phpstan-ignore-next-line protected function getAccessibleUserOrganizationIds($target_table) { $key = sprintf(Define::SYSTEM_KEY_SESSION_ACCESSIBLE_TABLE, $target_table, $this->table_name); @@ -2004,6 +2182,8 @@ protected function getAccessibleUserOrganizationIds($target_table) * @param array $options * @return \Encore\Admin\Form\Field */ + + // @phpstan-ignore-next-line public function setSelectTableField(\Encore\Admin\Form\Field $field, array $options = []): \Encore\Admin\Form\Field { $options = array_merge([ @@ -2021,9 +2201,9 @@ public function setSelectTableField(\Encore\Admin\Form\Field $field, array $opti // add table info $field->attribute(['data-target_table_name' => array_get($this, 'table_name')]); - /** @phpstan-ignore-next-line */ $field->buttons($options['buttons']); - /** @phpstan-ignore-next-line options() expects array, Closure given */ + + // @phpstan-ignore-next-line $field->options(function ($value, $field) use ($thisObj, $selectOption) { $selectOption['selected_value'] = (!empty($field) ? $field->getOld() : null) ?? $value; return $thisObj->getSelectOptions($selectOption); @@ -2065,6 +2245,8 @@ public function setSelectTableField(\Encore\Admin\Form\Field $field, array $opti * @param array $options * @return Collection */ + + // @phpstan-ignore-next-line public function getSelectOptions($options = []): Collection { $options = array_merge( @@ -2108,6 +2290,8 @@ public function getSelectOptions($options = []): Collection * @param array $options * @return string|null url */ + + // @phpstan-ignore-next-line public function getOptionAjaxPath($options = []) { // if use options, return null @@ -2126,6 +2310,8 @@ public function getOptionAjaxPath($options = []) * @param array $options * @return string|null url */ + + // @phpstan-ignore-next-line public function getOptionAjaxUrl($options = []) { $path = $this->getOptionAjaxPath($options); @@ -2141,6 +2327,8 @@ public function getOptionAjaxUrl($options = []) * @param array $options * @return array offset 0 is select options, 1 is ajax url */ + + // @phpstan-ignore-next-line public function getSelectOptionsAndAjaxUrl($options = []) { return [ @@ -2152,6 +2340,8 @@ public function getSelectOptionsAndAjaxUrl($options = []) /** * put selected value */ + + // @phpstan-ignore-next-line protected function putSelectedValue(Collection $items, $selected_value, $options = []): Collection { // if display_table and $this is same, and contains target_id, remove selects @@ -2197,6 +2387,8 @@ protected function putSelectedValue(Collection $items, $selected_value, $options /** * getOptionsQuery. this function uses for count, get, ... */ + + // @phpstan-ignore-next-line protected function getOptionsQuery($options = []) { $options = array_merge( @@ -2245,6 +2437,8 @@ protected function getOptionsQuery($options = []) /** * Filtering display table. if $this table is user or org, filtering. */ + + // @phpstan-ignore-next-line public function filterDisplayTable($query, $display_table, $options = []) { $options = array_merge([ @@ -2278,6 +2472,8 @@ public function filterDisplayTable($query, $display_table, $options = []) * @param int|string|null $selected_value * @return \Illuminate\Support\Collection */ + + // @phpstan-ignore-next-line protected function getSelectedOptionDefault($selected_value): Collection { if (!isset($selected_value)) { @@ -2293,10 +2489,14 @@ protected function getSelectedOptionDefault($selected_value): Collection $ret[$i->id] = $i->label; } /** @var Collection $collection */ + + // @phpstan-ignore-next-line $collection = collect($ret); return $collection; } /** @var Collection $collection */ + + // @phpstan-ignore-next-line $collection = collect([$item->id => $item->label]); return $collection; } else { @@ -2317,6 +2517,8 @@ protected function getSelectedOptionDefault($selected_value): Collection * @return array|null option items */ //public function getColumnsSelectOptions($append_table = false, $index_enabled_only = false, $include_parent = false, $include_child = false, $include_system = true) + + // @phpstan-ignore-next-line public function getColumnsSelectOptions($selectOptions = []) { $selectOptions = array_merge( @@ -2535,6 +2737,8 @@ public function getColumnsSelectOptions($selectOptions = []) return $options; } + + // @phpstan-ignore-next-line protected function setColumnOptions(&$options, $custom_columns, $table_id, $selectOptions = []) { $selectOptions = array_merge( @@ -2680,6 +2884,8 @@ protected function setColumnOptions(&$options, $custom_columns, $table_id, $sele * * @return array options */ + + // @phpstan-ignore-next-line public function getSummaryColumnsSelectOptions() { $options = []; @@ -2733,6 +2939,8 @@ public function getSummaryColumnsSelectOptions() } + + // @phpstan-ignore-next-line protected function setSummarySelectOptionItem(&$options, $custom_table, $custom_columns, ?string $view_name, $optionKeyParams = []) { @@ -2756,6 +2964,8 @@ protected function setSummarySelectOptionItem(&$options, $custom_table, $custom_ * get date columns select options. It contains date, datetime. * */ + + // @phpstan-ignore-next-line public function getDateColumnsSelectOptions() { $options = []; @@ -2784,6 +2994,8 @@ public function getDateColumnsSelectOptions() * get user and organization columns select options. * */ + + // @phpstan-ignore-next-line public function getUserOrgColumnsSelectOptions($options = []) { $options = array_merge( @@ -2815,6 +3027,8 @@ public function getUserOrgColumnsSelectOptions($options = []) * Get relation tables list. * It contains search_type(select_table, one_to_many, many_to_many) */ + + // @phpstan-ignore-next-line public function getRelationTables($checkPermission = true, $options = []) { return RelationTable::getRelationTables($this, $checkPermission, $options); @@ -2855,6 +3069,8 @@ public function getValueModel($id = null, $withTrashed = false): ?CustomValue * * @return \Illuminate\Database\Eloquent\Builder */ + + // @phpstan-ignore-next-line public function getValueQuery(): \Illuminate\Database\Eloquent\Builder { return $this->getValueModel()->query(); @@ -2882,6 +3098,8 @@ public function findValue($column, $value): ?CustomValue /** * get array for "makeHidden" function */ + + // @phpstan-ignore-next-line public function getMakeHiddenArray() { return $this->getSearchEnabledColumns()->map(function ($columns) { @@ -2895,6 +3113,8 @@ public function getMakeHiddenArray() /** * whether login user has permission. target is table */ + + // @phpstan-ignore-next-line public function hasPermission($role_key = Permission::AVAILABLE_VIEW_CUSTOM_VALUE) { // if system doesn't use role, return true @@ -2956,6 +3176,8 @@ public function hasPermission($role_key = Permission::AVAILABLE_VIEW_CUSTOM_VALU /** * Whether login user has permission about view. */ + + // @phpstan-ignore-next-line public function hasViewPermission() { $userview_unavailable_table = config('exment.userview_unavailable_table', ''); @@ -2968,6 +3190,8 @@ public function hasViewPermission() /** * Whether login user has system permission about view. */ + + // @phpstan-ignore-next-line public function hasSystemViewPermission() { return $this->hasPermission([Permission::CUSTOM_TABLE, Permission::CUSTOM_VIEW]); @@ -2976,6 +3200,8 @@ public function hasSystemViewPermission() /** * Whether login user has permission about target id data. */ + + // @phpstan-ignore-next-line public function hasPermissionData($id) { $result = $this->_hasPermissionData($id, Permission::AVAILABLE_ACCESS_CUSTOM_VALUE, Permission::AVAILABLE_ALL_CUSTOM_VALUE, Permission::AVAILABLE_ACCESS_CUSTOM_VALUE); @@ -2987,6 +3213,8 @@ public function hasPermissionData($id) $parent_table = $relation->parent_custom_table; if (isset($parent_table)) { if (is_numeric($id)) { + + // @phpstan-ignore-next-line $model = $this->getValueModel($id); } else { $model = $id; @@ -3003,6 +3231,8 @@ public function hasPermissionData($id) /** * Whether login user has edit permission about target id data. */ + + // @phpstan-ignore-next-line public function hasPermissionEditData($id) { return $this->_hasPermissionData($id, Permission::AVAILABLE_ACCESS_CUSTOM_VALUE, Permission::AVAILABLE_ALL_EDIT_CUSTOM_VALUE, Permission::AVAILABLE_EDIT_CUSTOM_VALUE); @@ -3014,6 +3244,8 @@ public function hasPermissionEditData($id) * @$tableRole if user doesn't have these permission, return false * @$tableRoleTrue if user has these permission, return true */ + + // @phpstan-ignore-next-line protected function _hasPermissionData($id, $tableRole, $tableRoleTrue, $dataRole) { // if system doesn't use role, return true @@ -3037,6 +3269,8 @@ protected function _hasPermissionData($id, $tableRole, $tableRoleTrue, $dataRole } if (is_numeric($id)) { + + // @phpstan-ignore-next-line $model = $this->getValueModel($id); } else { $model = $id; @@ -3072,6 +3306,8 @@ protected function _hasPermissionData($id, $tableRole, $tableRoleTrue, $dataRole * * @return bool if true, has in database. */ + + // @phpstan-ignore-next-line public function hasCustomValueInDB($custom_value_id) { return $this->getValueModel()->withoutGlobalScopes([CustomValueModelScope::class])->where('id', $custom_value_id)->count() > 0; @@ -3083,6 +3319,8 @@ public function hasCustomValueInDB($custom_value_id) * * @return ErrorCode */ + + // @phpstan-ignore-next-line public function getNoDataErrorCode($custom_value_id) { if ($this->hasCustomValueInDB($custom_value_id)) { @@ -3095,6 +3333,8 @@ public function getNoDataErrorCode($custom_value_id) /** * check permission with pivot */ + + // @phpstan-ignore-next-line protected function checkPermissionWithPivot($rows, $role_key) { if (!isset($rows) || count($rows) == 0) { @@ -3120,6 +3360,8 @@ protected function checkPermissionWithPivot($rows, $role_key) /** * */ + + // @phpstan-ignore-next-line public function allUserAccessable() { return !System::permission_available() @@ -3133,6 +3375,8 @@ public function allUserAccessable() * * @return void */ + + // @phpstan-ignore-next-line public function setGridAuthoritable(Collection $custom_values) { $key = sprintf(Define::SYSTEM_KEY_SESSION_GRID_AUTHORITABLE, $this->id); @@ -3152,6 +3396,8 @@ public function setGridAuthoritable(Collection $custom_values) * @param $action_type * @return bool */ + + // @phpstan-ignore-next-line public function formActionDisable($action_type) { $disable_actions = $this->getOption('form_action_disable_flg', []); @@ -3162,6 +3408,8 @@ public function formActionDisable($action_type) * @param $action_type * @return bool */ + + // @phpstan-ignore-next-line public function gridFilterDisable($action_type) { $grid_filter_disable_flg = System::grid_filter_disable_flg() ?? []; @@ -3202,6 +3450,8 @@ public function enableView() * @param $checkFormAction * @return ErrorCode|true */ + + // @phpstan-ignore-next-line public function enableCreate($checkFormAction = false) { if (!$this->hasPermission(Permission::AVAILABLE_EDIT_CUSTOM_VALUE)) { @@ -3222,6 +3472,8 @@ public function enableCreate($checkFormAction = false) * @param $checkFormAction * @return ErrorCode|true */ + + // @phpstan-ignore-next-line public function enableEdit($checkFormAction = false) { if (!$this->hasPermission(Permission::AVAILABLE_EDIT_CUSTOM_VALUE)) { @@ -3314,6 +3566,8 @@ public function enableTableMenuButton() /** * User can view customview menu button */ + + // @phpstan-ignore-next-line public function enableViewMenuButton() { if (boolval(config('exment.datalist_view_button_disabled', false))) { @@ -3330,6 +3584,8 @@ public function enableViewMenuButton() /** * */ + + // @phpstan-ignore-next-line public function isOneRecord() { return $this->getOption('one_record_flg', false); @@ -3338,6 +3594,8 @@ public function isOneRecord() /** * get show positon for system values */ + + // @phpstan-ignore-next-line public function getSystemValuesPosition() { $positon = $this->getOption('system_values_pos', ShowPositionType::DEFAULT); @@ -3350,6 +3608,8 @@ public function getSystemValuesPosition() /** * copy this table */ + + // @phpstan-ignore-next-line public function copyTable($inputs = null, bool $include_view = false, bool $include_form = false) { \ExmentDB::transaction(function ($connect) use ($inputs, $include_view, $include_form) { @@ -3488,6 +3748,8 @@ public function copyTable($inputs = null, bool $include_view = false, bool $incl /** * check if copy target view. */ + + // @phpstan-ignore-next-line protected function isCopyTargetView($custom_view): bool { if ($custom_view->view_type == ViewType::USER) { @@ -3545,6 +3807,8 @@ protected function isCopyTargetView($custom_view): bool /** * validate before value delete. */ + + // @phpstan-ignore-next-line public function validateValueDestroy($id) { $ids = stringToArray($id); @@ -3587,6 +3851,8 @@ public function validateValueDestroy($id) /** * check if data is referenced. */ + + // @phpstan-ignore-next-line protected function checkReferenced($custom_table, $list) { foreach ($custom_table->getSelectedItems() as $item) { diff --git a/src/Model/CustomValue.php b/src/Model/CustomValue.php index 27c02193b..60e120b84 100644 --- a/src/Model/CustomValue.php +++ b/src/Model/CustomValue.php @@ -65,61 +65,83 @@ abstract class CustomValue extends ModelBase protected $casts = ['value' => 'json']; // protected $appends = ['label']; protected $hidden = ['laravel_admin_escape']; + + // @phpstan-ignore-next-line protected $keepRevisionOf = ['value']; + + // @phpstan-ignore-next-line protected $keepRevisionOfTrigger = ['deleted_at' => 'value']; /** * remove_file_columns. * default flow, if file column is empty, set original value. */ + + // @phpstan-ignore-next-line protected $remove_file_columns = []; /** * disabled saving event. * if true, disable. */ + + // @phpstan-ignore-next-line protected $disable_saving_event = false; /** * disabled saved event. * if true, disable. */ + + // @phpstan-ignore-next-line protected $disable_saved_event = false; /** * set value directly without processing. * if true, skip saving event without revision. */ + + // @phpstan-ignore-next-line protected $restore_revision = false; /** * saved notify. * if false, don't notify */ + + // @phpstan-ignore-next-line protected $saved_notify = true; /** * already_updated. * if true, not call saved event again. */ + + // @phpstan-ignore-next-line protected $already_updated = false; /** * label work. * get label only first time. */ + + // @phpstan-ignore-next-line protected $_label; /** * file uuids. * *NOW only use edtitor images */ + + // @phpstan-ignore-next-line protected $file_uuids = []; /** * result validate destroy. * if true, pass validate destroy */ + + // @phpstan-ignore-next-line protected $validation_destroy = false; /** @@ -128,6 +150,8 @@ abstract class CustomValue extends ModelBase * @param array $attributes * @return void */ + + // @phpstan-ignore-next-line public function __construct(array $attributes = []) { // set parent_id for org @@ -141,6 +165,8 @@ public function __construct(array $attributes = []) parent::__construct($attributes); } + + // @phpstan-ignore-next-line public function workflow_value() { return $this->hasOne(WorkflowValue::class, 'morph_id') @@ -153,12 +179,16 @@ public function workflow_value() /** * Get all workflow values */ + + // @phpstan-ignore-next-line public function workflow_values() { return $this->hasMany(WorkflowValue::class, 'morph_id') ->where('morph_type', $this->custom_table->table_name); } + + // @phpstan-ignore-next-line public function getLabelAttribute() { if (is_null($this->_label)) { @@ -167,32 +197,46 @@ public function getLabelAttribute() return $this->_label; } + + // @phpstan-ignore-next-line public function getCustomTableAttribute() { // return resuly using cache return CustomTable::getEloquent($this->custom_table_name); } + + // @phpstan-ignore-next-line public function getDeletedUserAttribute() { return $this->getUser('deleted_user_id'); } + + // @phpstan-ignore-next-line public function getDeletedUserValueAttribute() { return $this->getUserValue('deleted_user_id'); } + + // @phpstan-ignore-next-line public function getDeletedUserTagAttribute() { return $this->getUser('deleted_user_id', true); } + + // @phpstan-ignore-next-line public function getDeletedUserAvatarAttribute() { return $this->getUser('deleted_user_id', true, true); } + + // @phpstan-ignore-next-line public function getValidationDestroy() { return $this->validation_destroy; } + + // @phpstan-ignore-next-line public function setValidationDestroy($value) { $this->validation_destroy = $value; @@ -208,6 +252,8 @@ public function getDisabledDeleteAttribute() return $this->enableDelete(true) !== true; } + + // @phpstan-ignore-next-line public function getWorkflowStatusAttribute() { if (is_null(Workflow::getWorkflowByTable($this->custom_table))) { @@ -217,6 +263,8 @@ public function getWorkflowStatusAttribute() return isset($this->workflow_value) ? $this->workflow_value->workflow_status_cache : null; } + + // @phpstan-ignore-next-line public function getWorkflowStatusNameAttribute() { if (isset($this->workflow_status)) { @@ -238,6 +286,8 @@ public function getWorkflowStatusNameAttribute() /** * Get workflow status tag. Please escape workflow_status_name */ + + // @phpstan-ignore-next-line public function getWorkflowStatusTagAttribute() { $icon = ' '; @@ -245,6 +295,8 @@ public function getWorkflowStatusTagAttribute() ($this->lockedWorkflow() ? $icon : ''); } + + // @phpstan-ignore-next-line public function getWorkflowWorkUsersAttribute() { $workflow_actions = $this->getWorkflowActions(false, true); @@ -260,6 +312,8 @@ public function getWorkflowWorkUsersAttribute() return $result; } + + // @phpstan-ignore-next-line public function getWorkflowWorkUsersTagAttribute() { $users = $this->workflow_work_users; @@ -273,6 +327,8 @@ public function getWorkflowWorkUsersTagAttribute() } // value_authoritable. it's all role data. + + // @phpstan-ignore-next-line public function custom_value_authoritables() { return $this->hasMany(CustomValueAuthoritable::class, 'parent_id') @@ -280,6 +336,8 @@ public function custom_value_authoritables() } // user value_authoritable. it's all role data. only filter morph_type + + // @phpstan-ignore-next-line public function value_authoritable_users() { return $this->morphToMany(getModelName(SystemTableName::USER), 'parent', 'custom_value_authoritables', 'parent_id', 'authoritable_target_id') @@ -289,6 +347,8 @@ public function value_authoritable_users() } // user value_authoritable. it's all role data. only filter morph_type + + // @phpstan-ignore-next-line public function value_authoritable_organizations() { return $this->morphToMany(getModelName(SystemTableName::ORGANIZATION), 'parent', 'custom_value_authoritables', 'parent_id', 'authoritable_target_id') @@ -305,6 +365,8 @@ public function value_authoritable_organizations() * @param boolean $isCallAsParent * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany|\Illuminate\Database\Eloquent\Relations\MorphMany|\Illuminate\Database\Eloquent\Relations\BelongsTo */ + + // @phpstan-ignore-next-line public function getDynamicRelationValue(int $custom_relation_id, bool $isCallAsParent) { $relation = CustomRelation::getEloquent($custom_relation_id); @@ -313,6 +375,8 @@ public function getDynamicRelationValue(int $custom_relation_id, bool $isCallAsP // get whether workflow is completed + + // @phpstan-ignore-next-line public function isWorkflowCompleted() { $workflow_value = $this->workflow_value; @@ -329,6 +393,8 @@ public function isWorkflowCompleted() // get workflow actions which has authority + + // @phpstan-ignore-next-line public function getWorkflowActions($onlyHasAuthority = false, $ignoreNextWork = false) { $workflow_value = $this->workflow_value; @@ -378,6 +444,8 @@ public function getWorkflowActions($onlyHasAuthority = false, $ignoreNextWork = * * @return Collection */ + + // @phpstan-ignore-next-line public function getWorkflowHistories($appendsStatus = false) { $workflow_values = WorkflowValue::where('morph_type', $this->custom_table->table_name) @@ -400,6 +468,8 @@ public function getWorkflowHistories($appendsStatus = false) } /** @var Collection $collection */ + + // @phpstan-ignore-next-line $collection = collect($results); return $collection; } @@ -407,6 +477,8 @@ public function getWorkflowHistories($appendsStatus = false) /** * get or set remove_file_columns */ + + // @phpstan-ignore-next-line public function remove_file_columns($key = null) { // get @@ -422,6 +494,8 @@ public function remove_file_columns($key = null) /** * get or set file_uuids */ + + // @phpstan-ignore-next-line public function file_uuids($key = null) { // get @@ -434,22 +508,30 @@ public function file_uuids($key = null) return $this; } + + // @phpstan-ignore-next-line public function saved_notify($disable_saved_notify) { $this->saved_notify = $disable_saved_notify; return $this; } + + // @phpstan-ignore-next-line public function disable_saving_event($disable_saving_event) { $this->disable_saving_event = $disable_saving_event; return $this; } + + // @phpstan-ignore-next-line public function disable_saved_event($disable_saved_event) { $this->disable_saved_event = $disable_saved_event; return $this; } + + // @phpstan-ignore-next-line public function restore_revision($restore_revision = true) { $this->restore_revision = $restore_revision; @@ -616,6 +698,8 @@ protected function savedEvent($isCreate) * @param array $input laravel-admin input * @return mixed */ + + // @phpstan-ignore-next-line public function validateSaving($input, array $options = []) { $options = array_merge([ @@ -641,6 +725,8 @@ public function validateSaving($input, array $options = []) // re-set field data -------------------------------------------------- // if user update form and save, but other field remove if not conatins form field, so re-set field before update + + // @phpstan-ignore-next-line protected function prepareValue() { ///// saving event for image, file event @@ -686,6 +772,8 @@ protected function prepareValue() /** * set original data. */ + + // @phpstan-ignore-next-line protected function setAgainOriginalValue(&$value, $original, $custom_column) { if (is_null($value)) { @@ -713,6 +801,8 @@ protected function setAgainOriginalValue(&$value, $original, $custom_column) /** * saved file id. */ + + // @phpstan-ignore-next-line protected function setFileValue() { // if requestsession "file upload uuid"(for set data this value's id and type into files) @@ -742,6 +832,8 @@ protected function setFileValue() /** * saved value event. */ + + // @phpstan-ignore-next-line protected function savedValue() { $this->syncOriginal(); @@ -778,6 +870,8 @@ protected function savedValue() /** * delete file and document. */ + + // @phpstan-ignore-next-line public function deleteFile() { ///// delete file column @@ -819,6 +913,8 @@ public function deleteFile() // notify user -------------------------------------------------- + + // @phpstan-ignore-next-line public function notify($notifySavedType) { // if $saved_notify is false, return @@ -837,6 +933,8 @@ public function notify($notifySavedType) /** * delete relation if record delete */ + + // @phpstan-ignore-next-line protected function deleteRelationValues() { if (!$this->isForceDeleting()) { @@ -909,6 +1007,8 @@ public function delete() /** * delete relation if record delete */ + + // @phpstan-ignore-next-line protected function deleteChildrenValues() { $custom_table = $this->custom_table; @@ -943,6 +1043,8 @@ protected function deleteChildrenValues() /** * restore relation if record delete */ + + // @phpstan-ignore-next-line protected function restoreChildrenValues() { $custom_table = $this->custom_table; @@ -962,6 +1064,8 @@ protected function restoreChildrenValues() * get Authoritable values. * this function selects value_authoritable, and get all values. */ + + // @phpstan-ignore-next-line public function getAuthoritable($related_type) { // check request session for grid. @@ -1014,6 +1118,8 @@ public function getAuthoritable($related_type) * @param boolean $forgetIfNull if true, and val is null, remove DB's column from "value". * @return $this */ + + // @phpstan-ignore-next-line public function setValue($key, $val = null, $forgetIfNull = false) { $custom_columns = $this->custom_table->custom_columns_cache; @@ -1047,6 +1153,8 @@ public function setValue($key, $val = null, $forgetIfNull = false) * @throws ValidationException validation error * @return $this */ + + // @phpstan-ignore-next-line public function setValueStrictly($list, $forgetIfNull = false) { // validation value @@ -1072,6 +1180,8 @@ public function setValueStrictly($list, $forgetIfNull = false) * @param boolean $forgetIfNull if true, and val is null, remove DB's column from "value". * @return $this */ + + // @phpstan-ignore-next-line public function setValueDirectly($key, $val = null, $forgetIfNull = false) { return $this->setJson('value', $key, $val, $forgetIfNull); @@ -1082,6 +1192,8 @@ public function setValueDirectly($key, $val = null, $forgetIfNull = false) * "$this->value" : return data on database * "$this->getValues()" : return data converting getValue */ + + // @phpstan-ignore-next-line public function getValues($label = false, $options = []) { $custom_table = $this->custom_table; @@ -1093,6 +1205,8 @@ public function getValues($label = false, $options = []) return $values; } + + // @phpstan-ignore-next-line public function getValue($column, $label = false, $options = []) { $time_start = microtime(true); @@ -1201,6 +1315,8 @@ public function getLabel() /** * get label string (general setting case) */ + + // @phpstan-ignore-next-line protected function getBasicLabel($label_columns) { $custom_table = $this->custom_table; @@ -1241,6 +1357,8 @@ protected function getBasicLabel($label_columns) /** * get custom format label */ + + // @phpstan-ignore-next-line protected function getExpansionLabel($label_format) { $options['afterCallback'] = function ($text, $custom_value, $options) { @@ -1252,10 +1370,14 @@ protected function getExpansionLabel($label_format) /** * replace text. ex.comma, ¥, etc... */ + + // @phpstan-ignore-next-line protected function replaceText($text, $documentItem = []) { // add comma if number_format if (array_key_exists('number_format', $documentItem) && !str_contains($text, ',') && is_numeric($text)) { + + // @phpstan-ignore-next-line $text = number_format($text); } @@ -1270,6 +1392,8 @@ protected function replaceText($text, $documentItem = []) /** * get target custom_value's self link url */ + + // @phpstan-ignore-next-line public function getUrl($options = []) { // options is boolean, tag is true @@ -1302,6 +1426,7 @@ public function getUrl($options = []) return $url; } + // Exment helper class not recognized return \Exment::getUrlTag($url, $document_name, UrlTagType::BLANK, [], [ 'tooltipTitle' => exmtrans('common.download') ]); @@ -1353,6 +1478,8 @@ public function getUrl($options = []) * * @return \Illuminate\Database\Eloquent\Collection|AbstractPaginator */ + + // @phpstan-ignore-next-line public function getDocuments($options = []) { $options = array_merge( @@ -1375,6 +1502,8 @@ public function getDocuments($options = []) /** * get target custom_value's relation search url */ + + // @phpstan-ignore-next-line public function getRelationSearchUrl($options = []) { if (is_bool($options)) { @@ -1392,6 +1521,8 @@ public function getRelationSearchUrl($options = []) /** * merge value from custom_value */ + + // @phpstan-ignore-next-line public function mergeValue($value) { foreach ($this->custom_table->custom_columns_cache as $custom_column) { @@ -1408,6 +1539,8 @@ public function mergeValue($value) /** * get parent value */ + + // @phpstan-ignore-next-line public function getParentValue(?CustomRelation $custom_relation = null, bool $noScope = false) { // if not has arg or custom relation is one to many @@ -1445,6 +1578,8 @@ public function getParentValue(?CustomRelation $custom_relation = null, bool $no /** * Get Custom children value summary */ + + // @phpstan-ignore-next-line public function getSum($custom_column) { $name = $custom_column->getQueryKey(); @@ -1460,13 +1595,16 @@ public function getSum($custom_column) * Get Custom children Value. * v1.1.0 changes ... get children values using relation or select_table */ + + // @phpstan-ignore-next-line public function getChildrenValues($relation, $returnBuilder = false) { // first, get children values as relation if ($relation instanceof CustomColumn) { // get custom column as array // target column is select table and has index, get index name - /** @phpstan-ignore-next-line Right side of && is always true. */ + + // @phpstan-ignore-next-line if (ColumnType::isSelectTable($relation->column_type) && $relation->indexEnabled()) { $index_name = $relation->getIndexColumnName(); // get children values where this id @@ -1493,6 +1631,8 @@ public function getChildrenValues($relation, $returnBuilder = false) /** * set revision data */ + + // @phpstan-ignore-next-line public function setRevision($revision_suuid) { $revision_value = $this->revisionHistory()->where('suuid', $revision_suuid)->first()->new_value; @@ -1508,6 +1648,8 @@ public function setRevision($revision_suuid) * * @return \Illuminate\Database\Eloquent\Builder */ + + // @phpstan-ignore-next-line public function getSearchQuery($q, $options = []) { $options = $this->getQueryOptions($q, $options); @@ -1603,6 +1745,8 @@ public function getSearchQuery($q, $options = []) * * @return void */ + + // @phpstan-ignore-next-line public function setSearchQueryOrWhere(&$query, $q, $options = []) { $options = $this->getQueryOptions($q, $options); @@ -1643,6 +1787,8 @@ public function setSearchQueryOrWhere(&$query, $q, $options = []) * @param array $options * @return array query option for search. */ + + // @phpstan-ignore-next-line protected function getQueryOptions($q, $options = []) { $options = array_merge( @@ -1704,6 +1850,8 @@ protected function getQueryOptions($q, $options = []) * @param string $q search string * @return array */ + + // @phpstan-ignore-next-line protected function getQueryMarkAndValue($isLike, $q, bool $relation) { // if relation search, return always "=" and $q @@ -1718,6 +1866,8 @@ protected function getQueryMarkAndValue($isLike, $q, bool $relation) * Set CustomValue's model for request session. * */ + + // @phpstan-ignore-next-line public function setValueModel() { $key = sprintf(Define::SYSTEM_KEY_SESSION_CUSTOM_VALUE_VALUE, $this->custom_table_name, $this->id); @@ -1902,6 +2052,8 @@ public function enableShare() /** * Get all accessible users on this value. (get model) */ + + // @phpstan-ignore-next-line public function getAccessibleUsers() { $custom_table = $this->custom_table; @@ -1928,6 +2080,8 @@ public function getAccessibleUsers() /** * Filter all accessible users on this value. */ + + // @phpstan-ignore-next-line public function filterAccessibleUsers($userIds): \Illuminate\Support\Collection { if (is_nullorempty($userIds)) { @@ -1952,6 +2106,8 @@ public function filterAccessibleUsers($userIds): \Illuminate\Support\Collection /** * Get all accessible organization on this value. (get model) */ + + // @phpstan-ignore-next-line public function getAccessibleOrganizations() { $custom_table = $this->custom_table; @@ -1978,6 +2134,8 @@ public function getAccessibleOrganizations() /** * Filter all accessible orgs on this value. */ + + // @phpstan-ignore-next-line public function filterAccessibleOrganizations($organizationIds): \Illuminate\Support\Collection { if (is_nullorempty($organizationIds)) { diff --git a/src/Model/CustomValueAuthoritable.php b/src/Model/CustomValueAuthoritable.php index c6c0dbe31..9bd727ef9 100644 --- a/src/Model/CustomValueAuthoritable.php +++ b/src/Model/CustomValueAuthoritable.php @@ -22,6 +22,8 @@ class CustomValueAuthoritable extends ModelBase { use Traits\DataShareTrait; + + // @phpstan-ignore-next-line public function getAuthoritableUserOrgAttribute() { return CustomTable::getEloquent($this->authoritable_user_org_type)->getValueModel($this->authoritable_target_id); @@ -32,6 +34,8 @@ public function getAuthoritableUserOrgAttribute() * * @return void */ + + // @phpstan-ignore-next-line public static function setValueAuthoritable($custom_value) { $custom_table = $custom_value->custom_table; @@ -182,6 +186,8 @@ public static function setValueAuthoritableEx(CustomValue $custom_value, $share_ * @param bool $is_edit is true, as edit permission * @param bool $sync is true, delete items if not has array */ + + // @phpstan-ignore-next-line public static function setAuthoritableByUserOrgArray($custom_value, $arrays, $is_edit = false, $sync = false) { $custom_table = $custom_value->custom_table; @@ -243,6 +249,8 @@ protected static function hasPermssionAccessible($custom_table, $related_id, $re * * @return void */ + + // @phpstan-ignore-next-line public static function deleteValueAuthoritable($custom_value) { $custom_table = $custom_value->custom_table; @@ -258,6 +266,8 @@ public static function deleteValueAuthoritable($custom_value) * * @return ModalForm */ + + // @phpstan-ignore-next-line public static function getShareDialogForm($custom_value) { // create form fields @@ -319,6 +329,8 @@ public static function getShareDialogForm($custom_value) * @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface */ + + // @phpstan-ignore-next-line public static function saveShareDialogForm($custom_value) { $custom_table = $custom_value->custom_table; @@ -420,6 +432,8 @@ public static function saveShareDialogForm($custom_value) * @param boolean $all if true, get all items. For checking value * @return array */ + + // @phpstan-ignore-next-line public static function getUserOrgSelectOptions($custom_table, $permission = null, $ignoreLoginUser = false, $default = null, $all = false) { $options = collect(); @@ -465,6 +479,8 @@ public static function getUserOrgSelectOptions($custom_table, $permission = null * @param string $permission * @return array user and organization default options */ + + // @phpstan-ignore-next-line protected static function getUserOrgSelectDefault(CustomValue $custom_value, $permission) { $custom_table = $custom_value->custom_table; @@ -506,6 +522,8 @@ protected static function hasPermissionAsOrganization($custom_table, $organizati } + + // @phpstan-ignore-next-line public static function getListsOnCustomValue(CustomValue $custom_value) { return static::where(['parent_id' => $custom_value->id, 'parent_type' => $custom_value->custom_table->table_name])->get(); @@ -518,6 +536,8 @@ public static function getListsOnCustomValue(CustomValue $custom_value) * @param Collection|\Tightenco\Collect\Support\Collection $shareTargets user and organization notify targets collection * @return void */ + + // @phpstan-ignore-next-line protected static function notifyUser($custom_value, $shareTargets) { foreach ($custom_value->custom_table->notifies as $notify) { diff --git a/src/Model/CustomValueModelScope.php b/src/Model/CustomValueModelScope.php index d62f88cbd..7b2115b52 100644 --- a/src/Model/CustomValueModelScope.php +++ b/src/Model/CustomValueModelScope.php @@ -21,6 +21,8 @@ class CustomValueModelScope implements Scope * @return void * @throws \Exception */ + + // @phpstan-ignore-next-line public function apply(Builder $builder, Model $model) { $table_name = $model->custom_table->table_name; diff --git a/src/Model/CustomView.php b/src/Model/CustomView.php index d84deb381..9ad2f8e25 100644 --- a/src/Model/CustomView.php +++ b/src/Model/CustomView.php @@ -46,6 +46,8 @@ class CustomView extends ModelBase implements Interfaces\TemplateImporterInterfa protected $casts = ['options' => 'json', 'custom_options' => 'json']; //protected $with = ['custom_table', 'custom_view_columns']; + + // @phpstan-ignore-next-line private $_grid_item; /** @@ -55,6 +57,8 @@ class CustomView extends ModelBase implements Interfaces\TemplateImporterInterfa */ private $_search_service; + + // @phpstan-ignore-next-line public static $templateItems = [ 'excepts' => ['custom_table', 'target_view_name', 'view_calendar_target', 'pager_count'], 'uniqueKeys' => ['suuid'], @@ -94,37 +98,51 @@ class CustomView extends ModelBase implements Interfaces\TemplateImporterInterfa //public function custom_table() + + // @phpstan-ignore-next-line public function getCustomTableAttribute() { return CustomTable::getEloquent($this->custom_table_id); //return $this->belongsTo(CustomTable::class, 'custom_table_id'); } + + // @phpstan-ignore-next-line public function custom_view_columns(): HasMany { return $this->hasMany(CustomViewColumn::class, 'custom_view_id'); } + + // @phpstan-ignore-next-line public function custom_view_filters(): HasMany { return $this->hasMany(CustomViewFilter::class, 'custom_view_id'); } + + // @phpstan-ignore-next-line public function custom_view_sorts(): HasMany { return $this->hasMany(CustomViewSort::class, 'custom_view_id'); } + + // @phpstan-ignore-next-line public function custom_view_summaries(): HasMany { return $this->hasMany(CustomViewSummary::class, 'custom_view_id'); } + + // @phpstan-ignore-next-line public function custom_view_grid_filters(): HasMany { return $this->hasMany(CustomViewGridFilter::class, 'custom_view_id'); } + + // @phpstan-ignore-next-line public function data_share_authoritables(): HasMany { return $this->hasMany(DataShareAuthoritable::class, 'parent_id') @@ -134,6 +152,8 @@ public function data_share_authoritables(): HasMany /** * get Custom columns using cache */ + + // @phpstan-ignore-next-line public function getCustomViewColumnsCacheAttribute() { return $this->hasManyCache(CustomViewColumn::class, 'custom_view_id'); @@ -142,6 +162,8 @@ public function getCustomViewColumnsCacheAttribute() /** * get Custom filters using cache */ + + // @phpstan-ignore-next-line public function getCustomViewFiltersCacheAttribute() { return $this->hasManyCache(CustomViewFilter::class, 'custom_view_id'); @@ -150,6 +172,8 @@ public function getCustomViewFiltersCacheAttribute() /** * get Custom Sorts using cache */ + + // @phpstan-ignore-next-line public function getCustomViewSortsCacheAttribute() { return $this->hasManyCache(CustomViewSort::class, 'custom_view_id'); @@ -158,21 +182,29 @@ public function getCustomViewSortsCacheAttribute() /** * get Custom summaries using cache */ + + // @phpstan-ignore-next-line public function getCustomViewSummariesCacheAttribute() { return $this->hasManyCache(CustomViewSummary::class, 'custom_view_id'); } + + // @phpstan-ignore-next-line public function getTableNameAttribute() { return $this->custom_table->table_name; } + + // @phpstan-ignore-next-line public function getFilterIsOrAttribute() { return $this->condition_join == 'or'; } + + // @phpstan-ignore-next-line public function getGridItemAttribute() { if (isset($this->_grid_item)) { @@ -185,15 +217,21 @@ public function getGridItemAttribute() return $this->_grid_item; } + + // @phpstan-ignore-next-line public function getCustomOption($key, $default = null) { return $this->getJson('custom_options', $key, $default); } + + // @phpstan-ignore-next-line public function setCustomOption($key, $val = null) { return $this->setJson('custom_options', $key, $val); } + + // @phpstan-ignore-next-line public function deletingChildren() { $this->custom_view_columns()->delete(); @@ -239,6 +277,8 @@ protected static function boot() }); } + + // @phpstan-ignore-next-line protected function setDefaultFlgFilter($query) { $query->where('view_type', $this->view_type); @@ -248,6 +288,8 @@ protected function setDefaultFlgFilter($query) } } + + // @phpstan-ignore-next-line protected function setDefaultFlgSet() { // set if only this flg is system @@ -272,6 +314,8 @@ public function getSearchService(): SearchService /** * reset search service. */ + + // @phpstan-ignore-next-line public function resetSearchService() { $this->_search_service = null; @@ -280,6 +324,8 @@ public function resetSearchService() /** * set search service. */ + + // @phpstan-ignore-next-line public function setSearchService(SearchService $service) { $this->_search_service = $service; @@ -290,6 +336,8 @@ public function setSearchService(SearchService $service) * get eloquent using request settion. * now only support only id. */ + + // @phpstan-ignore-next-line public static function getEloquent($id, $withs = []) { if (strlen_ex($id) == 20) { @@ -307,6 +355,8 @@ public static function getEloquent($id, $withs = []) * @param array $options * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder */ + + // @phpstan-ignore-next-line public function getQuery($query, array $options = []) { return $this->grid_item->getQuery($query, $options); @@ -316,6 +366,8 @@ public function getQuery($query, array $options = []) /** * set laravel-admin grid using custom_view */ + + // @phpstan-ignore-next-line public function setGrid($grid) { return $this->grid_item->setGrid($grid); @@ -325,6 +377,8 @@ public function setGrid($grid) /** * Get data paginate. default or summary */ + + // @phpstan-ignore-next-line public function getDataPaginate($options = []) { $options = array_merge([ @@ -351,6 +405,8 @@ public function getDataPaginate($options = []) * set DataTable using custom_view * @return array $headers : header items, $bodies : body items. */ + + // @phpstan-ignore-next-line public function convertDataTable($datalist, $options = []) { $options = array_merge( @@ -573,6 +629,8 @@ public static function getDefault($tableObj, $getSettingValue = true, $is_dashbo return $view; } + + // @phpstan-ignore-next-line protected static function showableViews($query) { $query->where('view_type', ViewType::SYSTEM); @@ -604,6 +662,8 @@ protected static function showableViews($query) }); } + + // @phpstan-ignore-next-line public static function createDefaultView($tableObj) { $tableObj = CustomTable::getEloquent($tableObj); @@ -621,6 +681,8 @@ public static function createDefaultView($tableObj) /** * filter target model */ + + // @phpstan-ignore-next-line public function filterModel($model, $options = []) { $options = array_merge([ @@ -657,6 +719,8 @@ public function filterModel($model, $options = []) /** * filter and sort target model */ + + // @phpstan-ignore-next-line public function filterSortModel($query, $options = []) { $options = array_merge([ @@ -671,6 +735,8 @@ public function filterSortModel($query, $options = []) * * @param boolean $appendIndexColumn if true, append custom column has index */ + + // @phpstan-ignore-next-line public function createDefaultViewColumns($appendIndexColumn = false) { $view_columns = []; @@ -718,6 +784,8 @@ public function createDefaultViewColumns($appendIndexColumn = false) * * @param CustomView|null $fromView copied target view */ + + // @phpstan-ignore-next-line public function copyFromDefaultViewColumns(?CustomView $fromView) { $view_columns = []; @@ -743,6 +811,8 @@ public function copyFromDefaultViewColumns(?CustomView $fromView) /** * set value filters */ + + // @phpstan-ignore-next-line public function setValueFilters($query) { // If summary, call setSummaryValueFilters. @@ -774,6 +844,8 @@ public function setValueFilters($query) /** * set summary value filters */ + + // @phpstan-ignore-next-line protected function setSummaryValueFilters($query) { // Cannot use $custom_view_filters_cache because summary to grid, use custom_view_filters directly. @@ -818,6 +890,8 @@ protected function setSummaryValueFilters($query) * * @deprecated Please use sortModel func. */ + + // @phpstan-ignore-next-line public function setValueSort($model) { return $this->sortModel($model); @@ -826,6 +900,8 @@ public function setValueSort($model) /** * set value sort */ + + // @phpstan-ignore-next-line public function sortModel($query) { // if request has "_sort", not executing @@ -849,6 +925,8 @@ public function sortModel($query) * * @return array */ + + // @phpstan-ignore-next-line public function getSummaryIndexAndViewColumns() { $results = []; @@ -875,6 +953,8 @@ public function getSummaryIndexAndViewColumns() * get view columns select options. It contains system column(ex. id, suuid, created_at, updated_at), and table columns. * @param bool $is_y */ + + // @phpstan-ignore-next-line public function getViewColumnsSelectOptions(bool $is_y): array { $options = []; @@ -909,6 +989,8 @@ public function getViewColumnsSelectOptions(bool $is_y): array return $options; } + + // @phpstan-ignore-next-line protected function setViewColumnsOptions(&$options, $view_kind_type, $custom_view_column, ?bool $is_number) { $option = $this->getSelectColumn($view_kind_type, $custom_view_column); @@ -917,6 +999,8 @@ protected function setViewColumnsOptions(&$options, $view_kind_type, $custom_vie } } + + // @phpstan-ignore-next-line protected function getSelectColumn($column_type, $custom_view_column) { $condition_item = $custom_view_column->condition_item; @@ -931,6 +1015,8 @@ protected function getSelectColumn($column_type, $custom_view_column) return ['id' => $view_column_id, 'text' => $column_view_name, 'is_number' => $is_number]; } + + // @phpstan-ignore-next-line public function getViewCalendarTargetAttribute() { $custom_view_columns = $this->custom_view_columns_cache; @@ -940,6 +1026,8 @@ public function getViewCalendarTargetAttribute() return null; } + + // @phpstan-ignore-next-line public function setViewCalendarTargetAttribute($view_calendar_target) { $custom_view_columns = $this->custom_view_columns_cache; @@ -949,11 +1037,15 @@ public function setViewCalendarTargetAttribute($view_calendar_target) $custom_view_columns[0]->view_column_target = $view_calendar_target; } + + // @phpstan-ignore-next-line public function getPagerCountAttribute() { return $this->getOption('pager_count'); } + + // @phpstan-ignore-next-line public function setPagerCountAttribute($val) { $this->setOption('pager_count', $val); @@ -961,11 +1053,15 @@ public function setPagerCountAttribute($val) return $this; } + + // @phpstan-ignore-next-line public function getConditionJoinAttribute() { return $this->getOption('condition_join'); } + + // @phpstan-ignore-next-line public function setConditionJoinAttribute($val) { $this->setOption('condition_join', $val); @@ -973,11 +1069,15 @@ public function setConditionJoinAttribute($val) return $this; } + + // @phpstan-ignore-next-line public function getConditionReverseAttribute() { return $this->getOption('condition_reverse'); } + + // @phpstan-ignore-next-line public function setConditionReverseAttribute($val) { $this->setOption('condition_reverse', $val); @@ -985,11 +1085,15 @@ public function setConditionReverseAttribute($val) return $this; } + + // @phpstan-ignore-next-line public function getUseViewInfoboxAttribute() { return $this->getOption('use_view_infobox'); } + + // @phpstan-ignore-next-line public function setUseViewInfoboxAttribute($val) { $this->setOption('use_view_infobox', $val); @@ -997,10 +1101,14 @@ public function setUseViewInfoboxAttribute($val) return $this; } + + // @phpstan-ignore-next-line public function getViewInfoboxTitleAttribute() { return $this->getOption('view_infobox_title'); } + + // @phpstan-ignore-next-line public function setViewInfoboxTitleAttribute($val) { $this->setOption('view_infobox_title', $val); @@ -1008,10 +1116,14 @@ public function setViewInfoboxTitleAttribute($val) return $this; } + + // @phpstan-ignore-next-line public function getViewInfoboxAttribute() { return $this->getOption('view_infobox'); } + + // @phpstan-ignore-next-line public function setViewInfoboxAttribute($val) { $this->setOption('view_infobox', $val); @@ -1019,11 +1131,15 @@ public function setViewInfoboxAttribute($val) return $this; } + + // @phpstan-ignore-next-line public function getHeaderAlignAttribute() { return $this->getOption('header_align'); } + + // @phpstan-ignore-next-line public function setHeaderAlignAttribute($val) { $this->setOption('header_align', $val); @@ -1031,6 +1147,8 @@ public function setHeaderAlignAttribute($val) return $this; } + + // @phpstan-ignore-next-line public function getHeaderOptions() { $attributes = []; @@ -1056,6 +1174,8 @@ public function getDisabledDeleteAttribute() /** * Whether login user has edit permission about this view. */ + + // @phpstan-ignore-next-line public function hasEditPermission() { $login_user = \Exment::user(); @@ -1080,6 +1200,8 @@ public function hasEditPermission() * * @return array */ + + // @phpstan-ignore-next-line public function getQueryData() { $query = $this->custom_table->getValueQuery(); @@ -1092,6 +1214,8 @@ public function getQueryData() * @param int|string $id * @return array [boolean, string] status, error message. */ + + // @phpstan-ignore-next-line public static function validateDestroy($id) { // check notify target view diff --git a/src/Model/CustomViewColumn.php b/src/Model/CustomViewColumn.php index 29ebd3da5..21dba446f 100644 --- a/src/Model/CustomViewColumn.php +++ b/src/Model/CustomViewColumn.php @@ -35,6 +35,8 @@ class CustomViewColumn extends ModelBase //protected $with = ['custom_column']; protected $casts = ['options' => 'json']; + + // @phpstan-ignore-next-line public static $templateItems = [ 'excepts' => [ 'import' => ['custom_table', 'view_column_target', 'custom_column', 'target_view_name', 'view_group_condition', 'view_pivot_column_name', 'view_pivot_table_name'], @@ -79,6 +81,8 @@ class CustomViewColumn extends ModelBase * get eloquent using request settion. * now only support only id. */ + + // @phpstan-ignore-next-line public static function getEloquent($id, $withs = []) { return static::getEloquentDefault($id, $withs); @@ -96,10 +100,14 @@ protected static function boot() static::addGlobalScope(new OrderScope('order')); } + + // @phpstan-ignore-next-line public function getViewColumnColorAttribute() { return $this->getOption('color'); } + + // @phpstan-ignore-next-line public function setViewColumnColorAttribute($view_column_color) { $this->setOption('color', $view_column_color); @@ -107,10 +115,14 @@ public function setViewColumnColorAttribute($view_column_color) return $this; } + + // @phpstan-ignore-next-line public function getViewColumnFontColorAttribute() { return $this->getOption('font_color'); } + + // @phpstan-ignore-next-line public function setViewColumnFontColorAttribute($view_column_color) { $this->setOption('font_color', $view_column_color); @@ -118,10 +130,14 @@ public function setViewColumnFontColorAttribute($view_column_color) return $this; } + + // @phpstan-ignore-next-line public function getViewColumnEndDateAttribute() { return $this->getViewColumnTarget('view_column_table_id', 'options.end_date_type', 'options.end_date_target'); } + + // @phpstan-ignore-next-line public function setViewColumnEndDateAttribute($end_date) { if (!isset($end_date)) { @@ -138,34 +154,48 @@ public function setViewColumnEndDateAttribute($end_date) return $this; } + + // @phpstan-ignore-next-line public function getViewPivotColumnIdAttribute() { return $this->getViewPivotIdTrait('view_pivot_column_id'); } + + // @phpstan-ignore-next-line public function setViewPivotColumnIdAttribute($view_pivot_column_id) { return $this->setViewPivotIdTrait('view_pivot_column_id', $view_pivot_column_id); } + + // @phpstan-ignore-next-line public function getViewPivotTableIdAttribute() { return $this->getViewPivotIdTrait('view_pivot_table_id'); } + + // @phpstan-ignore-next-line public function setViewPivotTableIdAttribute($view_pivot_table_id) { return $this->setViewPivotIdTrait('view_pivot_table_id', $view_pivot_table_id); } + + // @phpstan-ignore-next-line public function getViewGroupConditionAttribute() { return $this->getOption('view_group_condition'); } + + // @phpstan-ignore-next-line public function setViewGroupConditionAttribute($view_group_condition) { return $this->setOption('view_group_condition', $view_group_condition); } + + // @phpstan-ignore-next-line public function getViewColumnEndDateTypeAttribute() { return $this->getOption('end_date_type'); @@ -177,6 +207,8 @@ public function getViewColumnEndDateTypeAttribute() * @param array $json * @return void */ + + // @phpstan-ignore-next-line protected function exportReplaceJson(&$json) { self:: exportReplaceJsonTrait($json); @@ -187,6 +219,8 @@ protected function exportReplaceJson(&$json) if ($end_date_target) { if ($end_date_type == ConditionType::COLUMN) { $custom_column = CustomColumn::find($end_date_target); + + // @phpstan-ignore-next-line $json['end_date_target_name'] = $custom_column? $custom_column->column_name: null; } elseif ($end_date_type == ConditionType::SYSTEM) { $json['end_date_target_name'] = SystemColumn::getOption(['id' => $end_date_target])['name']; diff --git a/src/Model/CustomViewFilter.php b/src/Model/CustomViewFilter.php index 06ffd8341..8433bc0a8 100644 --- a/src/Model/CustomViewFilter.php +++ b/src/Model/CustomViewFilter.php @@ -31,6 +31,8 @@ class CustomViewFilter extends ModelBase protected $appends = ['view_column_target', 'view_filter_condition_value']; protected $casts = ['options' => 'json']; + + // @phpstan-ignore-next-line public static $templateItems = [ 'excepts' => [ 'import' => ['custom_table', 'view_column_table_id', 'view_column_target', 'custom_column'], @@ -73,6 +75,8 @@ class CustomViewFilter extends ModelBase /** * get edited view_filter_condition_value_text. */ + + // @phpstan-ignore-next-line public function getViewFilterConditionValueAttribute() { if (is_string($this->view_filter_condition_value_text)) { @@ -90,6 +94,8 @@ public function getViewFilterConditionValueAttribute() * set view_filter_condition_value_text. * * we have to convert int if view_filter_condition_value is array* */ + + // @phpstan-ignore-next-line public function setViewFilterConditionValueAttribute($view_filter_condition_value) { if (is_array($view_filter_condition_value)) { @@ -106,24 +112,34 @@ public function setViewFilterConditionValueAttribute($view_filter_condition_valu * get eloquent using request settion. * now only support only id. */ + + // @phpstan-ignore-next-line public static function getEloquent($id, $withs = []) { return static::getEloquentDefault($id, $withs); } + + // @phpstan-ignore-next-line public function getViewPivotColumnIdAttribute() { return $this->getViewPivotIdTrait('view_pivot_column_id'); } + + // @phpstan-ignore-next-line public function setViewPivotColumnIdAttribute($view_pivot_column_id) { return $this->setViewPivotIdTrait('view_pivot_column_id', $view_pivot_column_id); } + + // @phpstan-ignore-next-line public function getViewPivotTableIdAttribute() { return $this->getViewPivotIdTrait('view_pivot_table_id'); } + + // @phpstan-ignore-next-line public function setViewPivotTableIdAttribute($view_pivot_table_id) { return $this->setViewPivotIdTrait('view_pivot_table_id', $view_pivot_table_id); @@ -133,6 +149,8 @@ public function setViewPivotTableIdAttribute($view_pivot_table_id) /** * set value filter */ + + // @phpstan-ignore-next-line public function setValueFilter($query, $or_option = false) { // get filter target column diff --git a/src/Model/CustomViewGridFilter.php b/src/Model/CustomViewGridFilter.php index 9a64ee19a..2a88a13cd 100644 --- a/src/Model/CustomViewGridFilter.php +++ b/src/Model/CustomViewGridFilter.php @@ -28,6 +28,8 @@ class CustomViewGridFilter extends ModelBase protected $appends = ['view_column_target']; protected $casts = ['options' => 'json']; + + // @phpstan-ignore-next-line public static $templateItems = [ 'excepts' => ['custom_table', 'view_column_table_id', 'view_column_target_id', 'custom_view_id', 'view_column_target', 'custom_column'], 'uniqueKeys' => ['custom_view_id', 'view_column_type', 'view_column_target_id', 'view_column_table_id'], @@ -65,6 +67,8 @@ class CustomViewGridFilter extends ModelBase * get eloquent using request settion. * now only support only id. */ + + // @phpstan-ignore-next-line public static function getEloquent($id, $withs = []) { return static::getEloquentDefault($id, $withs); @@ -82,19 +86,27 @@ protected static function boot() static::addGlobalScope(new OrderScope('order')); } + + // @phpstan-ignore-next-line public function getViewPivotColumnIdAttribute() { return $this->getViewPivotIdTrait('view_pivot_column_id'); } + + // @phpstan-ignore-next-line public function setViewPivotColumnIdAttribute($view_pivot_column_id) { return $this->setViewPivotIdTrait('view_pivot_column_id', $view_pivot_column_id); } + + // @phpstan-ignore-next-line public function getViewPivotTableIdAttribute() { return $this->getViewPivotIdTrait('view_pivot_table_id'); } + + // @phpstan-ignore-next-line public function setViewPivotTableIdAttribute($view_pivot_table_id) { return $this->setViewPivotIdTrait('view_pivot_table_id', $view_pivot_table_id); diff --git a/src/Model/CustomViewSort.php b/src/Model/CustomViewSort.php index 9dfbb5c32..3cef698cd 100644 --- a/src/Model/CustomViewSort.php +++ b/src/Model/CustomViewSort.php @@ -28,6 +28,8 @@ class CustomViewSort extends ModelBase protected $appends = ['view_column_target']; protected $casts = ['options' => 'json']; + + // @phpstan-ignore-next-line public static $templateItems = [ 'excepts' => ['custom_table', 'view_column_table_id', 'view_column_target_id', 'custom_view_id', 'view_column_target', 'custom_column'], 'uniqueKeys' => ['custom_view_id', 'view_column_type', 'view_column_target_id', 'view_column_table_id'], @@ -65,6 +67,8 @@ class CustomViewSort extends ModelBase * get eloquent using request settion. * now only support only id. */ + + // @phpstan-ignore-next-line public static function getEloquent($id, $withs = []) { return static::getEloquentDefault($id, $withs); @@ -82,19 +86,27 @@ protected static function boot() static::addGlobalScope(new OrderScope('priority')); } + + // @phpstan-ignore-next-line public function getViewPivotColumnIdAttribute() { return $this->getViewPivotIdTrait('view_pivot_column_id'); } + + // @phpstan-ignore-next-line public function setViewPivotColumnIdAttribute($view_pivot_column_id) { return $this->setViewPivotIdTrait('view_pivot_column_id', $view_pivot_column_id); } + + // @phpstan-ignore-next-line public function getViewPivotTableIdAttribute() { return $this->getViewPivotIdTrait('view_pivot_table_id'); } + + // @phpstan-ignore-next-line public function setViewPivotTableIdAttribute($view_pivot_table_id) { return $this->setViewPivotIdTrait('view_pivot_table_id', $view_pivot_table_id); diff --git a/src/Model/CustomViewSummary.php b/src/Model/CustomViewSummary.php index 8974fb42b..2bf68f311 100644 --- a/src/Model/CustomViewSummary.php +++ b/src/Model/CustomViewSummary.php @@ -29,6 +29,8 @@ class CustomViewSummary extends ModelBase protected $appends = ['view_column_target', 'sort_order', 'sort_type']; protected $casts = ['options' => 'json']; + + // @phpstan-ignore-next-line public static $templateItems = [ 'excepts' => ['custom_table', 'view_column_table_id', 'view_column_target_id', 'custom_view_id', 'view_column_target', 'custom_column'], 'uniqueKeys' => ['custom_view_id', 'view_column_type', 'view_column_target_id', 'view_column_table_id'], @@ -66,11 +68,15 @@ class CustomViewSummary extends ModelBase ], ]; + + // @phpstan-ignore-next-line public function custom_view(): BelongsTo { return $this->belongsTo(CustomView::class, 'custom_view_id'); } + + // @phpstan-ignore-next-line public function custom_column(): ?BelongsTo { if ($this->view_column_type != ConditionType::COLUMN) { @@ -79,24 +85,34 @@ public function custom_column(): ?BelongsTo return $this->belongsTo(CustomColumn::class, 'view_column_target_id'); } + + // @phpstan-ignore-next-line public function custom_table(): BelongsTo { return $this->belongsTo(CustomTable::class, 'view_column_table_id'); } + + // @phpstan-ignore-next-line public function getViewPivotColumnIdAttribute() { return $this->getViewPivotIdTrait('view_pivot_column_id'); } + + // @phpstan-ignore-next-line public function setViewPivotColumnIdAttribute($view_pivot_column_id) { return $this->setViewPivotIdTrait('view_pivot_column_id', $view_pivot_column_id); } + + // @phpstan-ignore-next-line public function getViewPivotTableIdAttribute() { return $this->getViewPivotIdTrait('view_pivot_table_id'); } + + // @phpstan-ignore-next-line public function setViewPivotTableIdAttribute($view_pivot_table_id) { return $this->setViewPivotIdTrait('view_pivot_table_id', $view_pivot_table_id); @@ -106,6 +122,8 @@ public function setViewPivotTableIdAttribute($view_pivot_table_id) * get eloquent using request settion. * now only support only id. */ + + // @phpstan-ignore-next-line public static function getEloquent($id, $withs = []) { return static::getEloquentDefault($id, $withs); diff --git a/src/Model/Dashboard.php b/src/Model/Dashboard.php index 7f6fa119a..bb4b347c9 100644 --- a/src/Model/Dashboard.php +++ b/src/Model/Dashboard.php @@ -34,6 +34,8 @@ class Dashboard extends ModelBase implements Interfaces\TemplateImporterInterfac protected $guarded = ['id']; protected $casts = ['options' => 'json']; + + // @phpstan-ignore-next-line public static $templateItems = [ 'excepts' => ['suuid'], 'uniqueKeys' => ['dashboard_name'], @@ -55,6 +57,8 @@ class Dashboard extends ModelBase implements Interfaces\TemplateImporterInterfac ], ]; + + // @phpstan-ignore-next-line public function dashboard_boxes(): HasMany { return $this->hasMany(DashboardBox::class, 'dashboard_id') @@ -68,6 +72,8 @@ public function dashboard_boxes(): HasMany * @param int $row_no * @return \Illuminate\Support\Collection */ + + // @phpstan-ignore-next-line public function dashboard_row_boxes($row_no) { return DashboardBox::allRecords(function ($record) use ($row_no) { @@ -81,6 +87,8 @@ public function dashboard_row_boxes($row_no) }, false)->sortBy('column_no'); } + + // @phpstan-ignore-next-line public function data_share_authoritables(): HasMany { return $this->hasMany(DataShareAuthoritable::class, 'parent_id') @@ -90,6 +98,8 @@ public function data_share_authoritables(): HasMany /** * get default dashboard */ + + // @phpstan-ignore-next-line public static function getDefault() { $user = Admin::user(); @@ -137,6 +147,8 @@ public static function getDefault() * get eloquent using request settion. * now only support only id. */ + + // @phpstan-ignore-next-line public static function getEloquent($id, $withs = []) { return static::getEloquentDefault($id, $withs); @@ -172,6 +184,8 @@ protected static function boot() }); } + + // @phpstan-ignore-next-line protected function setDefaultFlgFilter($query) { $query->where('dashboard_type', $this->dashboard_type); @@ -182,6 +196,8 @@ protected function setDefaultFlgFilter($query) } } + + // @phpstan-ignore-next-line protected function setDefaultFlgSet() { // set if only this flg is system @@ -196,6 +212,8 @@ protected function setDefaultFlgSet() * @param \Illuminate\Database\Eloquent\Builder $query * @return void */ + + // @phpstan-ignore-next-line protected static function showableDashboards($query) { $query->where('dashboard_type', DashboardType::SYSTEM); @@ -252,16 +270,23 @@ public function hasEditPermission() return $hasEdit; } + + // @phpstan-ignore-next-line public static function hasSystemPermission() { + return \Admin::user()->hasPermission(Permission::SYSTEM); } + + // @phpstan-ignore-next-line public static function hasPermission() { return System::userdashboard_available() || static::hasSystemPermission(); } + + // @phpstan-ignore-next-line public function deletingChildren() { $this->dashboard_boxes()->delete(); diff --git a/src/Model/DashboardBox.php b/src/Model/DashboardBox.php index 887ae1a08..6b2df0ce0 100644 --- a/src/Model/DashboardBox.php +++ b/src/Model/DashboardBox.php @@ -30,6 +30,8 @@ class DashboardBox extends ModelBase implements Interfaces\TemplateImporterInter protected $guarded = ['id']; protected $casts = ['options' => 'json']; + + // @phpstan-ignore-next-line public static $templateItems = [ 'excepts' => ['suuid'], 'langs' => [ @@ -106,11 +108,15 @@ class DashboardBox extends ModelBase implements Interfaces\TemplateImporterInter ], ]; + + // @phpstan-ignore-next-line public function dashboard() { return $this->belongsTo(Dashboard::class, 'dashboard_id'); } + + // @phpstan-ignore-next-line public function getDashboardBoxItemAttribute() { $enum_class = DashboardBoxType::getEnum($this->dashboard_box_type)->getDashboardBoxItemClass(); @@ -121,6 +127,8 @@ public function getDashboardBoxItemAttribute() * get eloquent using request settion. * now only support only id. */ + + // @phpstan-ignore-next-line public static function getEloquent($id, $withs = []) { return static::getEloquentDefault($id, $withs); @@ -131,6 +139,8 @@ public static function getEloquent($id, $withs = []) * * @return array */ + + // @phpstan-ignore-next-line public function getBoxHtmlAttr(): array { $attributes = [ @@ -146,6 +156,8 @@ public function getBoxHtmlAttr(): array })->toArray(); } + + // @phpstan-ignore-next-line protected function getUniqueKeyValues($key) { if (is_array($key) && count($key) > 0) { @@ -182,6 +194,8 @@ protected function getUniqueKeyValues($key) ]; } + + // @phpstan-ignore-next-line protected static function importReplaceJson(&$json, $options = []) { // switch dashboard_box_type @@ -211,6 +225,8 @@ protected static function importReplaceJson(&$json, $options = []) static::importReplaceJsonCustomColumn('chart_axisy', $json); } + + // @phpstan-ignore-next-line protected static function importReplaceJsonCustomColumn($key, &$json) { $custom_column_key = "options.{$key}_column_name"; diff --git a/src/Model/DataShareAuthoritable.php b/src/Model/DataShareAuthoritable.php index 883be3a63..cb9dc66c7 100644 --- a/src/Model/DataShareAuthoritable.php +++ b/src/Model/DataShareAuthoritable.php @@ -18,6 +18,8 @@ class DataShareAuthoritable extends ModelBase /** * Set Data Share Authoritable after custom value save */ + + // @phpstan-ignore-next-line public static function setDataAuthoritable($target_data) { $target_type = static::getTargetType($target_data); @@ -42,6 +44,8 @@ public static function setDataAuthoritable($target_data) * @param $target_data * @return ShareTargetType */ + + // @phpstan-ignore-next-line public static function getTargetType($target_data) { if ($target_data instanceof CustomView) { @@ -56,6 +60,8 @@ public static function getTargetType($target_data) * * @return void */ + + // @phpstan-ignore-next-line public static function deleteDataAuthoritable($target_data) { $target_type = static::getTargetType($target_data); @@ -70,6 +76,8 @@ public static function deleteDataAuthoritable($target_data) * * @return ModalForm */ + + // @phpstan-ignore-next-line public static function getShareDialogForm($target_data, $tableKey = null) { $id = $target_data->id; @@ -137,6 +145,8 @@ public static function getShareDialogForm($target_data, $tableKey = null) * get listbox options default * */ + + // @phpstan-ignore-next-line protected static function getUserOrgSelectDefault($target_key, $id, $permission) { // get values @@ -158,6 +168,8 @@ protected static function getUserOrgSelectDefault($target_key, $id, $permission) * * @return \Symfony\Component\HttpFoundation\Response */ + + // @phpstan-ignore-next-line public static function saveShareDialogForm($target_data) { $custom_table = $target_data->custom_table; @@ -219,6 +231,7 @@ public static function saveShareDialogForm($target_data) }, ])); } + // Laravel facade DB not recognized \DB::commit(); System::clearCache(); diff --git a/src/Model/Define.php b/src/Model/Define.php index ba353090a..65cb84b0d 100644 --- a/src/Model/Define.php +++ b/src/Model/Define.php @@ -411,6 +411,8 @@ class Define 'data', ]; + + // @phpstan-ignore-next-line public static function FILE_OPTION() { // get max size diff --git a/src/Model/File.php b/src/Model/File.php index b073f666e..e5334e876 100644 --- a/src/Model/File.php +++ b/src/Model/File.php @@ -48,11 +48,15 @@ class File extends ModelBase // increment disable public $incrementing = false; + + // @phpstan-ignore-next-line public function getPathAttribute() { return path_join($this->local_dirname, $this->local_filename); } + + // @phpstan-ignore-next-line public function getExtensionAttribute() { if (!isset($this->local_filename)) { @@ -70,6 +74,8 @@ public function getExtensionAttribute() * @param array|boolean|null $options (Old version, this args is boolean) * @return string|null */ + + // @phpstan-ignore-next-line public static function getUrl($path, $options = []): ?string { if ($options === true) { @@ -126,6 +132,8 @@ public static function getFileFromFormColumn(?string $form_column): ?File /** * save document model. Please call after save file */ + + // @phpstan-ignore-next-line public function saveDocumentModel($custom_value, $document_name) { // save Document Model @@ -155,11 +163,15 @@ public function saveDocumentModel($custom_value, $document_name) public function saveCustomValue($custom_value_id, $custom_column = null, $custom_table = null) { if (!is_nullorempty($custom_column)) { + + // @phpstan-ignore-next-line return $this->saveCustomValueAndColumn($custom_value_id, $custom_column, $custom_table); } if (!is_nullorempty($custom_value_id)) { $this->parent_id = $custom_value_id; + + // @phpstan-ignore-next-line $this->parent_type = $custom_table->table_name; } $this->save(); @@ -217,6 +229,8 @@ public function saveCustomValueAndColumn($custom_value_id, $custom_column, $cust * @param string $dirname directory name * @return File */ + + // @phpstan-ignore-next-line public static function saveFileInfo(?string $file_type, string $dirname, array $options = []): File { $options = array_merge([ @@ -283,6 +297,8 @@ public static function deleteFileInfo($file) /** * Delete document model and file */ + + // @phpstan-ignore-next-line public static function deleteDocumentModel($file, bool $isDeleteFile = true) { if ($isDeleteFile) { @@ -331,6 +347,8 @@ public static function getFile($uuid, \Closure $authCallback = null) /** * get CustomValue from form. for saved CustomValue */ + + // @phpstan-ignore-next-line public function getCustomValueFromForm($custom_value, $uuidObj) { // replace $uuidObj[path] for windows @@ -371,6 +389,8 @@ public function getCustomValueFromForm($custom_value, $uuidObj) * @param \Illuminate\Http\UploadedFile|\Symfony\Component\HttpFoundation\File\UploadedFile|string|null $content file content * @return File */ + + // @phpstan-ignore-next-line public static function put(?string $file_type, $path, $content, array $options = []) { $file = static::saveFileInfo($file_type, $path, $options); @@ -393,6 +413,8 @@ public static function put(?string $file_type, $path, $content, array $options = * @param array $options * @return File */ + + // @phpstan-ignore-next-line public static function storeAs(?string $file_type, $content, string $dirname, string $name, array $options = []): File { $options = array_merge([ @@ -418,6 +440,8 @@ public static function storeAs(?string $file_type, $content, string $dirname, st * @param string|File|array $pathOrUuids * @return File|null */ + + // @phpstan-ignore-next-line public static function getData($pathOrUuids) { if (is_nullorempty($pathOrUuids)) { @@ -464,6 +488,8 @@ public static function getData($pathOrUuids) /** * get unique file name */ + + // @phpstan-ignore-next-line public static function getUniqueFileName($dirname, $filename = null, $override = false) { if ($override) { @@ -486,6 +512,8 @@ public static function getUniqueFileName($dirname, $filename = null, $override = /** * get directory and filename from path */ + + // @phpstan-ignore-next-line protected static function getDirAndFileName($path) { $pathinfo = pathinfo($path); diff --git a/src/Model/Interfaces/TemplateImporterInterface.php b/src/Model/Interfaces/TemplateImporterInterface.php index b325d83b3..bea06e8c1 100644 --- a/src/Model/Interfaces/TemplateImporterInterface.php +++ b/src/Model/Interfaces/TemplateImporterInterface.php @@ -4,5 +4,7 @@ interface TemplateImporterInterface { + + // @phpstan-ignore-next-line public static function importTemplate($json, $flg, $options = []); } diff --git a/src/Model/Linkage.php b/src/Model/Linkage.php index 5416f9c7d..2bc2997f2 100644 --- a/src/Model/Linkage.php +++ b/src/Model/Linkage.php @@ -10,10 +10,18 @@ */ class Linkage { + + // @phpstan-ignore-next-line public $parent_column; + + // @phpstan-ignore-next-line public $child_column; + + // @phpstan-ignore-next-line public $searchType; + + // @phpstan-ignore-next-line public function __construct(array $params = []) { $this->parent_column = array_get($params, 'parent_column'); @@ -21,10 +29,14 @@ public function __construct(array $params = []) $this->searchType = array_get($params, 'searchType'); } + + // @phpstan-ignore-next-line public function parent_custom_table() { return isset($this->parent_column) ? $this->parent_column->custom_table_cache : null; } + + // @phpstan-ignore-next-line public function child_custom_table() { return isset($this->child_column) ? $this->child_column->custom_table_cache : null; @@ -37,6 +49,8 @@ public function child_custom_table() * * @return array contains parent_column, child_column, searchType */ + + // @phpstan-ignore-next-line public static function getSelectTableLinkages($custom_table, $checkPermission = true) { $result = []; @@ -99,6 +113,8 @@ public static function getSelectTableLinkages($custom_table, $checkPermission = * @param CustomColumn|string|null $child_custom_column * @return \Illuminate\Support\Collection */ + + // @phpstan-ignore-next-line public static function getLinkages($parent_custom_column, $child_custom_column) { $parent_custom_column = CustomColumn::getEloquent($parent_custom_column); @@ -106,11 +122,15 @@ public static function getLinkages($parent_custom_column, $child_custom_column) if (is_nullorempty($child_custom_column)) { /** @var Collection $collection */ + + // @phpstan-ignore-next-line $collection = collect(); return $collection; } /** @var Collection $collection */ + + // @phpstan-ignore-next-line $collection = collect(static::getSelectTableLinkages($child_custom_column->custom_table_cache, false)) ->filter(function ($relationColumn) use ($parent_custom_column, $child_custom_column) { if (isset($parent_custom_column)) { @@ -138,6 +158,8 @@ public static function getLinkage($parent_custom_column, $child_custom_column) } + + // @phpstan-ignore-next-line public function getParentValueId($custom_value) { if (!isset($custom_value)) { @@ -157,6 +179,8 @@ public function getParentValueId($custom_value) * @param int|string|null $parent_v * @return void */ + + // @phpstan-ignore-next-line public function setQueryFilter($query, $parent_v) { $parent_target_table = $this->parent_column->select_target_table; diff --git a/src/Model/LoginSetting.php b/src/Model/LoginSetting.php index a6851583a..237823a10 100644 --- a/src/Model/LoginSetting.php +++ b/src/Model/LoginSetting.php @@ -23,12 +23,16 @@ class LoginSetting extends ModelBase protected $appends = ['login_type_text']; protected $casts = ['options' => 'json', 'active_flg' => 'boolean']; + + // @phpstan-ignore-next-line public function getLoginTypeTextAttribute() { $enum = LoginType::getEnum($this->login_type); return isset($enum) ? $enum->transKey('login.login_type_options') : null; } + + // @phpstan-ignore-next-line public function getProviderNameAttribute() { if ($this->login_type == LoginType::OAUTH) { @@ -44,6 +48,8 @@ public function getProviderNameAttribute() } } + + // @phpstan-ignore-next-line public function getNameIdFormatStringAttribute() { // create config(copied from setting file) @@ -127,6 +133,8 @@ public function getExmentCallbackUrlTestAttribute(): string * get eloquent using request settion. * now only support only id. */ + + // @phpstan-ignore-next-line public static function getEloquent($id, $withs = []) { return static::getEloquentDefault($id, $withs); @@ -137,6 +145,8 @@ public static function getEloquent($id, $withs = []) * * @return array */ + + // @phpstan-ignore-next-line public function getLoginButton() { $provider_name = $this->provider_name; @@ -162,8 +172,12 @@ public function getLoginButton() * * @return \Illuminate\Support\Collection */ + + // @phpstan-ignore-next-line public static function getAllSettings($filterActive = true) { + + // @phpstan-ignore-next-line return static::allRecords(function ($record) use ($filterActive) { return !$filterActive || $record->active_flg; }, false); @@ -174,6 +188,8 @@ public static function getAllSettings($filterActive = true) * * @return \Illuminate\Support\Collection */ + + // @phpstan-ignore-next-line public static function getSSOSettings($filterActive = true) { return static::getOAuthSettings($filterActive)->merge(static::getSamlSettings()); @@ -184,6 +200,8 @@ public static function getSSOSettings($filterActive = true) * * @return \Illuminate\Support\Collection */ + + // @phpstan-ignore-next-line public static function getOAuthSettings($filterActive = true) { return static::getAllSettings($filterActive)->filter(function ($record) { @@ -196,6 +214,8 @@ public static function getOAuthSettings($filterActive = true) * * @return ?LoginSetting */ + + // @phpstan-ignore-next-line public static function getOAuthSetting($provider_name, $filterActive = true) { return static::getOAuthSettings($filterActive)->first(function ($record) use ($provider_name) { @@ -208,6 +228,8 @@ public static function getOAuthSetting($provider_name, $filterActive = true) * * @return \Illuminate\Support\Collection */ + + // @phpstan-ignore-next-line public static function getSamlSettings($filterActive = true) { return static::getAllSettings($filterActive)->filter(function ($record) { @@ -220,6 +242,8 @@ public static function getSamlSettings($filterActive = true) * * @return ?LoginSetting */ + + // @phpstan-ignore-next-line public static function getSamlSetting($provider_name, $filterActive = true) { return static::getSamlSettings($filterActive)->first(function ($record) use ($provider_name) { @@ -232,6 +256,8 @@ public static function getSamlSetting($provider_name, $filterActive = true) * * @return \Illuminate\Support\Collection */ + + // @phpstan-ignore-next-line public static function getLdapSettings($filterActive = true) { return static::getAllSettings($filterActive)->filter(function ($record) { @@ -244,6 +270,8 @@ public static function getLdapSettings($filterActive = true) * * @return ?LoginSetting */ + + // @phpstan-ignore-next-line public static function getLdapSetting($provider_name, $filterActive = true) { return static::getLdapSettings($filterActive)->first(function ($record) use ($provider_name) { @@ -278,6 +306,8 @@ public static function getRedirectSSOForceUrl() /** * get Socialite Provider */ + + // @phpstan-ignore-next-line public static function getSocialiteProvider($login_provider, $isTest = false, ?string $redirectUrl = null) { if (is_string($login_provider)) { @@ -313,6 +343,8 @@ public static function getSocialiteProvider($login_provider, $isTest = false, ?s // If has custom setting, call custom config. if (!is_nullorempty($socialiteProvider) && is_subclass_of($socialiteProvider, \Exceedone\Exment\Auth\ProviderLoginConfig::class)) { + + // @phpstan-ignore-next-line $socialiteProvider->setLoginCustomConfig($provider); } @@ -322,6 +354,8 @@ public static function getSocialiteProvider($login_provider, $isTest = false, ?s /** * get Socialite Provider */ + + // @phpstan-ignore-next-line public static function getSamlAuth($login_provider, bool $isTest = false) { if (!class_exists('\\Aacotroneo\\Saml2\\Saml2Auth')) { diff --git a/src/Model/LoginUser.php b/src/Model/LoginUser.php index 8c174a4bc..659126214 100644 --- a/src/Model/LoginUser.php +++ b/src/Model/LoginUser.php @@ -39,34 +39,48 @@ class LoginUser extends ModelBase implements \Illuminate\Contracts\Auth\Authenti /** * send password */ + + // @phpstan-ignore-next-line protected $send_password = null; /** * is change password */ + + // @phpstan-ignore-next-line protected $changePassword = false; /** * taale "user" */ + + // @phpstan-ignore-next-line public function base_user(): BelongsTo { return $this->belongsTo(getModelName(SystemTableName::USER), 'base_user_id'); } + + // @phpstan-ignore-next-line public function getUserNameAttribute() { return $this->base_user->value['user_name'] ?? null; } + + // @phpstan-ignore-next-line public function getUserCodeAttribute() { return $this->base_user->value['user_code'] ?? null; } + + // @phpstan-ignore-next-line public function getEmailAttribute() { return $this->base_user->value['email'] ?? null; } + + // @phpstan-ignore-next-line public function getNameAttribute() { return $this->base_user->value['user_name'] ?? null; @@ -125,16 +139,22 @@ public function belong_organizations() } + + // @phpstan-ignore-next-line public function isLoginProvider() { return !is_nullorempty($this->login_provider); } + + // @phpstan-ignore-next-line public function findForPassport($username, ?array $credentials = []) { return LoginUserProvider::RetrieveByCredential(array_merge(['username' => $username], $credentials)); } + + // @phpstan-ignore-next-line public function validateForPassportPasswordGrant($password, ?array $credentials = []) { return LoginUserProvider::ValidateCredential($this, array_merge(['password' => $password], $credentials)); @@ -143,6 +163,8 @@ public function validateForPassportPasswordGrant($password, ?array $credentials /** * set sendPassword param */ + + // @phpstan-ignore-next-line public function sendPassword($sendPassword) { $this->send_password = $sendPassword; @@ -185,6 +207,8 @@ protected function send(bool $is_newuser): ?MailSender /** * get value from user setting table */ + + // @phpstan-ignore-next-line public function getSettingValue($key, $default = null) { if (is_null($this->base_user_id)) { @@ -208,6 +232,8 @@ public function getSettingValue($key, $default = null) // return array_get($settings, $key) ?? $default; } + + // @phpstan-ignore-next-line public function setSettingValue($key, $value) { if (is_null($this->base_user)) { @@ -253,6 +279,8 @@ public function forgetSettingValue($key) return $userSetting; } + + // @phpstan-ignore-next-line protected function setBcryptPassword() { $password = $this->password; diff --git a/src/Model/Menu.php b/src/Model/Menu.php index 817e1e611..6c86cbba2 100644 --- a/src/Model/Menu.php +++ b/src/Model/Menu.php @@ -38,6 +38,8 @@ class Menu extends AdminMenu implements Interfaces\TemplateImporterInterface protected $appends = ['menu_target_view']; protected $casts = ['options' => 'json']; + + // @phpstan-ignore-next-line public static $templateItems = [ 'excepts' => [ 'import' => ['permission'], @@ -81,21 +83,29 @@ class Menu extends AdminMenu implements Interfaces\TemplateImporterInterface * * @param array $attributes */ + + // @phpstan-ignore-next-line public function __construct(array $attributes = []) { parent::__construct($attributes); } + + // @phpstan-ignore-next-line public function getMenuTargetViewAttribute() { return $this->getOption('menu_target_view', false); } + + // @phpstan-ignore-next-line public function setMenuTargetViewAttribute($value) { return $this->setOption('menu_target_view', $value); } + + // @phpstan-ignore-next-line public static function getTableName() { return (new static())->getTable(); @@ -104,6 +114,8 @@ public static function getTableName() /** * @return array */ + + // @phpstan-ignore-next-line public function allNodes(): array { $grammar = DB::getQueryGrammar(); @@ -173,6 +185,8 @@ public function allNodes(): array } if (is_nullorempty($row['icon'])) { $table_options = json_decode_ex(array_get($row, 'table_options'), true); + + // @phpstan-ignore-next-line $row['icon'] = array_get($table_options, 'icon'); } $row['uri'] = 'data/'.$row['table_name']; @@ -211,6 +225,8 @@ public function allNodes(): array return $results; } + + // @phpstan-ignore-next-line public static function importReplaceJson(&$json, $options = []) { // Create menu. -------------------------------------------------- @@ -312,6 +328,8 @@ public static function importReplaceJson(&$json, $options = []) /** * get Table And Column Name */ + + // @phpstan-ignore-next-line protected function getUniqueKeyValues() { // add item diff --git a/src/Model/ModelBase.php b/src/Model/ModelBase.php index 9ccddc7fe..0ed03e88a 100644 --- a/src/Model/ModelBase.php +++ b/src/Model/ModelBase.php @@ -26,6 +26,8 @@ class ModelBase extends Model /** * @param array $attributes */ + + // @phpstan-ignore-next-line public function __construct(array $attributes = []) { parent::__construct($attributes); @@ -40,6 +42,8 @@ public function getCreatedUserAttribute() { return $this->getUser('created_user_id'); } + + // @phpstan-ignore-next-line public function getUpdatedUserAttribute() { return $this->getUser('updated_user_id'); @@ -54,6 +58,8 @@ public function getCreatedUserValueAttribute() { return $this->getUserValue('created_user_id'); } + + // @phpstan-ignore-next-line public function getUpdatedUserValueAttribute() { return $this->getUserValue('updated_user_id'); @@ -68,6 +74,8 @@ public function getCreatedUserTagAttribute() { return $this->getUser('created_user_id', true); } + + // @phpstan-ignore-next-line public function getUpdatedUserTagAttribute() { return $this->getUser('updated_user_id', true); @@ -82,6 +90,8 @@ public function getCreatedUserAvatarAttribute() { return $this->getUser('created_user_id', true, true); } + + // @phpstan-ignore-next-line public function getUpdatedUserAvatarAttribute() { return $this->getUser('updated_user_id', true, true); @@ -97,6 +107,8 @@ public function getDisabledDeleteAttribute() return false; } + + // @phpstan-ignore-next-line public static function getTableName() { return (new static())->getTable(); @@ -142,6 +154,8 @@ protected static function callClearCache() /** * set id to $columns */ + + // @phpstan-ignore-next-line protected static function setUser($model, $columns = []) { // if property 'saving_users' is false, return; @@ -149,6 +163,7 @@ protected static function setUser($model, $columns = []) return; } + // Exment helper class not recognized $user_id = \Exment::getUserId(); if (is_nullorempty($user_id)) { return; @@ -162,6 +177,8 @@ protected static function setUser($model, $columns = []) * get eloquent using request settion. * now only support only id. */ + + // @phpstan-ignore-next-line public static function getEloquentDefault($obj, $withs = [], $query_key = 'id') { return static::_getEloquent($obj, $withs, $query_key, 'firstRecord'); @@ -171,6 +188,8 @@ public static function getEloquentDefault($obj, $withs = [], $query_key = 'id') * get eloquent using request settion. * now only support only id. */ + + // @phpstan-ignore-next-line public static function getEloquentCache($obj, $withs = [], $query_key = 'id') { return static::_getEloquent($obj, $withs, $query_key, 'firstRecordCache'); @@ -180,6 +199,8 @@ public static function getEloquentCache($obj, $withs = [], $query_key = 'id') * get eloquent using request settion. * now only support only id. */ + + // @phpstan-ignore-next-line protected static function _getEloquent($obj, $withs = [], $query_key = 'id', $fucnName = 'firstRecord') { if (is_nullorempty($obj)) { @@ -210,6 +231,8 @@ protected static function _getEloquent($obj, $withs = [], $query_key = 'id', $fu /** * get user from id */ + + // @phpstan-ignore-next-line protected function getUser($column, $link = false, $addAvatar = false) { return getUserName($this->{$column}, $link, $addAvatar); @@ -218,6 +241,8 @@ protected function getUser($column, $link = false, $addAvatar = false) /** * get user from id */ + + // @phpstan-ignore-next-line protected function getUserValue($column) { return CustomTable::getEloquent(SystemTableName::USER)->getValueModel($this->{$column}, true); @@ -229,6 +254,8 @@ protected function getUserValue($column) * @param \Illuminate\Database\Query\Builder $query * @return \Exceedone\Exment\Database\Eloquent\ExtendedBuilder */ + + // @phpstan-ignore-next-line public function newEloquentBuilder($query) { return new \Exceedone\Exment\Database\Eloquent\ExtendedBuilder($query); diff --git a/src/Model/Notify.php b/src/Model/Notify.php index dba086637..f3d067688 100644 --- a/src/Model/Notify.php +++ b/src/Model/Notify.php @@ -52,8 +52,12 @@ class Notify extends ModelBase protected $guarded = ['id']; protected $casts = ['trigger_settings' => 'json', 'action_settings' => 'json']; + + // @phpstan-ignore-next-line protected $_schedule_date_column_item; + + // @phpstan-ignore-next-line public function custom_table(): ?BelongsTo { if (!in_array($this->notify_trigger, NotifyTrigger::CUSTOM_TABLES())) { @@ -63,6 +67,8 @@ public function custom_table(): ?BelongsTo ; } + + // @phpstan-ignore-next-line public function custom_view(): BelongsTo { if (isset($this->custom_view_id)) { @@ -71,11 +77,15 @@ public function custom_view(): BelongsTo return $this->belongsTo(CustomView::class, 'custom_view_id')->whereNotMatch(); } + + // @phpstan-ignore-next-line public function getNotifyActionsAttribute() { return explode(",", array_get($this->attributes, 'notify_actions')); } + + // @phpstan-ignore-next-line public function getTriggerSettingsAttribute() { $trigger_settings = $this->getAttributeFromArray('trigger_settings'); @@ -101,6 +111,8 @@ public function getTriggerSettingsAttribute() return $trigger_settings; } + + // @phpstan-ignore-next-line public function setTriggerSettingsAttribute($value = null) { $notify_target_date = array_get($value, 'notify_target_date'); @@ -124,6 +136,8 @@ public function setTriggerSettingsAttribute($value = null) $this->attributes['trigger_settings'] = $value; } + + // @phpstan-ignore-next-line public function getMailTemplate() { $mail_template_id = array_get($this, 'mail_template_id'); @@ -133,15 +147,21 @@ public function getMailTemplate() } } + + // @phpstan-ignore-next-line public function getTriggerSetting($key, $default = null) { return $this->getJson('trigger_settings', $key, $default); } + + // @phpstan-ignore-next-line public function setTriggerSetting($key, $value = null) { return $this->setJson('trigger_settings', $key, $value); } + + // @phpstan-ignore-next-line public function getMentionHere($action_setting) { $mention_here = array_get($action_setting, 'mention_here', false); @@ -149,6 +169,8 @@ public function getMentionHere($action_setting) return boolval($mention_here); } + + // @phpstan-ignore-next-line public function getMentionUsers($users) { return collect($users)->map(function ($user) { @@ -169,6 +191,7 @@ public function getScheduleDateColumnItemAttribute() // Now only column. $custom_column = CustomColumn::getEloquent(array_get($this, 'trigger_settings.notify_target_column')); + // Exment helper class not recognized $query_key = \Exment::getOptionKey($custom_column->id, true, $custom_column->custom_table_id, array_get($this, 'trigger_settings')); $this->_schedule_date_column_item = ColumnItems\CustomItem::getItem($custom_column, null, $query_key); @@ -182,6 +205,8 @@ public function getScheduleDateColumnItemAttribute() /** * notify user on schedule */ + + // @phpstan-ignore-next-line public function notifySchedule() { list($datalist, $table, $column) = $this->getNotifyTargetDatalist(); @@ -216,6 +241,8 @@ public function notifySchedule() continue; } + + // @phpstan-ignore-next-line $users = $this->uniqueUsers($users); foreach ($users as $user) { // send mail @@ -242,6 +269,8 @@ public function notifySchedule() * notify_create_update_user * *Contains Comment, share */ + + // @phpstan-ignore-next-line public function notifyCreateUpdateUser($custom_value, $notifySavedType, $options = []) { if (!$this->isNotifyTarget($custom_value, NotifyTrigger::CREATE_UPDATE_DATA, $notifySavedType)) { @@ -269,6 +298,8 @@ public function notifyCreateUpdateUser($custom_value, $notifySavedType, $options * notify target user. * *Contains Comment, share */ + + // @phpstan-ignore-next-line public function notifyUser($custom_value, $options = []) { $options = array_merge( @@ -367,6 +398,7 @@ public function notifyUser($custom_value, $options = []) } // throw mailsend Exception catch (TransportExceptionInterface $ex) { + // Laravel facade Log not recognized \Log::error($ex); // show warning message admin_warning(exmtrans('error.header'), exmtrans('error.mailsend_failed')); @@ -380,6 +412,8 @@ public function notifyUser($custom_value, $options = []) * notify workflow * *Contains Comment, share */ + + // @phpstan-ignore-next-line public function notifyWorkflow(CustomValue $custom_value, WorkflowAction $workflow_action, WorkflowValue $workflow_value, $statusTo) { $workflow = $workflow_action->workflow_cache; @@ -421,6 +455,8 @@ public function notifyWorkflow(CustomValue $custom_value, WorkflowAction $workfl continue; } + + // @phpstan-ignore-next-line $users = $this->uniqueUsers($users); foreach ($users as $user) { // send mail @@ -440,6 +476,7 @@ public function notifyWorkflow(CustomValue $custom_value, WorkflowAction $workfl } // throw mailsend Exception catch (TransportExceptionInterface $ex) { + // Laravel facade Log not recognized \Log::error($ex); // show warning message admin_warning(exmtrans('error.header'), exmtrans('error.mailsend_failed')); @@ -513,6 +550,8 @@ public function isNotifyTarget($custom_value, $notify_trigger, $notifySavedType /** * notify_create_update_user */ + + // @phpstan-ignore-next-line public function notifyButtonClick($custom_value, $target_user_keys, $subject, $body, $attachments = []) { $custom_table = $custom_value->custom_table; @@ -583,6 +622,7 @@ public function notifyButtonClick($custom_value, $target_user_keys, $subject, $b } // throw mailsend Exception catch (TransportExceptionInterface $ex) { + // Laravel facade Log not recognized \Log::error($ex); // show warning message admin_warning(exmtrans('error.header'), exmtrans('error.mailsend_failed')); @@ -594,6 +634,8 @@ public function notifyButtonClick($custom_value, $target_user_keys, $subject, $b /** * get notify target datalist */ + + // @phpstan-ignore-next-line protected function getNotifyTargetDatalist() { // get target date number. @@ -629,6 +671,8 @@ protected function getNotifyTargetDatalist() * @param CustomTable|null $custom_table * @return array|Collection|\Tightenco\Collect\Support\Collection */ + + // @phpstan-ignore-next-line public function getNotifyTargetUsers($custom_value, array $action_setting, ?CustomTable $custom_table = null) { $notify_action_target = array_get($action_setting, 'notify_action_target'); @@ -658,6 +702,8 @@ public function getNotifyTargetUsers($custom_value, array $action_setting, ?Cust * @param $statusTo * @return array|Collection|\Tightenco\Collect\Support\Collection */ + + // @phpstan-ignore-next-line public function getNotifyTargetUsersWorkflow(CustomValue $custom_value, array $action_setting, WorkflowAction $workflow_action, WorkflowValue $workflow_value, $statusTo) { $notify_action_target = array_get($action_setting, 'notify_action_target'); @@ -679,6 +725,7 @@ public function getNotifyTargetUsersWorkflow(CustomValue $custom_value, array $a } } + // Exment helper class not recognized $loginuser = \Exment::user(); $values = $values->unique()->filter(function ($value) use ($loginuser) { if (is_nullorempty($loginuser)) { @@ -700,9 +747,12 @@ public function getNotifyTargetUsersWorkflow(CustomValue $custom_value, array $a /** * whether $user is target send user */ + + // @phpstan-ignore-next-line protected function approvalSendUser($mail_template, $custom_table, $custom_value, NotifyTarget $user, $checkHistory = true) { // if $user is myself, return false + // Exment helper class not recognized $loginuser = \Exment::user(); if (!$this->isNotifyMyself()) { if ($checkHistory && !is_nullorempty($loginuser) && isMatchString($loginuser->email, $user->email())) { @@ -758,6 +808,8 @@ protected function isNotifyMyself(): bool * @param array|Collection $users * @return Collection */ + + // @phpstan-ignore-next-line protected function uniqueUsers($users): Collection { return collect($users)->unique(function ($user) { @@ -777,6 +829,8 @@ protected static function boot() }); } + + // @phpstan-ignore-next-line protected function getNotifyTargetValue($custom_value, $column) { $item = $column->column_item diff --git a/src/Model/NotifyTarget.php b/src/Model/NotifyTarget.php index 39af823fb..ea223245e 100644 --- a/src/Model/NotifyTarget.php +++ b/src/Model/NotifyTarget.php @@ -82,26 +82,36 @@ class NotifyTarget */ protected $id; + + // @phpstan-ignore-next-line public function notifyKey() { return $this->notifyKey; } + + // @phpstan-ignore-next-line public function id() { return $this->id; } + + // @phpstan-ignore-next-line public function email() { return $this->email; } + + // @phpstan-ignore-next-line public function slack_id() { return $this->slack_id; } + + // @phpstan-ignore-next-line public function getLabel() { if (isset($this->email)) { @@ -111,6 +121,8 @@ public function getLabel() return $this->name; } + + // @phpstan-ignore-next-line public function toArray() { return [ @@ -141,6 +153,8 @@ public function getUserId() * @param CustomTable|null $custom_table * @return Collection|\Tightenco\Collect\Support\Collection */ + + // @phpstan-ignore-next-line public static function getModels(Notify $notify, ?CustomValue $custom_value, $notify_action_target, array $action_setting, ?CustomTable $custom_table = null) { $notifyTarget = NotifyTargetBase::make($notify_action_target, $notify, $action_setting); @@ -214,6 +228,8 @@ public static function getModelAsUser(?CustomValue $target_value, ?CustomColumn return NotifyTarget::getModelAsSelectTable($target_value, NotifyTargetType::USER, $custom_column); } + + // @phpstan-ignore-next-line public static function getModelsAsOrganization(?CustomValue $target_value, ?CustomColumn $custom_column = null): Collection { // get organization user @@ -235,6 +251,8 @@ public static function getModelsAsOrganization(?CustomValue $target_value, ?Cust * @param CustomValue $custom_value * @return Collection */ + + // @phpstan-ignore-next-line public static function getModelsAsRole(?CustomValue $custom_value, ?CustomTable $custom_table = null): Collection { $items = AuthUserOrgHelper::getRoleUserAndOrganizations($custom_value, Permission::AVAILABLE_ALL_CUSTOM_VALUE, $custom_table); @@ -252,6 +270,8 @@ public static function getModelsAsRole(?CustomValue $custom_value, ?CustomTable return $list->filter()->unique(); } + + // @phpstan-ignore-next-line public static function getSelectedNotifyTarget($select_target, Notify $notify, ?CustomValue $custom_value) { // all target users @@ -265,6 +285,8 @@ public static function getSelectedNotifyTarget($select_target, Notify $notify, ? return $user; } + + // @phpstan-ignore-next-line public static function getSelectedNotifyTargets($select_targets, Notify $notify, ?CustomValue $custom_value) { // all target users diff --git a/src/Model/OperationLog.php b/src/Model/OperationLog.php index b0868995d..b1923f7a5 100644 --- a/src/Model/OperationLog.php +++ b/src/Model/OperationLog.php @@ -12,6 +12,8 @@ class OperationLog extends \Encore\Admin\Auth\Database\OperationLog use Traits\SerializeDateTrait; //protected $appends = ['base_user_id']; + + // @phpstan-ignore-next-line public function getBaseUserIdAttribute() { if (isMatchString($this->user_id, 0)) { @@ -22,6 +24,8 @@ public function getBaseUserIdAttribute() return $user ? $user->base_user_id : "0"; } + + // @phpstan-ignore-next-line public function getUserNameAttribute() { if (isMatchString($this->user_id, 0)) { diff --git a/src/Model/OrderScope.php b/src/Model/OrderScope.php index 29a050c6a..c493a26b0 100644 --- a/src/Model/OrderScope.php +++ b/src/Model/OrderScope.php @@ -8,16 +8,24 @@ class OrderScope implements Scope { + + // @phpstan-ignore-next-line private $column; + + // @phpstan-ignore-next-line private $direction; + + // @phpstan-ignore-next-line public function __construct($column, $direction = 'asc') { $this->column = $column; $this->direction = $direction; } + + // @phpstan-ignore-next-line public function apply(Builder $builder, Model $model) { if (!$this->hasOrderById($builder, $this->column)) { @@ -36,6 +44,8 @@ public function apply(Builder $builder, Model $model) * @param Builder $builder * @return boolean */ + + // @phpstan-ignore-next-line protected function hasOrderById(Builder $builder, string $key) { if (empty($builder->getQuery()->orders)) { diff --git a/src/Model/Plugin.php b/src/Model/Plugin.php index ed5f0c41e..5f226fcd7 100644 --- a/src/Model/Plugin.php +++ b/src/Model/Plugin.php @@ -32,6 +32,8 @@ class Plugin extends ModelBase protected $casts = ['options' => 'json', 'custom_options' => 'json']; + + // @phpstan-ignore-next-line public function setPluginTypesAttribute($pluginTypes) { if (is_null($pluginTypes)) { @@ -49,6 +51,8 @@ public function setPluginTypesAttribute($pluginTypes) } } + + // @phpstan-ignore-next-line public function getPluginTypesAttribute() { $plugin_types = array_get($this->attributes, 'plugin_types'); @@ -74,6 +78,8 @@ public function getDisabledDeleteAttribute() * $role_key * if set array, check whether either items. * @param array|string $role_key */ + + // @phpstan-ignore-next-line public function hasPermission($role_key) { return \Exment::user()->hasPermissionPlugin($this->id, $role_key); @@ -84,6 +90,8 @@ public function hasPermission($role_key) * * @return array|\Illuminate\Support\Collection */ + + // @phpstan-ignore-next-line public static function getIdsHasSettingPermission() { return System::requestSession(Define::SYSTEM_KEY_SESSION_PLUGIN_ALL_SETTING_IDS, function () { @@ -106,6 +114,8 @@ public static function getIdsHasSettingPermission() * * @return bool is match plugin type. if $plugin_types is multiple, whether contains. */ + + // @phpstan-ignore-next-line public function matchPluginType($plugin_types) { $plugin_types = toArray($plugin_types); @@ -118,11 +128,15 @@ public function matchPluginType($plugin_types) return false; } + + // @phpstan-ignore-next-line public function isPluginTypeUri() { return $this->matchPluginType(PluginType::PLUGIN_TYPE_PUBLIC_CLASS()); } + + // @phpstan-ignore-next-line public static function getPluginByUUID($uuid) { if ($uuid instanceof Plugin) { @@ -133,6 +147,8 @@ public static function getPluginByUUID($uuid) }); } + + // @phpstan-ignore-next-line public static function getPluginByName($plugin_name) { return static::getPluginsCache()->first(function ($plugin) use ($plugin_name) { @@ -175,6 +191,8 @@ public static function getPluginsByTable($custom_table, $filterAccessible = true * * @return Collection */ + + // @phpstan-ignore-next-line public static function getBatches() { $now = Carbon::now(); @@ -189,6 +207,8 @@ public static function getBatches() * * @return Collection */ + + // @phpstan-ignore-next-line public static function getCronBatches() { return static::getByPluginTypes(PluginType::BATCH)->filter(function ($plugin) { @@ -201,6 +221,8 @@ public static function getCronBatches() * * @return mixed \Exceedone\Exment\Services\Plugin\PluginBase */ + + // @phpstan-ignore-next-line public function getClass($plugin_type, $options = []) { $options = array_merge( @@ -227,6 +249,8 @@ public function getClass($plugin_type, $options = []) /** * Get namespace path */ + + // @phpstan-ignore-next-line public function getNameSpace(...$pass_array) { $array = ["App", "Plugins", pascalize($this->plugin_name)]; @@ -243,6 +267,8 @@ public function getNameSpace(...$pass_array) * Get plugin path. (not fullpath. relation from laravel root) * if $pass_array is empty, return plugin folder path. */ + + // @phpstan-ignore-next-line public function getPath(...$pass_array) { $pluginPath = pascalize(preg_replace('/\s+/', '', $this->plugin_name)); @@ -263,6 +289,8 @@ public function getPath(...$pass_array) * Get plugin fullpath. * if $pass_array is empty, return plugin folder full path. */ + + // @phpstan-ignore-next-line public function getFullPath(...$pass_array) { $diskService = new PluginDiskService($this); @@ -277,6 +305,8 @@ public function getFullPath(...$pass_array) /** * Get plugin file paths. relative path, not fullpath */ + + // @phpstan-ignore-next-line public function getPluginFilePaths($dirPath = null, $subdir = true, ?PluginDiskService $diskService = null) { list($diskService, $disk, $dirName, $dirPath) = $this->initPluginDisk($dirPath, $diskService); @@ -295,6 +325,8 @@ public function getPluginFilePaths($dirPath = null, $subdir = true, ?PluginDiskS /** * Get plugin directories paths. relative path, not fullpath */ + + // @phpstan-ignore-next-line public function getPluginDirPaths($dirPath = null, $subdir = true, ?PluginDiskService $diskService = null) { list($diskService, $disk, $dirName, $dirPath) = $this->initPluginDisk($dirPath, $diskService); @@ -334,6 +366,8 @@ public function getPluginFiledata(string $path, ?PluginDiskService $diskService * @return mixed * @throws FileNotFoundException */ + + // @phpstan-ignore-next-line public function putPluginFile(string $path, $file, ?PluginDiskService $diskService = null) { list($diskService, $disk, $dirName, $filePath) = $this->initPluginDisk($path, $diskService, ['exceptionFileNotFound' => false]); @@ -351,6 +385,8 @@ public function putPluginFile(string $path, $file, ?PluginDiskService $diskServi * @return mixed * @throws FileNotFoundException */ + + // @phpstan-ignore-next-line public function putAsPluginFile(?string $dirPath, string $fileName, $file, ?PluginDiskService $diskService = null) { list($diskService, $disk, $dirName, $dirPath) = $this->initPluginDisk($dirPath, $diskService, ['exceptionFileNotFound' => false]); @@ -413,6 +449,8 @@ public function requirePlugin(?PluginDiskService $diskService = null) * @param array $options * @return array offset 0:PluginDiskService, 1:disk, 2: root dir name, 3: joined path. */ + + // @phpstan-ignore-next-line protected function initPluginDisk(string $path = null, ?PluginDiskService $diskService = null, array $options = []) { $options = array_merge([ @@ -451,6 +489,8 @@ protected function initPluginDisk(string $path = null, ?PluginDiskService $diskS /** * @param string|null $event */ + + // @phpstan-ignore-next-line public static function pluginExecuteEvent($event = null, $custom_table = null, $options = []) { $plugins = static::getPluginsByTable($custom_table, false); @@ -500,6 +540,8 @@ public static function pluginExecuteEvent($event = null, $custom_table = null, $ * @param string|null $event * @return array */ + + // @phpstan-ignore-next-line public static function pluginPreparingButton($event = null, $custom_table = null) { $plugins = static::getPluginsByTable($custom_table, true); @@ -569,6 +611,8 @@ public static function pluginPreparingButton($event = null, $custom_table = null * @param CustomTable $custom_table * @return array */ + + // @phpstan-ignore-next-line public static function pluginPreparingImport($custom_table) { $plugins = static::getPluginsByTable($custom_table, true); @@ -593,6 +637,8 @@ public static function pluginPreparingImport($custom_table) /** * execute custom plugin validate */ + + // @phpstan-ignore-next-line public static function pluginValidator($custom_table, $options = []) { $plugins = static::getPluginsByTable($custom_table, false); @@ -617,6 +663,8 @@ public static function pluginValidator($custom_table, $options = []) /** * execute validate destroy */ + + // @phpstan-ignore-next-line public static function pluginValidateDestroy($model, $options = []) { $plugins = static::getPluginsByTable($model->custom_table, false); @@ -630,6 +678,8 @@ public static function pluginValidateDestroy($model, $options = []) // if isset $class, call if (isset($class)) { if (method_exists($class, 'validateDestroy')) { + + // @phpstan-ignore-next-line $res = $class->validateDestroy($model); if ($res === false) { return [ @@ -656,6 +706,8 @@ public static function pluginValidateDestroy($model, $options = []) /** * Get plugins filtering accessable by selecting plugin_type */ + + // @phpstan-ignore-next-line public static function getAccessableByPluginTypes($plugin_types, $getAsClass = false) { return static::getByPluginTypes($plugin_types, $getAsClass) @@ -671,6 +723,8 @@ public static function getAccessableByPluginTypes($plugin_types, $getAsClass = f /** * Get plugins by selecting plugin_type */ + + // @phpstan-ignore-next-line public static function getByPluginTypes($plugin_types, $getAsClass = false) { return static::getPluginPublicSessions($plugin_types, $getAsClass); @@ -681,6 +735,8 @@ public static function getByPluginTypes($plugin_types, $getAsClass = false) * * @return Collection */ + + // @phpstan-ignore-next-line public static function getPluginPages() { return static::getPluginPublicSessions(PluginType::PLUGIN_TYPE_PLUGIN_PAGE(), true); @@ -691,6 +747,8 @@ public static function getPluginPages() * * @return Collection */ + + // @phpstan-ignore-next-line public static function getPluginScriptStyles() { return static::getPluginPublicSessions(PluginType::PLUGIN_TYPE_SCRIPT_STYLE(), true); @@ -701,6 +759,8 @@ public static function getPluginScriptStyles() * * @return Collection */ + + // @phpstan-ignore-next-line protected static function getPluginPublicSessions($targetPluginTypes, $getAsClass = false) { $plugins = static::getPluginsCache(); @@ -729,6 +789,8 @@ protected static function getPluginPublicSessions($targetPluginTypes, $getAsClas })->filter(); } + + // @phpstan-ignore-next-line protected static function getPluginsCache() { // get plugin page's @@ -795,6 +857,8 @@ public static function getPluginPageModel() * * @return string */ + + // @phpstan-ignore-next-line public function getRootUrl($plugin_type): string { if ($plugin_type == PluginType::PAGE || $plugin_type == PluginType::CRUD) { @@ -810,6 +874,8 @@ public function getRootUrl($plugin_type): string * * @return string */ + + // @phpstan-ignore-next-line public function getFullUrl(...$pass_array) { return admin_urls($this->getRouteUri(...$pass_array)); @@ -820,6 +886,8 @@ public function getFullUrl(...$pass_array) * * @return string */ + + // @phpstan-ignore-next-line public function getRouteUri(...$pass_array) { return url_join('plugins', $this->getOptionUri(), ...$pass_array); @@ -840,6 +908,8 @@ public function getOptionUri() return snake_case($uri); } + + // @phpstan-ignore-next-line public function getCannotReadMessage() { return exmtrans('plugin.error.cannot_read', [ @@ -850,6 +920,8 @@ public function getCannotReadMessage() /** * get eloquent using request settion. */ + + // @phpstan-ignore-next-line public static function getEloquent($obj, $withs = []) { if ($obj instanceof Plugin) { @@ -890,10 +962,14 @@ public static function getEloquent($obj, $withs = []) return $obj; } + + // @phpstan-ignore-next-line public function getCustomOption($key, $default = null) { return $this->getJson('custom_options', $key, $default); } + + // @phpstan-ignore-next-line public function setCustomOption($key, $val = null) { return $this->setJson('custom_options', $key, $val); diff --git a/src/Model/PublicForm.php b/src/Model/PublicForm.php index e7accaa8c..84a705bbb 100644 --- a/src/Model/PublicForm.php +++ b/src/Model/PublicForm.php @@ -43,6 +43,8 @@ class PublicForm extends ModelBase protected $casts = ['options' => 'json']; + + // @phpstan-ignore-next-line public static $templateItems = [ 'excepts' => [ 'custom_form_id', 'proxy_user_id', 'uuid', 'active_flg', 'public_form_view_name', 'options.analytics_tag', 'options.use_recaptcha', 'options.header_logo','options.plugin_css','options.plugin_js', @@ -50,23 +52,31 @@ class PublicForm extends ModelBase ]; + + // @phpstan-ignore-next-line public function custom_form() { return $this->belongsTo(CustomForm::class, 'custom_form_id'); } + + // @phpstan-ignore-next-line public function notify_complete_admin() { return $this->hasOne(Notify::class, 'target_id') ->where('notify_trigger', NotifyTrigger::PUBLIC_FORM_COMPLETE_ADMIN) ->where('active_flg', 1); } + + // @phpstan-ignore-next-line public function notify_complete_user() { return $this->hasOne(Notify::class, 'target_id') ->where('notify_trigger', NotifyTrigger::PUBLIC_FORM_COMPLETE_USER) ->where('active_flg', 1); } + + // @phpstan-ignore-next-line public function notify_error() { return $this->hasOne(Notify::class, 'target_id') @@ -74,22 +84,30 @@ public function notify_error() ->where('active_flg', 1); } + + // @phpstan-ignore-next-line public function notify_all() { return $this->hasMany(Notify::class, 'target_id') ->whereIn('notify_trigger', NotifyTrigger::PUBLIC_FORMS()); } + + // @phpstan-ignore-next-line public function deletingChildren() { $this->notify_all()->delete(); } + + // @phpstan-ignore-next-line public function getCustomFormCacheAttribute() { return CustomForm::getEloquent($this->custom_form_id); } + + // @phpstan-ignore-next-line public function getCustomTableCacheAttribute() { $custom_form = $this->custom_form_cache; @@ -125,6 +143,8 @@ protected static function boot() * * @return string */ + + // @phpstan-ignore-next-line public function getBasePath(...$pass_array): string { return url_join(public_form_base_path(), $this->uuid, ...$pass_array); @@ -135,6 +155,8 @@ public function getBasePath(...$pass_array): string * * @return string */ + + // @phpstan-ignore-next-line public function getUrl(...$pass_array): string { return asset_urls($this->getBasePath(...$pass_array)); @@ -177,6 +199,8 @@ public static function getUuidByRequest(): ?string * * @return PublicForm|null */ + + // @phpstan-ignore-next-line public static function getPublicFormByUuid($uuid, bool $skipCheckActiveEtc = false): ?PublicForm { if (!$uuid) { @@ -240,6 +264,8 @@ public static function getPublicFormByRequest(): ?PublicForm * * @return Collection */ + + // @phpstan-ignore-next-line public function getListOfTablesUsed(): Collection { $result = collect(); @@ -286,6 +312,8 @@ public function getListOfTablesUsed(): Collection * @param array $options * @return Form|null */ + + // @phpstan-ignore-next-line public function getForm(Request $request, ?CustomValue $custom_value = null, array $options = []) { $options = array_merge([ @@ -359,6 +387,8 @@ public function getForm(Request $request, ?CustomValue $custom_value = null, arr * @return mixed|null * @throws \Throwable */ + + // @phpstan-ignore-next-line public function getShow(Request $request, CustomValue|Model $custom_value, array $inputs = []) { $custom_form = $this->custom_form; @@ -456,6 +486,8 @@ public function getErrorView(Request $request) * @return PublicContent|\Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View * @throws \Throwable */ + + // @phpstan-ignore-next-line public function showError($ex, $asInner = false, ?array $data = null) { try { @@ -494,6 +526,8 @@ public function showError($ex, $asInner = false, ?array $data = null) } + + // @phpstan-ignore-next-line public function getNotifyParams(?CustomValue $custom_value = null, array $relationInputs = null, ?array $data = null) { return [ @@ -510,6 +544,8 @@ public function getNotifyParams(?CustomValue $custom_value = null, array $relati * @param array|null $data * @return array|\Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\Translation\Translator|string|null */ + + // @phpstan-ignore-next-line protected function getInputValueText(?CustomValue $custom_value = null, array $relationInputs = null, ?array $data = null) { try { @@ -526,6 +562,8 @@ protected function getInputValueText(?CustomValue $custom_value = null, array $r 'asConfirm' => true, ]); /** @var array|null $relationInputs */ + + // @phpstan-ignore-next-line $relationInputs = $form->getRelationModelByInputs(); } @@ -570,6 +608,8 @@ protected function getInputValueText(?CustomValue $custom_value = null, array $r // if relation, set relation label if (!is_null($relationInfo[0]) && !is_null($relationInfo[2])) { + + // @phpstan-ignore-next-line $label = $relationInfo[2] . " - " . ($index + 1) . " - " . $label; } @@ -606,6 +646,8 @@ protected function getInputValueText(?CustomValue $custom_value = null, array $r * @param PublicContent $content * @return $this */ + + // @phpstan-ignore-next-line public function setContentOption(PublicContent $content, array $options = []) { \Admin::css(asset('vendor/exment/css/publicform.css')); @@ -682,6 +724,7 @@ public static function isEnableRecaptcha() { $message = null; // checking NoCaptcha + // Exment helper class not recognized if (!\Exment::isAvailableGoogleRecaptcha()) { $message = exmtrans('login.message.not_install_library', [ 'name' => 'Google reCaptcha', @@ -710,6 +753,8 @@ public static function isEnableRecaptcha() * * @return Collection */ + + // @phpstan-ignore-next-line public function getCssJsPlugins() { $result = collect(); diff --git a/src/Model/RelationTable.php b/src/Model/RelationTable.php index c02adc216..f5b274eb4 100644 --- a/src/Model/RelationTable.php +++ b/src/Model/RelationTable.php @@ -70,9 +70,13 @@ class RelationTable * * @var array */ + + // @phpstan-ignore-next-line public $subQueryCallbacks = []; + + // @phpstan-ignore-next-line public function __construct(array $params = []) { $this->base_table = array_get($params, 'base_table'); @@ -94,6 +98,8 @@ public function __construct(array $params = []) * @param array $options * @return \Illuminate\Support\Collection children relation(select_table, one_to_many, many_to_many)'s RleationTable info. */ + + // @phpstan-ignore-next-line public static function getRelationTables($custom_table, $checkPermission = true, $options = []) { $options = array_merge( @@ -260,6 +266,8 @@ public static function getRelationTableByKey(?string $key): ?RelationTable * @param array $options execute options. * @return Collection */ + + // @phpstan-ignore-next-line protected static function _getTablesSelectTable(CustomTable $custom_table, array $options): Collection { $results = collect(); @@ -310,6 +318,8 @@ protected static function _getTablesSelectTable(CustomTable $custom_table, array * @param array $options execute options. * @return Collection */ + + // @phpstan-ignore-next-line protected static function _getParentTablesSelectTable(CustomTable $custom_table, array $options): Collection { $results = collect(); @@ -356,6 +366,8 @@ protected static function _getParentTablesSelectTable(CustomTable $custom_table, * @param array $options * @return Collection */ + + // @phpstan-ignore-next-line protected static function _getTablesRelation(CustomTable $custom_table, array $options): Collection { $results = collect(); @@ -388,6 +400,8 @@ protected static function _getTablesRelation(CustomTable $custom_table, array $o * @param array $options * @return Collection */ + + // @phpstan-ignore-next-line protected static function _getParentTablesRelation(CustomTable $custom_table, array $options): Collection { $results = collect(); @@ -423,6 +437,8 @@ protected static function _getParentTablesRelation(CustomTable $custom_table, ar * @param array $params * @return mixed */ + + // @phpstan-ignore-next-line public static function setQuery($query, $searchType, $value, $params = []) { $parent_table = CustomTable::getEloquent(array_get($params, 'parent_table')); @@ -452,6 +468,8 @@ public static function setQuery($query, $searchType, $value, $params = []) * @param mixed $value * @return mixed */ + + // @phpstan-ignore-next-line public static function setQueryOneMany($query, $parent_table, $child_table, $value) { if (is_nullorempty($parent_table) || is_nullorempty($child_table)) { @@ -459,6 +477,8 @@ public static function setQueryOneMany($query, $parent_table, $child_table, $val } $dbName = getDBTableName($child_table); + + // @phpstan-ignore-next-line $query->whereOrIn("$dbName.parent_id", $value)->where("$dbName.parent_type", $parent_table->table_name); return $query; @@ -474,6 +494,8 @@ public static function setQueryOneMany($query, $parent_table, $child_table, $val * @param mixed $value * @return mixed */ + + // @phpstan-ignore-next-line public static function setQueryManyMany($query, $parent_table, $child_table, $value) { if (is_nullorempty($parent_table) || is_nullorempty($child_table)) { @@ -484,6 +506,8 @@ public static function setQueryManyMany($query, $parent_table, $child_table, $va return; } + + // @phpstan-ignore-next-line $query->whereHas($relation->getRelationName(), function ($query) use ($relation, $value) { $query->whereOrIn($relation->getRelationName() . '.parent_id', $value); }); @@ -499,12 +523,16 @@ public static function setQueryManyMany($query, $parent_table, $child_table, $va * @param mixed $value * @return mixed */ + + // @phpstan-ignore-next-line public static function setQuerySelectTable($query, $custom_column, $value) { if (is_nullorempty($custom_column)) { return; } + + // @phpstan-ignore-next-line $query->whereOrIn($custom_column->getQueryKey(), $value); return $query; @@ -520,6 +548,8 @@ public static function setQuerySelectTable($query, $custom_column, $value) * @param array $params * @return mixed */ + + // @phpstan-ignore-next-line public function setParentJoin($query, $params = []) { $parent_table = CustomTable::getEloquent(array_get($params, 'parent_table')); @@ -549,6 +579,8 @@ public function setParentJoin($query, $params = []) * @param array $params * @return mixed */ + + // @phpstan-ignore-next-line public function setSummaryChildJoin($query, $params = []) { $parent_table = CustomTable::getEloquent(array_get($params, 'parent_table')); @@ -578,6 +610,8 @@ public function setSummaryChildJoin($query, $params = []) * @param CustomTable $parent_table * @return mixed */ + + // @phpstan-ignore-next-line public function setParentJoinOneMany($query, $parent_table, $child_table, bool $leftJoin = false) { if (is_nullorempty($parent_table) || is_nullorempty($child_table)) { @@ -602,6 +636,8 @@ public function setParentJoinOneMany($query, $parent_table, $child_table, bool $ * @param CustomTable $parent_table * @return mixed */ + + // @phpstan-ignore-next-line public function setParentJoinManyMany($query, $parent_table, $child_table, bool $leftJoin = false) { if (is_nullorempty($parent_table) || is_nullorempty($child_table)) { @@ -638,6 +674,8 @@ public function setParentJoinManyMany($query, $parent_table, $child_table, bool * @param CustomColumn $custom_column select_table's column in $query's table * @return mixed */ + + // @phpstan-ignore-next-line public function setParentJoinSelectTable($query, $parent_table, $custom_column, bool $leftJoin = false) { if (is_nullorempty($parent_table) || is_nullorempty($custom_column)) { @@ -677,6 +715,8 @@ public function setParentJoinSelectTable($query, $parent_table, $custom_column, * @param CustomTable $parent_table * @return mixed */ + + // @phpstan-ignore-next-line public function setSummaryChildJoinOneMany($query, $parent_table, $child_table, bool $leftJoin = false) { if (is_nullorempty($parent_table) || is_nullorempty($child_table)) { @@ -713,6 +753,8 @@ public function setSummaryChildJoinOneMany($query, $parent_table, $child_table, * @param CustomTable $parent_table * @return mixed */ + + // @phpstan-ignore-next-line public static function setChildJoinManyMany($query, $parent_table, $child_table, ?string $tableUniqueName = null) { if (is_nullorempty($parent_table) || is_nullorempty($child_table)) { @@ -749,6 +791,8 @@ public static function setChildJoinManyMany($query, $parent_table, $child_table, * @param CustomTable $parent_table * @return mixed */ + + // @phpstan-ignore-next-line public function setSummaryChildJoinManyAndMany($query, $parent_table, $child_table, bool $leftJoin = false) { if (is_nullorempty($parent_table) || is_nullorempty($child_table)) { @@ -797,6 +841,8 @@ public function setSummaryChildJoinManyAndMany($query, $parent_table, $child_tab * @param CustomColumn $custom_column select_table's column in $query's table * @return mixed */ + + // @phpstan-ignore-next-line public function setSummaryChildJoinSelectTable($query, $parent_table, $custom_column, bool $leftJoin = false) { if (is_nullorempty($parent_table) || is_nullorempty($custom_column)) { @@ -848,6 +894,8 @@ public function setSummaryChildJoinSelectTable($query, $parent_table, $custom_co * @param boolean $or_option * @return void */ + + // @phpstan-ignore-next-line public static function setWorkflowStatusSubquery($query, CustomTable $custom_table, bool $or_option = false) { $tableName = getDBTableName($custom_table); @@ -874,6 +922,8 @@ public static function setWorkflowStatusSubquery($query, CustomTable $custom_tab * @param boolean $or_option * @return void */ + + // @phpstan-ignore-next-line public static function setWorkflowWorkUsersSubQuery($query, $custom_table, $or_option = false) { $tableName = getDBTableName($custom_table); diff --git a/src/Model/RoleGroup.php b/src/Model/RoleGroup.php index 7b23bc55a..58859b558 100644 --- a/src/Model/RoleGroup.php +++ b/src/Model/RoleGroup.php @@ -19,6 +19,8 @@ class RoleGroup extends ModelBase use Traits\UseRequestSessionTrait; use Traits\ClearCacheTrait; + + // @phpstan-ignore-next-line public static $templateItems = [ 'excepts' => [], 'uniqueKeys' => ['role_group_name'], @@ -31,22 +33,30 @@ class RoleGroup extends ModelBase ], ]; + + // @phpstan-ignore-next-line public function role_group_permissions(): HasMany { return $this->hasMany(RoleGroupPermission::class, 'role_group_id'); } + + // @phpstan-ignore-next-line public function role_group_user_organizations(): HasMany { return $this->hasMany(RoleGroupUserOrganization::class, 'role_group_id'); } + + // @phpstan-ignore-next-line public function role_group_users(): HasMany { return $this->hasMany(RoleGroupUserOrganization::class, 'role_group_id') ->where('role_group_user_org_type', 'user'); } + + // @phpstan-ignore-next-line public function role_group_organizations(): HasMany { return $this->hasMany(RoleGroupUserOrganization::class, 'role_group_id') @@ -59,9 +69,13 @@ public function role_group_organizations(): HasMany * * @return \Illuminate\Support\Collection */ + + // @phpstan-ignore-next-line public static function getHasPermissionRoleGroup($user_id, $organization_ids, $checkContainJointdOrgs = false) { // get all permissons for system. -------------------------------------------------- + + // @phpstan-ignore-next-line return static::allRecordsCache(function ($role_group) use ($user_id, $organization_ids, $checkContainJointdOrgs) { $user_orgs = array_get($role_group, SystemTableName::ROLE_GROUP_USER_ORGANIZATION); if (is_nullorempty($user_orgs)) { @@ -84,7 +98,8 @@ public static function getHasPermissionRoleGroup($user_id, $organization_ids, $c // ge check contains parent and child organizaions. $org = CustomTable::getEloquent(SystemTableName::ORGANIZATION)->getValueModel($organization_id); - /** @phpstan-ignore-next-line $org uses OrganizationTrait */ + + // @phpstan-ignore-next-line $targetOrgIds = $org->getOrganizationIdsForQuery($enum); if (in_array($organization_id, $targetOrgIds)) { return true; diff --git a/src/Model/RoleGroupPermission.php b/src/Model/RoleGroupPermission.php index d7a772d89..d413b859f 100644 --- a/src/Model/RoleGroupPermission.php +++ b/src/Model/RoleGroupPermission.php @@ -18,6 +18,8 @@ class RoleGroupPermission extends ModelBase protected $casts = ['permissions' => 'json']; + + // @phpstan-ignore-next-line public static $templateItems = [ 'excepts' => ['role_group'], 'uniqueKeys' => [ @@ -47,6 +49,8 @@ class RoleGroupPermission extends ModelBase ] ]; + + // @phpstan-ignore-next-line public function role_group() { return $this->belongsTo(RoleGroup::class, 'role_group_id'); @@ -55,6 +59,8 @@ public function role_group() /** * get Table Name or system name */ + + // @phpstan-ignore-next-line protected function getUniqueKeyValues() { switch ($this->role_group_permission_type) { @@ -70,6 +76,8 @@ protected function getUniqueKeyValues() return []; } + + // @phpstan-ignore-next-line protected static function importReplaceJson(&$json, $options = []) { $role_group_target_name = array_get($json, 'role_group_target_name'); diff --git a/src/Model/RoleGroupUserOrganization.php b/src/Model/RoleGroupUserOrganization.php index dfea26bc5..2f2218dab 100644 --- a/src/Model/RoleGroupUserOrganization.php +++ b/src/Model/RoleGroupUserOrganization.php @@ -19,6 +19,8 @@ class RoleGroupUserOrganization extends ModelBase * * @return void */ + + // @phpstan-ignore-next-line public static function deleteRoleGroupUserOrganization($custom_value) { $custom_table = $custom_value->custom_table; diff --git a/src/Model/System.php b/src/Model/System.php index 489eb810c..1f855b7fe 100644 --- a/src/Model/System.php +++ b/src/Model/System.php @@ -86,8 +86,12 @@ class System extends ModelBase protected $casts = ['role' => 'json']; protected $primaryKey = 'system_name'; public $incrementing = false; + + // @phpstan-ignore-next-line protected static $requestSession = []; + + // @phpstan-ignore-next-line public static function __callStatic($name, $argments) { // Get system setting value @@ -155,6 +159,8 @@ public static function hasRequestSession($key) /** * clear all request settion */ + + // @phpstan-ignore-next-line public static function clearRequestSession($key = null) { if (!isset($key)) { @@ -169,6 +175,8 @@ public static function clearRequestSession($key = null) * * @return \Illuminate\Support\Collection */ + + // @phpstan-ignore-next-line public static function getRequestSessionKeys(): \Illuminate\Support\Collection { $result = collect(); @@ -236,6 +244,8 @@ public static function cache($key, $value = null, $onlySetTrue = false) /** * reset Cache */ + + // @phpstan-ignore-next-line public static function clearCache($key = null) { static::clearRequestSession($key); @@ -254,11 +264,15 @@ public static function clearCache($key = null) /** * whether System_function keyname */ + + // @phpstan-ignore-next-line public static function hasFunction($name) { return array_key_exists($name, Define::SYSTEM_SETTING_NAME_VALUE); } + + // @phpstan-ignore-next-line public static function get_system_keys($group = null) { $keys = []; @@ -280,6 +294,8 @@ public static function get_system_keys($group = null) /** * get "systems" table key-value array */ + + // @phpstan-ignore-next-line public static function get_system_values($group = null) { $array = []; @@ -290,6 +306,8 @@ public static function get_system_values($group = null) return $array; } + + // @phpstan-ignore-next-line protected static function getset_system_value($name, $setting, $argments) { if (count($argments) > 0) { @@ -300,6 +318,8 @@ protected static function getset_system_value($name, $setting, $argments) } } + + // @phpstan-ignore-next-line protected static function get_system_value($name, $setting) { $key = static::getConfigKey($name); @@ -351,6 +371,8 @@ protected static function get_system_value($name, $setting) }); } + + // @phpstan-ignore-next-line protected static function set_system_value($name, $setting, $value) { $system = System::firstOrNew(['system_name' => $name]); @@ -394,12 +416,16 @@ protected static function set_system_value($name, $setting, $value) /** * destory value */ + + // @phpstan-ignore-next-line public static function deleteValue($name) { $system = System::find($name); if (!isset($system)) { return; } + + // @phpstan-ignore-next-line $old_value = $system->system_value; // change set value by type @@ -412,12 +438,18 @@ public static function deleteValue($name) ExmentFile::deleteFileInfo($old_value); } } + + // @phpstan-ignore-next-line $system->system_value = null; + + // @phpstan-ignore-next-line $system->save(); return $system; } + + // @phpstan-ignore-next-line protected static function getConfigKey($name) { return sprintf(Define::SYSTEM_KEY_SESSION_SYSTEM_CONFIG, $name); diff --git a/src/Model/Traits/AutoSUuidObserver.php b/src/Model/Traits/AutoSUuidObserver.php index 20c199d27..c41e4ab7a 100644 --- a/src/Model/Traits/AutoSUuidObserver.php +++ b/src/Model/Traits/AutoSUuidObserver.php @@ -4,6 +4,8 @@ class AutoSUuidObserver extends AutoUuidObserverBase { + + // @phpstan-ignore-next-line protected function setUuid($model) { if (is_nullorempty($model->suuid)) { diff --git a/src/Model/Traits/AutoSUuidTrait.php b/src/Model/Traits/AutoSUuidTrait.php index b96472e18..8811e6e38 100644 --- a/src/Model/Traits/AutoSUuidTrait.php +++ b/src/Model/Traits/AutoSUuidTrait.php @@ -12,8 +12,12 @@ trait AutoSUuidTrait { use AutoUuidTraitBase; + + // @phpstan-ignore-next-line protected static $uuid_key = 'suuid'; + + // @phpstan-ignore-next-line public static function bootAutoSUuidTrait() { self::observe(AutoSUuidObserver::class); diff --git a/src/Model/Traits/AutoUuidObserver.php b/src/Model/Traits/AutoUuidObserver.php index 7595c5e96..10edf3cca 100644 --- a/src/Model/Traits/AutoUuidObserver.php +++ b/src/Model/Traits/AutoUuidObserver.php @@ -4,6 +4,8 @@ class AutoUuidObserver extends AutoUuidObserverBase { + + // @phpstan-ignore-next-line protected function setUuid($model) { if (is_nullorempty($model->uuid)) { diff --git a/src/Model/Traits/AutoUuidObserverBase.php b/src/Model/Traits/AutoUuidObserverBase.php index 23cf8d8b2..5f9c9294c 100644 --- a/src/Model/Traits/AutoUuidObserverBase.php +++ b/src/Model/Traits/AutoUuidObserverBase.php @@ -8,10 +8,14 @@ */ class AutoUuidObserverBase { + + // @phpstan-ignore-next-line public function creating($model) { $this->setUuid($model); } + + // @phpstan-ignore-next-line public function updating($model) { $this->setUuid($model); diff --git a/src/Model/Traits/AutoUuidTrait.php b/src/Model/Traits/AutoUuidTrait.php index 4748720d0..3b0ce06bf 100644 --- a/src/Model/Traits/AutoUuidTrait.php +++ b/src/Model/Traits/AutoUuidTrait.php @@ -12,8 +12,12 @@ trait AutoUuidTrait { use AutoUuidTraitBase; + + // @phpstan-ignore-next-line protected static $uuid_key = 'uuid'; + + // @phpstan-ignore-next-line public static function bootAutoUuidTrait() { self::observe(AutoUuidObserver::class); diff --git a/src/Model/Traits/AutoUuidTraitBase.php b/src/Model/Traits/AutoUuidTraitBase.php index 831ebb825..3dac0fd39 100644 --- a/src/Model/Traits/AutoUuidTraitBase.php +++ b/src/Model/Traits/AutoUuidTraitBase.php @@ -15,6 +15,8 @@ trait AutoUuidTraitBase * * @deprecated version */ + + // @phpstan-ignore-next-line public static function findBySuuid($uuid) { return static::findByUuid($uuid); @@ -23,6 +25,8 @@ public static function findBySuuid($uuid) /** * find by string uuid */ + + // @phpstan-ignore-next-line public static function findByUuid($uuid) { if (!isset($uuid)) { diff --git a/src/Model/Traits/ColumnOptionQueryTrait.php b/src/Model/Traits/ColumnOptionQueryTrait.php index f21c35990..f6d55520e 100644 --- a/src/Model/Traits/ColumnOptionQueryTrait.php +++ b/src/Model/Traits/ColumnOptionQueryTrait.php @@ -23,6 +23,7 @@ trait ColumnOptionQueryTrait */ protected static function getOptionKey($column_key, $append_table = true, $table_id = null, $options = []) { + return \Exment::getOptionKey($column_key, $append_table, $table_id, $options); } diff --git a/src/Model/Traits/CustomViewColumnOptionTrait.php b/src/Model/Traits/CustomViewColumnOptionTrait.php index d4dfe2cad..7043f1ec7 100644 --- a/src/Model/Traits/CustomViewColumnOptionTrait.php +++ b/src/Model/Traits/CustomViewColumnOptionTrait.php @@ -7,6 +7,8 @@ trait CustomViewColumnOptionTrait /** * get sort order. */ + + // @phpstan-ignore-next-line public function getSortOrderAttribute() { return $this->getOption('sort_order'); @@ -14,6 +16,8 @@ public function getSortOrderAttribute() /** * set sort order. */ + + // @phpstan-ignore-next-line public function setSortOrderAttribute($sort_order) { return $this->setOption('sort_order', $sort_order); @@ -21,6 +25,8 @@ public function setSortOrderAttribute($sort_order) /** * get sort type. */ + + // @phpstan-ignore-next-line public function getSortTypeAttribute() { return $this->getOption('sort_type'); @@ -28,6 +34,8 @@ public function getSortTypeAttribute() /** * set sort type. */ + + // @phpstan-ignore-next-line public function setSortTypeAttribute($sort_order) { return $this->setOption('sort_type', $sort_order); diff --git a/src/Model/Traits/CustomViewColumnTrait.php b/src/Model/Traits/CustomViewColumnTrait.php index 0fcbbf5f6..04309635b 100644 --- a/src/Model/Traits/CustomViewColumnTrait.php +++ b/src/Model/Traits/CustomViewColumnTrait.php @@ -27,11 +27,15 @@ trait CustomViewColumnTrait { use ColumnOptionQueryTrait; + + // @phpstan-ignore-next-line private $_custom_item; /** * @return BelongsTo */ + + // @phpstan-ignore-next-line public function custom_view(): BelongsTo { return $this->belongsTo(CustomView::class, 'custom_view_id'); @@ -50,6 +54,8 @@ public function getCustomColumnAttribute() /** * @return BelongsTo */ + + // @phpstan-ignore-next-line public function custom_table(): BelongsTo { return $this->belongsTo(CustomTable::class, 'view_column_table_id'); @@ -455,6 +461,8 @@ public function getPivotUniqueKeyValues() * @param array $json * @return void */ + + // @phpstan-ignore-next-line protected function exportReplaceJson(&$json) { $view_pivot_column_id = array_get($json, 'options.view_pivot_column_id'); @@ -463,7 +471,11 @@ protected function exportReplaceJson(&$json) if ($view_pivot_column_id && $view_pivot_table_id) { $view_pivot_column = CustomColumn::find($view_pivot_column_id); + + // @phpstan-ignore-next-line if ($view_pivot_column && $view_pivot_column->custom_table_id != $view_pivot_table_id) { + + // @phpstan-ignore-next-line $json['view_pivot_column_table'] = $view_pivot_column->custom_table->table_name; } } diff --git a/src/Model/Traits/DataShareTrait.php b/src/Model/Traits/DataShareTrait.php index 10d51df35..213fbaa71 100644 --- a/src/Model/Traits/DataShareTrait.php +++ b/src/Model/Traits/DataShareTrait.php @@ -18,6 +18,8 @@ trait DataShareTrait * @param bool $all if true, get value for all * @return array $options : Select Options, $ajax : ajax url */ + + // @phpstan-ignore-next-line public static function getUserOrgSelectOptions($custom_table, $permission = null, $ignoreLoginUser = false, $default = null, $all = false) { $options = collect(); @@ -45,6 +47,7 @@ public static function getUserOrgSelectOptions($custom_table, $permission = null ]); if ($ignoreLoginUser && $key == SystemTableName::USER) { + $user_id = \Exment::getUserId(); $optionItem = $optionItem->filter(function ($user, $id) use ($user_id) { return $id != $user_id; diff --git a/src/Model/Traits/DatabaseJsonOptionTrait.php b/src/Model/Traits/DatabaseJsonOptionTrait.php index 71868eea4..bb4c16be8 100644 --- a/src/Model/Traits/DatabaseJsonOptionTrait.php +++ b/src/Model/Traits/DatabaseJsonOptionTrait.php @@ -6,18 +6,43 @@ trait DatabaseJsonOptionTrait { use DatabaseJsonTrait; + /** + * Get option value + * @param string|null $key + * @param mixed $default + * @return mixed + */ public function getOption($key, $default = null) { return $this->getJson('options', $key, $default); } + + /** + * Set option value + * @param string|array|\Illuminate\Support\Collection $key + * @param mixed $val + * @param bool $forgetIfNull + * @return $this + */ public function setOption($key, $val = null, $forgetIfNull = false) { return $this->setJson('options', $key, $val, $forgetIfNull); } + + /** + * Forget option value + * @param string $key + * @return $this + */ public function forgetOption($key) { return $this->forgetJson('options', $key); } + + /** + * Clear all options + * @return $this + */ public function clearOption() { return $this->clearJson('options'); diff --git a/src/Model/Traits/DatabaseJsonTrait.php b/src/Model/Traits/DatabaseJsonTrait.php index 78f274007..59cc4989d 100644 --- a/src/Model/Traits/DatabaseJsonTrait.php +++ b/src/Model/Traits/DatabaseJsonTrait.php @@ -6,6 +6,10 @@ trait DatabaseJsonTrait { /** * get value from json + * @param string $dbcolumnname + * @param string|null $key + * @param mixed $default + * @return mixed */ protected function getJson($dbcolumnname, $key, $default = null) { @@ -18,10 +22,16 @@ protected function getJson($dbcolumnname, $key, $default = null) /** * set value from json - * + * @param string $dbcolumnname + * @param string|array|\Illuminate\Support\Collection $key + * @param mixed $val + * @param bool $forgetIfNull + * @return $this */ protected function setJson($dbcolumnname, $key, $val = null, $forgetIfNull = false) { + + // @phpstan-ignore-next-line if (!isset($key)) { return $this; } @@ -50,10 +60,14 @@ protected function setJson($dbcolumnname, $key, $val = null, $forgetIfNull = fal /** * forget value from json - * + * @param string $dbcolumnname + * @param string $key + * @return $this */ protected function forgetJson($dbcolumnname, $key) { + + // @phpstan-ignore-next-line if (!isset($key)) { return $this; } @@ -69,7 +83,8 @@ protected function forgetJson($dbcolumnname, $key) } /** * clear value from json - * + * @param string $dbcolumnname + * @return $this */ protected function clearJson($dbcolumnname) { @@ -77,8 +92,12 @@ protected function clearJson($dbcolumnname) return $this; } - // re-set field data -------------------------------------------------- - // if user update form and save, but other field remove if not conatins form field, so re-set field before update + /** + * re-set field data + * if user update form and save, but other field remove if not conatins form field, so re-set field before update + * @param string $dbcolumnname + * @return void + */ protected function prepareJson($dbcolumnname) { ///// saving event for image, file event @@ -87,7 +106,11 @@ protected function prepareJson($dbcolumnname) // loop columns $update_flg = false; + + // @phpstan-ignore-next-line foreach ($original as $key => $o) { + + // @phpstan-ignore-next-line if ($this->setAgainOriginalValue($value, $original, $key)) { $update_flg = true; } @@ -110,6 +133,10 @@ protected function prepareJson($dbcolumnname) /** * whether setting original data. and return setting or not. + * @param array|null $value + * @param array $original + * @param string $key + * @return bool */ protected function setAgainOriginalValue(&$value, $original, $key) { @@ -145,6 +172,7 @@ protected function setAgainOriginalValue(&$value, $original, $key) protected function convertSetValue($value) { if ($value instanceof \Carbon\Carbon) { + return \Exment::carbonToArray($value); } diff --git a/src/Model/Traits/DefaultFlgTrait.php b/src/Model/Traits/DefaultFlgTrait.php index c9a971c40..b22a8f8e8 100644 --- a/src/Model/Traits/DefaultFlgTrait.php +++ b/src/Model/Traits/DefaultFlgTrait.php @@ -10,12 +10,16 @@ trait DefaultFlgTrait /** * set default flg. default flg is only 1 record in 1 table */ + + // @phpstan-ignore-next-line protected function setDefaultFlgInTable($filterCallback = null, $setCallback = null) { // get custom table_id $this->setDefaultFlg('custom_table_id', $filterCallback); } + + // @phpstan-ignore-next-line protected function setDefaultFlg($key = null, $filterCallback = null, $setCallback = null) { // create query diff --git a/src/Model/Traits/MailTemplateTrait.php b/src/Model/Traits/MailTemplateTrait.php index 141a0b1da..b1eae4179 100644 --- a/src/Model/Traits/MailTemplateTrait.php +++ b/src/Model/Traits/MailTemplateTrait.php @@ -89,6 +89,7 @@ public function getCustomAttachments($custom_value) }); return $files->filter()->map(function ($attachment) { + return ExmentFile::getData($attachment); }); } diff --git a/src/Model/Traits/PublicFormInputTrait.php b/src/Model/Traits/PublicFormInputTrait.php index fda9cd1a6..0483ffc26 100644 --- a/src/Model/Traits/PublicFormInputTrait.php +++ b/src/Model/Traits/PublicFormInputTrait.php @@ -20,85 +20,125 @@ trait PublicFormInputTrait * @var mixed */ protected $tmp_notify_action_error; + + // @phpstan-ignore-next-line protected $tmp_notify_mail_template_error; + + // @phpstan-ignore-next-line protected $tmp_notify_action_complete_user; + + // @phpstan-ignore-next-line protected $tmp_notify_action_complete_admin; + + // @phpstan-ignore-next-line protected $tmp_notify_mail_template_complete_user; + + // @phpstan-ignore-next-line protected $tmp_notify_mail_template_complete_admin; // For tab ---------------------------------------------------- + + // @phpstan-ignore-next-line public function getBasicSettingAttribute() { return $this->options; } + + // @phpstan-ignore-next-line public function setBasicSettingAttribute(?array $options) { $this->setOption($options); return $this; } + + // @phpstan-ignore-next-line public function getDesignSettingAttribute() { return $this->options; } + + // @phpstan-ignore-next-line public function setDesignSettingAttribute(?array $options) { $this->setOption($options); return $this; } + + // @phpstan-ignore-next-line public function getConfirmCompleteSettingAttribute() { return $this->options; } + + // @phpstan-ignore-next-line public function setConfirmCompleteSettingAttribute(?array $options) { $this->setOption($options); return $this; } + + // @phpstan-ignore-next-line public function getConfirmCompleteSetting2Attribute() { return $this->options; } + + // @phpstan-ignore-next-line public function setConfirmCompleteSetting2Attribute(?array $options) { $this->setOption($options); return $this; } + + // @phpstan-ignore-next-line public function getErrorSettingAttribute() { return $this->options; } + + // @phpstan-ignore-next-line public function setErrorSettingAttribute(?array $options) { $this->setOption($options); return $this; } + + // @phpstan-ignore-next-line public function getOptionSettingAttribute() { return $this->options; } + + // @phpstan-ignore-next-line public function setOptionSettingAttribute(?array $options) { $this->setOption($options); return $this; } + + // @phpstan-ignore-next-line public function getCssJsSettingAttribute() { return $this->options; } + + // @phpstan-ignore-next-line public function setCssJsSettingAttribute(?array $options) { $this->setOption($options); return $this; } + + // @phpstan-ignore-next-line public function getNotifyActionsCompleteUserAttribute() { $notify = $this->notify_complete_user; @@ -109,38 +149,52 @@ public function getNotifyActionsCompleteUserAttribute() // Convert notify_action_target as signle. return collect($notify->action_settings)->first(); } + + // @phpstan-ignore-next-line public function setNotifyActionsCompleteUserAttribute($json) { // action target convert as array $this->tmp_notify_action_complete_user = [$json]; return $this; } + + // @phpstan-ignore-next-line public function getNotifyActionsCompleteAdminAttribute() { $notify = $this->notify_complete_admin; return $notify ? $notify->action_settings : null; } + + // @phpstan-ignore-next-line public function setNotifyActionsCompleteAdminAttribute($json) { $this->tmp_notify_action_complete_admin = $json; return $this; } + + // @phpstan-ignore-next-line public function getNotifyActionsErrorAttribute() { $notify = $this->notify_error; return $notify ? $notify->action_settings : null; } + + // @phpstan-ignore-next-line public function setNotifyActionsErrorAttribute($json) { $this->tmp_notify_action_error = $json; return $this; } + + // @phpstan-ignore-next-line public function getNotifyMailTemplateCompleteUserAttribute() { $notify = $this->notify_complete_user; return $notify ? $notify->mail_template_id : null; } + + // @phpstan-ignore-next-line public function setNotifyMailTemplateCompleteUserAttribute($value) { $this->tmp_notify_mail_template_complete_user = $value; @@ -148,21 +202,29 @@ public function setNotifyMailTemplateCompleteUserAttribute($value) } + + // @phpstan-ignore-next-line public function getNotifyMailTemplateCompleteAdminAttribute() { $notify = $this->notify_complete_admin; return $notify ? $notify->mail_template_id : null; } + + // @phpstan-ignore-next-line public function setNotifyMailTemplateCompleteAdminAttribute($value) { $this->tmp_notify_mail_template_complete_admin = $value; return $this; } + + // @phpstan-ignore-next-line public function getNotifyMailTemplateErrorAttribute() { $notify = $this->notify_error; return $notify ? $notify->mail_template_id : null; } + + // @phpstan-ignore-next-line public function setNotifyMailTemplateErrorAttribute($value) { $this->tmp_notify_mail_template_error = $value; @@ -240,6 +302,8 @@ protected function toggleNotify() * @param array $json * @return void */ + + // @phpstan-ignore-next-line protected function exportReplaceJson(&$json) { // Append notify_complete_admin, notify_complete_user, notify_error @@ -292,6 +356,8 @@ protected function exportReplaceJson(&$json) * * @param array $json */ + + // @phpstan-ignore-next-line public function createNotifyImported(array $json) { // Append notify_complete_admin, notify_complete_user, notify_error @@ -347,6 +413,8 @@ public function createNotifyImported(array $json) * * @param array $json */ + + // @phpstan-ignore-next-line public function setPluginImported(array $json) { // set plugins ---------------------------------------------------- diff --git a/src/Model/Traits/TemplateTrait.php b/src/Model/Traits/TemplateTrait.php index 9361b4578..4dbec5386 100644 --- a/src/Model/Traits/TemplateTrait.php +++ b/src/Model/Traits/TemplateTrait.php @@ -13,6 +13,8 @@ */ trait TemplateTrait { + + // @phpstan-ignore-next-line protected static $defaultExcepts = ['id', 'created_at', 'updated_at', 'created_user_id', 'updated_user_id', 'disabled_delete']; // Description for $templateItems. @@ -55,6 +57,8 @@ trait TemplateTrait /** * search language data (by key matching). */ + + // @phpstan-ignore-next-line public static function searchLangData($json, $lang) { $keys = array_get(static::$templateItems, 'langs.keys', []); @@ -84,6 +88,8 @@ public static function searchLangData($json, $lang) * * @return array is_lang whether for language file */ + + // @phpstan-ignore-next-line public function getTemplateExportItems($is_lang = false) { $array = $this->toArray(); @@ -121,6 +127,8 @@ public function getTemplateExportItems($is_lang = false) })->toArray(); // get enum + + // @phpstan-ignore-next-line $enum = call_user_func_array([$uniqueKeyReplace['uniqueKeySystemEnum'], 'getEnum'], array_values($getEnumArgs)); if (isset($enum)) { $replacedValue = $enum->option(); @@ -135,6 +143,8 @@ public function getTemplateExportItems($is_lang = false) })->toArray(); // call eloquent function + + // @phpstan-ignore-next-line $replacedEloquent = call_user_func_array([$uniqueKeyReplace['uniqueKeyClassName'], 'getEloquent'], array_values($eloquentArgs)); if (isset($replacedEloquent)) { // get unique key names @@ -212,6 +222,8 @@ public function getTemplateExportItems($is_lang = false) * * @return \Illuminate\Database\Eloquent\Model|void template items */ + + // @phpstan-ignore-next-line public static function importTemplate($array, $is_update, $options = []) { //copy array for replacing items @@ -299,6 +311,8 @@ public static function importTemplate($array, $is_update, $options = []) } // create model + + // @phpstan-ignore-next-line $obj = static::firstOrNew($obj_keys); // if record is exists already skip process, when update @@ -374,6 +388,8 @@ public static function importTemplate($array, $is_update, $options = []) * * @return array key is database column name, value is database name. */ + + // @phpstan-ignore-next-line public function getUniqueKeyNames() { if (!property_exists(get_called_class(), 'templateItems') || !array_has(static::$templateItems, 'uniqueKeys')) { diff --git a/src/Model/Traits/UniqueKeyCustomColumnTrait.php b/src/Model/Traits/UniqueKeyCustomColumnTrait.php index cb73df3fe..04ac3defa 100644 --- a/src/Model/Traits/UniqueKeyCustomColumnTrait.php +++ b/src/Model/Traits/UniqueKeyCustomColumnTrait.php @@ -9,6 +9,8 @@ trait UniqueKeyCustomColumnTrait /** * get Table And Column Name */ + + // @phpstan-ignore-next-line protected function getUniqueKeyValues($key) { if (is_array($key) && count($key) > 0) { @@ -33,6 +35,8 @@ protected function getUniqueKeyValues($key) ]; } + + // @phpstan-ignore-next-line protected static function importReplaceJsonCustomColumn(&$json, $replace_custom_column_key, $custom_column_key, $custom_table_key, $options = []) { $custom_column = CustomColumn::getEloquent(array_get($json, $custom_column_key), array_get($json, $custom_table_key)); diff --git a/src/Model/Traits/UseRequestSessionTrait.php b/src/Model/Traits/UseRequestSessionTrait.php index 5a1a787ee..d1359213c 100644 --- a/src/Model/Traits/UseRequestSessionTrait.php +++ b/src/Model/Traits/UseRequestSessionTrait.php @@ -10,6 +10,10 @@ trait UseRequestSessionTrait { /** * get all records. use system session + * @param Closure|null $filter + * @param bool $isGetAll + * @param array $with + * @return \Illuminate\Support\Collection|static|null */ public static function allRecords(Closure $filter = null, $isGetAll = true, $with = []) { @@ -18,6 +22,10 @@ public static function allRecords(Closure $filter = null, $isGetAll = true, $wit /** * get all records. use cache + * @param Closure|null $filter + * @param bool $isGetAll + * @param array $with + * @return \Illuminate\Support\Collection|static|null */ public static function allRecordsCache(Closure $filter = null, $isGetAll = true, $with = []) { @@ -26,22 +34,38 @@ public static function allRecordsCache(Closure $filter = null, $isGetAll = true, /** * get first record. use system session + * @param Closure|null $filter + * @param bool $isGetAll + * @param array $with + * @return static|null */ public static function firstRecord(Closure $filter = null, $isGetAll = true, $with = []) { + + // @phpstan-ignore-next-line return static::_allRecords('requestSession', $filter, $isGetAll, $with, true); } /** * get first record. use cache + * @param Closure|null $filter + * @param bool $isGetAll + * @param array $with + * @return static|null */ public static function firstRecordCache(Closure $filter = null, $isGetAll = true, $with = []) { + + // @phpstan-ignore-next-line return static::_allRecords('cache', $filter, $isGetAll, $with, true); } /** * get children like hasMany. use cache + * @param class-string $className + * @param string $keyName + * @param string $idName + * @return \Illuminate\Support\Collection|static|null */ public function hasManyCache($className, $keyName, $idName = 'id') { @@ -52,6 +76,12 @@ public function hasManyCache($className, $keyName, $idName = 'id') /** * get all records. + * @param string $func + * @param Closure|null $filter + * @param bool $isGetAll + * @param array $with + * @param bool $first + * @return \Illuminate\Support\Collection|static|null */ protected static function _allRecords($func, Closure $filter = null, $isGetAll = true, $with = [], $first = false) { @@ -65,6 +95,7 @@ protected static function _allRecords($func, Closure $filter = null, $isGetAll = // execute filter if (isset($filter)) { + /** @phpstan-ignore-next-line Dynamic method call on Collection */ $records = $records->{$collectFunc}(function ($record) use ($filter) { return $filter($record); }); @@ -90,6 +121,8 @@ protected static function _allRecords($func, Closure $filter = null, $isGetAll = System::{$func}($key, $records); if (is_nullorempty($records)) { + + // @phpstan-ignore-next-line return $first ? null : $records; } @@ -101,8 +134,12 @@ protected static function _allRecords($func, Closure $filter = null, $isGetAll = } if ($first) { + + // @phpstan-ignore-next-line return $records->first(); } else { + + // @phpstan-ignore-next-line return $records; } } diff --git a/src/Model/Traits/UserTrait.php b/src/Model/Traits/UserTrait.php index c8f913f73..fabb00ed5 100644 --- a/src/Model/Traits/UserTrait.php +++ b/src/Model/Traits/UserTrait.php @@ -106,10 +106,12 @@ public function belong_role_groups_all() public function disabled_delete_trait() { // only administrator can delete and edit administrator record + if (!\Exment::user()->isAdministrator() && isset($this->login_user) && $this->login_user->isAdministrator()) { return true; } // cannnot delete myself + if (\Exment::getUserId() == $this->id) { return true; } diff --git a/src/Model/UserSetting.php b/src/Model/UserSetting.php index 88ebb775c..203ac7826 100644 --- a/src/Model/UserSetting.php +++ b/src/Model/UserSetting.php @@ -11,18 +11,26 @@ class UserSetting extends ModelBase use Traits\DatabaseJsonTrait; protected $casts = ['settings' => 'json']; + + // @phpstan-ignore-next-line public function getSetting($key, $default = null) { return $this->getJson('settings', $key, $default); } + + // @phpstan-ignore-next-line public function setSetting($key, $val = null, $forgetIfNull = false) { return $this->setJson('settings', $key, $val, $forgetIfNull); } + + // @phpstan-ignore-next-line public function forgetSetting($key) { return $this->forgetJson('settings', $key); } + + // @phpstan-ignore-next-line public function clearSetting() { return $this->clearJson('settings'); diff --git a/src/Model/Workflow.php b/src/Model/Workflow.php index e7f3af244..340544def 100644 --- a/src/Model/Workflow.php +++ b/src/Model/Workflow.php @@ -32,6 +32,8 @@ class Workflow extends ModelBase protected $appends = ['workflow_edit_flg']; protected $casts = ['options' => 'json']; + + // @phpstan-ignore-next-line public function workflow_tables() { return $this->hasMany(WorkflowTable::class, 'workflow_id'); @@ -40,6 +42,8 @@ public function workflow_tables() /** * get workflow statuses */ + + // @phpstan-ignore-next-line public function workflow_statuses() { return $this->hasMany(WorkflowStatus::class, 'workflow_id'); @@ -48,11 +52,15 @@ public function workflow_statuses() /** * get workflow actions */ + + // @phpstan-ignore-next-line public function workflow_actions() { return $this->hasMany(WorkflowAction::class, 'workflow_id'); } + + // @phpstan-ignore-next-line public function notifies() { return $this->hasMany(Notify::class, 'target_id') @@ -74,6 +82,8 @@ protected static function boot() /** * Delete children items */ + + // @phpstan-ignore-next-line public function deletingChildren() { $keys = ['workflow_statuses', 'workflow_tables', 'notifies']; @@ -83,6 +93,8 @@ public function deletingChildren() if (!method_exists($item, 'deletingChildren')) { continue; } + + // @phpstan-ignore-next-line $item->deletingChildren(); } @@ -96,10 +108,14 @@ public function deletingChildren() $this->workflow_actions()->forceDelete(); } + + // @phpstan-ignore-next-line public function getWorkflowEditFlgAttribute() { return $this->getOption('workflow_edit_flg'); } + + // @phpstan-ignore-next-line public function setWorkflowEditFlgAttribute($workflow_edit_flg) { $this->setOption('workflow_edit_flg', $workflow_edit_flg); @@ -110,6 +126,8 @@ public function setWorkflowEditFlgAttribute($workflow_edit_flg) /** * get workflow statuses using cache */ + + // @phpstan-ignore-next-line public function getWorkflowStatusesCacheAttribute() { return $this->hasManyCache(WorkflowStatus::class, 'workflow_id'); @@ -118,6 +136,8 @@ public function getWorkflowStatusesCacheAttribute() /** * get workflow actions */ + + // @phpstan-ignore-next-line public function getWorkflowActionsCacheAttribute() { return $this->hasManyCache(WorkflowAction::class, 'workflow_id'); @@ -127,6 +147,8 @@ public function getWorkflowActionsCacheAttribute() * get eloquent using Cache. * now only support only id. */ + + // @phpstan-ignore-next-line public static function getEloquent($id, $withs = []) { return static::getEloquentCache($id, $withs); @@ -147,6 +169,8 @@ public function getStatusesString() * * @return \Illuminate\Support\Collection|null */ + + // @phpstan-ignore-next-line public function getStatusOptions($onlyStart = false) { $statuses = collect(); @@ -164,6 +188,8 @@ public function getStatusOptions($onlyStart = false) * * @return \Illuminate\Support\Collection */ + + // @phpstan-ignore-next-line public function getActionOptions() { $actions = $this->workflow_actions_cache->pluck('action_name', 'id'); @@ -288,6 +314,8 @@ public function canActivate() return true; } + + // @phpstan-ignore-next-line public static function hasSettingCompleted() { return static::allRecords(function ($workflow) { diff --git a/src/Model/WorkflowAction.php b/src/Model/WorkflowAction.php index 5279d4e47..6247730b2 100644 --- a/src/Model/WorkflowAction.php +++ b/src/Model/WorkflowAction.php @@ -34,40 +34,58 @@ class WorkflowAction extends ModelBase protected $appends = ['work_targets', 'comment_type', 'flow_next_type', 'flow_next_count']; protected $casts = ['options' => 'json']; + + // @phpstan-ignore-next-line protected $work_targets; + + // @phpstan-ignore-next-line protected $work_condition_headers; + + // @phpstan-ignore-next-line public function workflow() { return $this->belongsTo(Workflow::class, 'workflow_id'); } + + // @phpstan-ignore-next-line public function workflow_authorities() { return $this->hasMany(WorkflowAuthority::class, 'workflow_action_id'); //->with(['user_organization']); } + + // @phpstan-ignore-next-line public function workflow_condition_headers() { return $this->hasMany(WorkflowConditionHeader::class, 'workflow_action_id'); } + + // @phpstan-ignore-next-line public function getWorkflowCacheAttribute() { return Workflow::getEloquent($this->workflow_id); } + + // @phpstan-ignore-next-line public function getWorkflowAuthoritiesCacheAttribute() { return $this->hasManyCache(WorkflowAuthority::class, 'workflow_action_id'); } + + // @phpstan-ignore-next-line public function getWorkflowConditionHeadersCacheAttribute() { return $this->hasManyCache(WorkflowConditionHeader::class, 'workflow_action_id'); } + + // @phpstan-ignore-next-line public function getWorkTargetsAttribute() { $result = []; @@ -79,7 +97,8 @@ public function getWorkTargetsAttribute() $result[$key] = $val; } - /** @phpstan-ignore-next-line Left side of && is always true. */ + + // @phpstan-ignore-next-line if ($key == 'work_target_type' && ($val == WorkflowWorkTargetType::FIX || $val == WorkflowWorkTargetType::GET_BY_USERINFO)) { $authorities = WorkflowAuthority::where('workflow_action_id', $this->id)->get(); $authorities->each(function ($v) use (&$result) { @@ -90,6 +109,8 @@ public function getWorkTargetsAttribute() return collect($result); } + + // @phpstan-ignore-next-line public function setWorkTargetsAttribute($work_targets) { if (is_nullorempty($work_targets)) { @@ -106,6 +127,8 @@ public function setWorkTargetsAttribute($work_targets) * * @return \Illuminate\Support\Collection|\Tightenco\Collect\Support\Collection */ + + // @phpstan-ignore-next-line public function getWorkConditionsAttribute() { $headers = $this->workflow_condition_headers() @@ -125,6 +148,8 @@ public function getWorkConditionsAttribute() ); }); } + + // @phpstan-ignore-next-line public function setWorkConditionsAttribute($work_conditions) { if (is_nullorempty($work_conditions)) { @@ -143,6 +168,8 @@ public function setWorkConditionsAttribute($work_conditions) * * @return array */ + + // @phpstan-ignore-next-line public function getWorkConditionSelectAttribute() { $headers = $this->workflow_condition_headers; @@ -152,6 +179,8 @@ public function getWorkConditionSelectAttribute() return $headers->first()->status_to; } + + // @phpstan-ignore-next-line public function setWorkConditionSelectAttribute($work_condition) { // Whether contains header check. @@ -169,6 +198,8 @@ public function setWorkConditionSelectAttribute($work_condition) return $this; } + + // @phpstan-ignore-next-line public function getStatusFromNameAttribute() { if (is_numeric($this->status_from)) { @@ -180,30 +211,42 @@ public function getStatusFromNameAttribute() return null; } + + // @phpstan-ignore-next-line public function getCommentTypeAttribute() { return $this->getOption('comment_type'); } + + // @phpstan-ignore-next-line public function setCommentTypeAttribute($comment_type) { $this->setOption('comment_type', $comment_type); return $this; } + + // @phpstan-ignore-next-line public function getFlowNextTypeAttribute() { return $this->getOption('flow_next_type'); } + + // @phpstan-ignore-next-line public function setFlowNextTypeAttribute($flow_next_type) { $this->setOption('flow_next_type', $flow_next_type); return $this; } + + // @phpstan-ignore-next-line public function getFlowNextCountAttribute() { return $this->getOption('flow_next_count'); } + + // @phpstan-ignore-next-line public function setFlowNextCountAttribute($flow_next_count) { $this->setOption('flow_next_count', $flow_next_count); @@ -214,6 +257,8 @@ public function setFlowNextCountAttribute($flow_next_count) * get eloquent using Cache. * now only support only id. */ + + // @phpstan-ignore-next-line public static function getEloquent($id, $withs = []) { return static::getEloquentCache($id, $withs); @@ -222,6 +267,8 @@ public static function getEloquent($id, $withs = []) /** * set action authority */ + + // @phpstan-ignore-next-line protected function setActionAuthority() { $this->syncOriginal(); @@ -280,6 +327,8 @@ protected function setActionAuthority() /** * set action conditions */ + + // @phpstan-ignore-next-line protected function setActionCondition() { $this->workflow_condition_headers()->delete(); @@ -306,6 +355,8 @@ protected function setActionCondition() * @param array $data * @return WorkflowValue|null */ + + // @phpstan-ignore-next-line public function executeAction($custom_value, $data = []) { $custom_table = $custom_value->custom_table; @@ -380,6 +431,8 @@ public function executeAction($custom_value, $data = []) * @param array $data comment * @return WorkflowValue created workflow value */ + + // @phpstan-ignore-next-line protected function forwardWorkflowValue(CustomValue $custom_value, array $data = []): WorkflowValue { $next = $this->isActionNext($custom_value); @@ -469,6 +522,8 @@ public function hasAuthority($custom_value, $targetUser = null) * @param CustomValue $custom_value * @return \Illuminate\Support\Collection */ + + // @phpstan-ignore-next-line public function getAuthorityTargets($custom_value, string $workflowGetAuthorityType, $params = []) { // Convert options @@ -562,6 +617,8 @@ public function getAuthorityTargets($custom_value, string $workflowGetAuthorityT * $getAutorities if true, get by authority * $asNextAction if true, get as next action. If false, get as current action. For use WorkflowWorkTargetType::GET_BY_USERINFO */ + + // @phpstan-ignore-next-line protected function getAuthorityTargetOption(string $workflowGetAuthorityType): array { $work_target_type = $this->getOption('work_target_type'); @@ -618,6 +675,8 @@ protected function getAuthorityTargetOption(string $workflowGetAuthorityType): a * * @return string|null */ + + // @phpstan-ignore-next-line public function getStatusToId($custom_value) { $next = $this->isActionNext($custom_value); @@ -640,6 +699,8 @@ public function getStatusToId($custom_value) * * @return WorkflowConditionHeader|null */ + + // @phpstan-ignore-next-line public function getMatchedCondtionHeader($custom_value) { if (count($this->workflow_condition_headers_cache) == 0) { @@ -661,6 +722,8 @@ public function getMatchedCondtionHeader($custom_value) * @param CustomValue $custom_value * @return boolean|array If next, return true. else, [$flow_next_count, $action_executed_count] */ + + // @phpstan-ignore-next-line public function isActionNext($custom_value) { list($isNext, $flow_next_count) = $this->getActionNextParams($custom_value); @@ -694,6 +757,8 @@ public function isActionNext($custom_value) * * @return array ["is action next", "next minimum count"] */ + + // @phpstan-ignore-next-line public function getActionNextParams($custom_value) { if (($flow_next_count = $this->getOption("flow_next_count", 1)) == 1 && $this->flow_next_type == WorkflowNextType::SOME) { @@ -735,6 +800,7 @@ public function actionModal($custom_value) } // check already executed user + // Exment helper class not recognized $showSubmit = !WorkflowValue::isAlreadyExecuted($this->id, $custom_value, \Exment::user()->base_user); if ($showSubmit) { @@ -805,6 +871,8 @@ public function actionModal($custom_value) // not next, showing message elseif ($next !== true) { + + // @phpstan-ignore-next-line list($flow_next_count, $action_executed_count) = $next; $form->display('flow_executed_user_count', exmtrans('workflow.flow_executed_user_count')) @@ -840,6 +908,8 @@ public function actionModal($custom_value) * * @return \Illuminate\Support\Collection */ + + // @phpstan-ignore-next-line protected function getNextActionAuthorities($custom_value, $statusTo, $nextActions = null) { // get next actions @@ -874,6 +944,8 @@ protected static function boot() }); } + + // @phpstan-ignore-next-line public function deletingChildren() { $keys = ['workflow_authorities', 'workflow_condition_headers']; @@ -883,6 +955,8 @@ public function deletingChildren() if (!method_exists($item, 'deletingChildren')) { continue; } + + // @phpstan-ignore-next-line $item->deletingChildren(); } @@ -898,6 +972,8 @@ public function deletingChildren() * @param string $workflow_status * @return void */ + + // @phpstan-ignore-next-line public static function appendStatusFromQuery($query, $workflow_status) { // if sql server, append cast @@ -906,8 +982,12 @@ public static function appendStatusFromQuery($query, $workflow_status) /** @phpstan-ignore-next-line */ $column = \DB::getQueryGrammar()->getCastColumn(DatabaseDataType::TYPE_STRING, SystemTableName::WORKFLOW_ACTION . '.status_from'); $whereStatusStart = $column . ' = ' . \Exment::wrapValue($workflow_status); + + // @phpstan-ignore-next-line $query->whereRaw($whereStatusStart); } else { + + // @phpstan-ignore-next-line $query->where(SystemTableName::WORKFLOW_ACTION . '.status_from', $workflow_status); } } @@ -925,8 +1005,12 @@ public static function appendStatusFromJoinQuery($query) // create where raw query /** @phpstan-ignore-next-line */ $whereStatusStart = \Exment::wrapColumn(SystemTableName::WORKFLOW_ACTION . '.status_from') . ' = ' . \DB::getQueryGrammar()->getCastColumn(DatabaseDataType::TYPE_STRING, SystemTableName::WORKFLOW_VALUE . '.workflow_status_to_id'); + + // @phpstan-ignore-next-line $query->whereRaw($whereStatusStart); } else { + + // @phpstan-ignore-next-line $query->whereColumn(SystemTableName::WORKFLOW_ACTION . '.status_from', SystemTableName::WORKFLOW_VALUE . '.workflow_status_to_id'); } } diff --git a/src/Model/WorkflowAuthority.php b/src/Model/WorkflowAuthority.php index 5985e35bd..8ddf2b255 100644 --- a/src/Model/WorkflowAuthority.php +++ b/src/Model/WorkflowAuthority.php @@ -18,6 +18,8 @@ class WorkflowAuthority extends ModelBase implements WorkflowAuthorityInterface { use Traits\UseRequestSessionTrait; + + // @phpstan-ignore-next-line public function getAuthorityTextAttribute() { $item = ConditionItemBase::getDetailItemByAuthority(null, $this); @@ -41,6 +43,8 @@ public function getAuthorityTextAttribute() * @param WorkflowAction $values * @return array */ + + // @phpstan-ignore-next-line public static function getAuhoritiesFromValue($values, $action = null) { $values = jsonToArray($values); @@ -71,6 +75,8 @@ public static function getAuhoritiesFromValue($values, $action = null) * * @return array */ + + // @phpstan-ignore-next-line public function getWorkflowAuthorityUserOrgLabels(CustomValue $custom_value, WorkflowAction $workflow_action, bool $asNextAction = false): array { $workflow = $workflow_action->workflow_cache; diff --git a/src/Model/WorkflowConditionHeader.php b/src/Model/WorkflowConditionHeader.php index cf39c5c78..58ffe53ba 100644 --- a/src/Model/WorkflowConditionHeader.php +++ b/src/Model/WorkflowConditionHeader.php @@ -18,11 +18,15 @@ class WorkflowConditionHeader extends ModelBase protected $appends = ['condition_join', 'condition_reverse']; protected $casts = ['options' => 'json']; + + // @phpstan-ignore-next-line public function workflow_action() { return $this->belongsTo(WorkflowAction::class, 'workflow_action_id'); } + + // @phpstan-ignore-next-line public function workflow_conditions() { return $this->morphMany(Condition::class, 'morph', 'morph_type', 'morph_id'); @@ -31,6 +35,8 @@ public function workflow_conditions() /** * check if custom_value and user(organization, role) match for conditions(with reverse option). */ + + // @phpstan-ignore-next-line public function isMatchCondition($custom_value) { $result = $this->_isMatchCondition($custom_value); @@ -43,6 +49,8 @@ public function isMatchCondition($custom_value) /** * check if custom_value and user(organization, role) match for conditions. */ + + // @phpstan-ignore-next-line public function _isMatchCondition($custom_value) { $is_or = $this->condition_join == 'or'; @@ -69,6 +77,8 @@ protected static function boot() }); } + + // @phpstan-ignore-next-line public function deletingChildren() { $keys = ['workflow_conditions']; @@ -78,11 +88,15 @@ public function deletingChildren() } } + + // @phpstan-ignore-next-line public function getConditionJoinAttribute() { return $this->getOption('condition_join'); } + + // @phpstan-ignore-next-line public function setConditionJoinAttribute($val) { if (is_null($val)) { @@ -94,11 +108,15 @@ public function setConditionJoinAttribute($val) return $this; } + + // @phpstan-ignore-next-line public function getConditionReverseAttribute() { return $this->getOption('condition_reverse'); } + + // @phpstan-ignore-next-line public function setConditionReverseAttribute($val) { if (is_null($val)) { diff --git a/src/Model/WorkflowStatus.php b/src/Model/WorkflowStatus.php index f70783912..c6e9bd6dd 100644 --- a/src/Model/WorkflowStatus.php +++ b/src/Model/WorkflowStatus.php @@ -21,6 +21,8 @@ class WorkflowStatus extends ModelBase use Traits\UseRequestSessionTrait; use Traits\ClearCacheTrait; + + // @phpstan-ignore-next-line public function deletingChildren() { } @@ -37,6 +39,8 @@ protected static function boot() * get eloquent using Cache. * now only support only id. */ + + // @phpstan-ignore-next-line public static function getEloquent($id, $withs = []) { return static::getEloquentCache($id, $withs); @@ -112,6 +116,8 @@ public static function getWorkflowStatusCompleted($workflow_status = null): bool * @param bool $ignoreReject * @return \Illuminate\Support\Collection */ + + // @phpstan-ignore-next-line public static function getActionsByFrom($workflow_status = null, $workflow = null, $ignoreReject = false) { if (!isset($workflow_status)) { diff --git a/src/Model/WorkflowTable.php b/src/Model/WorkflowTable.php index 554ce9642..adaa374a7 100644 --- a/src/Model/WorkflowTable.php +++ b/src/Model/WorkflowTable.php @@ -18,11 +18,15 @@ class WorkflowTable extends ModelBase use Traits\UseRequestSessionTrait; use Traits\ClearCacheTrait; + + // @phpstan-ignore-next-line public function workflow(): BelongsTo { return $this->belongsTo(Workflow::class, 'workflow_id'); } + + // @phpstan-ignore-next-line public function custom_table(): BelongsTo { return $this->belongsTo(CustomTable::class, 'custom_table_id'); diff --git a/src/Model/WorkflowValue.php b/src/Model/WorkflowValue.php index b47898d86..ff3ac4c5f 100644 --- a/src/Model/WorkflowValue.php +++ b/src/Model/WorkflowValue.php @@ -23,6 +23,8 @@ class WorkflowValue extends ModelBase { use Traits\AutoSUuidTrait; + + // @phpstan-ignore-next-line public function workflow() { return $this->belongsTo(Workflow::class, 'workflow_id'); @@ -33,51 +35,71 @@ public function workflow() * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ + + // @phpstan-ignore-next-line public function workflow_action() { return $this->belongsTo(WorkflowAction::class, 'workflow_action_id'); } + + // @phpstan-ignore-next-line public function workflow_status() { return $this->belongsTo(WorkflowStatus::class, 'workflow_status_to_id'); } + + // @phpstan-ignore-next-line public function workflow_status_to() { return $this->workflow_status(); } + + // @phpstan-ignore-next-line public function workflow_status_from() { return $this->belongsTo(WorkflowStatus::class, 'workflow_status_from_id'); } + + // @phpstan-ignore-next-line public function workflow_value_authorities() { return $this->hasMany(WorkflowValueAuthority::class, 'workflow_value_id'); } + + // @phpstan-ignore-next-line public function getWorkflowCacheAttribute() { return Workflow::getEloquent($this->workflow_id); } + + // @phpstan-ignore-next-line public function getWorkflowStatusCacheAttribute() { return WorkflowStatus::getEloquent($this->workflow_status_to_id); } + + // @phpstan-ignore-next-line public function getWorkflowActionCacheAttribute() { return WorkflowAction::getEloquent($this->workflow_action_id); } + + // @phpstan-ignore-next-line public function getWorkflowStatusNameAttribute() { return WorkflowStatus::getWorkflowStatusName($this->workflow_status_to_id, $this->workflow); } + + // @phpstan-ignore-next-line public function getWorkflowEditableAttribute() { $status = $this->workflow_status_cache; @@ -132,6 +154,8 @@ public function isCompleted(): bool * * @return bool */ + + // @phpstan-ignore-next-line public static function isAlreadyExecuted($action_id, $custom_value, $targetUser) { return static::where('morph_type', $custom_value->custom_table->table_name) @@ -150,6 +174,8 @@ public static function isAlreadyExecuted($action_id, $custom_value, $targetUser) * * @return WorkflowValue */ + + // @phpstan-ignore-next-line public static function getFirstExecutedWorkflowValue($custom_value) { // get first status name @@ -168,6 +194,8 @@ public static function getFirstExecutedWorkflowValue($custom_value) * * @return WorkflowValue|null */ + + // @phpstan-ignore-next-line public static function getLastExecutedWorkflowValue($custom_value) { return static::where('morph_type', $custom_value->custom_table_name) @@ -177,6 +205,8 @@ public static function getLastExecutedWorkflowValue($custom_value) ->first(); } + + // @phpstan-ignore-next-line public function deletingChildren() { $this->workflow_value_authorities()->delete(); diff --git a/src/Notifications/Mail/MailAttachment.php b/src/Notifications/Mail/MailAttachment.php index 2da4b7f82..ac86e47ce 100644 --- a/src/Notifications/Mail/MailAttachment.php +++ b/src/Notifications/Mail/MailAttachment.php @@ -7,12 +7,6 @@ class MailAttachment { - public function __construct(string $path, string $filename) - { - $this->path = $path; - $this->filename = $filename; - } - /** * Fillpath to file * @@ -27,6 +21,16 @@ public function __construct(string $path, string $filename) */ public $filename; + /** + * @param string $path + * @param string $filename + */ + public function __construct(string $path, string $filename) + { + $this->path = $path; + $this->filename = $filename; + } + /** * Get file full path * @@ -39,8 +43,10 @@ public function getFullPath(): ?string /** * Get file object + * + * @return string|null */ - public function getFile() + public function getFile(): ?string { return \Storage::disk(Define::DISKNAME_ADMIN)->get($this->path); } @@ -48,15 +54,16 @@ public function getFile() /** * Make instance * - * @param File|array $attachment + * @param File|array|mixed $attachment * @return MailAttachment|null */ - public static function make($attachment) + public static function make($attachment): ?MailAttachment { if ($attachment instanceof File) { return new MailAttachment($attachment->path, $attachment->filename); } elseif (is_array($attachment)) { return new MailAttachment(array_get($attachment, 'path'), array_get($attachment, 'filename')); } + return null; } } diff --git a/src/Notifications/Mail/MailChannel.php b/src/Notifications/Mail/MailChannel.php index a075c95a7..4ddc2dead 100644 --- a/src/Notifications/Mail/MailChannel.php +++ b/src/Notifications/Mail/MailChannel.php @@ -19,7 +19,7 @@ class MailChannel * @param \Illuminate\Notifications\Notification $notification * @return void */ - public function send($notifiable, Notification $notification) + public function send($notifiable, Notification $notification): void { /** @var MailSendJob $notification */ $mailMessage = $notification->toMail($notifiable); @@ -29,7 +29,11 @@ public function send($notifiable, Notification $notification) } - protected function sendMail(MailMessage $mailMessage) + /** + * @param MailMessage $mailMessage + * @return void + */ + protected function sendMail(MailMessage $mailMessage): void { // if use archive attachments, after sending, removing file $tmpZipPath = null; @@ -63,7 +67,13 @@ protected function sendMail(MailMessage $mailMessage) } - protected function setAttachments(Message $message, MailMessage $mailMessage, &$tmpZipPath) + /** + * @param Message $message + * @param MailMessage $mailMessage + * @param string|null $tmpZipPath + * @return void + */ + protected function setAttachments(Message $message, MailMessage $mailMessage, ?string &$tmpZipPath): void { if (collect($mailMessage->getAttachments())->count() == 0) { return; @@ -86,9 +96,10 @@ protected function setAttachments(Message $message, MailMessage $mailMessage, &$ /** * Archive tmp attachment * - * @return array offset 0 : zip path, offset 1 : filename + * @param MailMessage $mailMessage + * @return array offset 0 : zip path, offset 1 : filename */ - protected function archiveAttachments(MailMessage $mailMessage) + protected function archiveAttachments(MailMessage $mailMessage): array { $password = $mailMessage->getPassword(); $filename = Carbon::now()->format('YmdHis') . '.zip'; @@ -111,7 +122,7 @@ protected function archiveAttachments(MailMessage $mailMessage) * @param MailMessage $mailMessage * @return void */ - protected function saveHistory(MailMessage $mailMessage) + protected function saveHistory(MailMessage $mailMessage): void { if (!$mailMessage->isSetHistory()) { return; diff --git a/src/Notifications/Mail/MailHistory.php b/src/Notifications/Mail/MailHistory.php index bad68d32b..baecc87a1 100644 --- a/src/Notifications/Mail/MailHistory.php +++ b/src/Notifications/Mail/MailHistory.php @@ -55,11 +55,12 @@ class MailHistory * Get user id. * @return string|null */ - public function getUserId() + public function getUserId(): ?string { if ($this->user instanceof CustomValue) { return $this->user->getUserId(); } elseif ($this->user instanceof LoginUser) { + // @phpstan-ignore-next-line return $this->user->getUserId(); } elseif ($this->user instanceof NotifyTarget) { return $this->user->id(); @@ -74,7 +75,7 @@ public function getUserId() /** * Target mail template's id - * @return string|null + * @return string|int|null */ public function getMailTemplateId() { @@ -92,7 +93,7 @@ public function getMailTemplateId() * Target custom value's id * @return string|null */ - public function getParentId() + public function getParentId(): ?string { return $this->parent_id; } @@ -101,7 +102,7 @@ public function getParentId() * Target custom value's table name * @return string|null */ - public function getParentType() + public function getParentType(): ?string { return $this->parent_type; } @@ -153,14 +154,18 @@ public function isSetHistoryBody(): bool * * @return self */ - public function setUser($user) + public function setUser($user): self { $this->user = $user; return $this; } - public function setCustomValue(?CustomValue $custom_value) + /** + * @param CustomValue|null $custom_value + * @return self + */ + public function setCustomValue(?CustomValue $custom_value): self { $this->custom_value = $custom_value; $this->parent_id = $custom_value ? $custom_value->id : null; @@ -169,13 +174,21 @@ public function setCustomValue(?CustomValue $custom_value) return $this; } - public function setHistory(bool $isSetHistory) + /** + * @param bool $isSetHistory + * @return self + */ + public function setHistory(bool $isSetHistory): self { $this->isSetHistory = $isSetHistory; return $this; } - public function setHistoryBody(bool $isSetHistoryBody) + /** + * @param bool $isSetHistoryBody + * @return self + */ + public function setHistoryBody(bool $isSetHistoryBody): self { $this->isSetHistoryBody = $isSetHistoryBody; return $this; @@ -188,7 +201,7 @@ public function setHistoryBody(bool $isSetHistoryBody) * * @return self */ - public function setMailTemplate($mail_template) + public function setMailTemplate($mail_template): self { $this->mail_template = $mail_template; diff --git a/src/Notifications/Mail/MailHistoryTrait.php b/src/Notifications/Mail/MailHistoryTrait.php index 185693b1d..a002d6a3d 100644 --- a/src/Notifications/Mail/MailHistoryTrait.php +++ b/src/Notifications/Mail/MailHistoryTrait.php @@ -53,6 +53,7 @@ public function getUserId() */ public function getMailTemplateId() { + // @phpstan-ignore-next-line return $this->mailHistory->getMailTemplateId(); } @@ -114,16 +115,19 @@ public function setUser($user) return $this->mailHistory->setUser($user); } + // @phpstan-ignore-next-line public function setCustomValue(?CustomValue $custom_value) { return $this->mailHistory->setCustomValue($custom_value); } + // @phpstan-ignore-next-line public function setHistory(bool $isSetHistory) { return $this->mailHistory->setHistory($isSetHistory); } + // @phpstan-ignore-next-line public function setHistoryBody(bool $isSetHistoryBody) { return $this->mailHistory->setHistoryBody($isSetHistoryBody); diff --git a/src/Notifications/Mail/MailInfo.php b/src/Notifications/Mail/MailInfo.php index 56841726a..8d7b6b47e 100644 --- a/src/Notifications/Mail/MailInfo.php +++ b/src/Notifications/Mail/MailInfo.php @@ -8,49 +8,49 @@ class MailInfo { /** - * @var string + * @var string|null */ protected $from; /** * from name - * @var string + * @var string|null */ protected $fromName; /** - * @var array + * @var array */ protected $to = []; /** - * @var array + * @var array */ protected $cc = []; /** - * @var array + * @var array */ protected $bcc = []; /** - * @var string + * @var string|null */ protected $subject; /** - * @var string + * @var string|null */ protected $body; /** * 'text/plain' or 'text/html' - * @var string + * @var string|null */ protected $bodyType; /** - * @var array + * @var array */ protected $attachments = []; @@ -61,7 +61,7 @@ class MailInfo protected $usePassword = false; /** - * @var string + * @var string|null */ protected $password; @@ -89,6 +89,7 @@ public function getFromName(): ?string /** * @return array */ + // @phpstan-ignore-next-line public function getTo(): array { return NotifyService::getAddresses($this->to); @@ -97,6 +98,7 @@ public function getTo(): array /** * @return array */ + // @phpstan-ignore-next-line public function getCc(): array { return NotifyService::getAddresses($this->cc); @@ -105,6 +107,7 @@ public function getCc(): array /** * @return array */ + // @phpstan-ignore-next-line public function getBcc(): array { return NotifyService::getAddresses($this->bcc); @@ -137,6 +140,7 @@ public function getBodyType(): ?string /** * @return array */ + // @phpstan-ignore-next-line public function getAttachments(): array { return array_filter($this->attachments); @@ -161,60 +165,100 @@ public function getPassword(): ?string + /** + * @param mixed $from + * @return $this + */ public function setFrom($from) { $this->from = $from; return $this; } + /** + * @param mixed $fromName + * @return $this + */ public function setFromName($fromName) { $this->fromName = $fromName; return $this; } + /** + * @param mixed $to + * @return $this + */ public function setTo($to) { $this->to = array_merge($this->to, $this->convertArray($to)); return $this; } + /** + * @param mixed $cc + * @return $this + */ public function setCc($cc) { $this->cc = array_merge($this->cc, $this->convertArray($cc)); return $this; } + /** + * @param mixed $bcc + * @return $this + */ public function setBcc($bcc) { $this->bcc = array_merge($this->bcc, $this->convertArray($bcc)); return $this; } + /** + * @param mixed $subject + * @return $this + */ public function setSubject($subject) { $this->subject = $subject; return $this; } + /** + * @param mixed $body + * @return $this + */ public function setBody($body) { $this->body = $body; return $this; } + /** + * @param mixed $bodyType + * @return $this + */ public function setBodyType($bodyType) { $this->bodyType = $bodyType; return $this; } + /** + * @param mixed $usePassword + * @return $this + */ public function setUsePassword($usePassword) { $this->usePassword = $usePassword; return $this; } + /** + * @param mixed $password + * @return $this + */ public function setPassword($password) { $this->password = $password; @@ -222,6 +266,10 @@ public function setPassword($password) } + /** + * @param mixed $attachments + * @return $this + */ public function setAttachments($attachments) { if (is_nullorempty($this->attachments)) { @@ -239,13 +287,20 @@ public function setAttachments($attachments) } - public function clearAttachments() + /** + * @return void + */ + public function clearAttachments(): void { $this->attachments = []; } - protected function convertArray($value) + /** + * @param mixed $value + * @return array + */ + protected function convertArray($value): array { if ($value instanceof \Illuminate\Database\Eloquent\Model || $value instanceof \Exceedone\Exment\Model\NotifyTarget) { return [$value]; diff --git a/src/Notifications/Mail/MailInfoTrait.php b/src/Notifications/Mail/MailInfoTrait.php index 414a9c867..027b4d2f7 100644 --- a/src/Notifications/Mail/MailInfoTrait.php +++ b/src/Notifications/Mail/MailInfoTrait.php @@ -54,6 +54,7 @@ public function getFromName(): ?string /** * @return array */ + // @phpstan-ignore-next-line public function getTo(): array { return $this->mailInfo->getTo(); @@ -62,6 +63,7 @@ public function getTo(): array /** * @return array */ + // @phpstan-ignore-next-line public function getCc(): array { return $this->mailInfo->getCc(); @@ -70,6 +72,7 @@ public function getCc(): array /** * @return array */ + // @phpstan-ignore-next-line public function getBcc(): array { return $this->mailInfo->getBcc(); @@ -102,6 +105,7 @@ public function getBodyType(): ?string /** * @return array */ + // @phpstan-ignore-next-line public function getAttachments(): array { return $this->mailInfo->getAttachments(); @@ -125,57 +129,68 @@ public function getPassword(): ?string + // @phpstan-ignore-next-line public function setFrom($from) { return $this->mailInfo->setFrom($from); } + // @phpstan-ignore-next-line public function setFromName($fromName) { return $this->mailInfo->setFromName($fromName); } + // @phpstan-ignore-next-line public function setTo($to) { return $this->mailInfo->setTo($to); } + // @phpstan-ignore-next-line public function setCc($cc) { return $this->mailInfo->setCc($cc); } + // @phpstan-ignore-next-line public function setBcc($bcc) { return $this->mailInfo->setBcc($bcc); } + // @phpstan-ignore-next-line public function setSubject($subject) { return $this->mailInfo->setSubject($subject); } + // @phpstan-ignore-next-line public function setBody($body) { return $this->mailInfo->setBody($body); } + // @phpstan-ignore-next-line public function setBodyType($bodyType) { return $this->mailInfo->setBodyType($bodyType); } + // @phpstan-ignore-next-line public function setUsePassword($usePassword) { return $this->mailInfo->setUsePassword($usePassword); } + // @phpstan-ignore-next-line public function setPassword($password) { return $this->mailInfo->setPassword($password); } + // @phpstan-ignore-next-line public function setAttachments($attachments) { return $this->mailInfo->setAttachments($attachments); diff --git a/src/Notifications/MailSender.php b/src/Notifications/MailSender.php index 2973c3dc8..0af69209f 100644 --- a/src/Notifications/MailSender.php +++ b/src/Notifications/MailSender.php @@ -27,14 +27,24 @@ class MailSender extends SenderBase use MailInfoTrait; use MailHistoryTrait; - + /** + * @var array + */ protected $prms = []; + + /** + * @var array + */ protected $replaceOptions = []; + + /** + * @var mixed + */ protected $final_user; /** - * @param $mail_template - * @param $to + * @param mixed $mail_template + * @param mixed $to * @throws NoMailTemplateException */ public function __construct($mail_template, $to) @@ -51,20 +61,29 @@ public function __construct($mail_template, $to) if (!is_nullorempty($mail_template)) { $this->mailHistory->setMailTemplate($mail_template); $this->setSubject($mail_template->getValue('mail_subject')); - /** @phpstan-ignore-next-line Maybe need reflection. */ + // @phpstan-ignore-next-line $this->setBody($mail_template->getJoinedBody()); $this->setFromName($mail_template->getValue('mail_from_view_name')); } } - public static function make($mail_template, $to) + /** + * @param mixed $mail_template + * @param mixed $to + * @return MailSender + */ + public static function make($mail_template, $to): MailSender { $sender = new MailSender($mail_template, $to); return $sender; } + /** + * @param mixed $from + * @return $this + */ public function from($from) { $this->setFrom($from); @@ -73,6 +92,8 @@ public function from($from) /** * mail TO. support mail address or User model + * @param mixed $to + * @return $this */ public function to($to) { @@ -85,6 +106,8 @@ public function to($to) /** * mail CC. support mail address or User model + * @param mixed $cc + * @return $this */ public function cc($cc) { @@ -97,6 +120,8 @@ public function cc($cc) /** * mail BCC. support mail address or User model + * @param mixed $bcc + * @return $this */ public function bcc($bcc) { @@ -107,6 +132,10 @@ public function bcc($bcc) return $this; } + /** + * @param mixed $subject + * @return $this + */ public function subject($subject) { if (isset($subject)) { @@ -116,6 +145,10 @@ public function subject($subject) return $this; } + /** + * @param mixed $body + * @return $this + */ public function body($body) { if (isset($body)) { @@ -125,6 +158,10 @@ public function body($body) return $this; } + /** + * @param mixed $attachments + * @return $this + */ public function attachments($attachments) { if (isset($attachments)) { @@ -138,6 +175,10 @@ public function attachments($attachments) return $this; } + /** + * @param mixed $custom_value + * @return $this + */ public function custom_value($custom_value) { if (isset($custom_value)) { @@ -147,6 +188,10 @@ public function custom_value($custom_value) return $this; } + /** + * @param mixed $user + * @return $this + */ public function user($user) { if (isset($user)) { @@ -157,12 +202,19 @@ public function user($user) return $this; } + /** + * @return $this + */ public function disableHistoryBody() { $this->setHistoryBody(false); return $this; } + /** + * @param mixed $prms + * @return $this + */ public function prms($prms) { if (isset($prms)) { @@ -172,6 +224,10 @@ public function prms($prms) return $this; } + /** + * @param mixed $final_user + * @return $this + */ public function finalUser($final_user) { if (isset($final_user)) { @@ -181,6 +237,10 @@ public function finalUser($final_user) return $this; } + /** + * @param mixed $replaceOptions + * @return $this + */ public function replaceOptions($replaceOptions) { $this->replaceOptions = $replaceOptions; @@ -212,14 +272,19 @@ public function getKey() /** * Send Mail + * + * @return void */ - public function send() + public function send(): void { $this->sendMail(); $this->sendPasswordMail(); } - protected function sendMail() + /** + * @return void + */ + protected function sendMail(): void { // get subject $subject = NotifyService::replaceWord($this->getSubject(), $this->getCustomValue(), $this->prms, $this->replaceOptions); @@ -248,7 +313,10 @@ protected function sendMail() } - protected function sendPasswordMail() + /** + * @return void + */ + protected function sendPasswordMail(): void { if (!boolval($this->getUsePassword())) { return; @@ -293,10 +361,12 @@ protected function sendPasswordMail() * Get Body And Body Type(PLAIN, HTML) * Replace body break to
    , or
    to \n * - * @param string $body - * @return array offset 0 : $body, 1 : Type(PLAIN, HTML) + * @param mixed $body + * @param array $prms + * @param array $replaceOptions + * @return array offset 0 : $body, 1 : Type(PLAIN, HTML) */ - protected function getBodyAndBodyType($body, array $prms = [], array $replaceOptions = []) + protected function getBodyAndBodyType($body, array $prms = [], array $replaceOptions = []): array { $body = NotifyService::replaceWord($body, $this->getCustomValue(), $prms, $replaceOptions); diff --git a/src/Notifications/MicrosoftTeams/MicrosoftTeamsChannel.php b/src/Notifications/MicrosoftTeams/MicrosoftTeamsChannel.php index 0c0dc2827..893b06533 100644 --- a/src/Notifications/MicrosoftTeams/MicrosoftTeamsChannel.php +++ b/src/Notifications/MicrosoftTeams/MicrosoftTeamsChannel.php @@ -29,16 +29,17 @@ public function __construct(HttpClient $http) * Notify * * @param mixed $notifiable - * @param MicrosoftTeamsJob $notification + * @param Notification $notification * @return void */ - public function send($notifiable, Notification $notification) + public function send($notifiable, Notification $notification): void { if (! $url = $notifiable->routeNotificationFor('microsoft_teams', $notification)) { return; } $this->http->post($url, $this->buildJsonPayload( + // @phpstan-ignore-next-line $notification->toChat($notifiable) )); } @@ -46,9 +47,10 @@ public function send($notifiable, Notification $notification) /** * Build up a JSON payload for the Slack webhook. * - * @return array + * @param mixed $message + * @return array */ - protected function buildJsonPayload($message) + protected function buildJsonPayload($message): array { return [ 'json' => [ diff --git a/src/Notifications/MicrosoftTeams/MicrosoftTeamsMessage.php b/src/Notifications/MicrosoftTeams/MicrosoftTeamsMessage.php index d4f0333db..e99add111 100644 --- a/src/Notifications/MicrosoftTeams/MicrosoftTeamsMessage.php +++ b/src/Notifications/MicrosoftTeams/MicrosoftTeamsMessage.php @@ -7,21 +7,21 @@ class MicrosoftTeamsMessage /** * The text content of the message. * - * @var string + * @var string|null */ public $content; /** * The text title of the message. * - * @var string + * @var string|null */ public $title; /** * Set the content of the Teams message. * - * @param string $content + * @param mixed $content * @return $this */ public function content($content) @@ -34,7 +34,7 @@ public function content($content) /** * Set the title of the Teams message. * - * @param string $title + * @param mixed $title * @return $this */ public function title($title) diff --git a/src/Notifications/MicrosoftTeamsSender.php b/src/Notifications/MicrosoftTeamsSender.php index 393c2a3cc..2310cabc9 100644 --- a/src/Notifications/MicrosoftTeamsSender.php +++ b/src/Notifications/MicrosoftTeamsSender.php @@ -14,6 +14,9 @@ class MicrosoftTeamsSender extends SenderBase /** * Create a new notification instance. * + * @param mixed $webhook_url + * @param mixed $subject + * @param mixed $body * @return void */ public function __construct($webhook_url, $subject, $body) @@ -27,9 +30,10 @@ public function __construct($webhook_url, $subject, $body) /** * Initialize $this * - * @param string $webhook_url - * @param string $subject - * @param string $body + * @param mixed $webhook_url + * @param mixed $subject + * @param mixed $body + * @param array $options * @return MicrosoftTeamsSender */ public static function make($webhook_url, $subject, $body, array $options = []): MicrosoftTeamsSender @@ -38,7 +42,10 @@ public static function make($webhook_url, $subject, $body, array $options = []): } - protected function routeNotificationForMicrosoftTeams() + /** + * @return string|null + */ + protected function routeNotificationForMicrosoftTeams(): ?string { return $this->webhook_url; } @@ -48,7 +55,7 @@ protected function routeNotificationForMicrosoftTeams() * * @return void */ - public function send() + public function send(): void { // replace word $teams_content = $this->editContent(); @@ -58,12 +65,13 @@ public function send() /** * replace url to slack format. + * + * @return string */ - protected function editContent() + protected function editContent(): string { $content = $this->body; preg_match_all(Define::RULES_REGEX_LINK_FORMAT, $content, $matches); - // @phpstan-ignore-next-line if (isset($matches)) { for ($i = 0; $i < count($matches[1]); $i++) { diff --git a/src/Notifications/Navbar/NavbarChannel.php b/src/Notifications/Navbar/NavbarChannel.php index 495e954a0..f664823c2 100644 --- a/src/Notifications/Navbar/NavbarChannel.php +++ b/src/Notifications/Navbar/NavbarChannel.php @@ -10,11 +10,11 @@ class NavbarChannel /** * Notify * - * @param $notifiable + * @param mixed $notifiable * @param Notification $notification * @return void */ - public function send($notifiable, Notification $notification) + public function send($notifiable, Notification $notification): void { /** @var NavbarJob $notification */ $notification->toNavbar($notifiable); diff --git a/src/Notifications/NavbarSender.php b/src/Notifications/NavbarSender.php index 2ad17b2ca..7ccfe5e10 100644 --- a/src/Notifications/NavbarSender.php +++ b/src/Notifications/NavbarSender.php @@ -12,17 +12,32 @@ class NavbarSender extends SenderBase { use Notifiable; + /** + * @var mixed + */ protected $notify_id; + + /** + * @var mixed + */ protected $custom_value; + + /** + * @var mixed + */ protected $custom_table_id; + + /** + * @var mixed + */ protected $user; /** * Create a new notification instance. * * @return void - * @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line public function __construct($notify_id, $subject, $body, array $options = []) { $this->notify_id = $notify_id; @@ -33,10 +48,10 @@ public function __construct($notify_id, $subject, $body, array $options = []) /** * Initialize $this * - * @param string $notify_id - * @param string $subject - * @param string $body - * @param array $options + * @param mixed $notify_id + * @param mixed $subject + * @param mixed $body + * @param array $options * @return NavbarSender */ public static function make($notify_id, $subject, $body, $options): NavbarSender @@ -44,6 +59,10 @@ public static function make($notify_id, $subject, $body, $options): NavbarSender return new self($notify_id, $subject, $body, $options); } + /** + * @param mixed $custom_value + * @return $this + */ public function custom_value($custom_value) { if (isset($custom_value)) { @@ -53,6 +72,10 @@ public function custom_value($custom_value) return $this; } + /** + * @param mixed $custom_table + * @return $this + */ public function custom_table($custom_table) { if (isset($custom_table)) { @@ -62,6 +85,10 @@ public function custom_table($custom_table) return $this; } + /** + * @param mixed $user + * @return $this + */ public function user($user) { if (isset($user)) { @@ -77,7 +104,7 @@ public function user($user) * * @return void */ - public function send() + public function send(): void { if ($this->user instanceof CustomValue) { $target_user_id = $this->user->getUserId(); diff --git a/src/Notifications/SenderBase.php b/src/Notifications/SenderBase.php index ba4d8f2f9..aa87f8654 100644 --- a/src/Notifications/SenderBase.php +++ b/src/Notifications/SenderBase.php @@ -4,13 +4,20 @@ abstract class SenderBase { + /** + * @var mixed + */ protected $subject; + + /** + * @var mixed + */ protected $body; /** * Get the subject of message. * - * @return string + * @return mixed */ public function getSubject() { @@ -20,7 +27,7 @@ public function getSubject() /** * Get the body of message. * - * @return string + * @return mixed */ public function getBody() { @@ -32,5 +39,5 @@ public function getBody() * * @return void */ - abstract public function send(); + abstract public function send(): void; } diff --git a/src/Notifications/SlackSender.php b/src/Notifications/SlackSender.php index 4fb8dcc75..38d3235b2 100644 --- a/src/Notifications/SlackSender.php +++ b/src/Notifications/SlackSender.php @@ -12,14 +12,33 @@ class SlackSender extends SenderBase use Notifiable; use WebhookTrait; + /** + * @var mixed + */ protected $name; + + /** + * @var mixed + */ protected $icon; + + /** + * @var bool + */ protected $mention_here = false; + + /** + * @var array + */ protected $mention_users = []; /** * Create a new notification instance. * + * @param mixed $webhook_url + * @param mixed $subject + * @param mixed $body + * @param array $options * @return void */ public function __construct($webhook_url, $subject, $body, array $options = []) @@ -36,9 +55,10 @@ public function __construct($webhook_url, $subject, $body, array $options = []) /** * Initialize $this * - * @param string $webhook_url - * @param string $subject - * @param string $body + * @param mixed $webhook_url + * @param mixed $subject + * @param mixed $body + * @param array $options * @return SlackSender */ public static function make($webhook_url, $subject, $body, $options): SlackSender @@ -47,7 +67,10 @@ public static function make($webhook_url, $subject, $body, $options): SlackSende } - protected function routeNotificationForSlack() + /** + * @return string|null + */ + protected function routeNotificationForSlack(): ?string { return $this->webhook_url; } @@ -57,7 +80,7 @@ protected function routeNotificationForSlack() * * @return void */ - public function send() + public function send(): void { // replace word $slack_content = $this->editContent(); @@ -67,8 +90,10 @@ public function send() /** * replace url to slack format. + * + * @return string */ - protected function editContent() + protected function editContent(): string { $content = $this->subject . "\n*************************\n" . $this->body; @@ -87,7 +112,6 @@ protected function editContent() } preg_match_all(Define::RULES_REGEX_LINK_FORMAT, $content, $matches); - // @phpstan-ignore-next-line if (isset($matches)) { for ($i = 0; $i < count($matches[1]); $i++) { diff --git a/src/Notifications/WebhookTrait.php b/src/Notifications/WebhookTrait.php index de51b2ceb..125910649 100644 --- a/src/Notifications/WebhookTrait.php +++ b/src/Notifications/WebhookTrait.php @@ -4,14 +4,17 @@ trait WebhookTrait { + /** + * @var string|null + */ protected $webhook_url; /** * Get the value of the notifiable's primary key. * - * @return String + * @return string|null */ - public function getKey() + public function getKey(): ?string { return $this->webhook_url; } @@ -19,9 +22,9 @@ public function getKey() /** * Get the webhook url. * - * @return string + * @return string|null */ - public function getWebhookUrl() + public function getWebhookUrl(): ?string { return $this->webhook_url; } diff --git a/src/PartialCrudItems/ProviderBase.php b/src/PartialCrudItems/ProviderBase.php index 6db4af41c..f3760a7a7 100644 --- a/src/PartialCrudItems/ProviderBase.php +++ b/src/PartialCrudItems/ProviderBase.php @@ -8,8 +8,10 @@ */ abstract class ProviderBase { + // @phpstan-ignore-next-line protected $custom_table; + // @phpstan-ignore-next-line public function __construct($custom_table) { $this->custom_table = $custom_table; @@ -18,6 +20,7 @@ public function __construct($custom_table) /** * set laravel admin grid's content */ + // @phpstan-ignore-next-line public function setGridContent(&$content) { } @@ -25,6 +28,7 @@ public function setGridContent(&$content) /** * set laravel admin row action */ + // @phpstan-ignore-next-line public function setGridRowAction(&$actions) { } @@ -32,6 +36,7 @@ public function setGridRowAction(&$actions) /** * set laravel admin form's option */ + // @phpstan-ignore-next-line public function setAdminFormOptions(&$form, $id = null) { } @@ -39,6 +44,7 @@ public function setAdminFormOptions(&$form, $id = null) /** * set laravel admin form's tool */ + // @phpstan-ignore-next-line public function setAdminFormTools(&$tools, $id = null) { } @@ -46,6 +52,7 @@ public function setAdminFormTools(&$tools, $id = null) /** * set laravel admin show form's tool */ + // @phpstan-ignore-next-line public function setAdminShowTools(&$tools, $id = null) { } @@ -53,6 +60,7 @@ public function setAdminShowTools(&$tools, $id = null) /** * saving event */ + // @phpstan-ignore-next-line public function saving($form, $id = null) { } @@ -60,10 +68,12 @@ public function saving($form, $id = null) /** * saved event */ + // @phpstan-ignore-next-line public function saved($form, $id) { } + // @phpstan-ignore-next-line public static function getItem(...$args) { list($custom_table) = $args + [null]; diff --git a/src/PartialCrudItems/Providers/LoginUserItem.php b/src/PartialCrudItems/Providers/LoginUserItem.php index 214b893a2..bf60f7d25 100644 --- a/src/PartialCrudItems/Providers/LoginUserItem.php +++ b/src/PartialCrudItems/Providers/LoginUserItem.php @@ -21,6 +21,7 @@ class LoginUserItem extends ProviderBase /** * set laravel admin form's option */ + // @phpstan-ignore-next-line public function setAdminFormOptions(&$form, $id = null) { if (!\Exment::user()->hasPermission(Permission::LOGIN_USER)) { @@ -43,7 +44,7 @@ public function setAdminFormOptions(&$form, $id = null) if ($has_loginuser) { $form->switchbool('reset_password', exmtrans('user.reset_password')) - /** @phpstan-ignore-next-line Negated boolean expression is always false. */ + // @phpstan-ignore-next-line ->default(!$has_loginuser) ->help(exmtrans('user.help.reset_password')) ->attribute(['data-filter' => json_encode(['key' => 'use_loginuser', 'value' => '1'])]); @@ -103,6 +104,7 @@ public function setAdminFormOptions(&$form, $id = null) /** * saving event */ + // @phpstan-ignore-next-line public function saving($form, $id = null) { if (!\Exment::user()->hasPermission(Permission::LOGIN_USER)) { @@ -125,6 +127,7 @@ public function saving($form, $id = null) /** * saved event */ + // @phpstan-ignore-next-line public function saved($form, $id) { if (!\Exment::user()->hasPermission(Permission::LOGIN_USER)) { @@ -165,6 +168,7 @@ public function saved($form, $id) * @param null|string $id * @return array|\Illuminate\Http\Response|RedirectResponse|void if error, return redirect. if success, array. */ + // @phpstan-ignore-next-line protected function getLoginUserInfo($data, $id) { $user = getModelName(SystemTableName::USER)::find($id); @@ -183,7 +187,7 @@ protected function getLoginUserInfo($data, $id) $has_change = false; $is_newuser = false; $password = null; - /** @phpstan-ignore-next-line Right side of && is always true. Maybe boolval is unessasary. */ + // @phpstan-ignore-next-line if (is_null($login_user) && boolval(array_get($data, 'use_loginuser'))) { $login_user = new LoginUser(); $is_newuser = true; @@ -220,6 +224,7 @@ protected function getLoginUserInfo($data, $id) /** * set user grid's actions */ + // @phpstan-ignore-next-line public function setGridRowAction(&$actions) { $this->setEditDelete($actions, $actions->row); @@ -228,6 +233,7 @@ public function setGridRowAction(&$actions) /** * set user form's tools */ + // @phpstan-ignore-next-line public function setAdminFormTools(&$tools, $id = null) { $this->setEditDelete($tools, $id); @@ -236,11 +242,13 @@ public function setAdminFormTools(&$tools, $id = null) /** * set user show form's tool */ + // @phpstan-ignore-next-line public function setAdminShowTools(&$tools, $id = null) { $this->setEditDelete($tools, $id); } + // @phpstan-ignore-next-line protected function setEditDelete($tools, $custom_value) { if (is_numeric($custom_value)) { @@ -262,6 +270,7 @@ protected function setEditDelete($tools, $custom_value) } } + // @phpstan-ignore-next-line protected function getLoginUser($base_user_id) { if (!isset($base_user_id)) { diff --git a/src/PartialCrudItems/Providers/OrgazanizationTreeItem.php b/src/PartialCrudItems/Providers/OrgazanizationTreeItem.php index 00a18161f..19543b34f 100644 --- a/src/PartialCrudItems/Providers/OrgazanizationTreeItem.php +++ b/src/PartialCrudItems/Providers/OrgazanizationTreeItem.php @@ -15,6 +15,7 @@ class OrgazanizationTreeItem extends ProviderBase /** * set laravel admin grid's content */ + // @phpstan-ignore-next-line public function setGridContent(&$content) { if (!boolval(config('exment.show_organization_tree', false))) { diff --git a/src/PartialCrudItems/Providers/UserBelongOrganizationItem.php b/src/PartialCrudItems/Providers/UserBelongOrganizationItem.php index 971232f84..c584e5c50 100644 --- a/src/PartialCrudItems/Providers/UserBelongOrganizationItem.php +++ b/src/PartialCrudItems/Providers/UserBelongOrganizationItem.php @@ -16,12 +16,15 @@ */ class UserBelongOrganizationItem extends ProviderBase { + // @phpstan-ignore-next-line protected $custom_table; + // @phpstan-ignore-next-line protected $options; /** * set laravel admin form's option */ + // @phpstan-ignore-next-line public function setAdminFormOptions(&$form, $id = null) { $this->setOptions(); @@ -51,6 +54,7 @@ public function setAdminFormOptions(&$form, $id = null) /** * saved event */ + // @phpstan-ignore-next-line public function saved($form, $id) { $this->setOptions(); @@ -89,6 +93,7 @@ public function saved($form, $id) ]); } + // @phpstan-ignore-next-line protected function setOptions() { $custom_table = CustomTable::getEloquent(SystemTableName::ORGANIZATION); diff --git a/src/PartialCrudItems/Providers/UserOrgRoleGroupItem.php b/src/PartialCrudItems/Providers/UserOrgRoleGroupItem.php index e70ab345f..ba9f336e8 100644 --- a/src/PartialCrudItems/Providers/UserOrgRoleGroupItem.php +++ b/src/PartialCrudItems/Providers/UserOrgRoleGroupItem.php @@ -17,6 +17,7 @@ class UserOrgRoleGroupItem extends ProviderBase /** * set laravel admin form's option */ + // @phpstan-ignore-next-line public function setAdminFormOptions(&$form, $id = null) { if (!System::permission_available()) { @@ -46,6 +47,7 @@ public function setAdminFormOptions(&$form, $id = null) /** * saved event */ + // @phpstan-ignore-next-line public function saved($form, $id) { if (!System::permission_available()) { diff --git a/src/Providers/LoginUserProvider.php b/src/Providers/LoginUserProvider.php index 6ff0f12ba..6c0e50132 100644 --- a/src/Providers/LoginUserProvider.php +++ b/src/Providers/LoginUserProvider.php @@ -26,6 +26,7 @@ public function __construct($hasher, $model) public function retrieveById($identifier) { //return \Encore\Admin\Auth\Database\Administrator::find($identifier); + // @phpstan-ignore-next-line return LoginUser::find($identifier); } @@ -33,20 +34,22 @@ public function retrieveById($identifier) * retrieveByCredentials. * execute login using each service. * - * @param array $credentials + * @param array $credentials * @return ?Authenticatable */ public function retrieveByCredentials(array $credentials) { - return static::RetrieveByCredential($credentials); + /** @var Authenticatable|null $result */ + $result = static::RetrieveByCredential($credentials); + return $result; } /** * retrieveByCredentials. * execute login using each service. * - * @param array $credentials - * @return Authenticatable|null|array + * @param array $credentials + * @return Authenticatable|null|array */ public static function RetrieveByCredential(array $credentials) { @@ -66,6 +69,9 @@ public static function RetrieveByCredential(array $credentials) return $classname::retrieveByCredential($credentials); } + /** + * @param array $credentials + */ public function validateCredentials(Authenticatable $login_user, array $credentials) { return static::ValidateCredential($login_user, $credentials); @@ -74,7 +80,7 @@ public function validateCredentials(Authenticatable $login_user, array $credenti /** * findByCredentials. Only search from database. * - * @param array $credentials + * @param array $credentials * @return ?Authenticatable */ public static function findByCredential(array $credentials) @@ -121,12 +127,12 @@ public static function findByCredential(array $credentials) /** * @param Authenticatable $login_user - * @param array $credentials + * @param array $credentials * @return false */ public static function ValidateCredential(Authenticatable $login_user, array $credentials) { - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line if (is_null($login_user)) { return false; } @@ -139,6 +145,10 @@ public static function ValidateCredential(Authenticatable $login_user, array $cr return $classname::validateCredential($login_user, $credentials); } + /** + * @param array $credentials + * @return string|null + */ protected static function getClassName($credentials) { // has login type, set LoginType::PURE @@ -149,6 +159,10 @@ protected static function getClassName($credentials) return LoginType::getLoginServiceClassName($credentials['login_type']); } + /** + * @param array $credentials + * @return array + */ protected static function getCredentialDefault(array $credentials) { return array_merge( diff --git a/src/Providers/PluginPublicTrait.php b/src/Providers/PluginPublicTrait.php index d2150cad4..c74e1dacd 100644 --- a/src/Providers/PluginPublicTrait.php +++ b/src/Providers/PluginPublicTrait.php @@ -20,11 +20,13 @@ trait PluginPublicTrait */ protected function pluginScriptStyleRoute(Plugin $plugin, string $prefix, string $middleware) { + /** @phpstan-ignore-next-line */ if ($this->app->routesAreCached()) { return; } Route::group([ + /** @phpstan-ignore-next-line */ 'prefix' => url_join($prefix, $plugin->getRouteUri()), 'namespace' => 'Exceedone\Exment\Services\Plugin', 'middleware' => ['adminweb', $middleware], diff --git a/src/Providers/PluginServiceProvider.php b/src/Providers/PluginServiceProvider.php index 9d441b8f6..33afa8eb0 100644 --- a/src/Providers/PluginServiceProvider.php +++ b/src/Providers/PluginServiceProvider.php @@ -45,7 +45,11 @@ public function map() // loop foreach ($pluginPublics as $pluginScriptStyle) { - $this->pluginScriptStyleRoute($pluginScriptStyle->_plugin(), config('admin.route.prefix'), 'admin_plugin_public'); + /** @var \Exceedone\Exment\Services\Plugin\PluginPublicBase $pluginScriptStyle */ + $plugin = $pluginScriptStyle->_plugin(); + /** @var string $prefix */ + $prefix = config('admin.route.prefix'); + $this->pluginScriptStyleRoute($plugin, $prefix, 'admin_plugin_public'); } } @@ -134,6 +138,8 @@ protected function pluginRoute($plugin_type, $pluginPage) return; } + /** @var array $routes */ + // @phpstan-ignore-next-line $routes = array_get($json, 'route', []); // if not has index endpoint, set. @@ -146,33 +152,38 @@ protected function pluginRoute($plugin_type, $pluginPage) } foreach ($routes as $route) { - $method = array_get($route, 'method'); - $methods = is_string($method) ? [$method] : $method; + /** @var mixed $methodValue */ + $methodValue = array_get($route, 'method'); + $methods = is_string($methodValue) ? [$methodValue] : $methodValue; $plugin_name = $isApi ? 'PluginApiController' : 'PluginPageController'; foreach ($methods as $method) { - if ($method === "") { - $method = 'get'; - } - $method = strtolower($method); + /** @var string $methodStr */ + $methodStr = ($method === "") ? 'get' : $method; + $methodStr = strtolower($methodStr); // call method in these http method - if (in_array($method, ['get', 'post', 'put', 'patch', 'delete'])) { + if (in_array($methodStr, ['get', 'post', 'put', 'patch', 'delete'])) { + /** @var string $func */ $func = array_get($route, 'function'); - $router = Route::{$method}(array_get($route, 'uri'), $plugin_name . '@'. $func); + /** @var string $uri */ + $uri = array_get($route, 'uri'); + $router = Route::{$methodStr}($uri, $plugin_name . '@'. $func); $router->middleware(ApiScope::getScopeString($isApi, ApiScope::PLUGIN)); - $router->name("exment.plugins.{$plugin->id}.{$method}.{$func}"); + $router->name("exment.plugins.{$plugin->id}.{$methodStr}.{$func}"); } } } }); } - $this->pluginScriptStyleRoute($plugin, config('admin.route.prefix'), 'admin_plugin_public'); + /** @var string $adminPrefix */ + $adminPrefix = config('admin.route.prefix'); + $this->pluginScriptStyleRoute($plugin, $adminPrefix, 'admin_plugin_public'); } /** * Check route has index. * - * @param array $routes + * @param array $routes * @return boolean */ protected function hasPluginRouteIndex($routes) @@ -183,20 +194,21 @@ protected function hasPluginRouteIndex($routes) foreach ($routes as $route) { // if uri is not empty, continue. + /** @var array $route */ if (array_get($route, 'uri') != '') { continue; } - $method = array_get($route, 'method'); - $methods = is_string($method) ? [$method] : $method; + /** @var mixed $methodValue */ + $methodValue = array_get($route, 'method'); + $methods = is_string($methodValue) ? [$methodValue] : $methodValue; foreach ($methods as $method) { - if ($method === "") { - $method = 'get'; - } - $method = strtolower($method); + /** @var string $methodStr */ + $methodStr = ($method === "") ? 'get' : $method; + $methodStr = strtolower($methodStr); // if not get, continue. - if ($method != 'get') { + if ($methodStr != 'get') { continue; } return true; diff --git a/src/Providers/PublicFormUserProvider.php b/src/Providers/PublicFormUserProvider.php index e1287244e..9ac261303 100644 --- a/src/Providers/PublicFormUserProvider.php +++ b/src/Providers/PublicFormUserProvider.php @@ -19,6 +19,7 @@ class PublicFormUserProvider extends \Illuminate\Auth\EloquentUserProvider */ public function retrieveById($identifier) { + return null; } /** @@ -30,6 +31,7 @@ public function retrieveById($identifier) */ public function retrieveByToken($identifier, $token) { + return null; } /** @@ -46,11 +48,12 @@ public function updateRememberToken(Authenticatable $user, $token) /** * Retrieve a user by the given credentials. * - * @param array $credentials + * @param array $credentials * @return \Illuminate\Contracts\Auth\Authenticatable|null */ public function retrieveByCredentials(array $credentials) { + /** @var string|null $uuid */ $uuid = array_get($credentials, 'uuid'); $public_form = PublicForm::getPublicFormByUuid($uuid); if (!$public_form) { @@ -63,10 +66,11 @@ public function retrieveByCredentials(array $credentials) * Validate a user against the given credentials. * * @param Authenticatable $user - * @param array $credentials - * @return void|bool + * @param array $credentials + * @return bool */ public function validateCredentials(Authenticatable $user, array $credentials) { + return true; } } diff --git a/src/Providers/RouteOAuthServiceProvider.php b/src/Providers/RouteOAuthServiceProvider.php index 025af37cf..fa2ac2744 100644 --- a/src/Providers/RouteOAuthServiceProvider.php +++ b/src/Providers/RouteOAuthServiceProvider.php @@ -144,6 +144,9 @@ protected function forPersonalAccessTokens() }); } + /** + * @return array + */ protected function getOauthDefaultOptions() { return [ @@ -152,6 +155,9 @@ protected function getOauthDefaultOptions() 'middleware' => 'adminapi' ]; } + /** + * @return array + */ protected function getOauthAnonymousOptions() { return [ @@ -160,6 +166,9 @@ protected function getOauthAnonymousOptions() 'middleware' => ['adminapi_anonymous'], ]; } + /** + * @return array + */ protected function getOauthWebOptions() { return [ @@ -174,37 +183,54 @@ public function boot() parent::boot(); if (canConnection() && hasTable(SystemTableName::SYSTEM) && System::api_available()) { - app(AuthorizationServer::class)->enableGrantType( + /** @var AuthorizationServer $authServer */ + $authServer = app(AuthorizationServer::class); + /** @var \DateInterval $tokenExpiry */ + $tokenExpiry = Passport::tokensExpireIn(); + + $authServer->enableGrantType( $this->makeApiKeyGrant(), - Passport::tokensExpireIn() + $tokenExpiry ); - app(AuthorizationServer::class)->enableGrantType( + $authServer->enableGrantType( $this->makePasswordGrant(), - Passport::tokensExpireIn() + $tokenExpiry ); } } + /** + * @return ApiKeyGrant + */ protected function makeApiKeyGrant() { - $grant = new ApiKeyGrant( - $this->app->make(RefreshTokenRepository::class) - ); + /** @var RefreshTokenRepository $refreshTokenRepository */ + $refreshTokenRepository = $this->app->make(RefreshTokenRepository::class); + $grant = new ApiKeyGrant($refreshTokenRepository); - $grant->setRefreshTokenTTL(Passport::refreshTokensExpireIn()); + /** @var \DateInterval $refreshTokenTTL */ + $refreshTokenTTL = Passport::refreshTokensExpireIn(); + $grant->setRefreshTokenTTL($refreshTokenTTL); return $grant; } + /** + * @return PasswordGrant + */ protected function makePasswordGrant() { - $grant = new PasswordGrant( - $this->app->make(Bridge\UserRepository::class), - $this->app->make(Bridge\RefreshTokenRepository::class) - ); + /** @var Bridge\UserRepository $userRepository */ + $userRepository = $this->app->make(Bridge\UserRepository::class); + /** @var Bridge\RefreshTokenRepository $refreshTokenRepository */ + $refreshTokenRepository = $this->app->make(Bridge\RefreshTokenRepository::class); + + $grant = new PasswordGrant($userRepository, $refreshTokenRepository); - $grant->setRefreshTokenTTL(Passport::refreshTokensExpireIn()); + /** @var \DateInterval $refreshTokenTTL */ + $refreshTokenTTL = Passport::refreshTokensExpireIn(); + $grant->setRefreshTokenTTL($refreshTokenTTL); return $grant; } diff --git a/src/Providers/RoutePublicFormServiceProvider.php b/src/Providers/RoutePublicFormServiceProvider.php index 8be330f41..4db92ef99 100644 --- a/src/Providers/RoutePublicFormServiceProvider.php +++ b/src/Providers/RoutePublicFormServiceProvider.php @@ -33,6 +33,9 @@ public function map() $this->mapExmentPublicFormWebRotes(); } + /** + * @return void + */ protected function mapExmentPublicFormWebRotes() { if (!canConnection() || !hasTable(SystemTableName::SYSTEM) || !System::publicform_available()) { @@ -64,6 +67,7 @@ protected function mapExmentPublicFormWebRotes() } foreach ($public_form->getCssJsPlugins() as $plugin) { + /** @var \Exceedone\Exment\Model\Plugin $plugin */ $this->pluginScriptStyleRoute($plugin, $public_form->getBasePath(), 'publicform_plugin_public'); } } diff --git a/src/Providers/RouteServiceProvider.php b/src/Providers/RouteServiceProvider.php index 282f87854..f243594a4 100644 --- a/src/Providers/RouteServiceProvider.php +++ b/src/Providers/RouteServiceProvider.php @@ -27,6 +27,7 @@ class RouteServiceProvider extends ServiceProvider public function boot(): void { + /** @var int $rate_limit */ $rate_limit = config('exment.api_max_rate_limit', 60); RateLimiter::for('api', function (Request $request) use ($rate_limit) { $login_user = \Exment::user()?? \Auth::guard(Define::AUTHENTICATE_KEY_API)->user(); @@ -49,6 +50,7 @@ public function map() /** * Web web routes + * @return void */ protected function mapExmentWebRotes() { @@ -279,6 +281,9 @@ protected function mapExmentWebRotes() } + /** + * @return void + */ protected function mapExmentAnonymousWebRotes() { Route::group([ @@ -327,6 +332,9 @@ protected function mapExmentAnonymousWebRotes() }); } + /** + * @return void + */ protected function mapExmentInstallWebRotes() { Route::group([ @@ -340,6 +348,9 @@ protected function mapExmentInstallWebRotes() }); } + /** + * @return void + */ protected function mapExmentApiRotes() { // define adminapi(for webapi), api(for web) @@ -474,6 +485,7 @@ protected function mapExmentApiRotes() /** * define api and anonynous routes + * @return void */ protected function mapExmentAnonymousApiRotes() { @@ -498,6 +510,11 @@ protected function mapExmentAnonymousApiRotes() /** * set table resource. * (We cannot create endpoint using resouce function if contains {tableKey}). + * @param \Illuminate\Routing\Router $router + * @param string $endpointName + * @param string $controllerName + * @param bool $isShow + * @return void */ protected function setTableResouce($router, $endpointName, $controllerName, $isShow = false) { @@ -513,6 +530,11 @@ protected function setTableResouce($router, $endpointName, $controllerName, $isS /** * set resource. + * @param \Illuminate\Routing\Router $router + * @param string $endpointName + * @param string $controllerName + * @param bool $isShow + * @return void */ protected function setResouce($router, $endpointName, $controllerName, $isShow = false) { diff --git a/src/Revisionable/FieldFormatter.php b/src/Revisionable/FieldFormatter.php index 5d8935c6d..7f6c270e9 100644 --- a/src/Revisionable/FieldFormatter.php +++ b/src/Revisionable/FieldFormatter.php @@ -29,6 +29,7 @@ class FieldFormatter * * @return string formatted value */ + // @phpstan-ignore-next-line public static function format($key, $value, $formats) { foreach ($formats as $pkey => $format) { @@ -58,6 +59,7 @@ public static function format($key, $value, $formats) * * @return string */ + // @phpstan-ignore-next-line public static function isEmpty($value, $options = array()) { $value_set = isset($value) && $value != ''; @@ -73,10 +75,11 @@ public static function isEmpty($value, $options = array()) * * @return string Formatted version of the boolean field */ + // @phpstan-ignore-next-line public static function boolean($value, $options = null) { if (!is_null($options)) { - /** @phpstan-ignore-next-line explode expects string, array given */ + // @phpstan-ignore-next-line $options = explode('|', $options); } diff --git a/src/Revisionable/Revision.php b/src/Revisionable/Revision.php index 86c51d462..c22d808a7 100644 --- a/src/Revisionable/Revision.php +++ b/src/Revisionable/Revision.php @@ -34,21 +34,25 @@ class Revision extends Eloquent /** * @var array */ + // @phpstan-ignore-next-line protected $revisionFormattedFields = array(); /** * @param array $attributes */ + // @phpstan-ignore-next-line public function __construct(array $attributes = array()) { parent::__construct($attributes); } + // @phpstan-ignore-next-line public function getUserAttribute() { return $this->getUser('create_user_id', true); } + // @phpstan-ignore-next-line public function getDeleteUserAttribute() { return $this->getUser('delete_user_id', false); @@ -60,6 +64,7 @@ public function getDeleteUserAttribute() * * @return \Illuminate\Database\Eloquent\Relations\MorphTo */ + // @phpstan-ignore-next-line public function revisionable() { return $this->morphTo(); @@ -97,6 +102,7 @@ private function formatFieldName($key) { $related_model = $this->revisionable_type; $related_model = new $related_model(); + // @phpstan-ignore-next-line $revisionFormattedFieldNames = $related_model->getRevisionFormattedFieldNames(); if (isset($revisionFormattedFieldNames[$key])) { @@ -160,6 +166,7 @@ private function getValue($which = 'new') if (!method_exists($main_model, $related_model)) { $related_model = camel_case($related_model); // for cases like published_status_id if (!method_exists($main_model, $related_model)) { + // @phpstan-ignore-next-line throw new \Exception('Relation ' . $related_model . ' does not exist for ' . $main_model); } } @@ -172,11 +179,13 @@ private function getValue($which = 'new') if (is_null($this->$which_value) || $this->$which_value == '') { $item = new $related_class(); + // @phpstan-ignore-next-line return $item->getRevisionNullString(); } if (!$item) { $item = new $related_class(); + // @phpstan-ignore-next-line return $this->format($this->key, $item->getRevisionUnknownString()); } @@ -185,9 +194,11 @@ private function getValue($which = 'new') // see if there's an available mutator $mutator = 'get' . studly_case($this->key) . 'Attribute'; if (method_exists($item, $mutator)) { + // @phpstan-ignore-next-line return $this->format($item->$mutator($this->key), $item->identifiableName()); } + // @phpstan-ignore-next-line return $this->format($this->key, $item->identifiableName()); } } @@ -304,6 +315,7 @@ public function format($key, $value) { $related_model = $this->revisionable_type; $related_model = new $related_model(); + // @phpstan-ignore-next-line $revisionFormattedFields = $related_model->getRevisionFormattedFields(); if (isset($revisionFormattedFields[$key])) { @@ -316,6 +328,7 @@ public function format($key, $value) /** * get user from id */ + // @phpstan-ignore-next-line protected function getUser(string $keyName, bool $emptyAsSystem) { $value = CustomTable::getEloquent(SystemTableName::USER)->getValueModel($this->{$keyName}); diff --git a/src/Revisionable/RevisionableTrait.php b/src/Revisionable/RevisionableTrait.php index 1417cfe25..4416a387f 100644 --- a/src/Revisionable/RevisionableTrait.php +++ b/src/Revisionable/RevisionableTrait.php @@ -22,11 +22,13 @@ trait RevisionableTrait /** * @var array */ + // @phpstan-ignore-next-line private $originalData = array(); /** * @var array */ + // @phpstan-ignore-next-line private $updatedData = array(); /** @@ -37,16 +39,19 @@ trait RevisionableTrait /** * @var array|null */ + // @phpstan-ignore-next-line private $dontKeep = array(); /** * @var array|null */ + // @phpstan-ignore-next-line private $doKeep = array(); /** * @var array|null */ + // @phpstan-ignore-next-line private $doKeepTrigger = array(); /** @@ -54,6 +59,7 @@ trait RevisionableTrait * * @var array */ + // @phpstan-ignore-next-line protected $dirtyData = array(); /** @@ -128,6 +134,7 @@ public static function classRevisionHistory($limit = 100, $order = 'desc') /** * Invoked before a model is saved. Return false to abort the operation. */ + // @phpstan-ignore-next-line public function preSave() { if (!isset($this->revisionEnabled) || $this->revisionEnabled) { @@ -235,6 +242,7 @@ public function postSave() /** * Called after record successfully created */ + // @phpstan-ignore-next-line public function postCreate() { // Check if we should store creations in our revision history @@ -270,6 +278,7 @@ public function postCreate() /** * If softdeletes are enabled, store the deleted time */ + // @phpstan-ignore-next-line public function postDelete() { if ((!isset($this->revisionEnabled) || $this->revisionEnabled) @@ -313,6 +322,7 @@ public function postDelete() /** * Force delete are enabled, store the deleted time */ + // @phpstan-ignore-next-line public function postForceDelete() { if ((!isset($this->revisionEnabled) || $this->revisionEnabled) @@ -330,6 +340,7 @@ public function postForceDelete() /** * If softdeletes are enabled, restore event */ + // @phpstan-ignore-next-line public function postRestore() { if ((!isset($this->revisionEnabled) || $this->revisionEnabled) @@ -370,6 +381,7 @@ public function postRestore() * Attempt to find the user id of the currently logged in user * Supports Cartalyst Sentry/Sentinel based authentication, as well as stock Auth **/ + // @phpstan-ignore-next-line public function getSystemUserId() { try { @@ -393,6 +405,7 @@ public function getSystemUserId() return null; } + // @phpstan-ignore-next-line protected function saveData($revisions) { foreach ($revisions as $revision) { @@ -409,6 +422,7 @@ protected function saveData($revisions) } } + // @phpstan-ignore-next-line protected function forceDeleteData($revisions) { foreach ($revisions as $revision) { @@ -424,6 +438,7 @@ protected function forceDeleteData($revisions) * * @return array fields with new data, that should be recorded */ + // @phpstan-ignore-next-line private function changedRevisionableFields() { $changes_to_record = array(); diff --git a/src/Services/Auth2factor/Auth2factorService.php b/src/Services/Auth2factor/Auth2factorService.php index 266401eca..fa1aa2d5b 100644 --- a/src/Services/Auth2factor/Auth2factorService.php +++ b/src/Services/Auth2factor/Auth2factorService.php @@ -17,6 +17,7 @@ class Auth2factorService { protected const VERIFY_TYPE_2FACTOR = '2factor_'; + // @phpstan-ignore-next-line protected static $providers = [ ]; @@ -33,6 +34,7 @@ public static function providers($abstract, $class) static::$providers[$abstract] = $class; } + // @phpstan-ignore-next-line public static function getProvider() { $provider = \Exment::user()->getSettingValue( @@ -94,8 +96,10 @@ public static function verifyCode($verify_type, $verify_code, $matchDelete = fal * @param array $mail_prms * @return bool */ + // @phpstan-ignore-next-line public static function addAndSendVerify($verify_type, $verify_code, $valid_period_datetime, $mail_template, $mail_prms = []) { + // @phpstan-ignore-next-line static::addVerify($verify_type, $verify_code, $valid_period_datetime); // send mail @@ -145,6 +149,7 @@ protected static function addVerify($verify_type, $verify_code, $valid_period_da * @param array $mail_prms * @return MailSender */ + // @phpstan-ignore-next-line protected static function sendVerify($mail_template, $mail_prms = []): MailSender { $loginuser = \Admin::user(); @@ -159,6 +164,7 @@ protected static function sendVerify($mail_template, $mail_prms = []): MailSende } + // @phpstan-ignore-next-line public static function deleteCode($verify_type, $verify_code) { $loginuser = \Admin::user(); diff --git a/src/Services/Auth2factor/Providers/Email.php b/src/Services/Auth2factor/Providers/Email.php index d7c785b43..98d6ee382 100644 --- a/src/Services/Auth2factor/Providers/Email.php +++ b/src/Services/Auth2factor/Providers/Email.php @@ -74,6 +74,7 @@ public function verify() return redirect(admin_url('')); } + // @phpstan-ignore-next-line public function insertVerify() { $loginuser = \Admin::user(); diff --git a/src/Services/Auth2factor/Providers/Google.php b/src/Services/Auth2factor/Providers/Google.php index 4b8ce660e..9e1e3124f 100644 --- a/src/Services/Auth2factor/Providers/Google.php +++ b/src/Services/Auth2factor/Providers/Google.php @@ -187,10 +187,12 @@ public function verify() return redirect(admin_url('')); } + // @phpstan-ignore-next-line public function insertVerify() { } + // @phpstan-ignore-next-line protected function getG2fa() { $g2fa = new Google2FA(); diff --git a/src/Services/AuthUserOrgHelper.php b/src/Services/AuthUserOrgHelper.php index 2b4de1b0c..90acbdd22 100644 --- a/src/Services/AuthUserOrgHelper.php +++ b/src/Services/AuthUserOrgHelper.php @@ -26,8 +26,14 @@ class AuthUserOrgHelper /** * get organiztions who has roles. * this function is called from custom value role + * + * @param mixed $target_table + * @param mixed $tablePermission + * @param mixed $builder + * @return \Illuminate\Database\Eloquent\Builder|null */ // getRoleUserOrgQuery + // @phpstan-ignore-next-line public static function getRoleOrganizationQueryTable($target_table, $tablePermission = null, $builder = null) { if (!System::organization_available()) { @@ -44,6 +50,7 @@ public static function getRoleOrganizationQueryTable($target_table, $tablePermis } $key = sprintf(Define::SYSTEM_KEY_SESSION_TABLE_ACCRSSIBLE_ORGS, $target_table->id); + // @phpstan-ignore-next-line return static::_getRoleUserOrOrgQueryTable(SystemTableName::ORGANIZATION, $key, $target_table, $tablePermission, $builder); } @@ -51,8 +58,14 @@ public static function getRoleOrganizationQueryTable($target_table, $tablePermis /** * get users who has roles for target table. * this function is called from custom value display's role + * + * @param mixed $target_table + * @param mixed $tablePermission + * @param mixed $builder + * @return \Illuminate\Database\Eloquent\Builder|null */ // getRoleUserOrgQuery + // @phpstan-ignore-next-line public static function getRoleUserQueryTable($target_table, $tablePermission = null, $builder = null) { $target_table = CustomTable::getEloquent($target_table); @@ -61,6 +74,7 @@ public static function getRoleUserQueryTable($target_table, $tablePermission = n } $key = sprintf(Define::SYSTEM_KEY_SESSION_TABLE_ACCRSSIBLE_USERS, $target_table->id); + // @phpstan-ignore-next-line return static::_getRoleUserOrOrgQueryTable(SystemTableName::USER, $key, $target_table, $tablePermission, $builder); } @@ -69,8 +83,14 @@ public static function getRoleUserQueryTable($target_table, $tablePermission = n * get users who has roles for target table. * and get users joined parent or children organizations * this function is called from custom value display's role + * + * @param mixed $target_table + * @param mixed $tablePermission + * @param mixed $builder + * @return \Illuminate\Database\Eloquent\Builder|null */ // getRoleUserOrgQuery + // @phpstan-ignore-next-line public static function getRoleUserAndOrgBelongsUserQueryTable($target_table, $tablePermission = null, $builder = null) { if (is_null($target_table)) { @@ -79,6 +99,7 @@ public static function getRoleUserAndOrgBelongsUserQueryTable($target_table, $ta $target_table = CustomTable::getEloquent($target_table); $key = sprintf(Define::SYSTEM_KEY_SESSION_TABLE_ACCRSSIBLE_USERS_ORGS, $target_table->id); + // @phpstan-ignore-next-line return static::_getRoleUserOrOrgQueryTable(SystemTableName::USER, $key, $target_table, $tablePermission, $builder, function ($target_ids, $target_table) use ($tablePermission) { // joined organization belongs user ---------------------------------------------------- if (!System::organization_available()) { @@ -91,8 +112,10 @@ public static function getRoleUserAndOrgBelongsUserQueryTable($target_table, $ta foreach ($organizations as $organization) { // get JoinedOrgFilterType. this method is for org_joined_type_role_group. get users for has role groups. $enum = JoinedOrgFilterType::getEnum(System::org_joined_type_role_group(), JoinedOrgFilterType::ONLY_JOIN); + // @phpstan-ignore-next-line $relatedOrgs = CustomTable::getEloquent(SystemTableName::ORGANIZATION)->getValueModel()->with('users')->find($organization->getOrganizationIdsForQuery($enum)); + // @phpstan-ignore-next-line foreach ($relatedOrgs as $related_organization) { foreach ($related_organization->users as $user) { $target_ids[] = $user->getUserId(); @@ -104,6 +127,16 @@ public static function getRoleUserAndOrgBelongsUserQueryTable($target_table, $ta }); } + /** + * @param mixed $table_name + * @param string $key + * @param mixed $target_table + * @param mixed $tablePermission + * @param mixed $builder + * @param \Closure|null $target_ids_callback + * @return \Illuminate\Database\Eloquent\Builder|array + */ + // @phpstan-ignore-next-line protected static function _getRoleUserOrOrgQueryTable($table_name, $key, $target_table, $tablePermission = null, $builder = null, ?\Closure $target_ids_callback = null) { if (is_null($target_table)) { @@ -119,9 +152,10 @@ protected static function _getRoleUserOrOrgQueryTable($table_name, $key, $target $all = true; } else { // if set $tablePermission, always call - /** @phpstan-ignore-next-line Call to function is_null() with mixed will always evaluate to false. */ + // @phpstan-ignore-next-line if (isset($tablePermission) || is_null($target_ids = System::requestSession($key))) { // get user ids + // @phpstan-ignore-next-line $target_ids = static::getRoleUserOrgId($target_table ?? [], $table_name, $tablePermission); if ($target_ids_callback) { @@ -154,6 +188,7 @@ protected static function _getRoleUserOrOrgQueryTable($table_name, $key, $target * @param string|null|array $tablePermission * @return array */ + // @phpstan-ignore-next-line public static function getRoleUserAndOrganizations($custom_value, $tablePermission = null, ?CustomTable $custom_table = null) { if (!$custom_table) { @@ -172,7 +207,7 @@ public static function getRoleUserAndOrganizations($custom_value, $tablePermissi // check request session $key = sprintf(Define::SYSTEM_KEY_SESSION_VALUE_ACCRSSIBLE_USERS, $custom_table->id, $custom_value->id ?? null); // if set $tablePermission, always call - /** @phpstan-ignore-next-line Call to function is_null() with mixed will always evaluate to false. */ + // @phpstan-ignore-next-line if (isset($tablePermission) || is_null($results = System::requestSession($key))) { // get ids contains value_authoritable table $ids[SystemTableName::USER] = $custom_value ? $custom_value->value_authoritable_users()->pluck('authoritable_target_id')->toArray() : []; @@ -217,6 +252,7 @@ public static function getRoleUserAndOrganizations($custom_value, $tablePermissi * @param string $related_type "user" or "organization" * @param string|array|null $tablePermission target permission */ + // @phpstan-ignore-next-line protected static function getRoleUserOrgId($target_table, $related_type, $tablePermission = null) { $target_table = CustomTable::getEloquent($target_table); @@ -291,6 +327,7 @@ protected static function getRoleUserOrgId($target_table, $related_type, $tableP * * @return array */ + // @phpstan-ignore-next-line public static function getOrganizationIdsForQuery($filterType = JoinedOrgFilterType::ALL, $targetUserId = null) { // if system doesn't use organization, return empty array. @@ -318,6 +355,7 @@ public static function getOrganizationIdsForQuery($filterType = JoinedOrgFilterT * * @return array */ + // @phpstan-ignore-next-line protected static function getOrganizationTreeArray(): array { return System::requestSession(Define::SYSTEM_KEY_SESSION_ORGANIZATION_TREE, function () { @@ -350,6 +388,7 @@ protected static function getOrganizationTreeArray(): array }); } + // @phpstan-ignore-next-line protected static function parents(&$org, $orgs, $target, $indexName) { if (!isset($target[$indexName])) { @@ -373,8 +412,10 @@ protected static function parents(&$org, $orgs, $target, $indexName) static::parents($org, $orgs, $newTarget, $indexName); } + // @phpstan-ignore-next-line protected static function children(&$org, $orgs, $target, $indexName) { + // @phpstan-ignore-next-line $children = collect($orgs)->filter(function ($o) use ($target, $indexName) { if (!isset($o[$indexName])) { return; @@ -393,6 +434,7 @@ protected static function children(&$org, $orgs, $target, $indexName) } } + // @phpstan-ignore-next-line protected static function setJoinedOrganization(&$results, $org, $filterType, $targetUserId) { // set $org id only $targetUserId @@ -424,6 +466,7 @@ protected static function setJoinedOrganization(&$results, $org, $filterType, $t * @param string $db_table_name * @return void */ + // @phpstan-ignore-next-line public static function filterUserOnlyJoin($builder, $user, $db_table_name) { $setting = System::filter_multi_user(); @@ -440,6 +483,7 @@ public static function filterUserOnlyJoin($builder, $user, $db_table_name) // First, get users org joined $db_table_name_pivot = CustomRelation::getRelationNameByTables(SystemTableName::ORGANIZATION, SystemTableName::USER); + // @phpstan-ignore-next-line $target_users = \DB::table($db_table_name_pivot)->whereIn('parent_id', $user->getOrganizationIdsForQuery($joinedOrgFilterType)) ->pluck('child_id'); @@ -457,6 +501,7 @@ public static function filterUserOnlyJoin($builder, $user, $db_table_name) * @param string $db_table_name * @return void */ + // @phpstan-ignore-next-line public static function filterOrganizationOnlyJoin($builder, $user, $db_table_name) { $setting = System::filter_multi_user(); @@ -472,6 +517,7 @@ public static function filterOrganizationOnlyJoin($builder, $user, $db_table_nam $joinedOrgFilterType = JoinedOrgFilterType::getEnum($setting); // get only login user's organization + // @phpstan-ignore-next-line $builder->whereIn("$db_table_name.id", $user->getOrganizationIdsForQuery($joinedOrgFilterType)); } } diff --git a/src/Services/BackupRestore/Backup.php b/src/Services/BackupRestore/Backup.php index bcf02b9db..aa34c3772 100644 --- a/src/Services/BackupRestore/Backup.php +++ b/src/Services/BackupRestore/Backup.php @@ -36,6 +36,7 @@ public function check() * @return int * @throws \Exceedone\Exment\Exceptions\BackupRestoreCheckException */ + // @phpstan-ignore-next-line public function execute($target = null, bool $schedule = false) { try { @@ -46,7 +47,7 @@ public function execute($target = null, bool $schedule = false) if (is_string($target)) { $target = collect(explode(",", $target))->map(function ($t) { - /** @phpstan-ignore-next-line Expression on left side of ?? is not nullable. */ + // @phpstan-ignore-next-line return new BackupTarget($t) ?? null; })->filter()->toArray(); } @@ -84,6 +85,7 @@ public function execute($target = null, bool $schedule = false) * * @return bool true:success/false:fail */ + // @phpstan-ignore-next-line protected function copyFiles($target) { // get directory paths @@ -155,6 +157,7 @@ protected function copyFiles($target) * archive whole folder(sql and tsv only) to zip. * */ + // @phpstan-ignore-next-line protected function createZip() { // open new zip file @@ -225,6 +228,7 @@ protected function removeOldBackups() * get matched env data * */ + // @phpstan-ignore-next-line protected function getMatchedEnv() { // get env file diff --git a/src/Services/BackupRestore/BackupRestoreTrait.php b/src/Services/BackupRestore/BackupRestoreTrait.php index 5854ebaf4..597e471d2 100644 --- a/src/Services/BackupRestore/BackupRestoreTrait.php +++ b/src/Services/BackupRestore/BackupRestoreTrait.php @@ -6,18 +6,22 @@ trait BackupRestoreTrait { + // @phpstan-ignore-next-line protected $diskService; + // @phpstan-ignore-next-line public function disk() { return $this->diskService->diskItem()->disk(); } + // @phpstan-ignore-next-line public function tmpDisk() { return $this->diskService->tmpDiskItem()->disk(); } + // @phpstan-ignore-next-line public function initBackupRestore($basename = null) { $this->diskService = new BackupDiskService($basename); @@ -25,6 +29,7 @@ public function initBackupRestore($basename = null) return $this; } + // @phpstan-ignore-next-line public function diskService() { return $this->diskService; diff --git a/src/Services/BackupRestore/Restore.php b/src/Services/BackupRestore/Restore.php index 528bdbee4..7283598bf 100644 --- a/src/Services/BackupRestore/Restore.php +++ b/src/Services/BackupRestore/Restore.php @@ -27,11 +27,13 @@ public function __construct() * * @return array */ + // @phpstan-ignore-next-line public function list(): array { $disk = $this->disk(); // get all archive files + // @phpstan-ignore-next-line $files = array_filter($disk->files('list'), function ($file) { return preg_match('/list\/.+\.zip$/i', $file); }); @@ -57,6 +59,7 @@ public function list(): array * @return int * @throws \Exception */ + // @phpstan-ignore-next-line public function execute($file = null, ?bool $tmp = null) { try { @@ -100,6 +103,7 @@ public function execute($file = null, ?bool $tmp = null) * insert table data from backup tsv files. * */ + // @phpstan-ignore-next-line protected function importTsv() { \ExmentDB::importTsv($this->diskService->tmpDiskItem()->dirFullPath()); @@ -173,6 +177,7 @@ protected function copyFiles() * update env data * */ + // @phpstan-ignore-next-line protected function updateEnv() { // get env file @@ -208,6 +213,7 @@ protected function updateEnv() /** * unzip backup file to temporary folder path. */ + // @phpstan-ignore-next-line protected function unzipFile($file, ?bool $tmp = null) { // get file @@ -239,6 +245,7 @@ protected function unzipFile($file, ?bool $tmp = null) * restore backup table definition and table data. * */ + // @phpstan-ignore-next-line protected function restoreDatabase() { \ExmentDB::restoreDatabase($this->diskService->tmpDiskItem()->dirFullPath()); diff --git a/src/Services/Calc/CalcService.php b/src/Services/Calc/CalcService.php index e23764247..037aed899 100644 --- a/src/Services/Calc/CalcService.php +++ b/src/Services/Calc/CalcService.php @@ -47,12 +47,13 @@ public static function getCalcDisplayText($value, CustomTable $custom_table) * 'child_relation_name': if relation is 1:n, set child relation name. * 'pivot_column': if select_table, set pivot column's name. */ + // @phpstan-ignore-next-line public static function getCalcFormArray(CustomTable $custom_table, CustomFormBlock $custom_form_block) { $calc_formulas = []; $calc_counts = []; - /** @phpstan-ignore-next-line $relationInfo Ternary operator condition is always true. */ + // @phpstan-ignore-next-line $relationInfo = $custom_form_block ? $custom_form_block->getRelationInfo($custom_table) : null; foreach ($custom_form_block->custom_form_columns as $form_column) { if ($form_column->form_column_type != FormColumnType::COLUMN) { @@ -153,6 +154,7 @@ public static function getCalcFormArray(CustomTable $custom_table, CustomFormBlo * 'target_relation_name': If type is summary, box and triggered box is defferent, so set trigger relation name. * ] */ + // @phpstan-ignore-next-line protected static function getCalcParamsFromString($value, CustomTable $custom_table, ?CustomFormBlock $custom_form_block = null): array { if (is_nullorempty($value)) { @@ -216,6 +218,7 @@ protected static function getCalcParamsFromString($value, CustomTable $custom_ta * 'type': calc type * ] */ + // @phpstan-ignore-next-line public static function getCalcCustomColumnOptions($id, $custom_table): \Illuminate\Support\Collection { $options = collect(); @@ -234,6 +237,7 @@ public static function getCalcCustomColumnOptions($id, $custom_table): \Illumina * * @return \Illuminate\Support\Collection|\Tightenco\Collect\Support\Collection */ + // @phpstan-ignore-next-line public static function getSymbols() { return collect(exmtrans('custom_column.symbols'))->map(function ($symbol, $key) { diff --git a/src/Services/Calc/Items/CalcInterface.php b/src/Services/Calc/Items/CalcInterface.php index 54a7a0129..85c37fd22 100644 --- a/src/Services/Calc/Items/CalcInterface.php +++ b/src/Services/Calc/Items/CalcInterface.php @@ -7,9 +7,14 @@ */ interface CalcInterface { + // @phpstan-ignore-next-line public function type(); + // @phpstan-ignore-next-line public function text(); + // @phpstan-ignore-next-line public function val(); + // @phpstan-ignore-next-line public function displayText(); + // @phpstan-ignore-next-line public static function setCalcCustomColumnOptions($options, $id, $custom_table); } diff --git a/src/Services/Calc/Items/Count.php b/src/Services/Calc/Items/Count.php index 5b9313527..bc3436a24 100644 --- a/src/Services/Calc/Items/Count.php +++ b/src/Services/Calc/Items/Count.php @@ -21,26 +21,31 @@ public function __construct(?CustomTable $custom_table, ?CustomTable $child_cust $this->child_custom_table = $child_custom_table; } + // @phpstan-ignore-next-line public function type() { return 'count'; } + // @phpstan-ignore-next-line public function text() { return exmtrans('custom_column.calc_text.child_count', array_get($this->child_custom_table, 'table_view_name')); } + // @phpstan-ignore-next-line public function val() { return '${count:' . array_get($this->child_custom_table, 'table_name') .'}'; } + // @phpstan-ignore-next-line public static function getItem(?CustomTable $custom_table, ?CustomTable $child_custom_table) { return new self($custom_table, $child_custom_table); } + // @phpstan-ignore-next-line public static function getItemBySplits($splits, ?CustomTable $custom_table) { $child_table = CustomTable::getEloquent($splits[0]); @@ -52,6 +57,7 @@ public static function getItemBySplits($splits, ?CustomTable $custom_table) * * @return array */ + // @phpstan-ignore-next-line public function getTriggeredKeys(): array { return [ @@ -60,6 +66,7 @@ public function getTriggeredKeys(): array ]; } + // @phpstan-ignore-next-line public function toArray() { $child_relation_name = CustomRelation::getRelationNameByTables($this->custom_table, $this->child_custom_table); @@ -70,6 +77,7 @@ public function toArray() ], parent::toArray()); } + // @phpstan-ignore-next-line public static function setCalcCustomColumnOptions($options, $id, $custom_table) { // add child columns diff --git a/src/Services/Calc/Items/Dynamic.php b/src/Services/Calc/Items/Dynamic.php index 3db03b3ae..b8176f01a 100644 --- a/src/Services/Calc/Items/Dynamic.php +++ b/src/Services/Calc/Items/Dynamic.php @@ -17,26 +17,31 @@ public function __construct(?CustomColumn $custom_column, ?CustomTable $custom_t parent::__construct($custom_column, $custom_table); } + // @phpstan-ignore-next-line public function type() { return 'dynamic'; } + // @phpstan-ignore-next-line public function text() { return array_get($this->custom_column, 'column_view_name'); } + // @phpstan-ignore-next-line public function val() { return '${value:' . array_get($this->custom_column, 'column_name') . '}'; } + // @phpstan-ignore-next-line public static function getItem(?CustomColumn $custom_column, ?CustomTable $custom_table) { return new self($custom_column, $custom_table); } + // @phpstan-ignore-next-line public static function getItemBySplits($splits, ?CustomTable $custom_table) { $custom_column = CustomColumn::getEloquent($splits[0], $custom_table); @@ -49,6 +54,7 @@ public static function getItemBySplits($splits, ?CustomTable $custom_table) * * @return array */ + // @phpstan-ignore-next-line public function getTriggeredKeys(): array { $trigger_block = (!$this->custom_form_block || $this->custom_form_block->form_block_type == FormBlockType::DEFAULT) ? 'default' : $this->getRelationName(); @@ -59,6 +65,7 @@ public function getTriggeredKeys(): array } + // @phpstan-ignore-next-line public static function setCalcCustomColumnOptions($options, $id, $custom_table) { // get calc options diff --git a/src/Services/Calc/Items/ItemBase.php b/src/Services/Calc/Items/ItemBase.php index e7690c652..bae530129 100644 --- a/src/Services/Calc/Items/ItemBase.php +++ b/src/Services/Calc/Items/ItemBase.php @@ -39,6 +39,7 @@ public function __construct(?CustomColumn $custom_column, ?CustomTable $custom_t $this->custom_table = $custom_table; } + // @phpstan-ignore-next-line public function displayText() { $text = $this->text(); @@ -50,6 +51,7 @@ public function displayText() * * @return array */ + // @phpstan-ignore-next-line public function getTriggeredKeys(): array { return [ @@ -58,6 +60,7 @@ public function getTriggeredKeys(): array ]; } + // @phpstan-ignore-next-line public function toArray() { return array_merge([ @@ -70,17 +73,20 @@ public function toArray() } + // @phpstan-ignore-next-line public function setCustomFormBlock($custom_form_block) { $this->custom_form_block = $custom_form_block; return $this; } + // @phpstan-ignore-next-line public function getCustomFormBlock() { return $this->custom_form_block; } + // @phpstan-ignore-next-line protected function getRelationName() { return $this->custom_form_block ? $this->custom_form_block->getRelationInfo()[1] : null; diff --git a/src/Services/Calc/Items/ParentItem.php b/src/Services/Calc/Items/ParentItem.php index b7e75ff95..3204df499 100644 --- a/src/Services/Calc/Items/ParentItem.php +++ b/src/Services/Calc/Items/ParentItem.php @@ -25,26 +25,31 @@ public function __construct(?CustomColumn $custom_column, ?CustomTable $custom_t $this->parent_table = $parent_table; } + // @phpstan-ignore-next-line public function type() { return 'parent'; } + // @phpstan-ignore-next-line public function text() { return exmtrans('custom_column.calc_text.parent', array_get($this->custom_column, 'column_view_name')); } + // @phpstan-ignore-next-line public function val() { return '${parent:' . array_get($this->custom_column, 'column_name') . '}'; } + // @phpstan-ignore-next-line public static function getItem(?CustomColumn $custom_column, ?CustomTable $custom_table, ?CustomTable $parent_table) { return new self($custom_column, $custom_table, $parent_table); } + // @phpstan-ignore-next-line public static function getItemBySplits($splits, ?CustomTable $custom_table) { $relation = CustomRelation::getRelationByChild($custom_table, RelationType::ONE_TO_MANY); @@ -59,6 +64,7 @@ public static function getItemBySplits($splits, ?CustomTable $custom_table) } + // @phpstan-ignore-next-line public function toArray() { $array = []; @@ -73,6 +79,7 @@ public function toArray() * * @return array */ + // @phpstan-ignore-next-line public function getTriggeredKeys(): array { if ($this->custom_form_block) { @@ -108,6 +115,7 @@ public function getTriggeredKeys(): array ]; } + // @phpstan-ignore-next-line public static function setCalcCustomColumnOptions($options, $id, $custom_table) { // get parent table only 1:n @@ -130,6 +138,7 @@ public static function setCalcCustomColumnOptions($options, $id, $custom_table) }); } + // @phpstan-ignore-next-line protected function getRelationName() { return CustomRelation::getRelationNameByTables($this->parent_table, $this->custom_table); diff --git a/src/Services/Calc/Items/SelectTable.php b/src/Services/Calc/Items/SelectTable.php index b682eff13..47d65760d 100644 --- a/src/Services/Calc/Items/SelectTable.php +++ b/src/Services/Calc/Items/SelectTable.php @@ -26,21 +26,25 @@ public function __construct(?CustomColumn $custom_column, ?CustomTable $custom_t $this->select_pivot_column = $select_pivot_column; } + // @phpstan-ignore-next-line public function type() { return 'select_table'; } + // @phpstan-ignore-next-line public function text() { return exmtrans('custom_column.calc_text.select_table', array_get($this->select_pivot_column, 'column_view_name'), array_get($this->custom_column, 'column_view_name')); } + // @phpstan-ignore-next-line public function val() { return '${select_table:' . array_get($this->select_pivot_column, 'column_name') . '.' . array_get($this->custom_column, 'column_name') . '}'; } + // @phpstan-ignore-next-line public function toArray() { return array_merge([ @@ -53,6 +57,7 @@ public function toArray() * * @return array */ + // @phpstan-ignore-next-line public function getTriggeredKeys(): array { $trigger_block = (!$this->custom_form_block || $this->custom_form_block->form_block_type == FormBlockType::DEFAULT) ? 'default' : $this->getRelationName(); @@ -63,12 +68,14 @@ public function getTriggeredKeys(): array } + // @phpstan-ignore-next-line public static function getItem($custom_column, $custom_table, ?CustomColumn $select_pivot_column) { return new self($custom_column, $custom_table, $select_pivot_column); } + // @phpstan-ignore-next-line public static function getItemBySplits($splits, ?CustomTable $custom_table) { if (count($splits) < 2) { @@ -80,6 +87,7 @@ public static function getItemBySplits($splits, ?CustomTable $custom_table) } + // @phpstan-ignore-next-line public static function setCalcCustomColumnOptions($options, $id, $custom_table) { $custom_table->custom_columns_cache->each(function ($custom_column) use ($id, $custom_table, $options) { diff --git a/src/Services/Calc/Items/Sum.php b/src/Services/Calc/Items/Sum.php index 424d8bb24..daa559bd4 100644 --- a/src/Services/Calc/Items/Sum.php +++ b/src/Services/Calc/Items/Sum.php @@ -23,26 +23,31 @@ public function __construct(?CustomColumn $custom_column, ?CustomTable $custom_t $this->child_custom_table = $child_custom_table; } + // @phpstan-ignore-next-line public function type() { return 'summary'; } + // @phpstan-ignore-next-line public function text() { return exmtrans('custom_column.calc_text.child_sum', array_get($this->child_custom_table, 'table_view_name'), array_get($this->custom_column, 'column_view_name')); } + // @phpstan-ignore-next-line public function val() { return '${sum:' . array_get($this->child_custom_table, 'table_name') . '.' . array_get($this->custom_column, 'column_name') . '}'; } + // @phpstan-ignore-next-line public static function getItem(?CustomColumn $custom_column, ?CustomTable $custom_table, ?CustomTable $child_custom_table) { return new self($custom_column, $custom_table, $child_custom_table); } + // @phpstan-ignore-next-line public static function getItemBySplits($splits, ?CustomTable $custom_table) { if (count($splits) < 2) { @@ -59,6 +64,7 @@ public static function getItemBySplits($splits, ?CustomTable $custom_table) * * @return array */ + // @phpstan-ignore-next-line public function getTriggeredKeys(): array { return [ @@ -68,6 +74,7 @@ public function getTriggeredKeys(): array } + // @phpstan-ignore-next-line public function toArray() { return array_merge([ @@ -76,6 +83,7 @@ public function toArray() ], parent::toArray()); } + // @phpstan-ignore-next-line public static function setCalcCustomColumnOptions($options, $id, $custom_table) { // add child columns @@ -95,6 +103,7 @@ public static function setCalcCustomColumnOptions($options, $id, $custom_table) } } + // @phpstan-ignore-next-line protected function getRelationName() { return CustomRelation::getRelationNameByTables($this->custom_table, $this->child_custom_table); diff --git a/src/Services/ClassBuilder.php b/src/Services/ClassBuilder.php index 5f664462a..5a41143db 100644 --- a/src/Services/ClassBuilder.php +++ b/src/Services/ClassBuilder.php @@ -14,53 +14,85 @@ */ class ClassBuilder { + /** @var bool */ private $isTrait; + /** @var string|null */ private $namespace; + /** @var string */ private $className; + /** @var string|null */ private $superClass; + /** @var array */ private $interfaces = array(); + /** @var array */ private $uses = array(); + /** @var array */ private $inUses = array(); + /** @var array> */ private $properties = array(); + /** @var array> */ private $methods = array(); + /** + * @param string $className + * @return static + */ public static function startBuild($className) { + // @phpstan-ignore-next-line return new self($className); } + /** + * @param string $className + */ private function __construct($className) { $this->className = $className; $this->isTrait = false; } + /** + * @return $this + */ public function addTrait() { $this->isTrait = true; return $this; } + /** + * @param string $superClass + * @return $this + */ public function extend($superClass) { $this->superClass = $superClass; return $this; } + /** + * @param string $interface + * @return $this + */ public function implement($interface) { $this->interfaces[] = $interface; return $this; } + /** + * @param string $namespace + * @return $this + */ public function addNamespace($namespace) { $this->namespace = $namespace; @@ -68,18 +100,32 @@ public function addNamespace($namespace) return $this; } + /** + * @param string $use + * @return $this + */ public function addUse($use) { $this->uses[] = $use; return $this; } + /** + * @param string $inUse + * @return $this + */ public function addInUse($inUse) { $this->inUses[] = $inUse; return $this; } + /** + * @param string $scope + * @param string $name + * @param mixed $default + * @return $this + */ public function addProperty($scope, $name, $default = null) { $this->properties[] = array( @@ -91,6 +137,12 @@ public function addProperty($scope, $name, $default = null) return $this; } + /** + * @param string $scope + * @param string $signature + * @param string $contents + * @return $this + */ public function addMethod($scope, $signature, $contents) { $this->methods[] = array( @@ -102,6 +154,9 @@ public function addMethod($scope, $signature, $contents) return $this; } + /** + * @return string + */ public function toString() { $namespace = empty($this->namespace) ? "" : "namespace {$this->namespace};"; @@ -171,6 +226,7 @@ public function toString() return $class; } + // @phpstan-ignore-next-line public function build() { eval($this->toString()); @@ -182,6 +238,7 @@ public function build() /** * Create Custom Value Class Definition */ + // @phpstan-ignore-next-line public static function createCustomValue($namespace, $className, $fillpath, $table, $obj) { $table = CustomTable::getEloquent($table); diff --git a/src/Services/ClassLoader.php b/src/Services/ClassLoader.php index bdabd425c..8bc17fd32 100644 --- a/src/Services/ClassLoader.php +++ b/src/Services/ClassLoader.php @@ -12,22 +12,30 @@ class ClassLoader /** * Check target dirs * - * @var array + * @var array> */ protected $dirs = []; /** * Already called class * - * @var array + * @var array */ protected $called = []; + /** + * @return void + */ public function register() { spl_autoload_register(array($this, 'loadClass')); } + /** + * @param string $dir + * @param string $baseNamespace + * @return $this + */ public function registerDir(string $dir, string $baseNamespace) { $this->dirs[] = [ @@ -38,6 +46,10 @@ public function registerDir(string $dir, string $baseNamespace) return $this; } + /** + * @param string $class + * @return void + */ public function loadClass($class) { // if already has called, exit, diff --git a/src/Services/DataImportExport/Actions/Export/ActionInterface.php b/src/Services/DataImportExport/Actions/Export/ActionInterface.php index 6adec7de9..cc88856bd 100644 --- a/src/Services/DataImportExport/Actions/Export/ActionInterface.php +++ b/src/Services/DataImportExport/Actions/Export/ActionInterface.php @@ -7,10 +7,12 @@ interface ActionInterface /** * get output data list */ + // @phpstan-ignore-next-line public function datalist(); /** * get file base name */ + // @phpstan-ignore-next-line public function filebasename(); } diff --git a/src/Services/DataImportExport/Actions/Export/CustomTableAction.php b/src/Services/DataImportExport/Actions/Export/CustomTableAction.php index 254582300..7313d7ddb 100644 --- a/src/Services/DataImportExport/Actions/Export/CustomTableAction.php +++ b/src/Services/DataImportExport/Actions/Export/CustomTableAction.php @@ -11,16 +11,19 @@ class CustomTableAction extends ExportActionBase implements ActionInterface /** * target custom table */ + // @phpstan-ignore-next-line protected $custom_table; /** * custom_table's relations */ + // @phpstan-ignore-next-line protected $relations; /** * laravel-admin grid */ + // @phpstan-ignore-next-line protected $grid; /** @@ -37,6 +40,7 @@ class CustomTableAction extends ExportActionBase implements ActionInterface */ protected $add_relation = true; + // @phpstan-ignore-next-line public function __construct($args = []) { $this->custom_table = array_get($args, 'custom_table'); @@ -50,6 +54,7 @@ public function __construct($args = []) $this->add_relation = array_get($args, 'add_relation', true); } + // @phpstan-ignore-next-line public function datalist() { $providers = []; @@ -104,6 +109,7 @@ public function datalist() return $datalist; } + // @phpstan-ignore-next-line public function filebasename() { return $this->custom_table->table_view_name; diff --git a/src/Services/DataImportExport/Actions/Export/ExportActionBase.php b/src/Services/DataImportExport/Actions/Export/ExportActionBase.php index 249f816e5..56e0bbbf6 100644 --- a/src/Services/DataImportExport/Actions/Export/ExportActionBase.php +++ b/src/Services/DataImportExport/Actions/Export/ExportActionBase.php @@ -15,6 +15,7 @@ abstract class ExportActionBase */ protected $count = 0; + // @phpstan-ignore-next-line public function getCount() { return $this->count; diff --git a/src/Services/DataImportExport/Actions/Export/LoginUserAction.php b/src/Services/DataImportExport/Actions/Export/LoginUserAction.php index 00882fdb0..c6ac4350e 100644 --- a/src/Services/DataImportExport/Actions/Export/LoginUserAction.php +++ b/src/Services/DataImportExport/Actions/Export/LoginUserAction.php @@ -9,13 +9,16 @@ class LoginUserAction extends ExportActionBase implements ActionInterface /** * laravel-admin grid */ + // @phpstan-ignore-next-line protected $grid; + // @phpstan-ignore-next-line public function __construct($args = []) { $this->grid = array_get($args, 'grid'); } + // @phpstan-ignore-next-line public function datalist() { $provider = new Export\LoginUserProvider([ @@ -29,6 +32,7 @@ public function datalist() return $datalist; } + // @phpstan-ignore-next-line public function filebasename() { return 'login_user'; diff --git a/src/Services/DataImportExport/Actions/Export/OperationLogAction.php b/src/Services/DataImportExport/Actions/Export/OperationLogAction.php index e8a07c5ad..b00778bf6 100644 --- a/src/Services/DataImportExport/Actions/Export/OperationLogAction.php +++ b/src/Services/DataImportExport/Actions/Export/OperationLogAction.php @@ -12,13 +12,16 @@ class OperationLogAction extends ExportActionBase implements ActionInterface /** * laravel-admin grid */ + // @phpstan-ignore-next-line protected $grid; + // @phpstan-ignore-next-line public function __construct($args = []) { $this->grid = array_get($args, 'grid'); } + // @phpstan-ignore-next-line public function datalist() { $provider = new Export\OperationLogProvider([ @@ -32,6 +35,7 @@ public function datalist() return $datalist; } + // @phpstan-ignore-next-line public function filebasename() { return 'operation_log'; diff --git a/src/Services/DataImportExport/Actions/Export/PaginateAction.php b/src/Services/DataImportExport/Actions/Export/PaginateAction.php index 281f9fe34..ea546eaa8 100644 --- a/src/Services/DataImportExport/Actions/Export/PaginateAction.php +++ b/src/Services/DataImportExport/Actions/Export/PaginateAction.php @@ -20,6 +20,7 @@ class PaginateAction extends ExportActionBase implements ActionInterface * Widget grid * */ + // @phpstan-ignore-next-line protected $grid; /** @@ -27,6 +28,7 @@ class PaginateAction extends ExportActionBase implements ActionInterface * * @var array */ + // @phpstan-ignore-next-line protected $headers; /** @@ -36,6 +38,7 @@ class PaginateAction extends ExportActionBase implements ActionInterface */ protected $filename; + // @phpstan-ignore-next-line public function __construct($args = []) { $this->isAll = array_get($args, 'isAll'); @@ -44,6 +47,7 @@ public function __construct($args = []) $this->filename = array_get($args, 'filename'); } + // @phpstan-ignore-next-line public function datalist() { $providers = []; diff --git a/src/Services/DataImportExport/Actions/Export/PluginAction.php b/src/Services/DataImportExport/Actions/Export/PluginAction.php index 26b831d52..945b337a2 100644 --- a/src/Services/DataImportExport/Actions/Export/PluginAction.php +++ b/src/Services/DataImportExport/Actions/Export/PluginAction.php @@ -11,10 +11,13 @@ */ class PluginAction extends CustomTableAction { + // @phpstan-ignore-next-line protected $custom_view; + // @phpstan-ignore-next-line protected $plugin; + // @phpstan-ignore-next-line public function __construct($args = []) { $this->custom_table = array_get($args, 'custom_table'); @@ -24,6 +27,7 @@ public function __construct($args = []) $this->grid = array_get($args, 'grid'); } + // @phpstan-ignore-next-line public function plugin($plugin) { $this->plugin = Plugin::getPluginByUUID($plugin); @@ -31,6 +35,7 @@ public function plugin($plugin) return $this; } + // @phpstan-ignore-next-line public function datalist() { $providers = []; diff --git a/src/Services/DataImportExport/Actions/Export/RoleGroupAction.php b/src/Services/DataImportExport/Actions/Export/RoleGroupAction.php index dab5159e5..b766d0ce2 100644 --- a/src/Services/DataImportExport/Actions/Export/RoleGroupAction.php +++ b/src/Services/DataImportExport/Actions/Export/RoleGroupAction.php @@ -9,13 +9,16 @@ class RoleGroupAction extends ExportActionBase implements ActionInterface /** * laravel-admin grid */ + // @phpstan-ignore-next-line protected $grid; + // @phpstan-ignore-next-line public function __construct($args = []) { $this->grid = array_get($args, 'grid'); } + // @phpstan-ignore-next-line public function datalist() { $providers = []; @@ -50,6 +53,7 @@ public function datalist() return $datalist; } + // @phpstan-ignore-next-line public function filebasename() { return 'role_group'; diff --git a/src/Services/DataImportExport/Actions/Export/SummaryAction.php b/src/Services/DataImportExport/Actions/Export/SummaryAction.php index 27f275c12..9a82035cc 100644 --- a/src/Services/DataImportExport/Actions/Export/SummaryAction.php +++ b/src/Services/DataImportExport/Actions/Export/SummaryAction.php @@ -6,6 +6,7 @@ class SummaryAction extends ViewAction { + // @phpstan-ignore-next-line protected function getProvider() { return new Export\SummaryProvider([ diff --git a/src/Services/DataImportExport/Actions/Export/ViewAction.php b/src/Services/DataImportExport/Actions/Export/ViewAction.php index 9cd6ba555..a97d8fd50 100644 --- a/src/Services/DataImportExport/Actions/Export/ViewAction.php +++ b/src/Services/DataImportExport/Actions/Export/ViewAction.php @@ -6,8 +6,10 @@ class ViewAction extends CustomTableAction { + // @phpstan-ignore-next-line protected $custom_view; + // @phpstan-ignore-next-line public function __construct($args = []) { $this->custom_table = array_get($args, 'custom_table'); @@ -17,6 +19,7 @@ public function __construct($args = []) $this->grid = array_get($args, 'grid'); } + // @phpstan-ignore-next-line public function datalist() { $providers = []; @@ -37,6 +40,7 @@ public function datalist() } + // @phpstan-ignore-next-line protected function getProvider() { return new Export\ViewProvider([ diff --git a/src/Services/DataImportExport/Actions/Import/ActionInterface.php b/src/Services/DataImportExport/Actions/Import/ActionInterface.php index b613b2e2a..be4ea1d7d 100644 --- a/src/Services/DataImportExport/Actions/Import/ActionInterface.php +++ b/src/Services/DataImportExport/Actions/Import/ActionInterface.php @@ -4,7 +4,9 @@ interface ActionInterface { + // @phpstan-ignore-next-line public function filterDatalist($datalist); + // @phpstan-ignore-next-line public function import($datalist, $options = []); } diff --git a/src/Services/DataImportExport/Actions/Import/CustomTableAction.php b/src/Services/DataImportExport/Actions/Import/CustomTableAction.php index cd8510d71..3e5e75c3b 100644 --- a/src/Services/DataImportExport/Actions/Import/CustomTableAction.php +++ b/src/Services/DataImportExport/Actions/Import/CustomTableAction.php @@ -13,20 +13,25 @@ class CustomTableAction implements ActionInterface /** * target custom table */ + // @phpstan-ignore-next-line protected $custom_table; /** * custom_table's relations */ + // @phpstan-ignore-next-line protected $relations; /** * import data filter */ + // @phpstan-ignore-next-line protected $filter; + // @phpstan-ignore-next-line protected $primary_key; + // @phpstan-ignore-next-line public function __construct($args = []) { $this->custom_table = array_get($args, 'custom_table'); @@ -45,6 +50,7 @@ public function __construct($args = []) * @param array $options * @return array */ + // @phpstan-ignore-next-line public function importChunk($datalist, $options = []) { $messages = []; @@ -79,9 +85,9 @@ public function importChunk($datalist, $options = []) 'command.import.file_row_info', $options['file_name'] ?? null, $table_name, - /** @phpstan-ignore-next-line Offset 'row_start' on non-empty-array on left side of ?? always exists and is not nullable. */ + // @phpstan-ignore-next-line $options['row_start'] ?? null, - /** @phpstan-ignore-next-line Offset 'row_start' on non-empty-array on left side of ?? always exists and is not nullable. */ + // @phpstan-ignore-next-line $options['row_end'] ?? null )); } @@ -128,6 +134,7 @@ public function importChunk($datalist, $options = []) foreach ($data_import as $index => &$row) { // call dataProcessing if method exists if (method_exists($provider, 'dataProcessing')) { + // @phpstan-ignore-next-line $row['data'] = $provider->dataProcessing(array_get($row, 'data')); } @@ -154,6 +161,7 @@ public function importChunk($datalist, $options = []) ]; } + // @phpstan-ignore-next-line public function import($datalist, $options = []) { // get target data and model list @@ -201,6 +209,7 @@ public function import($datalist, $options = []) foreach ($data_import['data_import'] as $index => &$row) { // call dataProcessing if method exists if (method_exists($provider, 'dataProcessing')) { + // @phpstan-ignore-next-line $row['data'] = $provider->dataProcessing(array_get($row, 'data')); } @@ -217,6 +226,7 @@ public function import($datalist, $options = []) /** * filter only custom_table or relations datalist. */ + // @phpstan-ignore-next-line public function filterDatalist($datalist) { // get tablenames @@ -239,6 +249,7 @@ public function filterDatalist($datalist) /** * get provider */ + // @phpstan-ignore-next-line public function getProvider($keyname) { // get providers @@ -274,11 +285,13 @@ public function getProvider($keyname) /** * get import modal endpoint. not contains "import" and "admin" */ + // @phpstan-ignore-next-line public function getImportEndpoint() { return url_join('data', $this->custom_table->table_name); } + // @phpstan-ignore-next-line public function getImportHeaderViewName() { return $this->custom_table->table_view_name; @@ -287,6 +300,7 @@ public function getImportHeaderViewName() /** * get primary key list. */ + // @phpstan-ignore-next-line public function getPrimaryKeys() { // default list @@ -313,6 +327,7 @@ public function getPrimaryKeys() /** * set_import_modal_items. it sets at form footer */ + // @phpstan-ignore-next-line public function setImportModalItems(&$form) { $form->hidden('custom_table_name')->default($this->custom_table->table_name); @@ -322,6 +337,7 @@ public function setImportModalItems(&$form) return $this; } + // @phpstan-ignore-next-line protected function getImportTableSetting($settingArray, $table_name) { if (count($settingArray) <= 2) { diff --git a/src/Services/DataImportExport/Actions/Import/DocumentAction.php b/src/Services/DataImportExport/Actions/Import/DocumentAction.php index 93c29fdc7..5e3379739 100644 --- a/src/Services/DataImportExport/Actions/Import/DocumentAction.php +++ b/src/Services/DataImportExport/Actions/Import/DocumentAction.php @@ -9,11 +9,13 @@ */ class DocumentAction extends FileColumnAction { + // @phpstan-ignore-next-line protected static $files_name = 'documents'; /** * get provider */ + // @phpstan-ignore-next-line public function getProvider($table_name) { return new Import\DocumentProvider([ diff --git a/src/Services/DataImportExport/Actions/Import/FileColumnAction.php b/src/Services/DataImportExport/Actions/Import/FileColumnAction.php index 32c38a3b6..b5cb4edc3 100644 --- a/src/Services/DataImportExport/Actions/Import/FileColumnAction.php +++ b/src/Services/DataImportExport/Actions/Import/FileColumnAction.php @@ -19,8 +19,10 @@ class FileColumnAction implements ActionInterface /** * target custom table */ + // @phpstan-ignore-next-line protected $custom_table; + // @phpstan-ignore-next-line public function __construct($args = []) { $this->custom_table = array_get($args, 'custom_table'); @@ -28,6 +30,7 @@ public function __construct($args = []) } + // @phpstan-ignore-next-line public function importChunk($datalist, $options = []) { $messages = []; @@ -100,6 +103,7 @@ public function importChunk($datalist, $options = []) foreach ($data_import as $index => &$row) { // call dataProcessing if method exists if (method_exists($provider, 'dataProcessing')) { + // @phpstan-ignore-next-line $row['data'] = $provider->dataProcessing(array_get($row, 'data')); } @@ -119,6 +123,7 @@ public function importChunk($datalist, $options = []) } + // @phpstan-ignore-next-line public function import($datalist, $options = []) { } @@ -126,6 +131,7 @@ public function import($datalist, $options = []) /** * filter only custom_table or relations datalist. */ + // @phpstan-ignore-next-line public function filterDatalist($datalist) { return $datalist; @@ -134,6 +140,7 @@ public function filterDatalist($datalist) /** * get provider */ + // @phpstan-ignore-next-line public function getProvider($table_name) { return new Import\FileColumnProvider([ diff --git a/src/Services/DataImportExport/Actions/Import/LoginUserAction.php b/src/Services/DataImportExport/Actions/Import/LoginUserAction.php index bbc724eed..e3b37a64e 100644 --- a/src/Services/DataImportExport/Actions/Import/LoginUserAction.php +++ b/src/Services/DataImportExport/Actions/Import/LoginUserAction.php @@ -7,13 +7,16 @@ class LoginUserAction implements ActionInterface { + // @phpstan-ignore-next-line protected $primary_key; + // @phpstan-ignore-next-line public function __construct($args = []) { $this->primary_key = array_get($args, 'primary_key', 'id'); } + // @phpstan-ignore-next-line public function import($datalist, $options = []) { // get target data and model list @@ -65,6 +68,7 @@ public function import($datalist, $options = []) /** * filter */ + // @phpstan-ignore-next-line public function filterDatalist($datalist) { return $datalist; @@ -75,11 +79,13 @@ public function filterDatalist($datalist) /** * get import modal endpoint. not contains "import" and "admin" */ + // @phpstan-ignore-next-line public function getImportEndpoint() { return 'loginuser'; } + // @phpstan-ignore-next-line public function getImportHeaderViewName() { return exmtrans('menu.system_definitions.loginuser'); @@ -88,6 +94,7 @@ public function getImportHeaderViewName() /** * get primary key list. */ + // @phpstan-ignore-next-line public function getPrimaryKeys() { // default list @@ -98,6 +105,7 @@ public function getPrimaryKeys() /** * set_import_modal_items. it sets at form footer */ + // @phpstan-ignore-next-line public function setImportModalItems(&$form) { return $this; diff --git a/src/Services/DataImportExport/Actions/Import/RoleGroupAction.php b/src/Services/DataImportExport/Actions/Import/RoleGroupAction.php index c90862e7a..bd64a9681 100644 --- a/src/Services/DataImportExport/Actions/Import/RoleGroupAction.php +++ b/src/Services/DataImportExport/Actions/Import/RoleGroupAction.php @@ -7,13 +7,16 @@ class RoleGroupAction implements ActionInterface { + // @phpstan-ignore-next-line protected $primary_key; + // @phpstan-ignore-next-line public function __construct($args = []) { $this->primary_key = array_get($args, 'primary_key', 'id'); } + // @phpstan-ignore-next-line public function import($datalist, $options = []) { // get target data and model list @@ -60,6 +63,7 @@ public function import($datalist, $options = []) /** * filter */ + // @phpstan-ignore-next-line public function filterDatalist($datalist) { return $datalist; @@ -70,11 +74,13 @@ public function filterDatalist($datalist) /** * get import modal endpoint. not contains "import" and "admin" */ + // @phpstan-ignore-next-line public function getImportEndpoint() { return 'role_group'; } + // @phpstan-ignore-next-line public function getImportHeaderViewName() { return exmtrans('menu.system_definitions.role_group'); @@ -83,6 +89,7 @@ public function getImportHeaderViewName() /** * get primary key list. */ + // @phpstan-ignore-next-line public function getPrimaryKeys() { // default list @@ -93,11 +100,13 @@ public function getPrimaryKeys() /** * set_import_modal_items. it sets at form footer */ + // @phpstan-ignore-next-line public function setImportModalItems(&$form) { return $this; } + // @phpstan-ignore-next-line protected function getProvider(string $table_name) { switch ($table_name) { diff --git a/src/Services/DataImportExport/DataImportExportServiceTrait.php b/src/Services/DataImportExport/DataImportExportServiceTrait.php index 35ec71cbc..a776ad14d 100644 --- a/src/Services/DataImportExport/DataImportExportServiceTrait.php +++ b/src/Services/DataImportExport/DataImportExportServiceTrait.php @@ -22,38 +22,46 @@ */ trait DataImportExportServiceTrait { + // @phpstan-ignore-next-line public static $queryName = '_export_'; /** * csv or excel format string (xlsx, csv) */ + // @phpstan-ignore-next-line protected $format; /** * file base name */ + // @phpstan-ignore-next-line protected $filebasename; /** * import action. */ + // @phpstan-ignore-next-line protected $importAction; /** * export action. */ + // @phpstan-ignore-next-line protected $exportAction; /** * view export action. */ + // @phpstan-ignore-next-line protected $viewExportAction; /** * plugin export action. */ + // @phpstan-ignore-next-line protected $pluginExportAction; + // @phpstan-ignore-next-line public function __construct($args = []) { $this->format = static::getFormat($args); @@ -63,6 +71,7 @@ public function __construct($args = []) } } + // @phpstan-ignore-next-line public function format($format = null) { if (!func_num_args()) { @@ -74,6 +83,7 @@ public function format($format = null) return $this; } + // @phpstan-ignore-next-line public function filebasename($filebasename = null) { if (!func_num_args()) { @@ -85,6 +95,7 @@ public function filebasename($filebasename = null) return $this; } + // @phpstan-ignore-next-line protected static function getFormat($args = []): string { if ($args instanceof FormatBase) { @@ -115,10 +126,12 @@ protected function getFormatClass(string $library, bool $isExport): FormatBase { if ($isExport) { if ($this->exportAction && method_exists($this->exportAction, 'getFormatClass')) { + // @phpstan-ignore-next-line return $this->exportAction->getFormatClass($this->format, $library); } } else { if ($this->importAction && method_exists($this->importAction, 'getFormatClass')) { + // @phpstan-ignore-next-line return $this->importAction->getFormatClass($this->format, $library); } } @@ -126,6 +139,7 @@ protected function getFormatClass(string $library, bool $isExport): FormatBase return FormatBase::getFormatClass($this->format, $library, $isExport); } + // @phpstan-ignore-next-line public function importAction($importAction) { $this->importAction = $importAction; @@ -133,6 +147,7 @@ public function importAction($importAction) return $this; } + // @phpstan-ignore-next-line public function exportAction($exportAction) { $this->exportAction = $exportAction; @@ -140,6 +155,7 @@ public function exportAction($exportAction) return $this; } + // @phpstan-ignore-next-line public function viewExportAction($viewExportAction) { $this->viewExportAction = $viewExportAction; @@ -147,6 +163,7 @@ public function viewExportAction($viewExportAction) return $this; } + // @phpstan-ignore-next-line public function pluginExportAction($pluginExportAction) { $this->pluginExportAction = $pluginExportAction; @@ -250,6 +267,7 @@ public function import($request) * @param array $options * @return array error message or success message etc... */ + // @phpstan-ignore-next-line public function importBackground(\Illuminate\Console\Command $command, $file_name, $file_path, array $options = []) { \Exment::setTimeLimitLong(); @@ -293,6 +311,7 @@ public function importBackground(\Illuminate\Console\Command $command, $file_nam /** * execute export background */ + // @phpstan-ignore-next-line public function exportBackground(array $options = []) { \Exment::setTimeLimitLong(); @@ -330,6 +349,7 @@ public function exportBackground(array $options = []) * @param int|string $import_plugin * @param mixed $file */ + // @phpstan-ignore-next-line protected function customImport($import_plugin, $file, $custom_table_id = null) { $plugin = Plugin::find($import_plugin); @@ -361,6 +381,7 @@ protected function customImport($import_plugin, $file, $custom_table_id = null) * @param Request $request * @return array|boolean */ + // @phpstan-ignore-next-line public function validateRequest($request) { $formatObj = $this->getFormatClass(ExportImportLibrary::PHP_SPREAD_SHEET, false); @@ -385,6 +406,7 @@ public function validateRequest($request) $validator = Validator::make( [ 'file' => $file, + // @phpstan-ignore-next-line 'custom_table_file' => strtolower($file->getClientOriginalExtension()), ], [ @@ -410,6 +432,7 @@ public function validateRequest($request) * @param array $pluginlist * @return \Symfony\Component\HttpFoundation\Response */ + // @phpstan-ignore-next-line public function getImportModal($pluginlist = null) { // create form fields @@ -500,6 +523,7 @@ public function getImportModal($pluginlist = null) * @param CustomTable $custom_table * @return array */ + // @phpstan-ignore-next-line protected static function getPrimaryKeys($custom_table) { // default list @@ -532,6 +556,7 @@ protected static function getPrimaryKeys($custom_table) * @param array $options * @return array */ + // @phpstan-ignore-next-line public static function processCustomValue($custom_columns, $data, $options = []) { foreach ($data as $key => &$value) { @@ -586,6 +611,7 @@ public static function processCustomValue($custom_columns, $data, $options = []) * * @return void */ + // @phpstan-ignore-next-line protected static function getImportColumnValue(&$data, $key, &$value, $column_item, $column_view_name, $setting, $target_table, $options = []) { $setting = $setting ?? []; @@ -598,6 +624,7 @@ protected static function getImportColumnValue(&$data, $key, &$value, $column_it ); if (method_exists($column_item, 'getKeyAndIdList')) { + // @phpstan-ignore-next-line $datalist = $column_item->getKeyAndIdList($options['datalist'], array_get($setting, 'target_column_name')); if (!is_nullorempty($datalist)) { $setting['datalist'] = $datalist; diff --git a/src/Services/DataImportExport/Formats/CsvTrait.php b/src/Services/DataImportExport/Formats/CsvTrait.php index f93c8813e..659f0cca9 100644 --- a/src/Services/DataImportExport/Formats/CsvTrait.php +++ b/src/Services/DataImportExport/Formats/CsvTrait.php @@ -12,6 +12,7 @@ public function getFormat(): string } + // @phpstan-ignore-next-line public function getDataTable($request, array $options = []) { $options = $this->getDataOptions($options); @@ -44,6 +45,7 @@ public function getDataTable($request, array $options = []) }); } + // @phpstan-ignore-next-line public function getDataCount($request) { return $this->_getData($request, function ($files) { @@ -53,6 +55,7 @@ public function getDataCount($request) }); } + // @phpstan-ignore-next-line protected function _getData($request, $callbackZip, $callbackDefault) { // get file @@ -78,6 +81,7 @@ protected function _getData($request, $callbackZip, $callbackDefault) // get all files $files = collect(\File::files($tmpfolderpath))->filter(function ($value) { + // @phpstan-ignore-next-line return pathinfo($value)['extension'] == 'csv'; }); diff --git a/src/Services/DataImportExport/Formats/FormatBase.php b/src/Services/DataImportExport/Formats/FormatBase.php index 07575d1bb..f496467de 100644 --- a/src/Services/DataImportExport/Formats/FormatBase.php +++ b/src/Services/DataImportExport/Formats/FormatBase.php @@ -7,9 +7,13 @@ abstract class FormatBase { + // @phpstan-ignore-next-line protected $datalist; + // @phpstan-ignore-next-line protected $filebasename; + // @phpstan-ignore-next-line protected $downloadFilePath; + // @phpstan-ignore-next-line protected $output_aszip; /** @@ -19,7 +23,9 @@ abstract class FormatBase */ protected $isBackground = false; + // @phpstan-ignore-next-line protected $extension = '*'; + // @phpstan-ignore-next-line protected $accept_extension = '*'; /** @@ -35,6 +41,7 @@ public function __destruct() $this->deleteTmpDirectory(); } + // @phpstan-ignore-next-line public function datalist($datalist = []) { if (!func_num_args()) { @@ -46,6 +53,7 @@ public function datalist($datalist = []) return $this; } + // @phpstan-ignore-next-line public function filebasename($filebasename = []) { if (!func_num_args()) { @@ -57,11 +65,13 @@ public function filebasename($filebasename = []) return $this; } + // @phpstan-ignore-next-line public function accept_extension() { return $this->accept_extension; } + // @phpstan-ignore-next-line public function background() { $this->isBackground = true; @@ -82,6 +92,7 @@ public function output_aszip(bool $output_aszip) + // @phpstan-ignore-next-line public function sendResponse() { $response = response()->download($this->getDownloadFilePath(), $this->getFileName(), $this->getDefaultHeaders()); @@ -93,6 +104,7 @@ public function sendResponse() } + // @phpstan-ignore-next-line public function saveAsFile($dirpath) { // move file tmp directory to $dirpath @@ -169,12 +181,14 @@ protected function tmpdir(): string * * @return string */ + // @phpstan-ignore-next-line protected function getTmpFilePath($fileName): string { return path_join($this->tmpdir(), $fileName); } + // @phpstan-ignore-next-line protected function getDefaultHeaders() { $filename = $this->getFileName(); @@ -191,6 +205,7 @@ protected function getDefaultHeaders() * @param array $options * @return array */ + // @phpstan-ignore-next-line public function getDataOptions(array $options) { return array_merge([ @@ -240,6 +255,7 @@ public static function getFormatClass(?string $format, string $library, bool $is * @param array $files * @return string */ + // @phpstan-ignore-next-line protected function createDownloadFile(array $files): string { // save as csv @@ -272,20 +288,26 @@ protected function createDownloadFile(array $files): string * @param Request|\SplFileInfo|string $target * @return array [$path, $extension, $originalName]; */ + // @phpstan-ignore-next-line protected function getFileInfo($target): array { // get file if ($target instanceof Request) { $file = $target->file('custom_table_file'); + // @phpstan-ignore-next-line $path = $file->getRealPath(); + // @phpstan-ignore-next-line $extension = $file->extension(); + // @phpstan-ignore-next-line $originalName = $file->getClientOriginalName(); } elseif ($target instanceof \SplFileInfo) { $path = $target->getPathName(); + // @phpstan-ignore-next-line $extension = pathinfo($path)['extension']; $originalName = pathinfo($path, PATHINFO_BASENAME); } else { $path = $target; + // @phpstan-ignore-next-line $extension = pathinfo($path)['extension']; $originalName = pathinfo($path, PATHINFO_BASENAME); } @@ -316,6 +338,7 @@ protected function deleteTmpDirectory() * @param array $options * @return boolean */ + // @phpstan-ignore-next-line protected function isReadSheetRow(int $sheet_row_no, array $options = []): bool { // get options @@ -338,9 +361,11 @@ protected function isReadSheetRow(int $sheet_row_no, array $options = []): bool * create file * 1 sheet - 1 table data */ + // @phpstan-ignore-next-line abstract public function createFile(); + // @phpstan-ignore-next-line abstract public function getFormat(); /** @@ -350,6 +375,8 @@ abstract public function getFormat(); * @return boolean */ abstract protected function isOutputAsZip(); + // @phpstan-ignore-next-line abstract protected function createWriter($spreadsheet); + // @phpstan-ignore-next-line abstract protected function createReader(); } diff --git a/src/Services/DataImportExport/Formats/PhpSpreadSheet/Csv.php b/src/Services/DataImportExport/Formats/PhpSpreadSheet/Csv.php index a1f05d7a2..1e2c28f76 100644 --- a/src/Services/DataImportExport/Formats/PhpSpreadSheet/Csv.php +++ b/src/Services/DataImportExport/Formats/PhpSpreadSheet/Csv.php @@ -11,9 +11,11 @@ class Csv extends PhpSpreadSheet { use CsvTrait; + // @phpstan-ignore-next-line protected $accept_extension = 'csv,zip'; + // @phpstan-ignore-next-line protected function _getData($request, $callbackZip, $callbackDefault) { // get file @@ -39,6 +41,7 @@ protected function _getData($request, $callbackZip, $callbackDefault) // get all files $files = collect(\File::files($tmpfolderpath))->filter(function ($value) { + // @phpstan-ignore-next-line return pathinfo($value)['extension'] == 'csv'; }); @@ -62,6 +65,7 @@ protected function _getData($request, $callbackZip, $callbackDefault) } + // @phpstan-ignore-next-line protected function createWriter($spreadsheet) { /** @var \PhpOffice\PhpSpreadsheet\Writer\Csv $writer */ @@ -73,6 +77,7 @@ protected function createWriter($spreadsheet) return $writer; } + // @phpstan-ignore-next-line protected function createReader() { return IOFactory::createReader('Csv'); @@ -84,6 +89,7 @@ protected function createReader() * @param string|array|\Illuminate\Support\Collection $files * @return int */ + // @phpstan-ignore-next-line protected function getRowCount($files): int { $count = 0; @@ -104,9 +110,10 @@ protected function getRowCount($files): int return $count; } + // @phpstan-ignore-next-line protected function getCsvArray($file, array $options = []) { - /** @phpstan-ignore-next-line setlocale expects array|string|null, int given */ + // @phpstan-ignore-next-line $original_locale = setlocale(LC_CTYPE, 0); // set C locale @@ -121,6 +128,7 @@ protected function getCsvArray($file, array $options = []) $array = $this->getDataFromSheet($spreadsheet->getActiveSheet(), false, false, $options); // revert to original locale + // @phpstan-ignore-next-line setlocale(LC_CTYPE, $original_locale); return $array; diff --git a/src/Services/DataImportExport/Formats/PhpSpreadSheet/PhpSpreadSheet.php b/src/Services/DataImportExport/Formats/PhpSpreadSheet/PhpSpreadSheet.php index 60af60c35..cfdb21578 100644 --- a/src/Services/DataImportExport/Formats/PhpSpreadSheet/PhpSpreadSheet.php +++ b/src/Services/DataImportExport/Formats/PhpSpreadSheet/PhpSpreadSheet.php @@ -13,6 +13,7 @@ abstract class PhpSpreadSheet extends FormatBase * create file * 1 sheet - 1 table data */ + // @phpstan-ignore-next-line public function createFile() { // define writers. if zip, set as array. @@ -106,6 +107,7 @@ public function createFile() * @param array $options * @return array */ + // @phpstan-ignore-next-line public function getDataFromSheet($sheet, bool $keyvalue = false, bool $isGetMerge = false, array $options = []): array { $data = []; @@ -159,12 +161,14 @@ public function getCellValue($cell, $sheet, $isGetMerge = false) // if merge cell, get from master cell if ($isGetMerge && $cell->isInMergeRange()) { $mergeRange = $cell->getMergeRange(); + // @phpstan-ignore-next-line $cell = $sheet->getCell(explode(":", $mergeRange)[0]); } $value = $cell->getCalculatedValue(); // is datetime, convert to date string if (\PhpOffice\PhpSpreadsheet\Shared\Date::isDateTime($cell) && is_numeric($value)) { + // @phpstan-ignore-next-line $date = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($value); if (floatval($value) < 1) { $value = $date->format('H:i:s'); diff --git a/src/Services/DataImportExport/Formats/PhpSpreadSheet/Xlsx.php b/src/Services/DataImportExport/Formats/PhpSpreadSheet/Xlsx.php index 3f41a93fe..4bec682ca 100644 --- a/src/Services/DataImportExport/Formats/PhpSpreadSheet/Xlsx.php +++ b/src/Services/DataImportExport/Formats/PhpSpreadSheet/Xlsx.php @@ -9,11 +9,13 @@ class Xlsx extends PhpSpreadSheet { use XlsxTrait; + // @phpstan-ignore-next-line protected $accept_extension = 'xlsx'; /** * get data table list. contains self table, and relations (if contains) */ + // @phpstan-ignore-next-line public function getDataTable($request, array $options = []) { $options = $this->getDataOptions($options); @@ -37,6 +39,7 @@ public function getDataTable($request, array $options = []) } + // @phpstan-ignore-next-line protected function _getData($request, $callback) { // get file @@ -74,11 +77,13 @@ protected function getRowCount($spreadsheet): int } + // @phpstan-ignore-next-line protected function createWriter($spreadsheet) { return IOFactory::createWriter($spreadsheet, 'Xlsx'); } + // @phpstan-ignore-next-line protected function createReader() { return IOFactory::createReader('Xlsx'); diff --git a/src/Services/DataImportExport/Formats/SpOut/Csv.php b/src/Services/DataImportExport/Formats/SpOut/Csv.php index aca0c6cd2..f72fc804b 100644 --- a/src/Services/DataImportExport/Formats/SpOut/Csv.php +++ b/src/Services/DataImportExport/Formats/SpOut/Csv.php @@ -10,6 +10,7 @@ class Csv extends SpOut { use CsvTrait; + // @phpstan-ignore-next-line protected $accept_extension = 'csv,zip'; @@ -19,6 +20,7 @@ class Csv extends SpOut * @param string|array|\Illuminate\Support\Collection $files * @return int */ + // @phpstan-ignore-next-line protected function getRowCount($files): int { $count = 0; @@ -45,9 +47,10 @@ protected function getRowCount($files): int return $count; } + // @phpstan-ignore-next-line protected function getCsvArray($file, array $options = []) { - /** @phpstan-ignore-next-line setlocale expects array|string|null, int given*/ + // @phpstan-ignore-next-line $original_locale = setlocale(LC_CTYPE, 0); // set C locale @@ -68,6 +71,7 @@ protected function getCsvArray($file, array $options = []) } // revert to original locale + // @phpstan-ignore-next-line setlocale(LC_CTYPE, $original_locale); return $array; @@ -77,6 +81,7 @@ protected function getCsvArray($file, array $options = []) /** * @return \Box\Spout\Writer\CSV\Writer */ + // @phpstan-ignore-next-line protected function createWriter($spreadsheet) { return WriterEntityFactory::createCSVWriter(); diff --git a/src/Services/DataImportExport/Formats/SpOut/SpOut.php b/src/Services/DataImportExport/Formats/SpOut/SpOut.php index 92f7a82e7..ae1c7f9b0 100644 --- a/src/Services/DataImportExport/Formats/SpOut/SpOut.php +++ b/src/Services/DataImportExport/Formats/SpOut/SpOut.php @@ -14,6 +14,7 @@ abstract class SpOut extends FormatBase * create file * 1 sheet - 1 table data */ + // @phpstan-ignore-next-line public function createFile() { // define writers. if zip, set as array. @@ -96,6 +97,7 @@ public function createFile() * @param array $options * @return array */ + // @phpstan-ignore-next-line public function getDataFromSheet($sheet, bool $keyvalue = false, bool $isGetMerge = false, array $options = []): array { $data = []; @@ -142,6 +144,7 @@ public function getDataFromSheet($sheet, bool $keyvalue = false, bool $isGetMerg public function getCellValue($cell, $sheet, $isGetMerge = false) { if (is_string($cell)) { + // @phpstan-ignore-next-line $cell = $sheet->getCell($cell); } @@ -155,6 +158,7 @@ public function getCellValue($cell, $sheet, $isGetMerge = false) // If SpOut, already Calculated. // $value = $cell->getCalculatedValue(); $value = $cell->getValue(); + // @phpstan-ignore-next-line $type = $cell->getType(); // is datetime, convert to date string diff --git a/src/Services/DataImportExport/Formats/SpOut/Xlsx.php b/src/Services/DataImportExport/Formats/SpOut/Xlsx.php index 5d36c690a..568d13a6b 100644 --- a/src/Services/DataImportExport/Formats/SpOut/Xlsx.php +++ b/src/Services/DataImportExport/Formats/SpOut/Xlsx.php @@ -11,11 +11,13 @@ class Xlsx extends SpOut { use XlsxTrait; + // @phpstan-ignore-next-line protected $accept_extension = 'xlsx'; /** * get data table list. contains self table, and relations (if contains) */ + // @phpstan-ignore-next-line public function getDataTable($request, array $options = []) { $options = $this->getDataOptions($options); @@ -40,6 +42,7 @@ public function getDataTable($request, array $options = []) } + // @phpstan-ignore-next-line protected function _getData($request, $callback) { list($path, $extension, $originalName, $file) = $this->getFileInfo($request); @@ -79,6 +82,7 @@ protected function getRowCount(ReaderAbstract $reader): int /** * @return \Box\Spout\Writer\XLSX\Writer */ + // @phpstan-ignore-next-line protected function createWriter($spreadsheet) { return WriterEntityFactory::createXLSXWriter(); diff --git a/src/Services/DataImportExport/Formats/XlsxTrait.php b/src/Services/DataImportExport/Formats/XlsxTrait.php index 92bb1275b..3f4b8bdea 100644 --- a/src/Services/DataImportExport/Formats/XlsxTrait.php +++ b/src/Services/DataImportExport/Formats/XlsxTrait.php @@ -13,6 +13,7 @@ public function getFormat(): string /** * get data table list. contains self table, and relations (if contains) */ + // @phpstan-ignore-next-line public function getDataCount($request) { return $this->_getData($request, function ($reader) { diff --git a/src/Services/DataImportExport/Providers/Export/DefaultTableProvider.php b/src/Services/DataImportExport/Providers/Export/DefaultTableProvider.php index 60afe88f1..6df7afc20 100644 --- a/src/Services/DataImportExport/Providers/Export/DefaultTableProvider.php +++ b/src/Services/DataImportExport/Providers/Export/DefaultTableProvider.php @@ -13,10 +13,14 @@ class DefaultTableProvider extends ProviderBase { + // @phpstan-ignore-next-line protected $grid; + // @phpstan-ignore-next-line protected $parent_table; + // @phpstan-ignore-next-line protected $custom_table; + // @phpstan-ignore-next-line public function __construct($args = []) { parent::__construct(); @@ -29,6 +33,7 @@ public function __construct($args = []) /** * get data name */ + // @phpstan-ignore-next-line public function name() { return $this->custom_table->table_name; @@ -37,6 +42,7 @@ public function name() /** * get data */ + // @phpstan-ignore-next-line public function data() { // get header info @@ -74,6 +80,7 @@ protected function getColumnDefines() * get export headers * contains custom column name, column view name */ + // @phpstan-ignore-next-line protected function getHeaders($columnDefines) { // create 2 rows. @@ -108,6 +115,7 @@ protected function getHeaders($columnDefines) /** * get target chunk records */ + // @phpstan-ignore-next-line public function getRecords(): Collection { $records = new Collection(); @@ -146,6 +154,7 @@ public function getRecords(): Collection /** * get export bodies */ + // @phpstan-ignore-next-line protected function getBodies($records, $columnDefines) { if (!isset($records)) { @@ -171,6 +180,7 @@ protected function getBodies($records, $columnDefines) /** * get export body items */ + // @phpstan-ignore-next-line protected function getBodyItems($record, $columns, $array_header_key = null, $view_column_type = ConditionType::SYSTEM) { $body_items = []; @@ -197,6 +207,7 @@ protected function getBodyItems($record, $columns, $array_header_key = null, $vi * @param $record * @return int|mixed|string|null */ + // @phpstan-ignore-next-line protected function getBodyValue($values, $column, $view_column_type, $record) { if (is_nullorempty($values)) { diff --git a/src/Services/DataImportExport/Providers/Export/DefaultTableSettingProvider.php b/src/Services/DataImportExport/Providers/Export/DefaultTableSettingProvider.php index dbe07827d..dcff3bb68 100644 --- a/src/Services/DataImportExport/Providers/Export/DefaultTableSettingProvider.php +++ b/src/Services/DataImportExport/Providers/Export/DefaultTableSettingProvider.php @@ -10,10 +10,14 @@ class DefaultTableSettingProvider extends ProviderBase { + // @phpstan-ignore-next-line protected $custom_table; + // @phpstan-ignore-next-line protected $custom_columns; + // @phpstan-ignore-next-line protected $outputs = []; + // @phpstan-ignore-next-line public function __construct($args = []) { parent::__construct(); @@ -25,6 +29,7 @@ public function __construct($args = []) /** * get data name */ + // @phpstan-ignore-next-line public function name() { return Define::SETTING_SHEET_NAME; @@ -33,11 +38,13 @@ public function name() /** * get data */ + // @phpstan-ignore-next-line public function data() { return $this->outputs; } + // @phpstan-ignore-next-line protected function setOutputData() { // get header and body @@ -90,6 +97,7 @@ public function isOutput() * get export headers * contains custom column name, column view name */ + // @phpstan-ignore-next-line protected function getHeaders() { // create 2 rows. @@ -108,6 +116,7 @@ protected function getHeaders() * * @return \Illuminate\Support\Collection */ + // @phpstan-ignore-next-line protected static function getTargetColumns($custom_table) { // get custom columns. only select_valtext, select_table @@ -117,6 +126,7 @@ protected static function getTargetColumns($custom_table) } + // @phpstan-ignore-next-line public function getRecords(): Collection { return new Collection(); diff --git a/src/Services/DataImportExport/Providers/Export/LoginUserProvider.php b/src/Services/DataImportExport/Providers/Export/LoginUserProvider.php index 6d9ef0340..e7dd68514 100644 --- a/src/Services/DataImportExport/Providers/Export/LoginUserProvider.php +++ b/src/Services/DataImportExport/Providers/Export/LoginUserProvider.php @@ -10,8 +10,10 @@ class LoginUserProvider extends ProviderBase { + // @phpstan-ignore-next-line protected $grid; + // @phpstan-ignore-next-line public function __construct($args = []) { parent::__construct(); @@ -21,6 +23,7 @@ public function __construct($args = []) /** * get data name */ + // @phpstan-ignore-next-line public function name() { return 'login_user'; @@ -29,6 +32,7 @@ public function name() /** * get data */ + // @phpstan-ignore-next-line public function data() { $headers = $this->getHeaders(); @@ -48,6 +52,7 @@ public function data() /** * get export headers */ + // @phpstan-ignore-next-line protected function getHeaders() { // create 2 rows. @@ -89,6 +94,7 @@ protected function getHeaders() /** * get target chunk records */ + // @phpstan-ignore-next-line public function getRecords(): Collection { $records = new Collection(); @@ -106,6 +112,7 @@ public function getRecords(): Collection /** * get export bodies */ + // @phpstan-ignore-next-line protected function getBodies($records) { if (!isset($records)) { diff --git a/src/Services/DataImportExport/Providers/Export/OperationLogProvider.php b/src/Services/DataImportExport/Providers/Export/OperationLogProvider.php index 151d1fe9a..cf2d54530 100644 --- a/src/Services/DataImportExport/Providers/Export/OperationLogProvider.php +++ b/src/Services/DataImportExport/Providers/Export/OperationLogProvider.php @@ -6,8 +6,10 @@ class OperationLogProvider extends ProviderBase { + // @phpstan-ignore-next-line protected $grid; + // @phpstan-ignore-next-line public function __construct($args = []) { parent::__construct(); @@ -17,6 +19,7 @@ public function __construct($args = []) /** * get data name */ + // @phpstan-ignore-next-line public function name() { return 'operation_log'; @@ -25,6 +28,7 @@ public function name() /** * get data */ + // @phpstan-ignore-next-line public function data() { $headers = $this->getHeaders(); @@ -39,6 +43,7 @@ public function data() /** * get export headers */ + // @phpstan-ignore-next-line protected function getHeaders() { // create 2 rows. @@ -70,6 +75,7 @@ protected function getHeaders() /** * get target chunk records */ + // @phpstan-ignore-next-line public function getRecords(): Collection { $records = new Collection(); @@ -88,6 +94,7 @@ public function getRecords(): Collection /** * get export bodies */ + // @phpstan-ignore-next-line protected function getBodies($records) { if (!isset($records)) { diff --git a/src/Services/DataImportExport/Providers/Export/PaginateProvider.php b/src/Services/DataImportExport/Providers/Export/PaginateProvider.php index fc82184a0..116483ac2 100644 --- a/src/Services/DataImportExport/Providers/Export/PaginateProvider.php +++ b/src/Services/DataImportExport/Providers/Export/PaginateProvider.php @@ -17,6 +17,7 @@ class PaginateProvider extends ProviderBase * Widget grid * */ + // @phpstan-ignore-next-line protected $grid; /** @@ -24,6 +25,7 @@ class PaginateProvider extends ProviderBase * * @var array */ + // @phpstan-ignore-next-line protected $headers = []; /** @@ -33,6 +35,7 @@ class PaginateProvider extends ProviderBase */ protected $filename; + // @phpstan-ignore-next-line public function __construct($args = []) { parent::__construct(); @@ -45,6 +48,7 @@ public function __construct($args = []) /** * get data name */ + // @phpstan-ignore-next-line public function name() { return $this->filename; @@ -53,6 +57,7 @@ public function name() /** * get data */ + // @phpstan-ignore-next-line public function data() { // get header and body @@ -68,6 +73,7 @@ public function data() /** * get export headers */ + // @phpstan-ignore-next-line protected function getHeaders() { // 1st row, column name @@ -86,6 +92,7 @@ protected function getHeaders() /** * get target chunk records */ + // @phpstan-ignore-next-line public function getRecords(): Collection { if ($this->isAll) { @@ -107,6 +114,7 @@ public function getRecords(): Collection /** * get export bodies */ + // @phpstan-ignore-next-line protected function getBodies($records) { if (!isset($records)) { diff --git a/src/Services/DataImportExport/Providers/Export/ProviderBase.php b/src/Services/DataImportExport/Providers/Export/ProviderBase.php index d10f53c3a..75ab6663d 100644 --- a/src/Services/DataImportExport/Providers/Export/ProviderBase.php +++ b/src/Services/DataImportExport/Providers/Export/ProviderBase.php @@ -9,6 +9,7 @@ abstract class ProviderBase /** * Whether this output is as template */ + // @phpstan-ignore-next-line protected $template = false; /** @@ -29,11 +30,13 @@ public function __construct() /** * get data name */ + // @phpstan-ignore-next-line abstract public function name(); /** * get data */ + // @phpstan-ignore-next-line abstract public function data(); /** @@ -46,10 +49,12 @@ public function isOutput() return true; } + // @phpstan-ignore-next-line public function getCount() { return $this->count; } + // @phpstan-ignore-next-line abstract public function getRecords(): Collection; } diff --git a/src/Services/DataImportExport/Providers/Export/RelationPivotTableProvider.php b/src/Services/DataImportExport/Providers/Export/RelationPivotTableProvider.php index 542202a65..b6028dd62 100644 --- a/src/Services/DataImportExport/Providers/Export/RelationPivotTableProvider.php +++ b/src/Services/DataImportExport/Providers/Export/RelationPivotTableProvider.php @@ -9,10 +9,13 @@ */ class RelationPivotTableProvider extends ProviderBase { + // @phpstan-ignore-next-line protected $relation; + // @phpstan-ignore-next-line protected $grid; + // @phpstan-ignore-next-line public function __construct($args = []) { parent::__construct(); @@ -25,6 +28,7 @@ public function __construct($args = []) /** * get data name */ + // @phpstan-ignore-next-line public function name() { return $this->relation->getSheetName(); @@ -33,6 +37,7 @@ public function name() /** * get data */ + // @phpstan-ignore-next-line public function data() { // get header info @@ -69,6 +74,7 @@ protected function getColumnDefines() * get export headers * contains custom column name, column view name */ + // @phpstan-ignore-next-line protected function getHeaders($columnDefines) { // create 2 rows. @@ -91,6 +97,7 @@ protected function getHeaders($columnDefines) /** * get target chunk records */ + // @phpstan-ignore-next-line public function getRecords(): Collection { // get base records @@ -125,6 +132,7 @@ public function getRecords(): Collection /** * get export bodies */ + // @phpstan-ignore-next-line protected function getBodies($records, $columnDefines) { if (!isset($records)) { @@ -146,6 +154,7 @@ protected function getBodies($records, $columnDefines) /** * get export body items */ + // @phpstan-ignore-next-line protected function getBodyItems($record, $columns, $array_header_key = null) { $body_items = []; diff --git a/src/Services/DataImportExport/Providers/Export/RoleGroupPermissionMasterProvider.php b/src/Services/DataImportExport/Providers/Export/RoleGroupPermissionMasterProvider.php index 55f04352e..a0907e432 100644 --- a/src/Services/DataImportExport/Providers/Export/RoleGroupPermissionMasterProvider.php +++ b/src/Services/DataImportExport/Providers/Export/RoleGroupPermissionMasterProvider.php @@ -12,11 +12,13 @@ class RoleGroupPermissionMasterProvider extends RoleGroupPermissionProvider /** * get data name */ + // @phpstan-ignore-next-line public function name() { return 'role_group_permission_master'; } + // @phpstan-ignore-next-line protected function setRoleTypeFilter(&$query) { $ids = CustomTable::whereIn('table_name', SystemTableName::SYSTEM_TABLE_NAME_MASTER()) @@ -30,12 +32,14 @@ protected function getRoleGroupType(): RoleGroupType return RoleGroupType::MASTER(); } + // @phpstan-ignore-next-line protected function setHeadersOfType(array &$headers, array &$titles): void { $headers[] = "role_group_target_id"; $titles[] = exmtrans('role_group.role_group_target_table'); } + // @phpstan-ignore-next-line protected function setBodiesOfType(array &$body_items, $record): void { $body_items[] = $record->role_group_target_id; diff --git a/src/Services/DataImportExport/Providers/Export/RoleGroupPermissionPluginProvider.php b/src/Services/DataImportExport/Providers/Export/RoleGroupPermissionPluginProvider.php index 7e203914c..6b3a56b57 100644 --- a/src/Services/DataImportExport/Providers/Export/RoleGroupPermissionPluginProvider.php +++ b/src/Services/DataImportExport/Providers/Export/RoleGroupPermissionPluginProvider.php @@ -10,11 +10,13 @@ class RoleGroupPermissionPluginProvider extends RoleGroupPermissionProvider /** * get data name */ + // @phpstan-ignore-next-line public function name() { return 'role_group_permission_plugin'; } + // @phpstan-ignore-next-line protected function setRoleTypeFilter(&$query) { $query->where('role_group_permission_type', RoleType::PLUGIN); @@ -25,12 +27,14 @@ protected function getRoleGroupType(): RoleGroupType return RoleGroupType::PLUGIN(); } + // @phpstan-ignore-next-line protected function setHeadersOfType(array &$headers, array &$titles): void { $headers[] = "role_group_target_id"; $titles[] = exmtrans('role_group.role_group_target_plugin'); } + // @phpstan-ignore-next-line protected function setBodiesOfType(array &$body_items, $record): void { $body_items[] = $record->role_group_target_id; diff --git a/src/Services/DataImportExport/Providers/Export/RoleGroupPermissionProvider.php b/src/Services/DataImportExport/Providers/Export/RoleGroupPermissionProvider.php index a32f1ec57..09f1df47d 100644 --- a/src/Services/DataImportExport/Providers/Export/RoleGroupPermissionProvider.php +++ b/src/Services/DataImportExport/Providers/Export/RoleGroupPermissionProvider.php @@ -9,8 +9,10 @@ class RoleGroupPermissionProvider extends ProviderBase { + // @phpstan-ignore-next-line protected $grid; + // @phpstan-ignore-next-line public function __construct($args = []) { parent::__construct(); @@ -20,6 +22,7 @@ public function __construct($args = []) /** * get data name */ + // @phpstan-ignore-next-line public function name() { return 'role_group_permission'; @@ -28,6 +31,7 @@ public function name() /** * get data */ + // @phpstan-ignore-next-line public function data() { $headers = $this->getHeaders(); @@ -48,6 +52,7 @@ public function data() /** * get export headers */ + // @phpstan-ignore-next-line protected function getHeaders() { // create 2 rows. @@ -81,6 +86,7 @@ protected function getHeaders() /** * get target chunk records */ + // @phpstan-ignore-next-line public function getRecords(): Collection { $records = new Collection(); @@ -104,6 +110,7 @@ public function getRecords(): Collection /** * get export bodies */ + // @phpstan-ignore-next-line protected function getBodies($records) { if (!isset($records)) { @@ -145,14 +152,17 @@ protected function getBodies($records) return $bodies; } + // @phpstan-ignore-next-line protected function setHeadersOfType(array &$headers, array &$titles): void { } + // @phpstan-ignore-next-line protected function setBodiesOfType(array &$body_items, $record): void { } + // @phpstan-ignore-next-line protected function setRoleTypeFilter(&$query) { } diff --git a/src/Services/DataImportExport/Providers/Export/RoleGroupPermissionRoleProvider.php b/src/Services/DataImportExport/Providers/Export/RoleGroupPermissionRoleProvider.php index 3bc2473dc..88d48bc4e 100644 --- a/src/Services/DataImportExport/Providers/Export/RoleGroupPermissionRoleProvider.php +++ b/src/Services/DataImportExport/Providers/Export/RoleGroupPermissionRoleProvider.php @@ -10,11 +10,13 @@ class RoleGroupPermissionRoleProvider extends RoleGroupPermissionProvider /** * get data name */ + // @phpstan-ignore-next-line public function name() { return 'role_group_permission_role'; } + // @phpstan-ignore-next-line protected function setRoleTypeFilter(&$query) { $query->where('role_group_permission_type', RoleType::SYSTEM) diff --git a/src/Services/DataImportExport/Providers/Export/RoleGroupPermissionSystemProvider.php b/src/Services/DataImportExport/Providers/Export/RoleGroupPermissionSystemProvider.php index 9b9283ce8..c4839134c 100644 --- a/src/Services/DataImportExport/Providers/Export/RoleGroupPermissionSystemProvider.php +++ b/src/Services/DataImportExport/Providers/Export/RoleGroupPermissionSystemProvider.php @@ -10,11 +10,13 @@ class RoleGroupPermissionSystemProvider extends RoleGroupPermissionProvider /** * get data name */ + // @phpstan-ignore-next-line public function name() { return 'role_group_permission_system'; } + // @phpstan-ignore-next-line protected function setRoleTypeFilter(&$query) { $query->where('role_group_permission_type', RoleType::SYSTEM) diff --git a/src/Services/DataImportExport/Providers/Export/RoleGroupPermissionTableProvider.php b/src/Services/DataImportExport/Providers/Export/RoleGroupPermissionTableProvider.php index d630f818c..d93f6d280 100644 --- a/src/Services/DataImportExport/Providers/Export/RoleGroupPermissionTableProvider.php +++ b/src/Services/DataImportExport/Providers/Export/RoleGroupPermissionTableProvider.php @@ -12,11 +12,13 @@ class RoleGroupPermissionTableProvider extends RoleGroupPermissionProvider /** * get data name */ + // @phpstan-ignore-next-line public function name() { return 'role_group_permission_table'; } + // @phpstan-ignore-next-line protected function setRoleTypeFilter(&$query) { $ids = CustomTable::whereNotIn('table_name', SystemTableName::SYSTEM_TABLE_NAME_MASTER()) @@ -30,12 +32,14 @@ protected function getRoleGroupType(): RoleGroupType return RoleGroupType::TABLE(); } + // @phpstan-ignore-next-line protected function setHeadersOfType(array &$headers, array &$titles): void { $headers[] = "role_group_target_id"; $titles[] = exmtrans('role_group.role_group_target_table'); } + // @phpstan-ignore-next-line protected function setBodiesOfType(array &$body_items, $record): void { $body_items[] = $record->role_group_target_id; diff --git a/src/Services/DataImportExport/Providers/Export/RoleGroupProvider.php b/src/Services/DataImportExport/Providers/Export/RoleGroupProvider.php index f8d314234..d6acf5003 100644 --- a/src/Services/DataImportExport/Providers/Export/RoleGroupProvider.php +++ b/src/Services/DataImportExport/Providers/Export/RoleGroupProvider.php @@ -10,8 +10,10 @@ class RoleGroupProvider extends ProviderBase { + // @phpstan-ignore-next-line protected $grid; + // @phpstan-ignore-next-line public function __construct($args = []) { parent::__construct(); @@ -21,6 +23,7 @@ public function __construct($args = []) /** * get data name */ + // @phpstan-ignore-next-line public function name() { return 'role_group'; @@ -29,6 +32,7 @@ public function name() /** * get data */ + // @phpstan-ignore-next-line public function data() { $headers = $this->getHeaders(); @@ -48,6 +52,7 @@ public function data() /** * get export headers */ + // @phpstan-ignore-next-line protected function getHeaders() { // create 2 rows. @@ -79,6 +84,7 @@ protected function getHeaders() /** * get target chunk records */ + // @phpstan-ignore-next-line public function getRecords(): Collection { $records = new Collection(); @@ -96,6 +102,7 @@ public function getRecords(): Collection /** * get export bodies */ + // @phpstan-ignore-next-line protected function getBodies($records) { if (!isset($records)) { diff --git a/src/Services/DataImportExport/Providers/Export/RoleGroupUserOrganizationProvider.php b/src/Services/DataImportExport/Providers/Export/RoleGroupUserOrganizationProvider.php index 7f096611f..e39581fc6 100644 --- a/src/Services/DataImportExport/Providers/Export/RoleGroupUserOrganizationProvider.php +++ b/src/Services/DataImportExport/Providers/Export/RoleGroupUserOrganizationProvider.php @@ -8,8 +8,10 @@ class RoleGroupUserOrganizationProvider extends ProviderBase { + // @phpstan-ignore-next-line protected $grid; + // @phpstan-ignore-next-line public function __construct($args = []) { parent::__construct(); @@ -19,6 +21,7 @@ public function __construct($args = []) /** * get data name */ + // @phpstan-ignore-next-line public function name() { return 'role_group_user_organization'; @@ -27,6 +30,7 @@ public function name() /** * get data */ + // @phpstan-ignore-next-line public function data() { $headers = $this->getHeaders(); @@ -46,6 +50,7 @@ public function data() /** * get export headers */ + // @phpstan-ignore-next-line protected function getHeaders() { // create 2 rows. @@ -73,6 +78,7 @@ protected function getHeaders() /** * get target chunk records */ + // @phpstan-ignore-next-line public function getRecords(): Collection { $records = new Collection(); @@ -100,6 +106,7 @@ public function getRecords(): Collection /** * get export bodies */ + // @phpstan-ignore-next-line protected function getBodies($records) { if (!isset($records)) { diff --git a/src/Services/DataImportExport/Providers/Export/SummaryProvider.php b/src/Services/DataImportExport/Providers/Export/SummaryProvider.php index 999153114..88652ba41 100644 --- a/src/Services/DataImportExport/Providers/Export/SummaryProvider.php +++ b/src/Services/DataImportExport/Providers/Export/SummaryProvider.php @@ -4,6 +4,7 @@ class SummaryProvider extends ViewProvider { + // @phpstan-ignore-next-line protected function appendBodyItemOptions(array $options, $index) { $options['summary'] = true; diff --git a/src/Services/DataImportExport/Providers/Export/ViewProvider.php b/src/Services/DataImportExport/Providers/Export/ViewProvider.php index 11f6111ef..574959a0a 100644 --- a/src/Services/DataImportExport/Providers/Export/ViewProvider.php +++ b/src/Services/DataImportExport/Providers/Export/ViewProvider.php @@ -6,10 +6,13 @@ class ViewProvider extends DefaultTableProvider { + // @phpstan-ignore-next-line protected $custom_view; + // @phpstan-ignore-next-line protected $summary_index_and_view_columns; + // @phpstan-ignore-next-line public function __construct($args = []) { parent::__construct($args); @@ -22,6 +25,7 @@ public function __construct($args = []) /** * get data */ + // @phpstan-ignore-next-line public function data() { // get header and body @@ -43,6 +47,7 @@ public function data() * get export headers * contains custom column name, column view name */ + // @phpstan-ignore-next-line protected function getHeaders($columnDefines) { // create 2 rows. @@ -65,6 +70,7 @@ protected function getHeaders($columnDefines) /** * get target chunk records */ + // @phpstan-ignore-next-line public function getRecords(): Collection { $this->grid->applyQuickSearch(); @@ -84,6 +90,7 @@ public function getRecords(): Collection /** * get export bodies */ + // @phpstan-ignore-next-line protected function getBodies($records, $columnDefines) { if (!isset($records)) { @@ -119,6 +126,7 @@ protected function getBodies($records, $columnDefines) } + // @phpstan-ignore-next-line protected function appendBodyItemOptions(array $options, $index) { return $options; diff --git a/src/Services/DataImportExport/Providers/Import/DefaultTableProvider.php b/src/Services/DataImportExport/Providers/Import/DefaultTableProvider.php index e13184129..f739243e2 100644 --- a/src/Services/DataImportExport/Providers/Import/DefaultTableProvider.php +++ b/src/Services/DataImportExport/Providers/Import/DefaultTableProvider.php @@ -8,12 +8,16 @@ class DefaultTableProvider extends ProviderBase { + // @phpstan-ignore-next-line protected $custom_table; + // @phpstan-ignore-next-line protected $custom_columns; + // @phpstan-ignore-next-line protected $primary_key; + // @phpstan-ignore-next-line protected $filter; /** @@ -21,8 +25,10 @@ class DefaultTableProvider extends ProviderBase * * @var array */ + // @phpstan-ignore-next-line protected $selectTableNotFounds; + // @phpstan-ignore-next-line public function __construct($args = []) { $this->custom_table = array_get($args, 'custom_table'); @@ -40,6 +46,7 @@ public function __construct($args = []) * get data and object. * set matched model data */ + // @phpstan-ignore-next-line public function getDataObject($data, $options = []) { $headers = []; @@ -91,6 +98,7 @@ public function getDataObject($data, $options = []) foreach ($value_customs as $line_no => $value_custom) { $options['datalist'] = $value_customs; ///// convert data first. + // @phpstan-ignore-next-line $value_custom = $this->dataProcessingFirst($value_custom, $line_no, $options); // get model @@ -125,6 +133,7 @@ public function getDataObject($data, $options = []) * @param mixed $dataObjects * @return array */ + // @phpstan-ignore-next-line public function validateImportData($dataObjects) { if (count($this->selectTableNotFounds) > 0) { @@ -157,6 +166,7 @@ public function validateImportData($dataObjects) * @param array $dataObjects * @return array|true */ + // @phpstan-ignore-next-line public function validateDataRow($line_no, $dataAndModel, $validate_columns, $dataObjects) { $data = array_get($dataAndModel, 'data'); @@ -214,6 +224,7 @@ public function validateDataRow($line_no, $dataAndModel, $validate_columns, $dat * @param array $dataObjects * @return array */ + // @phpstan-ignore-next-line protected function getUniqueCheckParams($current_no, $dataObjects) { $siblings = []; @@ -237,6 +248,7 @@ protected function getUniqueCheckParams($current_no, $dataObjects) * @param array $data * @return array */ + // @phpstan-ignore-next-line public function dataProcessing($data) { $data_custom = []; @@ -262,6 +274,7 @@ public function dataProcessing($data) * @param array $options * @return array */ + // @phpstan-ignore-next-line public function dataProcessingFirst($data, $line_no, $options = []) { ///// convert data first. @@ -275,6 +288,7 @@ public function dataProcessingFirst($data, $line_no, $options = []) /** * import data */ + // @phpstan-ignore-next-line public function importData($dataAndModel) { $data = array_get($dataAndModel, 'data'); @@ -345,6 +359,7 @@ public function importData($dataAndModel) /** * check filter data */ + // @phpstan-ignore-next-line protected function filterData($value_custom) { $is_filter = false; diff --git a/src/Services/DataImportExport/Providers/Import/DocumentProvider.php b/src/Services/DataImportExport/Providers/Import/DocumentProvider.php index ed6e1e5f3..217907846 100644 --- a/src/Services/DataImportExport/Providers/Import/DocumentProvider.php +++ b/src/Services/DataImportExport/Providers/Import/DocumentProvider.php @@ -12,6 +12,7 @@ class DocumentProvider extends FileColumnProvider * @param mixed $dataObjects * @return array */ + // @phpstan-ignore-next-line public function validateImportData($dataObjects) { $error_data = []; @@ -35,6 +36,7 @@ public function validateImportData($dataObjects) * @param array|null $validate_columns(not use) * @param array $dataObjects */ + // @phpstan-ignore-next-line public function validateDataRow($line_no, $dataAndModel, $validate_columns, $dataObjects) { return $this->_validateDataRow($line_no, $dataAndModel, $validate_columns, false); @@ -44,6 +46,7 @@ public function validateDataRow($line_no, $dataAndModel, $validate_columns, $dat /** * import data */ + // @phpstan-ignore-next-line public function importData($dataAndModel) { $data = array_get($dataAndModel, 'data'); diff --git a/src/Services/DataImportExport/Providers/Import/FileColumnProvider.php b/src/Services/DataImportExport/Providers/Import/FileColumnProvider.php index 64e21e142..81d701e06 100644 --- a/src/Services/DataImportExport/Providers/Import/FileColumnProvider.php +++ b/src/Services/DataImportExport/Providers/Import/FileColumnProvider.php @@ -18,6 +18,7 @@ class FileColumnProvider extends ProviderBase */ protected $fileDirFullPath; + // @phpstan-ignore-next-line protected $primary_key; /** @@ -27,6 +28,7 @@ class FileColumnProvider extends ProviderBase */ protected $custom_table; + // @phpstan-ignore-next-line public function __construct($args = []) { $this->custom_table = array_get($args, 'custom_table'); @@ -38,6 +40,7 @@ public function __construct($args = []) * get data and object. * set matched model data */ + // @phpstan-ignore-next-line public function getDataObject($data, $options = []) { $headers = []; @@ -106,6 +109,7 @@ public function getDataObject($data, $options = []) * @param mixed $dataObjects * @return array */ + // @phpstan-ignore-next-line public function validateImportData($dataObjects) { ///// get all table columns @@ -116,6 +120,7 @@ public function validateImportData($dataObjects) $error_data = []; $success_data = []; foreach ($dataObjects as $line_no => $value) { + // @phpstan-ignore-next-line $check = $this->validateDataRow($line_no, $value, $validate_columns, $dataObjects); if ($check === true) { $success_data[] = $value; @@ -134,6 +139,7 @@ public function validateImportData($dataObjects) * @param array $validate_columns * @param array $dataObjects */ + // @phpstan-ignore-next-line public function validateDataRow($line_no, $dataAndModel, $validate_columns, $dataObjects) { return $this->_validateDataRow($line_no, $dataAndModel, $validate_columns, true); @@ -148,6 +154,7 @@ public function validateDataRow($line_no, $dataAndModel, $validate_columns, $dat * @param bool $isCheckColumn * @return array|mixed[]|true */ + // @phpstan-ignore-next-line protected function _validateDataRow($line_no, $dataAndModel, $validate_columns, bool $isCheckColumn) { $data = array_get($dataAndModel, 'data'); @@ -213,6 +220,7 @@ protected function _validateDataRow($line_no, $dataAndModel, $validate_columns, /** * import data */ + // @phpstan-ignore-next-line public function importData($dataAndModel) { $data = array_get($dataAndModel, 'data'); @@ -254,6 +262,7 @@ public function importData($dataAndModel) * @param array $value_custom * @return string|null */ + // @phpstan-ignore-next-line protected function getFileFullPath(array $value_custom): ?string { $file_name = array_get($value_custom, 'file_name'); diff --git a/src/Services/DataImportExport/Providers/Import/LoginUserProvider.php b/src/Services/DataImportExport/Providers/Import/LoginUserProvider.php index 4992851d7..41dc70398 100644 --- a/src/Services/DataImportExport/Providers/Import/LoginUserProvider.php +++ b/src/Services/DataImportExport/Providers/Import/LoginUserProvider.php @@ -10,8 +10,10 @@ class LoginUserProvider extends ProviderBase { + // @phpstan-ignore-next-line protected $primary_key; + // @phpstan-ignore-next-line public function __construct($args = []) { $this->primary_key = array_get($args, 'primary_key', 'id'); @@ -21,6 +23,7 @@ public function __construct($args = []) * get data and object. * set matched model data */ + // @phpstan-ignore-next-line public function getDataObject($data, $options = []) { $results = []; @@ -61,6 +64,7 @@ public function getDataObject($data, $options = []) // if exists, firstOrNew else { //*Replace "." to "->" for json value + // @phpstan-ignore-next-line $model = $modelName::withTrashed()->firstOrNew([str_replace(".", "->", $this->primary_key) => $primary_value]); } if (!isset($model)) { @@ -80,6 +84,7 @@ public function getDataObject($data, $options = []) * @param mixed $dataObjects * @return array */ + // @phpstan-ignore-next-line public function validateImportData($dataObjects) { $error_data = []; @@ -103,6 +108,7 @@ public function validateImportData($dataObjects) * @param $dataAndModel * @return array|true */ + // @phpstan-ignore-next-line public function validateDataRow($line_no, $dataAndModel) { $data = array_get($dataAndModel, 'data'); @@ -142,6 +148,7 @@ public function validateDataRow($line_no, $dataAndModel) /** * import data */ + // @phpstan-ignore-next-line public function importData($dataAndModel) { $data = array_get($dataAndModel, 'data'); diff --git a/src/Services/DataImportExport/Providers/Import/ProviderBase.php b/src/Services/DataImportExport/Providers/Import/ProviderBase.php index 50cbf31f9..3d2988228 100644 --- a/src/Services/DataImportExport/Providers/Import/ProviderBase.php +++ b/src/Services/DataImportExport/Providers/Import/ProviderBase.php @@ -11,6 +11,7 @@ abstract class ProviderBase * @param array $options * @return boolean */ + // @phpstan-ignore-next-line protected function isReadRow(int $row_no, array $options = []): bool { // get options @@ -38,16 +39,19 @@ protected function isReadRow(int $row_no, array $options = []): bool /** * get data object */ + // @phpstan-ignore-next-line abstract public function getDataObject($data, $options = []); /** * validate Import Data. * @return array please return 2 columns array. 1st success data array, 2nd error array. */ + // @phpstan-ignore-next-line abstract public function validateImportData($dataObjects); /** * import data */ + // @phpstan-ignore-next-line abstract public function importdata($data); } diff --git a/src/Services/DataImportExport/Providers/Import/RelationPivotTableProvider.php b/src/Services/DataImportExport/Providers/Import/RelationPivotTableProvider.php index 246547542..c03b50427 100644 --- a/src/Services/DataImportExport/Providers/Import/RelationPivotTableProvider.php +++ b/src/Services/DataImportExport/Providers/Import/RelationPivotTableProvider.php @@ -7,8 +7,10 @@ */ class RelationPivotTableProvider extends ProviderBase { + // @phpstan-ignore-next-line protected $relation; + // @phpstan-ignore-next-line public function __construct($args = []) { $this->relation = array_get($args, 'relation'); @@ -17,6 +19,7 @@ public function __construct($args = []) /** * get pivot data for n:n */ + // @phpstan-ignore-next-line public function getDataObject($data, $options = []) { $results = []; @@ -60,6 +63,7 @@ public function getDataObject($data, $options = []) * @param mixed $dataObjects * @return array */ + // @phpstan-ignore-next-line public function validateImportData($dataObjects) { return [$dataObjects, null]; @@ -68,6 +72,7 @@ public function validateImportData($dataObjects) /** * import data (n:n relation) */ + // @phpstan-ignore-next-line public function importdata($dataPivot) { $data = array_get($dataPivot, 'data'); diff --git a/src/Services/DataImportExport/Providers/Import/RoleGroupPermissionMasterProvider.php b/src/Services/DataImportExport/Providers/Import/RoleGroupPermissionMasterProvider.php index ddeca1005..3aa422f40 100644 --- a/src/Services/DataImportExport/Providers/Import/RoleGroupPermissionMasterProvider.php +++ b/src/Services/DataImportExport/Providers/Import/RoleGroupPermissionMasterProvider.php @@ -18,6 +18,7 @@ public function __construct() /** * get data name */ + // @phpstan-ignore-next-line public function name() { return 'role_group_permission_master'; @@ -28,6 +29,7 @@ public function name() * * @param $rules */ + // @phpstan-ignore-next-line protected function addValidateTypeRules(&$rules) : void { $ids = CustomTable::whereIn('table_name', SystemTableName::SYSTEM_TABLE_NAME_MASTER())->pluck('id')->toArray(); diff --git a/src/Services/DataImportExport/Providers/Import/RoleGroupPermissionPluginProvider.php b/src/Services/DataImportExport/Providers/Import/RoleGroupPermissionPluginProvider.php index cea8a0385..40d8b373b 100644 --- a/src/Services/DataImportExport/Providers/Import/RoleGroupPermissionPluginProvider.php +++ b/src/Services/DataImportExport/Providers/Import/RoleGroupPermissionPluginProvider.php @@ -18,6 +18,7 @@ public function __construct() /** * get data name */ + // @phpstan-ignore-next-line public function name() { return 'role_group_permission_plugin'; @@ -28,6 +29,7 @@ public function name() * * @param $rules */ + // @phpstan-ignore-next-line protected function addValidateTypeRules(&$rules) : void { $model = new Plugin(); @@ -41,11 +43,13 @@ protected function addValidateTypeRules(&$rules) : void * @param int $line_no * @param array $errors */ + // @phpstan-ignore-next-line protected function validateExtraRules($data, $line_no, &$errors) : void { $role_group_target_id = array_get($data, 'role_group_target_id'); $plugin_access = array_get($data, 'permissions:plugin_access'); $plugin = Plugin::find($role_group_target_id); + // @phpstan-ignore-next-line $enabledPluginAccess = collect($plugin->plugin_types)->contains(function ($plugin_type) { return in_array($plugin_type, PluginType::PLUGIN_TYPE_FILTER_ACCESSIBLE()); }); diff --git a/src/Services/DataImportExport/Providers/Import/RoleGroupPermissionProvider.php b/src/Services/DataImportExport/Providers/Import/RoleGroupPermissionProvider.php index dd646d60d..a3c61d03f 100644 --- a/src/Services/DataImportExport/Providers/Import/RoleGroupPermissionProvider.php +++ b/src/Services/DataImportExport/Providers/Import/RoleGroupPermissionProvider.php @@ -10,13 +10,17 @@ class RoleGroupPermissionProvider extends ProviderBase { + // @phpstan-ignore-next-line protected $role_group_permission_type = 0; + // @phpstan-ignore-next-line protected $role_group_target_id; + // @phpstan-ignore-next-line protected $permission_keys = []; /** * get data name */ + // @phpstan-ignore-next-line public function name() { return ''; @@ -26,6 +30,7 @@ public function name() * get data and object. * set matched model data */ + // @phpstan-ignore-next-line public function getDataObject($data, $options = []) { $results = []; @@ -66,6 +71,7 @@ public function getDataObject($data, $options = []) * @param mixed $dataObjects * @return array */ + // @phpstan-ignore-next-line public function validateImportData($dataObjects) { $error_data = []; @@ -89,6 +95,7 @@ public function validateImportData($dataObjects) * @param $dataAndModel * @return array|true */ + // @phpstan-ignore-next-line public function validateDataRow($line_no, $dataAndModel) { $data = array_get($dataAndModel, 'data'); @@ -129,6 +136,7 @@ public function validateDataRow($line_no, $dataAndModel) * * @param array $rules */ + // @phpstan-ignore-next-line protected function addValidateTypeRules(&$rules) : void { } @@ -140,6 +148,7 @@ protected function addValidateTypeRules(&$rules) : void * @param int $line_no * @param array $errors */ + // @phpstan-ignore-next-line protected function validateExtraRules($data, $line_no, &$errors) : void { } @@ -147,6 +156,7 @@ protected function validateExtraRules($data, $line_no, &$errors) : void /** * import data */ + // @phpstan-ignore-next-line public function importData($dataAndModel) { $data = array_get($dataAndModel, 'data'); @@ -189,6 +199,7 @@ public function importData($dataAndModel) return $model; } + // @phpstan-ignore-next-line protected function getPermissions(int|string $role_type, array $values) { $result = []; @@ -214,6 +225,7 @@ protected function getPermissions(int|string $role_type, array $values) return $result; } + // @phpstan-ignore-next-line protected function getTargetRoleGroupType($role_type) { switch ($role_type) { diff --git a/src/Services/DataImportExport/Providers/Import/RoleGroupPermissionRoleProvider.php b/src/Services/DataImportExport/Providers/Import/RoleGroupPermissionRoleProvider.php index fe88c8b42..9beffe0ff 100644 --- a/src/Services/DataImportExport/Providers/Import/RoleGroupPermissionRoleProvider.php +++ b/src/Services/DataImportExport/Providers/Import/RoleGroupPermissionRoleProvider.php @@ -15,6 +15,7 @@ public function __construct() /** * get data name */ + // @phpstan-ignore-next-line public function name() { return 'role_group_permission_role'; diff --git a/src/Services/DataImportExport/Providers/Import/RoleGroupPermissionSystemProvider.php b/src/Services/DataImportExport/Providers/Import/RoleGroupPermissionSystemProvider.php index 4fd3dd190..6799e71c1 100644 --- a/src/Services/DataImportExport/Providers/Import/RoleGroupPermissionSystemProvider.php +++ b/src/Services/DataImportExport/Providers/Import/RoleGroupPermissionSystemProvider.php @@ -20,6 +20,7 @@ public function __construct() /** * get data name */ + // @phpstan-ignore-next-line public function name() { return 'role_group_permission_system'; diff --git a/src/Services/DataImportExport/Providers/Import/RoleGroupPermissionTableProvider.php b/src/Services/DataImportExport/Providers/Import/RoleGroupPermissionTableProvider.php index 204fa4f9f..784625ddd 100644 --- a/src/Services/DataImportExport/Providers/Import/RoleGroupPermissionTableProvider.php +++ b/src/Services/DataImportExport/Providers/Import/RoleGroupPermissionTableProvider.php @@ -18,6 +18,7 @@ public function __construct() /** * get data name */ + // @phpstan-ignore-next-line public function name() { return 'role_group_permission_table'; @@ -29,6 +30,7 @@ public function name() * * @param $rules */ + // @phpstan-ignore-next-line protected function addValidateTypeRules(&$rules) : void { $ids = CustomTable::whereIn('table_name', SystemTableName::SYSTEM_TABLE_NAME_MASTER())->pluck('id')->toArray(); diff --git a/src/Services/DataImportExport/Providers/Import/RoleGroupProvider.php b/src/Services/DataImportExport/Providers/Import/RoleGroupProvider.php index 6e84a5c7d..4274802df 100644 --- a/src/Services/DataImportExport/Providers/Import/RoleGroupProvider.php +++ b/src/Services/DataImportExport/Providers/Import/RoleGroupProvider.php @@ -13,8 +13,10 @@ class RoleGroupProvider extends ProviderBase { + // @phpstan-ignore-next-line protected $primary_key; + // @phpstan-ignore-next-line public function __construct($args = []) { $this->primary_key = array_get($args, 'primary_key', 'id'); @@ -23,6 +25,7 @@ public function __construct($args = []) /** * get data name */ + // @phpstan-ignore-next-line public function name() { return 'role_group'; @@ -32,6 +35,7 @@ public function name() * get data and object. * set matched model data */ + // @phpstan-ignore-next-line public function getDataObject($data, $options = []) { $results = []; @@ -69,6 +73,7 @@ public function getDataObject($data, $options = []) return $results; } + // @phpstan-ignore-next-line protected function getImportColumnName(): array { return [ @@ -85,6 +90,7 @@ protected function getImportColumnName(): array * @param mixed $dataObjects * @return array */ + // @phpstan-ignore-next-line public function validateImportData($dataObjects) { $error_data = []; @@ -136,6 +142,7 @@ public function validateImportData($dataObjects) * @param $dataAndModel * @return array|true */ + // @phpstan-ignore-next-line public function validateDataRow($line_no, $dataAndModel) { $data = array_get($dataAndModel, 'data'); @@ -171,6 +178,7 @@ public function validateDataRow($line_no, $dataAndModel) /** * import data */ + // @phpstan-ignore-next-line public function importData($dataAndModel) { $data = array_get($dataAndModel, 'data'); @@ -190,6 +198,7 @@ public function importData($dataAndModel) } if ($delete) { + // @phpstan-ignore-next-line return $model->delete(); } @@ -206,6 +215,7 @@ public function importData($dataAndModel) $model->{$dkey} = $dvalue; } + // @phpstan-ignore-next-line return $model->save(); } } diff --git a/src/Services/DataImportExport/Providers/Import/RoleGroupUserOrganizationProvider.php b/src/Services/DataImportExport/Providers/Import/RoleGroupUserOrganizationProvider.php index 39f048619..5e8644e7f 100644 --- a/src/Services/DataImportExport/Providers/Import/RoleGroupUserOrganizationProvider.php +++ b/src/Services/DataImportExport/Providers/Import/RoleGroupUserOrganizationProvider.php @@ -13,6 +13,7 @@ class RoleGroupUserOrganizationProvider extends ProviderBase /** * get data name */ + // @phpstan-ignore-next-line public function name() { return 'role_group_user_organization'; @@ -22,6 +23,7 @@ public function name() * get data and object. * set matched model data */ + // @phpstan-ignore-next-line public function getDataObject($data, $options = []) { $results = []; @@ -65,6 +67,7 @@ public function getDataObject($data, $options = []) * @param mixed $dataObjects * @return array */ + // @phpstan-ignore-next-line public function validateImportData($dataObjects) { $error_data = []; @@ -88,6 +91,7 @@ public function validateImportData($dataObjects) * @param $dataAndModel * @return array|true */ + // @phpstan-ignore-next-line public function validateDataRow($line_no, $dataAndModel) { $data = array_get($dataAndModel, 'data'); @@ -126,6 +130,7 @@ public function validateDataRow($line_no, $dataAndModel) /** * import data */ + // @phpstan-ignore-next-line public function importData($dataPivot) { $data = array_get($dataPivot, 'data'); @@ -146,6 +151,7 @@ public function importData($dataPivot) // if delete if ($delete) { if (isset($id)) { + // @phpstan-ignore-next-line RoleGroupUserOrganization::find($id)->delete(); } return; diff --git a/src/Services/DocumentExcelService.php b/src/Services/DocumentExcelService.php index 0440a1dd3..fac55f9c8 100644 --- a/src/Services/DocumentExcelService.php +++ b/src/Services/DocumentExcelService.php @@ -12,19 +12,25 @@ class DocumentExcelService { - /** - * - */ + /** @var mixed */ protected $baseInfo; + + /** @var string */ protected $templateFileFullPath; + + /** @var string */ protected $outputfilename; + + /** @var string|null */ protected $filename; + + /** @var string|null */ protected $uniqueFileName; /** * Image setted disk services * - * @var array + * @var array */ protected $diskServies = []; @@ -130,6 +136,7 @@ public function makeExcel() /** * Write Table */ + // @phpstan-ignore-next-line protected function lfTable($sheet) { // first time, define loop value @@ -230,6 +237,7 @@ protected function lfTable($sheet) /** * Write default value */ + // @phpstan-ignore-next-line protected function lfValue($sheet) { // first time, define loop value @@ -246,6 +254,7 @@ protected function lfValue($sheet) }); } + // @phpstan-ignore-next-line protected function callbackSheetCell($sheet, $callback) { foreach ($sheet->getRowIterator() as $row) { @@ -271,6 +280,7 @@ protected function callbackSheetCell($sheet, $callback) /** * get output text from document item */ + // @phpstan-ignore-next-line protected function getText($text, $options = [], $model = null) { $options['disable_currency_symbol'] = true; @@ -301,10 +311,12 @@ protected function getText($text, $options = [], $model = null) /** * replace text. ex.comma, ¥, etc... */ + // @phpstan-ignore-next-line protected function replaceText($text, $documentItem = []) { // add comma if number_format if (array_key_exists('number_format', $documentItem) && !str_contains($text, ',') && is_numeric($text)) { + // @phpstan-ignore-next-line $text = number_format($text); } @@ -399,6 +411,7 @@ protected function getFullPathTmp() * * @return void */ + // @phpstan-ignore-next-line protected function saveFile($writer) { // save file to local @@ -423,6 +436,7 @@ protected function saveFile($writer) * @param string|null $path * @return Drawing|null */ + // @phpstan-ignore-next-line protected function getImage(?string $path, $matchOptions) { $diskService = new AdminDiskService($path); diff --git a/src/Services/EnvService.php b/src/Services/EnvService.php index 2050540aa..76bded3c7 100644 --- a/src/Services/EnvService.php +++ b/src/Services/EnvService.php @@ -7,6 +7,7 @@ */ class EnvService { + // @phpstan-ignore-next-line public static function setEnv($data = [], $matchRemove = false) { if (empty($data)) { @@ -20,13 +21,14 @@ public static function setEnv($data = [], $matchRemove = false) // Loop through .env-data + // @phpstan-ignore-next-line foreach ($env as $env_value) { // Turn the value into an array and stop after the first split // So it's not possible to split e.g. the App-Key by accident $entry = explode("=", $env_value, 2); - /** @phpstan-ignore-next-line If condition is always false. */ + // @phpstan-ignore-next-line if (count($entry) == 0) { $newEnvs[] = $entry; continue; @@ -86,6 +88,7 @@ protected static function convertEnvValue($value) return $value; } + // @phpstan-ignore-next-line public static function removeEnv($data = []) { if (empty($data)) { @@ -94,6 +97,7 @@ public static function removeEnv($data = []) static::setEnv($data, true); } + // @phpstan-ignore-next-line public static function getEnv($key, $path = null, $matchPrefix = false) { if (empty($key)) { @@ -123,7 +127,7 @@ public static function getEnv($key, $path = null, $matchPrefix = false) // So it's not possible to split e.g. the App-Key by accident $entry = array_map('trim', explode("=", $env_value, 2)); - /** @phpstan-ignore-next-line If condition is always false. */ + // @phpstan-ignore-next-line if (count($entry) == 0) { continue; } diff --git a/src/Services/FormHelper.php b/src/Services/FormHelper.php index ac110fef9..7e182e7f8 100644 --- a/src/Services/FormHelper.php +++ b/src/Services/FormHelper.php @@ -15,6 +15,13 @@ class FormHelper /** * Get form field. be called by value form, importer. * + * @param mixed $custom_table + * @param mixed $column + * @param mixed $custom_value_or_id + * @param mixed $form_column + * @param mixed $column_name_prefix + * @param bool $validate + * @return mixed * @deprecated Please use getFormFieldObj. */ public static function getFormField($custom_table, $column, $custom_value_or_id = null, $form_column = null, $column_name_prefix = null, $validate = false) @@ -26,6 +33,7 @@ public static function getFormField($custom_table, $column, $custom_value_or_id $column_item = isset($form_column) ? $form_column->column_item : $column->column_item; if ($custom_value_or_id instanceof CustomValue && method_exists($column_item, 'setCustomValue')) { + // @phpstan-ignore-next-line $column_item->setCustomValue($custom_value_or_id); } else { $column_item->id($custom_value_or_id); @@ -36,6 +44,11 @@ public static function getFormField($custom_table, $column, $custom_value_or_id /** * Get form field. be called by value form, importer. + * + * @param CustomTable $custom_table + * @param CustomColumn $column + * @param array $options + * @return mixed */ public static function getFormFieldObj(CustomTable $custom_table, CustomColumn $column, array $options = []) { @@ -58,6 +71,7 @@ public static function getFormFieldObj(CustomTable $custom_table, CustomColumn $ $column_item = isset($form_column) ? $form_column->column_item : $column->column_item; if ($custom_value_or_id instanceof CustomValue && method_exists($column_item, 'setCustomValue')) { + // @phpstan-ignore-next-line $column_item->setCustomValue($custom_value_or_id); } else { $column_item->id($custom_value_or_id); diff --git a/src/Services/FormSetting/FormBlock/BlockBase.php b/src/Services/FormSetting/FormBlock/BlockBase.php index 3e0ec3770..77e0e13fe 100644 --- a/src/Services/FormSetting/FormBlock/BlockBase.php +++ b/src/Services/FormSetting/FormBlock/BlockBase.php @@ -37,6 +37,7 @@ abstract class BlockBase * FormColumn list * @var Collection */ + // @phpstan-ignore-next-line protected $custom_form_column_items; @@ -70,6 +71,7 @@ public static function make(CustomFormBlock $custom_form_block, CustomTable $cus * * @return self */ + // @phpstan-ignore-next-line public static function makeByParams($form_block_type, $form_block_target_table_id): BlockBase { $form_block = new CustomFormBlock(); @@ -117,6 +119,7 @@ public function getCustomTable() * * @return array */ + // @phpstan-ignore-next-line public function getItemsForDisplay(): array { return [ @@ -140,6 +143,7 @@ public function getItemsForDisplay(): array * * @return Collection */ + // @phpstan-ignore-next-line public function getSuggestItems() { $suggests = collect(); @@ -191,6 +195,7 @@ public function getSuggestItems() * * @return Collection */ + // @phpstan-ignore-next-line public function getFormColumns(): Collection { // get custom_form_blocks from request @@ -235,8 +240,10 @@ protected function getHtmlHeaderName() * * @return self */ + // @phpstan-ignore-next-line public function setCustomFormColumnItems(Collection|\Tightenco\Collect\Support\Collection $custom_form_column_items) { + // @phpstan-ignore-next-line $this->custom_form_column_items = $custom_form_column_items; return $this; @@ -248,6 +255,7 @@ public function setCustomFormColumnItems(Collection|\Tightenco\Collect\Support\C * * @return Collection|\Tightenco\Collect\Support\Collection */ + // @phpstan-ignore-next-line public function getCustomFormRows() { // grouping row_no and column_no; @@ -310,6 +318,7 @@ public function getCustomFormRows() * * @return boolean */ + // @phpstan-ignore-next-line protected function hasCustomForms($suggest_form_column_type, $suggest_form_column_target_id) { $has_custom_forms = false; @@ -325,5 +334,6 @@ protected function hasCustomForms($suggest_form_column_type, $suggest_form_colum }); } + // @phpstan-ignore-next-line abstract public static function getBlockLabelHeader(CustomTable $custom_table); } diff --git a/src/Services/FormSetting/FormBlock/DefaultBlock.php b/src/Services/FormSetting/FormBlock/DefaultBlock.php index c512de184..d495058c0 100644 --- a/src/Services/FormSetting/FormBlock/DefaultBlock.php +++ b/src/Services/FormSetting/FormBlock/DefaultBlock.php @@ -10,6 +10,7 @@ */ class DefaultBlock extends BlockBase { + // @phpstan-ignore-next-line public static function getBlockLabelHeader(CustomTable $custom_table) { return exmtrans('custom_form.table_default_label') . $custom_table->table_view_name; diff --git a/src/Services/FormSetting/FormBlock/ManyToMany.php b/src/Services/FormSetting/FormBlock/ManyToMany.php index 86ba01e0c..80eded49d 100644 --- a/src/Services/FormSetting/FormBlock/ManyToMany.php +++ b/src/Services/FormSetting/FormBlock/ManyToMany.php @@ -9,6 +9,7 @@ */ class ManyToMany extends RelationBase { + // @phpstan-ignore-next-line public static function getBlockLabelHeader(CustomTable $custom_table) { return exmtrans('custom_form.table_many_to_many_label') . $custom_table->table_view_name; @@ -20,6 +21,7 @@ public static function getBlockLabelHeader(CustomTable $custom_table) * * @return Collection */ + // @phpstan-ignore-next-line public function getSuggestItems() { //return empty collection diff --git a/src/Services/FormSetting/FormBlock/OneToMany.php b/src/Services/FormSetting/FormBlock/OneToMany.php index 4af9553c4..25b67ff01 100644 --- a/src/Services/FormSetting/FormBlock/OneToMany.php +++ b/src/Services/FormSetting/FormBlock/OneToMany.php @@ -8,6 +8,7 @@ */ class OneToMany extends RelationBase { + // @phpstan-ignore-next-line public static function getBlockLabelHeader(CustomTable $custom_table) { return exmtrans('custom_form.table_one_to_many_label') . $custom_table->table_view_name; diff --git a/src/Services/FormSetting/FormBlock/RelationBase.php b/src/Services/FormSetting/FormBlock/RelationBase.php index aff2e6607..b7467d141 100644 --- a/src/Services/FormSetting/FormBlock/RelationBase.php +++ b/src/Services/FormSetting/FormBlock/RelationBase.php @@ -16,6 +16,7 @@ abstract class RelationBase extends BlockBase */ protected $custom_relation; + // @phpstan-ignore-next-line protected function setCustomRelation(CustomRelation $custom_relation) { $this->custom_relation = $custom_relation; @@ -46,7 +47,7 @@ public static function getDefaultBlock(CustomTable $custom_table, CustomRelation 'form_block_order' => 0 ]; - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line return BlockBase::make($block, $custom_table)->setCustomRelation($custom_relation); } } diff --git a/src/Services/FormSetting/FormColumn/Column.php b/src/Services/FormSetting/FormColumn/Column.php index 18adb6554..0d08b1e67 100644 --- a/src/Services/FormSetting/FormColumn/Column.php +++ b/src/Services/FormSetting/FormColumn/Column.php @@ -89,6 +89,7 @@ public function isRequired(): bool * * @return array */ + // @phpstan-ignore-next-line public function prepareSavingOptions(array $options): array { // convert field_showing_type @@ -106,6 +107,7 @@ public function prepareSavingOptions(array $options): array * * @return array */ + // @phpstan-ignore-next-line protected function prepareSavingOptionsKeys() { return [ @@ -131,6 +133,7 @@ protected function prepareSavingOptionsKeys() * @param array $options * @return string */ + // @phpstan-ignore-next-line protected function convertFieldDisplayType(array $options): ?string { foreach (['view_only','read_only','hidden','internal'] as $key) { @@ -148,6 +151,7 @@ protected function convertFieldDisplayType(array $options): ?string * * @return WidgetForm */ + // @phpstan-ignore-next-line public function getSettingModalForm(BlockBase $block_item, array $parameters): WidgetForm { $form = new WidgetForm($parameters); @@ -236,6 +240,7 @@ public function getSettingModalForm(BlockBase $block_item, array $parameters): W * * @return Collection */ + // @phpstan-ignore-next-line protected function getSelectTableColumns(BlockBase $block_item): Collection { if (!isset($this->custom_column)) { @@ -263,6 +268,7 @@ protected function getSelectTableColumns(BlockBase $block_item): Collection $target_table = $custom_column->select_target_table; if (!isset($target_table)) { /** @var Collection $collection */ + // @phpstan-ignore-next-line $collection = collect($result); return $collection; } @@ -281,6 +287,7 @@ protected function getSelectTableColumns(BlockBase $block_item): Collection } /** @var Collection $collection */ + // @phpstan-ignore-next-line $collection = collect($result); return $collection; } diff --git a/src/Services/FormSetting/FormColumn/ColumnBase.php b/src/Services/FormSetting/FormColumn/ColumnBase.php index 2ef082d73..b887664cf 100644 --- a/src/Services/FormSetting/FormColumn/ColumnBase.php +++ b/src/Services/FormSetting/FormColumn/ColumnBase.php @@ -51,6 +51,7 @@ public static function make(CustomFormColumn $custom_form_column): ?ColumnBase * * @return self */ + // @phpstan-ignore-next-line public static function makeByParams($form_column_type, $form_column_target_id, $header_column_name = null): ColumnBase { $form_column = new CustomFormColumn(); @@ -83,6 +84,7 @@ public function getCustomFormColumn() * * @return array */ + // @phpstan-ignore-next-line public function getItemsForDisplay(): array { return [ @@ -113,6 +115,7 @@ public function getItemsForDisplay(): array + // @phpstan-ignore-next-line public function isSelected(bool $isSelected) { $this->isSelected = $isSelected; @@ -143,6 +146,7 @@ public function isSelectTable(): bool * * @return array */ + // @phpstan-ignore-next-line public function getOptionLabels(): array { $options = $this->custom_form_column->options ?? []; @@ -180,6 +184,7 @@ public function getOptionLabels(): array * * @return array */ + // @phpstan-ignore-next-line public function getOptionLabelsDefinitions(): array { $result = []; @@ -220,6 +225,7 @@ abstract public function getFontAwesomeClass(): ?string; * * @return array */ + // @phpstan-ignore-next-line public function getValidationRules(): array { return []; @@ -247,6 +253,7 @@ abstract public function isRequired(): bool; * @param array $parameters * @return WidgetForm|null */ + // @phpstan-ignore-next-line abstract public function getSettingModalForm(BlockBase $block_item, array $parameters): ?WidgetForm; /** @@ -254,5 +261,6 @@ abstract public function getSettingModalForm(BlockBase $block_item, array $param * * @return array */ + // @phpstan-ignore-next-line abstract public function prepareSavingOptions(array $options): array; } diff --git a/src/Services/FormSetting/FormColumn/Explain.php b/src/Services/FormSetting/FormColumn/Explain.php index f044cde6e..324af46d1 100644 --- a/src/Services/FormSetting/FormColumn/Explain.php +++ b/src/Services/FormSetting/FormColumn/Explain.php @@ -14,6 +14,7 @@ class Explain extends Header * * @return WidgetForm */ + // @phpstan-ignore-next-line public function getSettingModalForm(BlockBase $block_item, array $parameters): WidgetForm { $form = new WidgetForm($parameters); diff --git a/src/Services/FormSetting/FormColumn/Header.php b/src/Services/FormSetting/FormColumn/Header.php index 1d25d3121..ba8c2d7ae 100644 --- a/src/Services/FormSetting/FormColumn/Header.php +++ b/src/Services/FormSetting/FormColumn/Header.php @@ -14,6 +14,7 @@ class Header extends OtherBase * * @return WidgetForm */ + // @phpstan-ignore-next-line public function getSettingModalForm(BlockBase $block_item, array $parameters): WidgetForm { $form = new WidgetForm($parameters); @@ -33,6 +34,7 @@ public function getSettingModalForm(BlockBase $block_item, array $parameters): W * * @return array */ + // @phpstan-ignore-next-line public function prepareSavingOptions(array $options): array { return array_filter($options, function ($option, $key) { @@ -48,6 +50,7 @@ public function prepareSavingOptions(array $options): array * * @return array */ + // @phpstan-ignore-next-line public function getValidationRules(): array { return ['text' => 'required']; diff --git a/src/Services/FormSetting/FormColumn/Hr.php b/src/Services/FormSetting/FormColumn/Hr.php index a0aac795c..ebf00e6c0 100644 --- a/src/Services/FormSetting/FormColumn/Hr.php +++ b/src/Services/FormSetting/FormColumn/Hr.php @@ -16,6 +16,7 @@ class Hr extends OtherBase * @param array $parameters * @return WidgetForm|null */ + // @phpstan-ignore-next-line public function getSettingModalForm(BlockBase $block_item, array $parameters): ?WidgetForm { return null; @@ -27,6 +28,7 @@ public function getSettingModalForm(BlockBase $block_item, array $parameters): ? * @param array $options * @return array */ + // @phpstan-ignore-next-line public function prepareSavingOptions(array $options): array { return []; diff --git a/src/Services/FormSetting/FormColumn/Html.php b/src/Services/FormSetting/FormColumn/Html.php index e95128d89..29112907d 100644 --- a/src/Services/FormSetting/FormColumn/Html.php +++ b/src/Services/FormSetting/FormColumn/Html.php @@ -14,6 +14,7 @@ class Html extends OtherBase * * @return WidgetForm */ + // @phpstan-ignore-next-line public function getSettingModalForm(BlockBase $block_item, array $parameters): WidgetForm { $form = new WidgetForm($parameters); @@ -32,6 +33,7 @@ public function getSettingModalForm(BlockBase $block_item, array $parameters): W * @param array $options * @return array */ + // @phpstan-ignore-next-line public function prepareSavingOptions(array $options): array { return array_filter($options, function ($option, $key) { @@ -46,6 +48,7 @@ public function prepareSavingOptions(array $options): array * * @return array */ + // @phpstan-ignore-next-line public function getValidationRules(): array { return ['html' => 'required']; diff --git a/src/Services/FormSetting/FormColumn/Image.php b/src/Services/FormSetting/FormColumn/Image.php index 06bb9c1dd..1898b86a2 100644 --- a/src/Services/FormSetting/FormColumn/Image.php +++ b/src/Services/FormSetting/FormColumn/Image.php @@ -15,6 +15,7 @@ class Image extends OtherBase * * @return WidgetForm */ + // @phpstan-ignore-next-line public function getSettingModalForm(BlockBase $block_item, array $parameters): WidgetForm { $form = new WidgetForm($parameters); @@ -44,12 +45,14 @@ public function getSettingModalForm(BlockBase $block_item, array $parameters): W * * @return array */ + // @phpstan-ignore-next-line public function getItemsForDisplay(): array { $result = parent::getItemsForDisplay(); // set image url for option $options = json_decode_ex($result['options'], true); + // @phpstan-ignore-next-line $options['image_url'] = $this->getImageUrl(); $result['options'] = collect($options)->toJson(); return $result; @@ -75,6 +78,7 @@ protected function getImageUrl(): ?string * @param array $options * @return array */ + // @phpstan-ignore-next-line public function prepareSavingOptions(array $options): array { return array_filter($options, function ($option, $key) { @@ -89,6 +93,7 @@ public function prepareSavingOptions(array $options): array * * @return array */ + // @phpstan-ignore-next-line public function getValidationRules(): array { return ['image' => 'required_image']; @@ -104,6 +109,7 @@ public function getFontAwesomeClass(): ?string * * @return array */ + // @phpstan-ignore-next-line public function getOptionLabels(): array { $result = parent::getOptionLabels(); diff --git a/src/Services/FormSetting/FormColumn/OtherBase.php b/src/Services/FormSetting/FormColumn/OtherBase.php index 2291a2610..b8a460388 100644 --- a/src/Services/FormSetting/FormColumn/OtherBase.php +++ b/src/Services/FormSetting/FormColumn/OtherBase.php @@ -37,6 +37,7 @@ public static function make(CustomFormColumn $custom_form_column): ?ColumnBase * @param $form_column_type_id * @return ColumnBase */ + // @phpstan-ignore-next-line public static function makeBySuggest($form_column_type_id): ColumnBase { $form_column = new CustomFormColumn(); @@ -76,6 +77,7 @@ public function isRequired(): bool * @param array $parameters * @return WidgetForm|null */ + // @phpstan-ignore-next-line public function getSettingModalForm(BlockBase $block_item, array $parameters): ?WidgetForm { $form = new WidgetForm($parameters); @@ -88,6 +90,7 @@ public function getSettingModalForm(BlockBase $block_item, array $parameters): ? * * @return array */ + // @phpstan-ignore-next-line public function prepareSavingOptions(array $options): array { return $options; @@ -99,6 +102,7 @@ public function prepareSavingOptions(array $options): array * * @return array */ + // @phpstan-ignore-next-line public function getOptionLabels(): array { $options = $this->custom_form_column->options ?? []; @@ -121,6 +125,7 @@ public function getOptionLabels(): array * * @return array */ + // @phpstan-ignore-next-line public function getOptionLabelsDefinitions(): array { $result = []; diff --git a/src/Services/FormSetting/FormColumn/SelectTable.php b/src/Services/FormSetting/FormColumn/SelectTable.php index 73faea6bd..4d97afa86 100644 --- a/src/Services/FormSetting/FormColumn/SelectTable.php +++ b/src/Services/FormSetting/FormColumn/SelectTable.php @@ -22,6 +22,7 @@ public function isSelectTable(): bool * * @return array */ + // @phpstan-ignore-next-line protected function prepareSavingOptionsKeys() { return array_merge(parent::prepareSavingOptionsKeys(), [ @@ -36,6 +37,7 @@ protected function prepareSavingOptionsKeys() * * @return WidgetForm */ + // @phpstan-ignore-next-line public function getSettingModalForm(BlockBase $block_item, array $parameters): WidgetForm { $form = parent::getSettingModalForm($block_item, $parameters); @@ -61,6 +63,7 @@ public function getSettingModalForm(BlockBase $block_item, array $parameters): W * * @return Collection */ + // @phpstan-ignore-next-line public function getRelationFileterColumns(): Collection { // get relation columns. diff --git a/src/Services/Helpers.php b/src/Services/Helpers.php index 47ac02f25..5d0db8269 100644 --- a/src/Services/Helpers.php +++ b/src/Services/Helpers.php @@ -24,6 +24,7 @@ /** * Debug log */ + // @phpstan-ignore-next-line function exmDebugLog($log) { $now = Carbon::now(); @@ -35,6 +36,7 @@ function exmDebugLog($log) } if (!function_exists('exmtrans')) { + // @phpstan-ignore-next-line function exmtrans($key, ...$args) { if (count($args) > 0 && is_array($args[0])) { @@ -50,6 +52,7 @@ function exmtrans($key, ...$args) } if (!function_exists('getManualUrl')) { + // @phpstan-ignore-next-line function getManualUrl($uri = null) { return \Exment::getManualUrl($uri); @@ -57,6 +60,7 @@ function getManualUrl($uri = null) } if (!function_exists('mbTrim')) { + // @phpstan-ignore-next-line function mbTrim($pString) { if (is_null($pString)) { @@ -70,6 +74,7 @@ function mbTrim($pString) /** * escape html */ + // @phpstan-ignore-next-line function esc_html($str) { return htmlspecialchars_ex($str, ENT_QUOTES|ENT_HTML5); @@ -82,6 +87,7 @@ function esc_html($str) * * @deprecated Please use html_clean */ + // @phpstan-ignore-next-line function esc_script_tag($html) { return html_clean($html); @@ -92,6 +98,7 @@ function esc_script_tag($html) /** * clean html with HTML Purifier */ + // @phpstan-ignore-next-line function html_clean($html) { if (is_nullorempty($html)) { @@ -129,6 +136,7 @@ function html_clean($html) * * @return bool null is true, "" is true, 0 and "0" is false. */ + // @phpstan-ignore-next-line function is_nullorempty($obj) { if (is_null($obj)) { @@ -170,6 +178,7 @@ function parseIntN($str) /** * parseFloat */ + // @phpstan-ignore-next-line function parseFloat($num) { if (is_null($num)) { @@ -194,7 +203,7 @@ function floorDigit($num, int $digit, bool $display = false) if ($digit < 0) { $digit = 0; } - /** @phpstan-ignore-next-line strpos expects string, float|int|null given */ + // @phpstan-ignore-next-line $numPointPosition = intval(strpos($num, '.')); // if for display @@ -202,7 +211,7 @@ function floorDigit($num, int $digit, bool $display = false) if ($numPointPosition === 0) { //$num is an integer $result = $num; } else { - /** @phpstan-ignore-next-line substr expects string, float|int|null given */ + // @phpstan-ignore-next-line $result = floatval(substr($num, 0, $numPointPosition + $digit + 1)); ; } @@ -216,6 +225,7 @@ function floorDigit($num, int $digit, bool $display = false) } if (!function_exists('hex2rgb')) { + // @phpstan-ignore-next-line function hex2rgb($hex) { if (substr($hex, 0, 1) == "#") { @@ -232,6 +242,7 @@ function hex2rgb($hex) /** * remove comma */ + // @phpstan-ignore-next-line function rmcomma($value) { if (is_null($value)) { @@ -245,6 +256,7 @@ function rmcomma($value) /** * decrypt if can, caanot return null */ + // @phpstan-ignore-next-line function trydecrypt($value) { try { @@ -283,6 +295,7 @@ function exment_app_path($path = '') function exment_package_path($path = '') { $reflection = new \ReflectionClass(\Exceedone\Exment\ExmentServiceProvider::class); + // @phpstan-ignore-next-line $package_path = dirname(dirname($reflection->getFileName())); return path_join($package_path, $path); @@ -293,6 +306,7 @@ function exment_package_path($path = '') /** * Join admin url paths. */ + // @phpstan-ignore-next-line function admin_urls(...$pass_array) { return admin_url(url_join($pass_array)); @@ -303,6 +317,7 @@ function admin_urls(...$pass_array) /** * Join admin base paths. */ + // @phpstan-ignore-next-line function admin_base_paths(...$pass_array) { return admin_base_path(url_join($pass_array)); @@ -313,6 +328,7 @@ function admin_base_paths(...$pass_array) /** * Join admin url paths and query. Please set last arg */ + // @phpstan-ignore-next-line function admin_urls_query(...$pass_array) { // get last arg @@ -333,6 +349,7 @@ function admin_urls_query(...$pass_array) /** * Join admin url paths. */ + // @phpstan-ignore-next-line function asset_urls(...$pass_array) { return asset(url_join(...$pass_array)); @@ -343,6 +360,7 @@ function asset_urls(...$pass_array) /** * Join url paths and query. Please set last arg */ + // @phpstan-ignore-next-line function assets_query(...$pass_array) { // get last arg @@ -364,6 +382,7 @@ function assets_query(...$pass_array) /** * Join public form base path. */ + // @phpstan-ignore-next-line function public_form_base_path() { return config('exment.publicform_route_prefix', 'publicform'); @@ -375,6 +394,7 @@ function public_form_base_path() * Join public form urls. * "Cannot join path, because when you want to use public form, you have to set public form's uuid." */ + // @phpstan-ignore-next-line function public_form_url() { return asset(public_form_base_path()); @@ -385,6 +405,7 @@ function public_form_url() /** * Join NameSpace. */ + // @phpstan-ignore-next-line function namespace_join(...$pass_array) { return join_paths('\\', $pass_array); @@ -395,6 +416,7 @@ function namespace_join(...$pass_array) /** * Join FilePath. */ + // @phpstan-ignore-next-line function path_join(...$pass_array) { return join_paths('/', $pass_array); @@ -406,6 +428,7 @@ function path_join(...$pass_array) /** * Join FilePath. consider OS SEPARATOR. */ + // @phpstan-ignore-next-line function path_join_os(...$pass_array) { return join_paths(DIRECTORY_SEPARATOR, $pass_array); @@ -416,6 +439,7 @@ function path_join_os(...$pass_array) /** * Join FilePath. */ + // @phpstan-ignore-next-line function url_join(...$pass_array) { return join_paths("/", $pass_array); @@ -427,6 +451,7 @@ function url_join(...$pass_array) /** * Join path using trim_str. */ + // @phpstan-ignore-next-line function join_paths($trim_str, $pass_array) { $ret_pass = ""; @@ -451,6 +476,7 @@ function join_paths($trim_str, $pass_array) } if (!function_exists('storage_paths')) { + // @phpstan-ignore-next-line function storage_paths(...$pass_array) { return path_join(storage_path(), ...$pass_array); @@ -458,6 +484,7 @@ function storage_paths(...$pass_array) } if (!function_exists('app_paths')) { + // @phpstan-ignore-next-line function app_paths(...$pass_array) { return path_join(app_path(), ...$pass_array); @@ -533,6 +560,7 @@ function path_rtrim($path, $rtrim) } if (!function_exists('getFullpath')) { + // @phpstan-ignore-next-line function getFullpath($filename, $disk, $mkdir = false) { if (is_string($disk)) { @@ -543,6 +571,7 @@ function getFullpath($filename, $disk, $mkdir = false) $path = \Exment::getPathPrefix($adapter, $filename); if ($mkdir) { + // @phpstan-ignore-next-line $dirPath = pathinfo($path)['dirname']; \Exment::makeDirectory($dirPath); } @@ -552,9 +581,11 @@ function getFullpath($filename, $disk, $mkdir = false) if (!function_exists('mb_basename')) { + // @phpstan-ignore-next-line function mb_basename($str, $suffix=null) { $tmp = preg_split('/[\/\\\\]/', $str); + // @phpstan-ignore-next-line $res = end($tmp); if (strlen_ex($suffix)) { $suffix = preg_quote($suffix); @@ -567,6 +598,7 @@ function mb_basename($str, $suffix=null) /** * get file extension */ + // @phpstan-ignore-next-line function file_ext($filename) { return preg_match('/\./', $filename) ? preg_replace('/^.*\./', '', $filename) : ''; @@ -576,6 +608,7 @@ function file_ext($filename) /** * Returns the file name, less the extension. */ + // @phpstan-ignore-next-line function file_ext_strip($filename) { return preg_replace('/.[^.]*$/', '', $filename); @@ -583,6 +616,7 @@ function file_ext_strip($filename) } if (!function_exists('bytesToHuman')) { + // @phpstan-ignore-next-line function bytesToHuman($bytes, $default = null) { if (is_null($bytes)) { @@ -606,6 +640,7 @@ function bytesToHuman($bytes, $default = null) * @param array|string $uris * @return boolean */ + // @phpstan-ignore-next-line function isMatchRequest($uris = null) { $request = app('request'); @@ -630,6 +665,7 @@ function isMatchRequest($uris = null) /** * delete target directory */ + // @phpstan-ignore-next-line function deleteDirectory($disk, $path) { if (is_nullorempty($path)) { @@ -660,6 +696,7 @@ function deleteDirectory($disk, $path) * @param array|Collection $dates array of between ['start':Carbon, 'end':Carbon] * @return boolean Duplicate:true */ + // @phpstan-ignore-next-line function hasDuplicateDate($dates) { $dates = collect($dates); @@ -686,6 +723,7 @@ function hasDuplicateDate($dates) * get array_get and return boolval * @return bool */ + // @phpstan-ignore-next-line function array_boolval($array, $key, $default = false): bool { if (is_string($array)) { @@ -783,6 +821,7 @@ function array_value_exists($value, $array): bool * @param $array * @return array|null */ + // @phpstan-ignore-next-line function array_dot_reverse($array) { if (is_null($array)) { @@ -801,6 +840,7 @@ function array_dot_reverse($array) * arrayonly with dot * @return array */ + // @phpstan-ignore-next-line function array_dot_only($array, $keys) { $newArray = []; @@ -815,6 +855,7 @@ function array_dot_only($array, $keys) /** * array remove as "array_forget" */ + // @phpstan-ignore-next-line function array_remove(array $array, $keys) { $result = array_diff($array, toArray($keys)); @@ -841,7 +882,7 @@ function jsonToArray($value) return $value; } // convert json to array - /** @phpstan-ignore-next-line Call to function is_array() with mixed will always evaluate to false. already checked is_array() */ + // @phpstan-ignore-next-line if (!is_array($value) && is_json($value)) { return json_decode_ex($value, true); } @@ -857,6 +898,7 @@ function jsonToArray($value) * @param mixed $value * @return array */ + // @phpstan-ignore-next-line function stringToArray($value) { if (is_nullorempty($value)) { @@ -888,6 +930,7 @@ function stringToArray($value) * @param mixed $value * @return array */ + // @phpstan-ignore-next-line function breakCommaToArray($value) { if (is_nullorempty($value)) { @@ -921,6 +964,7 @@ function breakCommaToArray($value) * @param mixed $value * @return ?array */ + // @phpstan-ignore-next-line function toArray($value): ?array { if (is_null($value)) { @@ -951,6 +995,7 @@ function toArray($value): ?array * @param $value * @return string|null */ + // @phpstan-ignore-next-line function arrayToString($value) { if (is_null($value)) { @@ -970,6 +1015,7 @@ function arrayToString($value) } if (!function_exists('is_json')) { + // @phpstan-ignore-next-line function is_json($string) { return is_string($string) && is_array(json_decode_ex($string, true)) && (json_last_error() == JSON_ERROR_NONE) ? true : false; @@ -987,6 +1033,7 @@ function is_json($string) * false: ['foo' => 0, 'bar' => 1] * false: [0 => 'foo', 1 => 'bar'] */ + // @phpstan-ignore-next-line function is_vector(array $arr) { // foreach($arr as $key => $value){ @@ -1059,6 +1106,7 @@ function isMatchDecimal($v1, $v2): bool * @param array $v2 * @return bool */ + // @phpstan-ignore-next-line function isMatchArray(array $v1, array $v2): bool { if (count($v1) == count($v2)) { @@ -1095,6 +1143,7 @@ function rstrpos(?string $haystack, ?string $needle, ?int $offset = 0) } if (!function_exists('make_password')) { + // @phpstan-ignore-next-line function make_password($length = 16, $options = []) { $options = array_merge( @@ -1129,6 +1178,7 @@ function make_password($length = 16, $options = []) } if (!function_exists('make_randomstr')) { + // @phpstan-ignore-next-line function make_randomstr($length, bool $useAlphabet = true, bool $useNumber = true) { $chars = ''; @@ -1148,6 +1198,7 @@ function make_randomstr($length, bool $useAlphabet = true, bool $useNumber = tru } if (!function_exists('make_uuid')) { + // @phpstan-ignore-next-line function make_uuid() { return Uuid::generate()->string; @@ -1166,6 +1217,7 @@ function short_uuid() } if (!function_exists('is_uuid')) { + // @phpstan-ignore-next-line function is_uuid($uuid): bool { return Uuid::validate($uuid); @@ -1173,6 +1225,7 @@ function is_uuid($uuid): bool } if (!function_exists('make_licensecode')) { + // @phpstan-ignore-next-line function make_licensecode() { return make_randomstr(5).'-'.make_randomstr(5).'-'.make_randomstr(5).'-'.make_randomstr(5).'-'.make_randomstr(5); @@ -1180,6 +1233,7 @@ function make_licensecode() } if (!function_exists('pascalize')) { + // @phpstan-ignore-next-line function pascalize($string) { // replace A to _a @@ -1200,6 +1254,7 @@ function pascalize($string) * get_password_rule(for validation) * @return array */ + // @phpstan-ignore-next-line function get_password_rule($required = true, ?LoginUser $login_user = null) { return \Exment::get_password_rule($required, $login_user); @@ -1214,6 +1269,7 @@ function get_password_rule($required = true, ?LoginUser $login_user = null) * @param $length * @return mixed|string|null */ + // @phpstan-ignore-next-line function get_omitted_string($text, $length = null) { if (is_null($length)) { @@ -1241,6 +1297,7 @@ function get_omitted_string($text, $length = null) * replace new line code to
    * @return string */ + // @phpstan-ignore-next-line function replaceBreak($text, $isescape = true) { return preg_replace("/\\\\r\\\\n|\\\\r|\\\\n|\\r\\n|\\r|\\n/", "
    ", $isescape ? esc_html($text) : $text); @@ -1252,6 +1309,7 @@ function replaceBreak($text, $isescape = true) * replace and new line code to
    * @return string */ + // @phpstan-ignore-next-line function replaceBreakEsc($text) { return preg_replace("/\\\\r\\\\n|\\\\r|\\\\n|\\r\\n|\\r|\\n/", "
    ", esc_html($text)); @@ -1263,6 +1321,7 @@ function replaceBreakEsc($text) * replace
    to new line code * @return string */ + // @phpstan-ignore-next-line function replaceBrTag($text) { return preg_replace("/
    /u", "\n", $text); @@ -1274,6 +1333,7 @@ function replaceBrTag($text) * explode new line code * @return array */ + // @phpstan-ignore-next-line function explodeBreak($text) { return explode_ex("\r\n", preg_replace("/\\\\r\\\\n|\\\\r|\\\\n|\\r\\n|\\r|\\n/", "\r\n", $text)); @@ -1285,6 +1345,7 @@ function explodeBreak($text) * get yes no label * @return string */ + // @phpstan-ignore-next-line function getYesNo($value): string { return boolval($value) ? 'YES' : 'NO'; @@ -1301,6 +1362,7 @@ function getYesNo($value): string * @param $get_name_only * @return string|null */ + // @phpstan-ignore-next-line function getModelName($obj, $get_name_only = false) { if ($obj instanceof CustomValue) { @@ -1412,6 +1474,7 @@ function hasColumn($table_name, $column_name) * @return string * @throws Exception */ + // @phpstan-ignore-next-line function getDBTableName($obj, $isThrow = true) { $obj = CustomTable::getEloquent($obj); @@ -1444,6 +1507,7 @@ function getEndpointName($obj) /** * Get Currency Sybmol. ex. $, ¥, ... */ + // @phpstan-ignore-next-line function getCurrencySymbolLabel($currencySymbol, $html = false, $value = null) { $currencySymbol = CurrencySymbol::getEnum($currencySymbol); @@ -1473,6 +1537,7 @@ function getCurrencySymbolLabel($currencySymbol, $html = false, $value = null) * * @deprecated Please use ReplaceFormatService::replaceTextFromFormat */ + // @phpstan-ignore-next-line function replaceTextFromFormat($format, $custom_value = null, $options = []) { return ReplaceFormatService::replaceTextFromFormat($format, $custom_value, $options); @@ -1481,6 +1546,7 @@ function replaceTextFromFormat($format, $custom_value = null, $options = []) // Database Difinition -------------------------------------------------- if (!function_exists('shouldPassThrough')) { + // @phpstan-ignore-next-line function shouldPassThrough($initialize = false) { if ($initialize) { @@ -1510,6 +1576,7 @@ function shouldPassThrough($initialize = false) /** * Create Associative array translated */ + // @phpstan-ignore-next-line function getTransArray($array, $base_key, $isExment = true) { if ($array instanceof \MyCLabs\Enum\Enum) { @@ -1527,6 +1594,7 @@ function getTransArray($array, $base_key, $isExment = true) /** * Create Associative array translated */ + // @phpstan-ignore-next-line function getTransArrayValue($array, $base_key, $isExment = true) { $associative_array = []; @@ -1549,6 +1617,7 @@ function getTransArrayValue($array, $base_key, $isExment = true) * @param ErrorCode $errorCode * @return \Symfony\Component\HttpFoundation\Response */ + // @phpstan-ignore-next-line function abortJson($code, $message = null, $errorCode = null) { $result = []; @@ -1567,6 +1636,7 @@ function abortJson($code, $message = null, $errorCode = null) $result['code'] = $errorCode->getValue(); } + // @phpstan-ignore-next-line return response()->json($result, $code); } } @@ -1578,6 +1648,7 @@ function abortJson($code, $message = null, $errorCode = null) * * @return \Symfony\Component\HttpFoundation\Response Response for ajax json */ + // @phpstan-ignore-next-line function getAjaxResponse($results) { if ($results instanceof \Illuminate\Http\Response) { @@ -1613,6 +1684,7 @@ function getAjaxResponse($results) * download file. * Support large file */ + // @phpstan-ignore-next-line function downloadFile($path, $disk) { $driver = $disk->getDriver(); @@ -1642,6 +1714,7 @@ function () use ($stream) { /** * get pager select options */ + // @phpstan-ignore-next-line function getPagerOptions($addEmpty = false, $counts = Define::PAGER_GRID_COUNTS) { $options = []; @@ -1662,6 +1735,7 @@ function getPagerOptions($addEmpty = false, $counts = Define::PAGER_GRID_COUNTS) /** * get Data from excel sheet */ + // @phpstan-ignore-next-line function getDataFromSheet($sheet, $keyvalue = false, $isGetMerge = false) { return \Exment::getDataFromSheet($sheet, $keyvalue, $isGetMerge); @@ -1672,6 +1746,7 @@ function getDataFromSheet($sheet, $keyvalue = false, $isGetMerge = false) /** * get cell value */ + // @phpstan-ignore-next-line function getCellValue($cell, $sheet, $isGetMerge = false) { return \Exment::getCellValue($cell, $sheet, $isGetMerge); @@ -1681,6 +1756,7 @@ function getCellValue($cell, $sheet, $isGetMerge = false) if (!function_exists('getCellAlphabet')) { /** */ + // @phpstan-ignore-next-line function getCellAlphabet($no) { $alphabet = "ZABCDEFGHIJKLMNOPQRSTUVWXY"; @@ -1707,6 +1783,7 @@ function getCellAlphabet($no) * @param $addAvatar * @return array|\Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\Translation\Translator|mixed|string|null */ + // @phpstan-ignore-next-line function getUserName($id, $link = false, $addAvatar = false) { if (is_nullorempty($id)) { @@ -1812,12 +1889,14 @@ function unicode_encode($str) * * @return object|array|string|int|float|bool|null */ + // @phpstan-ignore-next-line function json_decode_ex($json, bool $assoc = false, int $depth = 512, int $options = 0) { if (is_null($json) || is_array($json)) { return $json; } + // @phpstan-ignore-next-line return json_decode($json, $assoc, $depth, $options); } } diff --git a/src/Services/Installer/DatabaseForm.php b/src/Services/Installer/DatabaseForm.php index a99ee6615..50eca1f3c 100644 --- a/src/Services/Installer/DatabaseForm.php +++ b/src/Services/Installer/DatabaseForm.php @@ -13,6 +13,7 @@ class DatabaseForm { use EnvTrait; + // @phpstan-ignore-next-line protected $database_default = null; public const settings = [ @@ -24,6 +25,7 @@ class DatabaseForm 'password', ]; + // @phpstan-ignore-next-line public function index() { $database_default = config('database.default', 'mysql'); @@ -38,9 +40,11 @@ public function index() $args[$s] = array_get($database_connection, $s); } + // @phpstan-ignore-next-line return view('exment::install.database', $args); } + // @phpstan-ignore-next-line public function post() { $request = request(); @@ -156,6 +160,7 @@ protected function checkDatabaseVersion() // check max(less than) if (array_has($database_version, 'max_lt')) { $message_lt = true; + // @phpstan-ignore-next-line if (version_compare($version, $database_version['max_lt']) >= 0) { $result = false; } @@ -167,6 +172,7 @@ protected function checkDatabaseVersion() $errorMessage = exmtrans('install.error.not_require_database_version_' . ($message_lt ? 'min_maxlt' : 'min'), [ 'min' => $database_version['min'], + // @phpstan-ignore-next-line 'max_lt' => ($message_lt ? $database_version['max_lt'] : null), 'database' => Define::DATABASE_TYPE[$this->database_default], 'current' => $version @@ -229,6 +235,7 @@ protected function checkPhpVersion() return true; } + // @phpstan-ignore-next-line protected function connection() { return \DB::connection($this->database_default); diff --git a/src/Services/Installer/EnvTrait.php b/src/Services/Installer/EnvTrait.php index 71fa9c835..95a5b0daf 100644 --- a/src/Services/Installer/EnvTrait.php +++ b/src/Services/Installer/EnvTrait.php @@ -9,16 +9,19 @@ */ trait EnvTrait { + // @phpstan-ignore-next-line protected function setEnv($data = [], $matchRemove = false) { return EnvService::setEnv($data, $matchRemove); } + // @phpstan-ignore-next-line protected function removeEnv($data = []) { return EnvService::removeEnv($data); } + // @phpstan-ignore-next-line protected function getEnv($key, $path = null, $matchPrefix = false) { return EnvService::getEnv($key, $path, $matchPrefix); diff --git a/src/Services/Installer/InitializeForm.php b/src/Services/Installer/InitializeForm.php index 1fd571218..4516df037 100644 --- a/src/Services/Installer/InitializeForm.php +++ b/src/Services/Installer/InitializeForm.php @@ -19,6 +19,7 @@ class InitializeForm use EnvTrait; use InitializeFormTrait; + // @phpstan-ignore-next-line public function index() { $form = $this->getInitializeForm('initialize', true); @@ -40,6 +41,7 @@ public function index() ]); } + // @phpstan-ignore-next-line public function post() { $request = request(); @@ -93,6 +95,7 @@ public function post() } } + // @phpstan-ignore-next-line protected function guard() { return Auth::guard('admin'); diff --git a/src/Services/Installer/InitializeFormTrait.php b/src/Services/Installer/InitializeFormTrait.php index bb4ad0977..07f94286b 100644 --- a/src/Services/Installer/InitializeFormTrait.php +++ b/src/Services/Installer/InitializeFormTrait.php @@ -137,6 +137,7 @@ protected function getsendmailTestBox(): Box } + // @phpstan-ignore-next-line protected function setNotifyForm($form) { // use mail setting @@ -174,6 +175,7 @@ protected function setNotifyForm($form) } + // @phpstan-ignore-next-line protected function postInitializeForm(Request $request, $group = null, $initialize = false, $validateUser = false) { $rules = [ @@ -215,6 +217,7 @@ protected function postInitializeForm(Request $request, $group = null, $initiali return true; } + // @phpstan-ignore-next-line protected function addTemplateTile($form) { $form->exmheader(exmtrans('template.header'))->hr(); @@ -270,6 +273,7 @@ function searchTemplate(q, url){ /** * Upload Template */ + // @phpstan-ignore-next-line protected function uploadTemplate(Request $request) { // upload zip file @@ -280,11 +284,13 @@ protected function uploadTemplate(Request $request) $file = $request->file('upload_template'); // upload excel file + // @phpstan-ignore-next-line if ($file->getClientOriginalExtension() == 'xlsx') { $json = $importer->uploadTemplateExcel($file); $importer->import($json, false, false, true); } // upload zip file + // @phpstan-ignore-next-line elseif ($file->getClientOriginalExtension() == 'zip') { $upload_template = $importer->uploadTemplate($file); $importer->importTemplate($upload_template); @@ -295,6 +301,7 @@ protected function uploadTemplate(Request $request) /** * file delete system. */ + // @phpstan-ignore-next-line public function filedelete(Request $request) { // get file delete flg column name @@ -306,17 +313,20 @@ public function filedelete(Request $request) ]); } + // @phpstan-ignore-next-line protected function guard() { return Auth::guard('admin'); } + // @phpstan-ignore-next-line protected function getUserOrgSlackColumns(string $table_name) { return $this->getUserOrgColumns($table_name, Enums\ColumnType::TEXT); } + // @phpstan-ignore-next-line protected function getUserOrgColumns(string $table_name, string $column_type) { $custom_table = CustomTable::getEloquent($table_name); @@ -337,6 +347,7 @@ protected function getUserOrgColumns(string $table_name, string $column_type) * @param bool $isAdvanced * @return array */ + // @phpstan-ignore-next-line protected function getProgressInfo(bool $isAdvanced): array { $steps = []; diff --git a/src/Services/Installer/InstallFormInterface.php b/src/Services/Installer/InstallFormInterface.php index 3e06d3191..b57821fab 100644 --- a/src/Services/Installer/InstallFormInterface.php +++ b/src/Services/Installer/InstallFormInterface.php @@ -7,7 +7,9 @@ */ interface InstallFormInterface { + // @phpstan-ignore-next-line public function index(); + // @phpstan-ignore-next-line public function post(); } diff --git a/src/Services/Installer/InstallService.php b/src/Services/Installer/InstallService.php index ebacf7058..539315064 100644 --- a/src/Services/Installer/InstallService.php +++ b/src/Services/Installer/InstallService.php @@ -12,6 +12,7 @@ */ class InstallService { + // @phpstan-ignore-next-line public static function index() { static::setSettingTmp(); @@ -26,6 +27,7 @@ public static function index() return $form->index(); } + // @phpstan-ignore-next-line public static function post() { static::setSettingTmp(); @@ -40,6 +42,7 @@ public static function post() return $form->post(); } + // @phpstan-ignore-next-line public static function getStatus() { static::setSettingTmp(); @@ -77,6 +80,7 @@ public static function getStatus() return InitializeStatus::INITIALIZE; } + // @phpstan-ignore-next-line public static function redirect($status) { $isInstallPath = collect(explode('/', request()->getRequestUri()))->last() == 'install'; @@ -109,6 +113,7 @@ public static function redirect($status) } } + // @phpstan-ignore-next-line public static function getForm($status) { switch ($status) { @@ -127,16 +132,19 @@ public static function getForm($status) return new InitializeForm(); } + // @phpstan-ignore-next-line public static function getInitializeStatus() { return session(Define::SYSTEM_KEY_SESSION_INITIALIZE); } + // @phpstan-ignore-next-line public static function setInitializeStatus($status) { session([Define::SYSTEM_KEY_SESSION_INITIALIZE => $status]); } + // @phpstan-ignore-next-line public static function forgetInitializeStatus() { session()->forget(Define::SYSTEM_KEY_SESSION_INITIALIZE); @@ -144,6 +152,7 @@ public static function forgetInitializeStatus() + // @phpstan-ignore-next-line public static function setInputParams(array $inputs) { $session_inputs = session(Define::SYSTEM_KEY_SESSION_INITIALIZE_INPUTS, []); @@ -153,11 +162,13 @@ public static function setInputParams(array $inputs) session([Define::SYSTEM_KEY_SESSION_INITIALIZE_INPUTS => $session_inputs]); } + // @phpstan-ignore-next-line public static function getInputParams(): array { return session(Define::SYSTEM_KEY_SESSION_INITIALIZE_INPUTS, []); } + // @phpstan-ignore-next-line public static function forgetInputParams() { session()->forget(Define::SYSTEM_KEY_SESSION_INITIALIZE_INPUTS); diff --git a/src/Services/Installer/InstallingForm.php b/src/Services/Installer/InstallingForm.php index 4be6ad26f..5d52ad13d 100644 --- a/src/Services/Installer/InstallingForm.php +++ b/src/Services/Installer/InstallingForm.php @@ -11,11 +11,13 @@ class InstallingForm { use EnvTrait; + // @phpstan-ignore-next-line public function index() { return view('exment::install.installing'); } + // @phpstan-ignore-next-line public function post() { try { diff --git a/src/Services/Installer/LangForm.php b/src/Services/Installer/LangForm.php index 25ceb794f..2a94ebfad 100644 --- a/src/Services/Installer/LangForm.php +++ b/src/Services/Installer/LangForm.php @@ -13,6 +13,7 @@ class LangForm { use EnvTrait; + // @phpstan-ignore-next-line public function index() { \Artisan::call('exment:publish'); @@ -25,6 +26,7 @@ public function index() ]); } + // @phpstan-ignore-next-line public function post() { $request = request(); diff --git a/src/Services/Installer/SystemRequireForm.php b/src/Services/Installer/SystemRequireForm.php index 3c66d2b0c..61786708c 100644 --- a/src/Services/Installer/SystemRequireForm.php +++ b/src/Services/Installer/SystemRequireForm.php @@ -13,12 +13,14 @@ class SystemRequireForm { use EnvTrait; + // @phpstan-ignore-next-line public function index() { $checkResult = SystemRequireList::make(SystemRequireCalledType::INSTALL_WEB); return view('exment::install.system_require', ['checkResult' => $checkResult, 'login_box_classname' => 'login-box-wide']); } + // @phpstan-ignore-next-line public function post() { if (boolval(request()->get('refresh'))) { @@ -27,7 +29,7 @@ public function post() try { $inputs = InstallService::getInputParams(); - /** @phpstan-ignore-next-line Call to function is_null() with string will always evaluate to false. asset always returns string */ + // @phpstan-ignore-next-line if (is_null(array_get($inputs, 'APP_URL')) && !is_null($url = asset(''))) { $inputs['APP_URL'] = rtrim($url, '/'); } diff --git a/src/Services/Login/CustomLoginUserBase.php b/src/Services/Login/CustomLoginUserBase.php index efa3cfc0c..356923e8b 100644 --- a/src/Services/Login/CustomLoginUserBase.php +++ b/src/Services/Login/CustomLoginUserBase.php @@ -14,15 +14,21 @@ */ abstract class CustomLoginUserBase { + // @phpstan-ignore-next-line public $id; + // @phpstan-ignore-next-line public $login_setting; + // @phpstan-ignore-next-line public $login_id; + // @phpstan-ignore-next-line public $mapping_user_column; + // @phpstan-ignore-next-line public $provider_name; // public $email; // public $user_code; // public $user_name; + // @phpstan-ignore-next-line public $login_type; /** @@ -30,6 +36,7 @@ abstract class CustomLoginUserBase * * @var array */ + // @phpstan-ignore-next-line public $mapping_errors = []; /** @@ -37,30 +44,35 @@ abstract class CustomLoginUserBase * * @var array */ + // @phpstan-ignore-next-line public $mapping_values = []; + // @phpstan-ignore-next-line public function user_code() { return array_get($this->mapping_values, 'user_code'); } + // @phpstan-ignore-next-line public function user_name() { return array_get($this->mapping_values, 'user_name'); } + // @phpstan-ignore-next-line public function email() { return array_get($this->mapping_values, 'email'); } + // @phpstan-ignore-next-line public function domain() { if (is_nullorempty($email = $this->email())) { return null; } - /** @phpstan-ignore-next-line If condition is always false. explode always one element in array */ + // @phpstan-ignore-next-line if (count($emails = explode("@", $email)) == 0) { return null; } @@ -73,6 +85,7 @@ public function domain() * * @return void */ + // @phpstan-ignore-next-line protected static function setMappingValue(CustomLoginUserBase $user, $providerUser) { $user_custom_columns = static::getUserColumns(); @@ -113,6 +126,7 @@ protected static function setMappingValue(CustomLoginUserBase $user, $providerUs } } } + // @phpstan-ignore-next-line protected static function getUserColumns() { return CustomTable::getEloquent(SystemTableName::USER)->custom_columns_cache; diff --git a/src/Services/Login/Ldap/LdapService.php b/src/Services/Login/Ldap/LdapService.php index 92d00922d..962dccfd3 100644 --- a/src/Services/Login/Ldap/LdapService.php +++ b/src/Services/Login/Ldap/LdapService.php @@ -36,6 +36,7 @@ class LdapService implements LoginServiceInterface * * @throws SsoLoginErrorException */ + // @phpstan-ignore-next-line public static function retrieveByCredential(array $credentials) { list($result, $message, $adminMessage, $custom_login_user) = static::loginCallback(request(), array_get($credentials, 'login_setting') ?? LoginSetting::getLdapSetting(array_get($credentials, 'provider_name'))); @@ -61,6 +62,7 @@ public static function retrieveByCredential(array $credentials) * @param array $credentials * @return boolean */ + // @phpstan-ignore-next-line public static function validateCredential(Authenticatable $login_user, array $credentials) { // always true. @@ -68,6 +70,7 @@ public static function validateCredential(Authenticatable $login_user, array $cr } + // @phpstan-ignore-next-line public static function getLdapConfig(LoginSetting $login_setting) { return [ @@ -160,6 +163,7 @@ public static function getTestForm(LoginSetting $login_setting) + // @phpstan-ignore-next-line public static function setLdapForm($form, $login_setting, $errors) { if (array_has($errors, LoginType::LDAP)) { @@ -277,7 +281,7 @@ protected static function loginCallback(Request $request, $login_setting) $username : static::getLdapUserDN($provider, $credentials['username'], $login_setting); if (!$bindDN || !$provider->auth()->attempt($bindDN, $credentials['password'], true)) { - /** @phpstan-ignore-next-line getLoginResult() expects bool, string given */ + // @phpstan-ignore-next-line return LoginService::getLoginResult(SsoLoginErrorType::NOT_EXISTS_PROVIDER_USER, [exmtrans('error.login_failed')]); } @@ -285,7 +289,7 @@ protected static function loginCallback(Request $request, $login_setting) $ldapUser = static::syncLdapUser($provider, $login_setting, $username); if (!$ldapUser) { - /** @phpstan-ignore-next-line getLoginResult() expects bool, string given */ + // @phpstan-ignore-next-line return LoginService::getLoginResult(SsoLoginErrorType::NOT_EXISTS_PROVIDER_USER, [exmtrans('error.login_failed')]); } @@ -293,7 +297,7 @@ protected static function loginCallback(Request $request, $login_setting) $custom_login_user = LdapUser::with($login_setting, $ldapUser); if (!is_nullorempty($custom_login_user->mapping_errors)) { - /** @phpstan-ignore-next-line getLoginResult() expects bool, string given */ + // @phpstan-ignore-next-line return LoginService::getLoginResult(SsoLoginErrorType::SYNC_MAPPING_ERROR, exmtrans('login.sso_provider_error'), $custom_login_user->mapping_errors); } @@ -301,10 +305,10 @@ protected static function loginCallback(Request $request, $login_setting) $validator = LoginService::validateCustomLoginSync($custom_login_user); if ($validator->fails()) { return LoginService::getLoginResult( - /** @phpstan-ignore-next-line getLoginResult() expects bool, string given */ + // @phpstan-ignore-next-line SsoLoginErrorType::SYNC_VALIDATION_ERROR, exmtrans('login.sso_provider_error_validate', ['errors' => implode(' ', $validator->getMessageStrings())]), - /** @phpstan-ignore-next-line getLoginResult() expects array|null, Illuminate\Support\MessageBag given */ + // @phpstan-ignore-next-line $validator->errors(), $custom_login_user ); @@ -313,15 +317,16 @@ protected static function loginCallback(Request $request, $login_setting) return LoginService::getLoginResult(true, [], [], $custom_login_user); } catch (\Adldap\Auth\BindException $ex) { \Log::error($ex); - /** @phpstan-ignore-next-line getLoginResult() expects bool, string given */ + // @phpstan-ignore-next-line return LoginService::getLoginResult(SsoLoginErrorType::PROVIDER_ERROR, exmtrans('login.sso_provider_error'), [$ex]); } catch (\Exception $ex) { \Log::error($ex); - /** @phpstan-ignore-next-line getLoginResult() expects bool, string given */ + // @phpstan-ignore-next-line return LoginService::getLoginResult(SsoLoginErrorType::UNDEFINED_ERROR, exmtrans('login.sso_provider_error'), [$ex]); } } + // @phpstan-ignore-next-line public static function appendActivateSwalButton($tools, LoginSetting $login_setting) { return LoginService::appendActivateSwalButtonSso($tools, $login_setting); diff --git a/src/Services/Login/Ldap/LdapUser.php b/src/Services/Login/Ldap/LdapUser.php index 9fe29989b..df01945a8 100644 --- a/src/Services/Login/Ldap/LdapUser.php +++ b/src/Services/Login/Ldap/LdapUser.php @@ -12,6 +12,7 @@ */ class LdapUser extends CustomLoginUserBase { + // @phpstan-ignore-next-line public static function with($login_setting, $ldapUser) { $user = new LdapUser(); @@ -37,6 +38,7 @@ public static function with($login_setting, $ldapUser) * @param array $replaceMaps * @return mixed */ + // @phpstan-ignore-next-line protected static function getMappingItemValue($ldapuser, $mappingKey, $replaceMaps) { $hasValue = false; @@ -56,7 +58,7 @@ protected static function getMappingItemValue($ldapuser, $mappingKey, $replaceMa $ldap_attr = strtolower($ldap_attr); if (!isset($ldapuser_attrs[$ldap_attr])) { - /** @phpstan-ignore-next-line str_replace expects array|string, null given */ + // @phpstan-ignore-next-line $mappingKey = str_replace($replaceValue, null, $mappingKey); continue; } @@ -68,7 +70,7 @@ protected static function getMappingItemValue($ldapuser, $mappingKey, $replaceMa } if (count($ldapuser_attrs[$ldap_attr]) == 0) { - /** @phpstan-ignore-next-line str_replace expects array|string, null given */ + // @phpstan-ignore-next-line $mappingKey = str_replace($replaceValue, null, $mappingKey); continue; } @@ -87,6 +89,7 @@ protected static function getMappingItemValue($ldapuser, $mappingKey, $replaceMa return $mappingKey; } + // @phpstan-ignore-next-line protected static function accessProtected($obj, $prop) { $reflection = new \ReflectionClass($obj); diff --git a/src/Services/Login/LoginService.php b/src/Services/Login/LoginService.php index 2b5618f20..bf8e85063 100644 --- a/src/Services/Login/LoginService.php +++ b/src/Services/Login/LoginService.php @@ -35,6 +35,7 @@ class LoginService * @return \Illuminate\Http\RedirectResponse|void * @throws \Exception */ + // @phpstan-ignore-next-line public static function resetPassword($user, array $options = []) { $options = array_merge([ @@ -83,6 +84,7 @@ public static function resetPassword($user, array $options = []) } + // @phpstan-ignore-next-line public static function setToken() { // get custom login user @@ -105,6 +107,7 @@ public static function setToken() * * @return array access_token, refresh_token, provider */ + // @phpstan-ignore-next-line public static function getToken() { $session = session(Define::SYSTEM_KEY_SESSION_PROVIDER_TOKEN); @@ -176,6 +179,7 @@ public static function validateCustomLoginSync(CustomLoginUserBase $custom_login * @param CustomLoginUserBase $custom_login_user * @return array */ + // @phpstan-ignore-next-line public static function validateUniques(CustomLoginUserBase $custom_login_user) { // get target user @@ -209,6 +213,7 @@ public static function validateUniques(CustomLoginUserBase $custom_login_user) * @param array $rules * @return array updated rules */ + // @phpstan-ignore-next-line protected static function removeInitRule(CustomLoginUserBase $custom_login_user, ?CustomValue $exment_user, array $rules) { if (static::needCheck($custom_login_user, $exment_user)) { @@ -251,6 +256,7 @@ protected static function needCheck(CustomLoginUserBase $custom_login_user, ?Cus * @param CustomLoginUserBase $custom_login_user * @return array */ + // @phpstan-ignore-next-line public static function getLoginResult($result, $messages, $adminMessages = null, ?CustomLoginUserBase $custom_login_user = null) { if (is_nullorempty($adminMessages)) { @@ -263,6 +269,7 @@ public static function getLoginResult($result, $messages, $adminMessages = null, return [$result, $message, $adminMessage, $custom_login_user]; } + // @phpstan-ignore-next-line protected static function convertErrorMessage($result, $messages, ?CustomLoginUserBase $custom_login_user = null) { $message = []; @@ -334,6 +341,7 @@ public static function getTestFormSso(LoginSetting $login_setting) return $form; } + // @phpstan-ignore-next-line public static function appendActivateSwalButtonSso($tools, LoginSetting $login_setting) { if (!$login_setting->active_flg) { @@ -514,7 +522,7 @@ public static function getLoginUser(CustomLoginUserBase $custom_login_user, $exm ); // if don't has, create loginuser or match email - /** @phpstan-ignore-next-line $hasLoginUser Negated boolean expression is always true. */ + // @phpstan-ignore-next-line if (!$hasLoginUser) { $login_user = LoginUser::firstOrNew([ 'base_user_id' => $exment_user->getUserId(), @@ -527,7 +535,7 @@ public static function getLoginUser(CustomLoginUserBase $custom_login_user, $exm } // get avatar - /** @phpstan-ignore-next-line $hasLoginUser Negated boolean expression is always true. */ + // @phpstan-ignore-next-line if (!$hasLoginUser || boolval($custom_login_user->login_setting->getOption('update_user_info'))) { $avatar = static::getAvatar($custom_login_user, $socialiteProvider = null); if (isset($avatar)) { @@ -539,12 +547,14 @@ public static function getLoginUser(CustomLoginUserBase $custom_login_user, $exm return $login_user; } + // @phpstan-ignore-next-line public static function getAvatar(CustomLoginUserBase $custom_login_user, $socialiteProvider = null) { try { // if socialiteProvider implements ProviderAvatar, call getAvatar if (isset($socialiteProvider) && is_subclass_of($socialiteProvider, \Exceedone\Exment\Auth\ProviderAvatar::class)) { /** @var OAuthUser $custom_login_user */ + // @phpstan-ignore-next-line $stream = $socialiteProvider->getAvatar($custom_login_user->token); } // if user obj has avatar, download avatar. @@ -567,6 +577,7 @@ public static function getAvatar(CustomLoginUserBase $custom_login_user, $social return null; } + // @phpstan-ignore-next-line protected static function getUserColumns() { return CustomTable::getEloquent(SystemTableName::USER)->custom_columns_cache; diff --git a/src/Services/Login/OAuth/OAuthService.php b/src/Services/Login/OAuth/OAuthService.php index a1d51b878..223aaa539 100644 --- a/src/Services/Login/OAuth/OAuthService.php +++ b/src/Services/Login/OAuth/OAuthService.php @@ -33,6 +33,7 @@ class OAuthService implements LoginServiceInterface * * @throws SsoLoginErrorException */ + // @phpstan-ignore-next-line public static function retrieveByCredential(array $credentials) { list($result, $message, $adminMessage, $custom_login_user) = static::loginCallback(request(), array_get($credentials, 'login_setting') ?? LoginSetting::getOAuthSetting(array_get($credentials, 'provider_name'))); @@ -58,6 +59,7 @@ public static function retrieveByCredential(array $credentials) * @param array $credentials * @return boolean */ + // @phpstan-ignore-next-line public static function validateCredential(Authenticatable $login_user, array $credentials) { // always true. @@ -74,6 +76,7 @@ public static function getTestForm(LoginSetting $login_setting) return LoginService::getTestFormSso($login_setting); } + // @phpstan-ignore-next-line public static function setOAuthForm($form, $login_setting, $errors) { if (array_has($errors, LoginType::OAUTH)) { @@ -181,6 +184,7 @@ public static function loginTest(Request $request, $login_setting) * * @param Request $request */ + // @phpstan-ignore-next-line public static function loginPluginClud(Request $request, $login_setting, string $callbackUrl) { // provider get @@ -197,6 +201,7 @@ public static function loginPluginClud(Request $request, $login_setting, string * @param LoginSetting $login_setting * @return array $result(bool), $message(string), $adminMessage(string), $custom_login_user */ + // @phpstan-ignore-next-line public static function loginCallback(Request $request, $login_setting, $isTest = false) { $custom_login_user = null; @@ -210,10 +215,10 @@ public static function loginCallback(Request $request, $login_setting, $isTest = $validator = LoginService::validateCustomLoginSync($custom_login_user); if ($validator->fails()) { return LoginService::getLoginResult( - /** @phpstan-ignore-next-line getLoginResult() expects bool, string given */ + // @phpstan-ignore-next-line SsoLoginErrorType::SYNC_VALIDATION_ERROR, exmtrans('login.sso_provider_error_validate', ['errors' => implode(' ', $validator->getMessageStrings())]), - /** @phpstan-ignore-next-line getLoginResult() expects array|null, Illuminate\Support\MessageBag given */ + // @phpstan-ignore-next-line $validator->errors(), $custom_login_user ); @@ -221,7 +226,7 @@ public static function loginCallback(Request $request, $login_setting, $isTest = $errors = LoginService::validateUniques($custom_login_user); if (count($errors) > 0) { return LoginService::getLoginResult( - /** @phpstan-ignore-next-line getLoginResult() expects bool, string given */ + // @phpstan-ignore-next-line SsoLoginErrorType::SYNC_VALIDATION_ERROR, exmtrans('login.sso_provider_error_validate', ['errors' => implode(' ', $errors)]), $errors, @@ -232,12 +237,12 @@ public static function loginCallback(Request $request, $login_setting, $isTest = } } catch (\Exception $ex) { \Log::error($ex); - /** @phpstan-ignore-next-line getLoginResult() expects bool, string given */ + // @phpstan-ignore-next-line return LoginService::getLoginResult(SsoLoginErrorType::UNDEFINED_ERROR, exmtrans('login.sso_provider_error'), [$ex]); } catch (\Throwable $ex) { \Log::error($ex); - /** @phpstan-ignore-next-line getLoginResult() expects bool, string given */ + // @phpstan-ignore-next-line return LoginService::getLoginResult(SsoLoginErrorType::UNDEFINED_ERROR, exmtrans('login.sso_provider_error'), [$ex]); } } @@ -315,6 +320,7 @@ public static function clearAccessTokenFromDB(LoginSetting $login_setting) } + // @phpstan-ignore-next-line public static function appendActivateSwalButton($tools, LoginSetting $login_setting) { return LoginService::appendActivateSwalButtonSso($tools, $login_setting); @@ -327,6 +333,7 @@ public static function appendActivateSwalButton($tools, LoginSetting $login_sett * @param \Encore\Admin\Form|\Encore\Admin\Form\EmbeddedForm $form * @return void */ + // @phpstan-ignore-next-line public static function setLoginSettingForm($provider_name, $form) { if (is_nullorempty($provider_name)) { @@ -345,9 +352,9 @@ public static function setLoginSettingForm($provider_name, $form) // has instance of if (!is_nullorempty($socialiteProvider) && is_subclass_of($socialiteProvider, \Exceedone\Exment\Auth\ProviderLoginConfig::class)) { - /** @phpstan-ignore-next-line */ $form->exmheader(exmtrans('login.custom_setting'))->hr(); + // @phpstan-ignore-next-line $socialiteProvider->setLoginSettingForm($form); } } catch (\Exception $ex) { diff --git a/src/Services/Login/OAuth/OAuthUser.php b/src/Services/Login/OAuth/OAuthUser.php index ce6886711..cb72f6baf 100644 --- a/src/Services/Login/OAuth/OAuthUser.php +++ b/src/Services/Login/OAuth/OAuthUser.php @@ -13,6 +13,7 @@ */ class OAuthUser extends CustomLoginUserBase { + // @phpstan-ignore-next-line public $avatar; /** @@ -28,8 +29,10 @@ class OAuthUser extends CustomLoginUserBase * @var string */ public $refreshToken; + // @phpstan-ignore-next-line public $expiresIn; + // @phpstan-ignore-next-line public static function with($provider_name, $provider_user, $isTest = false) { $user = new OAuthUser(); diff --git a/src/Services/Login/Pure/PureService.php b/src/Services/Login/Pure/PureService.php index 20566183d..9f3ea5c1e 100644 --- a/src/Services/Login/Pure/PureService.php +++ b/src/Services/Login/Pure/PureService.php @@ -26,6 +26,7 @@ public static function retrieveByCredential(array $credentials) * @param array $credentials * @return bool */ + // @phpstan-ignore-next-line public static function validateCredential(?Authenticatable $login_user, array $credentials) { if (is_null($login_user)) { diff --git a/src/Services/Login/Saml/SamlService.php b/src/Services/Login/Saml/SamlService.php index eecf8557c..1fd4a657b 100644 --- a/src/Services/Login/Saml/SamlService.php +++ b/src/Services/Login/Saml/SamlService.php @@ -34,6 +34,7 @@ class SamlService implements LoginServiceInterface * * @throws SsoLoginErrorException */ + // @phpstan-ignore-next-line public static function retrieveByCredential(array $credentials) { list($result, $message, $adminMessage, $custom_login_user) = static::loginCallback(request(), array_get($credentials, 'login_setting') ?? LoginSetting::getSamlSetting(array_get($credentials, 'provider_name'))); @@ -59,6 +60,7 @@ public static function retrieveByCredential(array $credentials) * @param array $credentials * @return boolean */ + // @phpstan-ignore-next-line public static function validateCredential(Authenticatable $login_user, array $credentials) { // always true. @@ -79,6 +81,7 @@ public static function getTestForm(LoginSetting $login_setting) + // @phpstan-ignore-next-line public static function setSamlForm($form, $login_setting, $errors) { if (array_has($errors, LoginType::SAML)) { @@ -214,6 +217,7 @@ public static function loginTest(Request $request, $login_setting) * @param LoginSetting $login_setting * @return array $result(bool), $message(string), $adminMessage(string), $custom_login_user */ + // @phpstan-ignore-next-line public static function loginCallback(Request $request, $login_setting, $isTest = false) { try { @@ -221,14 +225,14 @@ public static function loginCallback(Request $request, $login_setting, $isTest = $errors = $saml2Auth->acs(); if (!empty($errors)) { - /** @phpstan-ignore-next-line getLoginResult()F expects bool, string given */ + // @phpstan-ignore-next-line return LoginService::getLoginResult(SsoLoginErrorType::PROVIDER_ERROR, array_get($errors, 'last_error_reason', array_get($errors, 'error'))); } $custom_login_user = SamlUser::with($login_setting->provider_name, $saml2Auth->getSaml2User(), true); if (!is_nullorempty($custom_login_user->mapping_errors)) { - /** @phpstan-ignore-next-line getLoginResult() expects bool, string given */ + // @phpstan-ignore-next-line return LoginService::getLoginResult(SsoLoginErrorType::SYNC_MAPPING_ERROR, $custom_login_user->mapping_errors); } @@ -236,10 +240,10 @@ public static function loginCallback(Request $request, $login_setting, $isTest = $validator = LoginService::validateCustomLoginSync($custom_login_user); if ($validator->fails()) { return LoginService::getLoginResult( - /** @phpstan-ignore-next-line getLoginResult() expects bool, string given */ + // @phpstan-ignore-next-line SsoLoginErrorType::SYNC_VALIDATION_ERROR, exmtrans('login.sso_provider_error_validate', ['errors' => implode(' ', $validator->getMessageStrings())]), - /** @phpstan-ignore-next-line getLoginResult() expects array|null, Illuminate\Support\MessageBag given */ + // @phpstan-ignore-next-line $validator->errors(), $custom_login_user ); @@ -249,16 +253,17 @@ public static function loginCallback(Request $request, $login_setting, $isTest = } catch (\Exception $ex) { \Log::error($ex); - /** @phpstan-ignore-next-line getLoginResult() expects bool, string given */ + // @phpstan-ignore-next-line return LoginService::getLoginResult(SsoLoginErrorType::UNDEFINED_ERROR, exmtrans('login.sso_provider_error'), [$ex]); } catch (\Throwable $ex) { \Log::error($ex); - /** @phpstan-ignore-next-line getLoginResult() expects bool, string given */ + // @phpstan-ignore-next-line return LoginService::getLoginResult(SsoLoginErrorType::UNDEFINED_ERROR, exmtrans('login.sso_provider_error'), [$ex]); } } + // @phpstan-ignore-next-line public static function appendActivateSwalButton($tools, LoginSetting $login_setting) { return LoginService::appendActivateSwalButtonSso($tools, $login_setting); diff --git a/src/Services/Login/Saml/SamlUser.php b/src/Services/Login/Saml/SamlUser.php index 92e31caec..abf8d2c60 100644 --- a/src/Services/Login/Saml/SamlUser.php +++ b/src/Services/Login/Saml/SamlUser.php @@ -13,6 +13,7 @@ */ class SamlUser extends CustomLoginUserBase { + // @phpstan-ignore-next-line public static function with($provider_name, $samlUser, $isTest = false) { $user = new SamlUser(); @@ -38,6 +39,7 @@ public static function with($provider_name, $samlUser, $isTest = false) * @param $replaceMaps * @return array|mixed|string|string[]|null */ + // @phpstan-ignore-next-line protected static function getMappingItemValue($samlUser, $mappingKey, $replaceMaps) { // get attributes @@ -46,7 +48,7 @@ protected static function getMappingItemValue($samlUser, $mappingKey, $replaceMa $hasValue = false; foreach ($replaceMaps as $replaceKey => $replaceValue) { if (!array_has($samlAttibutes, $replaceKey)) { - /** @phpstan-ignore-next-line str_replace expects array|string, null given */ + // @phpstan-ignore-next-line $mappingKey = str_replace($replaceValue, null, $mappingKey); continue; } diff --git a/src/Services/LoginService.php b/src/Services/LoginService.php index 51b89f11d..02a293fc6 100644 --- a/src/Services/LoginService.php +++ b/src/Services/LoginService.php @@ -9,6 +9,7 @@ */ class LoginService { + // @phpstan-ignore-next-line public static function setToken() { return NewLoginService::setToken(); @@ -19,6 +20,7 @@ public static function setToken() * * @return array access_token, refresh_token, provider */ + // @phpstan-ignore-next-line public static function getToken() { return NewLoginService::getToken(); diff --git a/src/Services/Notify/ActionUser.php b/src/Services/Notify/ActionUser.php index 1eafee6f1..2811a667c 100644 --- a/src/Services/Notify/ActionUser.php +++ b/src/Services/Notify/ActionUser.php @@ -11,6 +11,7 @@ class ActionUser extends NotifyTargetBase { + // @phpstan-ignore-next-line public function getModels(?CustomValue $custom_value, ?CustomTable $custom_table): Collection { // work user not use getModels @@ -24,10 +25,12 @@ public function getModels(?CustomValue $custom_value, ?CustomTable $custom_table * @param CustomValue $custom_value * @return Collection */ + // @phpstan-ignore-next-line public function getModelsWorkflow(?CustomValue $custom_value, WorkflowAction $workflow_action, ?WorkflowValue $workflow_value, $statusTo): Collection { $base_user = \Exment::user()->base_user; /** @var Collection $users */ + // @phpstan-ignore-next-line $users = collect([$base_user]); return $users->map(function ($user) { diff --git a/src/Services/Notify/Administrator.php b/src/Services/Notify/Administrator.php index e5883c15c..cac999259 100644 --- a/src/Services/Notify/Administrator.php +++ b/src/Services/Notify/Administrator.php @@ -13,6 +13,7 @@ class Administrator extends NotifyTargetBase { + // @phpstan-ignore-next-line public function getModels(?CustomValue $custom_value, ?CustomTable $custom_table): Collection { return $this->_getModel(); @@ -25,12 +26,14 @@ public function getModels(?CustomValue $custom_value, ?CustomTable $custom_table * @param CustomValue $custom_value * @return Collection */ + // @phpstan-ignore-next-line public function getModelsWorkflow(?CustomValue $custom_value, WorkflowAction $workflow_action, ?WorkflowValue $workflow_value, $statusTo): Collection { return $this->_getModel(); } + // @phpstan-ignore-next-line protected function _getModel() { $admins = System::system_admin_users(); diff --git a/src/Services/Notify/Column.php b/src/Services/Notify/Column.php index a0112480e..7d28f5a7b 100644 --- a/src/Services/Notify/Column.php +++ b/src/Services/Notify/Column.php @@ -22,6 +22,7 @@ class Column extends NotifyTargetBase */ protected $column; + // @phpstan-ignore-next-line public function __construct(Notify $notify, array $action_setting, $column) { parent::__construct($notify, $action_setting); @@ -29,6 +30,7 @@ public function __construct(Notify $notify, array $action_setting, $column) $this->column = $column; } + // @phpstan-ignore-next-line public function getModels(?CustomValue $custom_value, ?CustomTable $custom_table): Collection { $result = collect(); @@ -93,6 +95,7 @@ public function getModels(?CustomValue $custom_value, ?CustomTable $custom_table * @param CustomValue $custom_value * @return Collection */ + // @phpstan-ignore-next-line public function getModelsWorkflow(?CustomValue $custom_value, WorkflowAction $workflow_action, ?WorkflowValue $workflow_value, $statusTo): Collection { return $this->getModels($custom_value, null); diff --git a/src/Services/Notify/CreatedUser.php b/src/Services/Notify/CreatedUser.php index 04e5b972c..61a0fff1b 100644 --- a/src/Services/Notify/CreatedUser.php +++ b/src/Services/Notify/CreatedUser.php @@ -11,6 +11,7 @@ class CreatedUser extends NotifyTargetBase { + // @phpstan-ignore-next-line public function getModels(?CustomValue $custom_value, ?CustomTable $custom_table): Collection { return $this->_getModel($custom_value); @@ -23,12 +24,14 @@ public function getModels(?CustomValue $custom_value, ?CustomTable $custom_table * @param CustomValue $custom_value * @return Collection */ + // @phpstan-ignore-next-line public function getModelsWorkflow(?CustomValue $custom_value, WorkflowAction $workflow_action, ?WorkflowValue $workflow_value, $statusTo): Collection { return $this->_getModel($custom_value); } + // @phpstan-ignore-next-line protected function _getModel(?CustomValue $custom_value) { if (!$custom_value) { diff --git a/src/Services/Notify/FixedEmail.php b/src/Services/Notify/FixedEmail.php index d2ba94f2e..2923676e7 100644 --- a/src/Services/Notify/FixedEmail.php +++ b/src/Services/Notify/FixedEmail.php @@ -11,6 +11,7 @@ class FixedEmail extends NotifyTargetBase { + // @phpstan-ignore-next-line public function getModels(?CustomValue $custom_value, ?CustomTable $custom_table): Collection { return $this->getFixedEmail(); @@ -23,12 +24,14 @@ public function getModels(?CustomValue $custom_value, ?CustomTable $custom_table * @param CustomValue $custom_value * @return Collection */ + // @phpstan-ignore-next-line public function getModelsWorkflow(?CustomValue $custom_value, WorkflowAction $workflow_action, ?WorkflowValue $workflow_value, $statusTo): Collection { return $this->getFixedEmail(); } + // @phpstan-ignore-next-line protected function getFixedEmail(): Collection { $emails = array_get($this->action_setting, 'target_emails'); @@ -36,6 +39,7 @@ protected function getFixedEmail(): Collection $emails = breakCommaToArray($emails); /** @var Collection $collection */ + // @phpstan-ignore-next-line $collection = collect($emails)->filter(function ($email) { return filter_var($email, FILTER_VALIDATE_EMAIL) !== false; })->map(function ($email) { diff --git a/src/Services/Notify/FixedOrganization.php b/src/Services/Notify/FixedOrganization.php index 3cf4077fd..9e73080ca 100644 --- a/src/Services/Notify/FixedOrganization.php +++ b/src/Services/Notify/FixedOrganization.php @@ -12,6 +12,7 @@ class FixedOrganization extends NotifyTargetBase { + // @phpstan-ignore-next-line public function getModels(?CustomValue $custom_value, ?CustomTable $custom_table): Collection { return $this->getFixedOrganization(); @@ -24,12 +25,14 @@ public function getModels(?CustomValue $custom_value, ?CustomTable $custom_table * @param CustomValue $custom_value * @return Collection */ + // @phpstan-ignore-next-line public function getModelsWorkflow(?CustomValue $custom_value, WorkflowAction $workflow_action, ?WorkflowValue $workflow_value, $statusTo): Collection { return $this->getFixedOrganization(); } + // @phpstan-ignore-next-line protected function getFixedOrganization(): Collection { $orgs = array_get($this->action_setting, 'target_organizations'); diff --git a/src/Services/Notify/FixedUser.php b/src/Services/Notify/FixedUser.php index 0c0af96d3..b55a4270e 100644 --- a/src/Services/Notify/FixedUser.php +++ b/src/Services/Notify/FixedUser.php @@ -12,6 +12,7 @@ class FixedUser extends NotifyTargetBase { + // @phpstan-ignore-next-line public function getModels(?CustomValue $custom_value, ?CustomTable $custom_table): Collection { return $this->getFixedUser(); @@ -24,12 +25,14 @@ public function getModels(?CustomValue $custom_value, ?CustomTable $custom_table * @param CustomValue $custom_value * @return Collection */ + // @phpstan-ignore-next-line public function getModelsWorkflow(?CustomValue $custom_value, WorkflowAction $workflow_action, ?WorkflowValue $workflow_value, $statusTo): Collection { return $this->getFixedUser(); } + // @phpstan-ignore-next-line protected function getFixedUser(): Collection { $users = array_get($this->action_setting, 'target_users'); @@ -39,6 +42,7 @@ protected function getFixedUser(): Collection } /** @var Collection $collection */ + // @phpstan-ignore-next-line $collection = collect(stringToArray($users))->map(function ($user) { $user = getModelName(SystemTableName::USER)::find($user); return NotifyTarget::getModelAsUser($user); diff --git a/src/Services/Notify/HasRoles.php b/src/Services/Notify/HasRoles.php index 9e79271ac..b289122d5 100644 --- a/src/Services/Notify/HasRoles.php +++ b/src/Services/Notify/HasRoles.php @@ -9,6 +9,7 @@ class HasRoles extends NotifyTargetBase { + // @phpstan-ignore-next-line public function getModels(?CustomValue $custom_value, ?CustomTable $custom_table): Collection { return NotifyTarget::getModelsAsRole($custom_value, $custom_table); diff --git a/src/Services/Notify/NotifyTargetBase.php b/src/Services/Notify/NotifyTargetBase.php index ac00075ee..8dce12d29 100644 --- a/src/Services/Notify/NotifyTargetBase.php +++ b/src/Services/Notify/NotifyTargetBase.php @@ -25,8 +25,10 @@ abstract class NotifyTargetBase * * @var array */ + // @phpstan-ignore-next-line protected $action_setting; + // @phpstan-ignore-next-line public function __construct(Notify $notify, array $action_setting) { $this->notify = $notify; @@ -40,6 +42,7 @@ public function __construct(Notify $notify, array $action_setting) * @param Notify $notify model * @return NotifyTargetBase|null */ + // @phpstan-ignore-next-line public static function make($notify_action_target, Notify $notify, array $action_setting): ?NotifyTargetBase { if ($notify_action_target instanceof CustomColumn) { @@ -84,6 +87,7 @@ public static function make($notify_action_target, Notify $notify, array $action * @param CustomValue $custom_value * @return Collection Please return Notify target's collection */ + // @phpstan-ignore-next-line abstract public function getModels(?CustomValue $custom_value, ?CustomTable $custom_table): Collection; @@ -96,6 +100,7 @@ abstract public function getModels(?CustomValue $custom_value, ?CustomTable $cus * @param mixed $statusTo * @return Collection Please return Notify target's collection */ + // @phpstan-ignore-next-line public function getModelsWorkflow(?CustomValue $custom_value, WorkflowAction $workflow_action, ?WorkflowValue $workflow_value, $statusTo): Collection { return collect(); diff --git a/src/Services/Notify/RelationColumn.php b/src/Services/Notify/RelationColumn.php index 78a8a5a81..509155001 100644 --- a/src/Services/Notify/RelationColumn.php +++ b/src/Services/Notify/RelationColumn.php @@ -31,6 +31,7 @@ class RelationColumn extends Column */ protected $relationTable; + // @phpstan-ignore-next-line public function __construct(Notify $notify, array $action_setting, $column) { $this->notify = $notify; @@ -40,6 +41,7 @@ public function __construct(Notify $notify, array $action_setting, $column) $this->column = !is_nullorempty($column) ? CustomColumn::getEloquent(explode('?', $column)[0]) : null; } + // @phpstan-ignore-next-line public function getModels(?CustomValue $custom_value, ?CustomTable $custom_table): Collection { $result = collect(); diff --git a/src/Services/Notify/WorkUser.php b/src/Services/Notify/WorkUser.php index 41b64896a..ffb0b0f4d 100644 --- a/src/Services/Notify/WorkUser.php +++ b/src/Services/Notify/WorkUser.php @@ -13,6 +13,7 @@ class WorkUser extends NotifyTargetBase { + // @phpstan-ignore-next-line public function getModels(?CustomValue $custom_value, ?CustomTable $custom_table): Collection { // work user not use getModels @@ -26,6 +27,7 @@ public function getModels(?CustomValue $custom_value, ?CustomTable $custom_table * @param CustomValue $custom_value * @return Collection */ + // @phpstan-ignore-next-line public function getModelsWorkflow(?CustomValue $custom_value, WorkflowAction $workflow_action, ?WorkflowValue $workflow_value, $statusTo): Collection { $workflow = $workflow_action->workflow_cache; diff --git a/src/Services/NotifyService.php b/src/Services/NotifyService.php index 3141d81a1..5b6a4b4b4 100644 --- a/src/Services/NotifyService.php +++ b/src/Services/NotifyService.php @@ -30,14 +30,24 @@ */ class NotifyService { + /** @var Notify */ protected $notify; + /** @var mixed */ protected $targetid; + /** @var CustomTable|null */ protected $custom_table; + /** @var CustomValue|null */ protected $custom_value; + /** + * @param Notify $notify + * @param mixed $targetid + * @param mixed $tableKey + * @param mixed $id + */ public function __construct(Notify $notify, $targetid, $tableKey, $id) { $this->notify = $notify; @@ -107,6 +117,7 @@ public function getNotifyDialogForm() * @param array|\Illuminate\Support\Collection $target_users * @return ModalForm */ + // @phpstan-ignore-next-line public function getNotifyDialogFormMultiple($target_users) { $users = []; @@ -117,6 +128,7 @@ public function getNotifyDialogFormMultiple($target_users) } } + // @phpstan-ignore-next-line return $this->getSendForm($users, true); } @@ -127,6 +139,7 @@ public function getNotifyDialogFormMultiple($target_users) * @param $isFlow * @return ModalForm|false */ + // @phpstan-ignore-next-line protected function getSendForm($notifyTargets, $isFlow = false) { $tableKey = $this->custom_table->table_name; @@ -213,6 +226,7 @@ protected function getSendForm($notifyTargets, $isFlow = false) * @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface */ + // @phpstan-ignore-next-line public function sendNotifyMail($custom_table) { $request = request(); @@ -271,6 +285,7 @@ public function sendNotifyMail($custom_table) * @param \Illuminate\Support\Collection $values * @return boolean */ + // @phpstan-ignore-next-line protected function hasNotifyUserByButton(\Illuminate\Support\Collection $values): bool { // Exists user, return true @@ -295,6 +310,7 @@ protected function hasNotifyUserByButton(\Illuminate\Support\Collection $values) * @param \Illuminate\Support\Collection $notifyTargets * @return string */ + // @phpstan-ignore-next-line protected function getNotifyTargetLabel(\Illuminate\Support\Collection $notifyTargets): string { $targets = clone $notifyTargets; @@ -364,6 +380,7 @@ public static function executeTestNotify($params = []): Notifications\SenderBase * @param array $params * @return void */ + // @phpstan-ignore-next-line public static function executeNotifyAction($notify, $params = []) { $params = array_merge( @@ -444,6 +461,7 @@ public static function executeNotifyAction($notify, $params = []) * @param array $params * @return Notifications\SenderBase */ + // @phpstan-ignore-next-line public static function notifyMail(array $params = []) { $params = array_merge( @@ -501,6 +519,7 @@ public static function notifyMail(array $params = []) * @param array $params * @return Notifications\SenderBase */ + // @phpstan-ignore-next-line public static function notifyNavbar(array $params = []): Notifications\SenderBase { $params = array_merge( @@ -556,6 +575,7 @@ public static function notifyNavbar(array $params = []): Notifications\SenderBas * @param array $params * @return Notifications\SenderBase */ + // @phpstan-ignore-next-line public static function notifySlack(array $params = []) { return static::notifyWebHook($params, Notifications\SlackSender::class); @@ -568,6 +588,7 @@ public static function notifySlack(array $params = []) * @param array $params * @return Notifications\SenderBase */ + // @phpstan-ignore-next-line public static function notifyTeams(array $params = []) { return static::notifyWebHook($params, Notifications\MicrosoftTeamsSender::class); @@ -581,6 +602,7 @@ public static function notifyTeams(array $params = []) * @param string $className * @return Notifications\SenderBase */ + // @phpstan-ignore-next-line protected static function notifyWebHook(array $params, string $className): Notifications\SenderBase { $params = array_merge( @@ -621,6 +643,7 @@ protected static function notifyWebHook(array $params, string $className): Notif /** * replace subject and body from mail template */ + // @phpstan-ignore-next-line public static function replaceSubjectBody(&$params = []) { $params = array_merge( @@ -672,6 +695,7 @@ public static function replaceSubjectBody(&$params = []) * @param bool $isSelectTarget * @return array */ + // @phpstan-ignore-next-line protected function getProgressInfo($isSelectTarget) { $steps[] = [ @@ -694,6 +718,7 @@ protected function getProgressInfo($isSelectTarget) /** * replace subject or body words. */ + // @phpstan-ignore-next-line public static function replaceWord($target, $custom_value = null, $prms = null, $replaceOptions = []) { $replaceOptions = array_merge([ @@ -716,6 +741,7 @@ public static function replaceWord($target, $custom_value = null, $prms = null, } + // @phpstan-ignore-next-line public static function getNotifyTargetColumns($custom_table, $notify_action, array $options = []) { // get notify options by notify action @@ -871,6 +897,7 @@ public static function getNotifyTargetColumns($custom_table, $notify_action, arr * @return string|null * @throws \Exception */ + // @phpstan-ignore-next-line public static function getAddress($user): ?string { $result = static::getAddresses($user); @@ -883,6 +910,7 @@ public static function getAddress($user): ?string * @param string|array|CustomValue|NotifyTarget $users * @return array */ + // @phpstan-ignore-next-line public static function getAddresses($users): array { // Convert "," string to array @@ -892,6 +920,7 @@ public static function getAddresses($users): array $users = [$users]; } $addresses = collect(); + // @phpstan-ignore-next-line foreach ($users as $user) { if ($user instanceof CustomValue) { $addresses->push($user->getValue('email')); diff --git a/src/Services/PartialCrudService.php b/src/Services/PartialCrudService.php index 5494e77b6..adb0dd2ce 100644 --- a/src/Services/PartialCrudService.php +++ b/src/Services/PartialCrudService.php @@ -7,6 +7,7 @@ */ class PartialCrudService { + // @phpstan-ignore-next-line protected static $providers = [ ]; @@ -15,11 +16,13 @@ class PartialCrudService * * @return void */ + // @phpstan-ignore-next-line public static function providers($provider, $options) { static::$providers[$provider] = $options; } + // @phpstan-ignore-next-line public static function setAdminFormOptions($custom_table, &$form, $id = null) { static::getItem($custom_table, function ($item) use (&$form, $id) { @@ -27,6 +30,7 @@ public static function setAdminFormOptions($custom_table, &$form, $id = null) }); } + // @phpstan-ignore-next-line public static function setAdminFormTools($custom_table, &$tools, $id = null) { static::getItem($custom_table, function ($item) use (&$tools, $id) { @@ -34,6 +38,7 @@ public static function setAdminFormTools($custom_table, &$tools, $id = null) }); } + // @phpstan-ignore-next-line public static function setAdminShowTools($custom_table, &$tools, $id = null) { static::getItem($custom_table, function ($item) use (&$tools, $id) { @@ -41,6 +46,7 @@ public static function setAdminShowTools($custom_table, &$tools, $id = null) }); } + // @phpstan-ignore-next-line public static function setGridContent($custom_table, &$form, $id = null) { static::getItem($custom_table, function ($item) use (&$form, $id) { @@ -48,6 +54,7 @@ public static function setGridContent($custom_table, &$form, $id = null) }); } + // @phpstan-ignore-next-line public static function setGridRowAction($custom_table, &$actions) { static::getItem($custom_table, function ($item) use (&$actions) { @@ -55,30 +62,33 @@ public static function setGridRowAction($custom_table, &$actions) }); } + // @phpstan-ignore-next-line public static function saving($custom_table, &$form, $id = null) { return static::getItem($custom_table, function ($item) use (&$form, $id) { $result = $item->saving($form, $id); - /** @phpstan-ignore-next-line Instanceof between *NEVER* and Illuminate\Http\Response will always evaluate to false. */ + // @phpstan-ignore-next-line if ($result instanceof \Symfony\Component\HttpFoundation\Response || $result instanceof \Illuminate\Http\Response) { return $result; } }); } + // @phpstan-ignore-next-line public static function saved($custom_table, &$form, $id = null) { return static::getItem($custom_table, function ($item) use (&$form, $id) { $result = $item->saved($form, $id); - /** @phpstan-ignore-next-line Instanceof between *NEVER* and Illuminate\Http\Response will always evaluate to false. */ + // @phpstan-ignore-next-line if ($result instanceof \Symfony\Component\HttpFoundation\Response || $result instanceof \Illuminate\Http\Response) { return $result; } }); } + // @phpstan-ignore-next-line protected static function getItem($custom_table, $callback) { foreach (static::$providers as $provider) { diff --git a/src/Services/Plugin/PluginApiBase.php b/src/Services/Plugin/PluginApiBase.php index 5d63f632b..b147fb000 100644 --- a/src/Services/Plugin/PluginApiBase.php +++ b/src/Services/Plugin/PluginApiBase.php @@ -16,11 +16,13 @@ class PluginApiBase use ApiTrait; use PluginBase; + // @phpstan-ignore-next-line public function _plugin() { return $this->plugin; } + // @phpstan-ignore-next-line public function __construct($plugin) { $this->plugin = $plugin; @@ -31,6 +33,7 @@ public function __construct($plugin) * * @return string|null */ + // @phpstan-ignore-next-line public function getRouteUri($endpoint = null) { if (!isset($this->plugin)) { diff --git a/src/Services/Plugin/PluginApiController.php b/src/Services/Plugin/PluginApiController.php index c166f7e49..1ecd667d4 100644 --- a/src/Services/Plugin/PluginApiController.php +++ b/src/Services/Plugin/PluginApiController.php @@ -7,6 +7,7 @@ class PluginApiController extends Controller { + // @phpstan-ignore-next-line protected $pluginApi; public function __construct(?PluginApiBase $pluginApi) @@ -20,6 +21,7 @@ public function __construct(?PluginApiBase $pluginApi) * @return mixed * */ + // @phpstan-ignore-next-line public function __call($method, $parameters) { if (!$this->pluginApi) { @@ -35,6 +37,7 @@ public function __call($method, $parameters) } // create html + // @phpstan-ignore-next-line $result = call_user_func_array([$this->pluginApi, $method], array_values($parameters)); return $result; diff --git a/src/Services/Plugin/PluginBase.php b/src/Services/Plugin/PluginBase.php index 9bf360e1f..8f0e83a94 100644 --- a/src/Services/Plugin/PluginBase.php +++ b/src/Services/Plugin/PluginBase.php @@ -6,12 +6,16 @@ trait PluginBase { + // @phpstan-ignore-next-line protected $plugin; + // @phpstan-ignore-next-line protected $useCustomOption = false; + // @phpstan-ignore-next-line protected $pluginOptions; + // @phpstan-ignore-next-line public function useCustomOption() { return $this->useCustomOption; @@ -31,6 +35,7 @@ public function setCustomOptionForm(&$form) /** * Get the value of pluginOptions */ + // @phpstan-ignore-next-line public function getPluginOptions() { return $this->pluginOptions; @@ -41,6 +46,7 @@ public function getPluginOptions() * * @return self */ + // @phpstan-ignore-next-line public function setPluginOptions($pluginOptions) { $this->pluginOptions = $pluginOptions; diff --git a/src/Services/Plugin/PluginBatchBase.php b/src/Services/Plugin/PluginBatchBase.php index 39c108813..7084d2595 100644 --- a/src/Services/Plugin/PluginBatchBase.php +++ b/src/Services/Plugin/PluginBatchBase.php @@ -9,6 +9,7 @@ class PluginBatchBase { use PluginBase; + // @phpstan-ignore-next-line public function __construct($plugin, $options = []) { $this->plugin = $plugin; diff --git a/src/Services/Plugin/PluginButtonBase.php b/src/Services/Plugin/PluginButtonBase.php index aeb8ea52d..e3734a383 100644 --- a/src/Services/Plugin/PluginButtonBase.php +++ b/src/Services/Plugin/PluginButtonBase.php @@ -13,7 +13,9 @@ class PluginButtonBase use PluginButtonTrait; use PluginPageTrait; + // @phpstan-ignore-next-line public $custom_table; + // @phpstan-ignore-next-line public $custom_value; /** @@ -21,10 +23,13 @@ class PluginButtonBase * * @var \Illuminate\Support\Collection */ + // @phpstan-ignore-next-line public $selected_custom_values; + // @phpstan-ignore-next-line public $isCreate; + // @phpstan-ignore-next-line public function __construct($plugin, $custom_table, $custom_value, $options = []) { $this->_initButton($plugin, $custom_table, $custom_value, $options); @@ -32,6 +37,7 @@ public function __construct($plugin, $custom_table, $custom_value, $options = [] $this->selected_custom_values = array_get($options, 'selected_custom_values', collect()); } + // @phpstan-ignore-next-line public function execute() { } diff --git a/src/Services/Plugin/PluginButtonTrait.php b/src/Services/Plugin/PluginButtonTrait.php index 12a5c90a2..c75a82d1b 100644 --- a/src/Services/Plugin/PluginButtonTrait.php +++ b/src/Services/Plugin/PluginButtonTrait.php @@ -19,6 +19,7 @@ trait PluginButtonTrait * @param array $options * @return void */ + // @phpstan-ignore-next-line protected function _initButton($plugin, $custom_table, $custom_value, $options = []) { $this->plugin = $plugin; @@ -31,6 +32,7 @@ protected function _initButton($plugin, $custom_table, $custom_value, $options = } } + // @phpstan-ignore-next-line public function getButtonLabel() { // get label diff --git a/src/Services/Plugin/PluginCrud/CrudBase.php b/src/Services/Plugin/PluginCrud/CrudBase.php index 41844dc4b..eb026bc4e 100644 --- a/src/Services/Plugin/PluginCrud/CrudBase.php +++ b/src/Services/Plugin/PluginCrud/CrudBase.php @@ -12,15 +12,17 @@ abstract class CrudBase * @param $plugin * @param $pluginClass * @param $options - * @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line public function __construct($plugin, $pluginClass, $options = []) { $this->plugin = $plugin; $this->pluginClass = $pluginClass; } + // @phpstan-ignore-next-line protected $plugin; + // @phpstan-ignore-next-line protected $pluginClass; @@ -29,6 +31,7 @@ public function __construct($plugin, $pluginClass, $options = []) * * @return string */ + // @phpstan-ignore-next-line public function getFullUrl(...$endpoint): string { return $this->pluginClass->getFullUrl(...$endpoint); @@ -40,12 +43,14 @@ public function getFullUrl(...$endpoint): string * * @return string */ + // @phpstan-ignore-next-line public function getRootFullUrl(...$endpoint): string { return $this->pluginClass->getRootFullUrl(...$endpoint); } + // @phpstan-ignore-next-line protected function getOAuthLogoutView() { if ($this->pluginClass->getAuthType() != PluginCrudAuthType::OAUTH) { diff --git a/src/Services/Plugin/PluginCrud/CrudForm.php b/src/Services/Plugin/PluginCrud/CrudForm.php index 5b01abaef..76901c0a8 100644 --- a/src/Services/Plugin/PluginCrud/CrudForm.php +++ b/src/Services/Plugin/PluginCrud/CrudForm.php @@ -35,6 +35,7 @@ public function create() * @param $id * @return mixed */ + // @phpstan-ignore-next-line public function edit($id) { $content = $this->pluginClass->getContent(); @@ -62,6 +63,7 @@ public function store() * @param $id * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ + // @phpstan-ignore-next-line public function update($id) { $content = $this->pluginClass->getContent(); @@ -75,6 +77,7 @@ public function update($id) * @param $id * @return string */ + // @phpstan-ignore-next-line public function delete($id) { $ids = stringToArray($id); @@ -90,10 +93,11 @@ public function delete($id) * @param $id * @return Box */ + // @phpstan-ignore-next-line protected function form(bool $isCreate, $id = null) { $form = $this->getForm($isCreate, $id); - /** @phpstan-ignore-next-line constructor expects string, Encore\Admin\Widgets\Form given */ + // @phpstan-ignore-next-line $box = new Box(trans($isCreate ? 'admin.create' : 'admin.edit'), $form); $box->style('info'); $this->setFormTools($id, $box); @@ -115,6 +119,7 @@ protected function form(bool $isCreate, $id = null) * @param $id * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ + // @phpstan-ignore-next-line protected function save(bool $isCreate, $id = null) { $values = $this->filterPostedValue(request()->all(), $isCreate); @@ -155,6 +160,7 @@ protected function save(bool $isCreate, $id = null) * @param boolean $isCreate * @return array */ + // @phpstan-ignore-next-line protected function filterPostedValue(array $array, bool $isCreate): array { $key = $isCreate ? 'create' : 'edit'; @@ -236,6 +242,7 @@ protected function setFormColumn(bool $isCreate, Form $form) * @param Box $box * @return void */ + // @phpstan-ignore-next-line protected function setFormTools($id, Box $box) { // get oauth logout view diff --git a/src/Services/Plugin/PluginCrud/CrudGrid.php b/src/Services/Plugin/PluginCrud/CrudGrid.php index cbb07a743..459132230 100644 --- a/src/Services/Plugin/PluginCrud/CrudGrid.php +++ b/src/Services/Plugin/PluginCrud/CrudGrid.php @@ -189,6 +189,7 @@ protected function setGridActions(Grid $grid) // create import and exporter + // @phpstan-ignore-next-line protected function getImportExportService(Grid $grid) { $service = (new DataImportExport\DataImportExportWidgetService()) diff --git a/src/Services/Plugin/PluginCrud/CrudShow.php b/src/Services/Plugin/PluginCrud/CrudShow.php index ad738454e..b3793e403 100644 --- a/src/Services/Plugin/PluginCrud/CrudShow.php +++ b/src/Services/Plugin/PluginCrud/CrudShow.php @@ -19,6 +19,7 @@ class CrudShow extends CrudBase * @param $id * @return mixed */ + // @phpstan-ignore-next-line public function show($id) { $content = $this->pluginClass->getContent(); @@ -34,6 +35,7 @@ public function show($id) * @param $id * @return Box */ + // @phpstan-ignore-next-line protected function detail($id) { $data = $this->pluginClass->getData($id); @@ -43,7 +45,7 @@ protected function detail($id) $form->disableSubmit(); $this->setShowColumn($form); - /** @phpstan-ignore-next-line constructor expects string, Encore\Admin\Widgets\Form given */ + // @phpstan-ignore-next-line $box = new Box(trans('admin.detail'), $form); $box->style('info'); $this->setShowTools($id, $box); @@ -79,6 +81,7 @@ protected function setShowColumn(Form $form) * @param Box $box * @return void */ + // @phpstan-ignore-next-line protected function setShowTools($id, Box $box) { // get oauth logout view diff --git a/src/Services/Plugin/PluginCrudBase.php b/src/Services/Plugin/PluginCrudBase.php index 3307db7c8..2ba23ad5a 100644 --- a/src/Services/Plugin/PluginCrudBase.php +++ b/src/Services/Plugin/PluginCrudBase.php @@ -19,6 +19,7 @@ abstract class PluginCrudBase extends PluginPublicBase use PluginBase; use PluginPageTrait; + // @phpstan-ignore-next-line public function __construct($plugin, $options = []) { $this->plugin = $plugin; @@ -81,6 +82,7 @@ public function __construct($plugin, $options = []) */ public $deleteClass = PluginCrud\CrudForm::class; + // @phpstan-ignore-next-line protected $endpoint = null; /** @@ -88,6 +90,7 @@ public function __construct($plugin, $options = []) * * @return array|Collection */ + // @phpstan-ignore-next-line public function getFieldDefinitions() { return []; @@ -98,6 +101,7 @@ public function getFieldDefinitions() * * @return LengthAwarePaginator|null */ + // @phpstan-ignore-next-line public function getPaginate(array $options = []): ?LengthAwarePaginator { return null; @@ -108,6 +112,7 @@ public function getPaginate(array $options = []): ?LengthAwarePaginator * * @return Collection */ + // @phpstan-ignore-next-line public function getList(array $options = []): Collection { return collect(); @@ -128,6 +133,7 @@ public function getChunkCount(): int * * @return array|Collection */ + // @phpstan-ignore-next-line public function getData($id, array $options = []) { return collect(); @@ -138,6 +144,7 @@ public function getData($id, array $options = []) * * @return Form|null */ + // @phpstan-ignore-next-line public function setForm(Form $form, bool $isCreate, array $options = []): ?Form { return null; @@ -148,6 +155,7 @@ public function setForm(Form $form, bool $isCreate, array $options = []): ?Form * * @return mixed */ + // @phpstan-ignore-next-line public function postCreate(array $posts, array $options = []) { } @@ -157,6 +165,7 @@ public function postCreate(array $posts, array $options = []) * * @return mixed */ + // @phpstan-ignore-next-line public function putEdit($id, array $posts, array $options = []) { } @@ -167,6 +176,7 @@ public function putEdit($id, array $posts, array $options = []) * @param $id string * @return mixed */ + // @phpstan-ignore-next-line public function delete($id, array $options = []) { } @@ -177,6 +187,7 @@ public function delete($id, array $options = []) * @param $ids array * @return mixed */ + // @phpstan-ignore-next-line public function deletes(array $ids, array $options = []) { foreach ($ids as $id) { @@ -187,6 +198,7 @@ public function deletes(array $ids, array $options = []) /** * Get the value of endpoint */ + // @phpstan-ignore-next-line public function getEndpoint() { return $this->endpoint; @@ -197,6 +209,7 @@ public function getEndpoint() * * @return self */ + // @phpstan-ignore-next-line public function setEndpoint($endpoint) { $this->endpoint = $endpoint; @@ -210,6 +223,7 @@ public function setEndpoint($endpoint) * * @return Collection|null */ + // @phpstan-ignore-next-line public function getAllEndpoints(): ?Collection { return null; @@ -310,6 +324,7 @@ public function getAuthKey(): ?string * * @return array */ + // @phpstan-ignore-next-line public function getAuthIdPassword(): array { return [ @@ -328,6 +343,7 @@ public function getOauthAccessToken(): ?string return $this->pluginOptions->getOauthAccessToken(); } + // @phpstan-ignore-next-line public function _plugin() { return $this->plugin; @@ -338,6 +354,7 @@ public function _plugin() * * @return string|null */ + // @phpstan-ignore-next-line public function getRouteUri($endpoint = null) { if (!isset($this->plugin)) { @@ -352,6 +369,7 @@ public function getRouteUri($endpoint = null) * * @return string */ + // @phpstan-ignore-next-line public function getFullUrl(...$endpoint): string { array_unshift($endpoint, $this->getEndpoint()); @@ -364,6 +382,7 @@ public function getFullUrl(...$endpoint): string * * @return string */ + // @phpstan-ignore-next-line public function getRootFullUrl(...$endpoint): string { return $this->plugin->getFullUrl(...$endpoint); @@ -400,6 +419,7 @@ public function enablePaginate(): bool * * @return bool */ + // @phpstan-ignore-next-line public function enableShow($value): bool { return true; @@ -411,6 +431,7 @@ public function enableShow($value): bool * * @return bool */ + // @phpstan-ignore-next-line public function enableCreate(array $options = []): bool { return true; @@ -422,6 +443,7 @@ public function enableCreate(array $options = []): bool * * @return bool */ + // @phpstan-ignore-next-line public function enableEditAll(array $options = []): bool { return true; @@ -433,6 +455,7 @@ public function enableEditAll(array $options = []): bool * * @return bool */ + // @phpstan-ignore-next-line public function enableEdit($value, array $options = []): bool { return true; @@ -444,6 +467,7 @@ public function enableEdit($value, array $options = []): bool * * @return bool */ + // @phpstan-ignore-next-line public function enableDeleteAll(array $options = []): bool { return true; @@ -455,6 +479,7 @@ public function enableDeleteAll(array $options = []): bool * * @return bool */ + // @phpstan-ignore-next-line public function enableDelete($value, array $options = []): bool { return true; @@ -466,6 +491,7 @@ public function enableDelete($value, array $options = []): bool * * @return bool */ + // @phpstan-ignore-next-line public function enableExport(array $options = []): bool { return false; @@ -477,6 +503,7 @@ public function enableExport(array $options = []): bool * * @return bool */ + // @phpstan-ignore-next-line public function enableFreewordSearch(array $options = []): bool { return false; @@ -488,6 +515,7 @@ public function enableFreewordSearch(array $options = []): bool * * @return bool */ + // @phpstan-ignore-next-line public function enableAccessCrud(array $options = []): bool { return true; @@ -499,6 +527,7 @@ public function enableAccessCrud(array $options = []): bool * * @return bool */ + // @phpstan-ignore-next-line public function enableOAuthLogoutButton(array $options = []): bool { return true; @@ -509,6 +538,7 @@ public function enableOAuthLogoutButton(array $options = []): bool * Get cannot access title * @return string */ + // @phpstan-ignore-next-line public function getCannotAccessTitle(array $options = []): ?string { return exmtrans('plugin.error.crud_autherror_setting'); @@ -518,6 +548,7 @@ public function getCannotAccessTitle(array $options = []): ?string * Get cannot access message * @return string */ + // @phpstan-ignore-next-line public function getCannotAccessMessage(array $options = []): ?string { return exmtrans('plugin.error.crud_autherror_common_help'); @@ -541,6 +572,7 @@ public function callbackGrid(Grid $grid) * @param $tools * @return void */ + // @phpstan-ignore-next-line public function callbackGridTool($tools) { } @@ -552,6 +584,7 @@ public function callbackGridTool($tools) * @param Box $box * @return void */ + // @phpstan-ignore-next-line public function callbackShowTool($id, Box $box) { } @@ -562,6 +595,7 @@ public function callbackShowTool($id, Box $box) * @param Box $box * @return void */ + // @phpstan-ignore-next-line public function callbackFormTool($id, Box $box) { } @@ -572,6 +606,7 @@ public function callbackFormTool($id, Box $box) * @param $actions * @return void */ + // @phpstan-ignore-next-line public function callbackGridAction($actions) { } @@ -582,6 +617,7 @@ public function callbackGridAction($actions) * @param WidgetForm $form * @return void */ + // @phpstan-ignore-next-line public function callbackShow($id, WidgetForm $form, Box $box) { } @@ -602,6 +638,7 @@ public function callbackCreate(WidgetForm $form, Box $box) * @param WidgetForm $form * @return void */ + // @phpstan-ignore-next-line public function callbackEdit($id, WidgetForm $form, Box $box) { } @@ -670,6 +707,7 @@ public function setFormPrimaryDifinition(WidgetForm $form, string $key, string $ * @param $id * @return bool|\Illuminate\Support\MessageBag */ + // @phpstan-ignore-next-line public function validate(WidgetForm $form, array $values, bool $isCreate, $id) { return $form->validationMessageArray($values); diff --git a/src/Services/Plugin/PluginCrudController.php b/src/Services/Plugin/PluginCrudController.php index 5aeac9293..a05d94b78 100644 --- a/src/Services/Plugin/PluginCrudController.php +++ b/src/Services/Plugin/PluginCrudController.php @@ -10,7 +10,9 @@ class PluginCrudController extends Controller { + // @phpstan-ignore-next-line protected $pluginPage; + // @phpstan-ignore-next-line protected $plugin; public function __construct(?PluginCrudBase $pluginPage) @@ -25,6 +27,7 @@ public function __construct(?PluginCrudBase $pluginPage) * @param $endpoint * @return \Illuminate\Http\RedirectResponse|Response */ + // @phpstan-ignore-next-line public function index($endpoint = null) { $targetClass = $this->getClass($endpoint); @@ -33,6 +36,7 @@ public function index($endpoint = null) } $className = $targetClass->gridClass; + // @phpstan-ignore-next-line return (new $className($this->plugin, $targetClass))->index(); } @@ -43,6 +47,7 @@ public function index($endpoint = null) * @param $id * @return \Illuminate\Http\RedirectResponse|Response */ + // @phpstan-ignore-next-line public function show($endpoint = null, $id = null) { if (!is_nullorempty($endpoint) && is_nullorempty($id)) { @@ -56,6 +61,7 @@ public function show($endpoint = null, $id = null) } $className = $targetClass->showClass; + // @phpstan-ignore-next-line return (new $className($this->plugin, $targetClass))->show($id); } @@ -65,6 +71,7 @@ public function show($endpoint = null, $id = null) * @param $endpoint * @return \Illuminate\Http\RedirectResponse|Response */ + // @phpstan-ignore-next-line public function create($endpoint = null) { $targetClass = $this->getClass($endpoint); @@ -73,6 +80,7 @@ public function create($endpoint = null) } $className = $targetClass->createClass; + // @phpstan-ignore-next-line return (new $className($this->plugin, $targetClass))->create(); } @@ -82,6 +90,7 @@ public function create($endpoint = null) * @param $endpoint * @return \Illuminate\Http\RedirectResponse|Response */ + // @phpstan-ignore-next-line public function store($endpoint = null) { $targetClass = $this->getClass($endpoint); @@ -90,6 +99,7 @@ public function store($endpoint = null) } $className = $targetClass->createClass; + // @phpstan-ignore-next-line return (new $className($this->plugin, $targetClass))->store(); } @@ -100,6 +110,7 @@ public function store($endpoint = null) * @param $id * @return \Illuminate\Http\RedirectResponse|Response */ + // @phpstan-ignore-next-line public function edit($endpoint = null, $id = null) { if (!is_nullorempty($endpoint) && is_nullorempty($id)) { @@ -113,6 +124,7 @@ public function edit($endpoint = null, $id = null) } $className = $targetClass->editClass; + // @phpstan-ignore-next-line return (new $className($this->plugin, $targetClass))->edit($id); } @@ -123,6 +135,7 @@ public function edit($endpoint = null, $id = null) * @param $id * @return \Illuminate\Http\RedirectResponse|Response */ + // @phpstan-ignore-next-line public function update($endpoint = null, $id = null) { if (!is_nullorempty($endpoint) && is_nullorempty($id)) { @@ -136,6 +149,7 @@ public function update($endpoint = null, $id = null) } $className = $targetClass->editClass; + // @phpstan-ignore-next-line return (new $className($this->plugin, $targetClass))->update($id); } @@ -146,6 +160,7 @@ public function update($endpoint = null, $id = null) * @param $id * @return \Illuminate\Http\RedirectResponse|Response */ + // @phpstan-ignore-next-line public function destroy($endpoint = null, $id = null) { if (!is_nullorempty($endpoint) && is_nullorempty($id)) { @@ -159,6 +174,7 @@ public function destroy($endpoint = null, $id = null) } $className = $targetClass->deleteClass; + // @phpstan-ignore-next-line $result = (new $className($this->plugin, $targetClass))->delete($id); return getAjaxResponse([ @@ -175,6 +191,7 @@ public function destroy($endpoint = null, $id = null) * @return \Illuminate\Http\RedirectResponse|Response * @throws SsoLoginErrorException */ + // @phpstan-ignore-next-line public function oauth($endpoint = null) { $targetClass = $this->getClass($endpoint, false, true); @@ -201,6 +218,7 @@ public function oauth($endpoint = null) * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|Response * @throws SsoLoginErrorException */ + // @phpstan-ignore-next-line public function oauthcallback($endpoint = null) { $targetClass = $this->getClass($endpoint, false, true); @@ -234,6 +252,7 @@ public function oauthcallback($endpoint = null) * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|Response * @throws SsoLoginErrorException */ + // @phpstan-ignore-next-line public function oauthlogout($endpoint = null) { $targetClass = $this->getClass($endpoint, false, true); @@ -260,6 +279,7 @@ public function oauthlogout($endpoint = null) * @param $endpoint * @return \Encore\Admin\Layout\Content|false|string */ + // @phpstan-ignore-next-line public function noauth($endpoint = null) { $targetClass = $this->getClass($endpoint, false, true); @@ -314,6 +334,7 @@ protected function getClass(?string $endpoint, bool $isCheckAuthorize = true, bo } $class = new $className($this->plugin); + // @phpstan-ignore-next-line $class->setPluginOptions($this->pluginPage->getPluginOptions()) ->setEndpoint($endpoint); @@ -331,6 +352,7 @@ protected function getClass(?string $endpoint, bool $isCheckAuthorize = true, bo * @param $targetClass * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|true|void */ + // @phpstan-ignore-next-line protected function authorizePlugin(?string $endpoint, $targetClass) { if (!$targetClass->enableAccessCrud()) { diff --git a/src/Services/Plugin/PluginDashboardBase.php b/src/Services/Plugin/PluginDashboardBase.php index 19baa9136..db81feab8 100644 --- a/src/Services/Plugin/PluginDashboardBase.php +++ b/src/Services/Plugin/PluginDashboardBase.php @@ -10,9 +10,12 @@ class PluginDashboardBase extends PluginPublicBase use PluginBase; use PluginPageTrait; + // @phpstan-ignore-next-line protected $dashboard; + // @phpstan-ignore-next-line protected $dashboard_box; + // @phpstan-ignore-next-line public function __construct($plugin, $dashboard_box) { $this->plugin = $plugin; @@ -54,6 +57,7 @@ public function footer() * * @return string */ + // @phpstan-ignore-next-line public function getDashboardUri($endpoint = null) { return url_join( diff --git a/src/Services/Plugin/PluginDocumentBase.php b/src/Services/Plugin/PluginDocumentBase.php index c60372c71..51f8e36ad 100644 --- a/src/Services/Plugin/PluginDocumentBase.php +++ b/src/Services/Plugin/PluginDocumentBase.php @@ -14,10 +14,14 @@ abstract class PluginDocumentBase { use PluginBase; + // @phpstan-ignore-next-line protected $custom_table; + // @phpstan-ignore-next-line protected $custom_value; + // @phpstan-ignore-next-line protected $document_value; + // @phpstan-ignore-next-line public function __construct($plugin, $custom_table, $custom_value_id) { $this->plugin = $plugin; @@ -31,6 +35,7 @@ public function __construct($plugin, $custom_table, $custom_value_id) /** * Create document execution */ + // @phpstan-ignore-next-line public function execute() { $table_name = $this->custom_table->table_name; @@ -75,10 +80,12 @@ public function execute() return $this->getResponseMessage(true); } + // @phpstan-ignore-next-line protected function getDocumentItem() { // get dir base path $reflector = new \ReflectionClass(get_class($this)); + // @phpstan-ignore-next-line $dir_path = dirname($reflector->getFileName()); // read document.json $document_json_path = path_join($dir_path, 'document.json'); @@ -90,6 +97,7 @@ protected function getDocumentItem() /** * get response message */ + // @phpstan-ignore-next-line protected function getResponseMessage($result) { if ($result) { @@ -109,6 +117,7 @@ protected function getResponseMessage($result) * first, template xlsx fullpath. * second, output file name. */ + // @phpstan-ignore-next-line protected function getDocumentInfo() { $default_document_name = "document".\Carbon\Carbon::now()->format('YmdHis'); @@ -119,6 +128,7 @@ protected function getDocumentInfo() $filename = $default_document_name; } else { $json = json_decode_ex(File::get($document_json_path), true); + // @phpstan-ignore-next-line $filename = array_get($json, "filename", $default_document_name); } // return "filename" value @@ -129,6 +139,7 @@ protected function getDocumentInfo() ]; } + // @phpstan-ignore-next-line public function getButtonLabel() { // get label @@ -142,6 +153,7 @@ public function getButtonLabel() /** * execute before creating document */ + // @phpstan-ignore-next-line protected function executing() { } @@ -149,6 +161,7 @@ protected function executing() /** * execute after creating document */ + // @phpstan-ignore-next-line protected function executed() { } @@ -158,6 +171,7 @@ protected function executed() * * @return void */ + // @phpstan-ignore-next-line protected function called($spreadsheet) { } @@ -167,6 +181,7 @@ protected function called($spreadsheet) * * @return void */ + // @phpstan-ignore-next-line protected function saving($spreadsheet) { } diff --git a/src/Services/Plugin/PluginDocumentDefault.php b/src/Services/Plugin/PluginDocumentDefault.php index dc217cb67..688bc95ca 100644 --- a/src/Services/Plugin/PluginDocumentDefault.php +++ b/src/Services/Plugin/PluginDocumentDefault.php @@ -10,6 +10,7 @@ class PluginDocumentDefault extends PluginDocumentBase /** * execute before creating document */ + // @phpstan-ignore-next-line protected function executing() { } @@ -17,6 +18,7 @@ protected function executing() /** * execute after creating document */ + // @phpstan-ignore-next-line protected function executed() { } diff --git a/src/Services/Plugin/PluginEventBase.php b/src/Services/Plugin/PluginEventBase.php index 6315fa540..f889b0b51 100644 --- a/src/Services/Plugin/PluginEventBase.php +++ b/src/Services/Plugin/PluginEventBase.php @@ -10,18 +10,25 @@ class PluginEventBase use PluginBase; use PluginEventTrait; + // @phpstan-ignore-next-line public $custom_table; + // @phpstan-ignore-next-line public $custom_value; + // @phpstan-ignore-next-line public $isCreate; + // @phpstan-ignore-next-line public $isDelete; + // @phpstan-ignore-next-line public $isForceDelete; + // @phpstan-ignore-next-line public function __construct($plugin, $custom_table, $custom_value, $options = []) { $this->_initEvent($plugin, $custom_table, $custom_value, $options); $this->pluginOptions = new PluginOption\PluginOptionEvent($options); } + // @phpstan-ignore-next-line public function execute() { } diff --git a/src/Services/Plugin/PluginEventTrait.php b/src/Services/Plugin/PluginEventTrait.php index 4c569fa99..6848162ec 100644 --- a/src/Services/Plugin/PluginEventTrait.php +++ b/src/Services/Plugin/PluginEventTrait.php @@ -12,9 +12,11 @@ trait PluginEventTrait { // workflow action(if call as workflow) + // @phpstan-ignore-next-line public $workflow_action; // notify(if call as notify) + // @phpstan-ignore-next-line public $notify; /** @@ -26,6 +28,7 @@ trait PluginEventTrait * @param array $options * @return void */ + // @phpstan-ignore-next-line protected function _initEvent($plugin, $custom_table, $custom_value, $options = []) { $this->plugin = $plugin; diff --git a/src/Services/Plugin/PluginExportBase.php b/src/Services/Plugin/PluginExportBase.php index fb53ecbf9..e630665fe 100644 --- a/src/Services/Plugin/PluginExportBase.php +++ b/src/Services/Plugin/PluginExportBase.php @@ -11,6 +11,7 @@ abstract class PluginExportBase { use PluginBase; + // @phpstan-ignore-next-line protected $custom_table; /** @@ -35,6 +36,7 @@ abstract class PluginExportBase protected $tmpFullPath; + // @phpstan-ignore-next-line public function __construct($plugin, $custom_table) { $this->plugin = $plugin; @@ -42,6 +44,7 @@ public function __construct($plugin, $custom_table) } + // @phpstan-ignore-next-line public function defaultProvider($default_provider) { $this->default_provider = $default_provider; @@ -50,6 +53,7 @@ public function defaultProvider($default_provider) } + // @phpstan-ignore-next-line public function viewProvider($view_provider) { $this->view_provider = $view_provider; @@ -61,6 +65,7 @@ public function viewProvider($view_provider) /** * Get grid data. */ + // @phpstan-ignore-next-line protected function getData() { return $this->combineData($this->default_provider->data()); @@ -71,6 +76,7 @@ protected function getData() * * @return array */ + // @phpstan-ignore-next-line protected function getViewData() { return $this->combineData($this->view_provider->data()); @@ -83,6 +89,7 @@ protected function getViewData() * @param array $data * @return array */ + // @phpstan-ignore-next-line protected function combineData($data) { $headers = $data[0]; @@ -98,6 +105,7 @@ protected function combineData($data) /** * Get CustomValue's records. */ + // @phpstan-ignore-next-line protected function getRecords() { return $this->default_provider->getRecords(); diff --git a/src/Services/Plugin/PluginImportBase.php b/src/Services/Plugin/PluginImportBase.php index 900ae4d2f..cd60ac32f 100644 --- a/src/Services/Plugin/PluginImportBase.php +++ b/src/Services/Plugin/PluginImportBase.php @@ -9,10 +9,13 @@ class PluginImportBase { use PluginBase; + // @phpstan-ignore-next-line protected $custom_table; + // @phpstan-ignore-next-line protected $file; + // @phpstan-ignore-next-line public function __construct($plugin, $custom_table, $file) { $this->plugin = $plugin; @@ -20,6 +23,7 @@ public function __construct($plugin, $custom_table, $file) $this->file = $file; } + // @phpstan-ignore-next-line public function execute() { } diff --git a/src/Services/Plugin/PluginInstaller.php b/src/Services/Plugin/PluginInstaller.php index a750c2fda..ca84e87dc 100644 --- a/src/Services/Plugin/PluginInstaller.php +++ b/src/Services/Plugin/PluginInstaller.php @@ -24,6 +24,7 @@ class PluginInstaller /** * Upload plugin (call from display) */ + // @phpstan-ignore-next-line public static function uploadPlugin($uploadFile) { try { @@ -54,6 +55,7 @@ public static function uploadPlugin($uploadFile) for ($i = 0; $i < $zip->numFiles; $i++) { $stat = $zip->statIndex($i); $fileInfo = $zip->getNameIndex($i); + // @phpstan-ignore-next-line if (basename($zip->statIndex($i)['name']) !== 'config.json') { continue; } @@ -61,10 +63,12 @@ public static function uploadPlugin($uploadFile) $zip->extractTo($tmpfolderfullpath); // get confign statname + // @phpstan-ignore-next-line $statname = array_get($stat, 'name'); $config_path = path_join($tmpfolderfullpath, $statname); // get dirname + // @phpstan-ignore-next-line $dirname = pathinfo($statname)['dirname']; // if dirname is '.', $pluginFileBasePath is $tmpfolderpath @@ -104,6 +108,7 @@ public static function uploadPlugin($uploadFile) } } + // @phpstan-ignore-next-line public static function templateInstall($pluginFileBasePath, PluginDiskService $diskService, array $json) { // If temlates not install, return true @@ -141,6 +146,7 @@ public static function templateInstall($pluginFileBasePath, PluginDiskService $d * @param PluginDiskService $diskService * @return array */ + // @phpstan-ignore-next-line protected static function getTemplateDirectories(string $pluginFileBasePath, PluginDiskService $diskService, $tmpDiskItem): array { $result = []; @@ -168,6 +174,7 @@ protected static function getTemplateDirectories(string $pluginFileBasePath, Plu return $result; } + // @phpstan-ignore-next-line public static function copySavePlugin($config_path, $pluginFileBasePath, ?PluginDiskService $diskService = null) { if (!$diskService) { @@ -183,18 +190,23 @@ public static function copySavePlugin($config_path, $pluginFileBasePath, ?Plugin return back()->with('errorMess', exmtrans('common.message.wrongconfig')); } else { //Validate json file with fields require + // @phpstan-ignore-next-line $checkRuleConfig = static::checkRuleConfigFile($json, $tmpDiskItem, $pluginFileBasePath); if ($checkRuleConfig === true) { + // @phpstan-ignore-next-line $templateInstall = static::templateInstall($pluginFileBasePath, $diskService, $json); if ($templateInstall === false) { return back()->with('errorMess', exmtrans('common.message.template_error')); } //Check if the name of the plugin has existed + // @phpstan-ignore-next-line $plugineExistByName = Plugin::getPluginByName(array_get($json, 'plugin_name')); //Check if the uuid of the plugin has existed + // @phpstan-ignore-next-line $plugineExistByUUID = Plugin::getPluginByUUID(array_get($json, 'uuid')); //If json pass validation, prepare data to do continue + // @phpstan-ignore-next-line $plugin = static::prepareData($json); //Make path of folder where contain plugin with name is plugin's name $pluginFolder = $plugin->getPath(); @@ -204,6 +216,7 @@ public static function copySavePlugin($config_path, $pluginFileBasePath, ?Plugin if (!is_null($plugineExistByName) && !is_null($plugineExistByUUID)) { $pluginUpdated = $plugin->saveOrFail(); //Rename folder with plugin name + // @phpstan-ignore-next-line static::copyPluginNameFolder($plugin, $json, $pluginFolder, $pluginFileBasePath, $diskService); admin_toastr(exmtrans('common.message.success_execute')); return back(); @@ -211,6 +224,7 @@ public static function copySavePlugin($config_path, $pluginFileBasePath, ?Plugin //If both name and uuid does not existed, save new record to database, change name folder with plugin name then return success elseif (is_null($plugineExistByName) && is_null($plugineExistByUUID)) { $plugin->save(); + // @phpstan-ignore-next-line static::copyPluginNameFolder($plugin, $json, $pluginFolder, $pluginFileBasePath, $diskService); admin_toastr(exmtrans('common.message.success_execute')); return back(); @@ -241,6 +255,7 @@ public static function copySavePlugin($config_path, $pluginFileBasePath, ?Plugin * @param DiskServiceItem $tmpDiskItem * @return bool|string */ + // @phpstan-ignore-next-line protected static function checkRuleConfigFile($json, DiskServiceItem $tmpDiskItem, string $pluginFileBasePath) { $rules = [ @@ -270,6 +285,7 @@ protected static function checkRuleConfigFile($json, DiskServiceItem $tmpDiskIte * @param array $json * @return Plugin plugin object */ + // @phpstan-ignore-next-line protected static function prepareData($json) { // find or new $plugin @@ -318,6 +334,7 @@ protected static function prepareData($json) * @param string $pluginFileBasepath * @return void */ + // @phpstan-ignore-next-line protected static function copyPluginNameFolder($plugin, $json, $pluginFolderPath, $pluginFileBasepath, $diskService) { // get all files @@ -327,6 +344,7 @@ protected static function copyPluginNameFolder($plugin, $json, $pluginFolderPath // get moved file name $movedFileName = str_replace($pluginFileBasepath, '', $file); $movedFileName = str_replace(\Exment::replaceBackToSlash($pluginFileBasepath), '', $movedFileName); + // @phpstan-ignore-next-line $movedFileName = trim($movedFileName, '/'); $movedFileName = trim($movedFileName, '\\'); diff --git a/src/Services/Plugin/PluginOption/PluginOptionBatch.php b/src/Services/Plugin/PluginOption/PluginOptionBatch.php index 7bd4a9554..3f6ee5eb1 100644 --- a/src/Services/Plugin/PluginOption/PluginOptionBatch.php +++ b/src/Services/Plugin/PluginOption/PluginOptionBatch.php @@ -4,8 +4,10 @@ class PluginOptionBatch extends PluginOptionBase { + // @phpstan-ignore-next-line public $command_options = []; + // @phpstan-ignore-next-line public function __construct($options = []) { if (isset($options['command_options'])) { diff --git a/src/Services/Plugin/PluginOption/PluginOptionCrud.php b/src/Services/Plugin/PluginOption/PluginOptionCrud.php index 1a391a0c4..5506bc0d5 100644 --- a/src/Services/Plugin/PluginOption/PluginOptionCrud.php +++ b/src/Services/Plugin/PluginOption/PluginOptionCrud.php @@ -11,16 +11,18 @@ class PluginOptionCrud extends PluginOptionBase * @param $plugin * @param $pluginClass * @param $options - * @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line public function __construct($plugin, $pluginClass, $options = []) { $this->plugin = $plugin; $this->pluginClass = $pluginClass; } + // @phpstan-ignore-next-line protected $plugin; + // @phpstan-ignore-next-line protected $pluginClass; /** @@ -49,6 +51,7 @@ public function getOauthSetting(): ?Model\LoginSetting /** * Login OAuth. */ + // @phpstan-ignore-next-line public function loginOAuth() { $login_setting = $this->getOauthSetting(); diff --git a/src/Services/Plugin/PluginOption/PluginOptionEvent.php b/src/Services/Plugin/PluginOption/PluginOptionEvent.php index 376f9ab98..d7d0ba1ce 100644 --- a/src/Services/Plugin/PluginOption/PluginOptionEvent.php +++ b/src/Services/Plugin/PluginOption/PluginOptionEvent.php @@ -4,10 +4,14 @@ class PluginOptionEvent extends PluginOptionBase { + // @phpstan-ignore-next-line public $is_modal = false; + // @phpstan-ignore-next-line public $event_type; + // @phpstan-ignore-next-line public $page_type; + // @phpstan-ignore-next-line public function __construct($options = []) { if (isset($options['is_modal'])) { diff --git a/src/Services/Plugin/PluginPageBase.php b/src/Services/Plugin/PluginPageBase.php index 66609d76e..3117df9d8 100644 --- a/src/Services/Plugin/PluginPageBase.php +++ b/src/Services/Plugin/PluginPageBase.php @@ -14,8 +14,10 @@ class PluginPageBase extends PluginPublicBase use PluginBase; use PluginPageTrait; + // @phpstan-ignore-next-line protected $showHeader = true; + // @phpstan-ignore-next-line public function __construct($plugin) { $this->plugin = $plugin; @@ -36,6 +38,7 @@ public function _showHeader() * * @return string|null */ + // @phpstan-ignore-next-line public function getRouteUri($endpoint = null) { if (!isset($this->plugin)) { diff --git a/src/Services/Plugin/PluginPageController.php b/src/Services/Plugin/PluginPageController.php index cd0ce8719..99bc33d8f 100644 --- a/src/Services/Plugin/PluginPageController.php +++ b/src/Services/Plugin/PluginPageController.php @@ -10,7 +10,9 @@ class PluginPageController extends Controller { + // @phpstan-ignore-next-line protected $pluginPage; + // @phpstan-ignore-next-line protected $plugin; public function __construct(?PluginPublicBase $pluginPage) @@ -25,6 +27,7 @@ public function __construct(?PluginPublicBase $pluginPage) * @return mixed * */ + // @phpstan-ignore-next-line public function __call($method, $parameters) { if (!$this->pluginPage) { @@ -40,6 +43,7 @@ public function __call($method, $parameters) } // create html + // @phpstan-ignore-next-line $result = call_user_func_array([$this->pluginPage, $method], array_values($parameters)); if ($result instanceof \Symfony\Component\HttpFoundation\Response) { @@ -48,6 +52,7 @@ public function __call($method, $parameters) $content = new Content(); $content->row($result); + // @phpstan-ignore-next-line if (method_exists($this->pluginPage, '_showHeader') && $this->pluginPage->_showHeader()) { $content->header($this->plugin->plugin_view_name) ->headericon($this->plugin->getOption('icon')?? 'fa-pencil'); @@ -56,6 +61,7 @@ public function __call($method, $parameters) return $content; } + // @phpstan-ignore-next-line public function _readPublicFile(Request $request, ...$args) { // get file path @@ -71,6 +77,7 @@ public function _readPublicFile(Request $request, ...$args) } $file = \File::get($filePath); + // @phpstan-ignore-next-line $extension = pathinfo($filePath)['extension']; switch ($extension) { @@ -87,6 +94,7 @@ public function _readPublicFile(Request $request, ...$args) // create response $response = Response::make($file, 200); + // @phpstan-ignore-next-line $response->header("Content-Type", $mimeType); return $response; diff --git a/src/Services/Plugin/PluginPageTrait.php b/src/Services/Plugin/PluginPageTrait.php index 37e6f3264..4aab8ec59 100644 --- a/src/Services/Plugin/PluginPageTrait.php +++ b/src/Services/Plugin/PluginPageTrait.php @@ -13,6 +13,7 @@ trait PluginPageTrait * * @return array|null|void */ + // @phpstan-ignore-next-line public function _getLoadView() { $base_path = $this->plugin->getFullPath(path_join('resources', 'views')); @@ -30,6 +31,7 @@ public function _getLoadView() * @param array $data * @return mixed */ + // @phpstan-ignore-next-line protected function pluginView($bladeName, $data = []) { $blade = 'exment_' . snake_case($this->plugin->plugin_name) . '::' . $bladeName; diff --git a/src/Services/Plugin/PluginPublicBase.php b/src/Services/Plugin/PluginPublicBase.php index d532fdba9..6e11d2fe8 100644 --- a/src/Services/Plugin/PluginPublicBase.php +++ b/src/Services/Plugin/PluginPublicBase.php @@ -9,8 +9,10 @@ */ class PluginPublicBase { + // @phpstan-ignore-next-line protected $plugin; + // @phpstan-ignore-next-line public function _plugin() { return $this->plugin; @@ -21,6 +23,7 @@ public function _plugin() * * @return array */ + // @phpstan-ignore-next-line public function css($skipPath = false) { return $this->getCssJsFiles($skipPath ? null : 'css', 'css'); @@ -32,6 +35,7 @@ public function css($skipPath = false) * @param $skipPath * @return array */ + // @phpstan-ignore-next-line public function js($skipPath = false) { return $this->getCssJsFiles($skipPath ? null : 'js', 'js'); @@ -44,6 +48,7 @@ public function js($skipPath = false) * @param $type * @return array|mixed[] */ + // @phpstan-ignore-next-line protected function getCssJsFiles($path, $type) { $base_path = $this->plugin->getFullPath('public'); @@ -56,6 +61,7 @@ protected function getCssJsFiles($path, $type) $files = \File::allFiles($type_path); return collect($files)->filter(function ($file) use ($type) { + // @phpstan-ignore-next-line return pathinfo($file)['extension'] == $type; })->map(function ($file) use ($base_path) { $path = trim(str_replace($base_path, '', $file->getPathName()), '/'); @@ -70,6 +76,7 @@ protected function getCssJsFiles($path, $type) * @param bool $asPublicForm * @return mixed|string|null */ + // @phpstan-ignore-next-line public function getCssJsUrl($fileName, bool $asPublicForm = false) { if ($asPublicForm) { diff --git a/src/Services/Plugin/PluginPublicDefault.php b/src/Services/Plugin/PluginPublicDefault.php index fdd1ccac7..bbe9186c4 100644 --- a/src/Services/Plugin/PluginPublicDefault.php +++ b/src/Services/Plugin/PluginPublicDefault.php @@ -12,6 +12,7 @@ class PluginPublicDefault extends PluginPublicBase { use PluginBase; + // @phpstan-ignore-next-line public function __construct($plugin) { $this->plugin = $plugin; diff --git a/src/Services/Plugin/PluginSettingBase.php b/src/Services/Plugin/PluginSettingBase.php index badabd939..fe5342eaf 100644 --- a/src/Services/Plugin/PluginSettingBase.php +++ b/src/Services/Plugin/PluginSettingBase.php @@ -10,6 +10,7 @@ abstract class PluginSettingBase { use PluginBase; + // @phpstan-ignore-next-line public function __construct($plugin) { $this->plugin = $plugin; diff --git a/src/Services/Plugin/PluginTriggerBase.php b/src/Services/Plugin/PluginTriggerBase.php index 2794f97a2..165736fb1 100644 --- a/src/Services/Plugin/PluginTriggerBase.php +++ b/src/Services/Plugin/PluginTriggerBase.php @@ -11,16 +11,25 @@ class PluginTriggerBase use PluginEventTrait; use PluginButtonTrait; + // @phpstan-ignore-next-line public $custom_table; + // @phpstan-ignore-next-line public $custom_value; + // @phpstan-ignore-next-line public $isCreate; + // @phpstan-ignore-next-line + public $isDelete; + // @phpstan-ignore-next-line + public $isForceDelete; + // @phpstan-ignore-next-line public function __construct($plugin, $custom_table, $custom_value, $options = []) { $this->_initButton($plugin, $custom_table, $custom_value, $options); $this->_initEvent($plugin, $custom_table, $custom_value, $options); } + // @phpstan-ignore-next-line public function execute() { } diff --git a/src/Services/Plugin/PluginValidatorBase.php b/src/Services/Plugin/PluginValidatorBase.php index 50eec1e70..a778b0235 100644 --- a/src/Services/Plugin/PluginValidatorBase.php +++ b/src/Services/Plugin/PluginValidatorBase.php @@ -32,6 +32,7 @@ class PluginValidatorBase * * @var array */ + // @phpstan-ignore-next-line public $input_value; /** @@ -46,6 +47,7 @@ class PluginValidatorBase * * @var array */ + // @phpstan-ignore-next-line protected $messages = []; /** @@ -57,6 +59,7 @@ class PluginValidatorBase * @param array $options * 'called_type' => Whether this validation is called. */ + // @phpstan-ignore-next-line public function __construct(PluginModel $plugin, ?CustomTable $custom_table, $original_value, array $options = []) { $this->plugin = $plugin; @@ -71,10 +74,12 @@ public function __construct(PluginModel $plugin, ?CustomTable $custom_table, $or } } + // @phpstan-ignore-next-line public function validate() { } + // @phpstan-ignore-next-line public function messages() { $messages = []; @@ -92,6 +97,7 @@ public function messages() return $messages; } + // @phpstan-ignore-next-line public function validateDestroy($model) { } diff --git a/src/Services/Plugin/PluginViewBase.php b/src/Services/Plugin/PluginViewBase.php index 7181e94ff..3c109a12f 100644 --- a/src/Services/Plugin/PluginViewBase.php +++ b/src/Services/Plugin/PluginViewBase.php @@ -37,6 +37,7 @@ abstract class PluginViewBase extends PluginPublicBase * * @var array|null */ + // @phpstan-ignore-next-line protected $useBoxButtons = [ 'newButton', 'menuButton', @@ -67,6 +68,7 @@ public function useBox(): bool * * @return array */ + // @phpstan-ignore-next-line public function useBoxButtons(): array { return $this->useBoxButtons ?? []; @@ -124,5 +126,6 @@ public function setSortFields(Form &$form) PluginGrid::setSortFields($form, $this->custom_table); } + // @phpstan-ignore-next-line abstract public function grid(); } diff --git a/src/Services/QueryLogger.php b/src/Services/QueryLogger.php index cbec98bc5..87556624a 100644 --- a/src/Services/QueryLogger.php +++ b/src/Services/QueryLogger.php @@ -4,19 +4,30 @@ class QueryLogger { + /** @var array */ protected static $queries = []; + /** + * @param string $query + * @return void + */ public static function add($query) { $index = count(self::$queries) + 1; self::$queries[] = "{$index}. {$query}"; } + /** + * @return array + */ public static function all() { return static::$queries; } + /** + * @return void + */ public static function clear() { static::$queries = []; diff --git a/src/Services/RefreshDataService.php b/src/Services/RefreshDataService.php index 37f365bcc..59f6db518 100644 --- a/src/Services/RefreshDataService.php +++ b/src/Services/RefreshDataService.php @@ -18,6 +18,7 @@ class RefreshDataService * Refresh transaction data * * @return void + * @throws \Throwable */ public static function refresh() { @@ -81,8 +82,9 @@ public static function refresh() /** * Refresh transaction data selecting table * - * @param array $tables + * @param array $tables * @return void + * @throws \Throwable */ public static function refreshTable(array $tables) { @@ -173,6 +175,7 @@ public static function refreshTable(array $tables) * @param array|\Illuminate\Support\Collection $custom_tables * @return void */ + // @phpstan-ignore-next-line public static function removeAttachmentFiles($custom_tables) { $disk = \Storage::disk(Define::DISKNAME_ADMIN); @@ -200,6 +203,7 @@ public static function removeAttachmentFiles($custom_tables) * @param array|\Illuminate\Support\Collection $custom_tables * @return void */ + // @phpstan-ignore-next-line public static function removeDocumentComments($custom_tables) { // delete tables diff --git a/src/Services/ReplaceFormat/Items/Child.php b/src/Services/ReplaceFormat/Items/Child.php index 3449dcbc8..635d1b1e2 100644 --- a/src/Services/ReplaceFormat/Items/Child.php +++ b/src/Services/ReplaceFormat/Items/Child.php @@ -10,6 +10,7 @@ class Child extends ItemBase /** * Replace value from format. ex. ${value:user_name} to user_name's value */ + // @phpstan-ignore-next-line public function replace($format, $options = []) { if (!isset($this->custom_value)) { diff --git a/src/Services/ReplaceFormat/Items/CustomTable.php b/src/Services/ReplaceFormat/Items/CustomTable.php index 6d613e90c..79109b8b4 100644 --- a/src/Services/ReplaceFormat/Items/CustomTable.php +++ b/src/Services/ReplaceFormat/Items/CustomTable.php @@ -10,6 +10,7 @@ class CustomTable extends ItemBase /** * Replace value from format. ex. ${value:user_name} to user_name's value */ + // @phpstan-ignore-next-line public function replace($format, $options = []) { if (is_nullorempty($this->custom_value)) { diff --git a/src/Services/ReplaceFormat/Items/DateString.php b/src/Services/ReplaceFormat/Items/DateString.php index 7b4e930b7..58f9d08ee 100644 --- a/src/Services/ReplaceFormat/Items/DateString.php +++ b/src/Services/ReplaceFormat/Items/DateString.php @@ -27,6 +27,7 @@ class DateString extends ItemBase /** * Replace date */ + // @phpstan-ignore-next-line public function replace($format, $options = []) { return Carbon::now()->format(static::dateStrings[strtolower($this->key)]); diff --git a/src/Services/ReplaceFormat/Items/DateValue.php b/src/Services/ReplaceFormat/Items/DateValue.php index 3a65accad..029f2d5cc 100644 --- a/src/Services/ReplaceFormat/Items/DateValue.php +++ b/src/Services/ReplaceFormat/Items/DateValue.php @@ -27,6 +27,7 @@ class DateValue extends ItemBase /** * Replace date */ + // @phpstan-ignore-next-line public function replace($format, $options = []) { $str = Carbon::now()->{static::dateValues[$this->key]}; diff --git a/src/Services/ReplaceFormat/Items/File.php b/src/Services/ReplaceFormat/Items/File.php index 49699f148..90c64ac84 100644 --- a/src/Services/ReplaceFormat/Items/File.php +++ b/src/Services/ReplaceFormat/Items/File.php @@ -10,6 +10,7 @@ class File extends ItemBase /** * Replace value from format. ex. ${value:user_name} to user_name's value */ + // @phpstan-ignore-next-line public function replace($format, $options = []) { $target_value = $this->custom_value; diff --git a/src/Services/ReplaceFormat/Items/ItemBase.php b/src/Services/ReplaceFormat/Items/ItemBase.php index 415db2a53..8c62fd1c0 100644 --- a/src/Services/ReplaceFormat/Items/ItemBase.php +++ b/src/Services/ReplaceFormat/Items/ItemBase.php @@ -10,11 +10,16 @@ */ abstract class ItemBase { + // @phpstan-ignore-next-line protected $custom_value; + // @phpstan-ignore-next-line protected $length_array; + // @phpstan-ignore-next-line protected $matchOptions; + // @phpstan-ignore-next-line protected $key; + // @phpstan-ignore-next-line public function __construct($custom_value, $length_array, $matchOptions) { $this->custom_value = $custom_value; @@ -23,6 +28,7 @@ public function __construct($custom_value, $length_array, $matchOptions) $this->key = $length_array[0]; } + // @phpstan-ignore-next-line public static function getItem($custom_value, $length_array, $matchOptions) { $key = $length_array[0]; @@ -74,6 +80,7 @@ public static function getItem($custom_value, $length_array, $matchOptions) } } + // @phpstan-ignore-next-line public function getLink($str) { return "$str"; diff --git a/src/Services/ReplaceFormat/Items/LoginUser.php b/src/Services/ReplaceFormat/Items/LoginUser.php index 0da17f81a..b97c8c3d2 100644 --- a/src/Services/ReplaceFormat/Items/LoginUser.php +++ b/src/Services/ReplaceFormat/Items/LoginUser.php @@ -10,6 +10,7 @@ class LoginUser extends ItemBase /** * Replace login user infomation */ + // @phpstan-ignore-next-line public function replace($format, $options = []) { if (count($this->length_array) < 2) { diff --git a/src/Services/ReplaceFormat/Items/Now.php b/src/Services/ReplaceFormat/Items/Now.php index 6d333eb3d..16c8724b4 100644 --- a/src/Services/ReplaceFormat/Items/Now.php +++ b/src/Services/ReplaceFormat/Items/Now.php @@ -10,6 +10,7 @@ class Now extends ItemBase /** * Replace date */ + // @phpstan-ignore-next-line public function replace($format, $options = []) { $format = null; diff --git a/src/Services/ReplaceFormat/Items/ParentValue.php b/src/Services/ReplaceFormat/Items/ParentValue.php index f36f5461d..902ce4b4c 100644 --- a/src/Services/ReplaceFormat/Items/ParentValue.php +++ b/src/Services/ReplaceFormat/Items/ParentValue.php @@ -12,6 +12,7 @@ class ParentValue extends ItemBase /** * Replace value from format. ex. ${value:user_name} to user_name's value */ + // @phpstan-ignore-next-line public function replace($format, $options = []) { if (!isset($this->custom_value)) { diff --git a/src/Services/ReplaceFormat/Items/SelectTableValue.php b/src/Services/ReplaceFormat/Items/SelectTableValue.php index 8a8d75cce..9951b5c33 100644 --- a/src/Services/ReplaceFormat/Items/SelectTableValue.php +++ b/src/Services/ReplaceFormat/Items/SelectTableValue.php @@ -10,6 +10,7 @@ class SelectTableValue extends ItemBase /** * Replace value from format. ex. ${select_table.customer.customer_name} to user_name's value */ + // @phpstan-ignore-next-line public function replace($format, $options = []) { $target_value = $this->custom_value; diff --git a/src/Services/ReplaceFormat/Items/System.php b/src/Services/ReplaceFormat/Items/System.php index 35abdee30..79009035c 100644 --- a/src/Services/ReplaceFormat/Items/System.php +++ b/src/Services/ReplaceFormat/Items/System.php @@ -12,6 +12,7 @@ class System extends ItemBase /** * Replace value from format. ex. ${value:user_name} to user_name's value */ + // @phpstan-ignore-next-line public function replace($format, $options = []) { if (count($this->length_array) < 2) { diff --git a/src/Services/ReplaceFormat/Items/SystemValue.php b/src/Services/ReplaceFormat/Items/SystemValue.php index 65b3dddc7..0a9b3d38b 100644 --- a/src/Services/ReplaceFormat/Items/SystemValue.php +++ b/src/Services/ReplaceFormat/Items/SystemValue.php @@ -12,6 +12,7 @@ class SystemValue extends ItemBase /** * Replace value from format. ex. ${value:user_name} to user_name's value */ + // @phpstan-ignore-next-line public function replace($format, $options = []) { if (!isset($this->custom_value)) { diff --git a/src/Services/ReplaceFormat/Items/UuidValue.php b/src/Services/ReplaceFormat/Items/UuidValue.php index 8196fb28e..a04ed0339 100644 --- a/src/Services/ReplaceFormat/Items/UuidValue.php +++ b/src/Services/ReplaceFormat/Items/UuidValue.php @@ -10,6 +10,7 @@ class UuidValue extends ItemBase /** * Replace value from format. ex. ${value:user_name} to user_name's value */ + // @phpstan-ignore-next-line public function replace($format, $options = []) { return make_uuid(); diff --git a/src/Services/ReplaceFormat/Items/Value.php b/src/Services/ReplaceFormat/Items/Value.php index 377422756..2ac0accb5 100644 --- a/src/Services/ReplaceFormat/Items/Value.php +++ b/src/Services/ReplaceFormat/Items/Value.php @@ -12,6 +12,7 @@ class Value extends ItemBase /** * Replace value from format. ex. ${value:user_name} to user_name's value */ + // @phpstan-ignore-next-line public function replace($format, $options = []) { if ($this->key == "value") { diff --git a/src/Services/ReplaceFormat/Items/ValueUrl.php b/src/Services/ReplaceFormat/Items/ValueUrl.php index 4ba325508..135473292 100644 --- a/src/Services/ReplaceFormat/Items/ValueUrl.php +++ b/src/Services/ReplaceFormat/Items/ValueUrl.php @@ -10,6 +10,7 @@ class ValueUrl extends ItemBase /** * Replace value from format. ex. ${value:user_name} to user_name's value */ + // @phpstan-ignore-next-line public function replace($format, $options = []) { if (!isset($this->custom_value)) { @@ -24,6 +25,7 @@ public function replace($format, $options = []) return $str; } + // @phpstan-ignore-next-line public function getLink($str) { return $str; diff --git a/src/Services/ReplaceFormat/Items/Workflow.php b/src/Services/ReplaceFormat/Items/Workflow.php index d741811ef..5796c0328 100644 --- a/src/Services/ReplaceFormat/Items/Workflow.php +++ b/src/Services/ReplaceFormat/Items/Workflow.php @@ -13,6 +13,7 @@ class Workflow extends ItemBase /** * Replace value from format. ex. ${value:user_name} to user_name's value */ + // @phpstan-ignore-next-line public function replace($format, $options = []) { // get workflow action and value diff --git a/src/Services/ReplaceFormat/ReplaceFormatService.php b/src/Services/ReplaceFormat/ReplaceFormatService.php index 83a225ccf..fabdade5b 100644 --- a/src/Services/ReplaceFormat/ReplaceFormatService.php +++ b/src/Services/ReplaceFormat/ReplaceFormatService.php @@ -12,6 +12,7 @@ class ReplaceFormatService /** * Replace value from format. ex. ${value:user_name} to user_name's value */ + // @phpstan-ignore-next-line public static function replaceTextFromFormat($format, $custom_value = null, $options = []) { if (is_null($format)) { diff --git a/src/Services/Search/SearchService.php b/src/Services/Search/SearchService.php index ac9bfc676..be81c9e45 100644 --- a/src/Services/Search/SearchService.php +++ b/src/Services/Search/SearchService.php @@ -39,6 +39,7 @@ class SearchService * * @var \Illuminate\Database\Eloquent\Builder */ + // @phpstan-ignore-next-line protected $query; /** @@ -60,6 +61,7 @@ class SearchService * * @var array */ + // @phpstan-ignore-next-line protected $joinedTables = []; /** @@ -67,12 +69,14 @@ class SearchService * * @var array */ + // @phpstan-ignore-next-line protected $joinedWorkflows = []; /** * Summary orders * @var array */ + // @phpstan-ignore-next-line protected $summaryOrders = []; /** @@ -80,6 +84,7 @@ class SearchService * "joinSub" query only calls once, so First set select and group by, and after these, join sub query. * @var array */ + // @phpstan-ignore-next-line protected $summaryJoins = []; @@ -94,6 +99,7 @@ public function __construct(CustomTable $custom_table) * * @return \Illuminate\Database\Eloquent\Builder */ + // @phpstan-ignore-next-line public function query() { if ($this->isAppendSelect) { @@ -124,6 +130,7 @@ public function addSelect() * * @return $this */ + // @phpstan-ignore-next-line public function setQuery($query) { $this->query = $query; @@ -148,6 +155,7 @@ public function setIsAppendSelect(bool $isAppendSelect) * @param array|string $columns * @return \Illuminate\Database\Eloquent\Collection */ + // @phpstan-ignore-next-line public function get($columns = ['*']) { return $this->query()->get($columns); @@ -164,6 +172,7 @@ public function get($columns = ['*']) * @param string $boolean * @return $this */ + // @phpstan-ignore-next-line public function where($column, $operator = null, $value = null, $boolean = 'and') { // Here we will make some assumptions about the operator. If only 2 values are @@ -177,9 +186,11 @@ public function where($column, $operator = null, $value = null, $boolean = 'and' // If custom column, execute where custom column's exists query. if ($column instanceof CustomColumn) { + // @phpstan-ignore-next-line return $this->whereCustomColumn($column, $operator, $value, $boolean); } if (is_string($column)) { + // @phpstan-ignore-next-line return $this->whereCustomColumn(CustomColumn::getEloquent($column, $this->custom_table), $operator, $value, $boolean); } @@ -224,6 +235,7 @@ public function orderBy($column, $direction = 'asc') * @param string $boolean * @return $this|Builder */ + // @phpstan-ignore-next-line protected function whereCustomColumn(CustomColumn $column, $operator = null, $value = null, $boolean = 'and') { $whereCustomTable = $column->custom_table_cache; @@ -462,6 +474,7 @@ public function selectSummaryCustomViewSummary(CustomViewSummary $column) * * @return $this */ + // @phpstan-ignore-next-line protected function setSummaryOrderBy($column, $wrap_column) { $sort_order = array_get($column->options, 'sort_order'); @@ -485,6 +498,7 @@ protected function setSummaryOrderBy($column, $wrap_column) /** * Execute order by if for summary */ + // @phpstan-ignore-next-line public function executeSummaryOrderBy() { foreach (collect($this->summaryOrders)->sortBy('sort_order') as $summaryOrder) { @@ -496,6 +510,7 @@ public function executeSummaryOrderBy() /** * Execute summary join. */ + // @phpstan-ignore-next-line public function executeSummaryJoin() { foreach ($this->summaryJoins as $summaryJoin) { @@ -510,6 +525,7 @@ public function executeSummaryJoin() * @param CustomViewFilter $column * @return $this */ + // @phpstan-ignore-next-line public function whereCustomViewFilter(CustomViewFilter $column, $filter_is_or, $query = null) { // if $query is null, set $query as base $this->query. @@ -535,6 +551,7 @@ public function whereCustomViewFilter(CustomViewFilter $column, $filter_is_or, $ * @param Notify $notify notify target * @return $this */ + // @phpstan-ignore-next-line public function whereNotifySchedule(Notify $notify, $operator = null, $value = null, $boolean = 'and', array $options = []) { // if $query is null, set $query as base $this->query. @@ -568,6 +585,7 @@ public function whereNotifySchedule(Notify $notify, $operator = null, $value = n * @return RelationTable|null * @throws \Exception */ + // @phpstan-ignore-next-line public function setRelationJoin($column, array $options = []): ?RelationTable { $options = array_merge([ @@ -601,7 +619,7 @@ public function setRelationJoin($column, array $options = []): ?RelationTable $column_item = $this->getColumnItem($column); if (!isset($column_item)) { $this->query->whereNotMatch(); - // @phpstan-ignore-next-line Maybe function type hinting miss + // @phpstan-ignore-next-line return $this; } $column_item->setUniqueTableName($relationTable->tableUniqueName); @@ -626,6 +644,7 @@ public function setRelationJoin($column, array $options = []): ?RelationTable * * @param string $key */ + // @phpstan-ignore-next-line public function setRelationJoinWorkflow(string $key, array $options = []) { // set relation workflow status @@ -645,6 +664,7 @@ public function setRelationJoinWorkflow(string $key, array $options = []) * @param CustomTable $whereCustomTable * @return RelationTable|null relation table info */ + // @phpstan-ignore-next-line protected function getRelationTable($whereCustomTable, bool $asSummary = false, $filterObj = null) { // get RelationTable info. @@ -672,6 +692,7 @@ protected function getRelationTable($whereCustomTable, bool $asSummary = false, * @param CustomViewColumn|CustomViewSort|CustomViewFilter|CustomViewSummary|CustomViewGridFilter $filterObj * @return RelationTable|null filtered Relation Table */ + // @phpstan-ignore-next-line protected function filterRelationTable($relationTables, $filterObj): ?RelationTable { // if only 1, return first. @@ -779,6 +800,7 @@ protected function isJoinedTable($relationTable) * * @return boolean is join workflow status */ + // @phpstan-ignore-next-line protected function isJoinWorkflowStatus($custom_view_filter): bool { return $this->isJoinWorkflow($custom_view_filter, SystemColumn::WORKFLOW_STATUS); @@ -789,6 +811,7 @@ protected function isJoinWorkflowStatus($custom_view_filter): bool * * @return boolean is join workflow status */ + // @phpstan-ignore-next-line protected function isJoinWorkflowWorkUsers($custom_view_filter): bool { return $this->isJoinWorkflow($custom_view_filter, SystemColumn::WORKFLOW_WORK_USERS); @@ -799,6 +822,7 @@ protected function isJoinWorkflowWorkUsers($custom_view_filter): bool * * @return boolean is join workflow status */ + // @phpstan-ignore-next-line protected function isJoinWorkflow($custom_view_filter, $key): bool { // Whether custom_view_filter is boolelan. if true, always call. @@ -836,6 +860,7 @@ protected function isJoinWorkflow($custom_view_filter, $key): bool * offset2 : this table's id * offset2 : this column's id */ + // @phpstan-ignore-next-line protected function getConditionParams($column): array { if ($column instanceof CustomViewColumn || $column instanceof CustomViewFilter || $column instanceof CustomViewSort || $column instanceof CustomViewSummary || $column instanceof CustomViewGridFilter) { diff --git a/src/Services/SystemRequire/BackupRestore.php b/src/Services/SystemRequire/BackupRestore.php index 05f0f4b4d..10e377b51 100644 --- a/src/Services/SystemRequire/BackupRestore.php +++ b/src/Services/SystemRequire/BackupRestore.php @@ -9,6 +9,7 @@ class BackupRestore extends SystemRequireBase { + // @phpstan-ignore-next-line protected $exceptionMessage; public function __construct() diff --git a/src/Services/SystemRequire/Composer.php b/src/Services/SystemRequire/Composer.php index d0aaa9ba0..99ea68191 100644 --- a/src/Services/SystemRequire/Composer.php +++ b/src/Services/SystemRequire/Composer.php @@ -7,7 +7,9 @@ class Composer extends SystemRequireBase { + // @phpstan-ignore-next-line protected $composer_version; + // @phpstan-ignore-next-line protected $command_path; /** @@ -105,6 +107,7 @@ protected function getComposerVersion() * * @return string */ + // @phpstan-ignore-next-line protected function checkComposerVersion($composer_version) { if ($composer_version === false) { diff --git a/src/Services/SystemRequire/FilePermission.php b/src/Services/SystemRequire/FilePermission.php index fa4981a1f..6297a0003 100644 --- a/src/Services/SystemRequire/FilePermission.php +++ b/src/Services/SystemRequire/FilePermission.php @@ -6,6 +6,7 @@ class FilePermission extends SystemRequireBase { + // @phpstan-ignore-next-line protected $checkPaths = [ 'storage', 'bootstrap/cache', diff --git a/src/Services/SystemRequire/FilePermissionInstaller.php b/src/Services/SystemRequire/FilePermissionInstaller.php index 6bee73f27..c6f271757 100644 --- a/src/Services/SystemRequire/FilePermissionInstaller.php +++ b/src/Services/SystemRequire/FilePermissionInstaller.php @@ -4,6 +4,7 @@ class FilePermissionInstaller extends FilePermission { + // @phpstan-ignore-next-line protected $checkPaths = [ '.env', 'app', diff --git a/src/Services/SystemRequire/SystemRequireBase.php b/src/Services/SystemRequire/SystemRequireBase.php index f6ad456d5..c6b5fc37c 100644 --- a/src/Services/SystemRequire/SystemRequireBase.php +++ b/src/Services/SystemRequire/SystemRequireBase.php @@ -24,6 +24,7 @@ abstract class SystemRequireBase protected $systemRequireCalledType; + // @phpstan-ignore-next-line public function systemRequireCalledType(string $systemRequireCalledType) { $this->systemRequireCalledType = $systemRequireCalledType; @@ -31,6 +32,7 @@ public function systemRequireCalledType(string $systemRequireCalledType) } + // @phpstan-ignore-next-line public function getResult() { return $this->result; @@ -57,6 +59,7 @@ public function getMessage(): ?string return null; } + // @phpstan-ignore-next-line public function getResultClassSet(): ?array { switch ($this->checkResult()) { diff --git a/src/Services/SystemRequire/SystemRequireList.php b/src/Services/SystemRequire/SystemRequireList.php index 825ddb17b..6691fe5d8 100644 --- a/src/Services/SystemRequire/SystemRequireList.php +++ b/src/Services/SystemRequire/SystemRequireList.php @@ -11,8 +11,10 @@ */ class SystemRequireList { + // @phpstan-ignore-next-line protected $items = []; + // @phpstan-ignore-next-line protected static $requireClassesCommand = [ MemorySize::class, MaxInputVars::class, @@ -23,6 +25,7 @@ class SystemRequireList BackupRestore::class, ]; + // @phpstan-ignore-next-line protected static $requireClassesWeb = [ MemorySize::class, MaxInputVars::class, @@ -33,6 +36,7 @@ class SystemRequireList BackupRestore::class, ]; + // @phpstan-ignore-next-line protected static $requireClassesInstallWeb = [ MemorySize::class, MaxInputVars::class, @@ -44,6 +48,7 @@ class SystemRequireList ]; + // @phpstan-ignore-next-line protected static function getRequireClasses(string $systemRequireCalledType) { switch ($systemRequireCalledType) { @@ -59,6 +64,7 @@ protected static function getRequireClasses(string $systemRequireCalledType) } + // @phpstan-ignore-next-line public function setItem($item) { $this->items[] = $item; @@ -66,6 +72,7 @@ public function setItem($item) } + // @phpstan-ignore-next-line public function getItems() { return $this->items; @@ -98,6 +105,7 @@ public static function make(string $systemRequireCalledType): SystemRequireList $classes = static::getRequireClasses($systemRequireCalledType); foreach ($classes as $className) { $obj = new $className(); + // @phpstan-ignore-next-line $obj->systemRequireCalledType($systemRequireCalledType); $result->setItem($obj); diff --git a/src/Services/TableService.php b/src/Services/TableService.php index f12d63db4..154222440 100644 --- a/src/Services/TableService.php +++ b/src/Services/TableService.php @@ -8,6 +8,11 @@ class TableService { + /** + * @param mixed $tools + * @param \Exceedone\Exment\Model\CustomTable $custom_table + * @return void + */ public static function appendActivateSwalButtonQRCode($tools, $custom_table) { if (!$custom_table->getOption('jan_use')) { @@ -37,6 +42,11 @@ public static function appendActivateSwalButtonQRCode($tools, $custom_table) } } + /** + * @param mixed $tools + * @param \Exceedone\Exment\Model\CustomTable $custom_table + * @return void + */ public static function appendActivateSwalButtonJanCode($tools, $custom_table) { if (!$custom_table->getOption('qr_use')) { @@ -71,6 +81,11 @@ public static function appendActivateSwalButtonJanCode($tools, $custom_table) } } + /** + * @param mixed $tools + * @param \Exceedone\Exment\Model\CustomTable $custom_table + * @return void + */ public static function appendCreateAndDownloadButtonQRCode($tools, $custom_table) { $current_locale = App::getLocale(); diff --git a/src/Services/TemplateImportExport/TemplateExporter.php b/src/Services/TemplateImportExport/TemplateExporter.php index dc17dd232..6b6413c79 100644 --- a/src/Services/TemplateImportExport/TemplateExporter.php +++ b/src/Services/TemplateImportExport/TemplateExporter.php @@ -26,6 +26,7 @@ class TemplateExporter /** * Create template from this system . */ + // @phpstan-ignore-next-line public static function exportTemplate($template_name, $template_view_name, $description, $thumbnail, $options = []) { // set options @@ -69,7 +70,9 @@ public static function exportTemplate($template_name, $template_view_name, $desc // add config array $locale = \App::getLocale(); + // @phpstan-ignore-next-line $zip->addFromString('config.json', json_encode($config, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); + // @phpstan-ignore-next-line $zip->addFromString("lang/$locale/lang.json", json_encode($lang, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); $zip->close(); @@ -87,6 +90,7 @@ public static function exportTemplate($template_name, $template_view_name, $desc /** * get export data array */ + // @phpstan-ignore-next-line public static function getExportData($template_name, $template_view_name, $description, $options = [], $is_lang = false) { $config = []; @@ -126,6 +130,7 @@ public static function getExportData($template_name, $template_view_name, $descr /** * set table info to config */ + // @phpstan-ignore-next-line protected static function setTemplateTable(&$config, $target_tables, $is_lang = false) { // get customtable and columns -------------------------------------------------- @@ -206,6 +211,7 @@ protected static function setTemplateTable(&$config, $target_tables, $is_lang = /** * set menu info to config */ + // @phpstan-ignore-next-line protected static function setTemplateMenu(&$config, $target_tables, $is_lang = false) { // get menu -------------------------------------------------- @@ -223,6 +229,7 @@ protected static function setTemplateMenu(&$config, $target_tables, $is_lang = f /** * set dashboard info to config */ + // @phpstan-ignore-next-line protected static function setTemplateDashboard(&$config, $is_lang = false) { // get dashboards -------------------------------------------------- @@ -239,6 +246,7 @@ protected static function setTemplateDashboard(&$config, $is_lang = false) /** * set Role info to config */ + // @phpstan-ignore-next-line protected static function setTemplateRole(&$config, $is_lang = false) { // Get Roles -------------------------------------------------- @@ -255,6 +263,7 @@ protected static function setTemplateRole(&$config, $is_lang = false) /** * Export public form */ + // @phpstan-ignore-next-line protected static function setTemplatePublicForm(&$config, $public_form_uuid, $is_lang = false) { $public_form = PublicForm::getPublicFormByUuid($public_form_uuid, true); @@ -265,6 +274,7 @@ protected static function setTemplatePublicForm(&$config, $public_form_uuid, $is } + // @phpstan-ignore-next-line protected static function getTemplateMenuItems($menu, $target_tables, $is_lang = false) { // checking target table visible. if false, return empty array @@ -273,6 +283,7 @@ protected static function getTemplateMenuItems($menu, $target_tables, $is_lang = } $menus = []; + // @phpstan-ignore-next-line $menus[] = Menu::find(array_get($menu, 'id'))->getTemplateExportItems($is_lang); // if has children, loop diff --git a/src/Services/TemplateImportExport/TemplateImporter.php b/src/Services/TemplateImportExport/TemplateImporter.php index b2c021e6d..f44889fc6 100644 --- a/src/Services/TemplateImportExport/TemplateImporter.php +++ b/src/Services/TemplateImportExport/TemplateImporter.php @@ -28,6 +28,7 @@ */ class TemplateImporter { + // @phpstan-ignore-next-line protected $diskService; public function __construct() @@ -38,6 +39,7 @@ public function __construct() /** * get template list (get from app folder and vendor/exceedone/exment/templates) */ + // @phpstan-ignore-next-line public function getTemplates() { return array_merge($this->getUserTemplates(), $this->getLocalTemplates()); @@ -46,6 +48,7 @@ public function getTemplates() /** * Import template (from display. select item) */ + // @phpstan-ignore-next-line public function importTemplate($importKeys) { try { @@ -55,7 +58,9 @@ public function importTemplate($importKeys) foreach (array_filter($importKeys) as $importKey) { $item = collect($items)->first(function ($item) use ($importKey) { $importItem = json_decode_ex($importKey, true); + // @phpstan-ignore-next-line return array_get($item, 'template_type') == array_get($importItem, 'template_type') + // @phpstan-ignore-next-line && array_get($item, 'template_name') == array_get($importItem, 'template_name'); }); if (!isset($item)) { @@ -109,6 +114,7 @@ public function importTemplate($importKeys) /** * Get json from zip */ + // @phpstan-ignore-next-line public function getJsonFromZip($uploadFile) { try { @@ -134,6 +140,7 @@ public function getJsonFromZip($uploadFile) /** * Delete template (from display. select item) */ + // @phpstan-ignore-next-line public function deleteTemplate($teplate_name) { $diskItem = $this->diskService->diskItem(); @@ -150,6 +157,7 @@ public function deleteTemplate($teplate_name) /** * get user uploaded template list (get from storage folder) */ + // @phpstan-ignore-next-line protected function getUserTemplates() { $templates = []; @@ -166,6 +174,7 @@ protected function getUserTemplates() $locale = \App::getLocale(); try { + // @phpstan-ignore-next-line $dirname = pathinfo($path)['dirname']; $json = json_decode_ex($disk->get($path), true); // merge language file @@ -180,6 +189,7 @@ protected function getUserTemplates() if ($disk->exists($thumbnail_path)) { // if local, get path if ($diskItem->isDriverLocal()) { + // @phpstan-ignore-next-line $json['thumbnail_file'] = base64_encode(file_get_contents(path_join($diskItem->dirFullPath(), $thumbnail_path))); } // if crowd, get url @@ -202,6 +212,7 @@ protected function getUserTemplates() /** * get local template list (get from storage folder) */ + // @phpstan-ignore-next-line protected function getLocalTemplates() { $templates = []; @@ -211,6 +222,7 @@ protected function getLocalTemplates() $locale = \App::getLocale(); foreach ($paths as $path) { try { + // @phpstan-ignore-next-line $dirname = pathinfo($path)['dirname']; $json = json_decode_ex(File::get($path), true); // merge language file @@ -223,6 +235,7 @@ protected function getLocalTemplates() if (isset($json['thumbnail'])) { $thumbnail_fullpath = path_join($dirname, $json['thumbnail']); if (File::exists($thumbnail_fullpath)) { + // @phpstan-ignore-next-line $json['thumbnail_file'] = base64_encode(file_get_contents($thumbnail_fullpath)); } } @@ -241,6 +254,7 @@ protected function getLocalTemplates() /** * Import System template (from command) */ + // @phpstan-ignore-next-line public function importSystemTemplate($is_update = false) { // get vendor folder @@ -259,6 +273,7 @@ public function importSystemTemplate($is_update = false) ]); } + // @phpstan-ignore-next-line public function importSystemLogsTemplate($is_update = false) { // get vendor folder @@ -280,6 +295,7 @@ public function importSystemLogsTemplate($is_update = false) /** * Upload template and import (from display) */ + // @phpstan-ignore-next-line public function uploadTemplate($uploadFile) { try { @@ -331,6 +347,7 @@ public function uploadTemplate($uploadFile) * @return array offset 0: json, 1: tmpfolderpath, 2: fullpath. 3: config_path, 4: thumbnail_path, 5:tmpDiskItem * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ + // @phpstan-ignore-next-line protected function extractZip($uploadFile): array { $emptyResult = [null, null, null, null, null, null]; @@ -357,8 +374,11 @@ protected function extractZip($uploadFile): array $fileInfo = $zip->getNameIndex($i); if ($fileInfo === 'config.json') { $zip->extractTo($tmpfolderpath); + // @phpstan-ignore-next-line $config_path = array_get($stat, 'name'); + // @phpstan-ignore-next-line } elseif (pathinfo($fileInfo)['filename'] === 'thumbnail') { + // @phpstan-ignore-next-line $thumbnail_path = array_get($stat, 'name'); } } @@ -380,6 +400,7 @@ protected function extractZip($uploadFile): array /** * Upload Template with plugin */ + // @phpstan-ignore-next-line public function uploadTemplateWithPlugin($tmpDiskItem, $directory) { $tmpDisk = $tmpDiskItem->disk(); @@ -397,12 +418,14 @@ public function uploadTemplateWithPlugin($tmpDiskItem, $directory) } // get template name + // @phpstan-ignore-next-line $template_name = array_get($json, 'template_name'); if (!isset($template_name)) { return false; } // get thumbnail name + // @phpstan-ignore-next-line $thumbnail_name = array_get($json, 'thumbnail'); if (isset($thumbnail_name)) { $thumbnail_path = path_join($directory, $thumbnail_name); @@ -428,6 +451,7 @@ public function uploadTemplateWithPlugin($tmpDiskItem, $directory) /** * upload from excel and import */ + // @phpstan-ignore-next-line public function uploadTemplateExcel($file) { // template file settings as json @@ -576,6 +600,7 @@ public function uploadTemplateExcel($file) /** * execute import from file */ + // @phpstan-ignore-next-line protected function importFromFile($jsonString, $options = []) { $options = array_merge( @@ -614,12 +639,14 @@ protected function importFromFile($jsonString, $options = []) /** * import data using csv, xlsx */ + // @phpstan-ignore-next-line public function importData($dataPath) { $files = File::files($dataPath); // get all csv files $files = collect($files)->filter(function ($value) { + // @phpstan-ignore-next-line return in_array(pathinfo($value)['extension'], ['csv', 'xlsx']); }); @@ -653,6 +680,7 @@ public function importData($dataPath) * @param boolean $is_update Is called for update * @return void */ + // @phpstan-ignore-next-line public function import($json, $system_flg = false, $is_update = false, $fromExcel = false) { System::clearCache(); @@ -808,6 +836,7 @@ public function import($json, $system_flg = false, $is_update = false, $fromExce System::clearCache(); } + // @phpstan-ignore-next-line protected function getTemplatePath() { return exment_package_path('templates'); @@ -816,6 +845,7 @@ protected function getTemplatePath() /** * create model path from table name. */ + // @phpstan-ignore-next-line protected function getModelPath($tablename) { if (is_string($tablename)) { @@ -836,6 +866,7 @@ protected function getModelPath($tablename) * @param array $options * @return array|void */ + // @phpstan-ignore-next-line public function getMergeJson(string $jsonString = null, array $options = []) { $options = array_merge( @@ -879,6 +910,7 @@ public function getMergeJson(string $jsonString = null, array $options = []) /** * update template json by language json. */ + // @phpstan-ignore-next-line protected function mergeTemplate($json, $langJson, $fillpath = null) { $result = []; diff --git a/src/Services/Update/UpdateHelper.php b/src/Services/Update/UpdateHelper.php index 48a19619c..9d436c0c4 100644 --- a/src/Services/Update/UpdateHelper.php +++ b/src/Services/Update/UpdateHelper.php @@ -13,6 +13,7 @@ class UpdateHelper extends UpdateHelperBase * @param array $dependencies key is labrary name, value is version. If newest version,Please set "*". * @return $this */ + // @phpstan-ignore-next-line public function require(array $dependencies) { foreach ($dependencies as $name => $version) { diff --git a/src/Services/Update/UpdateService.php b/src/Services/Update/UpdateService.php index 71b538ed7..df826c180 100644 --- a/src/Services/Update/UpdateService.php +++ b/src/Services/Update/UpdateService.php @@ -16,6 +16,7 @@ */ class UpdateService { + // @phpstan-ignore-next-line public static function update(array $options = []) { \Exment::setTimeLimitLong(); @@ -48,6 +49,7 @@ public static function update(array $options = []) } + // @phpstan-ignore-next-line public static function callBackup() { $backup = new Backup(); @@ -99,6 +101,7 @@ public static function updateExment(ScriptEvent $event = null) } + // @phpstan-ignore-next-line public static function callPublish() { \Artisan::call('exment:update'); diff --git a/src/Services/Uuids.php b/src/Services/Uuids.php index 5718879af..5dd32eecf 100644 --- a/src/Services/Uuids.php +++ b/src/Services/Uuids.php @@ -8,6 +8,8 @@ trait Uuids { /** * Boot function from laravel. + * + * @return void */ protected static function boot() { diff --git a/src/Services/ViewFilter/Items/DayBeforeAfter/DayBeforeAfterBase.php b/src/Services/ViewFilter/Items/DayBeforeAfter/DayBeforeAfterBase.php index fb2c3e235..d6aa11dfe 100644 --- a/src/Services/ViewFilter/Items/DayBeforeAfter/DayBeforeAfterBase.php +++ b/src/Services/ViewFilter/Items/DayBeforeAfter/DayBeforeAfterBase.php @@ -15,6 +15,7 @@ protected function _setFilter($query, $method_name, $query_column, $query_value) $query->{"{$method_name}DateMarkExment"}($query_column, $target_day, $mark, $isDateTime); } + // @phpstan-ignore-next-line abstract protected function getTargetDay($query_value); abstract protected function getMark(): string; diff --git a/src/Services/ViewFilter/Items/DayBeforeAfter/DayLastXDayOrAfter.php b/src/Services/ViewFilter/Items/DayBeforeAfter/DayLastXDayOrAfter.php index b1cd49c48..7fb204a94 100644 --- a/src/Services/ViewFilter/Items/DayBeforeAfter/DayLastXDayOrAfter.php +++ b/src/Services/ViewFilter/Items/DayBeforeAfter/DayLastXDayOrAfter.php @@ -12,6 +12,7 @@ public static function getFilterOption() return FilterOption::DAY_LAST_X_DAY_OR_AFTER; } + // @phpstan-ignore-next-line protected function getTargetDay($query_value) { $today = Carbon::today(); diff --git a/src/Services/ViewFilter/Items/DayBeforeAfter/DayLastXDayOrBefore.php b/src/Services/ViewFilter/Items/DayBeforeAfter/DayLastXDayOrBefore.php index a240b916b..c2a281987 100644 --- a/src/Services/ViewFilter/Items/DayBeforeAfter/DayLastXDayOrBefore.php +++ b/src/Services/ViewFilter/Items/DayBeforeAfter/DayLastXDayOrBefore.php @@ -12,6 +12,7 @@ public static function getFilterOption() return FilterOption::DAY_LAST_X_DAY_OR_BEFORE; } + // @phpstan-ignore-next-line protected function getTargetDay($query_value) { $today = Carbon::today(); diff --git a/src/Services/ViewFilter/Items/DayBeforeAfter/DayNextXDayOrAfter.php b/src/Services/ViewFilter/Items/DayBeforeAfter/DayNextXDayOrAfter.php index 96249b3f3..5df456ffe 100644 --- a/src/Services/ViewFilter/Items/DayBeforeAfter/DayNextXDayOrAfter.php +++ b/src/Services/ViewFilter/Items/DayBeforeAfter/DayNextXDayOrAfter.php @@ -12,6 +12,7 @@ public static function getFilterOption() return FilterOption::DAY_NEXT_X_DAY_OR_AFTER; } + // @phpstan-ignore-next-line protected function getTargetDay($query_value) { $today = Carbon::today(); diff --git a/src/Services/ViewFilter/Items/DayBeforeAfter/DayNextXDayOrBefore.php b/src/Services/ViewFilter/Items/DayBeforeAfter/DayNextXDayOrBefore.php index bcd9e33a5..6eb428d72 100644 --- a/src/Services/ViewFilter/Items/DayBeforeAfter/DayNextXDayOrBefore.php +++ b/src/Services/ViewFilter/Items/DayBeforeAfter/DayNextXDayOrBefore.php @@ -12,6 +12,7 @@ public static function getFilterOption() return FilterOption::DAY_NEXT_X_DAY_OR_BEFORE; } + // @phpstan-ignore-next-line protected function getTargetDay($query_value) { $today = Carbon::today(); diff --git a/src/Services/ViewFilter/Items/DayBeforeAfter/DayOnOrAfter.php b/src/Services/ViewFilter/Items/DayBeforeAfter/DayOnOrAfter.php index df2f111f6..fe6819d1b 100644 --- a/src/Services/ViewFilter/Items/DayBeforeAfter/DayOnOrAfter.php +++ b/src/Services/ViewFilter/Items/DayBeforeAfter/DayOnOrAfter.php @@ -12,6 +12,7 @@ public static function getFilterOption() return FilterOption::DAY_ON_OR_AFTER; } + // @phpstan-ignore-next-line protected function getTargetDay($query_value) { return Carbon::parse($query_value); diff --git a/src/Services/ViewFilter/Items/DayBeforeAfter/DayOnOrBefore.php b/src/Services/ViewFilter/Items/DayBeforeAfter/DayOnOrBefore.php index d1d7a0a43..9b8300b17 100644 --- a/src/Services/ViewFilter/Items/DayBeforeAfter/DayOnOrBefore.php +++ b/src/Services/ViewFilter/Items/DayBeforeAfter/DayOnOrBefore.php @@ -12,6 +12,7 @@ public static function getFilterOption() return FilterOption::DAY_ON_OR_BEFORE; } + // @phpstan-ignore-next-line protected function getTargetDay($query_value) { return Carbon::parse($query_value); diff --git a/src/Services/ViewFilter/Items/DayBeforeAfter/DayTodayOrAfter.php b/src/Services/ViewFilter/Items/DayBeforeAfter/DayTodayOrAfter.php index 20f5ce4c2..45aabc134 100644 --- a/src/Services/ViewFilter/Items/DayBeforeAfter/DayTodayOrAfter.php +++ b/src/Services/ViewFilter/Items/DayBeforeAfter/DayTodayOrAfter.php @@ -12,6 +12,7 @@ public static function getFilterOption() return FilterOption::DAY_TODAY_OR_AFTER; } + // @phpstan-ignore-next-line protected function getTargetDay($query_value) { return Carbon::today(); diff --git a/src/Services/ViewFilter/Items/DayBeforeAfter/DayTodayOrBefore.php b/src/Services/ViewFilter/Items/DayBeforeAfter/DayTodayOrBefore.php index 43fdcaa58..900ca33e2 100644 --- a/src/Services/ViewFilter/Items/DayBeforeAfter/DayTodayOrBefore.php +++ b/src/Services/ViewFilter/Items/DayBeforeAfter/DayTodayOrBefore.php @@ -12,6 +12,7 @@ public static function getFilterOption() return FilterOption::DAY_TODAY_OR_BEFORE; } + // @phpstan-ignore-next-line protected function getTargetDay($query_value) { return Carbon::today(); diff --git a/src/Services/ViewFilter/Items/DayMonth/DayLastMonth.php b/src/Services/ViewFilter/Items/DayMonth/DayLastMonth.php index 2448be906..e5041a5f3 100644 --- a/src/Services/ViewFilter/Items/DayMonth/DayLastMonth.php +++ b/src/Services/ViewFilter/Items/DayMonth/DayLastMonth.php @@ -11,6 +11,7 @@ public static function getFilterOption() return FilterOption::DAY_LAST_MONTH; } + // @phpstan-ignore-next-line protected function getTargetDay($query_value) { return new \Carbon\Carbon('first day of last month'); diff --git a/src/Services/ViewFilter/Items/DayMonth/DayMonthBase.php b/src/Services/ViewFilter/Items/DayMonth/DayMonthBase.php index 3ee2a6fe5..5e4c4cc2b 100644 --- a/src/Services/ViewFilter/Items/DayMonth/DayMonthBase.php +++ b/src/Services/ViewFilter/Items/DayMonth/DayMonthBase.php @@ -22,6 +22,7 @@ protected function _setFilter($query, $method_name, $query_column, $query_value) * @param Carbon|string $target_day * @return array */ + // @phpstan-ignore-next-line protected function getTargetAndTodayFirstDay($target_day) { $target_day = Carbon::parse($target_day)->firstOfMonth(); @@ -30,5 +31,6 @@ protected function getTargetAndTodayFirstDay($target_day) return [$target_day, $today]; } + // @phpstan-ignore-next-line abstract protected function getTargetDay($query_value); } diff --git a/src/Services/ViewFilter/Items/DayMonth/DayNextMonth.php b/src/Services/ViewFilter/Items/DayMonth/DayNextMonth.php index ab99dcd8d..05a4b6d10 100644 --- a/src/Services/ViewFilter/Items/DayMonth/DayNextMonth.php +++ b/src/Services/ViewFilter/Items/DayMonth/DayNextMonth.php @@ -11,6 +11,7 @@ public static function getFilterOption() return FilterOption::DAY_NEXT_MONTH; } + // @phpstan-ignore-next-line protected function getTargetDay($query_value) { return new \Carbon\Carbon('first day of next month'); diff --git a/src/Services/ViewFilter/Items/DayMonth/DayThisMonth.php b/src/Services/ViewFilter/Items/DayMonth/DayThisMonth.php index a8b716600..cfacafb39 100644 --- a/src/Services/ViewFilter/Items/DayMonth/DayThisMonth.php +++ b/src/Services/ViewFilter/Items/DayMonth/DayThisMonth.php @@ -11,6 +11,7 @@ public static function getFilterOption() return FilterOption::DAY_THIS_MONTH; } + // @phpstan-ignore-next-line protected function getTargetDay($query_value) { return new \Carbon\Carbon('first day of this month'); diff --git a/src/Services/ViewFilter/Items/DayOn/DayOn.php b/src/Services/ViewFilter/Items/DayOn/DayOn.php index df4afd886..e2afa668c 100644 --- a/src/Services/ViewFilter/Items/DayOn/DayOn.php +++ b/src/Services/ViewFilter/Items/DayOn/DayOn.php @@ -11,6 +11,7 @@ public static function getFilterOption() return FilterOption::DAY_ON; } + // @phpstan-ignore-next-line protected function getTargetDay($query_value) { return \Carbon\Carbon::parse($query_value); diff --git a/src/Services/ViewFilter/Items/DayOn/DayOnBase.php b/src/Services/ViewFilter/Items/DayOn/DayOnBase.php index fa8981616..f841ba299 100644 --- a/src/Services/ViewFilter/Items/DayOn/DayOnBase.php +++ b/src/Services/ViewFilter/Items/DayOn/DayOnBase.php @@ -14,5 +14,6 @@ protected function _setFilter($query, $method_name, $query_column, $query_value) $query->{"{$method_name}DateExment"}($query_column, $target_day, $isDateTime); } + // @phpstan-ignore-next-line abstract protected function getTargetDay($query_value); } diff --git a/src/Services/ViewFilter/Items/DayOn/DayToday.php b/src/Services/ViewFilter/Items/DayOn/DayToday.php index 12881ef9d..e0d7be4f9 100644 --- a/src/Services/ViewFilter/Items/DayOn/DayToday.php +++ b/src/Services/ViewFilter/Items/DayOn/DayToday.php @@ -11,6 +11,7 @@ public static function getFilterOption() return FilterOption::DAY_TODAY; } + // @phpstan-ignore-next-line protected function getTargetDay($query_value) { return \Carbon\Carbon::today(); diff --git a/src/Services/ViewFilter/Items/DayOn/DayTomorrow.php b/src/Services/ViewFilter/Items/DayOn/DayTomorrow.php index e75a0885c..9f135784c 100644 --- a/src/Services/ViewFilter/Items/DayOn/DayTomorrow.php +++ b/src/Services/ViewFilter/Items/DayOn/DayTomorrow.php @@ -11,6 +11,7 @@ public static function getFilterOption() return FilterOption::DAY_TOMORROW; } + // @phpstan-ignore-next-line protected function getTargetDay($query_value) { return \Carbon\Carbon::tomorrow(); diff --git a/src/Services/ViewFilter/Items/DayOn/DayYesterday.php b/src/Services/ViewFilter/Items/DayOn/DayYesterday.php index 4f8fb0035..4b70f4cd6 100644 --- a/src/Services/ViewFilter/Items/DayOn/DayYesterday.php +++ b/src/Services/ViewFilter/Items/DayOn/DayYesterday.php @@ -11,6 +11,7 @@ public static function getFilterOption() return FilterOption::DAY_YESTERDAY; } + // @phpstan-ignore-next-line protected function getTargetDay($query_value) { return \Carbon\Carbon::yesterday(); diff --git a/src/Services/ViewFilter/Items/DayYear/DayLastYear.php b/src/Services/ViewFilter/Items/DayYear/DayLastYear.php index d38b58b44..72c546ead 100644 --- a/src/Services/ViewFilter/Items/DayYear/DayLastYear.php +++ b/src/Services/ViewFilter/Items/DayYear/DayLastYear.php @@ -11,6 +11,7 @@ public static function getFilterOption() return FilterOption::DAY_LAST_YEAR; } + // @phpstan-ignore-next-line protected function getTargetDay($query_value) { return new \Carbon\Carbon('first day of last year'); diff --git a/src/Services/ViewFilter/Items/DayYear/DayNextYear.php b/src/Services/ViewFilter/Items/DayYear/DayNextYear.php index 9e2b24052..4d2692d38 100644 --- a/src/Services/ViewFilter/Items/DayYear/DayNextYear.php +++ b/src/Services/ViewFilter/Items/DayYear/DayNextYear.php @@ -11,6 +11,7 @@ public static function getFilterOption() return FilterOption::DAY_NEXT_YEAR; } + // @phpstan-ignore-next-line protected function getTargetDay($query_value) { return new \Carbon\Carbon('first day of next year'); diff --git a/src/Services/ViewFilter/Items/DayYear/DayThisYear.php b/src/Services/ViewFilter/Items/DayYear/DayThisYear.php index 95e6befd8..8068924e3 100644 --- a/src/Services/ViewFilter/Items/DayYear/DayThisYear.php +++ b/src/Services/ViewFilter/Items/DayYear/DayThisYear.php @@ -11,6 +11,7 @@ public static function getFilterOption() return FilterOption::DAY_THIS_YEAR; } + // @phpstan-ignore-next-line protected function getTargetDay($query_value) { return new \Carbon\Carbon('first day of this year'); diff --git a/src/Services/ViewFilter/Items/DayYear/DayYearBase.php b/src/Services/ViewFilter/Items/DayYear/DayYearBase.php index be8c79b72..d9339ff8d 100644 --- a/src/Services/ViewFilter/Items/DayYear/DayYearBase.php +++ b/src/Services/ViewFilter/Items/DayYear/DayYearBase.php @@ -14,5 +14,6 @@ protected function _setFilter($query, $method_name, $query_column, $query_value) $query->{"{$method_name}YearExment"}($query_column, $target_day, $isDateTime); } + // @phpstan-ignore-next-line abstract protected function getTargetDay($query_value); } diff --git a/src/Services/ViewFilter/Items/TimeBeforeAfter/TimeBeforeAfterBase.php b/src/Services/ViewFilter/Items/TimeBeforeAfter/TimeBeforeAfterBase.php index e371ee9e6..1dccad280 100644 --- a/src/Services/ViewFilter/Items/TimeBeforeAfter/TimeBeforeAfterBase.php +++ b/src/Services/ViewFilter/Items/TimeBeforeAfter/TimeBeforeAfterBase.php @@ -14,6 +14,7 @@ protected function _setFilter($query, $method_name, $query_column, $query_value) $query->{$method_name}($query_column, $mark, $target_day); } + // @phpstan-ignore-next-line abstract protected function getTargetDay($query_value); abstract protected function getMark(): string; diff --git a/src/Services/ViewFilter/Items/TimeBeforeAfter/TimeOnOrAfter.php b/src/Services/ViewFilter/Items/TimeBeforeAfter/TimeOnOrAfter.php index c5a06283b..fc11c10d5 100644 --- a/src/Services/ViewFilter/Items/TimeBeforeAfter/TimeOnOrAfter.php +++ b/src/Services/ViewFilter/Items/TimeBeforeAfter/TimeOnOrAfter.php @@ -15,6 +15,7 @@ public static function getFilterOption() return FilterOption::TIME_ON_OR_AFTER; } + // @phpstan-ignore-next-line protected function getTargetDay($query_value) { return Carbon::parse($query_value)->format('H:i:s'); diff --git a/src/Services/ViewFilter/Items/TimeBeforeAfter/TimeOnOrBefore.php b/src/Services/ViewFilter/Items/TimeBeforeAfter/TimeOnOrBefore.php index b54f7161a..727cbddba 100644 --- a/src/Services/ViewFilter/Items/TimeBeforeAfter/TimeOnOrBefore.php +++ b/src/Services/ViewFilter/Items/TimeBeforeAfter/TimeOnOrBefore.php @@ -15,6 +15,7 @@ public static function getFilterOption() return FilterOption::TIME_ON_OR_BEFORE; } + // @phpstan-ignore-next-line protected function getTargetDay($query_value) { return Carbon::parse($query_value)->format('H:i:s'); diff --git a/src/Services/ViewFilter/ViewFilterBase.php b/src/Services/ViewFilter/ViewFilterBase.php index e5ce88e1b..b3ef2dbdf 100644 --- a/src/Services/ViewFilter/ViewFilterBase.php +++ b/src/Services/ViewFilter/ViewFilterBase.php @@ -111,6 +111,7 @@ abstract class ViewFilterBase */ protected $or_option = false; + // @phpstan-ignore-next-line public function __construct($column_item, array $options = []) { $this->column_item = $column_item; @@ -120,6 +121,7 @@ public function __construct($column_item, array $options = []) } + // @phpstan-ignore-next-line public function setCondition(Condition $condition) { $this->condition = $condition; @@ -160,12 +162,14 @@ protected function getQueryWhereName(): string * @param string|int $view_filter_condition * @return ViewFilterBase|null */ + // @phpstan-ignore-next-line public static function make($view_filter_condition, $column_item, array $options = []): ?ViewFilterBase { $classNames = static::classNames; foreach ($classNames as $className) { if (isMatchString($view_filter_condition, $className::getFilterOption())) { + // @phpstan-ignore-next-line return new $className($column_item, $options); } } @@ -179,6 +183,7 @@ public static function make($view_filter_condition, $column_item, array $options * @param Condition $condition * @return ViewFilterBase|null */ + // @phpstan-ignore-next-line public static function makeForCondition(Condition $condition, array $options = []): ?ViewFilterBase { $classNames = static::classNames; @@ -186,7 +191,9 @@ public static function makeForCondition(Condition $condition, array $options = [ foreach ($classNames as $className) { if (isMatchString($condition->condition_key, $className::getFilterOption())) { $instance = new $className(null, $options); + // @phpstan-ignore-next-line $instance->setCondition($condition); + // @phpstan-ignore-next-line return $instance; } } @@ -238,7 +245,7 @@ public function compareValue($value, $conditionValue): bool */ public function isNumeric(): bool { - /** @phpstan-ignore-next-line Negated boolean expression is always false. */ + // @phpstan-ignore-next-line if (!$this->condition) { return false; } diff --git a/src/Services/ZipService.php b/src/Services/ZipService.php index 61a54999f..38592ad11 100644 --- a/src/Services/ZipService.php +++ b/src/Services/ZipService.php @@ -13,6 +13,11 @@ class ZipService * Create Password zip. * encrypt is ZipCrypto * + * @param array $files + * @param string $zipFullPath + * @param string $tmpFolderPath + * @param string $password + * @param string|null $disk * @return void */ public static function createPasswordZip($files, $zipFullPath, $tmpFolderPath, $password, ?string $disk = null) @@ -50,6 +55,13 @@ public static function createPasswordZip($files, $zipFullPath, $tmpFolderPath, $ } } + /** + * @param string $zipFullPath + * @param string $tmpFolderPath + * @param string $password + * @return void + * @throws \Exception + */ protected static function execPasswordZipWin($zipFullPath, $tmpFolderPath, $password) { if ($tmpFolderPath == '/' || $tmpFolderPath == '') { @@ -61,6 +73,13 @@ protected static function execPasswordZipWin($zipFullPath, $tmpFolderPath, $pass exec('"' . $dir7zip . '" a -p' . $password . ' "' . $zipFullPath . '" "' . $tmpFolderPath . '/*"', $output); } + /** + * @param string $zipFullPath + * @param string $tmpFolderPath + * @param string $password + * @return void + * @throws \Exception + */ protected static function execPasswordZipLinux($zipFullPath, $tmpFolderPath, $password) { if ($tmpFolderPath == '/' || $tmpFolderPath == '') { diff --git a/src/Storage/Adapter/AdapterTrait.php b/src/Storage/Adapter/AdapterTrait.php index 5d025f98f..dfb3a1767 100644 --- a/src/Storage/Adapter/AdapterTrait.php +++ b/src/Storage/Adapter/AdapterTrait.php @@ -13,6 +13,7 @@ trait AdapterTrait /** * Get URL using File class */ + // @phpstan-ignore-next-line public function getUrl($path) { return File::getUrl($path); @@ -24,7 +25,7 @@ public function getUrl($path) * @param string $baseConfigKey * @param string $mergeConfigKey * @param string $mergeFrom - * @return array + * @return array */ public static function mergeFileConfig($baseConfigKey, $mergeConfigKey, $mergeFrom) { @@ -42,8 +43,11 @@ public static function mergeFileConfig($baseConfigKey, $mergeConfigKey, $mergeFr array_set($baseConfig, $k, $m); } + /** @phpstan-ignore-next-line Static call to instance method */ $keys = static::getMergeConfigKeys($mergeFrom); + /** @phpstan-ignore-next-line Dynamic iteration over adapter config keys */ foreach ($keys as $k => $v) { + /** @phpstan-ignore-next-line Helper function from Helpers.php */ if (is_nullorempty($v)) { continue; } diff --git a/src/Storage/Adapter/ExmentAdapterAzure.php b/src/Storage/Adapter/ExmentAdapterAzure.php index 3c5b66f04..2380bf4cb 100644 --- a/src/Storage/Adapter/ExmentAdapterAzure.php +++ b/src/Storage/Adapter/ExmentAdapterAzure.php @@ -12,6 +12,7 @@ class ExmentAdapterAzure extends AzureBlobStorageAdapter implements ExmentAdapte /** * get adapter class */ + // @phpstan-ignore-next-line public static function getAdapter($app, $config, $driverKey) { $mergeConfig = static::getConfig($config); @@ -21,6 +22,7 @@ public static function getAdapter($app, $config, $driverKey) return new self($client, array_get($mergeConfig, 'container')); } + // @phpstan-ignore-next-line public static function getMergeConfigKeys(string $mergeFrom, array $options = []): array { return [ @@ -34,6 +36,7 @@ public static function getMergeConfigKeys(string $mergeFrom, array $options = [] * @param array $config * @return array */ + // @phpstan-ignore-next-line public static function getConfig($config): array { $mergeFrom = array_get($config, 'mergeFrom'); diff --git a/src/Storage/Adapter/ExmentAdapterFtp.php b/src/Storage/Adapter/ExmentAdapterFtp.php index 89ffe13b3..632d3a33d 100644 --- a/src/Storage/Adapter/ExmentAdapterFtp.php +++ b/src/Storage/Adapter/ExmentAdapterFtp.php @@ -12,6 +12,7 @@ class ExmentAdapterFtp extends FtpAdapter implements ExmentAdapterInterface /** * get adapter class */ + // @phpstan-ignore-next-line public static function getAdapter($app, $config, $driverKey) { $mergeConfig = static::getConfig($config); @@ -20,6 +21,7 @@ public static function getAdapter($app, $config, $driverKey) return $driver; } + // @phpstan-ignore-next-line public static function getMergeConfigKeys(string $mergeFrom, array $options = []): array { return [ @@ -33,6 +35,7 @@ public static function getMergeConfigKeys(string $mergeFrom, array $options = [] * @param array $config * @return array */ + // @phpstan-ignore-next-line public static function getConfig($config): array { $mergeFrom = array_get($config, 'mergeFrom'); diff --git a/src/Storage/Adapter/ExmentAdapterInterface.php b/src/Storage/Adapter/ExmentAdapterInterface.php index 76f2dc42a..abbc16e97 100644 --- a/src/Storage/Adapter/ExmentAdapterInterface.php +++ b/src/Storage/Adapter/ExmentAdapterInterface.php @@ -4,13 +4,16 @@ interface ExmentAdapterInterface { + // @phpstan-ignore-next-line public function getUrl($path); /** * get adapter class */ + // @phpstan-ignore-next-line public static function getAdapter($app, $config, $driverKey); + // @phpstan-ignore-next-line public static function getMergeConfigKeys(string $mergeFrom, array $options = []): array; /** @@ -19,5 +22,6 @@ public static function getMergeConfigKeys(string $mergeFrom, array $options = [] * @param array $config * @return array */ + // @phpstan-ignore-next-line public static function getConfig($config): array; } diff --git a/src/Storage/Adapter/ExmentAdapterInterface2.php b/src/Storage/Adapter/ExmentAdapterInterface2.php index 099b49765..b94671f33 100644 --- a/src/Storage/Adapter/ExmentAdapterInterface2.php +++ b/src/Storage/Adapter/ExmentAdapterInterface2.php @@ -13,6 +13,7 @@ public function getUrl(string $path): string; /** * get adapter class */ + // @phpstan-ignore-next-line public static function getAdapter($app, $config, $driverKey); /** @@ -21,7 +22,9 @@ public static function getAdapter($app, $config, $driverKey); * @param array $config * @return array */ + // @phpstan-ignore-next-line public static function getConfig($config): array; + // @phpstan-ignore-next-line public static function getMergeConfigKeys(string $mergeFrom, array $options = []): array; } diff --git a/src/Storage/Adapter/ExmentAdapterLocal.php b/src/Storage/Adapter/ExmentAdapterLocal.php index ecc994955..5e63da7f3 100644 --- a/src/Storage/Adapter/ExmentAdapterLocal.php +++ b/src/Storage/Adapter/ExmentAdapterLocal.php @@ -11,6 +11,7 @@ class ExmentAdapterLocal extends LocalFilesystemAdapter implements ExmentAdapter /** * @var array */ + // @phpstan-ignore-next-line protected static $permissions = [ 'file' => [ 'public' => 0644, @@ -26,12 +27,14 @@ class ExmentAdapterLocal extends LocalFilesystemAdapter implements ExmentAdapter /** * get adapter class */ + // @phpstan-ignore-next-line public static function getAdapter($app, $config, $driverKey) { $mergeConfig = static::getConfig($config); return new self(array_get($mergeConfig, 'root')); } + // @phpstan-ignore-next-line public static function getMergeConfigKeys(string $mergeFrom, array $options = []): array { return []; @@ -43,6 +46,7 @@ public static function getMergeConfigKeys(string $mergeFrom, array $options = [] * @param array $config * @return array */ + // @phpstan-ignore-next-line public static function getConfig($config): array { $mergeFrom = array_get($config, 'mergeFrom'); diff --git a/src/Storage/Adapter/ExmentAdapterS3.php b/src/Storage/Adapter/ExmentAdapterS3.php index dff74ffb1..6aa58f2da 100644 --- a/src/Storage/Adapter/ExmentAdapterS3.php +++ b/src/Storage/Adapter/ExmentAdapterS3.php @@ -23,6 +23,7 @@ class ExmentAdapterS3 extends AwsS3V3Adapter implements ExmentAdapterInterface /** * get adapter class */ + // @phpstan-ignore-next-line public static function getAdapter($app, $config, $driverKey) { $mergeConfig = static::getConfig($config); @@ -48,6 +49,7 @@ public static function getAdapter($app, $config, $driverKey) return new self($client, array_get($mergeConfig, 'bucket')); } + // @phpstan-ignore-next-line public static function getMergeConfigKeys(string $mergeFrom, array $options = []): array { return [ @@ -61,6 +63,7 @@ public static function getMergeConfigKeys(string $mergeFrom, array $options = [] * @param array $config * @return array */ + // @phpstan-ignore-next-line public static function getConfig($config): array { $mergeFrom = array_get($config, 'mergeFrom'); diff --git a/src/Storage/Adapter/ExmentAdapterSftp.php b/src/Storage/Adapter/ExmentAdapterSftp.php index 801fb2589..e71ca6387 100644 --- a/src/Storage/Adapter/ExmentAdapterSftp.php +++ b/src/Storage/Adapter/ExmentAdapterSftp.php @@ -13,6 +13,7 @@ class ExmentAdapterSftp extends SftpAdapter implements ExmentAdapterInterface /** * get adapter class */ + // @phpstan-ignore-next-line public static function getAdapter($app, $config, $driverKey) { $mergeConfig = static::getConfig($config); @@ -26,6 +27,7 @@ public static function getAdapter($app, $config, $driverKey) return $driver; } + // @phpstan-ignore-next-line public static function getMergeConfigKeys(string $mergeFrom, array $options = []): array { return [ @@ -39,6 +41,7 @@ public static function getMergeConfigKeys(string $mergeFrom, array $options = [] * @param array $config * @return array */ + // @phpstan-ignore-next-line public static function getConfig($config): array { $mergeFrom = array_get($config, 'mergeFrom'); diff --git a/src/Storage/Disk/AdminDiskService.php b/src/Storage/Disk/AdminDiskService.php index cc563e181..1a8dfb439 100644 --- a/src/Storage/Disk/AdminDiskService.php +++ b/src/Storage/Disk/AdminDiskService.php @@ -10,6 +10,7 @@ */ class AdminDiskService extends DiskServiceBase { + // @phpstan-ignore-next-line public function __construct(...$args) { $now = \Carbon\Carbon::now()->format('YmdHisv'); diff --git a/src/Storage/Disk/BackupDiskService.php b/src/Storage/Disk/BackupDiskService.php index fb48a4b2b..6899cc73d 100644 --- a/src/Storage/Disk/BackupDiskService.php +++ b/src/Storage/Disk/BackupDiskService.php @@ -7,6 +7,7 @@ class BackupDiskService extends DiskServiceBase { + // @phpstan-ignore-next-line public function __construct(...$args) { $now = date('YmdHis'); diff --git a/src/Storage/Disk/DiskServiceBase.php b/src/Storage/Disk/DiskServiceBase.php index be12d96a2..3af2f6ca5 100644 --- a/src/Storage/Disk/DiskServiceBase.php +++ b/src/Storage/Disk/DiskServiceBase.php @@ -15,35 +15,42 @@ abstract class DiskServiceBase * default disk Item * */ + // @phpstan-ignore-next-line protected $diskItem; /** * tmp disk Item * */ + // @phpstan-ignore-next-line protected $tmpDiskItem; /** * tmp disk Item * */ + // @phpstan-ignore-next-line protected $localSyncDiskItem; /** * Whether is this driver isNeedDownload */ + // @phpstan-ignore-next-line public $isNeedDownload = null; + // @phpstan-ignore-next-line public function diskItem() { return $this->diskItem; } + // @phpstan-ignore-next-line public function tmpDiskItem() { return $this->tmpDiskItem; } + // @phpstan-ignore-next-line public function localSyncDiskItem() { return $this->localSyncDiskItem; @@ -54,6 +61,7 @@ public function localSyncDiskItem() * * @return void */ + // @phpstan-ignore-next-line public function upload($file) { foreach ((array)$file as $key => $value) { @@ -114,7 +122,9 @@ public function syncFromDisk() return $this->sync(); } + // @phpstan-ignore-next-line abstract protected function isNeedDownload(); + // @phpstan-ignore-next-line abstract protected function isDeleteTmpAfterExecute(); /** diff --git a/src/Storage/Disk/DiskServiceItem.php b/src/Storage/Disk/DiskServiceItem.php index c228a6881..2ccfb6171 100644 --- a/src/Storage/Disk/DiskServiceItem.php +++ b/src/Storage/Disk/DiskServiceItem.php @@ -47,6 +47,7 @@ public function __construct($disk, $fileName, $dirName) protected $disk; + // @phpstan-ignore-next-line public function fileNameNoExtension() { if (is_null($this->fileName)) { diff --git a/src/Storage/Disk/PluginDiskService.php b/src/Storage/Disk/PluginDiskService.php index 38fcdc16e..3a2aad4b2 100644 --- a/src/Storage/Disk/PluginDiskService.php +++ b/src/Storage/Disk/PluginDiskService.php @@ -7,15 +7,19 @@ class PluginDiskService extends DiskServiceBase { + // @phpstan-ignore-next-line protected $plugin; + // @phpstan-ignore-next-line protected $now; + // @phpstan-ignore-next-line public function __construct(...$args) { $this->now = date('YmdHis'); $this->initDiskService(isset($args[0]) ? $args[0] : null); } + // @phpstan-ignore-next-line public function initDiskService($plugin) { $this->plugin = $plugin; @@ -66,6 +70,7 @@ protected function isNeedDownload() return false; } + // @phpstan-ignore-next-line protected function isSetUpdatedAt() { return false; diff --git a/src/Storage/Disk/TemplateDiskService.php b/src/Storage/Disk/TemplateDiskService.php index f23f66bfa..020a19a33 100644 --- a/src/Storage/Disk/TemplateDiskService.php +++ b/src/Storage/Disk/TemplateDiskService.php @@ -7,14 +7,17 @@ class TemplateDiskService extends DiskServiceBase { + // @phpstan-ignore-next-line protected $now; + // @phpstan-ignore-next-line public function __construct(...$args) { $this->now = date('YmdHis'); $this->initDiskService(isset($args[0]) ? $args[0] : null); } + // @phpstan-ignore-next-line public function initDiskService($template_name) { $this->diskItem = new DiskServiceItem(Storage::disk(Define::DISKNAME_TEMPLATE_SYNC), $template_name, $template_name); diff --git a/src/Validator/BooleanRule.php b/src/Validator/BooleanRule.php index a9db11061..bf9e4bd89 100644 --- a/src/Validator/BooleanRule.php +++ b/src/Validator/BooleanRule.php @@ -9,8 +9,12 @@ */ class BooleanRule implements Rule { + /** @var array */ protected $options; + /** + * @param array $parameters + */ public function __construct($parameters) { $this->options = $parameters; @@ -52,7 +56,7 @@ public function message() $values[] = $v; } - return trans('validation.in', [ + return (string)trans('validation.in', [ 'values' => implode(",", $values) ]); } diff --git a/src/Validator/CaptchaRule.php b/src/Validator/CaptchaRule.php index bf637b4c8..527dff4c5 100644 --- a/src/Validator/CaptchaRule.php +++ b/src/Validator/CaptchaRule.php @@ -23,6 +23,7 @@ class CaptchaRule implements Rule protected $version; /** @var array */ + // @phpstan-ignore-next-line protected $skipIps = []; /* ----------------------------------------------------------------- @@ -69,6 +70,7 @@ public function version($version) * * @return $this */ + // @phpstan-ignore-next-line public function skipIps($ip) { $this->skipIps = Arr::wrap($ip); diff --git a/src/Validator/ChangeFieldRule.php b/src/Validator/ChangeFieldRule.php index 25c59c050..cc59dc55f 100644 --- a/src/Validator/ChangeFieldRule.php +++ b/src/Validator/ChangeFieldRule.php @@ -11,10 +11,14 @@ */ class ChangeFieldRule implements Rule { + /** @var mixed */ protected $custom_table; + /** @var mixed */ protected $label; + /** @var mixed */ protected $target; + // @phpstan-ignore-next-line public function __construct(?CustomTable $custom_table, $label, $target) { $this->custom_table = $custom_table; @@ -57,6 +61,6 @@ public function passes($attribute, $value) */ public function message() { - return trans('validation.numeric'); + return (string)trans('validation.numeric'); } } diff --git a/src/Validator/ComplexPasswordRule.php b/src/Validator/ComplexPasswordRule.php index c080b8bb9..4f694f16a 100644 --- a/src/Validator/ComplexPasswordRule.php +++ b/src/Validator/ComplexPasswordRule.php @@ -26,6 +26,7 @@ public function passes($attribute, $value) return true; } + // @phpstan-ignore-next-line $char_cnt = collect(['a-z', 'A-Z', '0-9', '^a-zA-Z0-9'])->filter(function ($regstr) use ($value) { return preg_match("/[$regstr]+/", $value); })->count(); @@ -48,6 +49,6 @@ public function passes($attribute, $value) */ public function message() { - return exmtrans('validation.complex_password'); + return (string)exmtrans('validation.complex_password'); } } diff --git a/src/Validator/CurrentPasswordRule.php b/src/Validator/CurrentPasswordRule.php index 90d4ba510..e15a4d483 100644 --- a/src/Validator/CurrentPasswordRule.php +++ b/src/Validator/CurrentPasswordRule.php @@ -36,6 +36,6 @@ public function passes($attribute, $value) */ public function message() { - return exmtrans('validation.current_password'); + return (string)exmtrans('validation.current_password'); } } diff --git a/src/Validator/CustomColumnIndexCountRule.php b/src/Validator/CustomColumnIndexCountRule.php index 35fd2cf59..ef1915feb 100644 --- a/src/Validator/CustomColumnIndexCountRule.php +++ b/src/Validator/CustomColumnIndexCountRule.php @@ -12,9 +12,12 @@ */ class CustomColumnIndexCountRule implements Rule { + /** @var mixed */ protected $custom_table; + /** @var mixed */ protected $custom_column_id; + // @phpstan-ignore-next-line public function __construct(...$parameters) { $this->custom_table = CustomTable::getEloquent($parameters[0]); @@ -55,7 +58,7 @@ public function passes($attribute, $value) */ public function message() { - return exmtrans('validation.max_table_index', [ + return (string)exmtrans('validation.max_table_index', [ 'count' => config('exment.column_index_enabled_count', 20), ]); } diff --git a/src/Validator/CustomColumnUsingIndexRule.php b/src/Validator/CustomColumnUsingIndexRule.php index f836605ec..d9b451080 100644 --- a/src/Validator/CustomColumnUsingIndexRule.php +++ b/src/Validator/CustomColumnUsingIndexRule.php @@ -13,8 +13,10 @@ */ class CustomColumnUsingIndexRule implements Rule { + /** @var mixed */ protected $custom_column_id; + // @phpstan-ignore-next-line public function __construct(...$parameters) { $this->custom_column_id = $parameters[0]; @@ -85,6 +87,6 @@ public function passes($attribute, $value) */ public function message() { - return exmtrans('validation.using_index_column'); + return (string)exmtrans('validation.using_index_column'); } } diff --git a/src/Validator/CustomValueRule.php b/src/Validator/CustomValueRule.php index 4f8d2dc12..14921ba35 100644 --- a/src/Validator/CustomValueRule.php +++ b/src/Validator/CustomValueRule.php @@ -12,6 +12,7 @@ */ class CustomValueRule implements Rule { + /** @var mixed */ protected $custom_table; /** @@ -21,6 +22,10 @@ class CustomValueRule implements Rule */ protected $custom_view; + /** + * @param mixed $custom_table + */ + // @phpstan-ignore-next-line public function __construct($custom_table, $custom_view = null) { $this->custom_table = CustomTable::getEloquent($custom_table); @@ -62,6 +67,7 @@ public function passes($attribute, $value) * * @return boolean */ + // @phpstan-ignore-next-line protected function hasData(array $values): bool { foreach ($values as $v) { @@ -84,6 +90,7 @@ protected function hasData(array $values): bool * * @return boolean */ + // @phpstan-ignore-next-line protected function hasCustomViewFilter(array $values): bool { if (is_nullorempty($this->custom_view)) { @@ -92,6 +99,7 @@ protected function hasCustomViewFilter(array $values): bool // filter query $query = $this->custom_table->getValueQuery(); + // @phpstan-ignore-next-line $this->custom_view->filterModel($query); // Not sort. $query->whereIn(getDBTableName($this->custom_table) . '.id', $values); @@ -110,7 +118,7 @@ protected function hasCustomViewFilter(array $values): bool */ public function message() { - return exmtrans('validation.not_has_custom_value', [ + return (string)exmtrans('validation.not_has_custom_value', [ 'table_view_name' => $this->custom_table->table_view_name, 'value' => null, ]); diff --git a/src/Validator/DecimalCommaRule.php b/src/Validator/DecimalCommaRule.php index f41729ed7..fe800485c 100644 --- a/src/Validator/DecimalCommaRule.php +++ b/src/Validator/DecimalCommaRule.php @@ -18,6 +18,7 @@ public function passes($attribute, $value) if (is_list($value)) { return false; } + // @phpstan-ignore-next-line return preg_match('/^[-]?[\d\s,\.]*$/', $value); } @@ -28,6 +29,6 @@ public function passes($attribute, $value) */ public function message() { - return trans('validation.numeric'); + return (string)trans('validation.numeric'); } } diff --git a/src/Validator/DuplicateRelationRule.php b/src/Validator/DuplicateRelationRule.php index bd8b3a436..ccc5a2daa 100644 --- a/src/Validator/DuplicateRelationRule.php +++ b/src/Validator/DuplicateRelationRule.php @@ -12,8 +12,12 @@ */ class DuplicateRelationRule implements Rule { + /** @var mixed */ protected $relation_id; + /** + * @param mixed $relation_id + */ public function __construct($relation_id) { $this->relation_id = $relation_id; @@ -49,6 +53,6 @@ public function passes($attribute, $value) */ public function message() { - return exmtrans('validation.duplicate_relation'); + return (string)exmtrans('validation.duplicate_relation'); } } diff --git a/src/Validator/EmailMultiline.php b/src/Validator/EmailMultiline.php index b494e58d8..445be3d66 100644 --- a/src/Validator/EmailMultiline.php +++ b/src/Validator/EmailMultiline.php @@ -45,6 +45,6 @@ public function passes($attribute, $value) */ public function message() { - return exmtrans('validation.email_multiline'); + return (string)exmtrans('validation.email_multiline'); } } diff --git a/src/Validator/EmptyRule.php b/src/Validator/EmptyRule.php index 74385506c..287d473cd 100644 --- a/src/Validator/EmptyRule.php +++ b/src/Validator/EmptyRule.php @@ -27,6 +27,6 @@ public function passes($attribute, $value) */ public function message() { - return exmtrans('validation.empty'); + return (string)exmtrans('validation.empty'); } } diff --git a/src/Validator/ExmentCustomValidator.php b/src/Validator/ExmentCustomValidator.php index 94ee3973f..09954372e 100644 --- a/src/Validator/ExmentCustomValidator.php +++ b/src/Validator/ExmentCustomValidator.php @@ -22,6 +22,7 @@ class ExmentCustomValidator extends AdminValidator * * @var array */ + // @phpstan-ignore-next-line protected $appendedMessages = []; public function passes() @@ -34,6 +35,7 @@ public function fails() return parent::fails() || count($this->appendedMessages) > 0; } + // @phpstan-ignore-next-line public function getMessages() { return array_merge($this->errors()->messages(), $this->appendedMessages); @@ -45,6 +47,7 @@ public function getMessages() * @param array $errors * @return self */ + // @phpstan-ignore-next-line public function appendMessages(array $errors) { foreach ($errors as $key => $error) { @@ -54,6 +57,7 @@ public function appendMessages(array $errors) return $this; } + // @phpstan-ignore-next-line public function getMessageStrings(): array { $messages = collect(); @@ -74,6 +78,7 @@ public function getMessageStrings(): array * @param array $parameters * @return bool */ + // @phpstan-ignore-next-line public function validateUniqueInTable($attribute, $value, $parameters) { if (count($parameters) < 2) { @@ -105,6 +110,7 @@ public function validateUniqueInTable($attribute, $value, $parameters) * @param array $parameters * @return bool */ + // @phpstan-ignore-next-line public function validateSummaryCondition($attribute, $value, $parameters) { $field_name = str_replace('.view_summary_condition', '.view_column_target', $attribute); @@ -135,6 +141,7 @@ public function validateSummaryCondition($attribute, $value, $parameters) * @param array $parameters * @return bool */ + // @phpstan-ignore-next-line public function validateLoopRelation($attribute, $value, $parameters) { if (count($parameters) < 1) { @@ -161,6 +168,7 @@ public function validateLoopRelation($attribute, $value, $parameters) /** * check if exists custom relation. */ + // @phpstan-ignore-next-line protected function HasRelation($attr1, $attr2, $custom_table_id, $value, $relation_id = null) { // get count reverse relation in table; @@ -184,6 +192,7 @@ protected function HasRelation($attr1, $attr2, $custom_table_id, $value, $relati return true; } + // @phpstan-ignore-next-line protected function replaceChangeFieldValue($message, $attribute, $rule, $parameters) { if (count($parameters) > 0) { @@ -200,6 +209,7 @@ protected function replaceChangeFieldValue($message, $attribute, $rule, $paramet * @param array $parameters * @return bool */ + // @phpstan-ignore-next-line public function validateRegularExpression($attribute, $value, $parameters) { set_error_handler( diff --git a/src/Validator/FaviconRule.php b/src/Validator/FaviconRule.php index 8311063a1..573b19257 100644 --- a/src/Validator/FaviconRule.php +++ b/src/Validator/FaviconRule.php @@ -9,8 +9,8 @@ class FaviconRule extends FileRule { /** * @param array $extensions - * @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line public function __construct(array $extensions = []) { $this->extensions = ['ico']; @@ -23,6 +23,6 @@ public function __construct(array $extensions = []) */ public function message() { - return trans('validation.image'); + return (string)trans('validation.image'); } } diff --git a/src/Validator/FileNameRule.php b/src/Validator/FileNameRule.php index eb2f1b12f..bac14c8da 100644 --- a/src/Validator/FileNameRule.php +++ b/src/Validator/FileNameRule.php @@ -36,6 +36,7 @@ public function passes($attribute, $value) } } + // @phpstan-ignore-next-line protected function validateFileName($attribute, $value) { // not check null or empty. Check by other required rule. @@ -63,6 +64,6 @@ protected function validateFileName($attribute, $value) */ public function message() { - return exmtrans('validation.filename_not_allow'); + return (string)exmtrans('validation.filename_not_allow'); } } diff --git a/src/Validator/FileRequredRule.php b/src/Validator/FileRequredRule.php index 4bacf11c9..0c5223385 100644 --- a/src/Validator/FileRequredRule.php +++ b/src/Validator/FileRequredRule.php @@ -12,8 +12,10 @@ */ class FileRequredRule implements ImplicitRule { + /** @var mixed */ protected $custom_column; + /** @var mixed */ protected $custom_value; public function __construct(CustomColumn $custom_column, ?CustomValue $custom_value) @@ -52,6 +54,6 @@ public function passes($attribute, $value) */ public function message() { - return trans('validation.required'); + return (string)trans('validation.required'); } } diff --git a/src/Validator/FileRule.php b/src/Validator/FileRule.php index da72729ff..921e4c0a6 100644 --- a/src/Validator/FileRule.php +++ b/src/Validator/FileRule.php @@ -12,8 +12,10 @@ class FileRule implements Rule { use ValidatesAttributes; + // @phpstan-ignore-next-line protected $extensions = []; + // @phpstan-ignore-next-line public function __construct(array $extensions = []) { $this->extensions = $extensions; @@ -51,6 +53,7 @@ public function passes($attribute, $value) } } + // @phpstan-ignore-next-line protected function validateExtension($attribute, $value) { if (is_string($value)) { @@ -80,6 +83,6 @@ protected function validateExtension($attribute, $value) */ public function message() { - return trans('validation.mimes', ['values' => arrayToString($this->extensions)]); + return (string)trans('validation.mimes', ['values' => arrayToString($this->extensions)]); } } diff --git a/src/Validator/ImageRule.php b/src/Validator/ImageRule.php index 039a8fe5f..7b53b77db 100644 --- a/src/Validator/ImageRule.php +++ b/src/Validator/ImageRule.php @@ -11,8 +11,8 @@ class ImageRule extends FileRule { /** * @param array $extensions - * @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line public function __construct(array $extensions = []) { $this->extensions = Define::IMAGE_RULE_EXTENSIONS; @@ -25,6 +25,6 @@ public function __construct(array $extensions = []) */ public function message() { - return trans('validation.image'); + return (string)trans('validation.image'); } } diff --git a/src/Validator/InitOnlyRule.php b/src/Validator/InitOnlyRule.php index 60198a604..eee65411d 100644 --- a/src/Validator/InitOnlyRule.php +++ b/src/Validator/InitOnlyRule.php @@ -13,7 +13,9 @@ */ class InitOnlyRule implements Rule { + /** @var mixed */ protected $custom_column; + /** @var mixed */ protected $custom_value; public function __construct(CustomColumn $custom_column, ?CustomValue $custom_value) @@ -56,11 +58,12 @@ public function passes($attribute, $value) */ public function message() { - return exmtrans('validation.init_only', [ + return (string)exmtrans('validation.init_only', [ 'original_value' => $this->getOriginalValue(), ]); } + // @phpstan-ignore-next-line protected function getOriginalValue() { return array_get($this->custom_value->value, $this->custom_column->column_name); diff --git a/src/Validator/IntegerCommaRule.php b/src/Validator/IntegerCommaRule.php index 67b88e3b3..0fd636afc 100644 --- a/src/Validator/IntegerCommaRule.php +++ b/src/Validator/IntegerCommaRule.php @@ -18,6 +18,7 @@ public function passes($attribute, $value) if (is_list($value)) { return false; } + // @phpstan-ignore-next-line return preg_match('/^[-]?[\d\s,]*$/', $value); } @@ -28,6 +29,6 @@ public function passes($attribute, $value) */ public function message() { - return trans('validation.integer'); + return (string)trans('validation.integer'); } } diff --git a/src/Validator/MaxLengthExRule.php b/src/Validator/MaxLengthExRule.php index ae5a2d4df..1d300db31 100644 --- a/src/Validator/MaxLengthExRule.php +++ b/src/Validator/MaxLengthExRule.php @@ -10,8 +10,12 @@ */ class MaxLengthExRule implements Rule { + /** @var mixed */ protected $max_length; + /** + * @param mixed $parameters + */ public function __construct($parameters) { $this->max_length = $parameters; @@ -42,6 +46,7 @@ public function passes($attribute, $value) */ public function message() { + // @phpstan-ignore-next-line return str_replace(':max', $this->max_length, trans('validation.max.string')); } } diff --git a/src/Validator/NumberMaxRule.php b/src/Validator/NumberMaxRule.php index 66138ca98..2c9f7f976 100644 --- a/src/Validator/NumberMaxRule.php +++ b/src/Validator/NumberMaxRule.php @@ -10,8 +10,12 @@ */ class NumberMaxRule implements Rule { + /** @var mixed */ protected $max; + /** + * @param mixed $parameters + */ public function __construct($parameters) { $this->max = $parameters; @@ -47,6 +51,7 @@ public function passes($attribute, $value) */ public function message() { + // @phpstan-ignore-next-line return str_replace(':max', $this->max, trans('validation.max.numeric')); } } diff --git a/src/Validator/NumberMinRule.php b/src/Validator/NumberMinRule.php index 52d0c5bfe..26e1c40cf 100644 --- a/src/Validator/NumberMinRule.php +++ b/src/Validator/NumberMinRule.php @@ -10,8 +10,12 @@ */ class NumberMinRule implements Rule { + /** @var mixed */ protected $min; + /** + * @param mixed $parameters + */ public function __construct($parameters) { $this->min = $parameters; @@ -47,6 +51,7 @@ public function passes($attribute, $value) */ public function message() { + // @phpstan-ignore-next-line return str_replace(':min', $this->min, trans('validation.min.numeric')); } } diff --git a/src/Validator/PasswordHistoryRule.php b/src/Validator/PasswordHistoryRule.php index 49ceb491c..c743d3bcd 100644 --- a/src/Validator/PasswordHistoryRule.php +++ b/src/Validator/PasswordHistoryRule.php @@ -12,6 +12,7 @@ */ class PasswordHistoryRule implements Rule { + /** @var mixed */ protected $login_user; public function __construct(?LoginUser $login_user) @@ -61,6 +62,6 @@ public function passes($attribute, $value) */ public function message() { - return exmtrans('validation.password_history'); + return (string)exmtrans('validation.password_history'); } } diff --git a/src/Validator/PluginNamespaceRule.php b/src/Validator/PluginNamespaceRule.php index d62178bea..e25ccf2d0 100644 --- a/src/Validator/PluginNamespaceRule.php +++ b/src/Validator/PluginNamespaceRule.php @@ -11,6 +11,7 @@ */ class PluginNamespaceRule implements Rule { + // @phpstan-ignore-next-line protected $errors = []; /** @@ -83,6 +84,6 @@ public function passes($attribute, $value) public function message() { $classes = implode(exmtrans('common.separate_word'), $this->errors); - return exmtrans('plugin.error.class_wrongnamespace', ['classes' => $classes]); + return (string)exmtrans('plugin.error.class_wrongnamespace', ['classes' => $classes]); } } diff --git a/src/Validator/PluginRequirementRule.php b/src/Validator/PluginRequirementRule.php index e4e9e19e3..5664bbc4b 100644 --- a/src/Validator/PluginRequirementRule.php +++ b/src/Validator/PluginRequirementRule.php @@ -10,6 +10,7 @@ */ class PluginRequirementRule implements Rule { + // @phpstan-ignore-next-line protected $composers = []; public function __construct() @@ -60,6 +61,6 @@ public function passes($attribute, $value) public function message() { $composer = implode(exmtrans('common.separate_word'), $this->composers); - return exmtrans('plugin.error.class_requirement', ['composer' => $composer]); + return (string)exmtrans('plugin.error.class_requirement', ['composer' => $composer]); } } diff --git a/src/Validator/PluginTypeRule.php b/src/Validator/PluginTypeRule.php index 78e8631c5..ebd331b89 100644 --- a/src/Validator/PluginTypeRule.php +++ b/src/Validator/PluginTypeRule.php @@ -47,9 +47,11 @@ public function passes($attribute, $value) public function message() { $pluginTypes = $this->getPluginTypeDifinitions()->toArray(); + // @phpstan-ignore-next-line return str_replace(':values', implode(exmtrans('common.separate_word'), $pluginTypes), trans('validation.in')); } + // @phpstan-ignore-next-line protected function getPluginTypeDifinitions() { return collect(PluginType::keys())->map(function ($p) { diff --git a/src/Validator/SamlNameUniqueRule.php b/src/Validator/SamlNameUniqueRule.php index e91c468ef..969386f5c 100644 --- a/src/Validator/SamlNameUniqueRule.php +++ b/src/Validator/SamlNameUniqueRule.php @@ -41,6 +41,6 @@ public function passes($attribute, $value) */ public function message() { - return trans('validation.unique'); + return (string)trans('validation.unique'); } } diff --git a/src/Validator/SelectRule.php b/src/Validator/SelectRule.php index 821c0b99d..e2a56bd8d 100644 --- a/src/Validator/SelectRule.php +++ b/src/Validator/SelectRule.php @@ -11,8 +11,12 @@ */ class SelectRule implements Rule { + /** @var mixed */ protected $keys; + /** + * @param mixed $parameters + */ public function __construct($parameters) { $this->keys = $parameters; @@ -54,6 +58,6 @@ public function passes($attribute, $value) */ public function message() { - return trans('validation.in', ['values' => implode(exmtrans('common.separate_word'), $this->keys)]); + return (string)trans('validation.in', ['values' => implode(exmtrans('common.separate_word'), $this->keys)]); } } diff --git a/src/Validator/SelectTableNumericRule.php b/src/Validator/SelectTableNumericRule.php index 83acb5ad0..1a1044888 100644 --- a/src/Validator/SelectTableNumericRule.php +++ b/src/Validator/SelectTableNumericRule.php @@ -62,6 +62,6 @@ public function passes($attribute, $value) */ public function message() { - return trans('validation.numeric'); + return (string)trans('validation.numeric'); } } diff --git a/src/Validator/SelectValTextRule.php b/src/Validator/SelectValTextRule.php index 67533e13e..788c57289 100644 --- a/src/Validator/SelectValTextRule.php +++ b/src/Validator/SelectValTextRule.php @@ -11,8 +11,12 @@ */ class SelectValTextRule implements Rule { + /** @var mixed */ protected $keys; + /** + * @param mixed $parameters + */ public function __construct($parameters) { $this->keys = $parameters; @@ -54,6 +58,6 @@ public function passes($attribute, $value) */ public function message() { - return trans('validation.in', ['values' => implode(exmtrans('common.separate_word'), $this->keys)]); + return (string)trans('validation.in', ['values' => implode(exmtrans('common.separate_word'), $this->keys)]); } } diff --git a/src/Validator/SelectValTextSettingRule.php b/src/Validator/SelectValTextSettingRule.php index 8623eb04c..79907b8b7 100644 --- a/src/Validator/SelectValTextSettingRule.php +++ b/src/Validator/SelectValTextSettingRule.php @@ -10,6 +10,7 @@ */ class SelectValTextSettingRule implements Rule { + // @phpstan-ignore-next-line protected $errors = []; public function __construct() { diff --git a/src/Validator/StringNumericRule.php b/src/Validator/StringNumericRule.php index 7fabcdb25..88159d226 100644 --- a/src/Validator/StringNumericRule.php +++ b/src/Validator/StringNumericRule.php @@ -40,6 +40,6 @@ public function passes($attribute, $value) */ public function message() { - return trans('validation.string'); + return (string)trans('validation.string'); } } diff --git a/src/Validator/TimeRule.php b/src/Validator/TimeRule.php index 4be37ef52..f8988f11a 100644 --- a/src/Validator/TimeRule.php +++ b/src/Validator/TimeRule.php @@ -59,6 +59,6 @@ public function passes($attribute, $value) */ public function message() { - return trans('validation.regex'); + return (string)trans('validation.regex'); } } diff --git a/src/Validator/YesNoRule.php b/src/Validator/YesNoRule.php index 338349ef7..47ca823df 100644 --- a/src/Validator/YesNoRule.php +++ b/src/Validator/YesNoRule.php @@ -41,7 +41,7 @@ public function passes($attribute, $value) */ public function message() { - return trans('validation.in', [ + return (string)trans('validation.in', [ 'values' => '0,1,YES,NO,yes,no,true,false' ]); } diff --git a/tests/Browser/BCustomTableTest.php b/tests/Browser/BCustomTableTest.php index 25a62b3d6..968bcff6a 100644 --- a/tests/Browser/BCustomTableTest.php +++ b/tests/Browser/BCustomTableTest.php @@ -83,7 +83,7 @@ public function testCreateCustomTableSuccess() ->type('test description', 'description') ->type('#ff0000', 'options[color]') ->type('fa-automobile', 'options[icon]') - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line ->type(50, 'options[revision_count]') ->press('admin-submit') ->seePageIs(admin_url('column/test')) diff --git a/tests/Browser/CCustomCopyTest.php b/tests/Browser/CCustomCopyTest.php index 5e40e1487..48241f1bd 100644 --- a/tests/Browser/CCustomCopyTest.php +++ b/tests/Browser/CCustomCopyTest.php @@ -112,6 +112,7 @@ public function testUpdateCopySetting() $custom_copy = CustomCopy::find($id); + // @phpstan-ignore-next-line foreach ($custom_copy->custom_copy_columns as $custom_copy_column) { $row_id = $custom_copy_column->id; $this->seeIsSelected( @@ -124,6 +125,7 @@ public function testUpdateCopySetting() ); } + // @phpstan-ignore-next-line foreach ($custom_copy->custom_copy_input_columns as $custom_copy_column) { $row_id = $custom_copy_column->id; $this->seeIsSelected( diff --git a/tests/Browser/CCustomOperationTest.php b/tests/Browser/CCustomOperationTest.php index a8eadafab..7a6317282 100644 --- a/tests/Browser/CCustomOperationTest.php +++ b/tests/Browser/CCustomOperationTest.php @@ -227,7 +227,7 @@ public function testOperationMultiWithFilter() "custom_operation_conditions[$row_id][condition_target]", $custom_operation_condition->target_column_id ); - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line $this->seeOuterElement("input.condition_value.rowno-$row_id", 30000); $this->exactSelectOptions("select[name='custom_operation_conditions[$row_id][condition_key]']", $this->getFilterSelectOptions(FilterType::NUMBER)); } @@ -280,7 +280,7 @@ public function testOperationMultiWithFilter() 'suuid' => array_get($operation, 'suuid'), 'id' => implode(',', $err_ids) ]); - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line $this->assertFalse($this->response->getData()->result); $this->login(TestDefine::TESTDATA_USER_LOGINID_USER1); @@ -290,7 +290,7 @@ public function testOperationMultiWithFilter() 'suuid' => array_get($operation, 'suuid'), 'id' => implode(',', $ids) ]); - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line $this->assertFalse($this->response->getData()->result); } @@ -374,7 +374,7 @@ public function testOperationCreate() $this->visit(admin_url("data/$target_table_name/" . $custom_value->id . '/edit')) ->type('operation create test update', 'value[text]') ->type('even', 'value[odd_even]') - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line ->type(123.45, 'value[decimal]') ->press('admin-submit') ->seePageIs(admin_url("/data/$target_table_name")); diff --git a/tests/Browser/CCustomViewTest.php b/tests/Browser/CCustomViewTest.php index fe4f8afe3..e5ae3e02c 100644 --- a/tests/Browser/CCustomViewTest.php +++ b/tests/Browser/CCustomViewTest.php @@ -284,6 +284,7 @@ public function testAddViewSuccessContainsField() // if has query callback, execute, and filtering if (array_has($value, 'callback')) { + // @phpstan-ignore-next-line $callback = $value['callback']; $callback($query, $v); } @@ -296,6 +297,7 @@ public function testAddViewSuccessContainsField() /** * check custom view grid filters initialized default. */ + // @phpstan-ignore-next-line public function testCheckDefaultGridFilter() { $custom_table = CustomTable::getEloquent('exmenttest_view'); @@ -307,7 +309,9 @@ public function testCheckDefaultGridFilter() $response = $this->get(admin_url("data/exmenttest_view?filter_ajax=1")); $content = $response->response->getContent(); if (is_json($content)) { + // @phpstan-ignore-next-line $json = json_decode_ex($content, true); + // @phpstan-ignore-next-line $html = array_get($json, 'html'); $pattern = '/]*>\s*ID\s*<\/label>/i'; @@ -345,6 +349,7 @@ public function testCheckDefaultGridFilter() /** * Add custom view grid filters. */ + // @phpstan-ignore-next-line public function testAddViewSuccessGridFilter() { $custom_table = CustomTable::getEloquent('exmenttest_view'); @@ -378,7 +383,9 @@ public function testAddViewSuccessGridFilter() $response = $this->get(admin_url("data/exmenttest_view?filter_ajax=1")); $content = $response->response->getContent(); if (is_json($content)) { + // @phpstan-ignore-next-line $json = json_decode_ex($content, true); + // @phpstan-ignore-next-line $html = array_get($json, 'html'); $pattern = '/]*>\s*ID\s*<\/label>/i'; @@ -395,6 +402,7 @@ public function testAddViewSuccessGridFilter() /** * Update custom view grid filters. */ + // @phpstan-ignore-next-line public function testUpdateViewSuccessGridFilter() { $custom_table = CustomTable::getEloquent('exmenttest_view'); @@ -431,7 +439,9 @@ public function testUpdateViewSuccessGridFilter() $response = $this->get(admin_url("data/exmenttest_view?filter_ajax=1")); $content = $response->response->getContent(); if (is_json($content)) { + // @phpstan-ignore-next-line $json = json_decode_ex($content, true); + // @phpstan-ignore-next-line $html = array_get($json, 'html'); $pattern = '/]*>\s*更新ユーザー\s*<\/label>/i'; diff --git a/tests/Browser/CPublicFormTest.php b/tests/Browser/CPublicFormTest.php index 459ac2266..8511cd2bb 100644 --- a/tests/Browser/CPublicFormTest.php +++ b/tests/Browser/CPublicFormTest.php @@ -343,6 +343,7 @@ public function testAddPublicFormSuccess() $table_name = \getDBTableName($table); $row = \DB::table($table_name)->whereNull('deleted_at')->orderBy('id', 'desc')->first(); + // @phpstan-ignore-next-line $this->visit(admin_url('data/custom_value_edit_all/'. $row->id . '/edit')) ->seeInField('value[text]', 'unit test text') ->seeIsSelected('value[user]', '3') @@ -580,6 +581,7 @@ public function testUpdatePublicFormSuccess() $table_name = \getDBTableName($table); $row = \DB::table($table_name)->whereNull('deleted_at')->orderBy('id', 'desc')->first(); + // @phpstan-ignore-next-line $this->visit(admin_url('data/custom_value_edit_all/'. $row->id . '/edit')) ->seeInField('value[text]', 'unit test text') ; diff --git a/tests/Browser/DCustomDataTest.php b/tests/Browser/DCustomDataTest.php index f0330014e..dc46a702c 100644 --- a/tests/Browser/DCustomDataTest.php +++ b/tests/Browser/DCustomDataTest.php @@ -124,28 +124,28 @@ public function testAddRecordSuccess() $filePath = $this->getTextFilePath(); //$imagePath = $this->getTextImagePath(); $this->visit(admin_url('data/exmenttest_data/create')) - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line ->type(99, 'value[integer]') ->type('EXMENT Test Data 1', 'value[onelinetext]') ->type('2019-02-27 10:45:03', 'value[dateandtime]') - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line ->select(['Option 1'], 'value[selectfromstaticvalue][]') - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line ->select(['1'], 'value[selectsavevalueandlabel][]') ->type('EXMENT Test' . "\n" . 'Data Multiline Text', 'value[multiplelinetext]') - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line ->type(99.99, 'value[decimal]') ->type('https://google.com', 'value[url]') ->type('admin@admin.com', 'value[email]') ->type('2019-02-26', 'value[date]') ->type('13:40:21', 'value[time]') - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line ->select(['1'], 'value[selectfromtable][]') //->attach($imagePath, 'value[image]') ->attach($filePath, 'value[file]') - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line ->select(['1'], 'value[user][]') - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line ->select(['1'], 'value[organization][]') ->press('admin-submit') ->seePageIs('/admin/data/exmenttest_data') @@ -154,15 +154,16 @@ public function testAddRecordSuccess() // Get new data row $row = \DB::table($table_name)->whereNull('deleted_at')->orderBy('id', 'desc')->first(); // Check custom data + // @phpstan-ignore-next-line $this->visit(admin_url('data/exmenttest_data/'. $row->id . '/edit')) - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line ->seeInField('value[integer]', 99) ->seeInField('value[onelinetext]', 'EXMENT Test Data 1') ->seeInField('value[dateandtime]', '2019-02-27 10:45:03') ->seeIsSelected('value[selectfromstaticvalue][]', 'Option 1') ->seeIsSelected('value[selectsavevalueandlabel][]', '1') ->seeInField('value[multiplelinetext]', 'EXMENT Test Data Multiline Text') - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line ->seeInField('value[decimal]', 99.99) ->seeInField('value[url]', 'https://google.com') ->seeInField('value[email]', 'admin@admin.com') @@ -193,14 +194,16 @@ public function testEditRecord1() 'value[select2value]' => 'value1', 'value[yesno]' => 1, ]; + // @phpstan-ignore-next-line $this->visit(admin_url('data/exmenttest_data/'. $row->id . '/edit')) ->submitForm('admin-submit', $data) ->seePageIs('/admin/data/exmenttest_data') ; // Check custom data + // @phpstan-ignore-next-line $this->visit(admin_url('data/exmenttest_data/'. $row->id . '/edit')) ->seeInField('value[select2value]', 'value1') - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line ->seeInField('value[yesno]', 1) ; } @@ -218,37 +221,39 @@ public function testEditRecord2() $row = \DB::table($table_name)->whereNull('deleted_at')->orderBy('id', 'desc')->first(); // Update custom data + // @phpstan-ignore-next-line $this->visit(admin_url('data/exmenttest_data/'. $row->id . '/edit')) - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line ->type(100, 'value[integer]') ->type('EXMENT Test Data 1 Edited', 'value[onelinetext]') ->type('EXMENT Test Data Multiline Text', 'value[multiplelinetext]') ->type('2018-09-26 19:25:38', 'value[dateandtime]') - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line ->type(10.11, 'value[decimal]') ->type('2018-09-27', 'value[date]') ->type('09:18:54', 'value[time]') ->type('edit@admin.com', 'value[email]') ->type('https://exment.net', 'value[url]') - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line ->select(['Option 2'], 'value[selectfromstaticvalue][]') - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line ->select(['2'], 'value[selectsavevalueandlabel][]') - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line ->select(['2'], 'value[user][]') - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line ->select(['2'], 'value[organization][]') - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line ->select(['2'], 'value[selectfromtable][]') ->press('admin-submit') ->seePageIs('/admin/data/exmenttest_data') ; // Check custom data + // @phpstan-ignore-next-line $this->visit(admin_url('data/exmenttest_data/'. $row->id . '/edit')) - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line ->seeInField('value[integer]', 100) - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line ->seeInField('value[decimal]', 10.11) ->seeInField('value[onelinetext]', 'EXMENT Test Data 1 Edited') ->seeInField('value[multiplelinetext]', 'EXMENT Test Data Multiline Text') @@ -338,6 +343,7 @@ public function testDisplayGridSort() $colname1 = CustomColumn::getEloquent('index_text', 'custom_value_view_all')->getIndexColumnName(); $sort_str = "_sort%5Bcolumn%5D={$table_name}.{$colname1}&_sort%5Btype%5D=-1&_sort%5Bdirect%5D=1"; $row = \DB::table($table_name)->whereNull('deleted_at')->orderBy('value->index_text', 'desc')->first(); + // @phpstan-ignore-next-line $row = json_decode($row->value); // Check custom view data diff --git a/tests/Browser/EBackupDataTest.php b/tests/Browser/EBackupDataTest.php index 217aa14d3..790f3bceb 100644 --- a/tests/Browser/EBackupDataTest.php +++ b/tests/Browser/EBackupDataTest.php @@ -37,7 +37,7 @@ public function testInitializeBackupConfig() try { !\ExmentDB::checkBackup(); - /** @phpstan-ignore-next-line Dead catch - Exceedone\Exment\Exceptions\BackupRestoreCheckException is never thrown in the try block. */ + // @phpstan-ignore-next-line } catch (BackupRestoreCheckException $ex) { $this->assertTrue(true); return; @@ -64,7 +64,7 @@ public function testDisplayBackupData() { try { !\ExmentDB::checkBackup(); - /** @phpstan-ignore-next-line Dead catch - Exceedone\Exment\Exceptions\BackupRestoreCheckException is never thrown in the try block. */ + // @phpstan-ignore-next-line } catch (BackupRestoreCheckException $ex) { $this->assertTrue(true); return; @@ -125,7 +125,7 @@ public function testBackupConfigSave() { try { !\ExmentDB::checkBackup(); - /** @phpstan-ignore-next-line Dead catch - Exceedone\Exment\Exceptions\BackupRestoreCheckException is never thrown in the try block. */ + // @phpstan-ignore-next-line } catch (BackupRestoreCheckException $ex) { $this->assertTrue(true); return; @@ -184,7 +184,7 @@ public function testBackupNoTarget() { try { !\ExmentDB::checkBackup(); - /** @phpstan-ignore-next-line Dead catch - Exceedone\Exment\Exceptions\BackupRestoreCheckException is never thrown in the try block. */ + // @phpstan-ignore-next-line } catch (BackupRestoreCheckException $ex) { $this->assertTrue(true); return; @@ -202,7 +202,7 @@ public function testBackupNoTarget() // check config no change $this->visit(admin_url('backup')) ->seePageIs(admin_url('backup')) - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line ->seeInField('backup_enable_automatic', $backup_enable_automatic ? 1 : 0); // loop target @@ -220,7 +220,7 @@ protected function backupData() { try { !\ExmentDB::checkBackup(); - /** @phpstan-ignore-next-line Dead catch - Exceedone\Exment\Exceptions\BackupRestoreCheckException is never thrown in the try block. */ + // @phpstan-ignore-next-line } catch (BackupRestoreCheckException $ex) { $this->assertTrue(true); return; @@ -249,7 +249,7 @@ protected function restoreData() { try { !\ExmentDB::checkBackup(); - /** @phpstan-ignore-next-line Dead catch - Exceedone\Exment\Exceptions\BackupRestoreCheckException is never thrown in the try block. */ + // @phpstan-ignore-next-line } catch (BackupRestoreCheckException $ex) { $this->assertTrue(true); return; diff --git a/tests/Browser/ExmentKitTestCase.php b/tests/Browser/ExmentKitTestCase.php index 1746e2c45..64d015b81 100644 --- a/tests/Browser/ExmentKitTestCase.php +++ b/tests/Browser/ExmentKitTestCase.php @@ -82,6 +82,7 @@ protected function login($id = null) ); } + // @phpstan-ignore-next-line $this->be($user); } diff --git a/tests/Browser/FNotifyTest.php b/tests/Browser/FNotifyTest.php index 9305aa640..5e8b0dc40 100644 --- a/tests/Browser/FNotifyTest.php +++ b/tests/Browser/FNotifyTest.php @@ -123,9 +123,11 @@ public function testNotifyButtonPost() $content = $response->response->getContent(); if (is_json($content)) { + // @phpstan-ignore-next-line $json = json_decode_ex($content, true); ///// Cannot test checking whether submitting mail. + // @phpstan-ignore-next-line $this->assertTrue(array_get($json, 'result', false), 'Post submit error, message is : ' . json_encode($json['errors'])); } } @@ -173,11 +175,15 @@ protected function getDomDocument(string $url): \DOMDocument $content = $response->response->getContent(); if (is_json($content)) { + // @phpstan-ignore-next-line $json = json_decode_ex($content, true); + // @phpstan-ignore-next-line if (array_get($json, 'result') === false) { + // @phpstan-ignore-next-line throw new \Exception(json_encode($json['errors'])); } + // @phpstan-ignore-next-line $html = array_get($json, 'body'); } else { $html = $content; diff --git a/tests/Browser/HPluginPageTest.php b/tests/Browser/HPluginPageTest.php index 64cf71f7a..c33d9c006 100644 --- a/tests/Browser/HPluginPageTest.php +++ b/tests/Browser/HPluginPageTest.php @@ -96,7 +96,9 @@ public function testDisplayDashboard() $response = $this->get(admin_url('dashboardbox/html/' . $box->suuid)); $content = $response->response->getContent(); if (is_json($content)) { + // @phpstan-ignore-next-line $json = json_decode_ex($content, true); + // @phpstan-ignore-next-line $body = array_get($json, 'body'); $this->assertTrue(strpos($body, "

    $integer

    ") !== false); diff --git a/tests/ExmentTestCase.php b/tests/ExmentTestCase.php index 68dcd7bab..fe5451734 100644 --- a/tests/ExmentTestCase.php +++ b/tests/ExmentTestCase.php @@ -24,7 +24,7 @@ public function setUp(): void { parent::setUp(); - /** @phpstan-ignore-next-line $this->app is always Application */ + // @phpstan-ignore-next-line if (!$this->app) { $this->refreshApplication(); } diff --git a/tests/Feature/Api2Test.php b/tests/Feature/Api2Test.php index cfc4315d4..5795e8b58 100644 --- a/tests/Feature/Api2Test.php +++ b/tests/Feature/Api2Test.php @@ -208,7 +208,9 @@ public function testGetTablesUser() ])->get(admin_urls('api', 'table')) ->assertStatus(200); + // @phpstan-ignore-next-line $json = json_decode_ex($response->baseResponse->getContent(), true); + // @phpstan-ignore-next-line $data = array_get($json, 'data'); $this->assertTrue(!\is_nullorempty($data)); @@ -592,7 +594,9 @@ public function testGetValuesWithOrder() ])->get(admin_urls('api', 'data', 'custom_value_access_all').'?orderby=user%20desc,id%20asc') ->assertStatus(200); + // @phpstan-ignore-next-line $json = json_decode_ex($response->baseResponse->getContent(), true); + // @phpstan-ignore-next-line $data = array_get($json, 'data'); $value = array_get($data[0], 'value'); $this->assertMatch(array_get($value, 'user'), '9'); @@ -629,7 +633,9 @@ public function testGetValuesWithChildren() ->assertJsonCount(5, 'data'); // check children + // @phpstan-ignore-next-line $json = json_decode_ex($response->baseResponse->getContent(), true); + // @phpstan-ignore-next-line $data = array_get($json, 'data'); foreach ($data as $d) { @@ -654,7 +660,9 @@ public function testGetValuesWithChildren2() ->assertJsonCount(5, 'data'); // check children + // @phpstan-ignore-next-line $json = json_decode_ex($response->baseResponse->getContent(), true); + // @phpstan-ignore-next-line $data = array_get($json, 'data'); foreach ($data as $d) { @@ -679,7 +687,9 @@ public function testGetValuesWithParents() ->assertJsonCount(5, 'data'); // check children + // @phpstan-ignore-next-line $json = json_decode_ex($response->baseResponse->getContent(), true); + // @phpstan-ignore-next-line $data = array_get($json, 'data'); foreach ($data as $d) { @@ -704,7 +714,9 @@ public function testGetValuesWithParents2() ->assertJsonCount(5, 'data'); // check children + // @phpstan-ignore-next-line $json = json_decode_ex($response->baseResponse->getContent(), true); + // @phpstan-ignore-next-line $data = array_get($json, 'data'); foreach ($data as $d) { @@ -773,8 +785,10 @@ public function testGetValuesPermissionCheck() 'Authorization' => "Bearer $token", ])->get(admin_urls('api', 'data', 'custom_value_edit').'?count=1000') ->assertStatus(200); + // @phpstan-ignore-next-line $json = json_decode_ex($response->baseResponse->getContent(), true); // get ids + // @phpstan-ignore-next-line $ids = collect(array_get($json, 'data'))->map(function ($j) { return array_get($j, 'id'); })->toArray(); @@ -831,7 +845,9 @@ public function testGetValueWithChildren() ]); // check children + // @phpstan-ignore-next-line $d = json_decode_ex($response->baseResponse->getContent(), true); + // @phpstan-ignore-next-line $this->_testChildrenValues($d, TestDefine::TESTDATA_TABLE_NAME_PARENT_TABLE, array_get($d, 'id')); } @@ -854,7 +870,9 @@ public function testGetValueWithChildren2() ]); // check children + // @phpstan-ignore-next-line $d = json_decode_ex($response->baseResponse->getContent(), true); + // @phpstan-ignore-next-line $this->_testChildrenValues($d, TestDefine::TESTDATA_TABLE_NAME_PARENT_TABLE_MANY_TO_MANY, array_get($d, 'id')); } @@ -877,7 +895,9 @@ public function testGetValueWithParents() ]); // check children + // @phpstan-ignore-next-line $d = json_decode_ex($response->baseResponse->getContent(), true); + // @phpstan-ignore-next-line $this->_testParentsValues($d, TestDefine::TESTDATA_TABLE_NAME_CHILD_TABLE, array_get($d, 'id')); } @@ -900,7 +920,9 @@ public function testGetValueWithParents2() ]); // check children + // @phpstan-ignore-next-line $d = json_decode_ex($response->baseResponse->getContent(), true); + // @phpstan-ignore-next-line $this->_testParentsValues($d, TestDefine::TESTDATA_TABLE_NAME_CHILD_TABLE_MANY_TO_MANY, array_get($d, 'id')); } @@ -969,8 +991,11 @@ public function testGetViewData() ])->get(admin_urls('api', 'viewdata', TestDefine::TESTDATA_TABLE_NAME_VIEW_ALL, $custom_view->suuid)) ->assertStatus(200); + // @phpstan-ignore-next-line $json = json_decode_ex($response->baseResponse->getContent(), true); + // @phpstan-ignore-next-line $data = array_get($json, 'data'); + // @phpstan-ignore-next-line $column_definitions = array_get($json, 'column_definitions'); $user_key = collect($column_definitions)->filter(function ($val) { return array_get($val, 'column_name') == 'user'; @@ -1024,8 +1049,11 @@ public function testGetViewDataWithValueType() ])->get(admin_urls('api', 'viewdata', TestDefine::TESTDATA_TABLE_NAME_VIEW_ALL, $custom_view->suuid).'?valuetype=text') ->assertStatus(200); + // @phpstan-ignore-next-line $json = json_decode_ex($response->baseResponse->getContent(), true); + // @phpstan-ignore-next-line $data = array_get($json, 'data'); + // @phpstan-ignore-next-line $column_definitions = array_get($json, 'column_definitions'); $user_key = collect($column_definitions)->filter(function ($val) { return array_get($val, 'column_name') == 'user'; @@ -1051,8 +1079,11 @@ public function testGetViewDataWithSort() $check_data = $custom_view->getQueryData(); + // @phpstan-ignore-next-line $json = json_decode_ex($response->baseResponse->getContent(), true); + // @phpstan-ignore-next-line $data = array_get($json, 'data'); + // @phpstan-ignore-next-line $column_definitions = array_get($json, 'column_definitions'); $id_key = collect($column_definitions)->filter(function ($val) { return array_get($val, 'column_name') == 'id'; @@ -1076,8 +1107,11 @@ public function testGetViewDataById() ])->get(admin_urls('api', 'viewdata', TestDefine::TESTDATA_TABLE_NAME_VIEW_ALL, $custom_view->suuid, 3)) ->assertStatus(200); + // @phpstan-ignore-next-line $json = json_decode_ex($response->baseResponse->getContent(), true); + // @phpstan-ignore-next-line $data = array_get($json, 'value'); + // @phpstan-ignore-next-line $column_definitions = array_get($json, 'column_definitions'); $id_key = collect($column_definitions)->filter(function ($val) { return array_get($val, 'column_name') == 'id'; @@ -1775,7 +1809,7 @@ protected function _testDeleteValue(bool $appendForceQuery, bool $isGetTrashed, for ($i = 0; $i < 100; $i++) { $query = CustomTable::getEloquent('custom_value_edit')->getValueModel()->query(); if ($isAlreadyTrashed) { - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line $query->onlyTrashed(); } $data = $query->find($id + $i); @@ -1797,7 +1831,7 @@ protected function _testDeleteValue(bool $appendForceQuery, bool $isGetTrashed, $data = CustomTable::getEloquent('custom_value_edit')->getValueModel()->find($id); $this->assertTrue(!isset($data)); - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line $data = CustomTable::getEloquent('custom_value_edit')->getValueModel()->query()->onlyTrashed()->find($id); $this->assertTrue($isGetTrashed ? isset($data) : !isset($data)); } @@ -1931,8 +1965,10 @@ public function testDataQueryPermissionCheck() 'Authorization' => "Bearer $token", ])->get(admin_urls('api', 'data', 'custom_value_edit', 'query').'?q=index_001&count=100') ->assertStatus(200); + // @phpstan-ignore-next-line $json = json_decode_ex($response->baseResponse->getContent(), true); // get ids + // @phpstan-ignore-next-line $ids = collect(array_get($json, 'data'))->map(function ($j) { return array_get($j, 'id'); })->toArray(); @@ -2001,8 +2037,10 @@ public function testDataQueryColumnPermissionCheck() 'Authorization' => "Bearer $token", ])->get(admin_urls('api', 'data', 'custom_value_edit', 'query-column').'?q=odd_even%20eq%20odd&count=1000') ->assertStatus(200); + // @phpstan-ignore-next-line $json = json_decode_ex($response->baseResponse->getContent(), true); // get ids + // @phpstan-ignore-next-line $ids = collect(array_get($json, 'data'))->map(function ($j) { return array_get($j, 'id'); })->toArray(); @@ -2389,10 +2427,15 @@ public function testPostDocument() ]) ->assertStatus(201); + // @phpstan-ignore-next-line $json = json_decode_ex($response->baseResponse->getContent(), true); + // @phpstan-ignore-next-line $this->assertTrue(array_has($json, 'url')); + // @phpstan-ignore-next-line $this->assertTrue(array_has($json, 'created_at')); + // @phpstan-ignore-next-line $this->assertTrue(array_has($json, 'created_user_id')); + // @phpstan-ignore-next-line $this->assertMatch(array_get($json, 'name'), 'test1.txt'); } @@ -2411,7 +2454,9 @@ public function testGetDocument() ])->get(admin_urls('api', 'document', 'custom_value_edit', 1)) ->assertStatus(200); + // @phpstan-ignore-next-line $json = json_decode_ex($response->baseResponse->getContent(), true); + // @phpstan-ignore-next-line $data = collect(array_get($json, 'data'))->first(); $this->assertMatch(array_get($data, 'url'), $document->url); @@ -2456,9 +2501,12 @@ public function testDownloadFileJson() ])->get(admin_urls('api', 'files', $document->file_uuid . '?base64=1')) ->assertStatus(200); + // @phpstan-ignore-next-line $json = json_decode_ex($response->baseResponse->getContent(), true); + // @phpstan-ignore-next-line $this->assertMatch(array_get($json, 'name'), $document->label); + // @phpstan-ignore-next-line $this->assertMatch(array_get($json, 'base64'), base64_encode(TestDefine::FILE_TESTSTRING)); } @@ -2950,6 +2998,7 @@ protected function assertLogsFilterResult(array $filters, ?\Closure $ckeckCallba ])->get(admin_urls_query('api', 'log', $filters)) ->assertStatus(200); + // @phpstan-ignore-next-line $results = json_decode_ex($response->baseResponse->getContent(), true)['data']; foreach ($results as $result) { foreach ($filters as $key => $value) { @@ -2991,6 +3040,7 @@ protected function assertLogsFilterResult(array $filters, ?\Closure $ckeckCallba protected function assertFileUrl($token, $response) { $json = json_decode_ex($response->baseResponse->getContent(), true); + // @phpstan-ignore-next-line $id = array_get($json, 'id'); // get file url as uuid @@ -2998,7 +3048,9 @@ protected function assertFileUrl($token, $response) 'Authorization' => "Bearer $token", ])->get(admin_urls('api', 'data', 'custom_value_edit', $id . '?valuetype=text')) ->assertStatus(200); + // @phpstan-ignore-next-line $json = json_decode_ex($response->baseResponse->getContent(), true); + // @phpstan-ignore-next-line $url = array_get($json, 'value.file'); $this->assertTrue(isset($url)); @@ -3016,7 +3068,9 @@ protected function assertFileUrl($token, $response) 'Authorization' => "Bearer $token", ])->get(admin_urls('api', 'data', 'custom_value_edit', $id)) ->assertStatus(200); + // @phpstan-ignore-next-line $json = json_decode_ex($response->baseResponse->getContent(), true); + // @phpstan-ignore-next-line $path = array_get($json, 'value.file'); $this->assertTrue(isset($path)); @@ -3039,6 +3093,7 @@ protected function assertFileUrl($token, $response) protected function assertFilesUrl($token, $response, $matchValues) { $json = json_decode_ex($response->baseResponse->getContent(), true); + // @phpstan-ignore-next-line $id = array_get($json, 'id'); // get file url as uuid @@ -3046,7 +3101,9 @@ protected function assertFilesUrl($token, $response, $matchValues) 'Authorization' => "Bearer $token", ])->get(admin_urls('api', 'data', TestDefine::TESTDATA_TABLE_NAME_ALL_COLUMNS_FORTEST, $id . '?valuetype=text')) ->assertStatus(200); + // @phpstan-ignore-next-line $json = json_decode_ex($response->baseResponse->getContent(), true); + // @phpstan-ignore-next-line $urls = array_get($json, 'value.file_multiple'); $this->assertTrue(isset($urls)); $this->assertMatch(count(stringToArray($urls)), count($matchValues)); @@ -3067,7 +3124,9 @@ protected function assertFilesUrl($token, $response, $matchValues) 'Authorization' => "Bearer $token", ])->get(admin_urls('api', 'data', TestDefine::TESTDATA_TABLE_NAME_ALL_COLUMNS_FORTEST, $id)) ->assertStatus(200); + // @phpstan-ignore-next-line $json = json_decode_ex($response->baseResponse->getContent(), true); + // @phpstan-ignore-next-line $paths = array_get($json, 'value.file_multiple'); $this->assertTrue(isset($paths)); $this->assertMatch(count($paths), count($matchValues)); diff --git a/tests/Feature/Api3WorkflowTest.php b/tests/Feature/Api3WorkflowTest.php index 51f619e81..f5b19b3ad 100644 --- a/tests/Feature/Api3WorkflowTest.php +++ b/tests/Feature/Api3WorkflowTest.php @@ -882,7 +882,9 @@ public function testExecuteWorkflowWithNext() 'created_user_id' => "6" //dev0-userB ]); + // @phpstan-ignore-next-line $json = json_decode_ex($response->baseResponse->getContent(), true); + // @phpstan-ignore-next-line $id = array_get($json, 'id'); $authorities = WorkflowValueAuthority::where('workflow_value_id', $id)->get(); @@ -1185,7 +1187,9 @@ public function testExecuteWorkflow2WithNext() 'created_user_id' => "7" //dev1-userC ]); + // @phpstan-ignore-next-line $json = json_decode_ex($response->baseResponse->getContent(), true); + // @phpstan-ignore-next-line $id = array_get($json, 'id'); // get workflow value diff --git a/tests/Feature/ApiFilterConditionTest.php b/tests/Feature/ApiFilterConditionTest.php index 801ecf1df..a274e4189 100644 --- a/tests/Feature/ApiFilterConditionTest.php +++ b/tests/Feature/ApiFilterConditionTest.php @@ -415,6 +415,7 @@ protected function checkTestResult(string $url, string $filterType) $response = $this->response->getContent(); $this->assertTrue(is_json($response), "response is not json. response is $response"); + // @phpstan-ignore-next-line $json = collect(json_decode_ex($response, true))->pluck('text', 'id')->toArray(); $expectOptions = array_get(FilterOption::FILTER_OPTIONS(), $filterType, []); diff --git a/tests/Feature/ApiFilterValueTest.php b/tests/Feature/ApiFilterValueTest.php index 3a8ec1483..3a208345c 100644 --- a/tests/Feature/ApiFilterValueTest.php +++ b/tests/Feature/ApiFilterValueTest.php @@ -2319,7 +2319,9 @@ protected function checkTestResult(string $url, bool $hasHtml, $selector, bool $ $response = $this->response->getContent(); $this->assertTrue(is_json($response), "response is not json. response is $response"); + // @phpstan-ignore-next-line $json = json_decode_ex($response, true); + // @phpstan-ignore-next-line $html = array_get($json, 'html'); // check element result diff --git a/tests/Feature/ApiTestBase.php b/tests/Feature/ApiTestBase.php index 65438d5fd..870fba5ca 100644 --- a/tests/Feature/ApiTestBase.php +++ b/tests/Feature/ApiTestBase.php @@ -99,6 +99,7 @@ protected function getAdminAccessToken($scope = []) { $response = $this->getPasswordToken('admin', 'adminadmin', $scope); + // @phpstan-ignore-next-line return array_get(json_decode_ex($response->baseResponse->getContent(), true), 'access_token'); } @@ -111,6 +112,7 @@ protected function getAdminAccessTokenAsApiKey($scope = []) { $response = $this->getApiKey($scope); + // @phpstan-ignore-next-line return array_get(json_decode_ex($response->baseResponse->getContent(), true), 'access_token'); } @@ -123,6 +125,7 @@ protected function getUser1AccessToken($scope = []) { $response = $this->getPasswordToken('user1', 'user1user1', $scope); + // @phpstan-ignore-next-line return array_get(json_decode_ex($response->baseResponse->getContent(), true), 'access_token'); } @@ -135,6 +138,7 @@ protected function getUser2AccessToken($scope = []) { $response = $this->getPasswordToken('user2', 'user2user2', $scope); + // @phpstan-ignore-next-line return array_get(json_decode_ex($response->baseResponse->getContent(), true), 'access_token'); } @@ -147,6 +151,7 @@ protected function getDevUserBAccessToken($scope = []) { $response = $this->getPasswordToken('dev0-userB', 'dev0-userB', $scope); + // @phpstan-ignore-next-line return array_get(json_decode_ex($response->baseResponse->getContent(), true), 'access_token'); } @@ -159,6 +164,7 @@ protected function getDev1UserCAccessToken($scope = []) { $response = $this->getPasswordToken('dev1-userC', 'dev1-userC', $scope); + // @phpstan-ignore-next-line return array_get(json_decode_ex($response->baseResponse->getContent(), true), 'access_token'); } @@ -173,6 +179,7 @@ protected function getUserAccessToken($userid, $password, $scope = []) { $response = $this->getPasswordToken($userid, $password, $scope); + // @phpstan-ignore-next-line return array_get(json_decode_ex($response->baseResponse->getContent(), true), 'access_token'); } diff --git a/tests/Feature/ApiUserTest.php b/tests/Feature/ApiUserTest.php index 500fa978b..b4076a0ff 100644 --- a/tests/Feature/ApiUserTest.php +++ b/tests/Feature/ApiUserTest.php @@ -231,7 +231,7 @@ public function testGetAvatarNotHas() // Response is not file. $this->assertTrue($response->baseResponse instanceof \Illuminate\Http\Response); - /** @phpstan-ignore-next-line next line always false */ + // @phpstan-ignore-next-line $this->assertFalse($response->baseResponse instanceof \Symfony\Component\HttpFoundation\BinaryFileResponse); } } diff --git a/tests/Feature/FileImportTestBase.php b/tests/Feature/FileImportTestBase.php index d03a7e360..aa9d92791 100644 --- a/tests/Feature/FileImportTestBase.php +++ b/tests/Feature/FileImportTestBase.php @@ -55,6 +55,7 @@ protected function init() $sourceDir = $this->getSourceFilePath(); $dirs = scandir($sourceDir); + // @phpstan-ignore-next-line foreach ($dirs as $dir) { if ($dir == '.' ||$dir == '..') { continue; diff --git a/tests/Feature/ImportExportTest.php b/tests/Feature/ImportExportTest.php index fa7220654..ae8f74c2e 100644 --- a/tests/Feature/ImportExportTest.php +++ b/tests/Feature/ImportExportTest.php @@ -402,6 +402,7 @@ protected function _compareViewData($custom_view, array $file_array, Collection foreach ($db_array as $index => $db_data) { $db_text = $custom_view_column->column_item->setCustomValue($db_data) ->options(['disable_currency_symbol' => true])->text(); + // @phpstan-ignore-next-line $file_text = $file_array[$index + 2][$colno]; $this->assertEquals($db_text, $file_text); } diff --git a/tests/Feature/ImportTrait.php b/tests/Feature/ImportTrait.php index 9fee33c3d..3eb74dc9f 100644 --- a/tests/Feature/ImportTrait.php +++ b/tests/Feature/ImportTrait.php @@ -28,6 +28,7 @@ protected function _getCsvArray($file) $array = $spreadsheet->getActiveSheet()->toArray(); // revert to original locale + // @phpstan-ignore-next-line setlocale(LC_CTYPE, $original_locale); return $array; diff --git a/tests/Feature/PluginTest.php b/tests/Feature/PluginTest.php index a69359600..d3dfac2ee 100644 --- a/tests/Feature/PluginTest.php +++ b/tests/Feature/PluginTest.php @@ -97,6 +97,7 @@ public function testEventWorkflow() // get action $action = $custom_value->getWorkflowActions()->first(); $action_user = $action->getAuthorityTargets($custom_value, WorkflowGetAuthorityType::CURRENT_WORK_USER)->first(); + // @phpstan-ignore-next-line $this->be(LoginUser::find($action_user->id)); $action->executeAction($custom_value, [ diff --git a/tests/TestTrait.php b/tests/TestTrait.php index 5b8c55dd9..5e3b53d8d 100644 --- a/tests/TestTrait.php +++ b/tests/TestTrait.php @@ -172,6 +172,7 @@ protected function initAllTest() protected function checkCustomValuePermission(CustomTable $custom_table, $ids, ?\Closure $filterCallback = null) { // get all ids + /** @phpstan-ignore-next-line */ $allIds = \DB::table(getDBTableName($custom_table))->select('id')->pluck('id'); $query = $custom_table->getValueModel()->withoutGlobalScopes(); @@ -197,6 +198,7 @@ protected function checkCustomValuePermission(CustomTable $custom_table, $ids, ? protected function getTextDirPath(): string { $dir = storage_path('app/tests'); + /** @phpstan-ignore-next-line */ \Exment::makeDirectory($dir); return $dir; @@ -212,7 +214,9 @@ protected function getTextFilePath($fileName = 'file.txt'): string // create file $file = path_join($dir, $fileName); + /** @phpstan-ignore-next-line */ if (!\File::exists($file)) { + /** @phpstan-ignore-next-line */ \File::put($file, TestDefine::FILE_BASE64); } return $file; @@ -227,9 +231,11 @@ protected function getTextImagePath($imageName = 'image.png') $dir = $this->getTextDirPath(); // create file $file = path_join($dir, $imageName); + /** @phpstan-ignore-next-line */ if (!\File::exists($file)) { // convert to base64. This string is 1*1 rad color's image $f = base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAANSURBVBhXY3gro/IfAAVUAi3GPZKdAAAAAElFTkSuQmCC'); + /** @phpstan-ignore-next-line */ \File::put($file, $f); } return $file; @@ -242,6 +248,7 @@ protected function getTextImagePath($imageName = 'image.png') protected function getTextFileObject($fileName = 'file.txt') { $file = $this->getTextFilePath($fileName); + /** @phpstan-ignore-next-line */ return \File::get($file); } @@ -252,6 +259,7 @@ protected function getTextFileObject($fileName = 'file.txt') protected function getTextImageObject($imageName = 'image.png') { $file = $this->getTextImagePath($imageName); + /** @phpstan-ignore-next-line */ return \File::get($file); } @@ -265,6 +273,7 @@ protected function getTextImageObject($imageName = 'image.png') */ protected function callProtectedMethod($obj, $methodName, ...$args) { + // @phpstan-ignore-next-line $method = new \ReflectionMethod(get_class($obj), $methodName); $method->setAccessible(true); return $method->invoke($obj, ...$args); diff --git a/tests/Unit/ConditionTest.php b/tests/Unit/ConditionTest.php index ce8087b68..9bf2b1b4f 100644 --- a/tests/Unit/ConditionTest.php +++ b/tests/Unit/ConditionTest.php @@ -209,7 +209,7 @@ public function testColumnIntegerNullTrue() */ public function testColumnIntegerNullFalse() { - /** @phpstan-ignore-next-line str expects string|null, int given */ + // @phpstan-ignore-next-line $this->_testColumnIntegerNullCheck(2, str(FilterOption::NULL), false); $this->_testColumnIntegerNullCheck('2', FilterOption::NULL, false); $this->_testColumnIntegerNullCheck('0', FilterOption::NULL, false); diff --git a/tests/Unit/CustomColumnValidationTest.php b/tests/Unit/CustomColumnValidationTest.php index 07a5aa928..074bc3bcb 100644 --- a/tests/Unit/CustomColumnValidationTest.php +++ b/tests/Unit/CustomColumnValidationTest.php @@ -1354,12 +1354,12 @@ protected function executeTest($custom_value, array $values, array $errors = [], } } catch (ValidationException $ex) { if ($isSuccess) { - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line $this->assertTrue(false, 'This test excepts success, but falls validation. Messages : ' . json_encode($ex->validator->getMessages())); } //TODO: Check error messages - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line $messages = $ex->validator->getMessages(); $this->assertJsonExment($errors, $messages); } diff --git a/tests/Unit/CustomCopyTest.php b/tests/Unit/CustomCopyTest.php index bfcb2af80..9254695e6 100644 --- a/tests/Unit/CustomCopyTest.php +++ b/tests/Unit/CustomCopyTest.php @@ -204,6 +204,7 @@ protected function _prepareCustomCopy(array $options = []) $input_columns = $options['input_columns']; // Login user. + // @phpstan-ignore-next-line $this->be(LoginUser::find($login_user_id)); $custom_table = CustomTable::getEloquent($from_table_name); diff --git a/tests/Unit/CustomOperationTest.php b/tests/Unit/CustomOperationTest.php index 6fbf0b150..4a5b8eaeb 100644 --- a/tests/Unit/CustomOperationTest.php +++ b/tests/Unit/CustomOperationTest.php @@ -158,7 +158,7 @@ public function testUpdateSelectFilterError() $result = $operation->execute($custom_table, $custom_value->id); $this->assertFalse($result === true); - /** @phpstan-ignore-next-line Call to function is_string() with false will always evaluate to false. */ + // @phpstan-ignore-next-line $this->assertTrue(is_string($result)); } @@ -200,7 +200,7 @@ public function testUpdateSelectFilterNotError() $result = $operation->execute($custom_table, $custom_value->id); $this->assertFalse($result === true); - /** @phpstan-ignore-next-line Call to function is_string() with false will always evaluate to false. */ + // @phpstan-ignore-next-line $this->assertTrue(is_string($result)); } @@ -417,6 +417,7 @@ protected function _prepareCustomOperation(array $settings = []) $conditions = $settings['conditions']; // Login user. + // @phpstan-ignore-next-line $this->be(LoginUser::find($login_user_id)); $custom_table = CustomTable::getEloquent($custom_table_name); diff --git a/tests/Unit/CustomViewFilterTest.php b/tests/Unit/CustomViewFilterTest.php index 620c8248d..1bf3650fe 100644 --- a/tests/Unit/CustomViewFilterTest.php +++ b/tests/Unit/CustomViewFilterTest.php @@ -715,6 +715,7 @@ public function testFuncFilterDateTimeOnOrAfter() $date = \Carbon\Carbon::parse($date); $date = \Carbon\Carbon::create($date->year, $date->month, $date->day); + // @phpstan-ignore-next-line $diff = \Carbon\Carbon::today()->diffInDays($date, false); return $diff >= 0; }); diff --git a/tests/Unit/CustomViewGridFilterTest.php b/tests/Unit/CustomViewGridFilterTest.php index aa35d2dcb..15c28d642 100644 --- a/tests/Unit/CustomViewGridFilterTest.php +++ b/tests/Unit/CustomViewGridFilterTest.php @@ -27,11 +27,13 @@ class CustomViewGridFilterTest extends UnitTestBase use CustomViewTrait; use DatabaseTransactions; + // @phpstan-ignore-next-line protected $table_name = TestDefine::TESTDATA_TABLE_NAME_ALL_COLUMNS_FORTEST; /** * Grid Filter = ID */ + // @phpstan-ignore-next-line public function testFuncFilterId() { $this->init(); @@ -45,6 +47,7 @@ public function testFuncFilterId() /** * Grid Filter = created_at */ + // @phpstan-ignore-next-line public function testFuncFilterCreatedAt() { $this->init(); @@ -63,6 +66,7 @@ public function testFuncFilterCreatedAt() /** * Grid Filter = updated_at */ + // @phpstan-ignore-next-line public function testFuncFilterUpdatedAt() { $this->init(); @@ -73,6 +77,7 @@ public function testFuncFilterUpdatedAt() $this->__testGridFilter(['updated_at.start' => '2025-02-01', 'updated_at.end' => '2025-02-02'], function ($data) { $actual = array_get($data, 'updated_at'); + // @phpstan-ignore-next-line return $actual->between(Carbon::create(2025, 2, 1), Carbon::create(2025, 2, 2)->endOfDay()); }, 2); } @@ -80,6 +85,7 @@ public function testFuncFilterUpdatedAt() /** * Grid Filter = created_user_id */ + // @phpstan-ignore-next-line public function testFuncFilterCreatedUser() { $this->init(); @@ -93,6 +99,7 @@ public function testFuncFilterCreatedUser() /** * Grid Filter = updated_user_id */ + // @phpstan-ignore-next-line public function testFuncFilterUpdatedUser() { $this->init(); @@ -106,6 +113,7 @@ public function testFuncFilterUpdatedUser() /** * Grid Filter = text */ + // @phpstan-ignore-next-line public function testFuncFilterText() { $this->init(); @@ -127,6 +135,7 @@ public function testFuncFilterText() /** * Grid Filter = url */ + // @phpstan-ignore-next-line public function testFuncFilterUrl() { $this->init(); @@ -148,6 +157,7 @@ public function testFuncFilterUrl() /** * Grid Filter = email */ + // @phpstan-ignore-next-line public function testFuncFilterEmail() { $this->init(); @@ -169,6 +179,7 @@ public function testFuncFilterEmail() /** * Grid Filter = integer */ + // @phpstan-ignore-next-line public function testFuncFilterInteger() { $this->init(); @@ -185,6 +196,7 @@ public function testFuncFilterInteger() /** * Grid Filter = decimal */ + // @phpstan-ignore-next-line public function testFuncFilterDecimal() { $this->init(); @@ -201,6 +213,7 @@ public function testFuncFilterDecimal() /** * Grid Filter = currency */ + // @phpstan-ignore-next-line public function testFuncFilterCurrency() { $this->init(); @@ -217,6 +230,7 @@ public function testFuncFilterCurrency() /** * Grid Filter = date */ + // @phpstan-ignore-next-line public function testFuncFilterDate() { $this->init(); @@ -240,6 +254,7 @@ public function testFuncFilterDate() /** * Grid Filter = time */ + // @phpstan-ignore-next-line public function testFuncFilterTime() { $this->init(); @@ -263,6 +278,7 @@ public function testFuncFilterTime() /** * Grid Filter = datetime */ + // @phpstan-ignore-next-line public function testFuncFilterDateTime() { $this->init(); @@ -286,6 +302,7 @@ public function testFuncFilterDateTime() /** * Grid Filter = select */ + // @phpstan-ignore-next-line public function testFuncFilterSelect() { $this->init(); @@ -302,6 +319,7 @@ public function testFuncFilterSelect() /** * Grid Filter = select_table */ + // @phpstan-ignore-next-line public function testFuncFilterSelectTable() { $this->init(); @@ -318,6 +336,7 @@ public function testFuncFilterSelectTable() /** * Grid Filter = yesno */ + // @phpstan-ignore-next-line public function testFuncFilterYesNo() { $this->init(); @@ -334,6 +353,7 @@ public function testFuncFilterYesNo() /** * Grid Filter = boolean */ + // @phpstan-ignore-next-line public function testFuncFilterBoolean() { $this->init(); @@ -350,6 +370,7 @@ public function testFuncFilterBoolean() /** * Grid Filter = auto number */ + // @phpstan-ignore-next-line public function testFuncFilterAutoNumber() { $this->init(); @@ -369,6 +390,7 @@ public function testFuncFilterAutoNumber() /** * Grid Filter = user */ + // @phpstan-ignore-next-line public function testFuncFilterUser() { $this->init(); @@ -385,6 +407,7 @@ public function testFuncFilterUser() /** * Grid Filter = organization */ + // @phpstan-ignore-next-line public function testFuncFilterOrganization() { $this->init(); @@ -401,6 +424,7 @@ public function testFuncFilterOrganization() /** * Grid Filter = select_multiple */ + // @phpstan-ignore-next-line public function testFuncFilterSelectMulti() { $this->init(); @@ -417,6 +441,7 @@ public function testFuncFilterSelectMulti() /** * Grid Filter = select_valtext_multiple */ + // @phpstan-ignore-next-line public function testFuncFilterSelectValMulti() { $this->init(); @@ -433,6 +458,7 @@ public function testFuncFilterSelectValMulti() /** * Grid Filter = select_table_multiple */ + // @phpstan-ignore-next-line public function testFuncFilterSelectTableMulti() { $this->init(); @@ -449,6 +475,7 @@ public function testFuncFilterSelectTableMulti() /** * Grid Filter = user_multiple */ + // @phpstan-ignore-next-line public function testFuncFilterUserMulti() { $this->init(); @@ -465,6 +492,7 @@ public function testFuncFilterUserMulti() /** * Grid Filter = organization_multiple */ + // @phpstan-ignore-next-line public function testFuncFilterOrganizationMulti() { $this->init(); @@ -481,6 +509,7 @@ public function testFuncFilterOrganizationMulti() /** * Grid Filter = file_multiple */ + // @phpstan-ignore-next-line public function testFuncFilterFileMulti() { $this->init(); @@ -508,6 +537,7 @@ public function testFuncFilterFileMulti() /** * Grid Filter = workflow_status */ + // @phpstan-ignore-next-line public function testFuncFilterWorkflowStatus() { $this->init(); @@ -531,6 +561,7 @@ public function testFuncFilterWorkflowStatus() /** * Grid Filter = workflow_work_users */ + // @phpstan-ignore-next-line public function testFuncFilterWorkflowUsers() { $this->init(); @@ -552,6 +583,7 @@ public function testFuncFilterWorkflowUsers() /** * Grid Filter = parent_id */ + // @phpstan-ignore-next-line public function testFuncFilterParentID() { $this->init(); @@ -565,6 +597,7 @@ public function testFuncFilterParentID() /** * Grid Filter = comment */ + // @phpstan-ignore-next-line public function testFuncFilterComment() { $this->init(); @@ -582,6 +615,7 @@ public function testFuncFilterComment() /** * Grid Filter = comment, filter japanese */ + // @phpstan-ignore-next-line public function testFuncFilterCommentJp() { $this->init(); @@ -599,6 +633,7 @@ public function testFuncFilterCommentJp() /** * Grid Filter = comment, multiple result */ + // @phpstan-ignore-next-line public function testFuncFilterCommentMulti() { $this->init(); @@ -618,6 +653,7 @@ public function testFuncFilterCommentMulti() /** * Summary Grid Filter = ID */ + // @phpstan-ignore-next-line public function testFuncSummaryFilterId() { $this->init(); @@ -635,6 +671,7 @@ public function testFuncSummaryFilterId() $monthly_sum); } + // @phpstan-ignore-next-line protected function getGroupingData($values) { $grouped = $values->groupBy(function($item) { @@ -653,6 +690,7 @@ protected function getGroupingData($values) }); } + // @phpstan-ignore-next-line protected function createAssertClosure() { return function ($data, $custom_table, $monthly_sum) { $idx = 0; @@ -677,6 +715,7 @@ protected function createAssertClosure() { /** * Summary Grid Filter = updated_user */ + // @phpstan-ignore-next-line public function testFuncSummaryFilterUpdatedUser() { $this->init(); @@ -700,6 +739,7 @@ public function testFuncSummaryFilterUpdatedUser() /** * Summary Grid Filter = updated_user */ + // @phpstan-ignore-next-line public function testFuncSummaryFilterInteger() { $this->init(); @@ -723,6 +763,7 @@ public function testFuncSummaryFilterInteger() /** * Summary Grid Filter = select_valtext */ + // @phpstan-ignore-next-line public function testFuncSummaryFilterSelectVal() { $this->init(); @@ -746,6 +787,7 @@ public function testFuncSummaryFilterSelectVal() /** * Summary Grid Filter = workflow_status */ + // @phpstan-ignore-next-line public function testFuncSummaryFilterWorkflowStatus() { $this->init(); @@ -774,6 +816,7 @@ public function testFuncSummaryFilterWorkflowStatus() /** * Summary Grid Filter = parent_id */ + // @phpstan-ignore-next-line public function testFuncSummaryFilterParentID() { $this->init(); @@ -795,6 +838,7 @@ public function testFuncSummaryFilterParentID() /** * Summary Grid Filter = parent_table odd_even */ + // @phpstan-ignore-next-line public function testFuncSummaryFilterParentColumn() { $this->init(); @@ -824,6 +868,7 @@ public function testFuncSummaryFilterParentColumn() /** * Summary Grid Filter = reference_table multiples_of_3 */ + // @phpstan-ignore-next-line public function testFuncSummaryFilterReferColumn() { $this->init(); @@ -854,6 +899,7 @@ public function testFuncSummaryFilterReferColumn() $this->createFilterClosure($target_column, $pivot_column)); } + // @phpstan-ignore-next-line protected function createFilterClosure($target_column, $pivot_data = null) { return function ($custom_view_id) use ($target_column, $pivot_data) { @@ -877,6 +923,7 @@ protected function createFilterClosure($target_column, $pivot_data = null) }; } + // @phpstan-ignore-next-line protected function saveComment($id, $comment) { // save Comment Model @@ -890,11 +937,13 @@ protected function saveComment($id, $comment) } + // @phpstan-ignore-next-line protected function init() { $this->initAllTest(); } + // @phpstan-ignore-next-line protected function __testGridFilter(array $filters, \Closure $testCallback, ?int $count = null, $prevTest = null) { //$this->init(); @@ -927,6 +976,7 @@ protected function __testGridFilter(array $filters, \Closure $testCallback, ?int } } + // @phpstan-ignore-next-line protected function __testSummaryGridFilter(array $filters, \Closure $testCallback, ?Collection $monthly_sum = null, $prevTest = null) { $this->init(); diff --git a/tests/Unit/CustomViewSummaryTest.php b/tests/Unit/CustomViewSummaryTest.php index a9afda4db..197529fa8 100644 --- a/tests/Unit/CustomViewSummaryTest.php +++ b/tests/Unit/CustomViewSummaryTest.php @@ -921,6 +921,7 @@ public function testFuncSummaryChildDelete() * FilterOption = Group(parent:user,order:2), Summary(integer/sum/child_table,order:1) * bugfix: set order to child table column occurs exception. */ + // @phpstan-ignore-next-line public function testFuncSummaryChildOrder() { $this->init(); @@ -964,6 +965,7 @@ public function testFuncSummaryChildOrder() * FilterOption = Group(parent:user,order:1), Summary(integer/sum/child_table) * check if user sort by id as number */ + // @phpstan-ignore-next-line public function testFuncSummaryChildOrder2() { if (\Exment::isSqlServer()) { @@ -1503,7 +1505,7 @@ protected function getCustomViewDataAll($options) } $column_data = $this->getColumnValue($data, $column_name, $condition_type); - /** @phpstan-ignore-next-line Instanceof between Exceedone\Exment\Model\CustomValue|null and Illuminate\Support\Collection will always evaluate to false. */ + // @phpstan-ignore-next-line if ($column_data instanceof \Illuminate\Support\Collection) { $column_data = $column_data->map(function ($item) { if ($item instanceof Model) { diff --git a/tests/Unit/CustomViewTrait.php b/tests/Unit/CustomViewTrait.php index f9a204a42..95a36f809 100644 --- a/tests/Unit/CustomViewTrait.php +++ b/tests/Unit/CustomViewTrait.php @@ -62,6 +62,7 @@ protected function createCustomViewAll(array $options = [], $view_kind_type = Vi $summary_settings = array_get($options, 'summary_settings'); // Login user. + // @phpstan-ignore-next-line $this->be(LoginUser::find($login_user_id)); $custom_table = CustomTable::getEloquent($target_table_name); @@ -128,11 +129,14 @@ protected function getCustomView(array $options = [], $view_kind_type = ViewKind $grid = new \Exceedone\Exment\DataItems\Grid\SummaryGrid($custom_table, $custom_view); $query = $grid->getQuery($query); if (!is_null($offset = array_get($options, 'offset'))) { + // @phpstan-ignore-next-line $query->offset($offset); } if (!is_null($limit = array_get($options, 'limit'))) { + // @phpstan-ignore-next-line $query->limit($limit); } + // @phpstan-ignore-next-line $data = $query->get(); } else { $custom_view->setValueFilters($query); diff --git a/tests/Unit/LaravelAdminFieldTest.php b/tests/Unit/LaravelAdminFieldTest.php index 17262b507..a5ae85001 100644 --- a/tests/Unit/LaravelAdminFieldTest.php +++ b/tests/Unit/LaravelAdminFieldTest.php @@ -713,6 +713,7 @@ protected function _testLaravelField(\Closure $fieldOptionCallback, $value, bool $this->assertTrue($messages === false, 'This test expects true, but result is false. message is ' . json_encode($messages)); } else { $this->assertTrue($messages !== false, 'This test expects false, but result is true'); + // @phpstan-ignore-next-line $this->assertJsonExment($errors, $messages->getMessages()); } } diff --git a/tests/Unit/MultiUniqueValueTest.php b/tests/Unit/MultiUniqueValueTest.php index aea53886b..755153cff 100644 --- a/tests/Unit/MultiUniqueValueTest.php +++ b/tests/Unit/MultiUniqueValueTest.php @@ -13,6 +13,7 @@ class MultiUniqueValueTest extends UnitTestBase { + // @phpstan-ignore-next-line public function testUniqueColumn2() { $custom_table = $this->initUniqueValueTest(['text', 'decimal']); @@ -22,6 +23,7 @@ public function testUniqueColumn2() $this->assertTrue(count($result) == 0); } + // @phpstan-ignore-next-line public function testNotUniqueColumn2() { $custom_table = $this->initUniqueValueTest(['text', 'decimal']); @@ -36,6 +38,7 @@ public function testNotUniqueColumn2() $this->assertTrue(count($result) > 0); } + // @phpstan-ignore-next-line public function testUniqueColumn3() { $custom_table = $this->initUniqueValueTest(['user', 'date', 'integer']); @@ -45,6 +48,7 @@ public function testUniqueColumn3() $this->assertTrue(count($result) == 0); } + // @phpstan-ignore-next-line public function testNotUniqueColumn3() { $custom_table = $this->initUniqueValueTest(['user', 'date', 'integer']); @@ -60,6 +64,7 @@ public function testNotUniqueColumn3() $this->assertTrue(count($result) > 0); } + // @phpstan-ignore-next-line public function testUniqueColumn3withParent() { $custom_table = $this->initUniqueValueTest(['user', 'parent_id', 'integer']); @@ -69,6 +74,7 @@ public function testUniqueColumn3withParent() $this->assertTrue(count($result) == 0); } + // @phpstan-ignore-next-line public function testNotUniqueColumn3withParent() { $custom_table = $this->initUniqueValueTest(['odd_even', 'currency', 'parent_id']); @@ -85,6 +91,7 @@ public function testNotUniqueColumn3withParent() $this->assertTrue(count($result) > 0); } + // @phpstan-ignore-next-line public function testUniqueColumn3withParentUpdate() { $custom_table = $this->initUniqueValueTest(['odd_even', 'currency', 'parent_id']); @@ -101,6 +108,7 @@ public function testUniqueColumn3withParentUpdate() $this->assertTrue(count($result) == 0); } + // @phpstan-ignore-next-line public function testNotUniqueColumn3withParentUpdate() { $custom_table = $this->initUniqueValueTest(['odd_even', 'currency', 'parent_id']); @@ -121,6 +129,7 @@ public function testNotUniqueColumn3withParentUpdate() $this->assertTrue(count($result) > 0); } + // @phpstan-ignore-next-line protected function initUniqueValueTest(array $column_names): CustomTable { $custom_table = CustomTable::getEloquent('child_table'); diff --git a/tests/Unit/PermissionUpDownTest.php b/tests/Unit/PermissionUpDownTest.php index 0c148675d..cc91f0abf 100644 --- a/tests/Unit/PermissionUpDownTest.php +++ b/tests/Unit/PermissionUpDownTest.php @@ -511,7 +511,7 @@ protected function executeTestOrganizationUser($loginId, $joinedOrgFilterType, $ $this->init(); $user = CustomTable::getEloquent('user')->getValueModel($loginId); - /** @phpstan-ignore-next-line $user is generated class */ + // @phpstan-ignore-next-line $organizations = $user->getOrganizationIdsForQuery($joinedOrgFilterType); sort($organizations); @@ -547,7 +547,7 @@ protected function executeTestOrganizationOrg($id, $joinedOrgFilterType, $antiOr $this->init(); $organization = CustomTable::getEloquent('organization')->getValueModel($id); - /** @phpstan-ignore-next-line $organization is generated class */ + // @phpstan-ignore-next-line $organizations = $organization->getOrganizationIdsForQuery($joinedOrgFilterType); sort($organizations); diff --git a/tests/Unit/SystemRequireTest.php b/tests/Unit/SystemRequireTest.php index 3b06661aa..4de419e1a 100644 --- a/tests/Unit/SystemRequireTest.php +++ b/tests/Unit/SystemRequireTest.php @@ -135,6 +135,7 @@ public function testComposerVersionMin() protected function _test($classname, \Closure $exceptValueFunc, ?\Closure $resultFunc = null) { $obj = new $classname(); + // @phpstan-ignore-next-line $value = $obj->getResult(); $exceptValue = $exceptValueFunc(); diff --git a/tests/tmpfile/plugins/TestPluginDashboard/Plugin.php b/tests/tmpfile/plugins/TestPluginDashboard/Plugin.php index 67dc79cb4..0105d9428 100644 --- a/tests/tmpfile/plugins/TestPluginDashboard/Plugin.php +++ b/tests/tmpfile/plugins/TestPluginDashboard/Plugin.php @@ -16,6 +16,7 @@ public function body() $data = $this->getData(); return view('exment_test_plugin_dashboard::sample', [ + // @phpstan-ignore-next-line 'id' => $data->id, 'params' => $this->getParams($data), 'action' => admin_url($this->getDashboardUri('post')), @@ -36,15 +37,19 @@ public function post() $now = \Carbon\Carbon::now(); + // @phpstan-ignore-next-line $integer = $data->getValue('integer'); switch (request()->get('action')) { case 'add': + // @phpstan-ignore-next-line $data->setValue('integer', $integer + 1); break; case 'minus': + // @phpstan-ignore-next-line $data->setValue('integer', $integer - 1); break; } + // @phpstan-ignore-next-line $data->save(); admin_toastr(trans('admin.save_succeeded')); diff --git a/tests/tmpfile/plugins/TestPluginExportCsv/Plugin.php b/tests/tmpfile/plugins/TestPluginExportCsv/Plugin.php index 21bfdbaed..85a8a1439 100644 --- a/tests/tmpfile/plugins/TestPluginExportCsv/Plugin.php +++ b/tests/tmpfile/plugins/TestPluginExportCsv/Plugin.php @@ -29,9 +29,11 @@ public function execute() foreach ($data as $fields) { + // @phpstan-ignore-next-line fputcsv($fp, $fields); } + // @phpstan-ignore-next-line fclose($fp); // $tmpのstring文字列を返却する