8000 Allow to customize the message · symfony/symfony@7e2ff51 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7e2ff51

Browse files
committed
Allow to customize the message
1 parent ce9ceb8 commit 7e2ff51

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

src/Symfony/Component/Debug/DebugClassLoader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,13 @@ public function loadClass($class)
164164
throw new \RuntimeException(sprintf('Case mismatch between loaded and declared class names: %s vs %s', $class, $name));
165165
}
166166

167-
if (preg_match('#\n \* @final( .*)?\r?\n \*(?: @|/$)#s', $refl->getDocComment())) {
168-
self::$final[$name] = true;
167+
if (preg_match('#\n \* @final(?:( .+?)\.?)?\r?\n \*(?: @|/$)#s', $refl->getDocComment(), $notice)) {
168+
self::$final[$name] = isset($notice[1]) ? preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]) : '';
169169
}
170170

171171
$parent = get_parent_class($class);
172-
if ($parent && isset(self::$final[$parent])) {
173-
@trigger_error(sprintf('Extending the class %s in %s is deprecated. This class will be made final in the next major release.', $parent, $name), E_USER_DEPRECATED);
172+
if ($parent && array_key_exists($parent, self::$final)) {
173+
@trigger_error(sprintf('The %s class is considered final%s. It may change without further notice as of its next major version. You should not extend it from %s.', $parent, self::$final[$parent], $name), E_USER_DEPRECATED);
174174
}
175175

176176
if (in_array(strtolower($refl->getShortName()), self::$php7Reserved)) {

src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ class_exists('Test\\'.__NAMESPACE__.'\\ExtendsFinalClass', true);
284284

285285
$xError = array(
286286
'type' => E_USER_DEPRECATED,
287-
'message' => sprintf('Extending the class %s in Test\Symfony\Component\Debug\Tests\ExtendsFinalClass is deprecated. This class will be made final in the next major release.', Fixtures\FinalClass::class),
287+
'message' => 'The Symfony\Component\Debug\Tests\Fixtures\FinalClass class is considered final since version 3.3. It may change without further notice as of its next major version. You should not extend it from Test\Symfony\Component\Debug\Tests\ExtendsFinalClass.',
288288
);
289289

290290
$this->assertSame($xError, $lastError);

src/Symfony/Component/Debug/Tests/Fixtures/FinalClass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Symfony\Component\Debug\Tests\Fixtures;
44

55
/**
6-
* @final
6+
* @final since version 3.3.
77
*/
88
class FinalClass
99
{

src/Symfony/Component/Serializer/Encoder/ChainDecoder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
2121
* @author Lukas Kahwe Smith <smith@pooteeweet.org>
2222
*
23-
* @final
23+
* @final since version 3.3.
2424
*/
2525
class ChainDecoder implements DecoderInterface
2626
{

src/Symfony/Component/Serializer/Encoder/ChainEncoder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
2121
* @author Lukas Kahwe Smith <smith@pooteeweet.org>
2222
*
23-
* @final
23+
* @final since version 3.3.
2424
*/
2525
class ChainEncoder implements EncoderInterface
2626
{

0 commit comments

Comments
 (0)
0