Skip to content
This repository has been archived by the owner on Sep 20, 2021. It is now read-only.

Update README.md #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update README.md #14

wants to merge 1 commit into from

Conversation

panosru
Copy link

@panosru panosru commented Apr 22, 2018

Argument 3 passed to Hoa\Exception\Exception::__construct() must be of the type array

Argument 3 passed to Hoa\Exception\Exception::__construct() must be of the type array
@Hywan
Copy link
Member

Hywan commented Apr 24, 2018

Hello :-),

If it is not an array, it is automatically casted to an array (for strange backward compatibilities), check

Exception/Source/Idle.php

Lines 132 to 134 in c8dc4f4

if (!is_array($arguments)) {
$arguments = [$arguments];
}
.

I wonder if we want the user to always pass an array, cc @vonglasow?

@panosru
Copy link
Author

panosru commented Apr 27, 2018

@Hywan Sorry I might have missed your comment!

yes, that is true for \Hoa\Exception\Idle but not for \Hoa\Exception\Exception (at least not for what I have downloaded with composer require hoa/exception

That is mine exception/Source/Exception.php

/**
 * Each exception must extend `Hoa\Exception\Exception`.
 */
class Exception extends Idle implements Event\Source
{
    /**
     * Allocates a new exception.
     *
     * An exception is built with a formatted message, a code (an ID), and an
     * array that contains the list of formatted string for the message. If
     * chaining, a previous exception can be added.
     */
    public function __construct(
        string $message,
        int $code            = 0,
        array $arguments     = [],
        \Throwable $previous = null
    ) {

notice the array $arguments = [], type hinting.

but apparently you have already fallen into the same issue I have now with Fatal error: Uncaught TypeError: Argument 3 passed to Hoa\Exception\Exception::__construct() must be of the type array, string given and you removed the type hinting from \Hoa\Exception\Exception::__construct()

public function __construct(
string $message,
int $code = 0,
$arguments = [],
\Throwable $previous = null
) {

Thankfully I noticed your reply because I was about to make a PR in hoa/event and surround with [] all third params of Exception in hoa/event 😆

Nice work by the way! I'm using both hoa/exception and hoa/event in my omegad-biz/fault-manager lib which so far is under dev :)

@panosru
Copy link
Author

panosru commented Apr 27, 2018

Just in case anyone falls into the same issue as I did, check your composer.json file because you might either have "minimum-stability": "stable" or "prefer-stable": true.

also after your modifications in composer.json, composer update hoa/exception won't work, you'll need to run composer remove hoa/exception and then composer require hoa/exception in order to get the latest code :)

@Hywan
Copy link
Member

Hywan commented May 16, 2018

You're right, this is a bug in the master!

@Hywan Hywan added bug and removed enhancement labels May 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

None yet

2 participants