for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of the core-library package.
*
* (c) 2017 NdC/WBW
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace WBW\Library\Core\Navigation\Tree;
use WBW\Library\Core\Navigation\Node\AbstractNavigationNode;
use WBW\Library\Core\Navigation\Node\BreadcrumbNode;
use WBW\Library\Core\Navigation\Node\NavigationNode;
* Navigation tree.
* @author NdC/WBW <https://github.com/webeweb/>
* @package WBW\Library\Core\Navigation\Tree
* @final
final class NavigationTree extends AbstractNavigationNode {
* Constructor.
public function __construct() {
parent::__construct("tree");
}
* Get the breadcrumbs.
* @param AbstractNavigationNode $node The navigation node.
* @return AsbtractNavigationNode[] Returns the navigation nodes.
public function getBreadcrumbs(AbstractNavigationNode $node = null) {
// Create the breadcrumbs.
$breadcrumbs = [];
// Correct the parameter if necessary.
if (is_null($node)) {
$node = $this;
// Check the instance.
if (($node instanceof NavigationNode || $node instanceof BreadcrumbNode) && $node->getActive()) {
$breadcrumbs[] = $node;
// Handle each node.
foreach ($node->getNodes() as $current) {
$breadcrumbs = array_merge($breadcrumbs, $this->getBreadcrumbs($current));
$current
object<WBW\Library\Core\Node\AbstractNode>
null|object<WBW\Library\...AbstractNavigationNode>
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
// Return the breadcrumbs.
return $breadcrumbs;
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: