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的过程中,有时候无法避免在传统模型中存在一些公共的静态方法,因此实体模型应该支持对应模型公共静态方法的调用,而不是固定写死几个内置的方法

Copy link

codecov bot commented Sep 30, 2025

Codecov Report

❌ Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 52.04%. Comparing base (006ad4b) to head (eaf6f2e).

Files with missing lines Patch % Lines
src/Entity.php 88.88% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                4.0     #817      +/-   ##
============================================
- Coverage     52.06%   52.04%   -0.02%     
+ Complexity     3507     3505       -2     
============================================
  Files            74       74              
  Lines          8313     8310       -3     
============================================
- Hits           4328     4325       -3     
  Misses         3985     3985              
Flag Coverage Δ
unittests 52.04% <88.88%> (-0.02%) ⬇️

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.

@gitlilimin gitlilimin closed this Sep 30, 2025
@gitlilimin gitlilimin deleted the feature/entity branch September 30, 2025 23:20
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