Skip to content

Commit

Permalink
Merge pull request #675 from FriendsOfCake/controller-trait
Browse files Browse the repository at this point in the history
Make ControllerTrait::isAction() return a dummy closure for mapped actions.
  • Loading branch information
ADmad committed Jun 19, 2022
2 parents b468b01 + 8ef46e8 commit 8fb9e8e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ parameters:
- */src/TestSuite/*
universalObjectCratesClasses:
- Crud\Event\Subject
bootstrapFiles:
- vendor/cakephp/cakephp/src/Core/Exception/CakeException.php
13 changes: 12 additions & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="3.7.2@d9cae720c1af31db9ba27c2bc1fcf9b0dd092fb0">
<files psalm-version="4.x-dev@">
<file src="src/Error/ExceptionRenderer.php">
<DeprecatedClass occurrences="2">
<code>\Cake\Error\ExceptionRenderer</code>
<code>parent::_outputMessage($template)</code>
</DeprecatedClass>
</file>
<file src="src/Listener/ApiListener.php">
<DeprecatedClass occurrences="1">
<code>$controller-&gt;RequestHandler-&gt;setConfig('viewClassMap', [$type =&gt; $class])</code>
</DeprecatedClass>
</file>
<file src="src/Log/QueryLogger.php">
<InternalClass occurrences="2">
<code>\Cake\Database\Log\QueryLogger</code>
Expand Down
1 change: 0 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0"?>
<psalm
totallyTyped="false"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
Expand Down
7 changes: 6 additions & 1 deletion src/Controller/ControllerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ public function getAction(): Closure
} catch (MissingActionException $e) {
$this->mappedComponent = $this->_isActionMapped();
if ($this->mappedComponent) {
return Closure::fromCallable([$this->mappedComponent, 'execute']);
return function () {
// Dummy closure without arguments.
// This is to prevent the ControllerFactory from trying to type cast the method args.
// invokeAction() below simply ignores the $action argument for Crud mapped actions
// and calls CrudComponent::execute() directly.
};
}
}

Expand Down

0 comments on commit 8fb9e8e

Please sign in to comment.