Skip to content
This repository has been archived by the owner on May 5, 2024. It is now read-only.

Convert::to(string, callable, int) does not handle $severity #1

Closed
chitoku-k opened this issue Sep 21, 2017 · 1 comment
Closed

Convert::to(string, callable, int) does not handle $severity #1

chitoku-k opened this issue Sep 21, 2017 · 1 comment
Labels

Comments

@chitoku-k
Copy link
Contributor

Convert::to does not properly set ErrorException::$severity when called via to(string, callable, int) signature:

<?php
// OK: \ErrorException::$severity is set
// Using Convert::toErrorException, which handles it manually
Convert::toErrorException(function () {
    var_dump($undefined);
});

// NG: \ErrorException::$severity is default
// Using Convert::to, which does not specifically treat \ErrorException
Convert::to(\ErrorException::class, function () {
    var_dump($undefined);
});

This behavior is slightly confusing as they are neither documented nor logical.

@mpyw mpyw added the bug label Sep 22, 2017
@mpyw mpyw closed this as completed in e33e5bf Sep 22, 2017
@chitoku-k
Copy link
Contributor Author

This does not handle \ErrorException when $class is equal to \ErrorException, which begins with \, whilst it can be instantiated.

exceper/src/Convert.php

Lines 89 to 93 in a887c36

if (strcasecmp($class, 'ErrorException')) {
throw Core::rewriteLocation(new $class($message), $file, $line);
} else {
throw new \ErrorException($message, 0, $severity, $file, $line);
}

@mpyw mpyw reopened this Sep 22, 2017
@mpyw mpyw closed this as completed in 60d74b6 Sep 22, 2017
mpyw added a commit that referenced this issue Sep 22, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants