Skip to content

Commit

Permalink
Merge pull request #22 from aik099/18-double-global-function-inclusio…
Browse files Browse the repository at this point in the history
…n-fix

Add protection against double inclusion of global function declarations
  • Loading branch information
Alexander Obuhovich committed Jan 20, 2015
2 parents 734f9a1 + a5b33d0 commit ac50c47
Show file tree
Hide file tree
Showing 5 changed files with 746 additions and 741 deletions.
5 changes: 3 additions & 2 deletions generator/GlobalFunctionFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class GlobalFunctionFile extends FactoryFile

public function __construct($file)
{
parent::__construct($file, '');
parent::__construct($file, ' ');
$this->functions = '';
}

Expand All @@ -26,7 +26,8 @@ public function build()
{
$this->addFileHeader();
$this->addPart('functions_imports');
$this->addPart('assertThat');
$this->addPart('functions_header');
$this->addCode($this->functions);
$this->addPart('functions_footer');
}
}
22 changes: 0 additions & 22 deletions generator/parts/assertThat.txt

This file was deleted.

1 change: 1 addition & 0 deletions generator/parts/functions_footer.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
}
23 changes: 23 additions & 0 deletions generator/parts/functions_header.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

if (!function_exists('assertThat')) {
/**
* Make an assertion and throw {@link Hamcrest_AssertionError} if it fails.
*
* Example:
* <pre>
* //With an identifier
* assertThat("assertion identifier", $apple->flavour(), equalTo("tasty"));
* //Without an identifier
* assertThat($apple->flavour(), equalTo("tasty"));
* //Evaluating a boolean expression
* assertThat("some error", $a > $b);
* </pre>
*/
function assertThat()
{
$args = func_get_args();
call_user_func_array(
array('Hamcrest\MatcherAssert', 'assertThat'),
$args
);
}
Loading

0 comments on commit ac50c47

Please sign in to comment.