@@ -53,6 +53,11 @@ class Patch
5353 */
5454 private $ method = PatchApplicator::METHOD_PATCH ;
5555
56+ /**
57+ * @var bool
58+ */
59+ private $ keepEmptyFiles ;
60+
5661 /**
5762 * @param $sourcePackage
5863 * @param string $targetPackage
@@ -61,6 +66,7 @@ class Patch
6166 * @param string $description
6267 * @param int $stripPathComponents
6368 * @param string $method
69+ * @param bool $keepEmptyFiles
6470 */
6571 public function __construct (
6672 $ sourcePackage ,
@@ -69,7 +75,8 @@ public function __construct(
6975 $ filename ,
7076 $ description ,
7177 $ stripPathComponents = 1 ,
72- $ method = PatchApplicator::METHOD_PATCH
78+ $ method = PatchApplicator::METHOD_PATCH ,
79+ $ keepEmptyFiles = false
7380 ) {
7481 $ this ->sourcePackage = $ sourcePackage ;
7582 $ this ->targetPackage = $ targetPackage ;
@@ -78,6 +85,7 @@ public function __construct(
7885 $ this ->description = $ description ;
7986 $ this ->stripPathComponents = $ stripPathComponents ;
8087 $ this ->method = $ method ;
88+ $ this ->keepEmptyFiles = $ keepEmptyFiles ;
8189 }
8290
8391 /**
@@ -92,7 +100,8 @@ public static function createFromConfig($sourcePackage, $targetPackage, array $c
92100 'version-constraint ' => '* ' ,
93101 'description ' => null ,
94102 'strip-path-components ' => 1 ,
95- 'method ' => PatchApplicator::METHOD_PATCH
103+ 'method ' => PatchApplicator::METHOD_PATCH ,
104+ 'keep-empty-files ' => false ,
96105 ], $ config );
97106
98107 if (!in_array ($ config ['method ' ], PatchApplicator::METHODS )) {
@@ -110,7 +119,8 @@ public static function createFromConfig($sourcePackage, $targetPackage, array $c
110119 $ config ['filename ' ],
111120 $ config ['description ' ],
112121 $ config ['strip-path-components ' ],
113- $ config ['method ' ]
122+ $ config ['method ' ],
123+ $ config ['keep-empty-files ' ]
114124 );
115125 }
116126
@@ -124,7 +134,8 @@ public static function createFromArray(array $data)
124134 $ data ['filename ' ],
125135 $ data ['description ' ],
126136 $ data ['strip_path_components ' ],
127- $ data ['method ' ]
137+ $ data ['method ' ],
138+ $ data ['keep_empty_files ' ]
128139 );
129140 }
130141
@@ -193,6 +204,14 @@ public function getStripPathComponents()
193204 return $ this ->stripPathComponents ;
194205 }
195206
207+ /**
208+ * @return bool
209+ */
210+ public function getKeepEmptyFiles ()
211+ {
212+ return $ this ->keepEmptyFiles ;
213+ }
214+
196215 /**
197216 * @return string
198217 */
@@ -210,7 +229,8 @@ public function toArray()
210229 'filename ' => $ this ->filename ,
211230 'description ' => $ this ->description ,
212231 'strip_path_components ' => $ this ->stripPathComponents ,
213- 'method ' => $ this ->method
232+ 'method ' => $ this ->method ,
233+ 'keep_empty_files ' => $ this ->keepEmptyFiles ,
214234 ];
215235 }
216236}
0 commit comments