Skip to content

Explicitly mark readonly properties#1158

Merged
vjik merged 9 commits intomasterfrom
readonly-psr-cache
Feb 2, 2026
Merged

Explicitly mark readonly properties#1158
vjik merged 9 commits intomasterfrom
readonly-psr-cache

Conversation

@vjik
Copy link
Member

@vjik vjik commented Jan 30, 2026

Q A
Is bugfix?
New feature?
Breaks BC?
Tests pass? ✔️

@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.63%. Comparing base (e753995) to head (339f90d).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1158   +/-   ##
=========================================
  Coverage     98.63%   98.63%           
  Complexity     1654     1654           
=========================================
  Files           120      120           
  Lines          4308     4313    +5     
=========================================
+ Hits           4249     4254    +5     
  Misses           59       59           

☔ 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.

@vjik vjik requested a review from a team January 30, 2026 13:24
@vjik vjik added the status:code review The pull request needs review. label Jan 30, 2026
Copy link
Member

@Tigrov Tigrov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about other properties in other classes? They also can be marked as readonly.

* A transaction is a set of SQL statements that must either all succeed or all fail.
*
* It's usually created by calling {@see \Yiisoft\Db\Connection\AbstractConnectionAbstractConnection::beginTransaction()}.
* It's usually created by calling {@see AbstractConnectionAbstractConnection::beginTransaction()}.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* It's usually created by calling {@see AbstractConnectionAbstractConnection::beginTransaction()}.
* It's usually created by calling {@see ConnectionInterface::beginTransaction()}.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@vjik vjik changed the title Mark $psrCache property in SchemaCache as readonly Explicitly mark readonly properties Feb 1, 2026
@vjik
Copy link
Member Author

vjik commented Feb 1, 2026

What about other properties in other classes? They also can be marked as readonly.

Done

@vjik vjik requested a review from Tigrov February 1, 2026 14:59
@@ -113,7 +113,7 @@ abstract class AbstractDQLQueryBuilder implements DQLQueryBuilderInterface

public function __construct(
protected QueryBuilderInterface $queryBuilder,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
protected QueryBuilderInterface $queryBuilder,
protected readonly QueryBuilderInterface $queryBuilder,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks BC.

private AbstractDDLQueryBuilder $ddlBuilder,
private readonly ConnectionInterface $db,
private readonly AbstractDDLQueryBuilder $ddlBuilder,
private AbstractDMLQueryBuilder $dmlBuilder,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private AbstractDMLQueryBuilder $dmlBuilder,
private readonly AbstractDMLQueryBuilder $dmlBuilder,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This property is not readonly. See withTypecasting() method.


public function __construct(protected ConnectionInterface $db, private SchemaCache $schemaCache) {}
public function __construct(
protected ConnectionInterface $db,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
protected ConnectionInterface $db,
protected readonly ConnectionInterface $db,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks BC.

@vjik vjik merged commit 1f38570 into master Feb 2, 2026
80 of 81 checks passed
@vjik vjik deleted the readonly-psr-cache branch February 2, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:code review The pull request needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants