Skip to content

Conversation

@gitlilimin
Copy link
Contributor

原本实体模型的 __callStatic() 中是写死了对应模型的几个方法,只有这些方法支持对实体模型对应的模型调用,代码如下

public static function __callStatic($method, $args)
{
    $entity = new static();
    if (in_array($method, ['destroy', 'create', 'update', 'saveAll'])) {
        // 调用model的静态方法
        $db = $entity->model();
    } else {
        // 调用Query类查询方法
        $db = $entity->model()->db();
    }

    return call_user_func_array([$db, $method], $args);
}

在升级orm 4的过程中,有时候无法避免在传统模型中存在一些公共的静态方法,因此实体模型应该支持对应模型公共静态方法的调用,而不是固定写死几个内置的方法

@codecov
Copy link

codecov bot commented Sep 30, 2025

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 52.08%. Comparing base (006ad4b) to head (2e76ce3).

Files with missing lines Patch % Lines
src/Entity.php 80.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                4.0     #818      +/-   ##
============================================
+ Coverage     52.06%   52.08%   +0.01%     
  Complexity     3507     3507              
============================================
  Files            74       74              
  Lines          8313     8316       +3     
============================================
+ Hits           4328     4331       +3     
  Misses         3985     3985              
Flag Coverage Δ
unittests 52.08% <80.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant