Skip to content

Commit 45b1d68

Browse files
authored
Merge pull request #8056 from kenjis/make-Factories-final
fix: make Factories final
2 parents c3bdcc9 + effc82c commit 45b1d68

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

system/Config/Factories.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@
2828
* @method static Model|null models(string $alias, array $options = [], ?ConnectionInterface &$conn = null)
2929
* @see \CodeIgniter\Config\FactoriesTest
3030
*/
31-
class Factories
31+
final class Factories
3232
{
3333
/**
3434
* Store of component-specific options, usually
3535
* from CodeIgniter\Config\Factory.
3636
*
3737
* @var array<string, array<string, bool|string|null>>
3838
*/
39-
protected static $options = [];
39+
private static $options = [];
4040

4141
/**
4242
* Explicit options for the Config
@@ -65,7 +65,7 @@ class Factories
6565
* @var array<string, array<string, string>>
6666
* @phpstan-var array<string, array<string, class-string>>
6767
*/
68-
protected static $aliases = [];
68+
private static $aliases = [];
6969

7070
/**
7171
* Store for instances of any component that
@@ -79,7 +79,7 @@ class Factories
7979
* @var array<string, array<string, object>>
8080
* @phpstan-var array<string, array<class-string, object>>
8181
*/
82-
protected static $instances = [];
82+
private static $instances = [];
8383

8484
/**
8585
* Whether the component instances are updated?
@@ -88,7 +88,7 @@ class Factories
8888
*
8989
* @internal For caching only
9090
*/
91-
protected static $updated = [];
91+
private static $updated = [];
9292

9393
/**
9494
* Define the class to load. You can *override* the concrete class.
@@ -252,7 +252,7 @@ private static function isConfig(string $component): bool
252252
* @param array $options The array of component-specific directives
253253
* @param string $alias Class alias. See the $aliases property.
254254
*/
255-
protected static function locateClass(array $options, string $alias): ?string
255+
private static function locateClass(array $options, string $alias): ?string
256256
{
257257
// Check for low-hanging fruit
258258
if (
@@ -328,7 +328,7 @@ private static function isNamespaced(string $alias): bool
328328
* @param array $options The array of component-specific directives
329329
* @param string $alias Class alias. See the $aliases property.
330330
*/
331-
protected static function verifyPreferApp(array $options, string $alias): bool
331+
private static function verifyPreferApp(array $options, string $alias): bool
332332
{
333333
// Anything without that restriction passes
334334
if (! $options['preferApp']) {
@@ -349,7 +349,7 @@ protected static function verifyPreferApp(array $options, string $alias): bool
349349
* @param array $options The array of component-specific directives
350350
* @param string $alias Class alias. See the $aliases property.
351351
*/
352-
protected static function verifyInstanceOf(array $options, string $alias): bool
352+
private static function verifyInstanceOf(array $options, string $alias): bool
353353
{
354354
// Anything without that restriction passes
355355
if (! $options['instanceOf']) {

user_guide_src/source/changelogs/v4.5.0.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ Due to a bug fix, the behavior has changed so that options passed to the outer
3434
``group()`` are merged with the options of the inner ``group()``.
3535
See :ref:`Upgrading Guide <upgrade-450-nested-route-groups-and-options>` for details.
3636

37+
Factories class
38+
---------------
39+
40+
:doc:`../concepts/factories` has been changed to a final class. It is a static
41+
class, and even if it were extended, there is no way to replace it.
42+
3743
Others
3844
------
3945

user_guide_src/source/installation/upgrade_450.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ has been removed.
119119

120120
If you extneds ``BaseModel``, implement the ``getIdValue()`` method in the child class.
121121

122+
Factories
123+
=========
124+
125+
:doc:`../concepts/factories` has been changed to a final class.
126+
In the unlikely event, you have inherited the Factories, stop inheriting and
127+
copy the code into your Factories class.
128+
122129
Removed Deprecated Items
123130
========================
124131

0 commit comments

Comments
 (0)