Skip to content

Commit 68b7971

Browse files
authored
Merge pull request doctrine#12029 from greg0ire/remove-userland-proxies
Remove the possibility to use userland proxies
2 parents ac87e6e + e17b31e commit 68b7971

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+58
-1873
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,21 @@ jobs:
3939
- "pdo_sqlite"
4040
deps:
4141
- "highest"
42-
native_lazy:
43-
- "0"
4442
include:
4543
- php-version: "8.4"
4644
dbal-version: "4@dev"
4745
extension: "pdo_sqlite"
48-
native_lazy: "0"
4946
- php-version: "8.4"
5047
dbal-version: "4@dev"
5148
extension: "sqlite3"
52-
native_lazy: "0"
5349
- php-version: "8.4"
5450
dbal-version: "default"
5551
deps: "lowest"
5652
extension: "pdo_sqlite"
57-
native_lazy: "0"
5853
- php-version: "8.4"
5954
dbal-version: "default"
6055
deps: "highest"
6156
extension: "pdo_sqlite"
62-
native_lazy: "1"
6357

6458
steps:
6559
- name: "Checkout"
@@ -89,18 +83,16 @@ jobs:
8983
run: "vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml --coverage-clover=coverage-no-cache.xml"
9084
env:
9185
ENABLE_SECOND_LEVEL_CACHE: 0
92-
ENABLE_NATIVE_LAZY_OBJECTS: ${{ matrix.native_lazy }}
9386

9487
- name: "Run PHPUnit with Second Level Cache"
9588
run: "vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml --exclude-group performance,non-cacheable,locking_functional --coverage-clover=coverage-cache.xml"
9689
env:
9790
ENABLE_SECOND_LEVEL_CACHE: 1
98-
ENABLE_NATIVE_LAZY_OBJECTS: ${{ matrix.native_lazy }}
9991

10092
- name: "Upload coverage file"
10193
uses: "actions/upload-artifact@v4"
10294
with:
103-
name: "phpunit-${{ matrix.extension }}-${{ matrix.php-version }}-${{ matrix.dbal-version }}-${{ matrix.deps }}-${{ matrix.native_lazy }}-coverage"
95+
name: "phpunit-${{ matrix.extension }}-${{ matrix.php-version }}-${{ matrix.dbal-version }}-${{ matrix.deps }}-coverage"
10496
path: "coverage*.xml"
10597

10698

.github/workflows/phpbench.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ jobs:
5151
uses: "ramsey/composer-install@v3"
5252

5353
- name: "Run PHPBench"
54-
run: "ENABLE_NATIVE_LAZY_OBJECTS=0 vendor/bin/phpbench run --report=default"
54+
run: "vendor/bin/phpbench run --report=default"

UPGRADE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Upgrade to 4.0
22

3+
## BC BREAK: Userland lazy objects are no longer supported
4+
5+
Userland lazy objects are no longer supported.
6+
[Native lazy objects](https://www.php.net/manual/en/language.oop5.lazy-objects.php)
7+
are used instead.
8+
39
## BC BREAK: type declarations on constants
410

511
All constants in the ORM now have type declarations and are final. You may no

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
"doctrine/lexer": "^3",
3434
"doctrine/persistence": "^4",
3535
"psr/cache": "^1 || ^2 || ^3",
36-
"symfony/console": "^5.4 || ^6.0 || ^7.0",
37-
"symfony/var-exporter": "^6.3.9 || ^7.0"
36+
"symfony/console": "^5.4 || ^6.0 || ^7.0"
3837
},
3938
"require-dev": {
4039
"doctrine/coding-standard": "^13.0",
@@ -46,7 +45,8 @@
4645
"phpunit/phpunit": "^10.4.0",
4746
"psr/log": "^1 || ^2 || ^3",
4847
"squizlabs/php_codesniffer": "3.12.0",
49-
"symfony/cache": "^5.4 || ^6.2 || ^7.0"
48+
"symfony/cache": "^5.4 || ^6.2 || ^7.0",
49+
"symfony/var-exporter": "^6.3.9 || ^7.0"
5050
},
5151
"suggest": {
5252
"ext-dom": "Provides support for XSD validation for XML mapping files",

docs/en/reference/advanced-configuration.rst

Lines changed: 0 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -65,53 +65,6 @@ Configuration Options
6565
The following sections describe all the configuration options
6666
available on a ``Doctrine\ORM\Configuration`` instance.
6767

68-
Native Lazy Objects (**OPTIONAL**)
69-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
70-
71-
With PHP 8.4 we recommend that you use native lazy objects instead of
72-
the code generation approach using the ``symfony/var-exporter`` Ghost trait.
73-
74-
With Doctrine 4, the minimal requirement will become PHP 8.4 and native lazy objects
75-
will become the only approach to lazy loading.
76-
77-
.. code-block:: php
78-
79-
<?php
80-
$config->enableNativeLazyObjects(true);
81-
82-
Proxy Directory
83-
~~~~~~~~~~~~~~~
84-
85-
Required except if you use native lazy objects with PHP 8.4.
86-
This setting will be removed in the future.
87-
88-
.. code-block:: php
89-
90-
<?php
91-
$config->setProxyDir($dir);
92-
$config->getProxyDir();
93-
94-
Gets or sets the directory where Doctrine generates any proxy
95-
classes. For a detailed explanation on proxy classes and how they
96-
are used in Doctrine, refer to the "Proxy Objects" section further
97-
down.
98-
99-
Proxy Namespace
100-
~~~~~~~~~~~~~~~
101-
102-
Required except if you use native lazy objects with PHP 8.4.
103-
This setting will be removed in the future.
104-
105-
.. code-block:: php
106-
107-
<?php
108-
$config->setProxyNamespace($namespace);
109-
$config->getProxyNamespace();
110-
111-
Gets or sets the namespace to use for generated proxy classes. For
112-
a detailed explanation on proxy classes and how they are used in
113-
Doctrine, refer to the "Proxy Objects" section further down.
114-
11568
Metadata Driver (**REQUIRED**)
11669
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11770

@@ -211,63 +164,6 @@ Gets or sets the logger to use for logging all SQL statements
211164
executed by Doctrine. The logger class must implement the
212165
deprecated ``Doctrine\DBAL\Logging\SQLLogger`` interface.
213166

214-
Auto-generating Proxy Classes (**OPTIONAL**)
215-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
216-
217-
This setting is not required if you use native lazy objects with PHP 8.4
218-
and will be removed in the future.
219-
220-
Proxy classes can either be generated manually through the Doctrine
221-
Console or automatically at runtime by Doctrine. The configuration
222-
option that controls this behavior is:
223-
224-
.. code-block:: php
225-
226-
<?php
227-
$config->setAutoGenerateProxyClasses($mode);
228-
229-
Possible values for ``$mode`` are:
230-
231-
- ``Doctrine\ORM\Proxy\ProxyFactory::AUTOGENERATE_NEVER``
232-
233-
Never autogenerate a proxy. You will need to generate the proxies
234-
manually, for this use the Doctrine Console like so:
235-
236-
.. code-block:: php
237-
238-
$ ./doctrine orm:generate-proxies
239-
240-
When you do this in a development environment,
241-
be aware that you may get class/file not found errors if certain proxies
242-
are not yet generated. You may also get failing lazy-loads if new
243-
methods were added to the entity class that are not yet in the proxy class.
244-
In such a case, simply use the Doctrine Console to (re)generate the
245-
proxy classes.
246-
247-
- ``Doctrine\ORM\Proxy\ProxyFactory::AUTOGENERATE_ALWAYS``
248-
249-
Always generates a new proxy in every request and writes it to disk.
250-
251-
- ``Doctrine\ORM\Proxy\ProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS``
252-
253-
Generate the proxy class when the proxy file does not exist.
254-
This strategy causes a file exists call whenever any proxy is
255-
used the first time in a request.
256-
257-
- ``Doctrine\ORM\Proxy\ProxyFactory::AUTOGENERATE_EVAL``
258-
259-
Generate the proxy classes and evaluate them on the fly via eval(),
260-
avoiding writing the proxies to disk.
261-
This strategy is only sane for development.
262-
263-
In a production environment, it is highly recommended to use
264-
AUTOGENERATE_NEVER to allow for optimal performances. The other
265-
options are interesting in development environment.
266-
267-
``setAutoGenerateProxyClasses`` can accept a boolean
268-
value. This is still possible, ``FALSE`` being equivalent to
269-
AUTOGENERATE_NEVER and ``TRUE`` to AUTOGENERATE_ALWAYS.
270-
271167
Development vs Production Configuration
272168
---------------------------------------
273169

@@ -383,55 +279,6 @@ transparently initialize itself on first access.
383279
This will override the 'fetch' option specified in the mapping for
384280
that association, but only for that query.
385281

386-
387-
Generating Proxy classes
388-
~~~~~~~~~~~~~~~~~~~~~~~~
389-
390-
In a production environment, it is highly recommended to use
391-
``AUTOGENERATE_NEVER`` to allow for optimal performances.
392-
However you will be required to generate the proxies manually
393-
using the Doctrine Console:
394-
395-
.. code-block:: php
396-
397-
$ ./doctrine orm:generate-proxies
398-
399-
The other options are interesting in development environment:
400-
401-
- ``AUTOGENERATE_ALWAYS`` will require you to create and configure
402-
a proxy directory. Proxies will be generated and written to file
403-
on each request, so any modification to your code will be acknowledged.
404-
405-
- ``AUTOGENERATE_FILE_NOT_EXISTS`` will not overwrite an existing
406-
proxy file. If your code changes, you will need to regenerate the
407-
proxies manually.
408-
409-
- ``AUTOGENERATE_EVAL`` will regenerate each proxy on each request,
410-
but without writing them to disk.
411-
412-
Autoloading Proxies
413-
-------------------
414-
415-
When you deserialize proxy objects from the session or any other storage
416-
it is necessary to have an autoloading mechanism in place for these classes.
417-
For implementation reasons Proxy class names are not PSR-0 compliant. This
418-
means that you have to register a special autoloader for these classes:
419-
420-
.. code-block:: php
421-
422-
<?php
423-
use Doctrine\ORM\Proxy\Autoloader;
424-
425-
$proxyDir = "/path/to/proxies";
426-
$proxyNamespace = "MyProxies";
427-
428-
Autoloader::register($proxyDir, $proxyNamespace);
429-
430-
If you want to execute additional logic to intercept the proxy file not found
431-
state you can pass a closure as the third argument. It will be called with
432-
the arguments proxydir, namespace and className when the proxy file could not
433-
be found.
434-
435282
Multiple Metadata Sources
436283
-------------------------
437284

docs/en/reference/tools.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ The following Commands are currently available:
8383
cache drivers.
8484
- ``orm:clear-cache:result`` Clear result cache of the various
8585
cache drivers.
86-
- ``orm:generate-proxies`` Generates proxy classes for entity
87-
classes. Deprecated in favor of using native lazy objects.
8886
- ``orm:run-dql`` Executes arbitrary DQL directly from the command
8987
line.
9088
- ``orm:schema-tool:create`` Processes the schema and either

phpcs.xml.dist

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,6 @@
208208
<exclude-pattern>tests/Tests/Models/DDC1590/DDC1590User.php</exclude-pattern>
209209
</rule>
210210

211-
212-
<rule ref="Squiz.Classes.ValidClassName.NotCamelCaps">
213-
<!-- we need to test what happens with an stdClass proxy -->
214-
<exclude-pattern>tests/Tests/Proxy/DefaultProxyClassNameResolverTest.php</exclude-pattern>
215-
</rule>
216-
217211
<rule ref="Squiz.Commenting.FunctionComment.WrongStyle">
218212
<!-- https://github.com/squizlabs/PHP_CodeSniffer/issues/1961 -->
219213
<exclude-pattern>tests/Tests/Mocks/DatabasePlatformMock.php</exclude-pattern>

0 commit comments

Comments
 (0)