Skip to content

Added ErrorException handler.#1

Closed
xaav wants to merge 1 commit intocomposer:masterfrom
xaav:patch-1
Closed

Added ErrorException handler.#1
xaav wants to merge 1 commit intocomposer:masterfrom
xaav:patch-1

Conversation

@xaav
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
…ly fix)

Not all tests in the `InstallerTest` class actually create a temporary directory and set the `$this->tempComposerHome` property.

Those tests which didn't, throw a notice in PHP 8.1.

Fixes 3 notices along the lines of:
```
Deprecation triggered by Composer\Test\InstallerTest::tearDown:
is_dir(): Passing null to parameter composer#1 ($filename) of type string is deprecated

Stack trace:
0 [internal function]: Symfony\Bridge\PhpUnit\DeprecationErrorHandler->handleError(8192, '...', '...', 53)
1 tests/Composer/Test/InstallerTest.php(53): is_dir(NULL)
...
```
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.

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), '...')
...
```
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
Copy link
Copy Markdown

@Ripididip Ripididip left a comment

Choose a reason for hiding this comment

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

W

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.

4 participants