@@ -71,48 +71,55 @@ protected function execute(InputInterface $input, OutputInterface $output)
71
71
$ output ->writeln (sprintf ('Formatter: <comment>%s</comment> ' , 'Not available ' ));
72
72
}
73
73
74
+ // Used for BC compatibility with nikolaposa/version 2.2
75
+ $ isNikolaposaVersion2 = method_exists ($ version , ['withMajorIncremented ' ]);
76
+
74
77
$ incrementMajor = (int ) $ input ->getOption ('major ' );
75
78
if ($ incrementMajor > 0 ) {
76
79
for ($ i = 0 ; $ i < $ incrementMajor ; $ i ++) {
77
- $ version = $ version ->withMajorIncremented ();
80
+ $ version = $ isNikolaposaVersion2 ? $ version ->withMajorIncremented () : $ version -> incrementMajor ();
78
81
}
79
82
}
80
83
81
84
$ incrementMinor = (int ) $ input ->getOption ('minor ' );
82
85
if ($ incrementMinor > 0 ) {
83
86
for ($ i = 0 ; $ i < $ incrementMinor ; $ i ++) {
84
- $ version = $ version ->withMinorIncremented ();
87
+ $ version = $ isNikolaposaVersion2 ? $ version ->withMinorIncremented () : $ version -> incrementMinor ();
85
88
}
86
89
}
87
90
88
91
$ incrementPatch = (int ) $ input ->getOption ('patch ' );
89
92
if ($ incrementPatch > 0 ) {
90
93
for ($ i = 0 ; $ i < $ incrementPatch ; $ i ++) {
91
- $ version = $ version ->withPatchIncremented ();
94
+ $ version = $ isNikolaposaVersion2 ? $ version ->withPatchIncremented () : $ version -> incrementPatch ();
92
95
}
93
96
}
94
97
95
98
$ preRelease = $ input ->getOption ('prerelease ' );
96
99
if (!empty ($ preRelease )) {
97
- if (in_array (null , $ preRelease )) {
98
- $ preRelease = array ();
100
+ if (in_array (null , $ preRelease , true )) {
101
+ $ preRelease = $ isNikolaposaVersion2 ? array () : null ;
102
+ } else {
103
+ $ preRelease = implode ('. ' , $ preRelease );
99
104
}
100
105
101
106
$ version = $ version ->withPreRelease ($ preRelease );
102
107
}
103
108
104
109
$ build = $ input ->getOption ('build ' );
105
110
if (!empty ($ build )) {
106
- if (in_array (null , $ build )) {
107
- $ build = array ();
111
+ if (in_array (null , $ build , true )) {
112
+ $ build = $ isNikolaposaVersion2 ? array () : null ;
113
+ } else {
114
+ $ build = implode ('. ' , $ build );
108
115
}
109
116
110
117
$ version = $ version ->withBuild ($ build );
111
118
}
112
119
113
120
$ currentVersion = $ this ->manager ->getVersion ();
114
- if ((string ) $ currentVersion == (string ) $ version ) {
115
- $ version = $ version ->withPatchIncremented ();
121
+ if ((string ) $ currentVersion === (string ) $ version ) {
122
+ $ version = $ isNikolaposaVersion2 ? $ version ->withPatchIncremented () : $ version -> incrementPatch ();
116
123
}
117
124
118
125
$ output ->writeln (sprintf ('Current version: <info>%s</info> ' , $ currentVersion ));
0 commit comments