Skip to content

Latest commit

 

History

History
58 lines (41 loc) · 1.47 KB

UPGRADING.md

File metadata and controls

58 lines (41 loc) · 1.47 KB

2.1 to 3.0

Serializer changes

The s9e\RegexpBuilder\Serializer::$useNonCapturingGroups property has been removed and replaced with s9e\RegexpBuilder\Serializer::$groupType.

1.x to 2.0

Constructor signature

Starting with 2.0, parameter bags (configuration passed as an associative array) have been replaced with named parameters and public APIs. Named parameters are easier to inspect and analyse.

Here is an example of the old, unsupported configuration:

$builder = new s9e\RegexpBuilder\Builder([
	'input'         => 'Utf8',
	'inputOptions'  => ['useSurrogates' => true],
	'output'        => 'JavaScript',
	'outputOptions' => ['case' => 'lower']
]);

Here is the same example using the 2.0 API:

$builder = new s9e\RegexpBuilder\Builder(
	input:  new s9e\RegexpBuilder\Input\Utf8,
	output: new s9e\RegexpBuilder\Output\JavaScript
);
$builder->input->useSurrogates = true;
$builder->output->hexFormat = s9e\RegexpBuilder\Output\HexFormat::LowerCase;

The same result can be obtained using a factory, which is the recommended way to create an instance. Here we use the JavaScript factory:

$builder = new s9e\RegexpBuilder\Factory\JavaScript::getBuilder();
$builder->output->hexFormat = s9e\RegexpBuilder\Output\HexFormat::LowerCase;

Meta sequences

Old, unsupported:

$builder = new s9e\RegexpBuilder\Builder([
	'meta' => ['*' => '.*']
]);

2.0 API:

$builder = new s9e\RegexpBuilder\Builder;
$builder->meta->set('*', '.*');