Skip to content

Commit 508c694

Browse files
committed
more wip
1 parent d1e8641 commit 508c694

8 files changed

Lines changed: 71 additions & 76 deletions

File tree

system/core/events/EventPoolManager.cfc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,11 @@ component accessors="true" {
228228

229229
// Start Registering inheritances?
230230
if (
231-
structKeyExists( arguments.metadata, "extends" )
231+
arguments.metadata.keyExists( "extends" )
232232
AND
233-
!structIsEmpty( arguments.metadata.extends )
233+
!isNull( arguments.metadata.extends )
234234
AND
235-
NOT listFindNoCase( getStopRecursionClasses(), arguments.metadata.extends.name )
235+
!listFindNoCase( getStopRecursionClasses(), arguments.metadata.extends.name )
236236
) {
237237
parseMetadata( arguments.metadata.extends, arguments.eventsFound );
238238
}

system/core/util/Util.cfc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -416,18 +416,18 @@ component {
416416
if ( isObject( arguments.component ) ) {
417417
arguments.md = getMetadata( arguments.component );
418418
} else {
419-
arguments.md = server.keyExists( "boxlang" ) ? getClassMetadata( arguments.component ) : getComponentMetadata(
420-
arguments.component
421-
);
419+
arguments.md = server.keyExists( "boxlang" ) ?
420+
getClassMetadata( arguments.component ) :
421+
getComponentMetadata( arguments.component );
422422
}
423423
}
424424

425425
// If it has a parent, stop and calculate it first, unless of course, we've reached a class we shouldn't recurse into.
426426
if (
427-
structKeyExists( arguments.md, "extends" ) &&
428-
!structIsEmpty( arguments.md.extends ) &&
429-
arguments.md.type eq "component" &&
430-
stopClassRecursion( md.extends.name, arguments.stopRecursions ) EQ FALSE
427+
arguments.md.keyExists( "extends" ) AND
428+
!arguments.md.extends.isEmpty() AND
429+
listFindNoCase( "class,component", arguments.md.extends.type ) AND
430+
!stopClassRecursion( arguments.md.extends.name, arguments.stopRecursions )
431431
) {
432432
loc.parent = getInheritedMetaData(
433433
component = arguments.component,

system/ioc/config/Mapping.cfc

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ component accessors="true" {
354354
// check if already registered, if it is, just return
355355
for ( var x = 1; x lte arrayLen( variables.DIConstructorArguments ); x++ ) {
356356
if (
357-
structKeyExists( arguments, "name" ) AND
357+
!isNull( arguments.name ) AND
358358
structKeyExists( variables.DIConstructorArguments[ x ], "name" ) AND
359359
variables.DIConstructorArguments[ x ].name == arguments.name
360360
) {
@@ -492,7 +492,10 @@ component accessors="true" {
492492
// Remove scope for setter injection
493493
definition.scope = "";
494494
// Verify argument name, if not default it to setter name
495-
if ( NOT structKeyExists( arguments, "argName" ) OR len( arguments.argName ) EQ 0 ) {
495+
if (
496+
isNull( arguments.argName ) OR
497+
len( arguments.argName ) EQ 0
498+
) {
496499
arguments.argName = arguments.name;
497500
}
498501
// save incoming params
@@ -1058,44 +1061,58 @@ component accessors="true" {
10581061
}
10591062
}
10601063

1064+
/**
1065+
* Checks if the property has an annotation value for the key
1066+
*
1067+
* @metadata The metadata to check
1068+
* @key The key to look for in the annotations or documentation
1069+
*
1070+
* @return boolean
1071+
*/
10611072
private boolean function hasAnnotationValue( required struct metadata, required string key ){
1062-
// Check if the property has an annotations struct
1063-
if ( structKeyExists( metadata, "annotations" ) && structKeyExists( metadata.annotations, key ) ) {
1064-
return true;
1065-
}
1073+
var annotations = arguments.metadata.keyExists( "annotations" ) ? arguments.metadata.annotations : arguments.metadata;
1074+
var documentation = arguments.metadata.keyExists( "documentation" ) ? arguments.metadata.documentation : arguments.metadata;
10661075

1067-
// Check if the property has a documentation struct
1068-
if ( structKeyExists( metadata, "documentation" ) && structKeyExists( metadata.documentation, key ) ) {
1076+
// Check in the annotations struct first
1077+
if ( structKeyExists( annotations, key ) ) {
10691078
return true;
10701079
}
10711080

1072-
// Check if the property has the key directly
1073-
else if ( structKeyExists( metadata, key ) ) {
1081+
// Check in the documentation struct second, to support CFML engines
1082+
if ( structKeyExists( documentation, key ) ) {
10741083
return true;
10751084
}
10761085

10771086
return false;
10781087
}
10791088

1089+
/**
1090+
* Get the annotation value for a given key in the metadata
1091+
*
1092+
* @metadata The metadata to check
1093+
* @key The key to look for in the annotations or documentation
1094+
* @defaultValue The default value to return if the key is not found
1095+
*
1096+
* @return any
1097+
*/
10801098
private any function getAnnotationValue(
10811099
required struct metadata,
10821100
required string key,
10831101
any defaultValue
10841102
){
1103+
var annotations = arguments.metadata.keyExists( "annotations" ) ? arguments.metadata.annotations : arguments.metadata;
1104+
var documentation = arguments.metadata.keyExists( "documentation" ) ? arguments.metadata.documentation : arguments.metadata;
1105+
10851106
// Check if the property has an annotations struct
1086-
if ( structKeyExists( metadata, "annotations" ) && structKeyExists( metadata.annotations, key ) ) {
1087-
return metadata.annotations[ key ];
1107+
if ( structKeyExists( annotations, key ) ) {
1108+
return annotations[ key ];
10881109
}
10891110

10901111
// Check if the property has an documentation struct
1091-
if ( structKeyExists( metadata, "documentation" ) && structKeyExists( metadata.documentation, key ) ) {
1092-
return metadata.documentation[ key ];
1112+
if ( structKeyExists( documentation, key ) ) {
1113+
return documentation[ key ];
10931114
}
10941115

1095-
// Check if the property has the key directly
1096-
else if ( structKeyExists( metadata, key ) ) {
1097-
return metadata[ key ];
1098-
}
10991116
// Return default value
11001117
return defaultValue;
11011118
}

system/modules/HTMLHelper/models/HTMLHelper.cfc

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -205,21 +205,16 @@ component
205205
buffer = buffer
206206
);
207207

208-
try {
209-
// Prepare content output
210-
if ( len( arguments.content ) ) {
211-
// Value Encoding
212-
if ( variables.settings.encodeValues ) {
213-
arguments.content = encodeForHTML( arguments.content );
214-
}
215-
// Output tag + content
216-
buffer.append( ">#arguments.content#</#arguments.tag#>" );
217-
} else {
218-
buffer.append( "></#arguments.tag#>" );
208+
// Prepare content output
209+
if ( len( arguments.content ) ) {
210+
// Value Encoding
211+
if ( variables.settings.encodeValues ) {
212+
arguments.content = encodeForHTML( arguments.content );
219213
}
220-
} catch ( any e ) {
221-
writeDump( var = arguments );
222-
rethrow;
214+
// Output tag + content
215+
buffer.append( ">#arguments.content#</#arguments.tag#>" );
216+
} else {
217+
buffer.append( "></#arguments.tag#>" );
223218
}
224219

225220
// Return HTML

system/testing/BaseInterceptorTest.cfc

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ component extends="coldbox.system.testing.BaseTestCase" {
1313
*/
1414
function setup(){
1515
var md = getMetadata( this );
16+
var annotations = md.keyExists( "annotations" ) ? md.annotations : md;
1617
var mockBox = getMockBox();
1718
var applicationHelper = [];
1819

@@ -22,41 +23,28 @@ component extends="coldbox.system.testing.BaseTestCase" {
2223
}
2324

2425
// Check for interceptor else throw exception
25-
if (
26-
NOT structKeyExists( md, "interceptor" ) && NOT (
27-
structKeyExists( md, "annotations" ) && structKeyExists( md.annotations, "interceptor" )
28-
)
29-
) {
26+
if ( !annotations.keyExists( "interceptor" ) ) {
3027
throw(
31-
"interceptor annotation not found on component tag",
32-
"Please declare a 'interceptor=path' annotation",
33-
"BaseInterceptorTest.InvalidStateException"
28+
message : "interceptor annotation not found on component tag",
29+
detail : "Please declare a 'interceptor=path' annotation",
30+
type: "BaseInterceptorTest.InvalidStateException"
3431
);
3532
}
33+
3634
// Check for application helper
37-
if (
38-
structKeyExists( md, "applicationHelper" ) || (
39-
structKeyExists( md, "annotations" ) && structKeyExists( md.annotations, "applicationHelper" )
40-
)
41-
) {
35+
if ( annotations.keyExists( "applicationHelper" ) ) {
4236
// inflate it, since it can't be an array in metadata
43-
applicationHelper = listToArray(
44-
structKeyExists( md, "annotations" ) ? md.annotations.applicationHelper : md.applicationHelper
45-
);
37+
applicationHelper = listToArray( annotations.applicationHelper );
4638
}
4739
// Check if user setup interceptor properties on scope
4840
param variables.configProperties = {};
4941

5042
// Create interceptor with Mocking capabilities
51-
variables.interceptor = mockBox.createMock(
52-
structKeyExists( md, "annotations" ) ? md.annotations.interceptor : md.interceptor
53-
);
43+
variables.interceptor = mockBox.createMock( annotations.interceptor );
5444

5545
// Create Mock Objects
5646
variables.mockController = mockBox.createMock( "coldbox.system.testing.mock.web.MockController" );
57-
variables.mockInterceptorService = mockbox.createEmptyMock(
58-
"coldbox.system.web.services.InterceptorService"
59-
);
47+
variables.mockInterceptorService = mockBox.createEmptyMock( "coldbox.system.web.services.InterceptorService" );
6048
variables.mockRequestContext = getMockRequestContext();
6149
variables.mockRequestService = mockBox
6250
.createEmptyMock( "coldbox.system.web.services.RequestService" )

system/testing/BaseModelTest.cfc

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ component extends="coldbox.system.testing.BaseTestCase" {
1313
*/
1414
function setup(){
1515
var md = getMetadata( this );
16+
var annotations = md.keyExists( "annotations" ) ? md.annotations : md;
1617
var mockBox = getMockBox();
1718

1819
// Load ColdBox?
@@ -21,15 +22,9 @@ component extends="coldbox.system.testing.BaseTestCase" {
2122
}
2223

2324
// Check for model path annotation, and use it if declared.
24-
if (
25-
structKeyExists( md, "model" ) || (
26-
structKeyExists( md, "annotations" ) && structKeyExists( md.annotations, "model" )
27-
)
28-
) {
29-
// Create model with Mocking capabilities
30-
variables.model = mockBox.createMock(
31-
structKeyExists( md, "annotations" ) ? md.annotations.model : md.model
32-
);
25+
// Create model with Mocking capabilities
26+
if ( annotations.keyExists( "model" ) ) {
27+
variables.model = mockBox.createMock( annotations.model );
3328
}
3429

3530
// Create Mock Objects

system/testing/BaseTestCase.cfc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ component extends="testbox.system.compat.framework.TestCase" accessors="true" {
234234
var rcProps = structNew();
235235

236236
if ( arguments.clearMethods ) {
237-
if ( structKeyExists( arguments, "decorator" ) ) {
237+
if ( !isNull( arguments.decorator ) ) {
238238
return getMockBox().createEmptyMock( arguments.decorator );
239239
}
240240
return getMockBox().createEmptyMock( "coldbox.system.web.context.RequestContext" );
@@ -256,7 +256,7 @@ component extends="testbox.system.compat.framework.TestCase" accessors="true" {
256256
mockRC.init( properties = rcProps, controller = mockController );
257257

258258
// return decorator context
259-
if ( structKeyExists( arguments, "decorator" ) && !isNull( arguments.decorator ) ) {
259+
if ( !isNull( arguments.decorator ) ) {
260260
return getMockBox().createMock( arguments.decorator ).init( mockRC, mockController );
261261
}
262262

system/web/services/InterceptorService.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ component extends="coldbox.system.web.services.BaseService" accessors="true" {
674674
if (
675675
arguments.metadata.keyExists( "extends" )
676676
&&
677-
!structIsEmpty( arguments.metadata.extends )
677+
!arguments.metadata.extends.isEmpty()
678678
&&
679679
arguments.metadata.extends.name neq "coldbox.system.EventHandler"
680680
) {

0 commit comments

Comments
 (0)