mardi 7 février 2017

ReflectionMethod->getDocComment() does'nt seem to work on PHP 5.5

I'm trying to make an interface from reflectionMethods for one of my classes, and I've got a problem where the method getDocComments() fails on my staging environment.

Here is the test code I use :

<?php

class foo
{
    /**
     * Method bar description
     *
     * @param string $param1
     * @param int    $param2
     * @return array
     */
    public static function bar($param1, $param2 = 0)
    {
        return array();
    }
}

$r        = new ReflectionMethod('foo', 'bar');
$docBlock = $r->getDocComment();

echo $docBlock;

On my staging environment, $docBlock is empty (set to false if I var_dump() it). The PHP Version I have on the staging environment is PHP Version 5.5.30-1~dotdeb+7.1. On my local environment, with PHP Version 5.6.27-0+deb8u1, it seems to work.

The issue may be very specific to my environment though, I am not able to reproduce it on any nlyne php tester I found (I tested it with PHPTester and Online PHP Functions who allow to test against several versions of PHP, but none had the precise version I have on my environment.





Aucun commentaire:

Enregistrer un commentaire