Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13c76efcef | ||
|
|
f59c325b05 | ||
|
|
aac5157173 | ||
|
|
abc2705c64 | ||
|
|
e2fff45b16 | ||
|
|
b6ae3f99d9 | ||
|
|
a377ab4b61 | ||
|
|
ec9275d8d3 | ||
|
|
10ed5b3ea0 | ||
|
|
5f290419c6 | ||
|
|
0152af6e65 |
@@ -1,12 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phive xmlns="https://phar.io/phive">
|
||||
<phar name="phpunit" version="^9.6" installed="9.6.13" location="./tools/phpunit" copy="false"/>
|
||||
<phar name="phpcbf" version="^3.7.2" installed="3.7.2" location="./tools/phpcbf" copy="false"/>
|
||||
<phar name="phpcs" version="^3.7.2" installed="3.7.2" location="./tools/phpcs" copy="false"/>
|
||||
<phar name="phpstan" version="^1.10.37" installed="1.10.46" location="./tools/phpstan" copy="false"/>
|
||||
<phar name="phan" version="^5.4.2" installed="5.4.2" location="./tools/phan" copy="false"/>
|
||||
<phar name="psalm" version="^5.15.0" installed="5.16.0" location="./tools/psalm" copy="false"/>
|
||||
<phar name="phpunit" version="^9.6" installed="9.6.17" location="./tools/phpunit" copy="false"/>
|
||||
<phar name="phpcbf" version="^3.7.2" installed="3.9.0" location="./tools/phpcbf" copy="false"/>
|
||||
<phar name="phpcs" version="^3.7.2" installed="3.9.0" location="./tools/phpcs" copy="false"/>
|
||||
<phar name="phpstan" version="^1.10.37" installed="1.10.59" location="./tools/phpstan" copy="false"/>
|
||||
<phar name="phan" version="^5.4.2" installed="5.4.3" location="./tools/phan" copy="false"/>
|
||||
<phar name="psalm" version="^5.15.0" installed="5.22.2" location="./tools/psalm" copy="false"/>
|
||||
<phar name="phpdox" version="^0.12.0" installed="0.12.0" location="./tools/phpdox" copy="false"/>
|
||||
<phar name="phpdocumentor" version="^3.4.2" installed="3.4.3" location="./tools/phpDocumentor" copy="false"/>
|
||||
<phar name="php-cs-fixer" version="^3.34.1" installed="3.40.0" location="./tools/php-cs-fixer" copy="false"/>
|
||||
<phar name="php-cs-fixer" version="^3.34.1" installed="3.51.0" location="./tools/php-cs-fixer" copy="false"/>
|
||||
</phive>
|
||||
|
||||
@@ -28,10 +28,10 @@ final class CoreLibsCheckFileTest extends TestCase
|
||||
public function filesList(): array
|
||||
{
|
||||
return [
|
||||
['filename.txt', 'txt', 5],
|
||||
['filename.csv', 'csv', 15],
|
||||
['filename.tsv', 'tsv', 0],
|
||||
['file_does_not_exits', '', -1],
|
||||
['filename.txt', 'txt', 5, 'text/plain'],
|
||||
['filename.csv', 'csv', 15, 'text/csv'],
|
||||
['filename.tsv', 'tsv', 0, 'text/plain'],
|
||||
['file_does_not_exits', '', -1, ''],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -63,6 +63,15 @@ final class CoreLibsCheckFileTest extends TestCase
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function mimeTypeProvider(): array
|
||||
{
|
||||
$list = [];
|
||||
foreach ($this->filesList() as $row) {
|
||||
$list[$row[0] . ' must be mime type ' . $row[3]] = [$row[0], $row[3]];
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if file extension matches
|
||||
*
|
||||
@@ -115,6 +124,51 @@ final class CoreLibsCheckFileTest extends TestCase
|
||||
unlink($this->base_folder . $input);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @covers ::getMimeType
|
||||
* @dataProvider mimeTypeProvider
|
||||
* @testdox getMimeType $input must be mime type $expected [$_dataName]
|
||||
*
|
||||
* @param string $input
|
||||
* @param string $expected
|
||||
* @return void
|
||||
*/
|
||||
public function testGetMimeType(string $input, string $expected): void
|
||||
{
|
||||
if (!empty($expected)) {
|
||||
$file = $this->base_folder . $input;
|
||||
$fp = fopen($file, 'w');
|
||||
switch ($expected) {
|
||||
case 'text/csv':
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
fwrite($fp, '"This is row","' . $expected . '",' . $i . PHP_EOL);
|
||||
}
|
||||
break;
|
||||
case 'text/tsv':
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
fwrite($fp, "\"This is row\"\t\"" . $expected . "\"\t\"" . $i . PHP_EOL);
|
||||
}
|
||||
break;
|
||||
case 'text/plain':
|
||||
fwrite($fp, 'This is mime type: ' . $expected . PHP_EOL);
|
||||
break;
|
||||
}
|
||||
fclose($fp);
|
||||
} else {
|
||||
$this->expectException(\UnexpectedValueException::class);
|
||||
}
|
||||
$this->assertEquals(
|
||||
$expected,
|
||||
\CoreLibs\Check\File::getMimeType($this->base_folder . $input)
|
||||
);
|
||||
// unlink file
|
||||
if (is_file($this->base_folder . $input)) {
|
||||
unlink($this->base_folder . $input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -256,6 +256,80 @@ final class CoreLibsConvertStringsTest extends TestCase
|
||||
$output
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* provider for testStripMultiplePathSlashes
|
||||
*
|
||||
* @return array<mixed>
|
||||
*/
|
||||
public function stripMultiplePathSlashesProvider(): array
|
||||
{
|
||||
return [
|
||||
'no slahses' => [
|
||||
'input' => 'string_abc',
|
||||
'expected' => 'string_abc',
|
||||
],
|
||||
'one slash' => [
|
||||
'input' => 'some/foo',
|
||||
'expected' => 'some/foo',
|
||||
],
|
||||
'two slashes' => [
|
||||
'input' => 'some//foo',
|
||||
'expected' => 'some/foo',
|
||||
],
|
||||
'three slashes' => [
|
||||
'input' => 'some///foo',
|
||||
'expected' => 'some/foo',
|
||||
],
|
||||
'slashes in front' => [
|
||||
'input' => '/foo',
|
||||
'expected' => '/foo',
|
||||
],
|
||||
'two slashes in front' => [
|
||||
'input' => '//foo',
|
||||
'expected' => '/foo',
|
||||
],
|
||||
'thee slashes in front' => [
|
||||
'input' => '///foo',
|
||||
'expected' => '/foo',
|
||||
],
|
||||
'slashes in back' => [
|
||||
'input' => 'foo/',
|
||||
'expected' => 'foo/',
|
||||
],
|
||||
'two slashes in back' => [
|
||||
'input' => 'foo//',
|
||||
'expected' => 'foo/',
|
||||
],
|
||||
'thee slashes in back' => [
|
||||
'input' => 'foo///',
|
||||
'expected' => 'foo/',
|
||||
],
|
||||
'multiple slashes' => [
|
||||
'input' => '/foo//bar///string/end_times',
|
||||
'expected' => '/foo/bar/string/end_times',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* test multiple slashes clean up
|
||||
*
|
||||
* @covers ::stripMultiplePathSlashes
|
||||
* @dataProvider stripMultiplePathSlashesProvider
|
||||
* @testdox stripMultiplePathSlashes $input will be $expected [$_dataName]
|
||||
*
|
||||
* @param string $input
|
||||
* @param string $expected
|
||||
* @return void
|
||||
*/
|
||||
public function testStripMultiplePathSlashes(string $input, string $expected): void
|
||||
{
|
||||
$this->assertEquals(
|
||||
$expected,
|
||||
\CoreLibs\Convert\Strings::stripMultiplePathSlashes($input)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// __END__
|
||||
|
||||
18
phpcs.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0"?>
|
||||
<ruleset name="MyStandard">
|
||||
<description>PSR12 override rules (strict, standard). Switch spaces indent to tab.</description>
|
||||
<arg name="tab-width" value="4"/>
|
||||
<rule ref="PSR1"/>
|
||||
<rule ref="PSR12">
|
||||
<!-- turn off white space check for tab -->
|
||||
<exclude name="Generic.WhiteSpace.DisallowTabIndent"/>
|
||||
</rule>
|
||||
<!-- no space indent, must be tab, 4 is tab iwdth -->
|
||||
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>
|
||||
<rule ref="Generic.WhiteSpace.ScopeIndent">
|
||||
<properties>
|
||||
<property name="indent" value="4"/>
|
||||
<property name="tabIndent" value="true"/>
|
||||
</properties>
|
||||
</rule>
|
||||
</ruleset>
|
||||
@@ -1 +1 @@
|
||||
/home/clemens/.phive/phars/phan-5.4.2.phar
|
||||
/home/clemens/.phive/phars/phan-5.4.3.phar
|
||||
@@ -1 +1 @@
|
||||
/home/clemens/.phive/phars/php-cs-fixer-3.40.0.phar
|
||||
/home/clemens/.phive/phars/php-cs-fixer-3.51.0.phar
|
||||
@@ -1 +1 @@
|
||||
/home/clemens/.phive/phars/phpcbf-3.7.2.phar
|
||||
/home/clemens/.phive/phars/phpcbf-3.9.0.phar
|
||||
@@ -1 +1 @@
|
||||
/home/clemens/.phive/phars/phpcs-3.7.2.phar
|
||||
/home/clemens/.phive/phars/phpcs-3.9.0.phar
|
||||
@@ -1 +1 @@
|
||||
/home/clemens/.phive/phars/phpstan-1.10.46.phar
|
||||
/home/clemens/.phive/phars/phpstan-1.10.59.phar
|
||||
@@ -1 +1 @@
|
||||
/home/clemens/.phive/phars/phpunit-9.6.13.phar
|
||||
/home/clemens/.phive/phars/phpunit-9.6.17.phar
|
||||
@@ -1 +1 @@
|
||||
/home/clemens/.phive/phars/psalm-5.16.0.phar
|
||||
/home/clemens/.phive/phars/psalm-5.22.2.phar
|
||||
@@ -37,6 +37,7 @@ $file = '/some/path/to/some/file.txt';
|
||||
print "GETFILENAMEENDING: $file: " . File::getFilenameEnding($file) . "<br>";
|
||||
$file = getcwd() . DIRECTORY_SEPARATOR . 'class_test.file.php';
|
||||
print "GETLINESFROMFILE: $file: " . File::getLinesFromFile($file) . "<br>";
|
||||
print "MIMEINFO: $file: " . File::getMimeType($file) . "<br>";
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
|
||||
@@ -41,9 +41,9 @@ print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
$thumb_width = 250;
|
||||
$thumb_height = 300;
|
||||
// class
|
||||
$image = BASE . LAYOUT . CONTENT_PATH . IMAGES . 'no_picture_square.jpg';
|
||||
$image = BASE . CONTENT_PATH . LAYOUT . IMAGES . 'no_picture_square.jpg';
|
||||
// folders
|
||||
$cache_folder = BASE . LAYOUT . CONTENT_PATH . CACHE . IMAGES;
|
||||
$cache_folder = BASE . CONTENT_PATH . LAYOUT . CACHE . IMAGES;
|
||||
$web_folder = LAYOUT . CACHE . IMAGES;
|
||||
// rotate image first
|
||||
try {
|
||||
@@ -58,7 +58,7 @@ echo "<div>CLASS->CREATETHUMBNAILSIMPLE: "
|
||||
. basename($image) . ": WIDTH: $thumb_width<br><img src="
|
||||
. $_image->createThumbnailSimple($image, $thumb_width, 0, $cache_folder, $web_folder) . "></div>";
|
||||
// static
|
||||
$image = BASE . LAYOUT . CONTENT_PATH . IMAGES . 'no_picture.jpg';
|
||||
$image = BASE . CONTENT_PATH . LAYOUT . IMAGES . 'no_picture.jpg';
|
||||
// rotate image first
|
||||
try {
|
||||
$image_class::correctImageOrientation($image);
|
||||
@@ -94,7 +94,7 @@ $images = array(
|
||||
// return mime type ala mimetype
|
||||
$finfo = new finfo(FILEINFO_MIME_TYPE);
|
||||
foreach ($images as $image) {
|
||||
$image = BASE . LAYOUT . CONTENT_PATH . IMAGES . $image;
|
||||
$image = BASE . CONTENT_PATH . LAYOUT . IMAGES . $image;
|
||||
list ($height, $width, $img_type) = \CoreLibs\Convert\SetVarType::setArray(getimagesize($image));
|
||||
echo "<div><b>IMAGE INFO</b>: " . $height . "x" . $width . ", TYPE: "
|
||||
. \CoreLibs\Debug\Support::dumpVar($img_type) . " [" . $finfo->file($image) . "]</div>";
|
||||
|
||||
@@ -3,4 +3,3 @@
|
||||
// empty file for add and remove test
|
||||
|
||||
// __END__
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../layout/admin/
|
||||
|
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.5 MiB |
|
Before Width: | Height: | Size: 489 KiB After Width: | Height: | Size: 489 KiB |
|
Before Width: | Height: | Size: 807 KiB After Width: | Height: | Size: 807 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 56 B After Width: | Height: | Size: 56 B |
|
Before Width: | Height: | Size: 87 B After Width: | Height: | Size: 87 B |
|
Before Width: | Height: | Size: 56 B After Width: | Height: | Size: 56 B |
|
Before Width: | Height: | Size: 260 B After Width: | Height: | Size: 260 B |
|
Before Width: | Height: | Size: 210 B After Width: | Height: | Size: 210 B |
|
Before Width: | Height: | Size: 87 B After Width: | Height: | Size: 87 B |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 250 B After Width: | Height: | Size: 250 B |
|
Before Width: | Height: | Size: 257 B After Width: | Height: | Size: 257 B |
|
Before Width: | Height: | Size: 275 B After Width: | Height: | Size: 275 B |
|
Before Width: | Height: | Size: 270 B After Width: | Height: | Size: 270 B |
|
Before Width: | Height: | Size: 279 B After Width: | Height: | Size: 279 B |
|
Before Width: | Height: | Size: 257 B After Width: | Height: | Size: 257 B |
|
Before Width: | Height: | Size: 261 B After Width: | Height: | Size: 261 B |
|
Before Width: | Height: | Size: 208 B After Width: | Height: | Size: 208 B |
|
Before Width: | Height: | Size: 279 B After Width: | Height: | Size: 279 B |
|
Before Width: | Height: | Size: 268 B After Width: | Height: | Size: 268 B |
|
Before Width: | Height: | Size: 260 B After Width: | Height: | Size: 260 B |
|
Before Width: | Height: | Size: 169 B After Width: | Height: | Size: 169 B |
|
Before Width: | Height: | Size: 169 B After Width: | Height: | Size: 169 B |
|
Before Width: | Height: | Size: 169 B After Width: | Height: | Size: 169 B |
|
Before Width: | Height: | Size: 165 B After Width: | Height: | Size: 165 B |
|
Before Width: | Height: | Size: 167 B After Width: | Height: | Size: 167 B |
|
Before Width: | Height: | Size: 171 B After Width: | Height: | Size: 171 B |
|
Before Width: | Height: | Size: 173 B After Width: | Height: | Size: 173 B |
|
Before Width: | Height: | Size: 159 B After Width: | Height: | Size: 159 B |
|
Before Width: | Height: | Size: 159 B After Width: | Height: | Size: 159 B |
|
Before Width: | Height: | Size: 116 B After Width: | Height: | Size: 116 B |
|
Before Width: | Height: | Size: 211 B After Width: | Height: | Size: 211 B |
|
Before Width: | Height: | Size: 85 B After Width: | Height: | Size: 85 B |
|
Before Width: | Height: | Size: 223 B After Width: | Height: | Size: 223 B |
|
Before Width: | Height: | Size: 222 B After Width: | Height: | Size: 222 B |
|
Before Width: | Height: | Size: 225 B After Width: | Height: | Size: 225 B |
|
Before Width: | Height: | Size: 226 B After Width: | Height: | Size: 226 B |
|
Before Width: | Height: | Size: 222 B After Width: | Height: | Size: 222 B |
|
Before Width: | Height: | Size: 220 B After Width: | Height: | Size: 220 B |
|
Before Width: | Height: | Size: 216 B After Width: | Height: | Size: 216 B |
|
Before Width: | Height: | Size: 214 B After Width: | Height: | Size: 214 B |
|
Before Width: | Height: | Size: 212 B After Width: | Height: | Size: 212 B |
|
Before Width: | Height: | Size: 89 B After Width: | Height: | Size: 89 B |
|
Before Width: | Height: | Size: 220 B After Width: | Height: | Size: 220 B |
|
Before Width: | Height: | Size: 221 B After Width: | Height: | Size: 221 B |
|
Before Width: | Height: | Size: 222 B After Width: | Height: | Size: 222 B |
|
Before Width: | Height: | Size: 225 B After Width: | Height: | Size: 225 B |
|
Before Width: | Height: | Size: 219 B After Width: | Height: | Size: 219 B |
|
Before Width: | Height: | Size: 219 B After Width: | Height: | Size: 219 B |
|
Before Width: | Height: | Size: 213 B After Width: | Height: | Size: 213 B |
|
Before Width: | Height: | Size: 213 B After Width: | Height: | Size: 213 B |
|
Before Width: | Height: | Size: 249 B After Width: | Height: | Size: 249 B |
|
Before Width: | Height: | Size: 251 B After Width: | Height: | Size: 251 B |
|
Before Width: | Height: | Size: 231 B After Width: | Height: | Size: 231 B |
|
Before Width: | Height: | Size: 56 B After Width: | Height: | Size: 56 B |
|
Before Width: | Height: | Size: 261 B After Width: | Height: | Size: 261 B |