diff --git a/src/Matcher/Matcher.php b/src/Matcher/Matcher.php index 2ff034f..c2e0b17 100644 --- a/src/Matcher/Matcher.php +++ b/src/Matcher/Matcher.php @@ -24,14 +24,14 @@ class Matcher implements MatcherInterface /** * A cache that maps menu items and matching results. * - * @var SplObjectStorage + * @var \SplObjectStorage */ protected SplObjectStorage $_cache; /** * Collection of voters added `addVoter()`. * - * @var array + * @var array<\Knp\Menu\Matcher\Voter\VoterInterface> */ protected array $_voters = []; diff --git a/src/Matcher/MatcherInterface.php b/src/Matcher/MatcherInterface.php index 1d95b87..95c204e 100644 --- a/src/Matcher/MatcherInterface.php +++ b/src/Matcher/MatcherInterface.php @@ -20,7 +20,7 @@ interface MatcherInterface extends BaseMatcherInterface /** * Adds a voter in the matcher. * - * @param VoterInterface $voter The voter to add. + * @param \Knp\Menu\Matcher\Voter\VoterInterface $voter The voter to add. * @return void */ public function addVoter(VoterInterface $voter): void; diff --git a/src/Matcher/Voter/FuzzyRouteVoter.php b/src/Matcher/Voter/FuzzyRouteVoter.php index 27950bb..10c71b5 100644 --- a/src/Matcher/Voter/FuzzyRouteVoter.php +++ b/src/Matcher/Voter/FuzzyRouteVoter.php @@ -39,7 +39,7 @@ public function getParams(): array /** * Constructor. * - * @param ServerRequest $request The request object from where to extract the routing + * @param \Cake\Http\ServerRequest $request The request object from where to extract the routing * parameters to match against. */ public function __construct(ServerRequest $request) @@ -79,7 +79,7 @@ public function matchItem(ItemInterface $item): ?bool /** * Extracts the routing parameters from the given request. * - * @param ServerRequest $request The request object from where to extract the routing + * @param \Cake\Http\ServerRequest $request The request object from where to extract the routing * parameters. * @return array An array of routing parameters. */ @@ -112,7 +112,7 @@ protected function _extractParams(ServerRequest $request): array $params['_Token'], $params['_csrfToken'], $params['_matchedRoute'], - $params['_route'] + $params['_route'], ); $params = array_merge($params, $pass); $params += $params['?']; @@ -145,7 +145,7 @@ function (mixed &$value): void { if (is_numeric($value)) { $value = (string)$value; } - } + }, ); if (isset($params['?'])) { @@ -173,7 +173,7 @@ protected function _normalizeRoute(array &$route): void $route['_scheme'], $route['_port'], $route['_full'], - $route['_ssl'] + $route['_ssl'], ); $this->_normalizeParams($route); diff --git a/src/Matcher/Voter/UrlVoter.php b/src/Matcher/Voter/UrlVoter.php index be162a3..6df607f 100644 --- a/src/Matcher/Voter/UrlVoter.php +++ b/src/Matcher/Voter/UrlVoter.php @@ -73,7 +73,7 @@ public function getUrlWithoutQuery(): string * - `ignoreQueryString`: Defines whether the query string should be ignored when matching * items. Defaults to `true`. * - * @param ServerRequest $request The request object from where to extract the request + * @param \Cake\Http\ServerRequest $request The request object from where to extract the request * target to match against. * @param array $options An array of options, see the "Options" section in the method * description. diff --git a/src/MenuFactoryInterface.php b/src/MenuFactoryInterface.php index 6523307..7bd24d4 100644 --- a/src/MenuFactoryInterface.php +++ b/src/MenuFactoryInterface.php @@ -20,7 +20,7 @@ interface MenuFactoryInterface extends FactoryInterface /** * Adds a factory extension. * - * @param ExtensionInterface $extension The extension to add. + * @param \Knp\Menu\Factory\ExtensionInterface $extension The extension to add. * @param int $priority The priority to assign to the extension. * @return void */ diff --git a/src/Renderer/StringTemplateRenderer.php b/src/Renderer/StringTemplateRenderer.php index d9f0fac..824d147 100644 --- a/src/Renderer/StringTemplateRenderer.php +++ b/src/Renderer/StringTemplateRenderer.php @@ -30,7 +30,7 @@ class StringTemplateRenderer implements RendererInterface /** * The matcher to use for determining the active items. * - * @var MatcherInterface + * @var \Knp\Menu\Matcher\MatcherInterface */ protected MatcherInterface $_matcher; @@ -135,7 +135,7 @@ class StringTemplateRenderer implements RendererInterface * classes to consume (see the `inheritItemClasses` option for a list of valid class * names). * - * @param MatcherInterface $matcher The matcher to use for determining the active items. + * @param \Knp\Menu\Matcher\MatcherInterface $matcher The matcher to use for determining the active items. * @param array $config An array of options, see the "Configuration options" section in the * method description. */ @@ -158,7 +158,7 @@ public function __construct(MatcherInterface $matcher, array $config = []) * This method supports all the options that the constructor supports. * * @see __construct() - * @param ItemInterface $item The menu to render. + * @param \Knp\Menu\ItemInterface $item The menu to render. * @param array $options An array of options, see the "Options" section in the method * description. * @return string The rendered menu. @@ -179,7 +179,7 @@ public function render(ItemInterface $item, array $options = []): string /** * Renders the root menu item. * - * @param ItemInterface $item The menu item to render. + * @param \Knp\Menu\ItemInterface $item The menu item to render. * @param array $options The rendering options. * @return string The rendered menu item. */ @@ -236,7 +236,7 @@ protected function _renderMenu(ItemInterface $item, array $options): string * - `templateVars`: The template variables to use for the element. * - `childrenTemplates`: The templates to use for the children of the element. * - * @param ItemInterface $item The menu whose children to render. + * @param \Knp\Menu\ItemInterface $item The menu whose children to render. * @param array $options The rendering options, see the "Options" section in the method * description for specific nesting element options. * @return string The rendered element. @@ -282,7 +282,7 @@ protected function _renderNested(ItemInterface $item, array $options): string /** * Renders the menu items children. * - * @param ItemInterface $item The item whose children to render. + * @param \Knp\Menu\ItemInterface $item The item whose children to render. * @param array $options The rendering options. * @return array The rendered children. */ @@ -310,7 +310,7 @@ protected function _renderChildren(ItemInterface $item, array $options): array /** * Renders the menu item and its children. * - * @param ItemInterface $item The menu item to render. + * @param \Knp\Menu\ItemInterface $item The menu item to render. * @param array $options The rendering options. * @return string The rendered menu item. */ @@ -496,7 +496,7 @@ protected function _renderItem(ItemInterface $item, array $options): string * * - `currentAsLink`: Whether to render active items as links, or as text elements. * - * @param ItemInterface $item The menu item for which to render a link. + * @param \Knp\Menu\ItemInterface $item The menu item for which to render a link. * @param array $options The rendering options, see the "Options" section in the method * description specific link options. * @return string The rendered link. @@ -524,7 +524,7 @@ protected function _renderLink(ItemInterface $item, array $options): string * - `class`: The class(es) to set on the link element. * - `templateVars`: The template variables to use for the link element. * - * @param ItemInterface $item The menu item which to render as a link element. + * @param \Knp\Menu\ItemInterface $item The menu item which to render as a link element. * @param array $options The rendering options, see the "Options" section in the method * description specific link options. * @return string The rendered link element. @@ -553,7 +553,7 @@ protected function _renderLinkElement(ItemInterface $item, array $options): stri * - `class`: The class(es) to set on the text element. * - `templateVars`: The template variables to use for the text element. * - * @param ItemInterface $item The item whose text to render. + * @param \Knp\Menu\ItemInterface $item The item whose text to render. * @param array $options The rendering options, see the "Options" section in the method * description specific text options. * @return string The rendered text. @@ -579,7 +579,7 @@ protected function _renderTextElement(ItemInterface $item, array $options): stri * By default the label is being HTML entity encoded, unless explicitly disabled for the given * menu item via the `escape` or `escapeLabel` option. * - * @param ItemInterface $item The item whose label to render. + * @param \Knp\Menu\ItemInterface $item The item whose label to render. * @return string The rendered label. */ protected function _renderLabel(ItemInterface $item): string @@ -598,14 +598,14 @@ protected function _renderLabel(ItemInterface $item): string * Formats an array of attributes as a string of HTML attributes. * * @param array $attributes The attributes to format. - * @param ItemInterface $item The menu item that defined the attributes. + * @param \Knp\Menu\ItemInterface $item The menu item that defined the attributes. * @return string A formatted string of HTML attributes. */ protected function _formatAttributes(array $attributes, ItemInterface $item): string { if (!empty($attributes)) { return $this->templater()->formatAttributes( - $attributes + ['escape' => $item->getExtra('escape', true)] + $attributes + ['escape' => $item->getExtra('escape', true)], ); } diff --git a/src/TestSuite/RequestFactoryTrait.php b/src/TestSuite/RequestFactoryTrait.php index c4f762b..48e3fb6 100644 --- a/src/TestSuite/RequestFactoryTrait.php +++ b/src/TestSuite/RequestFactoryTrait.php @@ -22,7 +22,7 @@ trait RequestFactoryTrait * Creates a request object. * * @param string $requestUri The request URI for which to create a request object for. - * @return ServerRequest + * @return \Cake\Http\ServerRequest */ public static function createRequest(string $requestUri): ServerRequest { @@ -37,13 +37,13 @@ public static function createRequest(string $requestUri): ServerRequest 'QUERY_STRING' => $query['string'], 'DOCUMENT_ROOT' => '/', ], - $query['arguments'] + $query['arguments'], ); Router::setRequest($request); return $request->withAttribute( 'params', - Router::parseRequest($request) + Router::parseRequest($request), ); } diff --git a/src/View/Helper/MenuHelper.php b/src/View/Helper/MenuHelper.php index 86e98cc..5b9f26a 100644 --- a/src/View/Helper/MenuHelper.php +++ b/src/View/Helper/MenuHelper.php @@ -25,7 +25,6 @@ use Icings\Menu\Renderer\StringTemplateRenderer; use InvalidArgumentException; use Knp\Menu\ItemInterface; -use Knp\Menu\Matcher\Voter\VoterInterface; use Knp\Menu\Renderer\RendererInterface; use RuntimeException; use SplObjectStorage; @@ -71,28 +70,28 @@ class MenuHelper extends Helper /** * Collection of menu items created via `create()`. * - * @var array + * @var array<\Knp\Menu\ItemInterface> */ protected array $_menus = []; /** * Storage for menu configurations assigned to menus via `create()`. * - * @var SplObjectStorage + * @var \SplObjectStorage */ protected SplObjectStorage $_menuConfigurations; /** * The factory to use for creating menu items. * - * @var MenuFactoryInterface + * @var \Icings\Menu\MenuFactoryInterface */ protected MenuFactoryInterface $_factory; /** * Sets the menu factory to use for creating menu items. * - * @param MenuFactoryInterface $factory The factory to assign. + * @param \Icings\Menu\MenuFactoryInterface $factory The factory to assign. * @return $this */ public function setMenuFactory(MenuFactoryInterface $factory) @@ -105,7 +104,7 @@ public function setMenuFactory(MenuFactoryInterface $factory) /** * Gets the menu factory to use for creating menu items. * - * @return MenuFactoryInterface + * @return \Icings\Menu\MenuFactoryInterface */ public function getMenuFactory(): MenuFactoryInterface { @@ -149,7 +148,7 @@ public function getMenuFactory(): MenuFactoryInterface * @see StringTemplateRenderer::__construct() * @see create() * @see render() - * @param View $View The View this helper is being attached to. + * @param \Cake\View\View $View The View this helper is being attached to. * @param array $config An array of options, see the "Configuration options" section in the * method description. */ @@ -183,12 +182,12 @@ public function __construct(View $View, array $config = []) * passed as options to the renderer. * * @see __construct() - * @throws InvalidArgumentException In case the `$name` argument is not a string, or is empty. + * @throws \InvalidArgumentException In case the `$name` argument is not a string, or is empty. * @param string $name The name of the menu. The name serves as an identifier for retrieving * and rendering specific menus. * @param array $options An array of options, see the "Options" section in the method * description. - * @return ItemInterface + * @return \Knp\Menu\ItemInterface */ public function create(string $name, array $options = []): ItemInterface { @@ -210,20 +209,20 @@ public function create(string $name, array $options = []): ItemInterface * This method supports all the options that the constructor supports. * * @see __construct() - * @throws RuntimeException In case no menu object is passed, and no menu has been created via + * @throws \RuntimeException In case no menu object is passed, and no menu has been created via * the `create()` method yet. - * @throws InvalidArgumentException In case the menu with name given in the `$menu` argument + * @throws \InvalidArgumentException In case the menu with name given in the `$menu` argument * does not exist. - * @throws InvalidArgumentException In case the `$menu` argument is neither a + * @throws \InvalidArgumentException In case the `$menu` argument is neither a * `Knp\Menu\ItemInterface` implementation, the name of a menu, nor an array. - * @throws InvalidArgumentException In case the `matcher` option is not a + * @throws \InvalidArgumentException In case the `matcher` option is not a * `Icings\Menu\Matcher\MatcherInterface` implementation. - * @throws InvalidArgumentException In case the `matching` option is not one of + * @throws \InvalidArgumentException In case the `matching` option is not one of * `Icings\Menu\View\Helper\MenuHelper::MATCH_*` constant vales. - * @throws InvalidArgumentException In case the `voters` option is not an array. - * @throws InvalidArgumentException In case the `renderer` option is not a + * @throws \InvalidArgumentException In case the `voters` option is not an array. + * @throws \InvalidArgumentException In case the `renderer` option is not a * `Knp\Menu\Renderer\RendererInterface` implementation. - * @param ItemInterface|array|string|null $menu Either an `\Knp\Menu\ItemInterface` implementation, + * @param \Knp\Menu\ItemInterface|array|string|null $menu Either an `\Knp\Menu\ItemInterface` implementation, * the name of a menu created via `create()`, or an array of options to use instead of the * `$options` argument. If omitted or an array, the menu that was last created via `create()` * will be used. @@ -270,9 +269,9 @@ public function render(ItemInterface|array|string|null $menu = null, array $opti * the top most element in a menu is usually the menu itself, not an actual menu item that * is being rendered and has a URL assigned for matching, hence it is by default excluded. * - * @param ItemInterface $item The item from which to extract the path from. + * @param \Knp\Menu\ItemInterface $item The item from which to extract the path from. * @param array $options An array of options, see the "Options" section in the method description. - * @return array A set of items representing the path from the root item. + * @return array<\Knp\Menu\ItemInterface> A set of items representing the path from the root item. */ public function extractPath(ItemInterface $item, array $options = []): array { @@ -328,13 +327,13 @@ public function extractPath(ItemInterface $item, array $options = []): array * Similar to the `render()` method, this method will use the helper defaults for the * options if not specified. * - * @param ItemInterface|array|string|null $menu The menu (item) to search through. Either an + * @param \Knp\Menu\ItemInterface|array|string|null $menu The menu (item) to search through. Either an * `\Knp\Menu\ItemInterface` implementation, the name of a menu created via `create()`, or * an array of options to use instead of the `$options` argument. If omitted or an array, * the menu that was last created via `create()` will be used. * @param array $options An array of options, see the "Options" section in the method * description. - * @return ItemInterface|null The first current item or `null` if no current item could be found. + * @return \Knp\Menu\ItemInterface|null The first current item or `null` if no current item could be found. */ public function getCurrentItem(ItemInterface|array|string|null $menu = null, array $options = []): ?ItemInterface { @@ -369,14 +368,14 @@ public function getCurrentItem(ItemInterface|array|string|null $menu = null, arr /** * Returns a menu instance based on the given parameters. * - * @throws RuntimeException In case no menu object is passed, and no menu has been created via + * @throws \RuntimeException In case no menu object is passed, and no menu has been created via * the `create()` method yet. - * @throws InvalidArgumentException In case the menu with name given in the `$menu` argument + * @throws \InvalidArgumentException In case the menu with name given in the `$menu` argument * does not exist. - * @param ItemInterface|string|null $menu Either an `\Knp\Menu\ItemInterface` implementation, or + * @param \Knp\Menu\ItemInterface|string|null $menu Either an `\Knp\Menu\ItemInterface` implementation, or * the name of a menu created via `create()`. If omitted, the menu that was last created via * `create()` will be obtained. - * @return ItemInterface + * @return \Knp\Menu\ItemInterface */ protected function _getMenu(ItemInterface|string|null $menu = null): ItemInterface { @@ -385,12 +384,12 @@ protected function _getMenu(ItemInterface|string|null $menu = null): ItemInterfa throw new RuntimeException('No menu has been created.'); } - /** @var ItemInterface $menu */ + /** @var \Knp\Menu\ItemInterface $menu */ $menu = end($this->_menus); } elseif (is_string($menu)) { if (!isset($this->_menus[$menu])) { throw new InvalidArgumentException( - sprintf('The menu with the name `%s` does not exist.', $menu) + sprintf('The menu with the name `%s` does not exist.', $menu), ); } @@ -411,11 +410,11 @@ protected function _getMenu(ItemInterface|string|null $menu = null): ItemInterfa * `Icings\Menu\Matcher\Matcher`) * The matcher object to use. * - * @throws InvalidArgumentException In case the `matcher` option is not a + * @throws \InvalidArgumentException In case the `matcher` option is not a * `Icings\Menu\Matcher\MatcherInterface` implementation. * @param array $options An array of options, see the "Options" section in the method * description. - * @return MatcherInterface + * @return \Icings\Menu\Matcher\MatcherInterface */ protected function _getMatcher(array $options): MatcherInterface { @@ -427,8 +426,8 @@ protected function _getMatcher(array $options): MatcherInterface sprintf( 'The `matcher` option must be a `Icings\Menu\Matcher\MatcherInterface` ' . 'implementation, `%s` given.', - Debugger::getType($options['matcher']) - ) + Debugger::getType($options['matcher']), + ), ); } @@ -455,12 +454,12 @@ protected function _getMatcher(array $options): MatcherInterface * `[Icings\Menu\Matcher\Voter\FuzzyRouteVoter]`) * The voter objects to use. * - * @throws InvalidArgumentException In case the `matching` option is not one of + * @throws \InvalidArgumentException In case the `matching` option is not one of * `Icings\Menu\View\Helper\MenuHelper::MATCH_*` constant vales. - * @throws InvalidArgumentException In case the `voters` option is not an array. + * @throws \InvalidArgumentException In case the `voters` option is not an array. * @param array $options An array of options, see the "Options" section in the method * description. - * @return array + * @return array<\Icings\Menu\View\Helper\VoterInterface> */ protected function _getVoters(array $options): array { @@ -471,8 +470,8 @@ protected function _getVoters(array $options): array sprintf( 'The `matching` option must be one of the `Icings\Menu\View\Helper\MenuHelper::MATCH_*` ' . 'constant values, `%s` given.', - Debugger::exportVar($options['matching']) - ) + Debugger::exportVar($options['matching']), + ), ); } } else { @@ -480,8 +479,8 @@ protected function _getVoters(array $options): array throw new InvalidArgumentException( sprintf( 'The `voters` option must be an array, `%s` given.', - Debugger::getType($options['voters']) - ) + Debugger::getType($options['voters']), + ), ); } @@ -502,11 +501,11 @@ protected function _getVoters(array $options): array * `Icings\Menu\Renderer\StringTemplateRenderer`) * The renderer object to use. * - * @throws InvalidArgumentException In case the `renderer` option is not a + * @throws \InvalidArgumentException In case the `renderer` option is not a * `Knp\Menu\Renderer\RendererInterface` implementation. * @param array $options An array of options, see the "Options" section in the method * description. - * @return RendererInterface + * @return \Knp\Menu\Renderer\RendererInterface */ protected function _getRenderer(array $options): RendererInterface { @@ -525,8 +524,8 @@ protected function _getRenderer(array $options): RendererInterface sprintf( 'The `renderer` option must be a `Knp\Menu\Renderer\RendererInterface` ' . 'implementation, `%s` given.', - Debugger::getType($options['renderer']) - ) + Debugger::getType($options['renderer']), + ), ); } @@ -539,9 +538,9 @@ protected function _getRenderer(array $options): RendererInterface /** * Searches for and returns the first item which matches as current. * - * @param ItemInterface $item The menu (item) to search through. - * @param MatcherInterface $matcher The matcher to use for matching the current item. - * @return ItemInterface|null The current item, or `null` if no item matches are current. + * @param \Knp\Menu\ItemInterface $item The menu (item) to search through. + * @param \Icings\Menu\Matcher\MatcherInterface $matcher The matcher to use for matching the current item. + * @return \Knp\Menu\ItemInterface|null The current item, or `null` if no item matches are current. */ protected function _findCurrentItem(ItemInterface $item, MatcherInterface $matcher): ?ItemInterface { @@ -565,7 +564,7 @@ protected function _findCurrentItem(ItemInterface $item, MatcherInterface $match * Stores a menu and associates a set of configuration options with it for later use * with `render()`. * - * @param ItemInterface $menu The menu to store. + * @param \Knp\Menu\ItemInterface $menu The menu to store. * @param array $options The options to associate with it. * @return void */ @@ -595,7 +594,7 @@ protected function _extractMenuOptions(array &$options): array 'templates', 'templateVars', 'menuAttributes', - ]) + ]), ); $options = array_diff_key($options, $menuOptions); @@ -628,7 +627,7 @@ protected function _extractRendererOptions(array &$options): array 'matcher', 'voters', 'renderer', - ]) + ]), ); $options = array_diff_key($options, $rendererOptions); @@ -639,7 +638,7 @@ protected function _extractRendererOptions(array &$options): array /** * Creates the default matcher. * - * @return MatcherInterface + * @return \Icings\Menu\Matcher\MatcherInterface */ protected function _createDefaultMatcher(): MatcherInterface { @@ -650,7 +649,7 @@ protected function _createDefaultMatcher(): MatcherInterface * Creates default voters for the given type. * * @param string $type The type of the voters to create. - * @return array|bool An array holding the created voters, or `false` for unsupported + * @return array<\Knp\Menu\Matcher\Voter\VoterInterface>|bool An array holding the created voters, or `false` for unsupported * types. */ protected function _createDefaultVoters(string $type): array|bool @@ -674,8 +673,8 @@ protected function _createDefaultVoters(string $type): array|bool /** * Creates the default renderer. * - * @param MatcherInterface $matcher The matcher to pass to the renderer. - * @return RendererInterface + * @param \Icings\Menu\Matcher\MatcherInterface $matcher The matcher to pass to the renderer. + * @return \Knp\Menu\Renderer\RendererInterface */ protected function _createDefaultRenderer(MatcherInterface $matcher): RendererInterface { diff --git a/tests/TestCase/Integration/PerItemVotersExtensionTest.php b/tests/TestCase/Integration/PerItemVotersExtensionTest.php index 24539f3..a53c2b9 100644 --- a/tests/TestCase/Integration/PerItemVotersExtensionTest.php +++ b/tests/TestCase/Integration/PerItemVotersExtensionTest.php @@ -13,7 +13,6 @@ use Icings\Menu\Integration\PerItemVotersExtension; use Knp\Menu\FactoryInterface; use Knp\Menu\MenuItem; -use PHPUnit\Framework\MockObject\MockObject; class PerItemVotersExtensionTest extends TestCase { diff --git a/tests/TestCase/Integration/RoutingExtensionTest.php b/tests/TestCase/Integration/RoutingExtensionTest.php index 19d9db9..5979f24 100644 --- a/tests/TestCase/Integration/RoutingExtensionTest.php +++ b/tests/TestCase/Integration/RoutingExtensionTest.php @@ -16,7 +16,6 @@ use Icings\Menu\Integration\RoutingExtension; use Knp\Menu\FactoryInterface; use Knp\Menu\MenuItem; -use PHPUnit\Framework\MockObject\MockObject; class RoutingExtensionTest extends TestCase { @@ -85,7 +84,7 @@ public function testBuildOptionsDefineUriAsNamedRoute(): void ], [ '_name' => 'RouteName', - ] + ], ); }); @@ -182,7 +181,7 @@ public function testBuildOptionsDefineRoutesAsNamedRoute(): void ], [ '_name' => 'RouteName', - ] + ], ); }); diff --git a/tests/TestCase/Integration/TemplaterExtensionTest.php b/tests/TestCase/Integration/TemplaterExtensionTest.php index 2c1a69c..7b15c44 100644 --- a/tests/TestCase/Integration/TemplaterExtensionTest.php +++ b/tests/TestCase/Integration/TemplaterExtensionTest.php @@ -13,7 +13,6 @@ use Icings\Menu\Integration\TemplaterExtension; use Knp\Menu\FactoryInterface; use Knp\Menu\MenuItem; -use PHPUnit\Framework\MockObject\MockObject; class TemplaterExtensionTest extends TestCase { @@ -310,7 +309,7 @@ public function testBuildOptionsDefineAll(): void unset( $originalOptions['menuAttributes'], $originalOptions['nestAttributes'], - $originalOptions['textAttributes'] + $originalOptions['textAttributes'], ); $expected = [ 'labelAttributes' => [ diff --git a/tests/TestCase/KnpMenuTestCase.php b/tests/TestCase/KnpMenuTestCase.php index 64d9f53..65f34c0 100644 --- a/tests/TestCase/KnpMenuTestCase.php +++ b/tests/TestCase/KnpMenuTestCase.php @@ -1,4 +1,6 @@ createRequest($requestUri); diff --git a/tests/TestCase/Renderer/StringTemplateRendererTest.php b/tests/TestCase/Renderer/StringTemplateRendererTest.php index 3ee7df6..380c92e 100644 --- a/tests/TestCase/Renderer/StringTemplateRendererTest.php +++ b/tests/TestCase/Renderer/StringTemplateRendererTest.php @@ -20,7 +20,6 @@ use Knp\Menu\MenuFactory; use Knp\Menu\MenuItem; use Knp\Menu\Renderer\RendererInterface; -use PHPUnit\Framework\MockObject\MockObject; use TypeError; class StringTemplateRendererTest extends KnpAbstractRendererTestCase @@ -49,7 +48,7 @@ public function testConstructMissingRequiredArguments(): void $this->expectException(Error::class); $this->expectExceptionMessageMatches( - '/^(Argument 1 .+? must implement interface Knp\\\\Menu\\\\Matcher\\\\MatcherInterface, none given|Too few arguments .+? at least 1 expected)/' + '/^(Argument 1 .+? must implement interface Knp\\\\Menu\\\\Matcher\\\\MatcherInterface, none given|Too few arguments .+? at least 1 expected)/', ); new StringTemplateRenderer(); @@ -65,7 +64,7 @@ public function testConstructInvalidMatcherArgumentType(): void $this->expectExceptionMessageMatches( PHP_VERSION < 8 ? '/^Argument 1 .+? must implement interface Knp\\\\Menu\\\\Matcher\\\\MatcherInterface, string given/' : - '/^Icings\\\\Menu\\\\Renderer\\\\StringTemplateRenderer::__construct\(\): Argument #1 .+? must be of type Knp\\\\Menu\\\\Matcher\\\\MatcherInterface, string given/' + '/^Icings\\\\Menu\\\\Renderer\\\\StringTemplateRenderer::__construct\(\): Argument #1 .+? must be of type Knp\\\\Menu\\\\Matcher\\\\MatcherInterface, string given/', ); new StringTemplateRenderer('invalid'); @@ -81,7 +80,7 @@ public function testConstructInvalidConfigArgumentType(): void $this->expectExceptionMessageMatches( PHP_VERSION < 8 ? '/^Argument 2 .+? must be of the type array, string given/' : - '/^Icings\\\\Menu\\\\Renderer\\\\StringTemplateRenderer::__construct\(\): Argument #2 .+? must be of type array, string given/' + '/^Icings\\\\Menu\\\\Renderer\\\\StringTemplateRenderer::__construct\(\): Argument #2 .+? must be of type array, string given/', ); new StringTemplateRenderer(new Matcher(), 'invalid'); diff --git a/tests/TestCase/TestSuite/RequestFactoryTraitTest.php b/tests/TestCase/TestSuite/RequestFactoryTraitTest.php index f10b74c..f5ef51b 100644 --- a/tests/TestCase/TestSuite/RequestFactoryTraitTest.php +++ b/tests/TestCase/TestSuite/RequestFactoryTraitTest.php @@ -16,7 +16,6 @@ use Cake\Routing\Router; use Cake\TestSuite\TestCase; use Icings\Menu\TestSuite\RequestFactoryTrait; -use PHPUnit\Framework\MockObject\MockObject; class RequestFactoryTraitTest extends TestCase { diff --git a/tests/TestCase/View/Helper/MenuHelperTest.php b/tests/TestCase/View/Helper/MenuHelperTest.php index 2896192..247ee56 100644 --- a/tests/TestCase/View/Helper/MenuHelperTest.php +++ b/tests/TestCase/View/Helper/MenuHelperTest.php @@ -24,7 +24,6 @@ use Knp\Menu\MenuItem; use Knp\Menu\Renderer\RendererInterface; use Laminas\Diactoros\Uri; -use PHPUnit\Framework\MockObject\MockObject; use RuntimeException; use TypeError; use function Cake\Collection\collection; @@ -104,7 +103,7 @@ public function testCreateInvalidNameArgumentType(): void $this->expectExceptionMessageMatches( PHP_VERSION < 8 ? '/^Argument 1 passed to Icings\\\\Menu\\\\View\\\\Helper\\\\MenuHelper::create\(\) must be of the type string, (int|integer) given/' : - '/^Icings\\\\Menu\\\\View\\\\Helper\\\\MenuHelper::create\(\): Argument #1 .+? must be of type string, int given/' + '/^Icings\\\\Menu\\\\View\\\\Helper\\\\MenuHelper::create\(\): Argument #1 .+? must be of type string, int given/', ); $this->Menu->create(123); @@ -714,7 +713,7 @@ public function testRenderInvalidMatchingOption(): void $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage(sprintf( 'The `matching` option must be one of the `Icings\Menu\View\Helper\MenuHelper::MATCH_*` constant values, `%s` given.', - Debugger::exportVar('invalid') + Debugger::exportVar('invalid'), )); $menu = $this @@ -873,7 +872,7 @@ public function testRenderInvalidVotersOptionArray(): void $this->expectExceptionMessageMatches( PHP_VERSION < 8 ? '/^Argument 1 .+? must (be an instance of|implement interface) Knp\\\\Menu\\\\Matcher\\\\Voter\\\\VoterInterface, string given/' : - '/^Icings\\\\Menu\\\\Matcher\\\\Matcher::addVoter\(\): Argument #1 .+? must be of type Knp\\\\Menu\\\\Matcher\\\\Voter\\\\VoterInterface, string given/' + '/^Icings\\\\Menu\\\\Matcher\\\\Matcher::addVoter\(\): Argument #1 .+? must be of type Knp\\\\Menu\\\\Matcher\\\\Voter\\\\VoterInterface, string given/', ); $menu = $this @@ -976,7 +975,7 @@ public function testExtractPathFromExternalNode(): void ->extract(function ($node) { return $node->getLabel(); }) - ->toArray() + ->toArray(), ); } @@ -996,7 +995,7 @@ public function testExtractPathFromInternalNode(): void ->extract(function ($node) { return $node->getLabel(); }) - ->toArray() + ->toArray(), ); } @@ -1013,7 +1012,7 @@ public function testExtractPathNoParentItemsPresent(): void ->extract(function ($node) { return $node->getLabel(); }) - ->toArray() + ->toArray(), ); } @@ -1056,7 +1055,7 @@ public function testExtractPathInvalidMenuType(): void $this->expectExceptionMessageMatches( PHP_VERSION < 8 ? '/^Argument #?1 passed to Icings\\\\Menu\\\\View\\\\Helper\\\\MenuHelper::extractPath\(\) must (be an instance of|implement interface) Knp\\\\Menu\\\\ItemInterface, (int|integer) given/' : - '/^Icings\\\\Menu\\\\View\\\\Helper\\\\MenuHelper::extractPath\(\): Argument #1 \(\$item\) must be of type Knp\\\\Menu\\\\ItemInterface, int given/' + '/^Icings\\\\Menu\\\\View\\\\Helper\\\\MenuHelper::extractPath\(\): Argument #1 \(\$item\) must be of type Knp\\\\Menu\\\\ItemInterface, int given/', ); $this->Menu->extractPath(123); @@ -1086,7 +1085,7 @@ public function testExtractPathIncludeRootItem(): void ->extract(function ($node) { return $node->getLabel(); }) - ->toArray() + ->toArray(), ); } @@ -1104,7 +1103,7 @@ public function testExtractPathNoParentItemsPresentIncludeRootItem(): void ->extract(function ($node) { return $node->getLabel(); }) - ->toArray() + ->toArray(), ); } @@ -1114,7 +1113,7 @@ public function testExtractPathInvalidOptionsType(): void $this->expectExceptionMessageMatches( PHP_VERSION < 8 ? '/^Argument 2 passed to Icings\\\\Menu\\\\View\\\\Helper\\\\MenuHelper::extractPath\(\) must be of the type array, (int|integer) given/' : - '/^Icings\\\\Menu\\\\View\\\\Helper\\\\MenuHelper::extractPath\(\): Argument #2 .+? must be of type array, int given/' + '/^Icings\\\\Menu\\\\View\\\\Helper\\\\MenuHelper::extractPath\(\): Argument #2 .+? must be of type array, int given/', ); $this->Menu->extractPath($this->Menu->create('menu'), 123); @@ -1199,7 +1198,7 @@ public function testGetCurrentItemRetrievesTheFirstCurrentItem(): void public function testGetCurrentItemUsingMatcherWithVoters(): void { $this->Menu->getView()->setRequest( - $this->Menu->getView()->getRequest()->withUri(new Uri('/parent/child')) + $this->Menu->getView()->getRequest()->withUri(new Uri('/parent/child')), ); $menu = $this->Menu->create('main'); @@ -1245,7 +1244,7 @@ public function getCurrentItemMergeWithHelperOptionsTestSetup(): array 1 => $this->assertSame($voter1, $voter), 2 => $this->assertSame($voter2, $voter), default => $this->fail( - 'Icings\Menu\Matcher\Matcher::addVoter() was not expected to be called more than twice.' + 'Icings\Menu\Matcher\Matcher::addVoter() was not expected to be called more than twice.', ), }; }); @@ -1452,7 +1451,7 @@ public function testGetCurrentItemInvalidMatchingOption(): void $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage(sprintf( 'The `matching` option must be one of the `Icings\Menu\View\Helper\MenuHelper::MATCH_*` constant values, `%s` given.', - Debugger::exportVar('invalid') + Debugger::exportVar('invalid'), )); $menu = $this @@ -1579,7 +1578,7 @@ public function testGetCurrentItemInvalidVotersOptionArray(): void $this->expectExceptionMessageMatches( PHP_VERSION < 8 ? '/^Argument 1 .+? must (be an instance of|implement interface) Knp\\\\Menu\\\\Matcher\\\\Voter\\\\VoterInterface, string given/' : - '/^Icings\\\\Menu\\\\Matcher\\\\Matcher::addVoter\(\): Argument #1 .+? must be of type Knp\\\\Menu\\\\Matcher\\\\Voter\\\\VoterInterface, string given/' + '/^Icings\\\\Menu\\\\Matcher\\\\Matcher::addVoter\(\): Argument #1 .+? must be of type Knp\\\\Menu\\\\Matcher\\\\Voter\\\\VoterInterface, string given/', ); $menu = $this @@ -1667,7 +1666,7 @@ public function testGetCurrentItemInvalidOptionsType(): void $this->expectExceptionMessageMatches( PHP_VERSION < 8 ? '/^Argument 2 passed to Icings\\\\Menu\\\\View\\\\Helper\\\\MenuHelper::getCurrentItem\(\) must be of the type array, (int|integer) given/' : - '/^Icings\\\\Menu\\\\View\\\\Helper\\\\MenuHelper::getCurrentItem\(\): Argument #2 .+? must be of type array, int given/' + '/^Icings\\\\Menu\\\\View\\\\Helper\\\\MenuHelper::getCurrentItem\(\): Argument #2 .+? must be of type array, int given/', ); $this->Menu->getCurrentItem($this->Menu->create('menu'), 123);