@@ -84,7 +84,7 @@ |
||
84 | 84 | * @param \Closure $fcn Anonymous function to execute |
85 | 85 | * @param array $data List of parameters that is passed to the closure function |
86 | 86 | * @param boolean $restart True if the task should be restarted if it fails (only once) |
87 | - * @return \Aimeos\MW\Process\Iface Self object for method chaining |
|
87 | + * @return null|Pcntl Self object for method chaining |
|
88 | 88 | * @throws \Aimeos\MW\Process\Exception If starting the new task failed |
89 | 89 | */ |
90 | 90 | public function start( \Closure $fcn, array $data, $restart = false ) |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | }; |
52 | 52 | |
53 | 53 | if( pcntl_signal( SIGTERM, $handler ) === false ) { |
54 | - throw new Exception( 'Unable to install signal handler: ' . pcntl_strerror( pcntl_get_last_error() ) ); |
|
54 | + throw new Exception( 'Unable to install signal handler: '.pcntl_strerror( pcntl_get_last_error() ) ); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | flush(); // flush all pending output so it's not printed in childs again |
105 | 105 | |
106 | 106 | if( ( $pid = pcntl_fork() ) === -1 ) { |
107 | - throw new Exception( 'Unable to fork new process: ' . pcntl_strerror( pcntl_get_last_error() ) ); |
|
107 | + throw new Exception( 'Unable to fork new process: '.pcntl_strerror( pcntl_get_last_error() ) ); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | if( $pid === 0 ) { // child process |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | $status = -1; |
188 | 188 | |
189 | 189 | if( ( $pid = pcntl_wait( $status ) ) === -1 ) { |
190 | - throw new Exception( 'Unable to wait for child process: ' . pcntl_strerror( pcntl_get_last_error() ) ); |
|
190 | + throw new Exception( 'Unable to wait for child process: '.pcntl_strerror( pcntl_get_last_error() ) ); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | list( $fcn, $data, $restart ) = $this->list[$pid]; |
@@ -166,9 +166,12 @@ |
||
166 | 166 | ob_end_clean(); // avoid printing buffered messages of the parent again |
167 | 167 | } |
168 | 168 | |
169 | - try { |
|
169 | + try |
|
170 | + { |
|
170 | 171 | call_user_func_array( $fcn, $data ); |
171 | - } catch( \Exception $e ) { |
|
172 | + } |
|
173 | + catch( \Exception $e ) |
|
174 | + { |
|
172 | 175 | return 1; |
173 | 176 | } |
174 | 177 |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * Returns the message queue manager object. |
163 | 163 | * |
164 | 164 | * @return \Aimeos\MW\MQueue\Manager\Iface Message queue manager object |
165 | - */ |
|
165 | + */ |
|
166 | 166 | public function getMessageQueueManager(); |
167 | 167 | |
168 | 168 | /** |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * Returns the process object. |
187 | 187 | * |
188 | 188 | * @return \Aimeos\MW\Process\Iface Process object |
189 | - */ |
|
189 | + */ |
|
190 | 190 | public function getProcess(); |
191 | 191 | |
192 | 192 | /** |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * Returns the session object. |
202 | 202 | * |
203 | 203 | * @return \Aimeos\MW\Session\Iface Session object |
204 | - */ |
|
204 | + */ |
|
205 | 205 | public function getSession(); |
206 | 206 | |
207 | 207 | /** |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | * Returns the message queue manager object. |
376 | 376 | * |
377 | 377 | * @return \Aimeos\MW\MQueue\Manager\Iface Message queue manager object |
378 | - */ |
|
378 | + */ |
|
379 | 379 | public function getMessageQueueManager() |
380 | 380 | { |
381 | 381 | if( !isset( $this->mqueue ) ) { |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | * @param string $resource Resource name, e.g. "mq-email" |
393 | 393 | * @apram string $queue Message queue name, e.g. "order/email/payment" |
394 | 394 | * @return \Aimeos\MW\Queue\Manager\Iface Message queue object |
395 | - */ |
|
395 | + */ |
|
396 | 396 | public function getMessageQueue( $resource, $queue ) |
397 | 397 | { |
398 | 398 | if( !isset( $this->mqueue ) ) { |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | * Returns the process object. |
422 | 422 | * |
423 | 423 | * @return \Aimeos\MW\Process\Iface Process object |
424 | - */ |
|
424 | + */ |
|
425 | 425 | public function getProcess() |
426 | 426 | { |
427 | 427 | if( !isset( $this->process ) ) { |
@@ -23,7 +23,9 @@ discard block |
||
23 | 23 | public function testRun() |
24 | 24 | { |
25 | 25 | $object = new \Aimeos\MW\Process\Pcntl(); |
26 | - $fcn = function() { sleep( 1 ); }; |
|
26 | + $fcn = function() |
|
27 | + { |
|
28 | +sleep( 1 ); }; |
|
27 | 29 | |
28 | 30 | $start = microtime( true ); |
29 | 31 | $return = $object->start( $fcn, [] )->start( $fcn, [] )->wait(); |
@@ -37,7 +39,9 @@ discard block |
||
37 | 39 | |
38 | 40 | public function testRunException() |
39 | 41 | { |
40 | - $fcn = function() { throw new \Exception(); }; |
|
42 | + $fcn = function() |
|
43 | + { |
|
44 | +throw new \Exception(); }; |
|
41 | 45 | |
42 | 46 | $object = new \Aimeos\MW\Process\Pcntl(); |
43 | 47 |
@@ -16,7 +16,9 @@ |
||
16 | 16 | { |
17 | 17 | $object = new \Aimeos\MW\Process\None(); |
18 | 18 | |
19 | - $this->assertInstanceOf( '\Aimeos\MW\Process\Iface', $object->start( function() {}, [] ) ); |
|
19 | + $this->assertInstanceOf( '\Aimeos\MW\Process\Iface', $object->start( function() |
|
20 | + { |
|
21 | +}, [] ) ); |
|
20 | 22 | } |
21 | 23 | |
22 | 24 |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * Sets a new URL target specific for that category |
212 | 212 | * |
213 | 213 | * @param string $value New URL target specific for that category |
214 | - * @return \Aimeos\MShop\Product\Item\Iface Product item for chaining method calls |
|
214 | + * @return Standard Product item for chaining method calls |
|
215 | 215 | */ |
216 | 216 | public function setTarget( $value ) |
217 | 217 | { |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | /** |
343 | 343 | * Returns all children of this node. |
344 | 344 | * |
345 | - * @return array Numerically indexed list of nodes |
|
345 | + * @return Iface[] Numerically indexed list of nodes |
|
346 | 346 | */ |
347 | 347 | public function getChildren() |
348 | 348 | { |
@@ -19,13 +19,13 @@ discard block |
||
19 | 19 | { |
20 | 20 | $this->editor = \TestHelperMShop::getContext()->getEditor(); |
21 | 21 | $manager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperMShop::getContext() ); |
22 | - $this->object = $manager->getSubManager( 'property' )->getSubManager('type'); |
|
22 | + $this->object = $manager->getSubManager( 'property' )->getSubManager( 'type' ); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | |
26 | 26 | protected function tearDown() |
27 | 27 | { |
28 | - unset($this->object); |
|
28 | + unset( $this->object ); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | $results = $this->object->searchItems( $search ); |
70 | 70 | |
71 | - if( ($expected = reset($results) ) === false ) |
|
71 | + if( ( $expected = reset( $results ) ) === false ) |
|
72 | 72 | { |
73 | 73 | throw new \RuntimeException( 'No property type item found.' ); |
74 | 74 | } |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | { |
91 | 91 | $search = $this->object->createSearch(); |
92 | 92 | $search->setConditions( $search->compare( '==', 'product.property.type.editor', $this->editor ) ); |
93 | - $results = $this->object->searchItems($search); |
|
93 | + $results = $this->object->searchItems( $search ); |
|
94 | 94 | |
95 | - if( ( $item = reset($results) ) === false ) { |
|
95 | + if( ( $item = reset( $results ) ) === false ) { |
|
96 | 96 | throw new \RuntimeException( 'No type item found' ); |
97 | 97 | } |
98 | 98 | |
99 | - $item->setId(null); |
|
99 | + $item->setId( null ); |
|
100 | 100 | $item->setCode( 'unitTestSave' ); |
101 | 101 | $resultSaved = $this->object->saveItem( $item ); |
102 | 102 | $itemSaved = $this->object->getItem( $item->getId() ); |
@@ -156,24 +156,24 @@ discard block |
||
156 | 156 | $expr[] = $search->compare( '>=', 'product.property.type.ctime', '1970-01-01 00:00:00' ); |
157 | 157 | $expr[] = $search->compare( '==', 'product.property.type.editor', $this->editor ); |
158 | 158 | |
159 | - $search->setConditions( $search->combine('&&', $expr) ); |
|
159 | + $search->setConditions( $search->combine( '&&', $expr ) ); |
|
160 | 160 | $results = $this->object->searchItems( $search, [], $total ); |
161 | 161 | $this->assertEquals( 1, count( $results ) ); |
162 | 162 | |
163 | 163 | |
164 | 164 | $search = $this->object->createSearch(); |
165 | 165 | $conditions = array( |
166 | - $search->compare( '=~', 'product.property.type.code', 'package-'), |
|
166 | + $search->compare( '=~', 'product.property.type.code', 'package-' ), |
|
167 | 167 | $search->compare( '==', 'product.property.type.editor', $this->editor ) |
168 | 168 | ); |
169 | - $search->setConditions( $search->combine('&&', $conditions ) ); |
|
170 | - $search->setSlice(0, 1); |
|
171 | - $items = $this->object->searchItems( $search, [], $total); |
|
169 | + $search->setConditions( $search->combine( '&&', $conditions ) ); |
|
170 | + $search->setSlice( 0, 1 ); |
|
171 | + $items = $this->object->searchItems( $search, [], $total ); |
|
172 | 172 | |
173 | 173 | $this->assertEquals( 1, count( $items ) ); |
174 | 174 | $this->assertEquals( 4, $total ); |
175 | 175 | |
176 | - foreach($items as $itemId => $item) { |
|
176 | + foreach( $items as $itemId => $item ) { |
|
177 | 177 | $this->assertEquals( $itemId, $item->getId() ); |
178 | 178 | } |
179 | 179 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | |
182 | 182 | public function testGetSubManager() |
183 | 183 | { |
184 | - $this->setExpectedException('\\Aimeos\\MShop\\Exception'); |
|
185 | - $this->object->getSubManager('unknown'); |
|
184 | + $this->setExpectedException( '\\Aimeos\\MShop\\Exception' ); |
|
185 | + $this->object->getSubManager( 'unknown' ); |
|
186 | 186 | } |
187 | 187 | } |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | $search->setConditions( $search->compare( '==', 'product.property.editor', $this->editor ) ); |
55 | 55 | $results = $this->object->searchItems( $search ); |
56 | 56 | |
57 | - if( ( $item = reset($results) ) === false ) { |
|
57 | + if( ( $item = reset( $results ) ) === false ) { |
|
58 | 58 | throw new \RuntimeException( 'No property item found' ); |
59 | 59 | } |
60 | 60 | |
61 | - $item->setId(null); |
|
61 | + $item->setId( null ); |
|
62 | 62 | $item->setLanguageId( 'en' ); |
63 | 63 | $resultSaved = $this->object->saveItem( $item ); |
64 | 64 | $itemSaved = $this->object->getItem( $item->getId() ); |
@@ -109,13 +109,13 @@ discard block |
||
109 | 109 | { |
110 | 110 | $search = $this->object->createSearch(); |
111 | 111 | $conditions = array( |
112 | - $search->compare( '~=', 'product.property.value', '25.0'), |
|
112 | + $search->compare( '~=', 'product.property.value', '25.0' ), |
|
113 | 113 | $search->compare( '==', 'product.property.editor', $this->editor ) |
114 | 114 | ); |
115 | 115 | $search->setConditions( $search->combine( '&&', $conditions ) ); |
116 | 116 | $results = $this->object->searchItems( $search ); |
117 | 117 | |
118 | - if( ($expected = reset($results)) === false ) { |
|
118 | + if( ( $expected = reset( $results ) ) === false ) { |
|
119 | 119 | throw new \RuntimeException( sprintf( 'No product property item found for value "%1$s".', '25.0' ) ); |
120 | 120 | } |
121 | 121 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $expr[] = $search->compare( '>=', 'product.property.type.ctime', '1970-01-01 00:00:00' ); |
167 | 167 | $expr[] = $search->compare( '==', 'product.property.type.editor', $this->editor ); |
168 | 168 | |
169 | - $search->setConditions( $search->combine('&&', $expr) ); |
|
169 | + $search->setConditions( $search->combine( '&&', $expr ) ); |
|
170 | 170 | $results = $this->object->searchItems( $search, [], $total ); |
171 | 171 | $this->assertEquals( 1, count( $results ) ); |
172 | 172 | |
@@ -177,13 +177,13 @@ discard block |
||
177 | 177 | $search->compare( '==', 'product.property.editor', $this->editor ) |
178 | 178 | ); |
179 | 179 | $search->setConditions( $search->combine( '&&', $conditions ) ); |
180 | - $search->setSlice(0, 1); |
|
180 | + $search->setSlice( 0, 1 ); |
|
181 | 181 | $items = $this->object->searchItems( $search, [], $total ); |
182 | 182 | |
183 | 183 | $this->assertEquals( 1, count( $items ) ); |
184 | 184 | $this->assertEquals( 8, $total ); |
185 | 185 | |
186 | - foreach($items as $itemId => $item) { |
|
186 | + foreach( $items as $itemId => $item ) { |
|
187 | 187 | $this->assertEquals( $itemId, $item->getId() ); |
188 | 188 | } |
189 | 189 | } |
@@ -191,17 +191,17 @@ discard block |
||
191 | 191 | |
192 | 192 | public function testGetSubManager() |
193 | 193 | { |
194 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Manager\\Iface', $this->object->getSubManager('type') ); |
|
195 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Manager\\Iface', $this->object->getSubManager('type', 'Standard') ); |
|
194 | + $this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Manager\\Iface', $this->object->getSubManager( 'type' ) ); |
|
195 | + $this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Manager\\Iface', $this->object->getSubManager( 'type', 'Standard' ) ); |
|
196 | 196 | |
197 | - $this->setExpectedException('\\Aimeos\\MShop\\Exception'); |
|
198 | - $this->object->getSubManager('unknown'); |
|
197 | + $this->setExpectedException( '\\Aimeos\\MShop\\Exception' ); |
|
198 | + $this->object->getSubManager( 'unknown' ); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | |
202 | 202 | public function testGetSubManagerInvalidName() |
203 | 203 | { |
204 | - $this->setExpectedException('\\Aimeos\\MShop\\Exception'); |
|
205 | - $this->object->getSubManager('type', 'unknown'); |
|
204 | + $this->setExpectedException( '\\Aimeos\\MShop\\Exception' ); |
|
205 | + $this->object->getSubManager( 'type', 'unknown' ); |
|
206 | 206 | } |
207 | 207 | } |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | public function testGetItem() |
54 | 54 | { |
55 | 55 | $search = $this->object->createSearch(); |
56 | - $search->setConditions( $search->compare( '==', 'supplier.lists.type.editor', $this->editor) ); |
|
57 | - $results = $this->object->searchItems($search); |
|
56 | + $search->setConditions( $search->compare( '==', 'supplier.lists.type.editor', $this->editor ) ); |
|
57 | + $results = $this->object->searchItems( $search ); |
|
58 | 58 | |
59 | - if( ( $expected = reset($results) ) === false ) { |
|
59 | + if( ( $expected = reset( $results ) ) === false ) { |
|
60 | 60 | throw new \RuntimeException( 'No attribute list type item found' ); |
61 | 61 | } |
62 | 62 | |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | public function testSaveUpdateDeleteItem() |
75 | 75 | { |
76 | 76 | $search = $this->object->createSearch(); |
77 | - $search->setConditions( $search->compare( '==', 'supplier.lists.type.editor', $this->editor) ); |
|
78 | - $results = $this->object->searchItems($search); |
|
77 | + $search->setConditions( $search->compare( '==', 'supplier.lists.type.editor', $this->editor ) ); |
|
78 | + $results = $this->object->searchItems( $search ); |
|
79 | 79 | |
80 | - if( ( $item = reset($results) ) === false ) { |
|
80 | + if( ( $item = reset( $results ) ) === false ) { |
|
81 | 81 | throw new \RuntimeException( 'No type item found' ); |
82 | 82 | } |
83 | 83 | |
84 | - $item->setId(null); |
|
84 | + $item->setId( null ); |
|
85 | 85 | $item->setCode( 'unitTestSave' ); |
86 | 86 | $resultSaved = $this->object->saveItem( $item ); |
87 | 87 | $itemSaved = $this->object->getItem( $item->getId() ); |
@@ -140,13 +140,13 @@ discard block |
||
140 | 140 | $expr[] = $search->compare( '>=', 'supplier.lists.type.ctime', '1970-01-01 00:00:00' ); |
141 | 141 | $expr[] = $search->compare( '==', 'supplier.lists.type.editor', $this->editor ); |
142 | 142 | |
143 | - $search->setConditions( $search->combine('&&', $expr) ); |
|
144 | - $search->setSlice(0, 1); |
|
143 | + $search->setConditions( $search->combine( '&&', $expr ) ); |
|
144 | + $search->setSlice( 0, 1 ); |
|
145 | 145 | $results = $this->object->searchItems( $search, [], $total ); |
146 | 146 | $this->assertEquals( 1, count( $results ) ); |
147 | 147 | $this->assertEquals( 1, $total ); |
148 | 148 | |
149 | - foreach($results as $itemId => $item) { |
|
149 | + foreach( $results as $itemId => $item ) { |
|
150 | 150 | $this->assertEquals( $itemId, $item->getId() ); |
151 | 151 | } |
152 | 152 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | |
155 | 155 | public function testGetSubManager() |
156 | 156 | { |
157 | - $this->setExpectedException('\\Aimeos\\MShop\\Exception'); |
|
158 | - $this->object->getSubManager('unknown'); |
|
157 | + $this->setExpectedException( '\\Aimeos\\MShop\\Exception' ); |
|
158 | + $this->object->getSubManager( 'unknown' ); |
|
159 | 159 | } |
160 | 160 | } |