Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be able to run examples whatever current directory is #201

Merged
merged 1 commit into from Feb 22, 2024

Conversation

llaville
Copy link
Contributor

Hello

With recent problem found when using PHPUnit v9.6 PHAR version, I've rediscovered phpDocumentor/TypeResolver.

Context

I've forked the repo, and install all dependencies with composer install because there is a composer.lock.

BTW, do you tell us why dependencies seems very outdated (composer.lock was modified a year ago : Mar 12, 2023 on branch 1.x) while there is at least a recent version 1.8.1 (2 days ago) ?

Chunk of composer outdated command results :

Direct dependencies required in composer.json:
doctrine/deprecations            v1.0.0  1.1.3   A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to d...
phpbench/phpbench                1.2.7   1.2.14  PHP Benchmarking Framework
phpstan/extension-installer      1.1.0   1.3.1   Composer plugin for automatic installation of PHPStan extensions
phpstan/phpdoc-parser            1.13.0  1.25.0  PHPDoc parser with support for nullable, intersection and generic types
phpstan/phpstan                  1.8.2   1.10.59 PHPStan - PHP Static Analysis Tool
phpstan/phpstan-phpunit          1.1.1   1.3.15  PHPUnit extensions and rules for PHPStan
phpunit/phpunit                  9.5.21  9.6.16  The PHP Unit Testing framework.
rector/rector                    0.13.9  1.0.1   Instant Upgrade and Automated Refactoring of any PHP code
vimeo/psalm                      v4.25.0 5.22.1  A static analysis tool for finding errors in PHP applications

Try it

With current directory is root of the forked repo copy, I've tried to run examples :

devilbox@php-8.3.3 in /shared/backups/github/TypeResolver $ php examples/01-resolving-simple-types.php

But I got :


Warning: require(../vendor/autoload.php): Failed to open stream: No such file or directory in /shared/backups/github/TypeResolver/examples/01-resolving-simple-types.php on line 5

Call Stack:
    0.0001     934048   1. {main}() /shared/backups/github/TypeResolver/examples/01-resolving-simple-types.php:0


Fatal error: Uncaught Error: Failed opening required '../vendor/autoload.php' (include_path='.:/usr/local/lib/php') in /shared/backups/github/TypeResolver/examples/01-resolving-simple-types.php on line 5

Error: Failed opening required '../vendor/autoload.php' (include_path='.:/usr/local/lib/php') in /shared/backups/github/TypeResolver/examples/01-resolving-simple-types.php on line 5

Call Stack:
    0.0001     934048   1. {main}() /shared/backups/github/TypeResolver/examples/01-resolving-simple-types.php:0

While, expected results are :

\phpDocumentor\Reflection\Types\Compound::__set_state(array(
   'types' =>
  array (
    0 =>
    \phpDocumentor\Reflection\Types\String_::__set_state(array(
    )),
    1 =>
    \phpDocumentor\Reflection\Types\Integer::__set_state(array(
    )),
  ),
   'token' => '|',
))/shared/backups/github/TypeResolver/examples/01-resolving-simple-types.php:13:
string(10) "string|int"

This PR solve the problem, whatever current dir is !

@jaapio
Copy link
Member

jaapio commented Feb 22, 2024

Thanks for this PR, it's good to see that some people check those examples.

The reason the dependencies are outdated is because we support a broad range of php versions. Besides that I do not update very often, this library exists for many years now and doesn't require a lot of maintenance. I shifted my focus to other projects but I'm still doing small changes when needed or create a new release when I merge a pr.

@jaapio jaapio merged commit 8ea4d87 into phpDocumentor:1.x Feb 22, 2024
21 checks passed
@llaville llaville deleted the fix-examples-vendor-path branch February 22, 2024 18:27
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.

None yet

2 participants