示例#1
0
<?php

/**
 * Test for formatting function call without arguments
 */
$a = array();
function definition()
{
}
class ClassDef
{
    private function emptyFunction()
    {
    }
}
functionCall();
$a = function () {
};
<?php

func(func(func(1, 2, ['required' => true])), 1.2, 'STRING');
$instance = new ClassName(['foo' => 'bar', 'member' => ClassName::class]);
functionCall('this', 'is', 'a', 'very', 'very', 'very', 'very', 'very', 'very', 'very', 'very', 'loooong', 'invocation');
functionCall('this', 'is', 'a', 'very', 'very', 'very', 'very', 'very', 'very', 'very', 'very', 'looong', 'invocation');
new static('canBeInOneLine');
new self('canBeInOneLine');
parent::__construct('canBeOneLine');
new Namespaced\ClassName('canBeOneLine');
namespaced\functionName('canBeOneLine');
<?php

$object->methodCall("\nfoo\nbar");
$object->methodCall('
foo
bar');
StaticClass::methodCall(<<<EOS
foo
bar
EOS
);
StaticClass::methodCall(<<<'EOS'
foo
bar
EOS
);
functionCall('Comment');
functionCall('Comment');
functionCall('Comment');
functionCall('Comment');
示例#4
0
文件: deref.php 项目: expobrain/phpcf
<?php

/**
 * test for formatting dereferencing
 */
"Dereferenced string double"[1];
'Dereferenced string single'[1];
array(1, 2, 3)[7];
[1, 2, 3][6];
functionCall()[45];
<?php

functionCall(['foo' => true, 'bar' => false]);
$object->methodCall('argument', 'argument', [['foo', 'bar']]);
$object->methodCall('argument', 'argument', [['foo', 'bar' => 'test', $key => 'value', 'key' => $value, $value]]);
functionCall('argument', 'argument', [array('foo', 'bar', 'baz')]);
$object->methodCall(['argument']);
$object->methodCall(['argument']);
$object->methodCall('argument', 'argument', [array('foo', 'bar')]);
示例#6
0
<?php

// simple
$a = [];
// next line
$b = [];
// no spaces
$c = [1, 2, 3];
// extra spaces
$d = [1, 2, 3];
// dereferenced call
$e = [1, 2, 3][2];
// passed as param in function
$f = functionCall([1, 2, 3], [4]);
// simply somewhere
[1, 2, 3345];
// nested
[[1, 2, 3], [4, 5, 6]];
if (true) {
    [123, 456];
}
[345];
array('a', [234, 345345, 8837673, 789], 'b');
array('a', [func() ? ['b'] : ['c']]);