17 private $terr = array();
45 private $transitionModelProperties = array(
56 private $transitionProperties = array(
67 $this->className = $className;
68 $this->familyName = $famName;
75 private function addError($code, $msg)
78 $msg = sprintf(
"{%s} %s", $code, $msg);
79 if (!in_array($msg, $this->terr)) {
89 private function addCodeError($code,
$args = null)
95 $nargs = func_num_args();
96 for ($ip = 1; $ip < $nargs; $ip++) {
97 $tArgs[] = func_get_arg($ip);
100 $msg = call_user_func_array(
"ErrorCode::getError", $tArgs);
101 if (!in_array($msg, $this->terr)) {
102 $this->terr[] = $msg;
109 return implode(
"\n", $this->terr);
149 $activities = $this->wdoc->stateactivity;
150 if (!is_array($activities)) {
152 $this->addCodeError(
'WFL0051', $this->className);
154 $states = $this->wdoc->getStates();
156 foreach ($activities as $state => $label) {
157 if (!in_array($state, $states)) {
158 $this->addCodeError(
'WFL0052', $state, $label, $this->className);
167 $cycle = $this->wdoc->cycle;
168 if (!is_array($cycle)) {
170 $this->addCodeError(
'WFL0200', $this->className);
172 foreach ($cycle as $k => $state) {
173 if (!is_array($state)) {
174 $this->addCodeError(
'WFL0203', $k, $this->className, gettype($state));
177 $props = array_keys($state);
178 $diff = array_diff($props, $this->transitionProperties);
179 if (count($diff) > 0) {
181 $this->addCodeError(
'WFL0201', implode(
',', $diff) , $k, $this->className, implode(
',', $this->transitionProperties));
183 if (!empty($state[
"e1"])) $this->checkTransitionStateKey($state[
"e1"]);
184 if (!empty($state[
"e2"])) $this->checkTransitionStateKey($state[
"e2"]);
185 if (!empty($state[
"t"])) {
187 $this->addCodeError(
'WFL0202', $k, $this->className);
196 $transitions = $this->wdoc->transitions;
197 if (!is_array($transitions)) {
198 $this->addCodeError(
'WFL0100', $this->className);
200 $columnNumber = count($transitions) * self::numberAttributeTransition + count($this->wdoc->getStates()) * self::numberAttributeState + count($this->wdoc->fields) + count($this->wdoc->sup_fields);
202 if ($columnNumber > self::maxSqlColumn) {
203 $this->addCodeError(
'WFL0102', $this->className, $columnNumber, self::maxSqlColumn);
206 foreach ($transitions as $tkey => $transition) {
207 if (!is_array($transition)) {
208 $this->addCodeError(
'WFL0110', $tkey, $index, $this->className, gettype($transition));
211 $this->checkTransitionStateKey($tkey);
213 $props = array_keys($transition);
214 $diff = array_diff($props, $this->transitionModelProperties);
215 if (count($diff) > 0) {
216 $this->addCodeError(
'WFL0101', implode(
',', $diff) , $tkey, $this->className, implode(
',', $this->transitionModelProperties));
219 if (isset($transition[
"ask"]) && (!is_array($transition[
"ask"]))) {
220 $this->addCodeError(
'WFL0103', $tkey, $this->className);
223 if (!empty($transition[
"m0"])) {
224 if (!method_exists($this->wdoc, $transition[
"m0"])) {
226 $this->addCodeError(
'WFL0108', $transition[
"m0"], $tkey, $this->className);
229 if (!empty($transition[
"m1"])) {
230 if (!method_exists($this->wdoc, $transition[
"m1"])) {
232 $this->addCodeError(
'WFL0105', $transition[
"m1"], $tkey, $this->className);
235 if (!empty($transition[
"m2"])) {
236 if (!method_exists($this->wdoc, $transition[
"m2"])) {
238 $this->addCodeError(
'WFL0106', $transition[
"m2"], $tkey, $this->className);
241 if (!empty($transition[
"m3"])) {
242 if (!method_exists($this->wdoc, $transition[
"m3"])) {
244 $this->addCodeError(
'WFL0109', $transition[
"m3"], $tkey, $this->className);
247 if (in_array(
"nr", $props)) {
248 if (!is_bool($transition[
"nr"])) {
249 $this->addCodeError(
'WFL0107', $tkey, $this->className);
259 $transitions = $this->wdoc->transitions;
260 if (!is_array($transitions)) {
261 $this->addCodeError(
'WFL0100', $this->className);
264 foreach ($transitions as $tkey => $transition) {
265 $this->checkTransitionStateKey($tkey);
266 $askes = isset($transition[
"ask"]) ? $transition[
"ask"] : null;
268 if (!is_array($askes)) {
269 $this->addCodeError(
'WFL0103', $tkey, $this->className);
272 $wi =
createTmpDoc($this->wdoc->dbaccess, $this->familyName);
273 $aids = array_keys($wi->getAttributes());
274 foreach ($askes as $aid) {
275 if (!in_array(strtolower($aid) , $aids)) {
276 $this->addCodeError(
'WFL0104', $aid, $this->className);
285 private function checkTransitionStateKey($key)
287 $limit = 49 - strlen($this->wdoc->attrPrefix);
288 if (!preg_match(
"/^[a-zA-Z_][a-zA-Z0-9_:]{0,$limit}$/", $key)) {
289 $this->addCodeError(
'WFL0050', $key, $this->className, $limit + 1);
298 $this->addCodeError(
'WFL0003', implode(
"\n", $output));
301 if (!class_exists($this->className)) {
302 $this->addCodeError(
'WFL0004', $this->className);
304 $class = $this->className;
305 $this->wdoc =
new $class();
307 if (!is_a($this->wdoc,
"WDoc")) {
308 $this->addCodeError(
'WFL0006', $this->className);
316 if (!$this->wdoc->attrPrefix) {
317 $this->addCodeError(
'WFL0007', $this->className);
318 } elseif (!preg_match(
'/^[a-zA-Z_][a-zA-Z0-9_]{0,14}$/', $this->wdoc->attrPrefix)) {
319 $this->addCodeError(
'WFL0008', $this->className);
325 if (empty($this->className)) {
326 $this->addCodeError(
'WFL0001');
327 } elseif (!self::checkPhpClass($this->className)) {
328 $this->addCodeError(
'WFL0002', $this->className);
337 if (!file_exists($fileName)) {
338 $this->addCodeError(
'WFL0005', $fileName, $this->className);
344 if (preg_match(
'/^[a-zA-Z_][a-zA-Z0-9_\\\\]+$/', $name)) {
355 if ($classFile === null) {
361 $classFile = sprintf(
"FDL/Class.%s.php", $this->className);
if(substr($wsh, 0, 1)!= '/') $args
const numberAttributeTransition
static instance($pTmpPath, $pTmpFileName= 'directoriesautoloader.cache.php')
static phpLintFile($fileName, &$output)
const numberAttributeState
__construct($className, $famName)
Check worflow definition when importing definition.
createTmpDoc($dbaccess, $fromid, $defaultvalue=true)
static checkPhpClass($name)