diff --git a/composer.json b/composer.json index 1c6b3f0..51718c5 100644 --- a/composer.json +++ b/composer.json @@ -33,13 +33,17 @@ "vufind-org/vufindcode": "^1.2" }, "require-dev": { - "friendsofphp/php-cs-fixer": "3.64.0", + "friendsofphp/php-cs-fixer": "3.95.15", "guzzlehttp/guzzle": "^7.8.1", "phpmd/phpmd": "2.15.0", - "phpstan/phpstan": "2.1.32", - "phpunit/phpunit": "11.5.50", - "phing/phing": "3.1.0", - "rector/rector": "2.2.7", + "phpstan/phpstan": "2.2.5", + "phpunit/phpunit": "11.5.56", + "phing/phing": "3.1.2", + "rector/rector": "2.5.7", "squizlabs/php_codesniffer": "4.0.1" + }, + "scripts": { + "fix": "phing fix-php", + "qa": "phing qa-console" } } diff --git a/src/Lint/CodeData.php b/src/Lint/CodeData.php index 0e3ef87..ebbbdbf 100644 --- a/src/Lint/CodeData.php +++ b/src/Lint/CodeData.php @@ -1,7 +1,7 @@ and available for download at @@ -59,77 +59,77 @@ class CodeData { /** - * Valid Geographic Area Codes + * Valid Geographic Area Codes. * * @var array */ public $geogAreaCodes; /** - * Obsolete Geographic Area Codes + * Obsolete Geographic Area Codes. * * @var array */ public $obsoleteGeogAreaCodes; /** - * Valid Language Codes + * Valid Language Codes. * * @var array */ public $languageCodes; /** - * Obsolete Language Codes + * Obsolete Language Codes. * * @var array */ public $obsoleteLanguageCodes; /** - * Valid Country Codes + * Valid Country Codes. * * @var array */ public $countryCodes; /** - * Obsolete Country Codes + * Obsolete Country Codes. * * @var array */ public $obsoleteCountryCodes; /** - * Valid sources for fields 600-651 + * Valid sources for fields 600-651. * * @var array */ public $sources600_651; /** - * Obsolete sources for fields 600-651 + * Obsolete sources for fields 600-651. * * @var array */ public $obsoleteSources600_651; /** - * Valid sources for field 655 + * Valid sources for field 655. * * @var array */ public $sources655; /** - * Obsolete sources for field 655 + * Obsolete sources for field 655. * * @var array */ public $obsoleteSources655; /** - * Start function + * Start function. * * Initialize code arrays. * diff --git a/src/MarcCollection.php b/src/MarcCollection.php index 94dc311..d2ac5f5 100644 --- a/src/MarcCollection.php +++ b/src/MarcCollection.php @@ -41,7 +41,7 @@ class MarcCollection implements \Iterator { /** - * Supported serialization formats + * Supported serialization formats. * * @var array */ @@ -52,21 +52,21 @@ class MarcCollection implements \Iterator ]; /** - * Records in the collection + * Records in the collection. * * @var array */ protected $records = []; /** - * Iteration position + * Iteration position. * * @var int */ protected $position = 0; /** - * Constructor + * Constructor. * * @param string $data MARC record collection in MARCXML or ISO2709 format */ @@ -76,7 +76,7 @@ public function __construct(string $data = '') } /** - * Set MARC record data + * Set MARC record data. * * @param string $data MARC record in MARCXML or ISO2709 format * diff --git a/src/MarcCollectionFile.php b/src/MarcCollectionFile.php index 85a010b..3b82c6c 100644 --- a/src/MarcCollectionFile.php +++ b/src/MarcCollectionFile.php @@ -41,7 +41,7 @@ class MarcCollectionFile implements \Iterator { /** - * Supported serialization formats + * Supported serialization formats. * * @var array */ @@ -52,35 +52,35 @@ class MarcCollectionFile implements \Iterator ]; /** - * Serialized format stream + * Serialized format stream. * * @var Serialization\SerializationFileInterface */ protected $stream; /** - * Iteration position + * Iteration position. * * @var int */ protected $position = 0; /** - * Current record + * Current record. * * @var string */ protected $record = ''; /** - * Message callback + * Message callback. * * @var callable */ protected $messageCallback; /** - * Constructor + * Constructor. * * @param string $file MARC record collection file in MARCXML or * ISO2709 format @@ -95,7 +95,7 @@ public function __construct(string $file = '', ?callable $messageCallback = null } /** - * Set MARC record file + * Set MARC record file. * * @param string $file MARC record collection file in MARCXML or ISO2709 format * diff --git a/src/MarcLint.php b/src/MarcLint.php index 93ca37c..db9abc3 100644 --- a/src/MarcLint.php +++ b/src/MarcLint.php @@ -1,7 +1,7 @@ and available at http://search.cpan.org/~eijabb/ @@ -56,28 +56,28 @@ class MarcLint { /** - * Rules used for testing records + * Rules used for testing records. * * @var array */ protected $rules; /** - * A Lint\CodeData object for validating codes + * A Lint\CodeData object for validating codes. * * @var Lint\CodeData */ protected $data; /** - * Warnings generated during analysis + * Warnings generated during analysis. * * @var array */ protected $warnings = []; /** - * Start function + * Start function. * * Set up rules for testing MARC records. * diff --git a/src/MarcReader.php b/src/MarcReader.php index 7cad052..4e6806f 100644 --- a/src/MarcReader.php +++ b/src/MarcReader.php @@ -46,7 +46,7 @@ class MarcReader { /** - * Supported serialization formats + * Supported serialization formats. * * @var array */ @@ -57,7 +57,7 @@ class MarcReader ]; /** - * MARC leader + * MARC leader. * * @var string */ @@ -66,6 +66,7 @@ class MarcReader /** * MARC is stored in a multidimensional array resembling MARC-in-JSON * specification by Ross Singer: + * * [ * 'leader' => '...', * 'fields' => [ @@ -93,14 +94,14 @@ class MarcReader protected $data; /** - * Any warnings encountered when parsing a record + * Any warnings encountered when parsing a record. * * @var array */ protected $warnings; /** - * Constructor + * Constructor. * * @param string|array $data MARC record in one of the supported formats, or an * associative array with 'leader' and 'fields' in the internal format @@ -111,7 +112,7 @@ public function __construct($data) } /** - * Set MARC record data + * Set MARC record data. * * @param string|array $data MARC record in one of the supported formats, or an * associative array with 'leader' and 'fields' in the internal format @@ -156,7 +157,7 @@ public function setData($data): void } /** - * Serialize the record + * Serialize the record. * * @param string $format Format to return (e.g. 'ISO2709' or 'MARCXML') * @@ -173,7 +174,7 @@ public function toFormat(string $format): string } /** - * Return leader + * Return leader. * * @return string */ @@ -184,7 +185,7 @@ public function getLeader(): string /** * Return an associative array for a data field, a string for a control field or - * an empty array if field does not exist + * an empty array if field does not exist. * * @param string $fieldTag The MARC field tag to get * @param array $subfieldCodes The MARC subfield codes to get, or empty for all @@ -199,7 +200,7 @@ public function getField(string $fieldTag, ?array $subfieldCodes = null) /** * Return an associative array of fields for data fields or an array of values - * for control fields + * for control fields. * * @param string $fieldTag The MARC field tag to get * @param array $subfieldCodes The MARC subfield codes to get, or empty for all. @@ -303,7 +304,7 @@ public function getAllFields() /** * Return first subfield with the given code in the MARC field provided by - * getField or getFields + * getField or getFields. * * @param array $field Result from MarcReader::getFields * @param string $subfieldCode The MARC subfield code to get @@ -391,7 +392,7 @@ public function getFieldsSubfields( /** * Return an associative array for a linked field such as 880 (Alternate Graphic - * Representation) or an empty array if field does not exist + * Representation) or an empty array if field does not exist. * * @param string $fieldTag The MARC field that contains the linked fields * @param string $linkedFieldTag The linked MARC field tag to get @@ -419,7 +420,7 @@ public function getLinkedField( /** * Return an array of associative arrays for a linked field such as 880 - * (Alternate Graphic Representation) + * (Alternate Graphic Representation). * * @param string $fieldTag The MARC field that contains the linked fields * @param string $linkedFieldTag The linked MARC field tag to get @@ -506,7 +507,7 @@ public function getLinkedFieldsSubfields( } /** - * Get linked field data from subfield 6 + * Get linked field data from subfield 6. * * @param array $field Field * @@ -518,7 +519,7 @@ public function getFieldLink(array $field): array } /** - * Parse a linkage field + * Parse a linkage field. * * @param string $link Linkage field * @@ -603,7 +604,7 @@ public function getFilteredRecord(array $rules): MarcReader } /** - * Get filtering rules matching a field tag + * Get filtering rules matching a field tag. * * @param array $rules Filtering rules * @param string $tag Field tag @@ -625,7 +626,7 @@ protected function getFilteringRulesForTag(array $rules, string $tag): array } /** - * Filter subfields + * Filter subfields. * * @param array $rules Filtering rules * @param array $subfields Subfields @@ -656,7 +657,7 @@ protected function filterSubfields(array $rules, array $subfields): array } /** - * Get any warnings encountered when parsing a record + * Get any warnings encountered when parsing a record. * * @return array */ @@ -666,7 +667,7 @@ public function getWarnings(): array } /** - * Return fields by tag in internal format + * Return fields by tag in internal format. * * @param string $tag Field tag * @@ -685,7 +686,7 @@ protected function getInternalFields(string $tag): array } /** - * Return first subfield with the given code in the internal MARC field + * Return first subfield with the given code in the internal MARC field. * * @param array $field Internal MARC field * @param string $subfieldCode The MARC subfield code to get diff --git a/src/Serialization/AbstractSerializationFile.php b/src/Serialization/AbstractSerializationFile.php index 2024594..7ee6021 100644 --- a/src/Serialization/AbstractSerializationFile.php +++ b/src/Serialization/AbstractSerializationFile.php @@ -45,14 +45,14 @@ abstract class AbstractSerializationFile implements MessageCallbackInterface { /** - * Message callback + * Message callback. * * @var callable */ protected $messageCallback = null; /** - * Set message callback + * Set message callback. * * @param callable $callback Message callback * @@ -64,7 +64,7 @@ public function setMessageCallback(?callable $callback): void } /** - * Output a message + * Output a message. * * @param string $msg Message * @param int $level Error level (see diff --git a/src/Serialization/Iso2709.php b/src/Serialization/Iso2709.php index f3e2ea8..9d928fe 100644 --- a/src/Serialization/Iso2709.php +++ b/src/Serialization/Iso2709.php @@ -51,14 +51,14 @@ class Iso2709 extends AbstractSerializationFile implements SerializationInterfac public const MAX_LENGTH = 99999; /** - * Serialized record file handle + * Serialized record file handle. * * @var resource */ protected $file = null; /** - * Check if this class can parse the given MARC string + * Check if this class can parse the given MARC string. * * @param string $marc MARC * @@ -71,7 +71,7 @@ public static function canParse(string $marc): bool } /** - * Check if the serialization class can parse the given MARC collection string + * Check if the serialization class can parse the given MARC collection string. * * @param string $marc MARC * @@ -84,7 +84,7 @@ public static function canParseCollection(string $marc): bool } /** - * Check if the serialization class can parse the given MARC collection file + * Check if the serialization class can parse the given MARC collection file. * * @param string $file File name * @@ -105,7 +105,7 @@ public static function canParseCollectionFile(string $file): bool } /** - * Parse MARC collection from a string into an array + * Parse MARC collection from a string into an array. * * @param string $collection MARC record collection in the format supported by * the serialization class @@ -130,7 +130,7 @@ function ($record) { } /** - * Parse an ISO2709 string + * Parse an ISO2709 string. * * @param string $marc ISO2709 * @@ -201,7 +201,7 @@ public static function fromString(string $marc): array } /** - * Convert record to an ISO2709 string + * Convert record to an ISO2709 string. * * @param array $record Record data * @@ -257,7 +257,7 @@ public static function toString(array $record): string } /** - * Open a collection file + * Open a collection file. * * @param string $file File name * @@ -273,7 +273,7 @@ public function openCollectionFile(string $file): void } /** - * Rewind the collection file + * Rewind the collection file. * * @return void * @@ -288,7 +288,7 @@ public function rewind(): void } /** - * Get next record from the file or an empty string on EOF + * Get next record from the file or an empty string on EOF. * * @return string * diff --git a/src/Serialization/MarcInJson.php b/src/Serialization/MarcInJson.php index 6264f89..6961d6e 100644 --- a/src/Serialization/MarcInJson.php +++ b/src/Serialization/MarcInJson.php @@ -46,21 +46,21 @@ class MarcInJson extends AbstractSerializationFile implements SerializationInterface { /** - * Current file + * Current file. * * @var string */ protected $fileName = ''; /** - * JSON Reader for current file + * JSON Reader for current file. * * @var JsonReader */ protected $reader = null; /** - * Check if this class can parse the given MARC string + * Check if this class can parse the given MARC string. * * @param string $marc MARC * @@ -73,7 +73,7 @@ public static function canParse(string $marc): bool } /** - * Check if the serialization class can parse the given MARC collection string + * Check if the serialization class can parse the given MARC collection string. * * @param string $marc MARC * @@ -86,7 +86,7 @@ public static function canParseCollection(string $marc): bool } /** - * Check if the serialization class can parse the given MARC collection file + * Check if the serialization class can parse the given MARC collection file. * * @param string $file File name * @@ -107,7 +107,7 @@ public static function canParseCollectionFile(string $file): bool } /** - * Parse MARC collection from a string into an array + * Parse MARC collection from a string into an array. * * @param string $collection MARC record collection in the format supported by * the serialization class @@ -121,7 +121,7 @@ public static function collectionFromString(string $collection): array } /** - * Parse MARC-in-JSON + * Parse MARC-in-JSON. * * @param string $marc JSON * @@ -134,7 +134,7 @@ public static function fromString(string $marc): array } /** - * Convert record to ISO2709 string + * Convert record to ISO2709 string. * * @param array $record Record data * @@ -146,7 +146,7 @@ public static function toString(array $record): string } /** - * Open a collection file + * Open a collection file. * * @param string $file File name * @@ -164,7 +164,7 @@ public function openCollectionFile(string $file): void } /** - * Rewind the collection file + * Rewind the collection file. * * @return void * @@ -179,7 +179,7 @@ public function rewind(): void } /** - * Get next record from the file or an empty string on EOF + * Get next record from the file or an empty string on EOF. * * @return string * @@ -203,7 +203,7 @@ public function getNextRecord(): string } /** - * Convert a record array to a JSON string + * Convert a record array to a JSON string. * * @param array $record Record * diff --git a/src/Serialization/MarcXml.php b/src/Serialization/MarcXml.php index 96f64b7..3749d11 100644 --- a/src/Serialization/MarcXml.php +++ b/src/Serialization/MarcXml.php @@ -46,28 +46,28 @@ class MarcXml extends AbstractSerializationFile implements SerializationInterface { /** - * Current file + * Current file. * * @var string */ protected $fileName = ''; /** - * XML Reader for current file + * XML Reader for current file. * * @var \XMLReader */ protected $xml = null; /** - * Current XML element path + * Current XML element path. * * @var array */ protected $currentXmlPath = []; /** - * Check if this class can parse the given MARC string + * Check if this class can parse the given MARC string. * * @param string $marc MARC * @@ -80,7 +80,7 @@ public static function canParse(string $marc): bool } /** - * Check if the serialization class can parse the given MARC collection string + * Check if the serialization class can parse the given MARC collection string. * * @param string $marc MARC * @@ -93,7 +93,7 @@ public static function canParseCollection(string $marc): bool } /** - * Check if the serialization class can parse the given MARC collection file + * Check if the serialization class can parse the given MARC collection file. * * @param string $file File name * @@ -113,7 +113,7 @@ public static function canParseCollectionFile(string $file): bool } /** - * Parse MARC collection from a string into an array + * Parse MARC collection from a string into an array. * * @param string $collection MARC record collection in the format supported by * the serialization class @@ -132,7 +132,7 @@ public static function collectionFromString(string $collection): array } /** - * Parse MARCXML string + * Parse MARCXML string. * * @param string $marc MARCXML * @@ -172,7 +172,7 @@ public static function fromString(string $marc): array } /** - * Convert record to a MARCXML string + * Convert record to a MARCXML string. * * @param array $record Record data * @@ -243,7 +243,7 @@ public static function toString(array $record): string } /** - * Load XML into SimpleXMLElement + * Load XML into SimpleXMLElement. * * @param string $xml XML * @@ -288,7 +288,7 @@ protected static function loadXML(string $xml): \SimpleXMLElement } /** - * Open a collection file + * Open a collection file. * * @param string $file File name * @@ -308,7 +308,7 @@ public function openCollectionFile(string $file): void } /** - * Rewind the collection file + * Rewind the collection file. * * @return void * @@ -323,7 +323,7 @@ public function rewind(): void } /** - * Get next record from the file or an empty string on EOF + * Get next record from the file or an empty string on EOF. * * @return string * diff --git a/src/Serialization/MessageCallbackInterface.php b/src/Serialization/MessageCallbackInterface.php index b0b0ada..946fb95 100644 --- a/src/Serialization/MessageCallbackInterface.php +++ b/src/Serialization/MessageCallbackInterface.php @@ -41,7 +41,7 @@ interface MessageCallbackInterface { /** - * Set message callback + * Set message callback. * * @param callable $callback Message callback * diff --git a/src/Serialization/SerializationFileInterface.php b/src/Serialization/SerializationFileInterface.php index 2173346..00d3a02 100644 --- a/src/Serialization/SerializationFileInterface.php +++ b/src/Serialization/SerializationFileInterface.php @@ -41,7 +41,7 @@ interface SerializationFileInterface { /** - * Check if the serialization class can parse the given MARC collection file + * Check if the serialization class can parse the given MARC collection file. * * @param string $file File name * @@ -50,7 +50,7 @@ interface SerializationFileInterface public static function canParseCollectionFile(string $file): bool; /** - * Set message callback + * Set message callback. * * @param callable $callback Message callback * @@ -59,7 +59,7 @@ public static function canParseCollectionFile(string $file): bool; public function setMessageCallback(?callable $callback): void; /** - * Open a collection file + * Open a collection file. * * @param string $file File name * @@ -70,7 +70,7 @@ public function setMessageCallback(?callable $callback): void; public function openCollectionFile(string $file): void; /** - * Rewind the collection file + * Rewind the collection file. * * @return void * @@ -79,7 +79,7 @@ public function openCollectionFile(string $file): void; public function rewind(): void; /** - * Get next record from the file or an empty string on EOF + * Get next record from the file or an empty string on EOF. * * @return string * diff --git a/src/Serialization/SerializationInterface.php b/src/Serialization/SerializationInterface.php index 9b2828a..ce75967 100644 --- a/src/Serialization/SerializationInterface.php +++ b/src/Serialization/SerializationInterface.php @@ -41,7 +41,7 @@ interface SerializationInterface { /** - * Check if the serialization class can parse the given MARC string + * Check if the serialization class can parse the given MARC string. * * @param string $marc MARC * @@ -50,7 +50,7 @@ interface SerializationInterface public static function canParse(string $marc): bool; /** - * Check if the serialization class can parse the given MARC collection string + * Check if the serialization class can parse the given MARC collection string. * * @param string $marc MARC * @@ -59,7 +59,7 @@ public static function canParse(string $marc): bool; public static function canParseCollection(string $marc): bool; /** - * Parse MARC collection from a string into an array of MarcReader classes + * Parse MARC collection from a string into an array of MarcReader classes. * * @param string $collection MARC record collection in the format supported by * the serialization class @@ -70,7 +70,7 @@ public static function canParseCollection(string $marc): bool; public static function collectionFromString(string $collection): array; /** - * Parse MARC from a string + * Parse MARC from a string. * * @param string $marc MARC record in the format supported by the serialization * class @@ -82,7 +82,7 @@ public static function fromString(string $marc): array; /** * Convert record to a string representing the format supported by the - * serialization class + * serialization class. * * @param array $data Record data * diff --git a/tests/MarcCollectionFileTest.php b/tests/MarcCollectionFileTest.php index ae71416..83a0361 100644 --- a/tests/MarcCollectionFileTest.php +++ b/tests/MarcCollectionFileTest.php @@ -1,7 +1,7 @@ in(__DIR__ . '/../src'); $rules = [ - '@PHP81Migration' => true, - '@PHPUnit100Migration:risky' => true, + '@PHP8x2Migration' => true, + '@PHPUnit10x0Migration:risky' => true, '@PSR12' => true, 'align_multiline_comment' => true, 'binary_operator_spaces' => [ @@ -15,6 +15,7 @@ ], 'cast_spaces' => ['space' => 'none'], 'class_attributes_separation' => ['elements' => ['method' => 'one', 'property' => 'one']], + 'class_reference_name_casing' => true, 'concat_space' => ['spacing' => 'one'], 'ereg_to_preg' => true, 'get_class_to_class_keyword' => true, @@ -57,6 +58,7 @@ 'sort_algorithm' => 'alpha', ], 'phpdoc_no_access' => true, + 'phpdoc_summary' => true, 'php_unit_method_casing' => true, 'pow_to_exponentiation' => true, 'single_line_after_imports' => true,