Skip to content

Commit

Permalink
added #[\ReturnTypeWillChange]
Browse files Browse the repository at this point in the history
  • Loading branch information
sfilatov-idt committed Oct 23, 2023
1 parent 7d31d30 commit b42de67
Show file tree
Hide file tree
Showing 42 changed files with 319 additions and 1 deletion.
25 changes: 25 additions & 0 deletions Slim/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public function __construct($container = [])
*
* @return ContainerInterface
*/
#[\ReturnTypeWillChange]
public function getContainer()
{
return $this->container;
Expand All @@ -85,6 +86,7 @@ public function getContainer()
*
* @return static
*/
#[\ReturnTypeWillChange]
public function add($callable)
{
return $this->addMiddleware(new DeferredCallable($callable, $this->container));
Expand All @@ -101,6 +103,7 @@ public function add($callable)
*
* @throws BadMethodCallException
*/
#[\ReturnTypeWillChange]
public function __call($method, $args)
{
if ($this->container->has($method)) {
Expand All @@ -121,6 +124,7 @@ public function __call($method, $args)
*
* @return RouteInterface
*/
#[\ReturnTypeWillChange]
public function get($pattern, $callable)
{
return $this->map(['GET'], $pattern, $callable);
Expand All @@ -134,6 +138,7 @@ public function get($pattern, $callable)
*
* @return RouteInterface
*/
#[\ReturnTypeWillChange]
public function post($pattern, $callable)
{
return $this->map(['POST'], $pattern, $callable);
Expand All @@ -147,6 +152,7 @@ public function post($pattern, $callable)
*
* @return RouteInterface
*/
#[\ReturnTypeWillChange]
public function put($pattern, $callable)
{
return $this->map(['PUT'], $pattern, $callable);
Expand All @@ -160,6 +166,7 @@ public function put($pattern, $callable)
*
* @return RouteInterface
*/
#[\ReturnTypeWillChange]
public function patch($pattern, $callable)
{
return $this->map(['PATCH'], $pattern, $callable);
Expand All @@ -173,6 +180,7 @@ public function patch($pattern, $callable)
*
* @return RouteInterface
*/
#[\ReturnTypeWillChange]
public function delete($pattern, $callable)
{
return $this->map(['DELETE'], $pattern, $callable);
Expand All @@ -186,6 +194,7 @@ public function delete($pattern, $callable)
*
* @return RouteInterface
*/
#[\ReturnTypeWillChange]
public function options($pattern, $callable)
{
return $this->map(['OPTIONS'], $pattern, $callable);
Expand All @@ -199,6 +208,7 @@ public function options($pattern, $callable)
*
* @return RouteInterface
*/
#[\ReturnTypeWillChange]
public function any($pattern, $callable)
{
return $this->map(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'], $pattern, $callable);
Expand All @@ -213,6 +223,7 @@ public function any($pattern, $callable)
*
* @return RouteInterface
*/
#[\ReturnTypeWillChange]
public function map(array $methods, $pattern, $callable)
{
if ($callable instanceof Closure) {
Expand Down Expand Up @@ -240,6 +251,7 @@ public function map(array $methods, $pattern, $callable)
*
* @return RouteInterface
*/
#[\ReturnTypeWillChange]
public function redirect($from, $to, $status = 302)
{
$handler = function ($request, ResponseInterface $response) use ($to, $status) {
Expand All @@ -261,6 +273,7 @@ public function redirect($from, $to, $status = 302)
*
* @return RouteGroupInterface
*/
#[\ReturnTypeWillChange]
public function group($pattern, $callable)
{
/** @var RouterInterface $router */
Expand Down Expand Up @@ -288,6 +301,7 @@ public function group($pattern, $callable)
* @throws Exception
* @throws Throwable
*/
#[\ReturnTypeWillChange]
public function run($silent = false)
{
$response = $this->container->get('response');
Expand Down Expand Up @@ -338,6 +352,7 @@ public function run($silent = false)
*
* @throws ContainerException
*/
#[\ReturnTypeWillChange]
protected function processInvalidMethod(ServerRequestInterface $request, ResponseInterface $response)
{
$router = $this->container->get('router');
Expand Down Expand Up @@ -373,6 +388,7 @@ protected function processInvalidMethod(ServerRequestInterface $request, Respons
* @throws Exception
* @throws Throwable
*/
#[\ReturnTypeWillChange]
public function process(ServerRequestInterface $request, ResponseInterface $response)
{
// Ensure basePath is set
Expand Down Expand Up @@ -404,6 +420,7 @@ public function process(ServerRequestInterface $request, ResponseInterface $resp
*
* @param ResponseInterface $response
*/
#[\ReturnTypeWillChange]
public function respond(ResponseInterface $response)
{
// Send response
Expand Down Expand Up @@ -484,6 +501,7 @@ public function respond(ResponseInterface $response)
* @throws MethodNotAllowedException
* @throws NotFoundException
*/
#[\ReturnTypeWillChange]
public function __invoke(ServerRequestInterface $request, ResponseInterface $response)
{
// Get the route info
Expand Down Expand Up @@ -540,6 +558,7 @@ public function __invoke(ServerRequestInterface $request, ResponseInterface $res
* @throws MethodNotAllowedException
* @throws NotFoundException
*/
#[\ReturnTypeWillChange]
public function subRequest(
$method,
$path,
Expand Down Expand Up @@ -573,6 +592,7 @@ public function subRequest(
*
* @return ServerRequestInterface
*/
#[\ReturnTypeWillChange]
protected function dispatchRouterAndPrepareRoute(ServerRequestInterface $request, RouterInterface $router)
{
$routeInfo = $router->dispatch($request);
Expand Down Expand Up @@ -604,6 +624,7 @@ protected function dispatchRouterAndPrepareRoute(ServerRequestInterface $request
*
* @throws RuntimeException
*/
#[\ReturnTypeWillChange]
protected function finalize(ResponseInterface $response)
{
// stop PHP sending a Content-Type automatically
Expand Down Expand Up @@ -645,6 +666,7 @@ protected function finalize(ResponseInterface $response)
*
* @return bool
*/
#[\ReturnTypeWillChange]
protected function isEmptyResponse(ResponseInterface $response)
{
if (method_exists($response, 'isEmpty')) {
Expand All @@ -661,6 +683,7 @@ protected function isEmptyResponse(ResponseInterface $response)
*
* @return bool
*/
#[\ReturnTypeWillChange]
protected function isHeadRequest(RequestInterface $request)
{
$method = $request->getMethod();
Expand All @@ -679,6 +702,7 @@ protected function isHeadRequest(RequestInterface $request)
*
* @throws Exception If a handler is needed and not found
*/
#[\ReturnTypeWillChange]
protected function handleException(Exception $e, ServerRequestInterface $request, ResponseInterface $response)
{
if ($e instanceof MethodNotAllowedException) {
Expand Down Expand Up @@ -718,6 +742,7 @@ protected function handleException(Exception $e, ServerRequestInterface $request
*
* @throws Throwable
*/
#[\ReturnTypeWillChange]
protected function handlePhpError(Throwable $e, ServerRequestInterface $request, ResponseInterface $response)
{
$handler = 'phpErrorHandler';
Expand Down
4 changes: 4 additions & 0 deletions Slim/CallableResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function __construct(ContainerInterface $container)
* @throws RuntimeException If the callable does not exist
* @throws RuntimeException If the callable is not resolvable
*/
#[\ReturnTypeWillChange]
public function resolve($toResolve)
{
if (is_callable($toResolve)) {
Expand All @@ -69,6 +70,7 @@ public function resolve($toResolve)
*
* @return array
*/
#[\ReturnTypeWillChange]
protected function parseCallable($toResolve)
{
if (preg_match(self::CALLABLE_PATTERN, $toResolve, $matches)) {
Expand All @@ -89,6 +91,7 @@ protected function parseCallable($toResolve)
*
* @throws RuntimeException if the callable does not exist
*/
#[\ReturnTypeWillChange]
protected function resolveCallable($class, $method)
{
if ($this->container->has($class)) {
Expand All @@ -107,6 +110,7 @@ protected function resolveCallable($class, $method)
*
* @throws RuntimeException if the callable is not resolvable
*/
#[\ReturnTypeWillChange]
protected function assertCallable($callable)
{
if (!is_callable($callable)) {
Expand Down
1 change: 1 addition & 0 deletions Slim/CallableResolverAwareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ trait CallableResolverAwareTrait
*
* @throws RuntimeException If the string cannot be resolved as a callable
*/
#[\ReturnTypeWillChange]
protected function resolveCallable($callable)
{
if (!$this->container instanceof ContainerInterface) {
Expand Down
14 changes: 14 additions & 0 deletions Slim/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function __construct(array $items = [])
/**
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function set($key, $value)
{
$this->data[$key] = $value;
Expand All @@ -45,6 +46,7 @@ public function set($key, $value)
/**
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function get($key, $default = null)
{
return $this->has($key) ? $this->data[$key] : $default;
Expand All @@ -53,6 +55,7 @@ public function get($key, $default = null)
/**
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function replace(array $items)
{
foreach ($items as $key => $value) {
Expand All @@ -63,6 +66,7 @@ public function replace(array $items)
/**
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function all()
{
return $this->data;
Expand All @@ -73,6 +77,7 @@ public function all()
*
* @return array The collection's source data keys
*/
#[\ReturnTypeWillChange]
public function keys()
{
return array_keys($this->data);
Expand All @@ -81,6 +86,7 @@ public function keys()
/**
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function has($key)
{
return array_key_exists($key, $this->data);
Expand All @@ -89,6 +95,7 @@ public function has($key)
/**
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function remove($key)
{
unset($this->data[$key]);
Expand All @@ -97,6 +104,7 @@ public function remove($key)
/**
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function clear()
{
$this->data = [];
Expand All @@ -109,6 +117,7 @@ public function clear()
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function offsetExists($key)
{
return $this->has($key);
Expand All @@ -121,6 +130,7 @@ public function offsetExists($key)
*
* @return mixed The key's value, or the default value
*/
#[\ReturnTypeWillChange]
public function offsetGet($key)
{
return $this->get($key);
Expand All @@ -132,6 +142,7 @@ public function offsetGet($key)
* @param string $key The data key
* @param mixed $value The data value
*/
#[\ReturnTypeWillChange]
public function offsetSet($key, $value)
{
$this->set($key, $value);
Expand All @@ -142,6 +153,7 @@ public function offsetSet($key, $value)
*
* @param string $key The data key
*/
#[\ReturnTypeWillChange]
public function offsetUnset($key)
{
$this->remove($key);
Expand All @@ -152,6 +164,7 @@ public function offsetUnset($key)
*
* @return int
*/
#[\ReturnTypeWillChange]
public function count()
{
return count($this->data);
Expand All @@ -162,6 +175,7 @@ public function count()
*
* @return ArrayIterator
*/
#[\ReturnTypeWillChange]
public function getIterator()
{
return new ArrayIterator($this->data);
Expand Down
4 changes: 4 additions & 0 deletions Slim/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public function __construct(array $values = [])
*
* @return void
*/
#[\ReturnTypeWillChange]
private function registerDefaultServices($userSettings)
{
$defaultSettings = $this->defaultSettings;
Expand Down Expand Up @@ -100,6 +101,7 @@ private function registerDefaultServices($userSettings)
* @throws ContainerValueNotFoundException No entry was found for this identifier.
* @throws ContainerExceptionInterface Error while retrieving the entry.
*/
#[\ReturnTypeWillChange]
public function get($id)
{
if (!$this->offsetExists($id)) {
Expand Down Expand Up @@ -128,6 +130,7 @@ public function get($id)
*
* @return bool
*/
#[\ReturnTypeWillChange]
private function exceptionThrownByContainer(InvalidArgumentException $exception)
{
$trace = $exception->getTrace()[0];
Expand All @@ -143,6 +146,7 @@ private function exceptionThrownByContainer(InvalidArgumentException $exception)
*
* @return boolean
*/
#[\ReturnTypeWillChange]
public function has($id)
{
return $this->offsetExists($id);
Expand Down
1 change: 1 addition & 0 deletions Slim/DefaultServicesProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class DefaultServicesProvider
*
* @param Container $container A DI container implementing ArrayAccess and psr/container.
*/
#[\ReturnTypeWillChange]
public function register($container)
{
if (!isset($container['environment'])) {
Expand Down
Loading

0 comments on commit b42de67

Please sign in to comment.