Skip to content

Releases: CodeIgniter/phpstan-codeigniter

v2.2.0

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

v2.1.0

Choose a tag to compare

@paulbalandan paulbalandan released this 15 Jun 21:21
Immutable release. Only release title and notes can be modified.
v2.1.0
61b0339

What's Changed

Added

  • Type asObject-fetched entities by the producing model's casts

Full Changelog: v2.0.1...v2.1.0

v2.0.1

Choose a tag to compare

@paulbalandan paulbalandan released this 15 Jun 20:09
Immutable release. Only release title and notes can be modified.
v2.0.1
da84020

What's Changed

Fixed

  • Apply the model's casts to entity property types

Full Changelog: v2.0.0...v2.0.1

v2.0.0

Choose a tag to compare

@paulbalandan paulbalandan released this 15 Jun 17:09
Immutable release. Only release title and notes can be modified.
v2.0.0
408f5d4

Highlights

This release is a ground-up rewrite of the extension. The headline feature is Model and Entity type inference driven by your real database schema: the extension materializes your schema by running your migrations against a temporary SQLite database, then uses it to type your models, entities, and fetched rows.

Important

This is a major release with breaking changes. Read the Upgrade Guide before upgrading.

Requirements

  • PHP ^8.2
  • PHPStan ^2.2
  • CodeIgniter 4 ^4.7
  • The sqlite3 PHP extension (new, powers the schema layer)

What's new

Model and Entity type inference

Resolved from your live schema instead of heuristics (closes #17, #19, #25):

  • Model::find(), findAll(), first(), and findColumn() return the precise row type for the model's $returnType (an entity, a shaped array{...} of columns, or a stdClass), honoring asArray(), asObject(), and the select() field list (aliases, table.*, and joined columns).
  • Entity virtual properties are typed from the entity's $casts and $dates (including custom $castHandlers) layered over the backing database column.
  • fake() returns a single fabricated record of the model's return type.

See the type inference docs for the full list.

Rules

  • The superglobals rules were split into four (SuperglobalsOffsetAccess, SuperglobalsOffsetAssign, SuperglobalsOffsetUnset, SuperglobalsGlobalAssign), now also catching whole-array assignment. Most are auto-fixable with vendor/bin/phpstan analyse --fix.
  • The config() / model() ::class discouragement rule was removed.

Breaking changes

  • PHPStan ^2.2 and the sqlite3 extension are now required.
  • Rule identifiers and messages changed (the superglobals split/rename and the removed discouragement rule), so existing baseline entries will no longer match and must be regenerated.

See the Upgrade Guide for the full migration steps.

Full Changelog: v1.6.0...v2.0.0

v1.6.0

Choose a tag to compare

@paulbalandan paulbalandan released this 15 Jun 08:36
Immutable release. Only release title and notes can be modified.
v1.6.0
509c7e3

What's Changed

  • Use list syntax in phpdoc
  • Do not use deprecated fixer
  • Use util_bootstrap
  • Bump actions/checkout from 4 to 5 (#39)
  • Simplify test code
  • Rename phpstan.dist.neon
  • Fix list type required for ConstantArrayType key
  • Security harden workflows
  • Bump actions/cache from 5.0.4 to 5.0.5 (#42)
  • Report abandoned packages
  • Bump shivammathur/setup-php from 2.37.0 to 2.37.1 (#43)
  • Bump actions/checkout from 6.0.2 to 6.0.3 (#44)
  • Bump shivammathur/setup-php from 2.37.1 to 2.37.2 (#45)
  • Drop support for PHP 8.1

Full Changelog: v1.5.4...v1.6.0

v1.5.4

Choose a tag to compare

@paulbalandan paulbalandan released this 11 Jul 14:31
Immutable release. Only release title and notes can be modified.
v1.5.4
e959fb0

What's Changed

  • Fix deprecated call to ClassReflection::isSubclassOf()
  • Remove unneeded PHPDoc on rules
  • Add ReflectionHelperGetPrivateMethodInvokerReturnTypeExtension (#35)
  • Fix calling non-static method without an object
  • Add extension for Services::getSharedInstance()
  • Extract type inference to separate doc
  • Fix outdated info in README
  • Fix code style and tests
  • Add CacheFactoryGetHandlerReturnTypeExtension (#37)
  • Allow certain superglobal offsets to be set directly
  • Add REQUEST_TIME and REQUEST_TIME_FLOAT as allowed offsets

Full Changelog: v1.5.3...v1.5.4

v1.5.3

Choose a tag to compare

@paulbalandan paulbalandan released this 25 Jan 15:35
Immutable release. Only release title and notes can be modified.
v1.5.3
430e0b4

Fixed 🔧

Full Changelog: v1.5.2...v1.5.3

v1.5.2

Choose a tag to compare

@paulbalandan paulbalandan released this 24 Jan 18:58
v1.5.2
d7c525e

Fixed 🔧

  • Move codeigniter4/framework to require-dev (#33)
  • Fix code styles

New Contributors

Full Changelog: v1.5.1...v1.5.2

v1.5.1

Choose a tag to compare

@paulbalandan paulbalandan released this 02 Dec 15:35
v1.5.1
4bfaba8

Fixed 🔧

  • Remove downgrade hacks as CI4 requires PHP 8.1

Full Changelog: v1.5.0...v1.5.1

v1.5.0

Choose a tag to compare

@paulbalandan paulbalandan released this 02 Dec 13:27
v1.5.0
b4386c6

What's Changed

  • Fix removed deleted_at on UserModel
  • Move bootstrap.php to root
  • Apply cs fixes
  • Update rector/rector requirement from ^0.18.2 to ^0.19.2 (#23)
  • Bump actions/cache from 3 to 4 (#22)
  • Update rector/rector requirement from ^0.19.2 to ^1.0.0 (#24)
  • Fix styles
  • Add explicit callback for array_filter
  • Fix return type of locator service
  • Fix return PHPDocs
  • Fix deprecation of ParametersAcceptorSelector::selectSingle()
  • Update phpunit/phpunit requirement from ^10.2 to ^11.4 (#29)
  • Bump to phpstan 2.0

Full Changelog: v1.4.3...v1.5.0