Что нового в PHP 7.2

Закрывающая запятая для любых списков

wiki: https://wiki.php.net/rfc/list-syntax-trailing-commas

В следующих списках допускается использование запятых в конце:

  • Сгруппированные пространства имен.
  • Аргументы функций/методов (объявления и вызовы).
  • Реализации интерфейсов в классе.
  • Реализации признаков в классе.
  • Списки членов класса.
  • Наследование переменных из родительской области видимости в анонимных функциях.
// Arrays (already possible)
$array = [1, 2, 3,];

// Grouped namepaces
use Foo\Bar\{ Foo, Bar, Baz, };

// Function/method arguments (call)
fooCall($arg1, $arg2, $arg3,);

class Foo implements
	// Interface implementations on a class
	FooInterface,
	BarInterface,
	BazInterface,
{
	// Trait implementations on a class
	use
		FooTrait,
		BarTrait,
		BazTrait,
	;

	// Class member lists
	const
		A = 1010,
		B = 1021,
		C = 1032,
		D = 1043,
	;
	protected
		$a = 'foo',
		$b = 'bar',
		$c = 'baz',
	;
	private
		$blah,
	;

	// Function/method arguments (declaration)
	function something(FooBarBazInterface $in, FooBarBazInterface $out,) : bool
	{
	}
}

// Inheriting variables from the parent scope in anonymous functions
$foo = function ( $bar ) use (
	$a,
	$b,
	$c,
) {
	// . . .
};

Заметка встроена в: PHP 5.3 - 8.5 — Синтаксис, Новинки