Beispiel #1
0
Datei: good.php Projekt: mohc/vdd
!($x + $y);
// Operator line break for long lines.
$x = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1;
$x = $test ? -1 : 1;
$x = $test ? 1 : -1;
// Casting has a space.
(int) $i;
// The last item in an multiline array should be followed by a comma.
// But not in a inline array.
$a = array();
$a = array('1', '2', '3');
$a = array('1', '2', '3');
$a = array('1', '2', array('3'));
$a = array('1', '2', array('one', 'two', 'three', array('key' => $value, 'title' => 'test')));
// Array indentation.
$x = array('foo' => 'bar', 'fi' => long_function_call('hsdfsdmfsldkfnmdflkngdfngfg', 'fghfghfghfghfgh', $z), 'a' => 'b', 'foo' => array('blu' => 1, 'f' => x(1) + array('h' => 'x')));
// Arrays in function calls.
foo(array('value' => 0, 'description' => t('xyz @url', array('@url' => 'http://example.com'))));
// Pretty array layout.
$a = array('title' => 1, 'weight' => 2, 'callback' => 3);
// Arrays with multi line strings.
$query = db_query("\n  SELECT * FROM {foobar} WHERE nid IN (1, 2, 3)\n  AND date BETWEEN '%s' AND '%s'\n  ", array(':from_date' => $from_date, ':to_date' => $to_date));
// Array with multi line comments.
$query = db_query("\n  SELECT * FROM {foobar} WHERE nid IN (1, 2, 3)\n  AND date BETWEEN '%s' AND '%s'", array(':from_date' => $from_date, ':to_date' => $to_date));
// Item assignment operators must be prefixed and followed by a space.
$a = array('one' => '1', 'two' => '2');
foreach ($a as $key => $value) {
}
// If conditions have a space before and after the condition parenthesis.
if (TRUE || TRUE) {
    $i;
Beispiel #2
0
// The last item in an multiline array should be followed by a comma.
// But not in a inline array.
$a = array();
$a = array('1', '2', '3');
$a = array('1', '2', '3');
$a = array('1', '2', array('3'));
$a = array('1', '2', array('one', 'two', 'three', array('key' => $value, 'title' => 'test')));
// Short array syntax.
$a = [];
$a = ['1', '2', '3'];
$a = ['1', '2', '3'];
$a = ['1', '2', ['3']];
$a = ['1', '2', ['one', 'two', 'three', ['key' => $value, 'title' => 'test']]];
// Array indentation.
$x = array('foo' => 'bar', 'fi' => long_function_call('hsdfsdmfsldkfnmdflkngdfngfg', 'fghfghfghfghfgh', $z), 'a' => 'b', 'foo' => array('blu' => 1, 'f' => x(1) + array('h' => 'x')));
$x = ['foo' => 'bar', 'fi' => long_function_call('hsdfsdmfsldkfnmdflkngdfngfg', 'fghfghfghfghfgh', $z), 'a' => 'b', 'foo' => ['blu' => 1, 'f' => x(1) + ['h' => 'x']]];
// Arrays in function calls.
foo(array('value' => 0, 'description' => t('xyz @url', array('@url' => 'http://example.com'))));
// Pretty array layout.
$a = array('title' => 1, 'weight' => 2, 'callback' => 3);
$a = ['title' => 1, 'weight' => 2, 'callback' => 3];
// Arrays with multi line strings.
$query = db_query("\n  SELECT * FROM {foobar} WHERE nid IN (1, 2, 3)\n  AND date BETWEEN '%s' AND '%s'\n  ", array(':from_date' => $from_date, ':to_date' => $to_date));
$query = db_query("\n  SELECT * FROM {foobar} WHERE nid IN (1, 2, 3)\n  AND date BETWEEN '%s' AND '%s'\n  ", [':from_date' => $from_date, ':to_date' => $to_date]);
// Array with multi line comments.
$query = db_query("\n  SELECT * FROM {foobar} WHERE nid IN (1, 2, 3)\n  AND date BETWEEN '%s' AND '%s'", array(':from_date' => $from_date, ':to_date' => $to_date));
$query = db_query("\n  SELECT * FROM {foobar} WHERE nid IN (1, 2, 3)\n  AND date BETWEEN '%s' AND '%s'", [':from_date' => $from_date, ':to_date' => $to_date]);
// Array with multi-line constant string in it.
$array = array('name' => 'example_a', 'title' => 'Example A', 'xml' => '
<foo>
  <bar>