Blame view

vendor/nikic/php-parser/test/bootstrap.php 446 Bytes
6c4edfa3   Alexandre   First Commit LabI...
1
2
3
4
5
6
7
<?php

namespace PhpParser;

require __DIR__ . '/../vendor/autoload.php';

function canonicalize($str) {
1e1f0c1c   Alexandre   Mise à jour CakePHP
8
9
    // normalize EOL style
    $str = str_replace("\r\n", "\n", $str);
6c4edfa3   Alexandre   First Commit LabI...
10

1e1f0c1c   Alexandre   Mise à jour CakePHP
11
12
    // trim newlines at end
    $str = rtrim($str, "\n");
6c4edfa3   Alexandre   First Commit LabI...
13

1e1f0c1c   Alexandre   Mise à jour CakePHP
14
15
16
17
18
19
    // remove trailing whitespace on all lines
    $lines = explode("\n", $str);
    $lines = array_map(function($line) {
        return rtrim($line, " \t");
    }, $lines);
    return implode("\n", $lines);
6c4edfa3   Alexandre   First Commit LabI...
20
}