Skip to content

Releases: salient-labs/toolkit

v0.21.20

10 Jan 06:29
v0.21.20
3c902ae

Choose a tag to compare

Added

  • Add DotNetDateParser

Changed

  • Move DateFormatter and *DateParser classes and interfaces to Lkrms\Support\Date
  • Rename:
    • IDateFormatter -> DateFormatterInterface
    • IDateParser -> DateParserInterface
    • TextualDateParser -> DateParser
    • CreateFromFormatDateParser -> DateFormatParser

Removed

  • Remove RegexDateParser

v0.21.19

08 Jan 23:21
v0.21.19
0eab307

Choose a tag to compare

Added

  • Add Str::upperFirst() and use it in favour of ucfirst()
  • Add Test::isDateString()
  • Add File::copy()
  • Add Console::getTargets()
  • Add lk-util command sync entity get

Changed

  • Allow filenames to be passed to File::stat(), not just streams
  • Rename File::is() to File::same()
  • Clean up Console classes
    • Make Console::getStdoutTarget() and Console::getStderrTarget() public to surface mockable output streams
    • Use new ConsoleTargetTypeFlag enumeration to simplify Console::setTargetPrefix() parameters
    • Rename IConsoleTarget to ConsoleTargetInterface and split into additional ConsoleTargetStreamInterface
    • Rename IConsoleTargetWithPrefix to ConsoleTargetPrefixInterface and add getPrefix() method
    • Split abstract ConsoleTarget class into additional ConsolePrefixTarget and ConsoleStreamTarget classes
    • Rename ConsoleLevels to ConsoleLevelGroup
    • Rename ConsoleMessageTypes to ConsoleMessageTypeGroup
    • Rename IConsoleFormat to ConsoleFormatInterface
    • Rename Console::registerStableOutputLog() to registerLogTarget()
    • Rename Console::registerDefaultStdioTargets() to maybeRegisterStdioTargets()
    • Rename ConsoleMessageType::DEFAULT to ConsoleMessageType::STANDARD
  • Improve handling of null, empty and default CliOption values
    • Add CliOption::$Nullable and resolve the value of nullable options not given on the command line to null
    • Allow required options to have an optional value
    • Require options with optional values to have a non-empty defaultValue
    • Normalise the value of multipleAllowed options not given on the command line to an empty array if they are not nullable
  • In lk-util generate commands:
    • Remove custom metadata tags and @uses from output
    • Remove --no-meta option
    • Add @api to output if --api is given
    • Add @generated to output
  • Sync: rename lk-util command heartbeat to sync provider check-heartbeat
  • Sync: add --shallow option to generic GetSyncEntities command

Removed

  • Remove HasEnvironment interface and its implementations
  • Remove unused Convert::pathToBasename() method
  • Remove deprecated methods

Fixed

  • Fix an issue where File::same() returns true for files with the same inode number on different devices
  • Fix an issue where Str::setEol() replaces every combination of CR and LF in a string instead of the string's current EOL sequence

v0.21.18

29 Dec 04:49
v0.21.18
b4a3104

Choose a tag to compare

Added

  • Add File::guessIndentation()
  • Add File::isSeekable()
  • Add Str::toStream()
  • Add Sys::getUserId()

Changed

  • Refactor File::realpath()
    • Remove file descriptor handling
    • Throw an exception if the file doesn't exist
    • Resolve Phar URIs when a Phar is not running
  • Refactor File::relativeToParent()
    • Require $parentDir
    • Add $fallback (null by default) and return it if $filename does not belong to $parentDir
  • Refactor File::writeCsv()
    • Make $resource a required parameter
    • Swap $data and $resource parameters
    • Change return type to void
    • Remove UTF-16LE filters applied to streams provided by the caller
    • Apply Arr::toScalars() to each row of data
  • Refactor Sys::getProgramBasename()
    • Only remove the first matched $suffix
  • Rename Stream::fromContents() to Stream::fromString()
  • Rename environment variable CONSOLE_OUTPUT to CONSOLE_TARGET
  • Add optional $null parameter to Arr::toScalars()
  • Adopt Str::lower() and Str::upper() for case comparison
  • Make File::fputcsv() public

Fixed

  • Fix File::realpath() issue where //../ segments in Phar URIs are not resolved correctly
  • Fix ErrorHandler::silencePath() issue where files and directories that start with the same name as a silenced file are inadvertently silenced

v0.21.17

25 Dec 09:07
v0.21.17
648b811

Choose a tag to compare

Added

  • Add Arr::flatten()
  • Add HttpFactory (implements PSR-17 factory interfaces)

Changed

  • Return null instead of false when FluentIteratorInterface::nextWithValue() finds no matching value
  • Pass value AND key to FluentIteratorInterface::forEach() callback
  • In HttpRequest, preserve the original case of the HTTP method
  • In HttpHeaders, throw an exception when a header with no values is given
  • In Uri, do not resolve dot segments if the URI is a relative reference
  • In Arr::toScalars(), preserve null values
  • In Arr::trim(), remove keys from the array if removing empty values
  • Optionally preserve keys in Arr::unique()
  • Rename Arr::sameValues() to same()
  • Accept iterable where possible in Arr methods
  • Add Arr::keyOffset(), deprecating Convert::arrayKeyToOffset()
  • Add Arr::toMap(), deprecating Convert::listToMap()
  • Add Arr::toScalars(), deprecating Convert::toScalarArray()
  • Add Get::array(), deprecating Convert::iterableToArray()

Deprecated

  • Deprecate (see above):
    • Convert::arrayKeyToOffset()
    • Convert::listToMap()
    • Convert::toScalarArray()
    • Convert::iterableToArray()

Removed

  • Remove unused/redundant methods:
    • Arr::forEach()
    • Convert::columnsToUnique()
    • Convert::iterableToItem()
    • Convert::iterableToIterator()
    • Convert::scalarToString()
    • Convert::stringsToUnique()
    • Convert::stringsToUniqueList()
    • Convert::valueAtKey()
    • Convert::walkRecursive()
    • FluentIteratorInterface::forEachWhile()
    • FluentIteratorTrait::forEachWhile()

Fixed

  • Fix bug in Arr::sortDesc() where keys are not preserved correctly

v0.21.16

21 Dec 12:09
v0.21.16
789bbf0

Choose a tag to compare

Fixed

  • Fix regression in 2a19c2d where builders cannot create objects from arrays that resolve to exactly 1 constructor parameter

v0.21.15

21 Dec 05:29
v0.21.15
c06744d

Choose a tag to compare

Added

  • Add static Uri::from() method
  • Add HttpRequest
  • Add TReadableCollection::filterItems()

Changed

  • Build out CliCommand::getJsonSchema() and CliCommand::filterJsonSchema()
  • Rename Json::toArrays() to Json::parseObjectAsArray()
  • Standardise types that can be converted to a Uri
  • Rename HttpRequest to HttpServerRequest and replace with PSR-7 HttpRequest class (for outgoing requests)
  • In HttpHeaders, move Host headers to the top of the index for compliance with [RFC7230]

Fixed

  • Fix HttpHeaders issue where header names and values with trailing newlines are not rejected as invalid

v0.21.14

20 Dec 02:06
v0.21.14
ec86a7f

Choose a tag to compare

Added

  • Add File::openPipe(), File::closePipe(), File::putContents()
  • Add PHPStan-friendly @param-out types to Pcre::match() and Pcre::matchAll()

Fixed

  • Fix issue where generated facades may import unused classes

v0.21.13

20 Dec 02:06
v0.21.13
9c6d6aa

Choose a tag to compare

Added

  • Add Stream class, related exceptions and tests
  • Add HttpMessage class
  • Add HttpProtocolVersion enumeration
  • Add InvalidArgumentTypeException
  • Add Arr::splice()
  • Add File::read(), File::stat(), File::getContents()
  • Add IEnumeration::hasValue() and implement in ConvertibleEnumeration, ReflectiveEnumeration, Enumeration

Changed

  • Refactor, move and deprecate previous:
    • Convert::arraySpliceAtKey() -> Arr::spliceByKey()
    • Convert::renameArrayKey() -> Arr::rename()
    • Test::isPharUrl() -> File::isPharUri()
    • Test::isAbsolutePath() -> File::isAbsolute()
  • Make Uri::removeDotSegments() public, improve documentation
  • Change HttpRequestMethod from dictionary to enumeration
  • Rename for PSR-7 consistency:
    • IHttpHeaders -> HttpHeadersInterface
    • IAccessToken -> AccessTokenInterface
  • Move classes in Http\Auth to Http\OAuth2

Deprecated

  • Deprecate (see above):
    • Convert::arraySpliceAtKey()
    • Convert::renameArrayKey()
    • Test::isPharUrl()
    • Test::isAbsolutePath()

Fixed

  • Fix issue where File methods do not throw FilesystemErrorException on failure
  • Fix issue where Test::isAbsolutePath() does not match URIs or Windows paths with forward slashes, e.g. C:/path/to/file
  • Fix issue where Test::isPharUrl() only matches when scheme name is lowercase

v0.21.12

12 Dec 16:26
v0.21.12
36770b8

Choose a tag to compare

Added

  • In CliApplication, generate a JSON Schema when _json_schema is the first argument after a command
  • Add Uri::follow() and Uri::resolveReference(), deprecating Convert::resolveRelativeUrl() and removing support for obsolete [RFC1808]
  • Add Uri::parse(), deprecating Convert::parseUrl()
  • Add Uri::unparse(), deprecating Convert::unparseUrl()
  • Add Uri::toParts(), Uri::fromParts(), Uri::normalise(), Uri::isReference()
  • Add CliCommand::filterJsonSchema()
  • Add CliOption::getSummary()

Changed

  • Replace Sys facade with renamed System class
  • Replace Debug facade with renamed Debugging class after making its methods static
  • Refactor Debug::getCaller()
  • Rename Inspect to Get and shorten method names, i.e.
    • Inspect::getType() -> Get::type()
    • Inspect::getEol() -> Get::eol()
  • Move Convert::classToBasename() and Convert::classToNamespace() to Get::basename() and Get::namespace(), deprecating the former
  • Rewrite Convert::resolvePath() and move to File::resolve(), deprecating the former

ArrayMapper:

  • Rewrite as a self-contained class instead of a closure factory
  • Remove its Mapper facade
  • Refactor Pipeline::throughKeyMap()

Uri:

  • Implement JsonSerializable
  • Make distinction between undefined (null) and empty ('') values when converting to and from URI strings and arrays
  • Move regular expressions from RegularExpression to Uri

MultipleErrorException:

  • Add MultipleErrorExceptionInterface and move implementation from MultipleErrorException to MultipleErrorExceptionTrait
  • Add hasUnreportedErrors() and getMessageWithoutErrors()
  • In Console::exception(), use hasUnreportedErrors() and getMessageWithoutErrors() to ensure errors are only reported once

Deprecated

  • As above, deprecate:
    • Convert::classToBasename()
    • Convert::classToNamespace()
    • Convert::parseUrl()
    • Convert::resolvePath()
    • Convert::resolveRelativeUrl()
    • Convert::unparseUrl()

Removed

  • Remove redundant FluentIterator class (IterableIterator can be used or extended instead)

Fixed

  • Fix issue where Convert::classToBasename() removes suffixes from the middle of class names
  • Fix issue where URI strings with an empty host are considered invalid
  • Fix issue where URI objects with an empty host cannot have userinfo or port
  • Fix issue where file:// URIs are composed as file:
  • Fix issue where errors passed to MultipleErrorException are not reported if ErrorHandler is not handling exceptions (e.g. when running PHPUnit) by adding errors to the exception message

v0.21.11

08 Dec 03:15
v0.21.11
46be6dc

Choose a tag to compare

Added

  • Allow exceptions to be thrown with an exit status
  • In ErrorHandler, check unhandled exceptions for an exit status to return
  • Add and implement CliOptionValueType::PATH_OR_DASH and CliOptionValueType::FILE_OR_DASH
  • Add CliOptionVisibility::SCHEMA so options can be flagged for inclusion in a JSON Schema
  • Add CliOptionVisibility::ALL_EXCEPT_SYNOPSIS for convenience
  • Add Json class
  • Add utility methods:
    • Date::timezone(), Date::maybeSetTimezone()
    • File::is()
    • Pcre::quoteCharacterClass()
    • Str::wrap()
    • Test::isStringable()

Changed

  • ErrorHandler: change default exit status from 15 to 16 to improve support for bitmasks as return values
  • Console: indent fenced code blocks for separation from surrounding text
  • Move and refactor, deprecating the former:
    • Convert::splitWords() -> Str::toWords()
    • Convert::toSnakeCase() -> Str::toSnakeCase()
    • Convert::toKebabCase() -> Str::toKebabCase()
    • Convert::toCamelCase() -> Str::toCamelCase()
    • Convert::toPascalCase() -> Str::toPascalCase()
  • Review Formatters
    • Extend Utility and make methods static
    • Remove Format facade and rename Formatters to Format
    • Add Format::value()
    • Refactor Format::date() and Format::dateRange()

Deprecated

  • Deprecate Convert::toTimezone() (replaced with Date::timezone())
  • Deprecate Test::areSameFile() (replaced with File::is())
  • Deprecate case conversion methods (as above)

Removed

  • Remove support for "t" and "f" as boolean strings
  • Remove previously deprecated methods
  • Remove Test::classImplements()

Fixed

  • Fix CliCommand issue where getOptionValues() and getDefaultOptionValues() fail with an exception when a positional option's $Long property is null
  • Fix Console issue where fenced code blocks are formatted as inline spans when indented