Skip to content

Latest commit

 

History

History
129 lines (94 loc) · 2.91 KB

upgrade.md

File metadata and controls

129 lines (94 loc) · 2.91 KB

Upgrade Guide

Upgrading To 3.2 From 3.1

Grammar Package Removed

Likelihood Of Impact: Medium

The phplrt/grammar and phplrt/grammar-contracts has been removed. All classes and interfaces associated with this package have been moved inside the phplrt/parser package.

  • All classes Phplrt\Grammar\* has been renamed to Phplrt\Parser\Grammar\*.
  • All interfaces Phplrt\Contracts\Grammar\* has been renamed to Phplrt\Parser\Grammar\*.

Buffer Package Has Been Moved

Likelihood Of Impact: Medium

  • Interface Phplrt\Contracts\Lexer\BufferInterface has been moved into Phplrt\Buffer\BufferInterface.
  • All classes Phplrt\Lexer\Buffer\* has been moved into Phplrt\Buffer\*.

Upgrading To 3.0 From 2.3

PHP 7.4 Required

Likelihood Of Impact: Medium

PHP 7.1 will no longer be actively maintained as of December 2019. Therefore, phplrt 3.0 requires PHP 7.4 or greater.

Compilation To PHP Class Was Removed

Likelihood Of Impact: Medium

The compiler code generation in the full-fledged PHP class has been removed and has been replaced by the generation of configs.

$compiler = new \Phplrt\Compiler\Compiler();

/** @var \Phplrt\Compiler\Generator $assembly */
$assembly = $compiler->build();
  • Method Phplrt\Compiler\Generator::generateGrammar(string $class): string has been removed.
  • Method Phplrt\Compiler\Generator::generateBuilder(string $class): string has been removed.
  • Method Phplrt\Compiler\Generator::generate(string $class): string has been modified to Phplrt\Compiler\Generator::generate(): string.

Old 2.3.x Behaviour

echo $assembly->generate('ClassName');
// class ClassName extends Parser 
// {
//    ...
// }

New 3.x Behaviour

echo $assembly->generate();
// return [
//     'tokens' => [...],
//     'rules'  => [...],
//     ...etc
// ];

Zend Generator Has Been Replaced By Laminas Generator

Likelihood Of Impact: Low

The Zend project has been abandoned and is no longer supported: https://getlaminas.org/blog/2019-12-31-out-with-the-old-in-with-the-new.html

Change the logic of the prependMany method

Likelihood Of Impact: Medium

In the phplrt 2.3, calling the prependMany() method added tokens by default in the following order:

$lexer->prependMany([
    'a' => 'a',
    'b' => 'b',
    'c' => 'c',
]);

// phplrt 2.3 lexer's data:
//  [
//      'c' => 'c',
//      'b' => 'b',
//      'a' => 'a',
//  ]

// New behavior:
//  [
//      'a' => 'a',
//      'b' => 'b',
//      'c' => 'c',
//  ]

In order to return to the old behavior, explicit transfer of the second argument is required:

$lexer->prependMany([
    'a' => 'a',
    'b' => 'b',
    'c' => 'c',
], true);

// Expected token definitions:
//  [
//      'c' => 'c',
//      'b' => 'b',
//      'a' => 'a',
//  ]