Added .editorconfig to tell others about spaces and tabs

Also:
- formated source code according to these rules;
- added spaces after commas in test code

See GitHub issue #101
This commit is contained in:
Christian Bläul
2017-12-06 03:00:22 +01:00
committed by Fonata
parent 0ac5064d58
commit 0ecaa80222
7 changed files with 114 additions and 71 deletions

15
.editorconfig Normal file
View File

@@ -0,0 +1,15 @@
# @see http://editorconfig.org/
# This is the top-most .editorconfig file; do not search in parent directories.
root = true
# All files.
[*]
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[composer.json]
indent_size = 4

View File

@@ -13,7 +13,9 @@
} }
], ],
"autoload": { "autoload": {
"classmap": ["."] "classmap": [
"."
]
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "4.1.*" "phpunit/phpunit": "4.1.*"

View File

@@ -28,21 +28,29 @@ $csv->auto('_books.csv');
?> ?>
</pre> </pre>
<style type="text/css" media="screen"> <style type="text/css" media="screen">
table { background-color: #BBB; } table {
th { background-color: #EEE; } background-color: #BBB;
td { background-color: #FFF; } }
th {
background-color: #EEE;
}
td {
background-color: #FFF;
}
</style> </style>
<table border="0" cellspacing="1" cellpadding="3"> <table border="0" cellspacing="1" cellpadding="3">
<tr> <tr>
<?php foreach ($csv->titles as $value): ?> <?php foreach ($csv->titles as $value): ?>
<th><?php echo $value; ?></th> <th><?php echo $value; ?></th>
<?php endforeach; ?> <?php endforeach; ?>
</tr> </tr>
<?php foreach ($csv->data as $key => $row): ?> <?php foreach ($csv->data as $key => $row): ?>
<tr> <tr>
<?php foreach ($row as $value): ?> <?php foreach ($row as $value): ?>
<td><?php echo $value; ?></td> <td><?php echo $value; ?></td>
<?php endforeach; ?> <?php endforeach; ?>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</table> </table>

View File

@@ -28,21 +28,29 @@ $csv->auto('_books.csv');
?> ?>
</pre> </pre>
<style type="text/css" media="screen"> <style type="text/css" media="screen">
table { background-color: #BBB; } table {
th { background-color: #EEE; } background-color: #BBB;
td { background-color: #FFF; } }
th {
background-color: #EEE;
}
td {
background-color: #FFF;
}
</style> </style>
<table border="0" cellspacing="1" cellpadding="3"> <table border="0" cellspacing="1" cellpadding="3">
<tr> <tr>
<?php foreach ($csv->titles as $value): ?> <?php foreach ($csv->titles as $value): ?>
<th><?php echo $value; ?></th> <th><?php echo $value; ?></th>
<?php endforeach; ?> <?php endforeach; ?>
</tr> </tr>
<?php foreach ($csv->data as $key => $row): ?> <?php foreach ($csv->data as $key => $row): ?>
<tr> <tr>
<?php foreach ($row as $value): ?> <?php foreach ($row as $value): ?>
<td><?php echo $value; ?></td> <td><?php echo $value; ?></td>
<?php endforeach; ?> <?php endforeach; ?>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</table> </table>

View File

@@ -41,21 +41,29 @@ $csv->auto('_books.csv');
?> ?>
</pre> </pre>
<style type="text/css" media="screen"> <style type="text/css" media="screen">
table { background-color: #BBB; } table {
th { background-color: #EEE; } background-color: #BBB;
td { background-color: #FFF; } }
th {
background-color: #EEE;
}
td {
background-color: #FFF;
}
</style> </style>
<table border="0" cellspacing="1" cellpadding="3"> <table border="0" cellspacing="1" cellpadding="3">
<tr> <tr>
<?php foreach ($csv->titles as $value): ?> <?php foreach ($csv->titles as $value): ?>
<th><?php echo $value; ?></th> <th><?php echo $value; ?></th>
<?php endforeach; ?> <?php endforeach; ?>
</tr> </tr>
<?php foreach ($csv->data as $key => $row): ?> <?php foreach ($csv->data as $key => $row): ?>
<tr> <tr>
<?php foreach ($row as $value): ?> <?php foreach ($row as $value): ?>
<td><?php echo $value; ?></td> <td><?php echo $value; ?></td>
<?php endforeach; ?> <?php endforeach; ?>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</table> </table>

View File

@@ -1,6 +1,7 @@
<?php <?php
class default_values_properties_Test extends PHPUnit\Framework\TestCase { class default_values_properties_Test extends PHPUnit\Framework\TestCase {
/** /**
* CSV * CSV
* The parseCSV object * The parseCSV object
@@ -38,7 +39,7 @@ class default_values_properties_Test extends PHPUnit\Framework\TestCase {
public function test_fields_default() { public function test_fields_default() {
$this->assertTrue(is_array($this->csv->fields)); $this->assertTrue(is_array($this->csv->fields));
$this->assertCount(0,$this->csv->fields); $this->assertCount(0, $this->csv->fields);
} }
public function test_sort_by_default() { public function test_sort_by_default() {
@@ -56,12 +57,12 @@ class default_values_properties_Test extends PHPUnit\Framework\TestCase {
public function test_delimiter_default() { public function test_delimiter_default() {
$this->assertTrue(is_string($this->csv->delimiter)); $this->assertTrue(is_string($this->csv->delimiter));
$this->assertEquals(',',$this->csv->delimiter); $this->assertEquals(',', $this->csv->delimiter);
} }
public function test_enclosure_default() { public function test_enclosure_default() {
$this->assertTrue(is_string($this->csv->enclosure)); $this->assertTrue(is_string($this->csv->enclosure));
$this->assertEquals('"',$this->csv->enclosure); $this->assertEquals('"', $this->csv->enclosure);
} }
public function test_enclose_all_default() { public function test_enclose_all_default() {
@@ -83,17 +84,17 @@ class default_values_properties_Test extends PHPUnit\Framework\TestCase {
public function test_auto_depth_default() { public function test_auto_depth_default() {
$this->assertTrue(is_numeric($this->csv->auto_depth)); $this->assertTrue(is_numeric($this->csv->auto_depth));
$this->assertEquals(15,$this->csv->auto_depth); $this->assertEquals(15, $this->csv->auto_depth);
} }
public function test_auto_non_chars_default() { public function test_auto_non_chars_default() {
$this->assertTrue(is_string($this->csv->auto_non_chars)); $this->assertTrue(is_string($this->csv->auto_non_chars));
$this->assertEquals("a-zA-Z0-9\n\r",$this->csv->auto_non_chars); $this->assertEquals("a-zA-Z0-9\n\r", $this->csv->auto_non_chars);
} }
public function test_auto_preferred_default() { public function test_auto_preferred_default() {
$this->assertTrue(is_string($this->csv->auto_preferred)); $this->assertTrue(is_string($this->csv->auto_preferred));
$this->assertEquals(",;\t.:|",$this->csv->auto_preferred); $this->assertEquals(",;\t.:|", $this->csv->auto_preferred);
} }
public function test_convert_encoding_default() { public function test_convert_encoding_default() {
@@ -103,27 +104,27 @@ class default_values_properties_Test extends PHPUnit\Framework\TestCase {
public function test_input_encoding_default() { public function test_input_encoding_default() {
$this->assertTrue(is_string($this->csv->input_encoding)); $this->assertTrue(is_string($this->csv->input_encoding));
$this->assertEquals('ISO-8859-1',$this->csv->input_encoding); $this->assertEquals('ISO-8859-1', $this->csv->input_encoding);
} }
public function test_output_encoding_default() { public function test_output_encoding_default() {
$this->assertTrue(is_string($this->csv->output_encoding)); $this->assertTrue(is_string($this->csv->output_encoding));
$this->assertEquals('ISO-8859-1',$this->csv->output_encoding); $this->assertEquals('ISO-8859-1', $this->csv->output_encoding);
} }
public function test_linefeed_default() { public function test_linefeed_default() {
$this->assertTrue(is_string($this->csv->linefeed)); $this->assertTrue(is_string($this->csv->linefeed));
$this->assertEquals("\r",$this->csv->linefeed); $this->assertEquals("\r", $this->csv->linefeed);
} }
public function test_output_delimiter_default() { public function test_output_delimiter_default() {
$this->assertTrue(is_string($this->csv->output_delimiter)); $this->assertTrue(is_string($this->csv->output_delimiter));
$this->assertEquals(',',$this->csv->output_delimiter); $this->assertEquals(',', $this->csv->output_delimiter);
} }
public function test_output_filename_default() { public function test_output_filename_default() {
$this->assertTrue(is_string($this->csv->output_filename)); $this->assertTrue(is_string($this->csv->output_filename));
$this->assertEquals('data.csv',$this->csv->output_filename); $this->assertEquals('data.csv', $this->csv->output_filename);
} }
public function test_keep_file_data_default() { public function test_keep_file_data_default() {
@@ -141,21 +142,21 @@ class default_values_properties_Test extends PHPUnit\Framework\TestCase {
public function test_error_default() { public function test_error_default() {
$this->assertTrue(is_numeric($this->csv->error)); $this->assertTrue(is_numeric($this->csv->error));
$this->assertEquals(0,$this->csv->error); $this->assertEquals(0, $this->csv->error);
} }
public function test_error_info_default() { public function test_error_info_default() {
$this->assertTrue(is_array($this->csv->error_info)); $this->assertTrue(is_array($this->csv->error_info));
$this->assertCount(0,$this->csv->error_info); $this->assertCount(0, $this->csv->error_info);
} }
public function test_titles_default() { public function test_titles_default() {
$this->assertTrue(is_array($this->csv->titles)); $this->assertTrue(is_array($this->csv->titles));
$this->assertCount(0,$this->csv->titles); $this->assertCount(0, $this->csv->titles);
} }
public function test_data_default() { public function test_data_default() {
$this->assertTrue(is_array($this->csv->data)); $this->assertTrue(is_array($this->csv->data));
$this->assertCount(0,$this->csv->data); $this->assertCount(0, $this->csv->data);
} }
} }

View File

@@ -1,6 +1,7 @@
<?php <?php
class worthless_properties_Test extends PHPUnit\Framework\TestCase { class worthless_properties_Test extends PHPUnit\Framework\TestCase {
/** /**
* CSV * CSV
* The parseCSV object * The parseCSV object
@@ -64,7 +65,7 @@ class worthless_properties_Test extends PHPUnit\Framework\TestCase {
* @access public * @access public
*/ */
public function test_propertiesCount() { public function test_propertiesCount() {
$this->assertCount(27,$this->properties); $this->assertCount(27, $this->properties);
} }
/** /**
@@ -109,17 +110,17 @@ class worthless_properties_Test extends PHPUnit\Framework\TestCase {
); );
//find our real properties //find our real properties
$real_properties = array(); $real_properties = [];
for ($a=0; $a<count($this->properties); $a++) { for ($a = 0; $a < count($this->properties); $a++) {
$real_properties[] = $this->properties[$a]->getName(); $real_properties[] = $this->properties[$a]->getName();
} }
//lets make sure our expected matches the number of real properties //lets make sure our expected matches the number of real properties
$this->assertCount(count($names),$this->properties); $this->assertCount(count($names), $this->properties);
//lets loop through our expected to make sure they exists //lets loop through our expected to make sure they exists
for ($a=0; $a<count($names); $a++) { for ($a = 0; $a < count($names); $a++) {
$this->assertTrue(in_array($names[$a],$real_properties)); $this->assertTrue(in_array($names[$a], $real_properties));
} }
} }
@@ -133,12 +134,12 @@ class worthless_properties_Test extends PHPUnit\Framework\TestCase {
public function test_count_public_properties() { public function test_count_public_properties() {
$counter = 0; $counter = 0;
for ($a=0; $a<count($this->properties); $a++) { for ($a = 0; $a < count($this->properties); $a++) {
if ($this->properties[$a]->isPublic() === true) { if ($this->properties[$a]->isPublic() === true) {
$counter++; $counter++;
} }
} }
$this->assertCount($counter,$this->properties); $this->assertCount($counter, $this->properties);
} }
} }