Skip to content

Releases: salient-labs/toolkit

v0.99.30

20 Jun 06:30
v0.99.30
57657a6

Choose a tag to compare

Added

Utility

  • Add Str::title()

Changed

Utility

  • Rename Package methods:
    • reference() -> ref()
    • packageReference() -> getPackageRef()
    • packageVersion() -> getPackageVersion()
    • packagePath() -> getPackagePath()
    • classPath() -> getClassPath()
    • namespacePath() -> getNamespacePath()
  • Rename Str methods:
    • Rename wrap() to enclose()
    • Rename wordwrap() to wrap()
  • Don't accept or return null in Str::trimNativeEol(), Str::eolToNative(), Str::eolFromNative()
  • In Str::normalise(), only replace "&" with " and " when it is the only ampersand between two alphanumeric characters

Removed

Utility

  • Remove Get::notNull()

v0.99.29

18 Jun 03:26
v0.99.29
9859f04

Choose a tag to compare

Added

  • PHPStan: Add Arr::extend() return type extension

v0.99.28

15 Jun 08:17
v0.99.28
4129e84

Choose a tag to compare

Added

Core

  • In AbstractStore:
    • Add support for temporary databases created on the filesystem
    • Add isTemporary() to check if the store is backed by a temporary or in-memory database
    • Add and adopt protected SQLite3::prepare() and SQLite3Stmt::execute() wrapper methods prepare() and execute()
    • Improve support for cloning (e.g. by CacheStore::asOfNow()) by tracking state in an object shared between instances
    • Add detach() and detachDb() methods so stores can be closed without their clones also closing
    • Add hasTransaction()

Changed

Core

  • Don't allow AbstractStore subclasses to be cloned unless they override __clone()

Cache

  • Improve concurrency in CacheStore by starting a SQLite transaction when CacheStore::asOfNow() returns a copy of the store, and committing it when the copy goes out of scope or is explicitly closed

v0.99.27

13 Jun 04:56
v0.99.27
2c062ec

Choose a tag to compare

Fixed

Console

  • Use message prefixes with better cross-platform support

Utility

  • Remove visible codepoint ranges from INVISIBLE_CHAR regex

v0.99.26

12 Jun 14:50
v0.99.26
a70f0f1

Choose a tag to compare

Added

Console

  • Add Console::escape()

Core

  • Add ErrorHandler::handleExitSignal() so signal handlers can report the exit status of the running script before it terminates on SIGTERM, SIGINT or SIGHUP

Changed

Console

  • Preserve output from Console::logProgress() when exiting on error

Core

  • In ErrorHandler::handleException(), set shutdown flags and resolve exit status before calling Console::exception() so console output targets can respond appropriately during shutdown

Utility

  • In Sys::handleExitSignals(), report exit on SIGTERM, SIGINT or SIGHUP to Err::handleExitSignal()

Fixed

Console

  • Fix ConsoleFormatter::formatDiff() issue where an exception is thrown when a unified diff contains a line that starts with -++

v0.99.25

11 Jun 07:28
v0.99.25
6bdba06

Choose a tag to compare

Added

Console

  • Add ConsoleWriterInterface and adopt where appropriate
  • Add a spinner to Console::logProgress() output
  • Add ConsoleLogger to finalise PSR-3 support
  • Add Console::getLogger()

Changed

Console

  • Update message decorations and formatting
  • Optionally suppress error count and associated formatting in Console::summary()
  • Update Console::group() API
  • Rename CONSOLE_TARGET environment variable to console_target
  • Rename Console methods for consistency:
    • getErrors() -> getErrorCount()
    • getWarnings() -> getWarningCount()
    • maybeClearLine() -> clearProgress()
    • out() -> printOut()
    • tty() -> printTty()
    • stdout() -> printStdout()
    • stderr() -> printStderr()
  • Optionally filter targets by level and type in Console::getTargets()
  • Always replace existing STDOUT/STDERR targets

Core

  • Move Salient\Core\Utility namespace to Salient\Utility
  • Move Regex values to Pcre and rename Pcre to Regex
  • Move CopyFlag values to Get and rename for clarity as needed
  • Move EnvFlag values to Env and rename for clarity as needed
  • Rename Env methods:
    • load() -> loadFiles()
    • environment() -> getEnvironment()
    • home() -> getHomeDir()
    • dryRun() -> getDryRun() and setDryRun()
    • debug() -> getDebug() and setDebug()
    • flag() -> getFlag() and setFlag()
  • Do not print console messages from Env
  • Move AbstractUtility and PackageDataReceivedEvent to Utility namespace
  • Move exceptions to Utility namespace and refactor as needed

Removed

Console

  • Remove unused/internal Console methods:
    • deregisterAllTargets()
    • maybeRegisterStdioTargets()
    • registerLogTarget()
  • Remove $replace parameters from Console methods

Core

  • Remove Env::getClass()
  • Remove Env::isLocaleUtf8()
  • Remove JsonEncodeFlag and JsonDecodeFlag after replacing references to them with equivalent JSON_* values
  • Remove exceptions with the same name as their native parent:
    • BadMethodCallException
    • InvalidArgumentException
    • LogicException
    • OutOfRangeException
    • RuntimeException
    • UnexpectedValueException

Fixed

Core

  • Fix DateParser::parse() issue where empty strings are interpreted as 'now'
  • Fix DateParser::parse() issue where $timezone is not applied after parsing
  • Fix incorrect example in Env documentation
  • In Format::value(), fall back to Get::type() if encoding fails

sli

  • In generate commands, detect (some) constants to fix issue where JSON_* constants in PHPDoc types are treated as class names

v0.99.24

05 Jun 06:46
v0.99.24
a5ce67b

Choose a tag to compare

Added

Collection

  • Add collection methods has() and get() for accessing items by key (existing methods with the same name have been renamed as below)
  • Add collection method map() (analogous to array_map())
  • Add handleItemsReplaced() method to CollectionTrait

Core

  • Add Reflect::normaliseType() to allow inspection of declared types without flattening intersection types

Sync

  • Add AbstractSyncEntity::getParentSerializeRules() to simplify serialization rule inheritance

Changed

Collection

  • Rename collection methods has() and get() to more consistent hasValue() and firstOf()
  • In ReadableCollectionTrait, apply filterItems() even when merging collections of the same class

Core

  • In Reflect:
    • Normalise nullable types (?int) to equivalent unions (int|null)
    • Rename getFirstCallbackParameterClassNames() to getCallableParamClassNames() and allow $param to be given, return intersection types as nested arrays
    • Rename getMethodPrototypeClass() to getPrototypeClass()
  • Ignore intersection types in EventDispatcher::listen()

Sync

  • In SyncErrorCollection:
    • Rename toSummary() to getSummary()
    • Rename toString() to getSummaryText() and simplify
    • Add reportErrors() from SyncStore::reportErrors()
    • Use CollectionTrait::handleItemsReplaced() to maintain error and warning counts
  • Do not call closures provided via serialization rules to replace null
  • When rule recursion is enabled in SyncSerializeRules:
    • Apply inherited rules to inherited entity classes recursively
    • Only apply rules for entities seen at each path (i.e. don't apply path-based rules for UserSubClass to nested instances of User)

PHPStan

  • Improve GetCoalesceRule recommendations

Removed

  • Remove SyncStoreInterface::reportErrors() (moved to SyncErrorCollection)

Fixed

  • Fix SyncSerializeRules regression where rules are not applied recursively at the point of recursion (i.e. to instances of the entity class being serialized)

v0.99.23

01 Jun 10:14
v0.99.23
516ac7c

Choose a tag to compare

Added

Core

  • Add ErrorHandler methods isShuttingDown(), isShuttingDownOnError() and getExitStatus()
    • Destructors can use these via the Err facade to determine the script's exit status during shutdown and respond accordingly
  • Add Arr::setIf()
  • Add getContainer() to builders

Curler

  • Add CurlerInterface::withRequest() so middleware can use Curler to inspect arbitrary requests

Sync

  • Add SyncStore::getBinaryRunUuid() and remove $binary parameter from getRunUuid()
  • Add SyncStore::getEntityId()
  • Add SyncStoreInterface and adopt where appropriate

PHPStan

  • Add PHPStan extensions:
    • GetCoalesceRule to report unnecessary use of Get::coalesce()
    • ArrWhereNotEmptyMethodReturnTypeExtension to resolve return type of Arr::whereNotEmpty(), including for constant arrays
    • ArrWhereNotNullMethodReturnTypeExtension to similarly resolve return type of Arr::whereNotNull()

sli

  • Add --no-declare option to sli generate builder

Changed

Cache

  • Automatically remove expired items from CacheStore
  • Adopt CacheStoreInterface instead of CacheStore where appropriate

Container

  • Resolve internal interfaces to internal implementations by default, e.g. resolve CacheStoreInterface to CacheStore if it hasn't been bound to something else
  • Move RequiresContainer to Container namespace
  • In RequiresContainer::requireContainer(), fall back to the global container if it exists, otherwise create a standalone container (unless $createGlobalContainer = true)

Core

  • Rename builder methods for consistency and clarity:
    • build() -> create()
    • go() -> build()
  • Move Http utility class to Http namespace
  • Move Get methods to new FormData class in Http namespace:
    • query() -> getQuery()
    • formData() -> getValues()
    • data() -> getData()
  • Rename QueryFlag to FormDataFlag and move to Http namespace
  • Rename Arr::same() to Arr::sameValues() and add Arr::same(), which also checks keys (as one would expect)
  • Simplify Sys::handleExitSignals()
  • Move Char constants to Str
  • Move SortFlag constants to Arr
  • Rename AbstractStore::requireUpsert() to assertCanUpsert() and return void

Curler

  • Surface middleware messages via Curler::getLastRequest() and Curler::getLastResponse()
  • Pass $curler to Curler cache key callbacks
  • Add signature to $next closure in Curler middleware annotations
  • Allow Curler's user agent header to be suppressed
  • Rename CurlerInterface::withQueryFlags() to CurlerInterface::withFormDataFlags()
  • Rename CurlerBuilder::queryFlags() to CurlerBuilder::formDataFlags()

Sync

  • Revert serialization changes in @9344acb3, where containers are propagated via serialization rules, in favour of passing an optional entity store to serialize operations
    • This allows serialization of possibly-detached entities--that may belong to a namespace registered with a store they can't locate--without making serialization rules container-dependent
  • In SyncEntityInterface:
    • Rename defaultProvider() -> getDefaultProvider()
    • Make $container a required parameter for getDefaultProvider() and withDefaultProvider()
    • Remove $container parameter from getSerializeRules()
    • Rename plural() -> getPlural() and make return type nullable
    • Add $store parameter to toArray() and toArrayWith()
    • In toArrayWith(), don't allow $rules to be an unresolved builder
    • Pass $store instead of $container to toLink() and uri()
  • Remove static modifier from SyncClassResolverInterface methods
  • Rename SyncStore methods:
    • hasRunId() -> runHasStarted()
    • provider() -> registerProvider()
    • getProviderHash() -> getProviderSignature()
    • entityType() -> registerEntity()
    • namespace() -> registerNamespace() and require $resolver to be a SyncClassResolverInterface instance
    • getEntityTypeUri() -> getEntityUri()
    • getEntityTypeNamespace() -> getEntityPrefix()
    • getNamespaceResolver() -> getClassResolver() and return SyncClassResolverInterface|null
    • entity() -> setEntity()
    • deferredEntity() -> deferEntity()
    • deferredRelationship() -> deferRelationship()
    • resolveDeferred() -> resolveDeferrals() and add $providerId, remove $return, always return resolved entities
    • checkHeartbeats() -> checkProviderHeartbeats()
    • error() -> recordError()
  • Add $forEntityProperty parameter to SyncStore::resolveDeferredRelationships()
  • Automatically detect exit status during SyncStore shutdown
  • In SyncSerializeRules:
    • Don't flatten rules until they are compiled, in case rules for entities with different normalisers are merged
    • Normalise new key names during compilation
  • Add/rename/replace in SyncSerializeRules and related interfaces:
    • getEntity()
    • apply() -> merge()
    • getRemoveFrom() -> getRemovableKeys()
    • getReplaceIn() -> getReplaceableKeys()
    • withDateFormatter()
    • withDetectRecursion()
    • getRecurseRules()
    • withRecurseRules()
    • getForSyncStore() and remove getFlags()
    • withForSyncStore()
    • getRemoveCanonicalId() -> getIncludeCanonicalId()
    • withRemoveCanonicalId() -> withIncludeCanonicalId()
  • In SyncProviderInterface::with(), do not accept ContainerInterface as a $context

Removed

  • Remove getApp() methods in favour of getContainer()
  • Remove container method instanceIf() to address unexpected outcome when existing bindings are not shared instances
  • Remove Arr::upperFirst()
  • Remove HasProvider::requireProvider()
  • Remove AbstractStore::isTransactionOpen()
  • Remove AbstractSyncEntity::store()
  • Remove AbstractSyncProvider::buildSerializeRules()
  • Remove SyncEntityLinkType::INTERNAL

Fixed

  • Fix Arr::rename() bug when renaming a key with a null value
  • Remove of object from container method templates to fix static analysis errors when binding or resolving interfaces
  • Fix issue where serialization rules applied to date and time values trigger an exception
  • Fix issue where nested value paths may be incorrect during serialization, preventing rules from applying correctly

Security

  • Add "unstable" HTTP header group and use it to filter headers for inclusion in Curler's default cache key instead of "sensitive" headers, which had non-obvious security implications by default

v0.99.22

21 May 05:50
v0.99.22
647e0ad

Choose a tag to compare

Added

  • Implement PSR-16 caching interface in CacheStore
    • In set(), rename $expires parameter to $ttl
    • Remove values from the cache when $ttl is an integer less than or equal to 0
    • Add $default parameter to get(), getInstanceOf(), etc.
    • Rename deleteAll() -> clear()
    • Rename flush() -> clearExpired() for consistency
    • Adopt PSR-16 return types (bool instead of $this)
    • Add setMultiple(), getMultiple(), deleteMultiple()
    • Add CacheStoreInterface
  • Add PHPDoc::getTemplates()

Changed

  • Improve PHPDoc tag inheritance
  • Remove leading $ from PHPDoc @var names

Removed

  • Remove unused CacheStore::maybeGet() method

v0.99.21

20 May 08:10
v0.99.21
7f7cb61

Choose a tag to compare

Added

  • Add Str::PRESERVE_QUOTED

Changed

  • Allow null to be passed to all Format methods
  • Allow the current year to be passed to Format::date() and Format::dateRange()
  • In Format::dateRange():
    • Do not report time when the time of both dates is 00:00:00, even if they are in different timezones
    • Report time with both timezones when daylight saving time is active in one date but not the other
  • In Format::bytes():
    • Add option to use decimal units
    • Change default precision from 0 to 3
    • Improve output for values near binary unit boundaries
    • Suppress redundant decimal output when unit is 'B'
  • Move DocBlock-related regular expressions from Regex to PHPDocRegex
  • Move normaliseType() from PHPDocTag to PHPDoc
  • Move PHPDocTag and related classes to PHPDoc\Tag, then rename and make them immutable
  • Allow PHPDoc @param tags to indicate they are passed by reference
  • Improve parsing, e.g. when invalid whitespace is added between tokens
  • Fail with an exception when a DocBlock cannot be parsed

Removed

  • Remove $legacyNullable support from PHPDoc classes

Fixed

  • Fix rounding bugs in Format::bytes()
  • Fix issue where Test::isNumericKey() ignores trailing newlines
  • Fix issue where PHPDoc::$Summary may not be null when a DocBlock has no summary
  • Fix issue where /***/ is not recognised as an invalid DocBlock