bug #2483 Fix @final-related deprecations (nicolas-grekas)

This PR was merged into the 2.x branch.

Discussion
----------

Fix `@final`-related deprecations

The run-time notices make Symfony fail because the check should exclude e.g. `Twig_SimpleFilter`.
But IMHO, we may not really need these run-time checks, if we say that relying on the DebugClassLoader + CHANGELOG in enough (which we did in the past).

Commits
-------

635b9e59 Fix `@final`-related deprecations
This commit is contained in:
Fabien Potencier
2017-05-24 16:23:32 +02:00
9 changed files with 39 additions and 14 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
* 2.4.0 (2017-XX-XX)
* marked Twig_Node_Module as final via the @final annotation
* marked Twig_Filter, Twig_Function, Twig_Test, Twig_Node_Module and Twig_Profiler_Profile as final via the @final annotation
* 2.3.2 (2017-04-20)
+4 -1
View File
@@ -12,7 +12,7 @@
/**
* Represents a template filter.
*
* @final
* @final since version 2.4.0
*
* @author Fabien Potencier <fabien@symfony.com>
*
@@ -135,3 +135,6 @@ class Twig_Filter
return $this->options['alternative'];
}
}
// For Twig 1.x compatibility
class_alias('Twig_Filter', 'Twig_SimpleFilter', false);
+7
View File
@@ -34,6 +34,10 @@ class Twig_Function
*/
public function __construct(string $name, $callable = null, array $options = array())
{
if (__CLASS__ !== get_class($this)) {
@trigger_error('Overriding '.__CLASS__.' is deprecated since version 2.4.0 and the class will be final in 3.0.', E_USER_DEPRECATED);
}
$this->name = $name;
$this->callable = $callable;
$this->options = array_merge(array(
@@ -121,3 +125,6 @@ class Twig_Function
return $this->options['alternative'];
}
}
// For Twig 1.x compatibility
class_alias('Twig_Function', 'Twig_SimpleFunction', false);
+1 -1
View File
@@ -19,7 +19,7 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @final since 2.4.0
* @final since version 2.4.0
*/
class Twig_Node_Module extends Twig_Node
{
+1 -1
View File
@@ -12,7 +12,7 @@
/**
* @author Fabien Potencier <fabien@symfony.com>
*
* @final
* @final since version 2.4.0
*/
class Twig_Profiler_Profile implements IteratorAggregate, Serializable
{
+7 -3
View File
@@ -10,8 +10,12 @@
*/
/**
* Empty class for Twig 1.x compatibility.
* For Twig 1.x compatibility.
*/
final class Twig_SimpleFilter extends Twig_Filter
{
require __DIR__.'/Filter.php';
if (false) {
final class Twig_SimpleFilter extends Twig_Filter
{
}
}
+7 -3
View File
@@ -10,8 +10,12 @@
*/
/**
* Empty class for Twig 1.x compatibility.
* For Twig 1.x compatibility.
*/
final class Twig_SimpleFunction extends Twig_Function
{
require __DIR__.'/Function.php';
if (false) {
final class Twig_SimpleFunction extends Twig_Function
{
}
}
+7 -3
View File
@@ -10,8 +10,12 @@
*/
/**
* Empty class for Twig 1.x compatibility.
* For Twig 1.x compatibility.
*/
final class Twig_SimpleTest extends Twig_Test
{
require __DIR__.'/Test.php';
if (false) {
final class Twig_SimpleTest extends Twig_Test
{
}
}
+4 -1
View File
@@ -12,7 +12,7 @@
/**
* Represents a template test.
*
* @final
* @final since version 2.4.0
*
* @author Fabien Potencier <fabien@symfony.com>
*
@@ -87,3 +87,6 @@ class Twig_Test
return $this->options['alternative'];
}
}
// For Twig 1.x compatibility
class_alias('Twig_Test', 'Twig_SimpleTest', false);