Issue Task Closed

#97553Introduce string fragment extraction

Oliver Hader 05/05/22, 06:51 updated 02/08/23, 16:05

Description

When working with variable interpolation and similar scenarios, in most cases variables, constants, expressions, … are embedded in a solid string and can only be identified and extracted by the corresponding “reader” or “parser”.

This string fragment splitter aims to introduce a simpler way for extracting and working with these embedded fragments.

$pattern = new StringFragmentPattern(
  StringFragmentSplitter::TYPE_EXPRESSION,
  '%[^%]+%'
);
$splitter = new StringFragmentSplitter($pattern);
$collection = $splitter->split(
  'Hello %variable% World!'
  FLAG_UNMATCHED_AS_NULL | FLAG_CATCH_SPACES
);
// results in having
// + StringFragment(type: 'raw', value: 'Hello')
// + StringFragment(type: 'expression', value: ' %variable% ')
// + StringFragment(type: 'raw', value: 'World!')

Reviews 4

History 414

  1. Gerrit Code Review pushed patch set 4 for main to change 74517 status New Under Review 05/05/22, 06:53

  2. Gerrit Code Review pushed patch set 5 for main to change 74517 06/01/22, 11:30

  3. Gerrit Code Review 06/01/22, 11:33 Patch set 2 for branch *main* of project *Teams/Security/TYPO3v4-Core* has been pushed to the review server. It is available at https://review.typo3.org/c/Teams/Security/TYPO3v4-Core/+/74520

  4. Oliver Hader commented and changed status Under Review On Hold 06/02/22, 11:44

    Trapped in discussion loop

  5. Gerrit Code Review pushed patch set 6 for main to change 74517 status On Hold Under Review 12/06/22, 12:35

  6. Gerrit Code Review pushed patch set 7 for main to change 74517 12/06/22, 13:34

  7. Gerrit Code Review 12/07/22, 10:09 Patch set 3 for branch *main* of project *Teams/Security/TYPO3v4-Core* has been pushed to the review server. It is available at https://review.typo3.org/c/Teams/Security/TYPO3v4-Core/+/74520

  8. Gerrit Code Review pushed patch set 1 for 11.5 to change 76945 12/07/22, 13:02

  9. Gerrit Code Review pushed patch set 1 for 10.4 to change 76947 12/07/22, 13:11

  10. Gerrit Code Review 12/07/22, 13:30 Patch set 4 for branch *main* of project *Teams/Security/TYPO3v4-Core* has been pushed to the review server. It is available at https://review.typo3.org/c/Teams/Security/TYPO3v4-Core/+/74520

  11. Oliver Hader commented and changed status Under Review Resolved done 0 % 100 % 12/07/22, 13:35

    Applied in changeset commit:36459901858eb7ad3f2ac3789fc53c61b65c2589.

  12. Gerrit Code Review pushed patch set 1 for 12.1 to change 77112 status Resolved Under Review 12/13/22, 11:07

  13. Oliver Hader commented and changed status Under Review Resolved 12/13/22, 11:20

    Applied in changeset commit:645c9cab2dc9431a0e940176c8754b66ccef5543.

  14. Benni Mack changed status Resolved Closed 02/08/23, 16:05