php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75820 Parse error: syntax error, unexpected '?'
Submitted: 2018-01-15 17:49 UTC Modified: 2018-01-15 17:56 UTC
From: pyrrahnas at gmail dot com Assigned: peehaa (profile)
Status: Closed Package: *Programming Data Structures
PHP Version: 7.0.27 OS: Debian Jessie
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: pyrrahnas at gmail dot com
New email:
PHP Version: OS:

 

 [2018-01-15 17:49 UTC] pyrrahnas at gmail dot com
Description:
------------
On Debian Jessie (9) with PHP 7.0.27-0+deb9u1 (cli), it is impossible to use the character '?' in a function declaration.

PHP7.0.27 package is the most recent on Debian 9. I have not found a fix :(

Test script:
---------------
    private function addCityField(FormInterface $form, ?Department $department) {
        $form->add('city', EntityType::class, [
            'class'         => 'AppBundle\Entity\City',
            'placeholder'   => $department ? 'Select your city' : 'Select your department',
            'choices'       => $department ? $department->getCities() : []
        ]);
    }

Expected result:
----------------
Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE)

Line with problem :
"private function addCityField(FormInterface $form, ?Department $department) {"


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-01-15 17:51 UTC] spam2 at rhsoft dot net
nullable types are a PHP 7.1 feature - why do you assume that works on 7.0.x
http://php.net/manual/de/migration71.new-features.php
 [2018-01-15 17:55 UTC] pyrrahnas at gmail dot com
-Package: Variables related +Package: *Programming Data Structures
 [2018-01-15 17:55 UTC] pyrrahnas at gmail dot com
Change package
 [2018-01-15 17:56 UTC] peehaa@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: peehaa
 [2018-01-15 17:56 UTC] peehaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

http://php.net/manual/en/migration71.new-features.php
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 14:01:31 2024 UTC