File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -61,16 +61,14 @@ function get_version_array(string $version): array
6161 */
6262function get_complete_version (array $ version ): array
6363{
64- if (false === empty ($ version )) {
65- goto assert;
64+ if (empty ($ version )) {
65+ $ version = match (true ) {
66+ defined ('VERSION ' ) && is_array (VERSION ) => get_version_array (join ('- ' , array_filter (VERSION ))),
67+ file_exists ($ version = __DIR__ . '/../../../VERSION ' ), // project dir relative to /vendor
68+ file_exists ($ version = getcwd () . '/VERSION ' ) => get_version_array (@file_get_contents ($ version )),
69+ default => INVALID_VERSION_ARRAY ,
70+ };
6671 }
67- $ version = match (true ) {
68- defined ('VERSION ' ) && is_array (VERSION ) => get_version_array (join ('- ' , array_filter (VERSION ))),
69- file_exists ($ version = __DIR__ . '/../../../VERSION ' ), // project dir relative to vendor
70- file_exists ($ version = getcwd () . '/VERSION ' ) => get_version_array (@file_get_contents ($ version )),
71- default => INVALID_VERSION_ARRAY ,
72- };
73- assert:
7472 assert (3 === count ($ version ), 'version array should have exactly 3 parts ' );
7573 assert ('' !== $ version [1 ], 'pre-release is empty, should be zero or valid identifier ' );
7674 assert ('' !== $ version [2 ], 'build-metadata is empty, should be zero or valid identifier ' );
You can’t perform that action at this time.
0 commit comments