Skip to content

Conversation

@loic425
Copy link
Contributor

@loic425 loic425 commented Mar 9, 2022

<?php

declare(strict_types=1);

namespace App;

final class User implements \Serializable
{
    public function serialize(): string
    {
        return '';
    }

    public function unserialize($data): void
    {
    }
}
<?php

namespace spec\App;

use App\User;
use PhpSpec\ObjectBehavior;

class UserSpec extends ObjectBehavior
{
    function it_is_initializable()
    {
        $this->shouldHaveType(User::class);
    }
}

Capture d’écran 2022-03-09 à 10 18 56


$this->errorHandler(E_DEPRECATED, 'error message', 'file', 1)->shouldBe(false);

error_reporting($oldLevel);
Copy link
Contributor

Choose a reason for hiding this comment

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

you you need to put this in a try-finally.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what do you mean? we are on the spec file here and this is the same way as on the method just above.

https://github.com/phpspec/phpspec/blob/main/spec/PhpSpec/Runner/Maintainer/ErrorMaintainerSpec.php#L44

@ciaranmcnulty
Copy link
Member

This is a pretty opinionated change, how could a user opt out?

Currently you can set runner.maintainers.errors.level in the yaml (which is a bit messy but at least works)

@loic425
Copy link
Contributor Author

loic425 commented Mar 9, 2022

Currently you can set runner.maintainers.errors.level in the yaml (which is a bit messy but at least works)

I didn't know that. Yes it works with these following configuration

# phpspec.yaml
runner.maintainers.errors.level: 22527 # E_ALL ^ E_STRICT ^ E_DEPRECATED

It's on on documentation here:
http://www.phpspec.net/en/stable/cookbook/configuration.html#options

But what do you think about changing that on the ContainerAssembler:

$c->getParam('runner.maintainers.errors.level', E_ALL ^ E_STRICT ^ E_DEPRECATED)

Cause I don't think we need an error for deprecations by default.

@ciaranmcnulty
Copy link
Member

It sort of 'accidentally' works because it's a parameter; it's a little verbose for the config file - I'd be happy changing the default (in next major)

@ciaranmcnulty
Copy link
Member

What is a sensible default value for this in 8.0.0? Remove E_DEPRECATED and E_USER_DEPRECATED?

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.

3 participants