Skip to content

Commit

Permalink
minor #5585 DX: make doc examples prettier (kubawerlos)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 2.18 branch.

Discussion
----------

DX: make doc examples prettier

- Makes all diff for doc examples having whote file content.
- Removes the line numbers e.g. `@@ -1,2 +1,2 @@` from diffs.

All interesting changes are in `src/Documentation/DocumentationGenerator.php` file.

Ping @julienfalque for review.

Commits
-------

23e5515 DX: make doc examples prettier
  • Loading branch information
keradus committed Apr 6, 2021
2 parents f01521b + 23e5515 commit 02675fc
Show file tree
Hide file tree
Showing 243 changed files with 242 additions and 467 deletions.
1 change: 0 additions & 1 deletion doc/rules/alias/array_push.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Example #1
--- Original
+++ New
@@ -1,2 +1,2 @@
<?php
-array_push($x, $y);
+$x[] = $y;
Expand Down
1 change: 0 additions & 1 deletion doc/rules/alias/backtick_to_shell_exec.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Example #1
--- Original
+++ New
@@ -1,3 +1,3 @@
<?php
-$plain = `ls -lah`;
-$withVar = `ls -lah $var1 ${var2} {$var3} {$var4[0]} {$var5->call()}`;
Expand Down
1 change: 0 additions & 1 deletion doc/rules/alias/ereg_to_preg.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Example #1
--- Original
+++ New
@@ -1 +1 @@
-<?php $x = ereg('[A-Z]');
+<?php $x = preg_match('/[A-Z]/D');
Expand Down
1 change: 0 additions & 1 deletion doc/rules/alias/mb_str_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Example #1
--- Original
+++ New
@@ -1,13 +1,13 @@
<?php
-$a = strlen($a);
-$a = strpos($a, $b);
Expand Down
2 changes: 0 additions & 2 deletions doc/rules/alias/no_alias_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ Example #1
--- Original
+++ New
@@ -1,22 +1,22 @@
<?php
-$a = chop($b);
-close($b);
Expand Down Expand Up @@ -87,7 +86,6 @@ With configuration: ``['sets' => ['@mbreg']]``.
--- Original
+++ New
@@ -1,3 +1,3 @@
<?php
$a = is_double($b);
-mbereg_search_getregs();
Expand Down
1 change: 0 additions & 1 deletion doc/rules/alias/no_alias_language_construct_call.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Example #1
--- Original
+++ New
@@ -1,2 +1,2 @@
<?php
-die;
+exit;
Expand Down
2 changes: 0 additions & 2 deletions doc/rules/alias/no_mixed_echo_print.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Example #1
--- Original
+++ New
@@ -1 +1 @@
-<?php print 'example';
+<?php echo 'example';
Expand All @@ -41,7 +40,6 @@ With configuration: ``['use' => 'print']``.
--- Original
+++ New
@@ -1 +1 @@
-<?php echo('example');
+<?php print('example');
Expand Down
1 change: 0 additions & 1 deletion doc/rules/alias/pow_to_exponentiation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Example #1
--- Original
+++ New
@@ -1,2 +1,2 @@
<?php
- pow($a, 1);
+ $a** 1;
Expand Down
3 changes: 0 additions & 3 deletions doc/rules/alias/random_api_migration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ Example #1
--- Original
+++ New
@@ -1,4 +1,4 @@
<?php
-$a = getrandmax();
-$a = rand($b, $c);
Expand All @@ -51,7 +50,6 @@ With configuration: ``['replacements' => ['getrandmax' => 'mt_getrandmax']]``.
--- Original
+++ New
@@ -1,4 +1,4 @@
<?php
-$a = getrandmax();
+$a = mt_getrandmax();
Expand All @@ -67,7 +65,6 @@ With configuration: ``['replacements' => ['rand' => 'random_int']]``.
--- Original
+++ New
@@ -1 +1 @@
-<?php $a = rand($b, $c);
+<?php $a = random_int($b, $c);
Expand Down
1 change: 0 additions & 1 deletion doc/rules/alias/set_type_to_cast.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Example #1
--- Original
+++ New
@@ -1,4 +1,4 @@
<?php
-settype($foo, "integer");
-settype($bar, "string");
Expand Down
2 changes: 0 additions & 2 deletions doc/rules/array_notation/array_syntax.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Example #1
--- Original
+++ New
@@ -1,2 +1,2 @@
<?php
-[1,2];
+array(1,2);
Expand All @@ -42,7 +41,6 @@ With configuration: ``['syntax' => 'short']``.
--- Original
+++ New
@@ -1,2 +1,2 @@
<?php
-array(1,2);
+[1,2];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Example #1
--- Original
+++ New
@@ -1,4 +1,2 @@
<?php
-$a = array(1
-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Example #1
--- Original
+++ New
@@ -1,2 +1,2 @@
<?php
-$a = array('sample', );
+$a = array('sample');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Example #1
--- Original
+++ New
@@ -1 +1 @@
-<?php $x = array(1 , "2");
+<?php $x = array(1, "2");
Expand All @@ -41,7 +40,6 @@ With configuration: ``['after_heredoc' => true]``.
--- Original
+++ New
@@ -1,6 +1,5 @@
<?php
$x = [<<<EOD
foo
Expand Down
1 change: 0 additions & 1 deletion doc/rules/array_notation/normalize_index_brace.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Example #1
--- Original
+++ New
@@ -1,2 +1,2 @@
<?php
-echo $sample{$index};
+echo $sample[$index];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Example #1
--- Original
+++ New
@@ -1,5 +1,5 @@
<?php
array(
1,
Expand All @@ -45,7 +44,8 @@ With configuration: ``['after_heredoc' => true]``.
--- Original
+++ New
@@ -3,5 +3,5 @@
<?php
$x = [
'foo',
<<<EOD
bar
Expand Down
1 change: 0 additions & 1 deletion doc/rules/array_notation/trim_array_spaces.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Example #1
--- Original
+++ New
@@ -1,3 +1,3 @@
<?php
-$sample = array( );
-$sample = array( 'a', 'b' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Example #1
--- Original
+++ New
@@ -1,2 +1,2 @@
<?php
-$sample = array(1,'a',$b,);
+$sample = array(1, 'a', $b, );
Expand Down
3 changes: 0 additions & 3 deletions doc/rules/basic/braces.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ Example #1
--- Original
+++ New
@@ -1,25 +1,27 @@
<?php
-class Foo {
Expand Down Expand Up @@ -119,7 +118,6 @@ With configuration: ``['allow_single_line_closure' => true]``.
--- Original
+++ New
@@ -1,4 +1,5 @@
<?php
$positive = function ($item) { return $item >= 0; };
$negative = function ($item) {
Expand All @@ -136,7 +134,6 @@ With configuration: ``['position_after_functions_and_oop_constructs' => 'same']`
--- Original
+++ New
@@ -1,27 +1,25 @@
<?php
-class Foo
Expand Down
1 change: 0 additions & 1 deletion doc/rules/basic/encoding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Example #1
--- Original
+++ New
@@ -1,3 +1,3 @@
-<?php
+<?php
Expand Down
2 changes: 0 additions & 2 deletions doc/rules/basic/non_printable_character.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ Example #1
--- Original
+++ New
@@ -1 +1 @@
-<?php echo "​Hello World !";
+<?php echo "Hello World !";
Expand All @@ -46,7 +45,6 @@ With configuration: ``['use_escape_sequences_in_strings' => true]``.
--- Original
+++ New
@@ -1 +1 @@
-<?php echo "​Hello World !";
+<?php echo "\u{200b}Hello\u{2007}World\u{a0}!";
Expand Down
2 changes: 0 additions & 2 deletions doc/rules/basic/psr0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ Example #1
--- Original
+++ New
@@ -1,3 +1,3 @@
<?php
namespace PhpCsFixer\FIXER\Basic;
-class InvalidName {}
Expand All @@ -53,7 +52,6 @@ With configuration: ``['dir' => './src']``.
--- Original
+++ New
@@ -1,3 +1,3 @@
<?php
-namespace PhpCsFixer\FIXER\Basic;
-class InvalidName {}
Expand Down
1 change: 0 additions & 1 deletion doc/rules/basic/psr4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Example #1
--- Original
+++ New
@@ -1,3 +1,3 @@
<?php
namespace PhpCsFixer\FIXER\Basic;
-class InvalidName {}
Expand Down
2 changes: 0 additions & 2 deletions doc/rules/basic/psr_autoloading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ Example #1
--- Original
+++ New
@@ -1,3 +1,3 @@
<?php
namespace PhpCsFixer\FIXER\Basic;
-class InvalidName {}
Expand All @@ -49,7 +48,6 @@ With configuration: ``['dir' => './src']``.
--- Original
+++ New
@@ -1,3 +1,3 @@
<?php
-namespace PhpCsFixer\FIXER\Basic;
-class InvalidName {}
Expand Down
2 changes: 0 additions & 2 deletions doc/rules/casing/constant_case.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Example #1
--- Original
+++ New
@@ -1,4 +1,4 @@
<?php
-$a = FALSE;
-$b = True;
Expand All @@ -47,7 +46,6 @@ With configuration: ``['case' => 'upper']``.
--- Original
+++ New
@@ -1,4 +1,4 @@
<?php
$a = FALSE;
-$b = True;
Expand Down
1 change: 0 additions & 1 deletion doc/rules/casing/lowercase_constants.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Example #1
--- Original
+++ New
@@ -1,4 +1,4 @@
<?php
-$a = FALSE;
-$b = True;
Expand Down
1 change: 0 additions & 1 deletion doc/rules/casing/lowercase_keywords.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Example #1
--- Original
+++ New
@@ -1,11 +1,11 @@
<?php
- FOREACH($a AS $B) {
- TRY {
Expand Down
4 changes: 2 additions & 2 deletions doc/rules/casing/lowercase_static_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Example #1
--- Original
+++ New
@@ -3,16 +3,16 @@
<?php
class Foo extends Bar
{
public function baz1()
{
Expand Down Expand Up @@ -43,7 +44,6 @@ Example #2
--- Original
+++ New
@@ -1,8 +1,8 @@
<?php
class Foo extends Bar
{
Expand Down
1 change: 0 additions & 1 deletion doc/rules/casing/magic_constant_casing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Example #1
--- Original
+++ New
@@ -1,2 +1,2 @@
<?php
-echo __dir__;
+echo __DIR__;
Expand Down
2 changes: 0 additions & 2 deletions doc/rules/casing/magic_method_casing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Example #1
--- Original
+++ New
@@ -1,7 +1,7 @@
<?php
class Foo
{
Expand All @@ -31,7 +30,6 @@ Example #2
--- Original
+++ New
@@ -1,2 +1,2 @@
<?php
-$foo->__INVOKE(1);
+$foo->__invoke(1);
Expand Down
1 change: 0 additions & 1 deletion doc/rules/casing/native_function_casing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Example #1
--- Original
+++ New
@@ -1,2 +1,2 @@
<?php
-STRLEN($str);
+strlen($str);
Expand Down

0 comments on commit 02675fc

Please sign in to comment.