Skip to content

Commit c82443a

Browse files
committed
Initial implementation
0 parents  commit c82443a

17 files changed

+459
-0
lines changed

‎.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true

‎.gitattributes

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/tests/ export-ignore
2+
/.editorconfig export-ignore
3+
/.gitattributes export-ignore
4+
/.gitignore export-ignore
5+
/.php_cs.dist export-ignore
6+
/.travis.yml export-ignore

‎.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/.php_cs
2+
/.php_cs.cache
3+
/composer.lock
4+
/vendor/

‎.php_cs.dist

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
$header = <<<'EOF'
4+
This file is part of PHP CS Fixer / PHPUnit Constraint IsIdenticalString.
5+
6+
(c) Dariusz Rumiński <dariusz.ruminski@gmail.com>
7+
8+
This source file is subject to the MIT license that is bundled
9+
with this source code in the file LICENSE.
10+
EOF;
11+
12+
$finder = PhpCsFixer\Finder::create()
13+
->exclude('tests/Fixtures')
14+
->in(__DIR__)
15+
;
16+
17+
if (PHP_VERSION_ID < 70000) {
18+
$finder
19+
->notPath('tests/Test/Constraint/IsIdenticalStringForV7.php')
20+
;
21+
}
22+
23+
return PhpCsFixer\Config::create()
24+
->setRiskyAllowed(true)
25+
->setRules([
26+
// '@PHP56Migration' => true,
27+
'@PHPUnit60Migration:risky' => true,
28+
'@Symfony' => true,
29+
'@Symfony:risky' => true,
30+
'align_multiline_comment' => true,
31+
'array_indentation' => true,
32+
'array_syntax' => ['syntax' => 'short'],
33+
'blank_line_before_statement' => true,
34+
'combine_consecutive_issets' => true,
35+
'combine_consecutive_unsets' => true,
36+
'comment_to_phpdoc' => true,
37+
'compact_nullable_typehint' => true,
38+
'escape_implicit_backslashes' => true,
39+
'explicit_indirect_variable' => true,
40+
'explicit_string_variable' => true,
41+
'final_internal_class' => true,
42+
'fully_qualified_strict_types' => true,
43+
'function_to_constant' => ['functions' => ['get_class', 'get_called_class', 'php_sapi_name', 'phpversion', 'pi']],
44+
'header_comment' => ['header' => $header],
45+
'heredoc_to_nowdoc' => true,
46+
'list_syntax' => ['syntax' => 'long'],
47+
'method_argument_space' => ['ensure_fully_multiline' => true],
48+
'method_chaining_indentation' => true,
49+
'multiline_comment_opening_closing' => true,
50+
'no_alternative_syntax' => true,
51+
'no_extra_blank_lines' => ['tokens' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block']],
52+
'no_null_property_initialization' => true,
53+
'no_short_echo_tag' => true,
54+
'no_superfluous_elseif' => true,
55+
'no_unneeded_curly_braces' => true,
56+
'no_unneeded_final_method' => true,
57+
'no_unreachable_default_argument_value' => true,
58+
'no_useless_else' => true,
59+
'no_useless_return' => true,
60+
'ordered_class_elements' => true,
61+
'ordered_imports' => true,
62+
'php_unit_ordered_covers' => true,
63+
'php_unit_set_up_tear_down_visibility' => true,
64+
'php_unit_strict' => true,
65+
'php_unit_test_annotation' => true,
66+
'php_unit_test_class_requires_covers' => true,
67+
'phpdoc_add_missing_param_annotation' => true,
68+
'phpdoc_order' => true,
69+
'phpdoc_types_order' => true,
70+
'semicolon_after_instruction' => true,
71+
'single_line_comment_style' => true,
72+
'strict_comparison' => true,
73+
'strict_param' => true,
74+
'string_line_ending' => true,
75+
'yoda_style' => true,
76+
])
77+
->setFinder($finder)
78+
;

‎.travis.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
sudo: false
2+
3+
git:
4+
depth: 1
5+
6+
cache:
7+
directories:
8+
- $HOME/.composer
9+
10+
language: php
11+
12+
php:
13+
- 5.6
14+
- 7.0
15+
- 7.1
16+
- 7.2
17+
- nightly
18+
19+
env:
20+
global:
21+
- DEFAULT_COMPOSER_FLAGS="--no-interaction --no-progress"
22+
- COMPOSER_FLAGS=""
23+
24+
stages:
25+
- Static Code Analysis
26+
- Test
27+
28+
before_install:
29+
# turn off XDebug
30+
- phpenv config-rm xdebug.ini || return 0
31+
32+
# Composer: boost installation
33+
- composer global show -ND 2>&1 | grep "hirak/prestissimo" || travis_retry composer global require $DEFAULT_COMPOSER_FLAGS hirak/prestissimo
34+
35+
install:
36+
- composer update $DEFAULT_COMPOSER_FLAGS $COMPOSER_FLAGS
37+
- composer info -D | sort
38+
39+
script:
40+
- vendor/bin/phpunit
41+
42+
jobs:
43+
include:
44+
-
45+
stage: Static Code Analysis
46+
php: 7.2
47+
install:
48+
- travis_retry composer update -d dev-tools $DEFAULT_COMPOSER_FLAGS
49+
- composer info -d dev-tools -D | sort
50+
script:
51+
- composer validate --strict || travis_terminate 1
52+
- composer normalize -d ./dev-tools ./../composer.json --dry-run || travis_terminate 1
53+
- dev-tools/vendor/bin/phpmd src,tests text phpmd.xml || travis_terminate 1
54+
- dev-tools/vendor/bin/php-cs-fixer fix --diff --dry-run -v || travis_terminate 1

‎LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2018-now Dariusz Rumiński
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is furnished
10+
to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

‎composer.json

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "php-cs-fixer/phpunit-constraint-isidenticalstring",
3+
"type": "library",
4+
"description": "Constraint for testing strings considering not-same line endings.",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Dariusz Rumiński",
9+
"email": "dariusz.ruminski@gmail.com"
10+
}
11+
],
12+
"require": {
13+
"php": "^5.5 || ^7.0",
14+
"phpunit/phpunit": "^5.7.23 || ^6.4.3 || ^7.0",
15+
"phpunitgoodpractices/polyfill": "^1.0"
16+
},
17+
"conflict": {
18+
"hhvm": "*"
19+
},
20+
"require-dev": {
21+
"johnkary/phpunit-speedtrap": "^1.1 || ^2.0 || ^3.0",
22+
"symfony/phpunit-bridge": "^3.2.2 || ^4.0"
23+
},
24+
"config": {
25+
"optimize-autoloader": true,
26+
"sort-packages": true
27+
},
28+
"autoload": {
29+
"psr-4": {
30+
"PhpCsFixer\\PhpunitConstraintIsIdenticalString\\": "src/"
31+
},
32+
"files": [
33+
"src/Constraint/IsIdenticalString.php"
34+
]
35+
},
36+
"autoload-dev": {
37+
"psr-4": {
38+
"PhpCsFixer\\PhpunitConstraintIsIdenticalString\\Tests\\": "tests/"
39+
}
40+
}
41+
}

‎dev-tools/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/composer.lock
2+
/vendor/

‎dev-tools/composer.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"require": {
3+
"php": "^7.2"
4+
},
5+
"conflict": {
6+
"hhvm": "*"
7+
},
8+
"require-dev": {
9+
"friendsofphp/php-cs-fixer": "^2.11",
10+
"localheinz/composer-normalize": "^0.6.0",
11+
"maglnet/composer-require-checker": "^0.1.6",
12+
"mi-schi/phpmd-extension": "^4.2.1",
13+
"phpmd/phpmd": "^2.6.0"
14+
},
15+
"config": {
16+
"optimize-autoloader": true,
17+
"sort-packages": true
18+
}
19+
}

‎phpmd.xml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="friendsofphp/php-cs-fixer"
3+
xmlns="http://pmd.sf.net/ruleset/1.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
6+
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"
7+
>
8+
<rule ref="rulesets/controversial.xml/CamelCaseClassName" />
9+
<rule ref="rulesets/controversial.xml/CamelCaseMethodName" />
10+
<rule ref="rulesets/controversial.xml/CamelCaseParameterName" />
11+
<rule ref="rulesets/controversial.xml/CamelCasePropertyName" />
12+
<rule ref="rulesets/controversial.xml/CamelCaseVariableName" />
13+
14+
<rule ref="rulesets/design.xml/DevelopmentCodeFragment" />
15+
<rule ref="rulesets/design.xml/EvalExpression" />
16+
<rule ref="rulesets/design.xml/ExitExpression" />
17+
<rule ref="rulesets/design.xml/GotoStatement" />
18+
19+
<rule ref="rulesets/naming.xml/ConstantNamingConventions" />
20+
21+
<rule ref="../../../../../mi-schi/phpmd-extension/rulesets/cleancode.xml/DataStructureMethods" />
22+
<rule ref="../../../../../mi-schi/phpmd-extension/rulesets/cleancode.xml/SwitchStatement" />
23+
24+
<rule ref="../../../../../mi-schi/phpmd-extension/rulesets/naming.xml/CommentDescription">
25+
<properties>
26+
<property name="percent" value="70" />
27+
</properties>
28+
</rule>
29+
</ruleset>

‎phpunit.xml.dist

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit
4+
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
5+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
6+
backupGlobals="false"
7+
backupStaticAttributes="false"
8+
beStrictAboutChangesToGlobalState="true"
9+
beStrictAboutOutputDuringTests="true"
10+
beStrictAboutTestSize="true"
11+
beStrictAboutTestsThatDoNotTestAnything="true"
12+
beStrictAboutTodoAnnotatedTests="true"
13+
bootstrap="./vendor/autoload.php"
14+
colors="true"
15+
columns="max"
16+
convertErrorsToExceptions="true"
17+
convertNoticesToExceptions="true"
18+
convertWarningsToExceptions="true"
19+
processIsolation="false"
20+
stopOnFailure="false"
21+
verbose="true"
22+
>
23+
<testsuites>
24+
<testsuite>
25+
<directory>./tests</directory>
26+
</testsuite>
27+
</testsuites>
28+
29+
<filter>
30+
<whitelist>
31+
<directory>./src</directory>
32+
</whitelist>
33+
</filter>
34+
35+
<listeners>
36+
<listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener">
37+
<arguments>
38+
<array>
39+
<element key="slowThreshold">
40+
<integer>100</integer>
41+
</element>
42+
</array>
43+
</arguments>
44+
</listener>
45+
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
46+
</listeners>
47+
</phpunit>

‎src/.gitkeep

Whitespace-only changes.

‎src/Constraint/IsIdenticalString.php

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
/*
4+
* This file is part of PHP CS Fixer / PHPUnit Constraint IsIdenticalString.
5+
*
6+
* (c) Dariusz Rumiński <dariusz.ruminski@gmail.com>
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
12+
namespace PhpCsFixer\PhpunitConstraintIsIdenticalString\Constraint;
13+
14+
if (version_compare(\PHPUnit\Runner\Version::id(), '7.0.0') < 0) {
15+
class_alias(IsIdenticalStringForV5::class, IsIdenticalString::class);
16+
} else {
17+
class_alias(IsIdenticalStringForV7::class, IsIdenticalString::class);
18+
}
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
/*
4+
* This file is part of PHP CS Fixer / PHPUnit Constraint IsIdenticalString.
5+
*
6+
* (c) Dariusz Rumiński <dariusz.ruminski@gmail.com>
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
12+
namespace PhpCsFixer\PhpunitConstraintIsIdenticalString\Constraint;
13+
14+
if (!class_exists('PHPUnit\Framework\Constraint\IsIdentical')) {
15+
class_alias('PHPUnit_Framework_Constraint_IsIdentical', 'PHPUnit\Framework\Constraint\IsIdentical');
16+
}
17+
18+
use PHPUnit\Framework\Constraint\IsIdentical;
19+
20+
/**
21+
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
22+
*
23+
* @internal
24+
*/
25+
final class IsIdenticalStringForV5 extends IsIdentical
26+
{
27+
protected function additionalFailureDescription($other)
28+
{
29+
if (
30+
$other === $this->value
31+
|| preg_replace('/(\r\n|\n\r|\r)/', "\n", $other) !== preg_replace('/(\r\n|\n\r|\r)/', "\n", $this->value)
32+
) {
33+
return '';
34+
}
35+
36+
return ' #Warning: Strings contain different line endings! Debug using remapping ["\r" => "R", "\n" => "N", "\t" => "T"]:'
37+
."\n"
38+
.' -'.str_replace(["\r", "\n", "\t"], ['R', 'N', 'T'], $other)
39+
."\n"
40+
.' +'.str_replace(["\r", "\n", "\t"], ['R', 'N', 'T'], $this->value);
41+
}
42+
}

0 commit comments

Comments
 (0)