Skip to content

Commit 408f5d4

Browse files
committed
Document the CodeIgniter bootstrap and SQLite-affinity limitation
1 parent aa91ccb commit 408f5d4

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This PHPStan extension provides type inference support and rules for `CodeIgnite
1313

1414
* [Rules](docs/rules.md)
1515
* [Type inference](docs/type-inference.md)
16+
* [Upgrading from 1.x to 2.x](docs/upgrading.md)
1617

1718
## Installation
1819

@@ -35,6 +36,23 @@ includes:
3536
```
3637
</details>
3738
39+
## Bootstrapping CodeIgniter
40+
41+
This extension boots CodeIgniter during analysis so it can read your configuration, services, and database
42+
schema. Point PHPStan at a bootstrap file that loads the framework. CodeIgniter's own test bootstrap works
43+
out of the box:
44+
45+
```yml
46+
parameters:
47+
bootstrapFiles:
48+
- vendor/codeigniter4/framework/system/Test/bootstrap.php
49+
```
50+
51+
The Model and Entity type inference additionally materializes your schema by running your migrations against
52+
a temporary SQLite database, so the `sqlite3` PHP extension is required (it is declared in this package's
53+
`composer.json`). The schema is cached under the working directory's `tmp` folder by default. See the
54+
[type inference docs](docs/type-inference.md) for how to point it at a specific namespace.
55+
3856
## Contributing
3957

4058
Any contributions are welcome.

docs/upgrading.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ Both are optional. The defaults work for a typical application.
121121

122122
## Known limitations
123123

124+
- **Column types reflect SQLite affinity, not your production database.** The schema is materialized in
125+
SQLite, so a column's type follows SQLite's column affinity rather than your MySQL or Postgres type. A
126+
`BOOLEAN` column reads back as `int`, `DECIMAL` as `string`, and `ENUM`/`SET` as `string`. Add a `$casts`
127+
entry (for example `'is_active' => 'boolean'`) when you want the precise PHP type.
124128
- **Models that set `$table` in the constructor are not mapped.** The entity-to-table bridge reads `$table`
125129
from the model's default property value. A model that assigns `$this->table` inside its constructor is not
126130
resolved, so its entity's non-cast properties fall back to `mixed`.

0 commit comments

Comments
 (0)