Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit 0fc9584

Browse files
committed
(fix): Formatting style checked and fixed according to http://framework.zend.com/manual/1.12/en/coding-standard.coding-style.html
1 parent 1a4053d commit 0fc9584

File tree

2 files changed

+24
-44
lines changed

2 files changed

+24
-44
lines changed

library/Zend/Console/Getopt.php

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -731,26 +731,17 @@ public function parse()
731731
return $this;
732732
}
733733

734-
public function checkRequiredArguments(){
735-
736-
737-
foreach($this->_rules as $name=>$rule){
738-
739-
if($rule['param'] === 'required'){
740-
741-
$defined = false;
742-
743-
foreach($rule['alias'] as $alias){
744-
745-
$defined = $defined === true ? true : array_key_exists($alias, $this->_options);
746-
734+
public function checkRequiredArguments()
735+
{
736+
foreach ($this->_rules as $name=>$rule){
737+
if ($rule['param'] === 'required'){
738+
$defined = false;
739+
foreach ($rule['alias'] as $alias){
740+
$defined = $defined === true ? true : array_key_exists($alias, $this->_options);
747741
}
748-
if($defined === false){
749-
742+
if ($defined === false){
750743
require_once 'Zend/Console/Getopt/Exception.php';
751-
throw new Zend_Console_Getopt_Exception(
752-
"Option \"$alias\" requires a parameter.",
753-
$this->getUsageMessage());
744+
throw new Zend_Console_Getopt_Exception("Option \"$alias\" requires a parameter.", $this->getUsageMessage());
754745

755746
}
756747
}

tests/Zend/Console/GetoptTest.php

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -269,51 +269,40 @@ public function testGetoptUnSetBeforeParse()
269269
$this->assertFalse(isset($opts->a));
270270
}
271271

272-
public function testVerifyRequiredArgument(){
273-
$opts = new Zend_Console_Getopt(array(
274-
'apple|a=s' =>"First required argument"
275-
));
272+
public function testVerifyRequiredArgument()
273+
{
274+
$opts = new Zend_Console_Getopt(array('apple|a=s' => "First required argument"));
276275
try {
277276
$opts->parse();
278277
$opts->checkRequiredArguments();
279278
$this->fail('Expected to catch a Zend_Console_Getopt_Exception');
280279
}
281-
catch (Exception $e){
280+
catch (Zend_Exception $e){
282281
$this->assertTrue($e instanceof Zend_Console_Getopt_Exception,
283-
'Expected Zend_Console_Getopt_Exception, got '. get_class($e));
284-
285-
$this->assertEquals( 'Option "a" requires a parameter.' , $e->getMessage() );
282+
'Expected Zend_Console_Getopt_Exception, got '. get_class($e));
283+
$this->assertEquals('Option "a" requires a parameter.' , $e->getMessage());
286284
}
287285

288-
$opts->addArguments( array( "-a", "apple") );
286+
$opts->addArguments(array( "-a", "apple") );
289287
$opts->parse();
290288
$opts->checkRequiredArguments();//-> no Exception here
291289
}
292290

293-
public function testEmptyRequiredOption(){
294-
291+
public function testEmptyRequiredOption()
292+
{
295293
$opts = new Zend_Console_Getopt(array(
296294
'apple|a=s' =>"First required argument",
297295
'banana|b=i' =>"Second required argument"
298-
));
299-
300-
$opts->addArguments(array(
301-
"-a",
302-
"-b",
303-
"123"
304-
));
305-
296+
));
297+
$opts->addArguments(array("-a","-b","123"));
306298
try {
307299
$opts->parse();
308300
$opts->checkRequiredArguments();
309-
$this->fail('Expected to catch a Zend_Console_Getopt_Exception');
310-
311-
} catch (Exception $e) {
312-
301+
$this->fail('Expected to catch a Zend_Console_Getopt_Exception');
302+
} catch (Zend_Exception $e) {
313303
$this->assertTrue($e instanceof Zend_Console_Getopt_Exception,
314-
'Expected Zend_Console_Getopt_Exception, got '. get_class($e));
315-
316-
$this->assertEquals( 'Option "a" requires a parameter.' , $e->getMessage() );
304+
'Expected Zend_Console_Getopt_Exception, got '. get_class($e));
305+
$this->assertEquals('Option "a" requires a parameter.' , $e->getMessage());
317306
}
318307
}
319308

0 commit comments

Comments
 (0)