sebastianbergmann / phpunit

The PHP Unit Testing framework.
https://phpunit.de/
BSD 3-Clause "New" or "Revised" License
19.69k stars 2.2k forks source link

Regex umlaut inconsistencies between PHPUnit and just PHP, specific on Arch #4860

Closed FlyingHelix closed 2 years ago

FlyingHelix commented 2 years ago
Q A
PHPUnit version 9.5.11
PHP version 8.0.14
Installation Method Composer

Current behavior

When running a specific Regex it does not recognize ü, ä, ö, ß and similar, when not using the pattern modifier u at the end, although when running in normal PHP, without the extends TestCase, it recognizes fine. Only happens on Arch Linux so far. The files are UTF-8 encoded.

How to reproduce

When running Arch Linux, with kernel 5.15.13


use PHPUnit\Framework\TestCase;

class OutputTest extends TestCase{
  public function testOutput() {
    var_dump(preg_match('/^[\p{L}\p{Mn}\W]{8,128}$/', 'gülitgesWort'));
    var_dump(preg_match('/^[\p{L}\p{Mn}\W]{8,128}$/u', 'gülitgesWort'));
  }
}

$a = new OutputTest();
$a->testOutput();
?>

produces int(0) int(1)

but

class OutputTest{
  public function testOutput() {
    var_dump(preg_match('/^[\p{L}\p{Mn}\W]{8,128}$/', 'gülitgesWort'));
    var_dump(preg_match('/^[\p{L}\p{Mn}\W]{8,128}$/u', 'gülitgesWort'));
  }
}

$a = new OutputTest();
$a->testOutput();
?>

produces int(1) int(1)

while on Windows 21H2, PopOS 21.10 and the php:alpine docker image both produce the same int(1), int(1). I am not sure, if this is specific to my installation, but i am setting up another Arch bases system to test on at the moment. I also asked in the Arch forum, if other arch users experience it as well, it may as well be an Arch issue, and not phpunits. composer info is


evenement/evenement                v3.0.1  Événement is a very simple event dispatching library for PHP
ezyang/htmlpurifier                v4.14.0 Standards compliant HTML filter written in PHP
iio/libmergepdf                    4.0.4   Library for merging multiple PDFs
league/commonmark                  1.6.6   Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and Github-Flavored Markdown (GFM)
league/html-to-markdown            4.10.0  An HTML-to-markdown conversion helper for PHP
myclabs/deep-copy                  1.10.2  Create deep copies (clones) of your objects
nikic/fast-route                   v1.3.0  Fast request router for PHP
nikic/php-parser                   v4.13.2 A PHP parser written in PHP
phar-io/manifest                   2.0.3   Component for reading phar.io manifest information from a PHP Archive (PHAR)
phar-io/version                    3.1.0   Library for handling version information and constraints
phpdocumentor/reflection-common    2.2.0   Common reflection classes used by phpdocumentor to reflect the code structure
phpdocumentor/reflection-docblock  5.3.0   With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBl...
phpdocumentor/type-resolver        1.6.0   A PSR-5 based resolver of Class names, Types and Structural Element Names
phpmailer/phpmailer                v6.5.3  PHPMailer is a full-featured email creation and transfer class for PHP
phpspec/prophecy                   v1.15.0 Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage          9.2.10  Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator          3.0.6   FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-invoker                3.1.1   Invoke callables with a timeout
phpunit/php-text-template          2.0.4   Simple template engine.
phpunit/php-timer                  5.0.3   Utility class for timing
phpunit/phpunit                    9.5.11  The PHP Unit Testing framework.
psr/http-message                   1.0.1   Common interface for HTTP messages
react/cache                        v1.1.1  Async, Promise-based cache interface for ReactPHP
react/dns                          v1.9.0  Async DNS resolver for ReactPHP
react/event-loop                   v1.2.0  ReactPHP's core reactor event loop that libraries can use for evented I/O.
react/http                         v1.5.0  Event-driven, streaming HTTP client and server implementation for ReactPHP
react/promise-stream               v1.3.0  The missing link between Promise-land and Stream-land for ReactPHP
react/promise-timer                v1.8.0  A trivial implementation of timeouts for Promises, built on top of ReactPHP.
react/promise                      v2.8.0  A lightweight implementation of CommonJS Promises/A for PHP
react/socket                       v1.10.0 Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP
react/stream                       v1.2.0  Event-driven readable and writable streams for non-blocking I/O in ReactPHP
ringcentral/psr7                   1.3.0   PSR-7 message implementation
sebastian/cli-parser               1.0.1   Library for parsing CLI options
sebastian/code-unit                1.0.8   Collection of value objects that represent the PHP code units
sebastian/code-unit-reverse-lookup 2.0.3   Looks up which function or method a line of code belongs to
sebastian/comparator               4.0.6   Provides the functionality to compare PHP values for equality
sebastian/complexity               2.0.2   Library for calculating the complexity of PHP code units
sebastian/diff                     4.0.4   Diff implementation
sebastian/environment              5.1.3   Provides functionality to handle HHVM/PHP environments
sebastian/exporter                 4.0.4   Provides the functionality to export PHP variables for visualization
sebastian/global-state             5.0.3   Snapshotting of global state
sebastian/lines-of-code            1.0.3   Library for counting the lines of code in PHP source code
sebastian/object-enumerator        4.0.4   Traverses array structures and object graphs to enumerate all referenced objects
sebastian/object-reflector         2.0.4   Allows reflection of object attributes, including inherited and non-public ones
sebastian/recursion-context        4.0.4   Provides functionality to recursively process PHP variables
sebastian/resource-operations      3.0.3   Provides a list of PHP built-in functions that operate on resources
sebastian/type                     2.3.4   Collection of value objects that represent the types of the PHP type system
sebastian/version                  3.0.2   Library that helps with managing the version number of Git-hosted PHP projects
setasign/fpdi                      v2.3.6  FPDI is a collection of PHP classes facilitating developers to read pages from existing PDF documents and use them as templates in FPDF. Becau...
symfony/polyfill-ctype             v1.24.0 Symfony polyfill for ctype functions
tecnickcom/tcpdf                   6.4.4   TCPDF is a PHP class for generating PDF documents and barcodes.
theseer/tokenizer                  1.2.1   A small library for converting tokenized PHP source code into XML and potentially other formats
tototoshi/staticmock               4.0.1   A mockery-like DSL to replace static method in test.
webmozart/assert                   1.10.0  Assertions to validate method input/output with nice error messages.```
sebastianbergmann commented 2 years ago

Sorry, but I stopped reading after "Only happens on Arch Linux so far" and "I am not sure, if this is specific to my installation".