Skip to content

Commit

Permalink
Align tools and settings with main project release 9.1 (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz committed Oct 2, 2023
1 parent 2116830 commit 93c6583
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 32 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
VUFIND_LOCAL_DIR: $GITHUB_WORKSPACE/local
strategy:
matrix:
php-version: ['7.4', '8.0', '8.1']
php-version: ['8.0', '8.1', '8.2']
include:
- php-version: 7.4
phing_tasks: "phpunitfast"
- php-version: 8.0
phing_tasks: "phpunitfast"
- php-version: 8.1
phing_tasks: "phpunitfast"
- php-version: 8.2
phing_tasks: "phpunitfast phpcs-console php-cs-fixer-dryrun phpstan-console"

steps:
Expand Down
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## Next Release - TBD

### Added

- Nothing.

### Changed

- The minimum PHP version requirement has been raised to 8.0.

### Deprecated

- Nothing.

### Removed

- Nothing.

## Fixed

- Nothing.

## 1.2.0 - 2023-01-17

### Added
Expand Down
12 changes: 0 additions & 12 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@
<phingcall target="phpcs"/>
<phingcall target="phpunit"/>
<phingcall target="phpdoc"/>
<phingcall target="phpcpd"/>
<phingcall target="phpmd"/>
<phingcall target="pdepend"/>
<phingcall target="phploc"/>
<phingcall target="phpstan-checkstyle"/>
</target>

Expand All @@ -45,21 +43,11 @@
<exec command="${srcdir}/vendor/bin/phpmd ${srcdir}/src xml ${srcdir}/tests/phpmd.xml --exclude ${srcdir}/tests --reportfile ${builddir}/reports/phpmd.xml" />
</target>

<!-- Measure project with phploc -->
<target name="phploc">
<exec command="${srcdir}/vendor/bin/phploc --log-csv ${builddir}/reports/phploc.csv ${srcdir}/src" />
</target>

<!-- PHP_Depend code analysis -->
<target name="pdepend">
<exec command="${srcdir}/vendor/bin/pdepend --jdepend-xml=${builddir}/reports/jdepend.xml --jdepend-chart=${builddir}/reports/dependencies.svg --overview-pyramid=${builddir}/reports/pdepend-pyramid.svg ${srcdir}/src" />
</target>

<!-- PHP copy-and-paste detection -->
<target name="phpcpd">
<exec command="${srcdir}/vendor/bin/phpcpd --log-pmd ${builddir}/reports/pmd-cpd.xml --exclude tests ${srcdir}/src" />
</target>

<!-- PHP CodeSniffer -->
<target name="phpcbf">
<exec command="${srcdir}/vendor/bin/phpcbf --standard=${srcdir}/tests/phpcs.xml" escape="false" passthru="true" checkreturn="true" />
Expand Down
12 changes: 5 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,19 @@
},
"config": {
"platform": {
"php": "7.4.1"
"php": "8.0"
}
},
"require": {
"php": ">=7.4.1"
"php": ">=8.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "3.14.4",
"friendsofphp/php-cs-fixer": "3.26.1",
"pear/http_request2": "2.5.1",
"phploc/phploc": "7.0.2",
"phpmd/phpmd": "2.13.0",
"phpstan/phpstan": "1.10.3",
"phpunit/phpunit": "9.6.4",
"phpstan/phpstan": "1.10.34",
"phpunit/phpunit": "9.6.12",
"phing/phing": "2.17.4",
"sebastian/phpcpd": "6.0.3",
"squizlabs/php_codesniffer": "3.7.2"
}
}
19 changes: 12 additions & 7 deletions src/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
use DateTime;
use DateTimeZone;

use function in_array;
use function intval;
use function is_array;
use function is_float;

/**
* Date/time conversion functionality.
*
Expand Down Expand Up @@ -76,10 +81,10 @@ class Converter
public function __construct(array $config = [])
{
// Set Display Date Format
$this->displayDateFormat = $config['displayDateFormat'] ?? "m-d-Y";
$this->displayDateFormat = $config['displayDateFormat'] ?? 'm-d-Y';

// Set Display Date Format
$this->displayTimeFormat = $config['displayTimeFormat'] ?? "H:i";
$this->displayTimeFormat = $config['displayTimeFormat'] ?? 'H:i';

// Set time zone
$zone = $config['timezone'] ?? 'America/New_York';
Expand Down Expand Up @@ -117,8 +122,8 @@ public function convertToDateTime($inputFormat, $dateString)
// benefit from special processing. However, items not found in this list
// will still be attempted in a generic fashion before giving up.
$validFormats = [
"m-d-Y", "m-d-y", "m/d/Y", "m/d/y", "U", "m-d-y H:i", "Y-m-d",
"Y-m-d H:i",
'm-d-Y', 'm-d-y', 'm/d/Y', 'm/d/y', 'U', 'm-d-y H:i', 'Y-m-d',
'Y-m-d H:i',
];
$isValid = in_array($inputFormat, $validFormats);
if ($isValid) {
Expand Down Expand Up @@ -171,14 +176,14 @@ public function convertToDateTime($inputFormat, $dateString)
*/
protected function getDateExceptionMessage($details)
{
$errors = "Date/time problem: Details: ";
$errors = 'Date/time problem: Details: ';
if (is_array($details['errors']) && $details['error_count'] > 0) {
foreach ($details['errors'] as $error) {
$errors .= $error . " ";
$errors .= $error . ' ';
}
} elseif (is_array($details['warnings'])) {
foreach ($details['warnings'] as $warning) {
$errors .= $warning . " ";
$errors .= $warning . ' ';
}
}
return $errors;
Expand Down
24 changes: 21 additions & 3 deletions tests/vufind.php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
->in(__DIR__ . '/../src');

$rules = [
'@PHP74Migration' => true,
'@PHP80Migration' => true,
'@PHPUnit84Migration:risky' => true,
'@PSR12' => true,
'align_multiline_comment' => true,
Expand All @@ -17,12 +17,22 @@
'class_attributes_separation' => ['elements' => ['method' => 'one', 'property' => 'one']],
'concat_space' => ['spacing' => 'one'],
'ereg_to_preg' => true,
'function_typehint_space' => true,
'get_class_to_class_keyword' => true,
'global_namespace_import' => [
'import_functions' => true,
'import_classes' => null,
],
'is_null' => true,
'linebreak_after_opening_tag' => true,
'lowercase_cast' => true,
'magic_constant_casing' => true,
'modernize_strpos' => true,
'native_function_casing' => true,
'native_function_invocation' => [
'strict' => true,
'scope' => 'namespaced',
],
'no_alias_functions' => true,
'no_blank_lines_after_class_opening' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
Expand All @@ -31,21 +41,29 @@
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_mixed_echo_print' => true,
'no_php4_constructor' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_around_offset' => true,
'no_unneeded_control_parentheses' => true,
'no_unneeded_curly_braces' => true,
'no_unneeded_final_method' => true,
'no_unreachable_default_argument_value' => true,
'no_unused_imports' => true,
'no_useless_return' => true,
'no_whitespace_in_blank_line' => true,
'non_printable_character' => true,
'ordered_imports' => true,
'ordered_imports' => [
'imports_order' => ['class', 'function', 'const'],
'sort_algorithm' => 'alpha',
],
'phpdoc_no_access' => true,
'php_unit_method_casing' => true,
'pow_to_exponentiation' => true,
'single_line_after_imports' => true,
'single_quote' => true,
'standardize_not_equals' => true,
'ternary_operator_spaces' => true,
'type_declaration_spaces' => true,
];

$cacheDir = __DIR__ . '/../.php_cs_cache';
Expand Down

0 comments on commit 93c6583

Please sign in to comment.