Bug #73746 [NEW]: Method that returns string returns UNKNOWN:0 instead

From: Date: Thu, 15 Dec 2016 08:52:23 +0000
Subject: Bug #73746 [NEW]: Method that returns string returns UNKNOWN:0 instead
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-206026@lists.php.net to get a copy of this message
From:             info at mhlavac dot net
Operating system: Ubuntu 16.04
PHP version:      7.1.0
Package:          *General Issues
Bug Type:         Bug
Bug description:Method that returns string returns UNKNOWN:0 instead

Description:
------------
We upgraded to php 7.1 and noticed some tests are failing. This method
call returns UNKNOWN:0 since the upgrade. If we remove method return
type, then we get expected string that is really returned by the
method.

I noticed that this "sometimes" doesn't happen for the first run, so it
might be opcache related.

I noticed, removing self::CZ and changing it to CountryMapping::CZ fixes
the issue. Also removing return type fixes it as well.

Opcache is enabled. Settings:
opcache.blacklist_filename => no value => no value
opcache.consistency_checks => 0 => 0
opcache.dups_fix => Off => Off
opcache.enable => On => On
opcache.enable_cli => On => On
opcache.enable_file_override => Off => Off
opcache.error_log => no value => no value
opcache.fast_shutdown => 1 => 1
opcache.file_cache => no value => no value
opcache.file_cache_consistency_checks => 1 => 1
opcache.file_cache_only => 0 => 0
opcache.file_update_protection => 2 => 2
opcache.force_restart_timeout => 180 => 180
opcache.huge_code_pages => Off => Off
opcache.inherited_hack => On => On
opcache.interned_strings_buffer => 16 => 16
opcache.lockfile_path => /tmp => /tmp
opcache.log_verbosity_level => 1 => 1
opcache.max_accelerated_files => 65407 => 65407
opcache.max_file_size => 0 => 0
opcache.max_wasted_percentage => 5 => 5
opcache.memory_consumption => 192 => 192
opcache.opt_debug_level => 0 => 0
opcache.optimization_level => 0x7FFFBFFF => 0x7FFFBFFF
opcache.preferred_memory_model => no value => no value
opcache.protect_memory => 0 => 0
opcache.restrict_api => no value => no value
opcache.revalidate_freq => 0 => 0
opcache.revalidate_path => Off => Off
opcache.save_comments => 1 => 1
opcache.use_cwd => On => On
opcache.validate_permission => Off => Off
opcache.validate_root => Off => Off
opcache.validate_timestamps => On => On


Test script:
---------------
<?php
namespace Core\Bundle\Service\Property\Room\Rooms;

class CountryMapping
{
    const CZ = 'CZ';
    const EN = 'EN';

    public function get(string $countryIsoCode = null) : string // Works
correctly if return type is removed
    {
        switch (strtoupper($countryIsoCode)) {
            case 'CZ':
            case 'SK':
                return self::CZ; // Works correctly if changed to
CountryMapping::CZ
            default:
                return self::EN; // Works correctly if changed to
CountryMapping::EN
        }
    }
}

$mapping = new CountryMapping();
var_dump($mapping->get('CZ'));


Expected result:
----------------
string(2) "CZ"

Actual result:
--------------
UNKNOWN:0

-- 
Edit bug report at https://bugs.php.net/bug.php?id=73746&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=73746&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=73746&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=73746&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=73746&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=73746&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=73746&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=73746&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=73746&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=73746&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=73746&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=73746&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=73746&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=73746&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73746&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=73746&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=73746&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=73746&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=73746&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=73746&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=73746&r=mysqlcfg



Thread (3 messages)

« previous php.bugs (#206026) next »