These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of the puli/manager package. |
||
5 | * |
||
6 | * (c) Bernhard Schussek <[email protected]> |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace Puli\Manager\Api\Package; |
||
13 | |||
14 | use Exception; |
||
15 | use RuntimeException; |
||
16 | |||
17 | /** |
||
18 | * Thrown when the version of a package file is not supported. |
||
19 | * |
||
20 | * @since 1.0 |
||
21 | * |
||
22 | * @author Bernhard Schussek <[email protected]> |
||
23 | */ |
||
24 | class UnsupportedVersionException extends RuntimeException |
||
25 | { |
||
26 | /** |
||
27 | * Creates an exception for an unknown version. |
||
28 | * |
||
29 | * @param string $version The version that caused the |
||
30 | * exception. |
||
31 | * @param string[] $knownVersions The known versions. |
||
32 | * @param string $path The path of the read package file. |
||
0 ignored issues
–
show
|
|||
33 | * @param Exception|null $cause The exception that caused this |
||
34 | * exception. |
||
35 | * |
||
36 | * @return static The created exception. |
||
37 | */ |
||
38 | public static function forVersion($version, array $knownVersions, $path = null, Exception $cause = null) |
||
39 | { |
||
40 | usort($knownVersions, 'version_compare'); |
||
41 | |||
42 | $isHigher = version_compare($version, end($knownVersions), '>'); |
||
43 | |||
44 | return new static(sprintf( |
||
45 | 'Cannot read package file%s at version %s. The supported versions '. |
||
46 | 'are %s.%s', |
||
47 | $path ? ' '.$path : '', |
||
48 | $version, |
||
49 | implode(', ', $knownVersions), |
||
50 | $isHigher ? ' Please run "puli self-update".' : '' |
||
51 | ), 0, $cause); |
||
52 | } |
||
53 | } |
||
54 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.