Commit Graph

46 Commits

Author SHA1 Message Date
Chirag Aggarwal d2230f8fe7 chore: bump PHPStan to level 4 and fix all new errors
Raises `phpstan.neon` level from 3 to 4 and fixes the 549 new errors
that level 4 surfaces across 157 files. Fixes are root-cause — no
`@phpstan-ignore`, no `@var` casts, no baseline entries, no widened
types. A handful of latent bugs were fixed along the way:

- `app/controllers/general.php`: path-traversal guard was negating
  `\substr(...)` before the strict comparison (`!\substr(...) === $base`
  was always `false === $base`). Rewritten as `\substr(...) !== $base`.
- `src/Appwrite/Platform/Modules/Databases/Http/Databases/Logs/XList.php`
  and `.../TablesDB/Logs/XList.php`: were importing the raw Matomo
  `DeviceDetector` (whose `getDevice()` returns `?int`) but treating the
  result as an array with `deviceName/deviceBrand/deviceModel` keys.
  Swapped to `Appwrite\Detector\Detector`, matching the wrapper already
  used a few lines below for `$os`/`$client`.
- `src/Appwrite/Platform/Modules/Functions/Workers/Builds.php`: a match
  key was checking `$resourceKey === 'functions'` when `$resourceKey`
  is `'functionId'|'siteId'` — always false. Switched to the intended
  `$resource->getCollection() === 'functions'` check.
- `src/Appwrite/OpenSSL/OpenSSL.php`: `encrypt()` return type tightened
  to `string|false` to match `openssl_encrypt`; this lets callers'
  `=== false` error handling remain meaningful.
- `app/controllers/api/messaging.php`: removed a dead
  `array_key_exists('from', [])` branch in the Msg91 provider (empty
  array literal; branch was unreachable).

Large cleanup categories across the 549 fixes:
- Removed redundant `?? default` on array offsets and expressions that
  PHPStan now knows are non-nullable.
- Removed unreachable statements (mostly `return;` after `throw` or
  `markTestSkipped()`).
- Removed redundant `is_array`/`is_string`/`is_bool`/`instanceof` checks
  on already-narrowed types.
- Added `default =>` arms (or throwing arms) to non-exhaustive matches
  on `string`/`mixed` input.
- Removed dead `$document === false` branches where method return types
  were tightened to non-nullable `Document`.
- Removed unused properties (`$version` on Etsy/Zoom OAuth2, `$paths` on
  Installer State, `$source` on MigrationsWorker, `$account2` on two
  GraphQL auth tests), unused traits (`ApiVectorsDB`, `DatabaseFixture`),
  and an unused `cleanupStaleExecutions` task method.
- Replaced `assertTrue(true)` and redundant `assertIsArray`/`assertIsString`/
  `assertNotNull` assertions with `addToAssertionCount(1)` or
  `assertNotEmpty` where the runtime type was already known.
2026-04-19 17:31:20 +05:30
Chirag Aggarwal b4085d1083 Fix token trait PHPStan static access 2026-03-31 22:23:37 +05:30
Chirag Aggarwal 18ed6a9c59 Fix more PHPStan static access issues 2026-03-31 22:04:37 +05:30
Jake Barnby 2d160747ca perf: Remove @depends from Migrations, Projects, and Tokens tests
Added helper methods with static caching for independent test execution.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 12:13:54 +13:00
Jake Barnby 714b8d7ea6 Migrate to PHPUnit 11 2026-01-15 16:14:53 +13:00
Jake Barnby 2cfb5ecfd9 Reapply "Merge pull request #11130 from appwrite/feat-auth-instance"
This reverts commit 38687bc24e.
2026-01-15 04:08:00 +13:00
Jake Barnby 38687bc24e Revert "Merge pull request #11130 from appwrite/feat-auth-instance"
This reverts commit c12cad80bb, reversing
changes made to 2a17429226.

# Conflicts:
#	composer.lock
2026-01-15 03:48:42 +13:00
Jake Barnby 5c915ef92f Reapply "Merge pull request #11099 from appwrite/feat-auth-instance"
This reverts commit 321fc8ee70.
2026-01-14 19:07:49 +13:00
Jake Barnby 321fc8ee70 Revert "Merge pull request #11099 from appwrite/feat-auth-instance"
This reverts commit a4734a5de7, reversing
changes made to 15922fb88c.

# Conflicts:
#	composer.lock
2026-01-14 02:37:17 +13:00
Jake Barnby 7573ee75a2 Use authorization instance 2026-01-07 20:04:28 +13:00
Jake Barnby dc85d44647 Revert "Refactor auth single instance" 2025-12-20 02:54:50 +13:00
Shimon Newman 95e29d1046 Merge branch '1.8.x' into refactor-auth-single-instance 2025-11-28 16:10:26 +02:00
Hemachandar c09f7d5cf9 Fix file token expiry 2025-11-27 19:40:09 +05:30
shimon 4ad249f918 Revert "Revert "Merge pull request #10682 from appwrite/refactor-auth-single-instance""
This reverts commit 8765d5650a.
2025-11-26 12:05:12 +02:00
Jake Barnby 8765d5650a Revert "Merge pull request #10682 from appwrite/refactor-auth-single-instance"
This reverts commit 919b01a1b1, reversing
changes made to deb5039352.
2025-11-19 16:21:06 +13:00
shimon 5722241ff8 Merge branch '1.8.x' of github.com:appwrite/appwrite into refactor-auth-single-instance
# Conflicts:
#	composer.lock
2025-11-13 11:10:40 +02:00
Hemachandar bc19e66775 fix tests 2025-11-12 20:27:42 +05:30
Hemachandar 10a9845898 fix: Throw error when file token expiry is in the past 2025-11-03 16:55:13 +05:30
shimon 462634d311 Update dependencies in composer.json and composer.lock; upgrade utopia-php/detector to version 0.2.*, and utopia-php/migration to version 1.3.3. Modify exception messages in storage API for better clarity on authorization failures. Adjust test assertions to reflect updated error messages. 2025-10-28 09:09:54 +02:00
Evan 0371e488e9 test fix/lint 2025-08-21 11:02:53 -07:00
Cursor Agent e6e7a728a0 Enhance token JWT validation in TokensConsoleClientTest with comprehensive checks
Co-authored-by: evanleair <evanleair@gmail.com>
2025-08-21 16:10:06 +00:00
Evan 2beb6ba0cf Update tests/e2e/Services/Tokens/TokensConsoleClientTest.php
Co-authored-by: Steven Nguyen <1477010+stnguyen90@users.noreply.github.com>
2025-08-20 12:51:25 -07:00
Evan 3ed5699876 Better jwt handling and tests 2025-08-18 10:57:15 -07:00
Evan f5f6ec71de Address stnguyen90 feedback: simplify JWT logic and fix test expectations
- Remove excessive logic and 1-minute expiration hack as requested
- Simplify token expiry handling to directly use existing  value
- Remove problematic test that creates tokens with past expiry dates
- Update existing test to properly verify JWT expiration behavior
- Use proper base64url decoding for JWT payload testing
2025-08-18 09:39:19 -07:00
Evan 3a9353a78b linter 2025-08-15 17:35:49 -07:00
Evan eec62752ed fix - incorrect file token expiry 2025-08-15 16:27:48 -07:00
Darshan 7ca951ed81 remove: {} 2025-07-08 15:43:51 +05:30
Darshan 020814e672 update: inline guest headers. 2025-07-08 15:43:28 +05:30
Darshan 7ea896301f update: test to include preview, view and download with file-security. 2025-07-08 15:42:38 +05:30
Darshan 97d5f0f030 add: e2e. 2025-07-08 15:34:52 +05:30
Darshan bebd103611 update: token scopes tests for console client. 2025-05-15 19:22:53 +05:30
Darshan 1ab724ff04 update: token scopes tests. 2025-05-15 19:13:51 +05:30
Darshan 4e9f137e55 remove: jwt logic. serve the jwt directly from the model itself. 2025-05-13 15:41:26 +05:30
Darshan 64a24b2211 update: tests for getFileDownload with resourceToken and misc changes. 2025-04-30 10:10:35 +05:30
Darshan 1170fd0ee9 update: tests for getFileDownload with resourceToken. 2025-04-30 09:52:27 +05:30
Darshan eee9adc325 update: use constant. 2025-04-29 19:52:40 +05:30
Darshan 9ae22ae3fe add: resourceId check. 2025-04-29 19:52:14 +05:30
Darshan 5208e69543 add: infinite expiry test. 2025-04-29 19:46:35 +05:30
Darshan 645b04cf32 fix: tests. 2025-04-29 19:37:39 +05:30
Darshan 6c86faa5d4 add: file tokens tests. 2025-04-29 18:25:39 +05:30
Chirag Aggarwal ba0a6f0097 chore: added requires scopes, fix call method 2025-02-05 14:14:03 +00:00
Chirag Aggarwal ca7cf765b2 chore: refactor tokens 2025-02-05 09:22:35 +00:00
Damodar Lohani e21467d9f0 format 2024-12-05 05:40:52 +00:00
Damodar Lohani 285544d2d6 delete token test 2024-12-04 09:39:30 +00:00
Damodar Lohani d32dc0a4d9 tokens test and scopes 2024-11-18 08:52:16 +00:00
Damodar Lohani 0d1fec47c6 tokens test 2024-11-18 08:00:14 +00:00