Fatal error: 'break' not in the 'loop' or 'switch' context in D:\OpenServer\OpenServer\domains\Internetstor\components\Router.php on line 69

Я столкнулся с ошибкой. В ней написано что break не входит в цикл. Хоть я сделал все так как написано в мануале. Вот собственно документ:

<?php

class Router
{

    private $routes;

    public function __construct()
    {
        $routesPath = ROOT . '/config/routes.php';
        $this->routes = include($routesPath);
    }


    /**
     * Returns request string
     */
    private function getURI()
    {
        if (!empty($_SERVER['REQUEST_URI'])) {
            return trim($_SERVER['REQUEST_URI'], '/');
        }
    }

    public function run()
    {
        // Получить строку запроса
        $uri = $this->getURI();

        // Проверить наличие такого запроса в routes.php
        foreach ($this->routes as $uriPattern => $path) {
        }     // Сравниваем $uriPattern и $uri
            if (preg_match("~$uriPattern~", $uri)) {
            }    
                // Получаем внутренний путь из внешнего согласно правилу.
                $internalRoute = preg_replace("~$uriPattern~", $path, $uri);

                // Определить контроллер, action, параметры

               $segments = explode('/', $internalRoute);

                $controllerName = array_shift($segments) . 'Controller';
                $controllerName = ucfirst($controllerName);

                $actionName = 'action' . ucfirst(array_shift($segments));

                $parameters = $segments;

                // Подключить файл класса-контроллера
                $controllerFile = ROOT . '/controllers/' .
                        $controllerName . '.php';

                if (file_exists($controllerFile)) {
                    include_once($controllerFile);
                }

                }


    }
                // Создать объект, вызвать метод (т.е. action)
                $controllerObject = new $controllerName;


                class SiteControlle{
                   public function actionIndex(){

                if ($result != null){
                break;
                                    }
                                                }   
                                    }

Ответы (0 шт):