Skip to content

v2.2.0

Latest

Choose a tag to compare

@paulbalandan paulbalandan released this 06 Oct 08:46
Immutable release. Only release title and notes can be modified.
v2.2.0
ac12405

What's Changed

Added

  • Static Factories loaders. Factories::config(), Factories::models() and Factories::get() now return the requested class, the same as the config() and model() functions. A class-string resolves for any component. A short alias such as Factories::config('App') resolves through the config and model namespaces, including additionalConfigNamespaces and additionalModelNamespaces.
  • Request::getServer(). With no index it returns array<string, mixed>. A constant key returns string|null, or the actual type for argv, argc, REQUEST_TIME and REQUEST_TIME_FLOAT.
  • IncomingRequest input accessors. getGet(), getPost(), getCookie(), getPostGet(), getGetPost() and getRawInputVar() return array<string, mixed> for a null or array index. A constant string index returns array<mixed>|string|null (getRawInputVar() keeps its declared type here). A filter argument also keeps the declared type.

Fixed

  • Crash under PHPStan 2.3. Rector and other tools that ask PHPStan for native types stopped with assert(count($classTypes) === 1) on model fetch chains such as $this->select('name')->asArray()->find(). When the receiver has no known class, the model fetch extension now falls back to the declared return type.
  • Model fetches on a union of models. find(), findAll(), first() and findColumn() called on a union of models, for example ($flag ? $users : $jobs)->find(1), now return the union of the row types of every model in it. Previously they used the first model's type only.
  • Schema build in parallel runs. Migrations are discovered once per run, and building a cold schema cache is locked, so parallel PHPStan workers no longer all run the migrations.

Compatibility

  • Works with PHPStan 2.3. The minimum stays at PHPStan 2.2.

Coming natively in CodeIgniter 4.7.5

CodeIgniter 4.7.5 will declare precise types for the ResultInterface row accessors, the CLIRequest input getters, current_url()/previous_url(), and IncomingRequest::getJSON()/getJsonVar() (codeigniter4/CodeIgniter4#10588). This extension doesn't add those types itself. Upgrade CodeIgniter when 4.7.5 is out to get them.

Full Changelog: v2.1.0...v2.2.0