Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
Dwoo
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Common
Dwoo
Commits
19287dec
Commit
19287dec
authored
Jan 29, 2009
by
Seldaek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
+ Allowed string concatenation assignments with {$foo.="bar"}
git-svn-id:
svn://dwoo.org/dwoo/trunk@243
0598d79b-80c4-4d41-97ba-ac86fbbd088b
parent
b7950d49
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
2 deletions
+22
-2
CHANGELOG
CHANGELOG
+1
-0
Compiler.php
lib/Dwoo/Compiler.php
+6
-1
CompilerTests.php
tests/CompilerTests.php
+13
-0
DwooTests.php
tests/DwooTests.php
+2
-1
No files found.
CHANGELOG
View file @
19287dec
...
...
@@ -2,6 +2,7 @@
+
Added
{
template
}
plugin
that
allows
you
to
define
sub
-
templates
and
then
call
them
(
even
recursively
)
+
Added
{
load_templates
}
to
load
external
sub
-
templates
into
your
file
+
Allowed
string
concatenation
assignments
with
{$
foo
.=
"bar"
}
*
Many
new
unit
tests
to
improve
code
coverage
and
a
bunch
of
bug
fixes
that
resulted
,
but
I
didn
't really keep track of them
* Fixed a bug with parsing AND/OR keywords in conditionals when they were
...
...
lib/Dwoo/Compiler.php
View file @
19287dec
...
...
@@ -1392,7 +1392,7 @@ class Dwoo_Compiler implements Dwoo_ICompiler
$out
.=
$match
[
1
]
.
$expr
;
}
}
}
else
if
(
$curBlock
===
'root'
&&
preg_match
(
'#^(\s*(?:[+/*%-]=|=|\+\+|--)\s*)(.*)#s'
,
$substr
,
$match
))
{
}
else
if
(
$curBlock
===
'root'
&&
preg_match
(
'#^(\s*(?:[+/*%-
.
]=|=|\+\+|--)\s*)(.*)#s'
,
$substr
,
$match
))
{
if
(
$this
->
debug
)
echo
'PARSING POST-VAR ASSIGNMENT '
.
$substr
.
'<br />'
;
// parse assignment
$value
=
$match
[
2
];
...
...
@@ -1968,6 +1968,11 @@ class Dwoo_Compiler implements Dwoo_ICompiler
$hasExpression
=
!
empty
(
$match
[
4
]);
$hasMethodCall
=
!
empty
(
$match
[
3
]);
if
(
substr
(
$key
,
-
1
)
==
"."
)
{
$key
=
substr
(
$key
,
0
,
-
1
);
$matchedLength
--
;
}
if
(
$hasMethodCall
)
{
$matchedLength
-=
strlen
(
$match
[
3
])
+
strlen
(
substr
(
$match
[
1
],
strrpos
(
$match
[
1
],
'->'
)));
$key
=
substr
(
$match
[
1
],
1
,
strrpos
(
$match
[
1
],
'->'
)
-
1
);
...
...
tests/CompilerTests.php
View file @
19287dec
...
...
@@ -394,6 +394,19 @@ replace="BAR"
$this
->
assertEquals
(
"moo8"
,
$this
->
dwoo
->
get
(
$tpl
,
array
(
'foo'
=>
0
),
$this
->
compiler
));
}
public
function
testAssignAndConcatenate
()
{
$tpl
=
new
Dwoo_Template_String
(
'{$foo="test"}{$foo.="test"}{$foo}'
);
$tpl
->
forceCompilation
();
$this
->
assertEquals
(
"testtest"
,
$this
->
dwoo
->
get
(
$tpl
,
array
(
'foo'
=>
0
),
$this
->
compiler
));
$tpl
=
new
Dwoo_Template_String
(
'{$foo.="baz"}{$foo|upper}'
);
$tpl
->
forceCompilation
();
$this
->
assertEquals
(
"BARBAZ"
,
$this
->
dwoo
->
get
(
$tpl
,
array
(
'foo'
=>
'bar'
),
$this
->
compiler
));
}
public
function
testSetStringValToTrueWhenUsingNamedParams
()
{
$this
->
dwoo
->
addPlugin
(
'test'
,
create_function
(
'Dwoo $dwoo, $name, $bool=false'
,
'return $bool ? $name."!" : $name."?";'
));
...
...
tests/DwooTests.php
View file @
19287dec
...
...
@@ -3,6 +3,7 @@
error_reporting
(
E_ALL
|
E_STRICT
);
if
(
!
ini_get
(
'date.timezone'
))
date_default_timezone_set
(
'CET'
);
define
(
'DWOO_CACHE_DIR'
,
dirname
(
__FILE__
)
.
DIRECTORY_SEPARATOR
.
'temp'
.
DIRECTORY_SEPARATOR
.
'cache'
);
define
(
'DWOO_COMPILE_DIR'
,
dirname
(
__FILE__
)
.
DIRECTORY_SEPARATOR
.
'temp'
.
DIRECTORY_SEPARATOR
.
'compiled'
);
...
...
@@ -34,7 +35,7 @@ class DwooTests extends PHPUnit_Framework_TestSuite {
$suite
=
new
self
(
'Dwoo - Unit Tests Report'
);
foreach
(
new
DirectoryIterator
(
dirname
(
__FILE__
))
as
$file
)
{
if
(
!
$file
->
isD
ot
()
&&
!
$file
->
isDir
()
&&
(
string
)
$file
!==
'DwooT
ests.php'
&&
substr
((
string
)
$file
,
-
4
)
===
'.php'
)
{
if
(
!
$file
->
isD
ir
()
&&
substr
((
string
)
$file
,
-
4
)
==
'.php'
&&
(
string
)
$file
!==
'DwooTests.php'
&&
(
string
)
$file
!==
'run-t
ests.php'
&&
substr
((
string
)
$file
,
-
4
)
===
'.php'
)
{
require_once
$file
->
getPathname
();
$class
=
basename
(
$file
,
'.php'
);
// to have an optional test suite, it should implement a public static function isRunnable
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment