GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

WorkflowActionInstance   A
last analyzed

Complexity

Total Complexity 35

Size/Duplication

Total Lines 263
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 35
lcom 1
cbo 6
dl 0
loc 263
rs 9.6
c 0
b 0
f 0

18 Methods

Rating   Name   Duplication   Size   Complexity  
A fieldLabels() 0 11 1
A updateWorkflowFields() 0 19 3
A updateFrontendWorkflowFields() 0 12 2
A getFrontEndDataObject() 0 13 2
A updateFrontEndWorkflowActions() 0 8 2
A getRequiredFields() 0 11 2
A setFrontendFormRequirements() 0 8 2
A doFrontEndAction() 0 13 3
A getTitle() 0 4 1
A getValidTransitions() 0 19 4
A actionStart() 0 4 1
A actionComplete() 0 6 1
A canEditTarget() 0 16 5
A canViewTarget() 0 4 1
A canPublishTarget() 0 8 2
A canView() 0 4 1
A canEdit() 0 4 1
A canDelete() 0 4 1
1
<?php
2
3
namespace Symbiote\AdvancedWorkflow\DataObjects;
4
5
use SilverStripe\Control\HTTPRequest;
6
use SilverStripe\Forms\Form;
7
use SilverStripe\Forms\ReadonlyField;
8
use SilverStripe\Forms\TextareaField;
9
use SilverStripe\ORM\ArrayList;
10
use SilverStripe\ORM\DataObject;
11
use SilverStripe\ORM\FieldType\DBField;
12
use SilverStripe\Security\Member;
13
14
/**
15
 * A workflow action attached to a {@link WorkflowInstance} that has been run,
16
 * and is either currently running, or has finished.
17
 *
18
 * Each step of the workflow has one of these created for it - it refers back
19
 * to the original action definition, but is unique for each step of the
20
 * workflow to ensure re-entrant behaviour.
21
 *
22
 * @license BSD License (http://silverstripe.org/bsd-license/)
23
 * @package advancedworkflow
24
 */
25
class WorkflowActionInstance extends DataObject
26
{
27
    private static $db = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
28
        'Comment'  => 'Text',
29
        'Finished' => 'Boolean'
30
    );
31
32
    private static $has_one = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
33
        'Workflow'   => WorkflowInstance::class,
34
        'BaseAction' => WorkflowAction::class,
35
        'Member'     => Member::class,
36
    );
37
38
    private static $summary_fields = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
39
        'BaseAction.Title',
40
        'Comment',
41
        'Created',
42
        'Member.Name',
43
    );
44
45
    private static $table_name = 'WorkflowActionInstance';
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
46
47
    public function fieldLabels($includerelations = true)
48
    {
49
        $labels = parent::fieldLabels($includerelations);
50
        $labels['BaseAction.Title'] = _t('WorkflowActionInstance.Title', 'Title');
51
        $labels['Comment'] = _t('WorkflowAction.CommentLabel', 'Comment');
52
        $labels['Member.Name'] = _t('WorkflowAction.Author', 'Author');
53
        $labels['Finished'] = _t('WorkflowAction.FinishedLabel', 'Finished');
54
        $labels['BaseAction.Title'] = _t('WorkflowAction.TITLE', 'Title');
55
56
        return $labels;
57
    }
58
59
    /**
60
     * Gets fields for when this is part of an active workflow
61
     */
62
    public function updateWorkflowFields($fields)
63
    {
64
        $fieldDiff = $this->Workflow()->getTargetDiff();
0 ignored issues
show
Bug introduced by
The method Workflow() does not exist on Symbiote\AdvancedWorkflo...\WorkflowActionInstance. Did you maybe mean updateWorkflowFields()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
65
66
        foreach ($fieldDiff as $field) {
67
            $display = ReadonlyField::create(
68
                'workflow-' . $field->Name,
69
                $field->Title,
70
                DBField::create_field('HTMLText', $field->Diff)
71
            )
72
                ->addExtraClass('workflow-field-diff')
73
                ->setTemplate(__CLASS__ . '/ReadonlyField');
74
            $fields->push($display);
75
        }
76
77
        if ($this->BaseAction()->AllowCommenting) {
0 ignored issues
show
Documentation Bug introduced by
The method BaseAction does not exist on object<Symbiote\Advanced...WorkflowActionInstance>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
78
            $fields->push(new TextareaField('Comment', _t('WorkflowAction.COMMENT', 'Comment')));
79
        }
80
    }
81
82
    public function updateFrontendWorkflowFields($fields)
83
    {
84
        if ($this->BaseAction()->AllowCommenting) {
0 ignored issues
show
Documentation Bug introduced by
The method BaseAction does not exist on object<Symbiote\Advanced...WorkflowActionInstance>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
85
            $fields->push(new TextareaField(
86
                'WorkflowActionInstanceComment',
87
                _t('WorkflowAction.FRONTENDCOMMENT', 'Comment')
88
            ));
89
        }
90
91
        $ba = $this->BaseAction();
0 ignored issues
show
Documentation Bug introduced by
The method BaseAction does not exist on object<Symbiote\Advanced...WorkflowActionInstance>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
92
        $fields = $ba->updateFrontendWorkflowFields($fields, $this->Workflow());
0 ignored issues
show
Bug introduced by
The method Workflow() does not exist on Symbiote\AdvancedWorkflo...\WorkflowActionInstance. Did you maybe mean updateWorkflowFields()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
Unused Code introduced by
$fields is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
93
    }
94
95
    /**
96
     * Gets Front-End DataObject
97
     *
98
     * Use the DataObject as defined in the WorkflowAction, otherwise fall back to the
99
     * context object.
100
     *
101
     * Useful for situations where front end workflow deals with multiple data objects
102
     *
103
     * @return DataObject
104
     */
105
    public function getFrontEndDataObject()
106
    {
107
        $obj = null;
0 ignored issues
show
Unused Code introduced by
$obj is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
108
        $ba = $this->BaseAction();
0 ignored issues
show
Documentation Bug introduced by
The method BaseAction does not exist on object<Symbiote\Advanced...WorkflowActionInstance>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
109
110
        if ($ba->hasMethod('getFrontEndDataObject')) {
111
            $obj = $ba->getFrontEndDataObject();
112
        } else {
113
            $obj = $this->Workflow()->getTarget();
0 ignored issues
show
Bug introduced by
The method Workflow() does not exist on Symbiote\AdvancedWorkflo...\WorkflowActionInstance. Did you maybe mean updateWorkflowFields()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
114
        }
115
116
        return $obj;
117
    }
118
119
    public function updateFrontEndWorkflowActions($actions)
120
    {
121
        $ba = $this->BaseAction();
0 ignored issues
show
Documentation Bug introduced by
The method BaseAction does not exist on object<Symbiote\Advanced...WorkflowActionInstance>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
122
123
        if ($ba->hasMethod('updateFrontEndWorkflowActions')) {
124
            $ba->updateFrontEndWorkflowActions($actions);
125
        }
126
    }
127
128
    public function getRequiredFields()
129
    {
130
        $validator = null;
131
        $ba = $this->BaseAction();
0 ignored issues
show
Documentation Bug introduced by
The method BaseAction does not exist on object<Symbiote\Advanced...WorkflowActionInstance>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
132
133
        if ($ba->hasMethod('getRequiredFields')) {
134
            $validator = $ba->getRequiredFields();
135
        }
136
137
        return $validator;
138
    }
139
140
    public function setFrontendFormRequirements()
141
    {
142
        $ba = $this->BaseAction();
0 ignored issues
show
Documentation Bug introduced by
The method BaseAction does not exist on object<Symbiote\Advanced...WorkflowActionInstance>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
143
144
        if ($ba->hasMethod('setFrontendFormRequirements')) {
145
            $ba->setFrontendFormRequirements();
146
        }
147
    }
148
149
    public function doFrontEndAction(array $data, Form $form, HTTPRequest $request)
150
    {
151
        //Save Front End Workflow notes, then hand over to Workflow Action
152
        if (isset($data["WorkflowActionInstanceComment"])) {
153
            $this->Comment = $data["WorkflowActionInstanceComment"];
0 ignored issues
show
Documentation introduced by
The property Comment does not exist on object<Symbiote\Advanced...WorkflowActionInstance>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
154
            $this->write();
155
        }
156
157
        $ba = $this->BaseAction();
0 ignored issues
show
Documentation Bug introduced by
The method BaseAction does not exist on object<Symbiote\Advanced...WorkflowActionInstance>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
158
        if ($ba->hasMethod('doFrontEndAction')) {
159
            $ba->doFrontEndAction($data, $form, $request);
160
        }
161
    }
162
163
164
    /**
165
     * Gets the title of this active action instance
166
     *
167
     * @return string
168
     */
169
    public function getTitle()
170
    {
171
        return $this->BaseAction()->Title;
0 ignored issues
show
Documentation Bug introduced by
The method BaseAction does not exist on object<Symbiote\Advanced...WorkflowActionInstance>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
172
    }
173
174
    /**
175
     * Returns all the valid transitions that lead out from this action.
176
     *
177
     * This is called if this action has finished, and the workflow engine wants
178
     * to run the next action.
179
     *
180
     * If this action returns only one valid transition it will be immediately
181
     * followed; otherwise the user will decide which transition to follow.
182
     *
183
     * @return ArrayList
184
     */
185
    public function getValidTransitions()
186
    {
187
        $available = $this->BaseAction()->Transitions();
0 ignored issues
show
Documentation Bug introduced by
The method BaseAction does not exist on object<Symbiote\Advanced...WorkflowActionInstance>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
188
        $valid     = new ArrayList();
189
190
        // iterate through the transitions and see if they're valid for the current state of the item being
191
        // workflowed
192
        if ($available) {
193
            foreach ($available as $transition) {
194
                if ($transition->isValid($this->Workflow())) {
0 ignored issues
show
Bug introduced by
The method Workflow() does not exist on Symbiote\AdvancedWorkflo...\WorkflowActionInstance. Did you maybe mean updateWorkflowFields()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
195
                    $valid->push($transition);
196
                }
197
            }
198
        }
199
200
        $this->extend('updateValidTransitions', $valid);
201
202
        return $valid;
203
    }
204
205
    /**
206
     * Called when this instance is started within the workflow
207
     */
208
    public function actionStart(WorkflowTransition $transition)
209
    {
210
        $this->extend('onActionStart', $transition);
211
    }
212
213
    /**
214
     * Called when this action has been completed within the workflow
215
     */
216
    public function actionComplete(WorkflowTransition $transition)
217
    {
218
        $this->MemberID = Member::currentUserID();
0 ignored issues
show
Documentation introduced by
The property MemberID does not exist on object<Symbiote\Advanced...WorkflowActionInstance>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Deprecated Code introduced by
The method SilverStripe\Security\Member::currentUserID() has been deprecated with message: 5.0.0 use Security::getCurrentUser()

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
219
        $this->write();
220
        $this->extend('onActionComplete', $transition);
221
    }
222
223
224
    /**
225
     * Can documents in the current workflow state be edited?
226
     *
227
     * @param  DataObject $target
228
     * @return bool
229
     */
230
    public function canEditTarget(DataObject $target)
231
    {
232
        $absolute = $this->BaseAction()->canEditTarget($target);
0 ignored issues
show
Documentation Bug introduced by
The method BaseAction does not exist on object<Symbiote\Advanced...WorkflowActionInstance>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
233
        if (!is_null($absolute)) {
234
            return $absolute;
235
        }
236
        switch ($this->BaseAction()->AllowEditing) {
0 ignored issues
show
Documentation Bug introduced by
The method BaseAction does not exist on object<Symbiote\Advanced...WorkflowActionInstance>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
237
            case 'By Assignees':
238
                return $this->Workflow()->canEdit();
0 ignored issues
show
Bug introduced by
The method Workflow() does not exist on Symbiote\AdvancedWorkflo...\WorkflowActionInstance. Did you maybe mean updateWorkflowFields()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
239
            case 'No':
240
                return false;
241
            case 'Content Settings':
242
            default:
243
                return null;
244
        }
245
    }
246
247
    /**
248
     * Does this action restrict viewing of the document?
249
     *
250
     * @param  DataObject $target
251
     * @return bool
252
     */
253
    public function canViewTarget(DataObject $target)
254
    {
255
        return $this->BaseAction()->canViewTarget($target);
0 ignored issues
show
Documentation Bug introduced by
The method BaseAction does not exist on object<Symbiote\Advanced...WorkflowActionInstance>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
256
    }
257
258
    /**
259
     * Does this action restrict the publishing of a document?
260
     *
261
     * @param  DataObject $target
262
     * @return bool
263
     */
264
    public function canPublishTarget(DataObject $target)
265
    {
266
        $absolute = $this->BaseAction()->canPublishTarget($target);
0 ignored issues
show
Documentation Bug introduced by
The method BaseAction does not exist on object<Symbiote\Advanced...WorkflowActionInstance>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
267
        if (!is_null($absolute)) {
268
            return $absolute;
269
        }
270
        return false;
271
    }
272
273
    public function canView($member = null)
274
    {
275
        return $this->Workflow()->canView($member);
0 ignored issues
show
Bug introduced by
The method Workflow() does not exist on Symbiote\AdvancedWorkflo...\WorkflowActionInstance. Did you maybe mean updateWorkflowFields()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
276
    }
277
278
    public function canEdit($member = null)
279
    {
280
        return $this->Workflow()->canEdit($member);
0 ignored issues
show
Bug introduced by
The method Workflow() does not exist on Symbiote\AdvancedWorkflo...\WorkflowActionInstance. Did you maybe mean updateWorkflowFields()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
281
    }
282
283
    public function canDelete($member = null)
284
    {
285
        return $this->Workflow()->canDelete($member);
0 ignored issues
show
Bug introduced by
The method Workflow() does not exist on Symbiote\AdvancedWorkflo...\WorkflowActionInstance. Did you maybe mean updateWorkflowFields()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
286
    }
287
}
288