Entity does not exist: Pyz prefix
Edit on GitHubWhen running an upgrade, you can get an error about a non-existent constant, class, method, or property. It’s caused by the name of the entity containing the pyz
prefix.
Error example
Constant does not exist because the existent constant has PYZ_
prefix.
Solution
Remove pyz
from the names of the entities:
- Constant
- Class
- Method
- Property
Rename constants
- Replace
const PYZ_
withconst
. - Replace
::PYZ_
with::
. - Rename constant values that start with
PYZ_
. - Remove constants that override the same parent constant with the same value.
Rename transfers
-
In the
shared
folder, replace the following for*.xml
transfers files:"(pyz)(.)(\w*)
with"\L$2\E$3
"(Pyz)(.)(\w*)
with"$2E$3
-
In
*.php
files, replace theTransfer\->(get|set|require)Pyz
regexpa withTransfer->$1
. -
In
*.twig
files, removepyz
in transfer getters like.getPyz
or.pyz
.
Rename DB schemas
Naming convention
According to our naming convention, all custom tables must be prefixed with pyz_
Remove pyz_
in *.xml
schema files.
Rename methods
- Replace the
on (get|set|add|map)Pyz
regexp withon $1
. - Replace the
\->(get|set|add|map)Pyz
regexp with->$1
. - Replace
class Pyz
withclass
. - Replace
BasePyz
withBase
. - Replace the
([a-z])Pyz([A-Z])
regexp with$1$2
.
Rename variables and class names
- Search by the
\w\\Pyz
regexp,Pyz(
,: Pyz
,(Pyz
and removepyz
. - Search by the
(?<!(namespace |use |@[a-z]+ \\))(Pyz|pyz)
rexexp and remove all thepyz
occurrences.
Verify the changes
- Use phpstan to identify missed occurrences of
pyz
. If any found, rename or remove. - Manually check the project base functionality.
- Run the CI and make sure it’s green.
Thank you!
For submitting the form