Skip to content

Commit cb8f1be

Browse files
Merge pull request #1 from c9s/master
updating own fork
2 parents a2820c2 + 1e702d1 commit cb8f1be

36 files changed

+432
-904
lines changed

.travis.yml

+9-15
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,15 @@ php:
33
- 5.4
44
- 5.5
55
- 5.6
6-
# - hhvm
7-
before_script:
8-
- phpenv rehash
9-
- composer install --dev
6+
- hhvm
7+
install:
8+
- phpenv rehash
9+
- travis_retry composer self-update
10+
- travis_retry composer require satooshi/php-coveralls "^1" --no-update --dev
11+
- travis_retry composer install
1012
script:
11-
- phpunit
13+
- phpunit -c phpunit.xml.dist
1214
cache:
15+
apt: true
16+
directories:
1317
- vendor
14-
# matrix:
15-
# fast_finish: true
16-
# allow_failures:
17-
# - php: hhvm
18-
# - php: 5.6
19-
# exclude:
20-
# - php: hhvm
21-
# env: DB=pgsql DB_USER=postgres DB_NAME=postgres # driver currently unsupported by HHVM
22-
# - php: hhvm
23-
# env: DB=sqlite # some issues at the moment

CHANGELOG.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
CHANGELOG
2+
==================
3+
4+
Version 2.0.x
5+
-----------------
6+
7+
MethodCallExpr
8+
9+
- `MethodCall` is now removed.
10+
- Changed `MethodCallExpr` default object name from `this` to `$this`. be sure to create MethodClass with '$this'
11+
- Improve argument exporting.
12+
- Renamed `MethodCallExpr` to `MethodCallExpr`
13+
14+
Statement
15+
16+
- `Statement` class now render the content with a comma at the end.
17+
18+
Line
19+
20+
- `Line` class was added to provide indentation operation.
21+
22+
23+
Version 1.4.5
24+
-----------------
25+
26+
- `Block::indent()` and `Block::unindent()` is now deprecated. use
27+
`increaseIndentLevel()` and `decreaseIndentLevel()` instead.
28+
- `AllowIndent` and `AutoIndent` is now removed from Block class, it's now depends
29+
on the indent level.
30+
- Added `BracketedBlock` to support bracket wrapped block.
31+
- Improved indentation.
32+
- Added Argument class

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ SYNOPSIS
77
-------------
88

99
```php
10-
$class1 = new ClassTemplate\ClassTemplate('Foo\\Bar22',array(
10+
$class1 = new ClassTemplate\ClassFile('Foo\\Bar22',array(
1111
'template' => 'Class.php.twig',
1212
'template_dirs' => array('src/ClassTemplate/Templates'),
1313
));

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
"name": "corneltek/class-template",
33
"homepage": "http://github.com/c9s/ClassTemplate",
44
"description": "Class template Utilities",
5-
"version": "1.4.4",
65
"require": {
76
"php": ">=5.3.0",
8-
"twig/twig": "~1"
7+
"corneltek/codegen": "^2",
8+
"twig/twig": "^1"
99
},
1010
"require-dev": {
1111
"corneltek/phpunit-testmore": "dev-master"
@@ -23,4 +23,4 @@
2323
"ClassTemplate\\": "src/ClassTemplate/"
2424
}
2525
}
26-
}
26+
}

phpunit.xml

-13
This file was deleted.

phpunit.xml.dist

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit bootstrap="vendor/autoload.php"
3+
backupGlobals="false"
4+
convertErrorsToExceptions="true"
5+
convertNoticesToExceptions="true"
6+
convertWarningsToExceptions="true"
7+
stopOnError="false"
8+
stopOnFailure="false"
9+
verbose="true">
10+
11+
<filter>
12+
<whitelist>
13+
<directory suffix=".php">src/</directory>
14+
</whitelist>
15+
</filter>
16+
17+
<testsuites>
18+
<testsuite name="ClassTemplate">
19+
<directory suffix="Test.php">tests/ClassTemplate</directory>
20+
</testsuite>
21+
</testsuites>
22+
23+
<logging>
24+
25+
<log type="coverage-text" target="php://stdout" showUncoveredFiles="true"/>
26+
27+
<log type="coverage-html"
28+
target="build/coverage"
29+
title="CodeGen"
30+
charset="UTF-8"
31+
yui="true"
32+
highlight="true"
33+
lowUpperBound="35"
34+
highLowerBound="70"/>
35+
36+
<log type="coverage-clover"
37+
target="build/logs/clover.xml"/>
38+
39+
<log type="junit"
40+
target="build/logs/junit.xml"
41+
logIncompleteSkipped="false"/>
42+
43+
</logging>
44+
45+
</phpunit>

src/ClassTemplate/Block.php

-69
This file was deleted.

src/ClassTemplate/ClassConst.php

-21
This file was deleted.

src/ClassTemplate/ClassFile.php

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
namespace ClassTemplate;
3+
use Exception;
4+
use ReflectionClass;
5+
use ReflectionObject;
6+
use CodeGen\UserClass;
7+
use CodeGen\Renderable;
8+
9+
class ClassFile extends UserClass
10+
{
11+
public $templateFile;
12+
public $templateDirs;
13+
public $options = array();
14+
15+
/**
16+
* constructor create a new class template object
17+
*
18+
* @param string $className
19+
* @param array $options
20+
*
21+
* a sample options:
22+
*
23+
* $t = new ClassTemplate('NewClassFoo',[
24+
* 'template_dirs' => [ path1, path2 ],
25+
* 'template' => 'Class.php.twig',
26+
* 'template_args' => [ ... predefined template arguments ],
27+
* 'twig' => [ 'cache' => false, ... ]
28+
* ])
29+
*
30+
*/
31+
public function __construct($className, array $options = array())
32+
{
33+
parent::__construct($className);
34+
$this->setOptions($options);
35+
}
36+
37+
public function setOptions(array $options)
38+
{
39+
$this->options = $options;
40+
}
41+
42+
public function setOption($key, $val) {
43+
$this->options[$key] = $val;
44+
}
45+
46+
public function render(array $args = array())
47+
{
48+
return "<?php\n" . parent::render($args);
49+
}
50+
51+
public function writeTo($file)
52+
{
53+
return file_put_contents($file, $this->render());
54+
}
55+
56+
public function getSplFilePath()
57+
{
58+
return str_replace('\\', DIRECTORY_SEPARATOR, ltrim($this->class->getFullName(),'\\'));
59+
}
60+
61+
public function load() {
62+
$tmpname = tempnam('/tmp', $this->getSplFilePath());
63+
if (file_put_contents($tmpname, $this->render()) != false) {
64+
return require $tmpname;
65+
}
66+
throw new Exception("Can not load class file $tmpname");
67+
}
68+
}
69+

src/ClassTemplate/ClassMethod.php

-27
This file was deleted.

src/ClassTemplate/ClassName.php

-49
This file was deleted.

0 commit comments

Comments
 (0)