Issues (2)

src/Timezone.php (2 issues)

1
<?php
2
/*
3
 * Copyright (c) 2021. Leandro Passos.
4
 */
5
6
namespace ItsMeLePassos\Timezone;
7
/**
8
 * Class Timezone
9
 * @package ItsMeLePassos\Timezone
10
 */
11
class Timezone
12
{
13
    /**
14
     * setTimezone - define a timezone in the PHP official list
15
     * https://www.php.net/manual/en/timezones.php
16
     *
17
     * @param string|null $timezone
18
     * @return string|null
19
     */
20
    public function timezone(string $timezone = null): string
21
    {
22
        return date_default_timezone_set($timezone);
0 ignored issues
show
It seems like $timezone can also be of type null; however, parameter $timezoneId of date_default_timezone_set() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

22
        return date_default_timezone_set(/** @scrutinizer ignore-type */ $timezone);
Loading history...
Bug Best Practice introduced by
The expression return date_default_timezone_set($timezone) returns the type boolean which is incompatible with the type-hinted return string.
Loading history...
23
    }
24
}
25