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

Added ErrorException handler. #1

Closed
wants to merge 1 commit into from
Closed

Conversation

xaav
Copy link
Contributor

@xaav xaav commented Jun 9, 2011

Changed errors to exceptions, because:

  • This will probably used in a symfony environment (I'm guessing)
  • Errors are difficult to handle.

@stof
Copy link
Contributor

stof commented Jun 10, 2011

@xaav As I said in your previous PR, you are only setting an error handler for the testsuite, which is totally useless as this is already done by PHPUnit when you configure it to do it (and it let the user change it through its PHPUnit config). So this change is just useless

@Seldaek
Copy link
Member

Seldaek commented Jun 10, 2011

@Seldaek Seldaek closed this Jun 10, 2011
naderman referenced this pull request in naderman/composer Sep 25, 2011
naderman added a commit that referenced this pull request Apr 29, 2012
Seldaek added a commit that referenced this pull request May 28, 2012
@cevou cevou mentioned this pull request Sep 20, 2012
digitalkaoz pushed a commit to digitalkaoz/composer that referenced this pull request Nov 22, 2013
digitalkaoz pushed a commit to digitalkaoz/composer that referenced this pull request Nov 22, 2013
digitalkaoz pushed a commit to digitalkaoz/composer that referenced this pull request Nov 22, 2013
@romeox6x66 romeox6x66 mentioned this pull request Jun 7, 2015
jrfnl added a commit to jrfnl/composer that referenced this pull request Aug 12, 2021
The `LibraryInstallerTest::testUninstall()` method mocks a `Package` object, but did not set an expectation for a call to `getName()`, while that method _is_ called in the `LibraryInstaller::uninstall()` method.

Without expectation, the mock returns `null`, which was subsequently being passed on to `strpos()` leading to the below error.

Fixes:
```
Deprecation triggered by Composer\Test\Installer\LibraryInstallerTest::testUninstall:
strpos(): Passing null to parameter composer#1 ($haystack) of type string is deprecated

Stack trace:
0 [internal function]: Symfony\Bridge\PhpUnit\DeprecationErrorHandler->handleError(8192, '...', '...', 202)
1 src/Composer/Installer/LibraryInstaller.php(202): strpos(NULL, '...')
2 vendor/react/promise/src/FulfilledPromise.php(28): Composer\Installer\LibraryInstaller->Composer\Installer\{closure}(NULL)
3 src/Composer/Installer/LibraryInstaller.php(208): React\Promise\FulfilledPromise->then(Object(Closure))
4 tests/Composer/Test/Installer/LibraryInstallerTest.php(221): Composer\Installer\LibraryInstaller->uninstall(Object(Mock_InstalledRepositoryInterface_e3699f95), Object(Mock_Package_e4571076))
...
```
jrfnl added a commit to jrfnl/composer that referenced this pull request Aug 12, 2021
The default state for the `ProcessExecutor::$errorOutput` property is "not set" and if there has been no error during the execution of the process, it may well still be, resulting in the return value of `$this->process->getErrorOutput()` being `null`.

In that case, we may as well bypass the whole `foreach` as it will never match any of the recognized authentication failure messages.

Includes correcting the return type for the `ProcessExecutor::getErrorOutput()` method.

There are several alternative solutions possible here:
* Set a default value for the `ProcessExecutor::$errorOutput` property of an empty string.
* Check within the `ProcessExecutor::getErrorOutput()` method whether the property is set and if not, return an empty string.

Not sure what is the best solution, please provide guidance.

Fixes a total of 5 deprecation notices along the lines of:
```
Deprecation triggered by Composer\Test\Downloader\GitDownloaderTest::testDownloadThrowsRuntimeExceptionIfGitCommandFails:
strpos(): Passing null to parameter composer#1 ($haystack) of type string is deprecated

Stack trace:
0 [internal function]: Symfony\Bridge\PhpUnit\DeprecationErrorHandler->handleError(8192, '...', '...', 340)
1 src/Composer/Util/Git.php(340): strpos(NULL, '...')
2 src/Composer/Util/Git.php(200): Composer\Util\Git->isAuthenticationFailure('...', Array)
3 src/Composer/Downloader/GitDownloader.php(121): Composer\Util\Git->runCommand(Object(Closure), '...', NULL, true)
4 src/Composer/Downloader/VcsDownloader.php(137): Composer\Downloader\GitDownloader->doInstall(Object(Mock_PackageInterface_f8be9ebd), '...', '...')
5 tests/Composer/Test/Downloader/GitDownloaderTest.php(349): Composer\Downloader\VcsDownloader->install(Object(Mock_PackageInterface_f8be9ebd), '...')
...
```
glaubinix added a commit to glaubinix/composer that referenced this pull request Feb 9, 2022
glaubinix added a commit to glaubinix/composer that referenced this pull request Feb 9, 2022
Seldaek pushed a commit that referenced this pull request Feb 9, 2022
glaubinix added a commit to glaubinix/composer that referenced this pull request Jun 24, 2022
glaubinix added a commit to glaubinix/composer that referenced this pull request Jun 24, 2022
glaubinix added a commit to glaubinix/composer that referenced this pull request Jun 24, 2022
Seldaek pushed a commit that referenced this pull request Jun 24, 2022
ktomk referenced this pull request in ktomk/composer Jun 30, 2022
Fix string type requirement in case of NULL value:

    [TypeError]                                                                                                                                                                  
    Composer\Command\InitCommand::parseAuthorString(): Argument #1 ($author) must be of type string, null given, called in phar:///composer.phar/src/Composer/Command/InitCommand.php on line 345
Seldaek pushed a commit that referenced this pull request Jul 1, 2022
Fix string type requirement in case of NULL value:

    [TypeError]                                                                                                                                                                  
    Composer\Command\InitCommand::parseAuthorString(): Argument #1 ($author) must be of type string, null given, called in phar:///composer.phar/src/Composer/Command/InitCommand.php on line 345
Seldaek pushed a commit that referenced this pull request Jul 1, 2022
Fix string type requirement in case of NULL value:

    [TypeError]                                                                                                                                                                  
    Composer\Command\InitCommand::parseAuthorString(): Argument #1 ($author) must be of type string, null given, called in phar:///composer.phar/src/Composer/Command/InitCommand.php on line 345
Seldaek pushed a commit that referenced this pull request Jul 1, 2022
Fix string type requirement in case of NULL value:

    [TypeError]                                                                                                                                                                  
    Composer\Command\InitCommand::parseAuthorString(): Argument #1 ($author) must be of type string, null given, called in phar:///composer.phar/src/Composer/Command/InitCommand.php on line 345
Seldaek pushed a commit that referenced this pull request Jul 5, 2022
Deprecation Notice: trim(): Passing null to parameter #1 ($string) of type string is deprecated in phar:///usr/bin/composer/src/Composer/Util/GitHub.php:103
emahorvat52 pushed a commit to emahorvat52/composer that referenced this pull request Feb 3, 2023
emahorvat52 pushed a commit to emahorvat52/composer that referenced this pull request Feb 3, 2023
Fix string type requirement in case of NULL value:

    [TypeError]                                                                                                                                                                  
    Composer\Command\InitCommand::parseAuthorString(): Argument composer#1 ($author) must be of type string, null given, called in phar:///composer.phar/src/Composer/Command/InitCommand.php on line 345
emahorvat52 pushed a commit to emahorvat52/composer that referenced this pull request Feb 3, 2023
Fix string type requirement in case of NULL value:

    [TypeError]                                                                                                                                                                  
    Composer\Command\InitCommand::parseAuthorString(): Argument composer#1 ($author) must be of type string, null given, called in phar:///composer.phar/src/Composer/Command/InitCommand.php on line 345
Seldaek pushed a commit that referenced this pull request Feb 10, 2023
Deprecation Notice: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in composer/src/Composer/DependencyResolver/SolverProblemsException.php:80
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

3 participants