Skip to content

Conversation

Copy link

Copilot AI commented Jan 15, 2026

Static analysis tools like PHPStan and Psalm cannot infer types from the library's untyped methods and functions.

Changes

Added comprehensive PHPDoc annotations across all library classes:

  • Parameter types (@param) - method arguments and their types
  • Return types (@return) - including union types (int|null, int|false) and nullable types (string|null)
  • Exception types (@throws) - all throwable exceptions documented on methods that can raise them

Added PHPStan integration for automated type checking:

  • PHPStan dependency - Added phpstan/phpstan: ^1.0 to dev dependencies
  • PHPStan configuration - Created phpstan.neon with max level analysis targeting the lib/ directory
  • CI/CD integration - Added PHPStan job to GitHub Actions workflow running on PHP 8.1

Coverage

  • lib/Tinify.php - Tinify class static methods + global helper functions
  • lib/Tinify/Source.php - factory methods, transformation methods, output methods
  • lib/Tinify/Result.php - result data access and file operations
  • lib/Tinify/ResultMeta.php - metadata accessors
  • lib/Tinify/Client.php - HTTP client request handling
  • lib/Tinify/Exception.php - exception factory

Example

// Before: No type information for static analysis
function fromFile($path) {
    return Source::fromFile($path);
}

// After: Complete type information
/**
 * @param string $path
 * @return Source
 * @throws AccountException
 * @throws ClientException
 * @throws ServerException
 * @throws ConnectionException
 */
function fromFile($path) {
    return Source::fromFile($path);
}

The PHPStan integration ensures that all type annotations remain accurate and catches type-related issues automatically in CI/CD.

Original prompt

This section details on the original issue you should resolve

<issue_title>Feature : add phpdoc for return types</issue_title>
<issue_description>Can you please add phpdoc so phpstan and other static analyser can know the types</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits January 15, 2026 13:56
Co-authored-by: rkoopmans <1124992+rkoopmans@users.noreply.github.com>
Co-authored-by: rkoopmans <1124992+rkoopmans@users.noreply.github.com>
Co-authored-by: rkoopmans <1124992+rkoopmans@users.noreply.github.com>
Copilot AI changed the title [WIP] Add phpdoc for return types to support static analysis Add PHPDoc annotations for static analysis tools Jan 15, 2026
Copilot AI requested a review from rkoopmans January 15, 2026 14:00
Co-authored-by: rkoopmans <1124992+rkoopmans@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jan 15, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/myclabs/DeepCopy/zipball/07d290f0c47959fd5eed98c95ee5602db07e0b6a
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/nikic/PHP-Parser/zipball/dca41cd15c2ac9d055ad70dbfd011130757d1f82
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/phpstan/phpstan/zipball/2770dcdf5078d0b0d53f94317e06affe88419aa8
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/2b56bea83a09de3ac06bb18b92f068e60cc6f50b
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/comparator/zipball/67a2df3a62639eab2cc5906065e9805d4fd5dfc5
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/complexity/zipball/25f207c40d62b8b7aa32f5ab026c53561964053a
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/diff/zipball/ba01945089c3a293b01ba9badc29ad55b106b0bc
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/environment/zipball/830c43a844f1f8d5b7a1f6d6076b784454d8b7ed
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/exporter/zipball/14c6ba52f95a36c3d27c835d65efc7123c446e8c
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/global-state/zipball/b6781316bdcd28260904e7cc18ec983d0d2ef4f6
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/e1e4a170560925c26d424b6a03aed157e7dcc5c5
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/85402a822d1ecf1db1096959413d35e1c37cf1a5
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/phpunit/zipball/945d0b7f346a084ce5549e95289962972c4272e5
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/539c6691e0623af6dc6f9c20384c120f963465a0
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/theseer/tokenizer/zipball/b7489ce515e168639d17feec34b8847c326b0b3c
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/4FB57j /usr/bin/composer update --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/CzsYM9 /usr/bin/composer install --no-interaction 53b3d7c7^{commit} com-nikic-PHP-Pagit (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jFISYc /usr/bin/composer install --no-interaction --prefer-dist (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Add PHPDoc annotations for static analysis tools Add PHPDoc annotations and PHPStan for static analysis Jan 15, 2026
level: max
paths:
- lib
phpVersion: 50300
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

50300 is not supported. Minimal supported version is 70100.

"require-dev": {
"phpunit/phpunit": "^4.8 || ^5.7 || ^6.5 || ^7.5 || ^8.4 || ^9.3"
"phpunit/phpunit": "^4.8 || ^5.7 || ^6.5 || ^7.5 || ^8.4 || ^9.3",
"phpstan/phpstan": "^1.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a newer version, use ^2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature : add phpdoc for return types

3 participants