Skip to content

Commit

Permalink
Prepare PHP 8.4 support: Prevent property hooks from being used (#11628)
Browse files Browse the repository at this point in the history
Prevent property hooks from being used as they currently would work on external non-raw values without explicit code.
  • Loading branch information
beberlei authored Oct 9, 2024
1 parent 109042e commit 0e48b19
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ parameters:
count: 2
path: src/Mapping/ClassMetadataFactory.php

-
message: "#^Call to an undefined method ReflectionProperty\\:\\:getHooks\\(\\)\\.$#"
count: 1
path: src/Mapping/ClassMetadataInfo.php

-
message: "#^Method Doctrine\\\\ORM\\\\Mapping\\\\NamingStrategy\\:\\:joinColumnName\\(\\) invoked with 2 parameters, 1 required\\.$#"
count: 2
Expand Down
3 changes: 3 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,9 @@
<code><![CDATA[joinColumnName]]></code>
<code><![CDATA[joinColumnName]]></code>
</TooManyArguments>
<UndefinedMethod>
<code><![CDATA[getHooks]]></code>
</UndefinedMethod>
</file>
<file src="src/Mapping/ColumnResult.php">
<MissingConstructor>
Expand Down
4 changes: 4 additions & 0 deletions src/Mapping/ClassMetadataInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -3890,6 +3890,10 @@ private function getAccessibleProperty(ReflectionService $reflService, string $c
}
}

if (PHP_VERSION_ID >= 80400 && $reflectionProperty !== null && count($reflectionProperty->getHooks()) > 0) {
throw new LogicException('Doctrine ORM does not support property hooks in this version. Check https://github.com/doctrine/orm/issues/11624 for details of versions that support property hooks.');
}

return $reflectionProperty;
}
}

0 comments on commit 0e48b19

Please sign in to comment.