Skip to content

[Technical Debt]: Add getters for protected model variables #4489

Open

Description

@coderabbitai

Overview

Add getters for all protected model variables since they are currently being accessed directly, which is not the intended pattern. Making them public is a bad idea because they can be modified in the code unintentionally. They should be changed to private with a getter, then calling code should be refactored to use the getter.

Background

This was identified as a follow-up task from PR #4485 (Update to CodeIgniter 4.7.2).

Tasks

  • Audit all models for protected variables that are being accessed directly from outside the class
  • Change those variables from protected to private
  • Add appropriate getter methods for each variable
  • Refactor all calling code to use the new getters
  • Add tests to verify behavior is unchanged

References

Activity

  1. added a commit that references this issue on Apr 15, 2026
    e17e85b
  2. changed the title [-]Add getters for protected model variables and refactor direct access[/-] [+][Technical Debt]: Add getters for protected model variables[/+] on Apr 20, 2026
  3. objecttothis commented on Oct 26, 2026

    @objecttothis
    Member

    Claude Issue Checker Agent (cc @objecttothis)

    Investigated against current master.

    Status: Still present (fix not yet merged).

    There is an open PR addressing this directly: #4504 "refactor: Add getters for protected model properties" (closes #4489), which introduces app/Models/BaseModel.php with getters (getTableName(), getPrimaryKeyName(), getAllowedFields(), etc.) and updates 27+ models to extend it. As of this check PR #4504 is still open/unmerged (merged: false), so BaseModel does not exist on master yet and model variables are still accessed directly (protected, no getters) as described in the issue.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions