Browse Source

Remove deprecated code.

ADmad 4 years ago
parent
commit
092e2e748e

+ 0 - 6
psalm-baseline.xml

@@ -162,12 +162,6 @@
       <code>$request</code>
     </ArgumentTypeCoercion>
   </file>
-  <file src="src/Routing/Router.php">
-    <DeprecatedMethod occurrences="3">
-      <code>static::scope($path, $params, $callback)</code>
-      <code>static::scope($path, $params, $callback)</code>
-    </DeprecatedMethod>
-  </file>
   <file src="src/TestSuite/Constraint/EventFired.php">
     <InternalClass occurrences="1"/>
     <InternalMethod occurrences="1"/>

+ 0 - 53
src/Network/Socket.php

@@ -518,57 +518,4 @@ class Socket
     {
         return $this->encrypted;
     }
-
-    /**
-     * Temporary magic method to allow accessing protected properties.
-     *
-     * Will be removed in 5.0.
-     *
-     * @param string $name Property name.
-     * @return mixed
-     */
-    public function __get($name)
-    {
-        switch ($name) {
-            case 'connected':
-                deprecationWarning('The property `$connected` is deprecated, use `isConnected()` instead.');
-
-                return $this->connected;
-
-            case 'encrypted':
-                deprecationWarning('The property `$encrypted` is deprecated, use `isEncrypted()` instead.');
-
-                return $this->encrypted;
-
-            case 'lastError':
-                deprecationWarning('The property `$lastError` is deprecated, use `lastError()` instead.');
-
-                return $this->lastError;
-
-            case 'connection':
-                deprecationWarning('The property `$connection` is deprecated.');
-
-                return $this->connection;
-
-            case 'description':
-                deprecationWarning('The CakePHP team would love to know your use case for this property.');
-
-                return 'Remote DataSource Network Socket Interface';
-        }
-
-        $trace = debug_backtrace();
-        $parts = explode('\\', static::class);
-        trigger_error(
-            sprintf(
-                'Undefined property: %s::$%s in %s on line %s',
-                array_pop($parts),
-                $name,
-                $trace[0]['file'],
-                $trace[0]['line']
-            ),
-            E_USER_NOTICE
-        );
-
-        return null;
-    }
 }

+ 0 - 8
src/ORM/Marshaller.php

@@ -256,14 +256,6 @@ class Marshaller
             $validator = $this->_table->getValidator();
         } elseif (is_string($options['validate'])) {
             $validator = $this->_table->getValidator($options['validate']);
-        } elseif (is_object($options['validate'])) {
-            deprecationWarning(
-                'Passing validator instance for the `validate` option is deprecated,'
-                . ' use `ValidatorAwareTrait::setValidator() instead.`'
-            );
-
-            /** @var \Cake\Validation\Validator $validator */
-            $validator = $options['validate'];
         }
 
         if ($validator === null) {

+ 0 - 168
src/Routing/Router.php

@@ -20,7 +20,6 @@ use Cake\Core\Configure;
 use Cake\Http\ServerRequest;
 use Cake\Routing\Exception\MissingRouteException;
 use Cake\Routing\Route\Route;
-use Cake\Utility\Inflector;
 use InvalidArgumentException;
 use Psr\Http\Message\UriInterface;
 use ReflectionFunction;
@@ -193,36 +192,6 @@ class Router
     }
 
     /**
-     * Connects a new Route in the router.
-     *
-     * Compatibility proxy to \Cake\Routing\RouteBuilder::connect() in the `/` scope.
-     *
-     * @param \Cake\Routing\Route\Route|string $route A string describing the template of the route
-     * @param array|string $defaults An array describing the default route parameters.
-     *   These parameters will be used by default and can supply routing parameters that are not dynamic. See above.
-     * @param array<string, mixed> $options An array matching the named elements in the route to regular expressions which that
-     *   element should match. Also contains additional parameters such as which routed parameters should be
-     *   shifted into the passed arguments, supplying patterns for routing parameters and supplying the name of a
-     *   custom routing class.
-     * @return void
-     * @throws \Cake\Core\Exception\CakeException
-     * @see \Cake\Routing\RouteBuilder::connect()
-     * @see \Cake\Routing\Router::scope()
-     * @deprecated 4.3.0 Use the non-static method `RouterBuilder::connect()` instead.
-     */
-    public static function connect(Route|string $route, array|string $defaults = [], array $options = []): void
-    {
-        deprecationWarning(
-            '`Router::connect()` is deprecated, use the non-static method `RouterBuilder::connect()` instead.'
-        );
-
-        static::scope('/', function ($routes) use ($route, $defaults, $options): void {
-            /** @var \Cake\Routing\RouteBuilder $routes */
-            $routes->connect($route, $defaults, $options);
-        });
-    }
-
-    /**
      * Get the routing parameters for the request is possible.
      *
      * @param \Cake\Http\ServerRequest $request The request to parse request data from.
@@ -778,143 +747,6 @@ class Router
     }
 
     /**
-     * Create a routing scope.
-     *
-     * Routing scopes allow you to keep your routes DRY and avoid repeating
-     * common path prefixes, and or parameter sets.
-     *
-     * Scoped collections will be indexed by path for faster route parsing. If you
-     * re-open or re-use a scope the connected routes will be merged with the
-     * existing ones.
-     *
-     * ### Options
-     *
-     * The `$params` array allows you to define options for the routing scope.
-     * The options listed below *are not* available to be used as routing defaults
-     *
-     * - `routeClass` The route class to use in this scope. Defaults to
-     *   `Router::defaultRouteClass()`
-     * - `extensions` The extensions to enable in this scope. Defaults to the globally
-     *   enabled extensions set with `Router::extensions()`
-     *
-     * ### Example
-     *
-     * ```
-     * Router::scope('/blog', ['plugin' => 'Blog'], function ($routes) {
-     *    $routes->connect('/', ['controller' => 'Articles']);
-     * });
-     * ```
-     *
-     * The above would result in a `/blog/` route being created, with both the
-     * plugin & controller default parameters set.
-     *
-     * You can use `Router::plugin()` and `Router::prefix()` as shortcuts to creating
-     * specific kinds of scopes.
-     *
-     * @param string $path The path prefix for the scope. This path will be prepended
-     *   to all routes connected in the scoped collection.
-     * @param callable|array $params An array of routing defaults to add to each connected route.
-     *   If you have no parameters, this argument can be a callable.
-     * @param callable|null $callback The callback to invoke with the scoped collection.
-     * @throws \InvalidArgumentException When an invalid callable is provided.
-     * @return void
-     * @deprecated 4.3.0 Use the non-static method `RouterBuilder::scope()` instead.
-     */
-    public static function scope(string $path, callable|array $params = [], ?callable $callback = null): void
-    {
-        deprecationWarning(
-            '`Router::scope()` is deprecated, use the non-static method `RouterBuilder::scope()` instead.'
-        );
-
-        $options = [];
-        if (is_array($params)) {
-            $options = $params;
-            unset($params['routeClass'], $params['extensions']);
-        }
-        $builder = static::createRouteBuilder('/', $options);
-        $builder->scope($path, $params, $callback);
-    }
-
-    /**
-     * Create prefixed routes.
-     *
-     * This method creates a scoped route collection that includes
-     * relevant prefix information.
-     *
-     * The path parameter is used to generate the routing parameter name.
-     * For example a path of `admin` would result in `'prefix' => 'Admin'` being
-     * applied to all connected routes.
-     *
-     * The prefix name will be inflected to the dasherized version to create
-     * the routing path. If you want a custom path name, use the `path` option.
-     *
-     * You can re-open a prefix as many times as necessary, as well as nest prefixes.
-     * Nested prefixes will result in prefix values like `Admin/Api` which translates
-     * to the `Controller\Admin\Api\` namespace.
-     *
-     * @param string $name The prefix name to use.
-     * @param callable|array $params An array of routing defaults to add to each connected route.
-     *   If you have no parameters, this argument can be a callable.
-     * @param callable|null $callback The callback to invoke that builds the prefixed routes.
-     * @return void
-     * @deprecated 4.3.0 Use the non-static method `RouterBuilder::prefix()` instead.
-     */
-    public static function prefix(string $name, callable|array $params = [], ?callable $callback = null): void
-    {
-        deprecationWarning(
-            '`Router::prefix()` is deprecated, use the non-static method `RouterBuilder::prefix()` instead.'
-        );
-
-        if (!is_array($params)) {
-            $callback = $params;
-            $params = [];
-        }
-
-        $path = $params['path'] ?? '/' . Inflector::dasherize($name);
-        unset($params['path']);
-
-        $params = array_merge($params, ['prefix' => Inflector::camelize($name)]);
-        static::scope($path, $params, $callback);
-    }
-
-    /**
-     * Add plugin routes.
-     *
-     * This method creates a scoped route collection that includes
-     * relevant plugin information.
-     *
-     * The plugin name will be inflected to the dasherized version to create
-     * the routing path. If you want a custom path name, use the `path` option.
-     *
-     * Routes connected in the scoped collection will have the correct path segment
-     * prepended, and have a matching plugin routing key set.
-     *
-     * @param string $name The plugin name to build routes for
-     * @param callable|array $options Either the options to use, or a callback
-     * @param callable|null $callback The callback to invoke that builds the plugin routes.
-     *   Only required when $options is defined
-     * @return void
-     * @deprecated 4.3.0 Use the non-static method `RouterBuilder::plugin()` instead.
-     */
-    public static function plugin(string $name, callable|array $options = [], ?callable $callback = null): void
-    {
-        deprecationWarning(
-            '`Router::plugin()` is deprecated, use the non-static method `RouterBuilder::plugin()` instead.'
-        );
-
-        if (!is_array($options)) {
-            $callback = $options;
-            $options = [];
-        }
-        $params = ['plugin' => $name];
-        $path = $options['path'] ?? '/' . Inflector::dasherize($name);
-        if (isset($options['_namePrefix'])) {
-            $params['_namePrefix'] = $options['_namePrefix'];
-        }
-        static::scope($path, $params, $callback);
-    }
-
-    /**
      * Get the route scopes and their connected routes.
      *
      * @return array<\Cake\Routing\Route\Route>

+ 0 - 12
tests/TestCase/Network/SocketTest.php

@@ -492,16 +492,4 @@ class SocketTest extends TestCase
         ]);
         $socket->connect();
     }
-
-    /**
-     * @return void
-     * @deprecated
-     */
-    public function testDeprecatedProps()
-    {
-        $this->deprecated(function () {
-            $this->assertFalse($this->Socket->connected);
-            $this->assertFalse($this->Socket->encrypted);
-        });
-    }
 }

+ 0 - 21
tests/TestCase/ORM/MarshallerTest.php

@@ -2837,27 +2837,6 @@ class MarshallerTest extends TestCase
     }
 
     /**
-     * Tests that it is possible to pass a validator directly in the options
-     *
-     * @deprecated
-     */
-    public function testPassingCustomValidator(): void
-    {
-        $this->deprecated(function () {
-            $data = [
-                'title' => 'Thing',
-                'body' => 'hey',
-            ];
-
-            $validator = clone $this->articles->getValidator();
-            $validator->requirePresence('thing');
-            $marshall = new Marshaller($this->articles);
-            $entity = $marshall->one($data, ['validate' => $validator]);
-            $this->assertNotEmpty($entity->getError('thing'));
-        });
-    }
-
-    /**
      * Tests that invalid property is being filled when data cannot be patched into an entity.
      */
     public function testValidationWithInvalidFilled(): void

File diff suppressed because it is too large
+ 295 - 201
tests/TestCase/Routing/RouterTest.php


+ 7 - 9
tests/TestCase/View/Helper/TimeHelperTest.php

@@ -530,15 +530,13 @@ class TimeHelperTest extends TestCase
      */
     public function testFormatTimeInstance(): void
     {
-        $this->deprecated(function () {
-            $time = new DateTime('2010-01-14 13:59:28', 'America/New_York');
-            $result = $this->Time->format($time, 'HH:mm', false, 'America/New_York');
-            $this->assertTimeFormat('13:59', $result);
-
-            $time = new DateTime('2010-01-14 13:59:28', 'UTC');
-            $result = $this->Time->format($time, 'HH:mm', false, 'America/New_York');
-            $this->assertTimeFormat('08:59', $result);
-        });
+        $time = new DateTime('2010-01-14 13:59:28', 'America/New_York');
+        $result = $this->Time->format($time, 'HH:mm', false, 'America/New_York');
+        $this->assertTimeFormat('13:59', $result);
+
+        $time = new DateTime('2010-01-14 13:59:28', 'UTC');
+        $result = $this->Time->format($time, 'HH:mm', false, 'America/New_York');
+        $this->assertTimeFormat('08:59', $result);
     }
 
     /**