"Fossies" - the Fresh Open Source Software Archive

Member "4.6.1/composer/pimple/pimple/ext/pimple/tests/012.phpt" (8 Apr 2021, 507 Bytes) of package /linux/www/studip-4.6.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 --TEST--
    2 Test service factory
    3 --SKIPIF--
    4 <?php if (!extension_loaded("pimple")) print "skip"; ?>
    5 --FILE--
    6 <?php
    7 
    8 $p = new Pimple\Container();
    9 
   10 $p->factory($f = function() { var_dump('called-1'); return 'ret-1';});
   11 
   12 $p[] = $f;
   13 
   14 $p[] = function () { var_dump('called-2'); return 'ret-2'; };
   15 
   16 var_dump($p[0]);
   17 var_dump($p[0]);
   18 var_dump($p[1]);
   19 var_dump($p[1]);
   20 ?>
   21 --EXPECTF--
   22 string(8) "called-1"
   23 string(5) "ret-1"
   24 string(8) "called-1"
   25 string(5) "ret-1"
   26 string(8) "called-2"
   27 string(5) "ret-2"
   28 string(5) "ret-2"