Browse Source

Merge pull request #12703 from cakephp/deprecation-cleanup

Remove deprecated code from 4.x
Mark Story 7 years ago
parent
commit
4e5a90667f

+ 0 - 17
src/Core/Plugin.php

@@ -122,23 +122,6 @@ class Plugin
     }
 
     /**
-     * Forgets a loaded plugin or all of them if first parameter is null
-     *
-     * @param string|null $plugin name of the plugin to forget
-     * @deprecated 3.7 This method will be removed in 4.0.0. Use PluginCollection::remove() or clear() instead.
-     * @return void
-     */
-    public static function unload(?string $plugin = null): void
-    {
-        deprecationWarning('Plugin::unload() will be removed in 4.0. Use PluginCollection::remove() or clear()');
-        if ($plugin === null) {
-            static::getCollection()->clear();
-        } else {
-            static::getCollection()->remove($plugin);
-        }
-    }
-
-    /**
      * Get the shared plugin collection.
      *
      * This method should generally not be used during application

+ 22 - 22
src/Http/Middleware/SecurityHeadersMiddleware.php

@@ -25,70 +25,70 @@ use Psr\Http\Message\ServerRequestInterface;
 class SecurityHeadersMiddleware
 {
     /** @var string X-Content-Type-Option nosniff */
-    const NOSNIFF = 'nosniff';
+    public const NOSNIFF = 'nosniff';
 
     /** @var string X-Download-Option noopen */
-    const NOOPEN = 'noopen';
+    public const NOOPEN = 'noopen';
 
     /** @var string Referrer-Policy no-referrer */
-    const NO_REFERRER = 'no-referrer';
+    public const NO_REFERRER = 'no-referrer';
 
     /** @var string Referrer-Policy no-referrer-when-downgrade */
-    const NO_REFERRER_WHEN_DOWNGRADE = 'no-referrer-when-downgrade';
+    public const NO_REFERRER_WHEN_DOWNGRADE = 'no-referrer-when-downgrade';
 
     /** @var string Referrer-Policy origin */
-    const ORIGIN = 'origin';
+    public const ORIGIN = 'origin';
 
     /** @var string Referrer-Policy origin-when-cross-origin */
-    const ORIGIN_WHEN_CROSS_ORIGIN = 'origin-when-cross-origin';
+    public const ORIGIN_WHEN_CROSS_ORIGIN = 'origin-when-cross-origin';
 
     /** @var string Referrer-Policy same-origin */
-    const SAME_ORIGIN = 'same-origin';
+    public const SAME_ORIGIN = 'same-origin';
 
     /** @var string Referrer-Policy strict-origin */
-    const STRICT_ORIGIN = 'strict-origin';
+    public const STRICT_ORIGIN = 'strict-origin';
 
     /** @var string Referrer-Policy strict-origin-when-cross-origin */
-    const STRICT_ORIGIN_WHEN_CROSS_ORIGIN = 'strict-origin-when-cross-origin';
+    public const STRICT_ORIGIN_WHEN_CROSS_ORIGIN = 'strict-origin-when-cross-origin';
 
     /** @var string Referrer-Policy unsafe-url */
-    const UNSAFE_URL = 'unsafe-url';
+    public const UNSAFE_URL = 'unsafe-url';
 
     /** @var string X-Frame-Option deny */
-    const DENY = 'deny';
+    public const DENY = 'deny';
 
     /** @var string X-Frame-Option sameorigin */
-    const SAMEORIGIN = 'sameorigin';
+    public const SAMEORIGIN = 'sameorigin';
 
     /** @var string X-Frame-Option allow-from */
-    const ALLOW_FROM = 'allow-from';
+    public const ALLOW_FROM = 'allow-from';
 
     /** @var string X-XSS-Protection block, sets enabled with block */
-    const XSS_BLOCK = 'block';
+    public const XSS_BLOCK = 'block';
 
     /** @var string X-XSS-Protection enabled with block */
-    const XSS_ENABLED_BLOCK = '1; mode=block';
+    public const XSS_ENABLED_BLOCK = '1; mode=block';
 
     /** @var string X-XSS-Protection enabled */
-    const XSS_ENABLED = '1';
+    public const XSS_ENABLED = '1';
 
     /** @var string X-XSS-Protection disabled */
-    const XSS_DISABLED = '0';
+    public const XSS_DISABLED = '0';
 
     /** @var string X-Permitted-Cross-Domain-Policy all */
-    const ALL = 'all';
+    public const ALL = 'all';
 
     /** @var string X-Permitted-Cross-Domain-Policy none */
-    const NONE = 'none';
+    public const NONE = 'none';
 
     /** @var string X-Permitted-Cross-Domain-Policy master-only */
-    const MASTER_ONLY = 'master-only';
+    public const MASTER_ONLY = 'master-only';
 
     /** @var string X-Permitted-Cross-Domain-Policy by-content-type */
-    const BY_CONTENT_TYPE = 'by-content-type';
+    public const BY_CONTENT_TYPE = 'by-content-type';
 
     /** @var string X-Permitted-Cross-Domain-Policy by-ftp-filename */
-    const BY_FTP_FILENAME = 'by-ftp-filename';
+    public const BY_FTP_FILENAME = 'by-ftp-filename';
 
     /**
      * Security related headers to set

+ 0 - 124
src/Mailer/Email.php

@@ -1007,68 +1007,6 @@ class Email implements JsonSerializable, Serializable
     }
 
     /**
-     * Sets template.
-     *
-     * @param string|null $template Template name or null to not use.
-     * @return $this
-     */
-    public function setTemplate(?string $template): self
-    {
-        deprecationWarning(
-            'Email::setTemplate() is deprecated. Use $email->viewBuilder()->setTemplate() instead.'
-        );
-
-        $this->viewBuilder()->setTemplate($template ?: '');
-
-        return $this;
-    }
-
-    /**
-     * Gets template.
-     *
-     * @return string
-     */
-    public function getTemplate(): string
-    {
-        deprecationWarning(
-            'Email::getTemplate() is deprecated. Use $email->viewBuilder()->getTemplate() instead.'
-        );
-
-        return $this->viewBuilder()->getTemplate();
-    }
-
-    /**
-     * Sets layout.
-     *
-     * @param string|null $layout Layout name or null to not use
-     * @return $this
-     */
-    public function setLayout(?string $layout): self
-    {
-        deprecationWarning(
-            'Email::setLayout() is deprecated. Use $email->viewBuilder()->setLayout() instead.'
-        );
-
-        $this->viewBuilder()->setLayout($layout ?: false);
-
-        return $this;
-    }
-
-    /**
-     * Gets layout.
-     *
-     * @return string|null|false
-     */
-    public function getLayout()
-    {
-        deprecationWarning(
-            'Email::getLayout() is deprecated. Use $email->viewBuilder()->getLayout() instead.'
-        );
-
-        return $this->viewBuilder()->getLayout();
-    }
-
-    /**
      * Sets view class for render.
      *
      * @param string $viewClass View class name.
@@ -1115,68 +1053,6 @@ class Email implements JsonSerializable, Serializable
     }
 
     /**
-     * Sets theme to use when rendering.
-     *
-     * @param string|null $theme Theme name.
-     * @return $this
-     */
-    public function setTheme(?string $theme): self
-    {
-        deprecationWarning(
-            'Email::setTheme() is deprecated. Use $email->viewBuilder()->setTheme() instead.'
-        );
-
-        $this->viewBuilder()->setTheme($theme);
-
-        return $this;
-    }
-
-    /**
-     * Gets theme to use when rendering.
-     *
-     * @return string|null
-     */
-    public function getTheme(): ?string
-    {
-        deprecationWarning(
-            'Email::getTheme() is deprecated. Use $email->viewBuilder()->getTheme() instead.'
-        );
-
-        return $this->viewBuilder()->getTheme();
-    }
-
-    /**
-     * Sets helpers to be used when rendering.
-     *
-     * @param array $helpers Helpers list.
-     * @return $this
-     */
-    public function setHelpers(array $helpers): self
-    {
-        deprecationWarning(
-            'Email::setHelpers() is deprecated. Use $email->viewBuilder()->setHelpers() instead.'
-        );
-
-        $this->viewBuilder()->setHelpers($helpers, false);
-
-        return $this;
-    }
-
-    /**
-     * Gets helpers to be used when rendering.
-     *
-     * @return array
-     */
-    public function getHelpers(): array
-    {
-        deprecationWarning(
-            'Email::getHelpers() is deprecated. Use $email->viewBuilder()->getHelpers() instead.'
-        );
-
-        return $this->viewBuilder()->getHelpers();
-    }
-
-    /**
      * Sets email format.
      *
      * @param string $format Formatting string.

+ 3 - 2
src/ORM/Table.php

@@ -151,14 +151,14 @@ class Table implements RepositoryInterface, EventListenerInterface, EventDispatc
      *
      * @var string
      */
-    const RULES_CLASS = RulesChecker::class;
+    public const RULES_CLASS = RulesChecker::class;
 
     /**
      * The IsUnique class name that is used.
      *
      * @var string
      */
-    const IS_UNIQUE_CLASS = IsUnique::class;
+    public const IS_UNIQUE_CLASS = IsUnique::class;
 
     /**
      * Name of the table as it can be found in the database
@@ -2613,6 +2613,7 @@ class Table implements RepositoryInterface, EventListenerInterface, EventDispatc
             }
         }
         $class = static::IS_UNIQUE_CLASS;
+        /** @var \Cake\ORM\Rule\IsUnique $rule */
         $rule = new $class($fields, $options);
 
         return $rule($entity, ['repository' => $this]);

+ 5 - 5
src/ORM/TableRegistry.php

@@ -97,7 +97,7 @@ class TableRegistry
      * @param string $alias The alias name you want to get.
      * @param array $options The options you want to build the table with.
      * @return \Cake\ORM\Table
-     * @deprecated 3.6.0 Use \Cake\ORM\Locator\TableLocator::get() instead.
+     * @deprecated 3.6.0 Use \Cake\ORM\Locator\TableLocator::get() instead. Will be removed in 5.0
      */
     public static function get(string $alias, array $options = []): Table
     {
@@ -109,7 +109,7 @@ class TableRegistry
      *
      * @param string $alias The alias to check for.
      * @return bool
-     * @deprecated 3.6.0 Use \Cake\ORM\Locator\TableLocator::exists() instead.
+     * @deprecated 3.6.0 Use \Cake\ORM\Locator\TableLocator::exists() instead. Will be removed in 5.0
      */
     public static function exists(string $alias): bool
     {
@@ -122,7 +122,7 @@ class TableRegistry
      * @param string $alias The alias to set.
      * @param \Cake\ORM\Table $object The table to set.
      * @return \Cake\ORM\Table
-     * @deprecated 3.6.0 Use \Cake\ORM\Locator\TableLocator::set() instead.
+     * @deprecated 3.6.0 Use \Cake\ORM\Locator\TableLocator::set() instead. Will be removed in 5.0
      */
     public static function set(string $alias, Table $object): Table
     {
@@ -134,7 +134,7 @@ class TableRegistry
      *
      * @param string $alias The alias to remove.
      * @return void
-     * @deprecated 3.6.0 Use \Cake\ORM\Locator\TableLocator::remove() instead.
+     * @deprecated 3.6.0 Use \Cake\ORM\Locator\TableLocator::remove() instead. Will be removed in 5.0
      */
     public static function remove(string $alias): void
     {
@@ -145,7 +145,7 @@ class TableRegistry
      * Clears the registry of configuration and instances.
      *
      * @return void
-     * @deprecated 3.6.0 Use \Cake\ORM\Locator\TableLocator::clear() instead.
+     * @deprecated 3.6.0 Use \Cake\ORM\Locator\TableLocator::clear() instead. Will be removed in 5.0
      */
     public static function clear(): void
     {

+ 2 - 3
tests/TestCase/Collection/CollectionTest.php

@@ -21,7 +21,6 @@ use Cake\Collection\Collection;
 use Cake\Collection\CollectionInterface;
 use Cake\Collection\CollectionTrait;
 use Cake\ORM\Entity;
-use Cake\ORM\ResultSet;
 use Cake\TestSuite\TestCase;
 use NoRewindIterator;
 
@@ -715,7 +714,7 @@ class CollectionTest extends TestCase
             new Entity(['id' => 2, 'count' => 9]),
             new Entity(['id' => 3, 'count' => 42]),
             new Entity(['id' => 4, 'count' => 4]),
-            new Entity(['id' => 5, 'count' => 22])
+            new Entity(['id' => 5, 'count' => 22]),
         ]);
 
         $expected = new Entity(['id' => 3, 'count' => 42]);
@@ -747,7 +746,7 @@ class CollectionTest extends TestCase
             new Entity(['id' => 2, 'count' => 9]),
             new Entity(['id' => 3, 'count' => 42]),
             new Entity(['id' => 4, 'count' => 4]),
-            new Entity(['id' => 5, 'count' => 22])
+            new Entity(['id' => 5, 'count' => 22]),
         ]);
 
         $expected = new Entity(['id' => 4, 'count' => 4]);

+ 0 - 28
tests/TestCase/Core/PluginTest.php

@@ -71,34 +71,6 @@ class PluginTest extends TestCase
     }
 
     /**
-     * Tests unloading plugins
-     *
-     * @deprecated
-     * @return void
-     */
-    public function testUnload()
-    {
-        $this->deprecated(function () {
-            $this->loadPlugins(['TestPlugin' => ['bootstrap' => false, 'routes' => false]]);
-            $expected = ['TestPlugin'];
-            $this->assertEquals($expected, Plugin::loaded());
-            $this->assertTrue(Plugin::isLoaded('TestPlugin'));
-
-            Plugin::unload('TestPlugin');
-            $this->assertEquals([], Plugin::loaded());
-            $this->assertFalse(Plugin::isLoaded('TestPlugin'));
-
-            $this->loadPlugins(['TestPlugin' => ['bootstrap' => false, 'routes' => false]]);
-            $expected = ['TestPlugin'];
-            $this->assertEquals($expected, Plugin::loaded());
-
-            Plugin::unload('TestFakePlugin');
-            $this->assertEquals($expected, Plugin::loaded());
-            $this->assertFalse(Plugin::isLoaded('TestFakePlugin'));
-        });
-    }
-
-    /**
      * Tests that Plugin::path() returns the correct path for the loaded plugins
      *
      * @return void

+ 1 - 1
tests/TestCase/Error/Middleware/ErrorHandlerMiddlewareTest.php

@@ -243,7 +243,7 @@ class ErrorHandlerMiddlewareTest extends TestCase
 
         $request = ServerRequestFactory::fromGlobals([
             'REQUEST_URI' => '/target/url',
-            'HTTP_REFERER' => '/other/path'
+            'HTTP_REFERER' => '/other/path',
         ]);
         $response = new Response();
         $middleware = new ErrorHandlerMiddleware(null, ['log' => true, 'trace' => true]);

+ 1 - 2
tests/TestCase/ORM/ResultSetTest.php

@@ -22,7 +22,6 @@ use Cake\ORM\Entity;
 use Cake\ORM\ResultSet;
 use Cake\ORM\Table;
 use Cake\TestSuite\TestCase;
-use TestApp\Model\Entity\Article;
 
 /**
  * ResultSet test case.
@@ -447,7 +446,7 @@ class ResultSetTest extends TestCase
     {
         $query = $this->table->find();
         $query->select([
-            'counter' => 'COUNT(*)'
+            'counter' => 'COUNT(*)',
         ])->group('author_id');
 
         $min = $query->min('counter');