[FEATURE] Replace @transient with @Extbase\ORM\Transient 60/54760/5
authorAlexander Schnitzler <git@alexanderschnitzler.de>
Sat, 25 Nov 2017 13:13:29 +0000 (14:13 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 27 Nov 2017 15:37:28 +0000 (16:37 +0100)
This patch introduces the "TYPO3\CMS\Extbase\Annotation\ORM\Transient"
annotation that replaces the @transient annotation which is
deprecated from now on.

Releases: master
Resolves: #83092
Change-Id: Ib678b5e1b9d0c3034962b9c708d84b0a3c6b0671
Reviewed-on: https://review.typo3.org/54760
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Documentation/Changelog/master/Deprecation-83092-ReplaceTransientWithTYPO3CMSExtbaseAnnotationORMTransient.rst [new file with mode: 0644]
typo3/sysext/core/Documentation/Changelog/master/Feature-83092-ReplaceTransientWithTYPO3CMSExtbaseAnnotationORMTransient.rst [new file with mode: 0644]
typo3/sysext/extbase/Classes/Annotation/ORM/Transient.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Reflection/ClassSchema.php
typo3/sysext/extbase/Tests/Unit/Reflection/Fixture/DummyClassWithAllTypesOfProperties.php
typo3/sysext/extbase/Tests/UnitDeprecated/Reflection/Fixture/DummyClassWithAllTypesOfProperties.php [new file with mode: 0644]
typo3/sysext/install/Configuration/ExtensionScanner/Php/PropertyAnnotationMatcher.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-83092-ReplaceTransientWithTYPO3CMSExtbaseAnnotationORMTransient.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-83092-ReplaceTransientWithTYPO3CMSExtbaseAnnotationORMTransient.rst
new file mode 100644 (file)
index 0000000..47e4eda
--- /dev/null
@@ -0,0 +1,32 @@
+.. include:: ../../Includes.txt
+
+=========================================================================================
+Deprecation: #83092 - Replace @transient with @TYPO3\CMS\Extbase\Annotation\ORM\Transient
+=========================================================================================
+
+See :issue:`83092`
+
+Description
+===========
+
+The `@transient` annotation has been deprecated and must be replaced with the doctrine annotation `@TYPO3\CMS\Extbase\Annotation\ORM\Transient`.
+
+
+Impact
+======
+
+From version 9.0 on, `@transient` is deprecated and will be removed in version 10.
+
+
+Affected Installations
+======================
+
+All extensions that use `@transient`
+
+
+Migration
+=========
+
+Use `@TYPO3\CMS\Extbase\Annotation\ORM\Transient` instead.
+
+.. index:: PHP-API, ext:extbase, FullyScanned
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-83092-ReplaceTransientWithTYPO3CMSExtbaseAnnotationORMTransient.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-83092-ReplaceTransientWithTYPO3CMSExtbaseAnnotationORMTransient.rst
new file mode 100644 (file)
index 0000000..0bf08ad
--- /dev/null
@@ -0,0 +1,59 @@
+.. include:: ../../Includes.txt
+
+=====================================================================================
+Feature: #83092 - Replace @transient with @TYPO3\CMS\Extbase\Annotation\ORM\Transient
+=====================================================================================
+
+See :issue:`83092`
+
+Description
+===========
+
+As a successor to the `@transient` annotation, the doctrine annotation `@TYPO3\CMS\Extbase\Annotation\ORM\Transient` has been introduced.
+
+Example:
+
+.. code-block:: php
+
+       /**
+        * @TYPO3\CMS\Extbase\Annotation\ORM\Transient
+        */
+       public $property;
+
+Doctrine annotations are actual defined classes, therefore you can also use the annotation with a use statement.
+
+Example:
+
+.. code-block:: php
+
+       use TYPO3\CMS\Extbase\Annotation\ORM\Transient;
+
+.. code-block:: php
+
+       /**
+        * @Transient
+        */
+       public $property;
+
+Used annotations can also be aliased which the core will most likely be using a lot in the future.
+
+Example:
+
+.. code-block:: php
+
+       use TYPO3\CMS\Extbase\Annotation as Extbase;
+
+.. code-block:: php
+
+       /**
+        * @Extbase\ORM\Transient
+        */
+       public $property;
+
+
+Impact
+======
+
+In 9.x there is no actual impact. Both the simple `@transient` and `@TYPO3\CMS\Extbase\Annotation\ORM\Transient` can be used side by side. However, `@transient` is deprecated in 9.x and will be removed in version 10.
+
+.. index:: PHP-API, ext:extbase, FullyScanned
diff --git a/typo3/sysext/extbase/Classes/Annotation/ORM/Transient.php b/typo3/sysext/extbase/Classes/Annotation/ORM/Transient.php
new file mode 100644 (file)
index 0000000..38c7335
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+declare(strict_types=1);
+
+namespace TYPO3\CMS\Extbase\Annotation\ORM;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * @Annotation
+ * @Target({"PROPERTY"})
+ */
+class Transient
+{
+}
index 7d21804..00e488a 100644 (file)
@@ -19,6 +19,7 @@ use TYPO3\CMS\Core\SingletonInterface;
 use TYPO3\CMS\Core\Utility\ClassNamingUtility;
 use TYPO3\CMS\Extbase\Annotation\Inject;
 use TYPO3\CMS\Extbase\Annotation\ORM\Lazy;
+use TYPO3\CMS\Extbase\Annotation\ORM\Transient;
 use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
 use TYPO3\CMS\Extbase\DomainObject\AbstractValueObject;
 use TYPO3\CMS\Extbase\Utility\TypeHandlingUtility;
@@ -172,12 +173,12 @@ class ClassSchema
 
             $this->properties[$propertyName]['annotations']['inject'] = false;
             $this->properties[$propertyName]['annotations']['lazy'] = false;
-            $this->properties[$propertyName]['annotations']['transient'] = $docCommentParser->isTaggedWith('transient');
+            $this->properties[$propertyName]['annotations']['transient'] = false;
             $this->properties[$propertyName]['annotations']['type'] = null;
             $this->properties[$propertyName]['annotations']['cascade'] = null;
             $this->properties[$propertyName]['annotations']['dependency'] = null;
 
-            if (($annotation = $annotationReader->getPropertyAnnotation($reflectionProperty, Lazy::class)) instanceof Lazy) {
+            if ($annotationReader->getPropertyAnnotation($reflectionProperty, Lazy::class) instanceof Lazy) {
                 $this->properties[$propertyName]['annotations']['lazy'] = true;
             }
 
@@ -189,8 +190,20 @@ class ClassSchema
                 );
             }
 
+            if ($annotationReader->getPropertyAnnotation($reflectionProperty, Transient::class) instanceof Transient) {
+                $this->properties[$propertyName]['annotations']['transient'] = true;
+            }
+
+            if ($docCommentParser->isTaggedWith('transient')) {
+                $this->properties[$propertyName]['annotations']['transient'] = true;
+                trigger_error(
+                    'Tagging properties with @transient is deprecated and will be removed in TYPO3 v10.0.',
+                    E_USER_DEPRECATED
+                );
+            }
+
             if ($propertyName !== 'settings'
-                && ($annotation = $annotationReader->getPropertyAnnotation($reflectionProperty, Inject::class)) instanceof Inject
+                && ($annotationReader->getPropertyAnnotation($reflectionProperty, Inject::class) instanceof Inject)
             ) {
                 try {
                     $varValue = ltrim($docCommentParser->getTagValues('var')[0], '\\');
index 69c9b62..e4fad39 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture;
  */
 
 use TYPO3\CMS\Extbase\Annotation\Inject;
+use TYPO3\CMS\Extbase\Annotation\ORM\Transient;
 
 /**
  * Fixture class with getters and setters
@@ -50,7 +51,7 @@ class DummyClassWithAllTypesOfProperties
     public $propertyWithInjectAnnotation;
 
     /**
-     * @transient
+     * @Transient
      */
     public $propertyWithTransientAnnotation;
 
diff --git a/typo3/sysext/extbase/Tests/UnitDeprecated/Reflection/Fixture/DummyClassWithAllTypesOfProperties.php b/typo3/sysext/extbase/Tests/UnitDeprecated/Reflection/Fixture/DummyClassWithAllTypesOfProperties.php
new file mode 100644 (file)
index 0000000..1ef9b31
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+declare(strict_types=1);
+
+namespace TYPO3\CMS\Extbase\Tests\UnitDeprecated\Reflection\Fixture;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * Fixture class with getters and setters
+ *
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class DummyClassWithAllTypesOfProperties
+{
+    /**
+     * @transient
+     */
+    public $propertyWithTransientAnnotation;
+}
index 663646d..2eebc79 100644 (file)
@@ -12,4 +12,10 @@ return [
             'Deprecation-83078-ReplaceLazyWithTYPO3CMSExtbaseAnnotationORMLazy.rst',
         ],
     ],
+    '@transient' => [
+        'restFiles' => [
+            'Feature-83092-ReplaceTransientWithTYPO3CMSExtbaseAnnotationORMTransient.rst',
+            'Deprecation-83092-ReplaceTransientWithTYPO3CMSExtbaseAnnotationORMTransient.rst',
+        ],
+    ],
 ];