Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Wrong variable types for route default parameters in PHP 7 #19869

Copy link
Copy link
Closed
@nissim94

Description

@nissim94
Issue body actions

Hi,

Type error: Argument 1 passed to OC\PlatformBundle\Controller\AdvertController::indexAction() must be of the type integer, string given

This error has been catched when you have defined default value to a parameter of a route, and type in the url banner /platform/ .

Normally /platform/ equals to /platform but with PHP 7 not.

when you use php5 there is no problem

see the code >>

routing.yml

oc_platform_home:
    path:      /platform/{page}
    defaults:
        _controller: OCPlatformBundle:Advert:index
        page: 1
    requirements:
        page: \d*

AdvertController.php

public function indexAction(int $page) : Response
    {
        if($page < 1){
            throw new NotFoundHttpException("Page $page inexistante");
        }

        return $this->render('OCPlatformBundle:Advert:index.html.twig');
    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.