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.
Completed
Push — master ( 01d78b...5686eb )
by
unknown
01:21
created

EmailReminder_NotificationSchedule::validate()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4888
c 0
b 0
f 0
cc 5
nc 5
nop 0
1
<?php
2
3
class EmailReminder_NotificationSchedule extends DataObject
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
6
    /**
7
     * @var int
8
     */
9
    private static $grace_days = 3;
0 ignored issues
show
Unused Code introduced by
The property $grace_days is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
10
11
    /**
12
     * @var string
13
     */
14
    private static $default_data_object = 'Member';
0 ignored issues
show
Unused Code introduced by
The property $default_data_object is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
15
16
    /**
17
     * @var string
18
     */
19
    private static $default_date_field = '';
0 ignored issues
show
Unused Code introduced by
The property $default_date_field is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
20
21
    /**
22
     * @var string
23
     */
24
    private static $default_email_field = '';
0 ignored issues
show
Unused Code introduced by
The property $default_email_field is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
25
26
    /**
27
     * @var string
28
     */
29
    private static $replaceable_record_fields = array('FirstName', 'Surname', 'Email');
0 ignored issues
show
Unused Code introduced by
The property $replaceable_record_fields is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
30
31
    /**
32
     * @var string
33
     */
34
    private static $include_method = 'EmailReminderInclude';
0 ignored issues
show
Unused Code introduced by
The property $include_method is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
35
36
    /**
37
     * @var string
38
     */
39
    private static $exclude_method = 'EmailReminderExclude';
0 ignored issues
show
Unused Code introduced by
The property $exclude_method is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
40
41
    /**
42
     * @var string
43
     */
44
    private static $mail_out_class = 'EmailReminder_DailyMailOut';
0 ignored issues
show
Unused Code introduced by
The property $mail_out_class is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
45
46
    private static $singular_name = 'Email Reminder Schedule';
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...
47
    public function i18n_singular_name()
48
    {
49
        return self::$singular_name;
50
    }
51
52
    private static $plural_name = 'Email Reminder Schedules';
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...
53
    public function i18n_plural_name()
54
    {
55
        return self::$plural_name;
56
    }
57
58
    private static $db = array(
0 ignored issues
show
Unused Code introduced by
The property $db is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
59
        'DataObject' => 'Varchar(100)',
60
        'EmailField' => 'Varchar(100)',
61
        'DateField' => 'Varchar(100)',
62
        'Days' => 'Int',
63
        'RepeatDays' => 'Int',
64
        'BeforeAfter' => "Enum('before,after,immediately','before')",
65
        'EmailFrom' => 'Varchar(100)',
66
        'EmailSubject' => 'Varchar(100)',
67
        'Content' => 'HTMLText',
68
        'Disable' => 'Boolean',
69
        'SendTestTo' => 'Text'
70
    );
71
72
73
    private static $has_many = array(
0 ignored issues
show
Unused Code introduced by
The property $has_many is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
74
        'EmailsSent' => 'EmailReminder_EmailRecord'
75
    );
76
77
    private static $summary_fields = array(
0 ignored issues
show
Unused Code introduced by
The property $summary_fields is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
78
        'EmailSubject',
79
        'BeforeAfter',
80
        'Days'
81
    );
82
83
    private static $field_labels = 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...
Unused Code introduced by
The property $field_labels is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
84
        'DataObject' => 'Class/Table',
85
        'Days' => 'Days Before/After Date',
86
        'RepeatDays' => 'Repeat cycle days',
87
        'BeforeAfter' => 'When to send'
88
    );
89
90
    public function populateDefaults()
91
    {
92
        parent::populateDefaults();
93
        $this->DataObject = $this->Config()->get('default_data_object');
0 ignored issues
show
Documentation introduced by
The property DataObject does not exist on object<EmailReminder_NotificationSchedule>. 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...
94
        $this->EmailField = $this->Config()->get('default_email_field');
0 ignored issues
show
Documentation introduced by
The property EmailField does not exist on object<EmailReminder_NotificationSchedule>. 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...
95
        $this->DateField = $this->Config()->get('default_date_field');
0 ignored issues
show
Documentation introduced by
The property DateField does not exist on object<EmailReminder_NotificationSchedule>. 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...
96
        $this->Days = 7;
0 ignored issues
show
Documentation introduced by
The property Days does not exist on object<EmailReminder_NotificationSchedule>. 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...
97
        $this->RepeatDays = 300;
0 ignored issues
show
Documentation introduced by
The property RepeatDays does not exist on object<EmailReminder_NotificationSchedule>. 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...
98
        $this->BeforeAfter = 'before';
0 ignored issues
show
Documentation introduced by
The property BeforeAfter does not exist on object<EmailReminder_NotificationSchedule>. 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...
99
        $this->EmailFrom = Config::inst()->get('Email', 'admin_email');
0 ignored issues
show
Documentation introduced by
The property EmailFrom does not exist on object<EmailReminder_NotificationSchedule>. 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...
100
        $this->EmailSubject = 'Your memberships expires in [days] days';
0 ignored issues
show
Documentation introduced by
The property EmailSubject does not exist on object<EmailReminder_NotificationSchedule>. 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...
101
    }
102
103
    public function getCMSFields()
104
    {
105
        $fields = parent::getCMSFields();
106
107
        $emailsSentField = $fields->dataFieldByName('EmailsSent');
108
        $fields->removeFieldFromTab('Root', 'EmailsSent');
109
110
        $fields->addFieldToTab(
111
            'Root.Main',
112
            CheckboxField::create('Disable')
113
        );
114
        $fields->addFieldToTab(
115
            'Root.Main',
116
            $dataObjecField = DropdownField::create(
117
                'DataObject',
118
                'Table/Class Name',
119
                $this->dataObjectOptions()
120
            )
121
            ->setRightTitle('Type a valid table/class name')
122
        );
123
        if ($this->Config()->get('default_data_object')) {
124
            $fields->replaceField('DataObject', $dataObjecField->performReadonlyTransformation());
125
        }
126
127
128
129
        $fields->addFieldToTab(
130
            'Root.Main',
131
            $emailFieldField = DropdownField::create(
132
                'EmailField',
133
                'Email Field',
134
                $this->emailFieldOptions()
135
            )
136
            ->setRightTitle('Select the field that will contain a valid email address')
137
            ->setEmptyString('[ Please select ]')
138
        );
139
        if ($this->Config()->get('default_email_field')) {
140
            $fields->replaceField('EmailField', $emailFieldField->performReadonlyTransformation());
141
        }
142
143
        $fields->addFieldToTab(
144
            'Root.Main',
145
            $dateFieldField = DropdownField::create(
146
                'DateField',
147
                'Date Field',
148
                $this->dateFieldOptions()
149
            )
150
            ->setRightTitle('Select a valid Date field to calculate when reminders should be sent')
151
            ->setEmptyString('[ Please select ]')
152
        );
153
        if ($this->Config()->get('default_date_field')) {
154
            $fields->replaceField('DateField', $dateFieldField->performReadonlyTransformation());
155
        }
156
157
        $fields->removeFieldsFromTab(
158
            'Root.Main',
159
            array('Days', 'BeforeAfter', 'RepeatDays')
160
        );
161
        $fields->addFieldsToTab(
162
            'Root.Main',
163
            array(
164
                DropdownField::create('BeforeAfter', 'Before / After Expiration', array('before' => 'before', 'after' => 'after', 'immediately' => 'immediately'))
165
                    ->setRightTitle('Are the days listed above before or after the actual expiration date.'),
166
                NumericField::create('Days', 'Days')
167
                    ->setRightTitle('How many days in advance (before) or in arrears (after) of the expiration date should this email be sent? </br>This field is ignored if set to send immediately.'),
168
                NumericField::create('RepeatDays', 'Repeat Cycle Days')
169
                    ->setRightTitle(
170
                        '
171
                        Number of days after which the same reminder can be sent to the same email address.
172
                        <br />We allow an e-mail to be sent to one specific email address for one specific reminder only once.
173
                        <br />In this field you can indicate for how long we will apply this rule.'
174
                )
175
            )
176
        );
177
178
        if($this->BeforeAfter === 'immediately'){
0 ignored issues
show
Documentation introduced by
The property BeforeAfter does not exist on object<EmailReminder_NotificationSchedule>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
179
            $fields->removeFieldsFromTab(
180
                'Root.Main',
181
                array('Days', 'RepeatDays')
182
            );
183
        }
184
185
        $fields->addFieldsToTab(
186
            'Root.EmailContent',
187
            array(
188
                TextField::create('EmailFrom', 'Email From Address')
189
                    ->setRightTitle('The email from address, eg: "My Company &lt;[email protected]&gt;"'),
190
                $subjectField = TextField::create('EmailSubject', 'Email Subject Line')
191
                    ->setRightTitle('The subject of the email'),
192
                $contentField = HTMLEditorField::create('Content', 'Email Content')
193
                    ->SetRows(20)
194
            )
195
        );
196
        if ($obj = $this->getReplacerObject()) {
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $obj is correct as $this->getReplacerObject() (which targets EmailReminder_Notificati...le::getReplacerObject()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
197
            $html = $obj->replaceHelpList($asHTML = true);
198
            $otherFieldsThatCanBeUsed = $this->getFieldsFromDataObject(array('*'));
199
            $replaceableFields = $this->Config()->get('replaceable_record_fields');
200
            if (count($otherFieldsThatCanBeUsed)) {
201
                $html .= '<h3>You can also use the record fields (not replaced in tests):</h3><ul>';
202
                foreach ($otherFieldsThatCanBeUsed as $key => $value) {
203
                    if (in_array($key, $replaceableFields)) {
204
                        $html .= '<li><strong>$'.$key.'</strong> <span>'.$value.'</span></li>';
205
                    }
206
                }
207
            }
208
            $html .= '</ul>';
209
            $subjectField->setRightTitle('for replacement options, please see below ...');
210
            $contentField->setRightTitle($html);
211
        }
212
        $fields->addFieldsToTab(
213
            'Root.Sent',
214
            array(
215
                TextareaField::create('SendTestTo', 'Send test email to ...')
216
                    ->setRightTitle(
217
                        '
218
                        Separate emails by commas, a test email will be sent every time you save this Email Reminder, if you do not want test emails to be sent make sure this field is empty
219
                        '
220
                    )
221
                    ->SetRows(3)
222
            )
223
        );
224
        if ($emailsSentField) {
225
            $config = $emailsSentField->getConfig();
0 ignored issues
show
Bug introduced by
The method getConfig() does not exist on FormField. Did you maybe mean config()?

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...
226
            $config->removeComponentsByType('GridFieldAddExistingAutocompleter');
227
            $fields->addFieldToTab(
228
                'Root.Sent',
229
                $emailsSentField
230
            );
231
        }
232
        $records = $this->CurrentRecords();
233
        if ($records) {
234
            $fields->addFieldsToTab(
235
                'Root.Review',
236
                array(
237
                    GridField::create(
238
                        'CurrentRecords',
239
                        'Today we are sending to ...',
240
                        $records
241
                    ),
242
                    LiteralField::create(
243
                        'SampleSelectStatement',
244
                        '<h3>Here is a sample statement used to select records:</h3>
245
                        <pre>'.$this->whereStatementForDays().'</pre>'
246
                    ),
247
                    LiteralField::create(
248
                        'SampleFieldDataForRecords',
249
                        '<h3>sample of '.$this->DateField.' field values:</h3>
0 ignored issues
show
Documentation introduced by
The property DateField does not exist on object<EmailReminder_NotificationSchedule>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
250
                        <li>'.implode('</li><li>', $this->SampleFieldDataForRecords()).'</li>'
251
                    )
252
                )
253
            );
254
        }
255
        return $fields;
256
    }
257
258
    /**
259
     * @return array
0 ignored issues
show
Documentation introduced by
Should the return type not be null|array?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
260
     */
261
    protected function dataObjectOptions()
262
    {
263
        return ClassInfo::subclassesFor("DataObject");
264
    }
265
266
    /**
267
     * @return array
268
     */
269
    protected function emailFieldOptions()
270
    {
271
        return $this->getFieldsFromDataObject(array('Varchar', 'Email'));
272
    }
273
274
    /**
275
     * @return array
276
     */
277
    protected function dateFieldOptions()
278
    {
279
        return $this->getFieldsFromDataObject(array('Date'));
280
    }
281
282
283
    /**
284
     * list of database fields available
285
     * @param  array $fieldTypeMatchArray - strpos filter
286
     * @return array
287
     */
288
    protected function getFieldsFromDataObject($fieldTypeMatchArray = array())
289
    {
290
        $array = array();
291
        if ($this->hasValidDataObject()) {
292
            $object = Injector::inst()->get($this->DataObject);
0 ignored issues
show
Documentation introduced by
The property DataObject does not exist on object<EmailReminder_NotificationSchedule>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
293
            if ($object) {
294
                $allOptions = $object->stat('db');
295
                $fieldLabels = $object->fieldLabels();
296
                foreach ($allOptions as $fieldName => $fieldType) {
297
                    foreach ($fieldTypeMatchArray as $matchString) {
298
                        if ((strpos($fieldType, $matchString) !== false) || $matchString == '*') {
299
                            if (isset($fieldLabels[$fieldName])) {
300
                                $label = $fieldLabels[$fieldName];
301
                            } else {
302
                                $label = $fieldName;
303
                            }
304
                            $array[$fieldName] = $label;
305
                        }
306
                    }
307
                }
308
            }
309
        }
310
        return $array;
311
    }
312
313
314
    /**
315
     * Test if valid classname has been set
316
     * @param null
317
     * @return Boolean
318
     */
319
    public function hasValidDataObject()
320
    {
321
        return (! $this->DataObject) || ClassInfo::exists($this->DataObject) ? true : false;
0 ignored issues
show
Documentation introduced by
The property DataObject does not exist on object<EmailReminder_NotificationSchedule>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
322
    }
323
324
    /**
325
     * Test if valid fields have been set
326
     * @param null
327
     * @return Boolean
328
     */
329
    public function hasValidDataObjectFields()
330
    {
331
        if (!$this->hasValidDataObject()) {
332
            return false;
333
        }
334
        $emailFieldOptions = $this->emailFieldOptions();
335
        if (!isset($emailFieldOptions[$this->EmailField])) {
0 ignored issues
show
Documentation introduced by
The property EmailField does not exist on object<EmailReminder_NotificationSchedule>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
336
            return false;
337
        }
338
        $dateFieldOptions = $this->dateFieldOptions();
339
        if (!isset($dateFieldOptions[$this->DateField])) {
0 ignored issues
show
Documentation introduced by
The property DateField does not exist on object<EmailReminder_NotificationSchedule>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
Unused Code introduced by
This if statement, and the following return statement can be replaced with return isset($dateFieldO...ons[$this->DateField]);.
Loading history...
340
            return false;
341
        }
342
        return true;
343
    }
344
345
    /**
346
     * @return string
347
     */
348
    public function getTitle()
349
    {
350
        $niceTitle = '[' . $this->EmailSubject . '] // send ';
0 ignored issues
show
Documentation introduced by
The property EmailSubject does not exist on object<EmailReminder_NotificationSchedule>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
351
        $niceTitle .= ($this->BeforeAfter === 'immediately') ?  $this->BeforeAfter : $this->Days . ' days '.$this->BeforeAfter.' Expiration Date';
0 ignored issues
show
Documentation introduced by
The property BeforeAfter does not exist on object<EmailReminder_NotificationSchedule>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
Documentation introduced by
The property Days does not exist on object<EmailReminder_NotificationSchedule>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
352
        return ($this->hasValidDataObjectFields()) ? $niceTitle : 'uncompleted';
353
    }
354
355
    /**
356
     * @return boolean
357
     */
358
    public function hasValidFields()
359
    {
360
        if (!$this->hasValidDataObject()) {
361
            return false;
362
        }
363
        if (!$this->hasValidDataObjectFields()) {
364
            return false;
365
        }
366
        if ($this->EmailFrom && $this->EmailSubject && $this->Content) {
0 ignored issues
show
Documentation introduced by
The property EmailFrom does not exist on object<EmailReminder_NotificationSchedule>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
Documentation introduced by
The property EmailSubject does not exist on object<EmailReminder_NotificationSchedule>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
Documentation introduced by
The property Content does not exist on object<EmailReminder_NotificationSchedule>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
Unused Code introduced by
This if statement, and the following return statement can be replaced with return $this->EmailFrom ...ject && $this->Content;.
Loading history...
367
            return true;
368
        }
369
        return false;
370
    }
371
372
    /**
373
     * @return boolean
0 ignored issues
show
Documentation introduced by
Should the return type not be ValidationResult?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
374
     */
375
    public function validate()
376
    {
377
        $valid = parent::validate();
378
        if ($this->exists()) {
379
            if (! $this->hasValidDataObject()) {
380
                $valid->error('Please enter valid Tabe/Class name ("' . htmlspecialchars($this->DataObject) .'" does not exist)');
0 ignored issues
show
Documentation introduced by
The property DataObject does not exist on object<EmailReminder_NotificationSchedule>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
381
            } elseif (! $this->hasValidDataObjectFields()) {
382
                $valid->error('Please select valid fields for both Email & Date');
383
            } elseif (! $this->hasValidFields()) {
384
                $valid->error('Please fill in all fields.  Make sure not to forget the email details (from who, subject, content)');
385
            }
386
        }
387
        return $valid;
388
    }
389
390
    public function onBeforeWrite()
391
    {
392
        parent::onBeforeWrite();
393
        if ($this->RepeatDays < ($this->Days * 3)) {
0 ignored issues
show
Documentation introduced by
The property RepeatDays does not exist on object<EmailReminder_NotificationSchedule>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
Documentation introduced by
The property Days does not exist on object<EmailReminder_NotificationSchedule>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
394
            $this->RepeatDays = ($this->Days * 3);
0 ignored issues
show
Documentation introduced by
The property RepeatDays does not exist on object<EmailReminder_NotificationSchedule>. 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...
Documentation introduced by
The property Days does not exist on object<EmailReminder_NotificationSchedule>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
395
        }
396
397
        if ($this->BeforeAfter === 'immediately'){
0 ignored issues
show
Documentation introduced by
The property BeforeAfter does not exist on object<EmailReminder_NotificationSchedule>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
398
            $this->Days = 0;
0 ignored issues
show
Documentation introduced by
The property Days does not exist on object<EmailReminder_NotificationSchedule>. 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...
399
        }
400
    }
401
402
    public function onAfterWrite()
403
    {
404
        parent::onAfterWrite();
405
        if ($this->SendTestTo) {
0 ignored issues
show
Documentation introduced by
The property SendTestTo does not exist on object<EmailReminder_NotificationSchedule>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
406
            if ($mailOutObject = $this->getMailOutObject()) {
407
                $mailOutObject->setTestOnly(true);
408
                $mailOutObject->setVerbose(true);
409
                $mailOutObject->run(null);
0 ignored issues
show
Documentation introduced by
null is of type null, but the function expects a object<SS_HTTPRequest>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
410
            }
411
        }
412
    }
413
414
    /**
415
     *
416
     * @return null | EmailReminder_ReplacerClassInterface
417
     */
418
    public function getReplacerObject()
419
    {
420
        if ($mailOutObject = $this->getMailOutObject()) {
421
            return $mailOutObject->getReplacerObject();
422
        }
423
    }
424
425
    /**
426
     *
427
     * @return null | ScheduledTask
0 ignored issues
show
Documentation introduced by
Should the return type not be BuildTask|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
428
     */
429
    public function getMailOutObject()
430
    {
431
        $mailOutClass = $this->Config()->get('mail_out_class');
432
        if (class_exists($mailOutClass)) {
433
            $obj = Injector::inst()->get($mailOutClass);
434
            if ($obj instanceof BuildTask) {
435
                return $obj;
436
            } else {
437
                user_error($mailOutClass.' needs to be an instance of a Scheduled Task');
438
            }
439
        }
440
    }
441
442
    /**
443
     * @param int $limit
444
     * @return array
0 ignored issues
show
Documentation introduced by
Should the return type not be array|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
445
     */
446
    public function SampleFieldDataForRecords($limit = 200)
447
    {
448
        if ($this->hasValidFields()) {
449
            $className = $this->DataObject;
0 ignored issues
show
Documentation introduced by
The property DataObject does not exist on object<EmailReminder_NotificationSchedule>. 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...
450
            $objects = $className::get()->sort('RAND()')
451
                ->where('"'.$this->DateField.'" IS NOT NULL AND "'.$this->DateField.'" <> \'\' AND "'.$this->DateField.'" <> 0')
0 ignored issues
show
Documentation introduced by
The property DateField does not exist on object<EmailReminder_NotificationSchedule>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
452
                ->limit($limit);
453
            if ($objects->count()) {
454
                return array_unique($objects->column($this->DateField));
0 ignored issues
show
Documentation introduced by
The property DateField does not exist on object<EmailReminder_NotificationSchedule>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
455
            } else {
456
                return array();
457
            }
458
        }
459
    }
460
461
    public function CMSEditLink()
462
    {
463
        $controller = singleton("EmailReminder_ModelAdmin");
464
465
        return $controller->Link().$this->ClassName."/EditForm/field/".$this->ClassName."/item/".$this->ID."/edit";
466
    }
467
468
469
    /**
470
     * @return DataList | null
471
     */
472
    public function CurrentRecords()
473
    {
474
        if ($this->hasValidFields()) {
475
            $className = $this->DataObject;
0 ignored issues
show
Documentation introduced by
The property DataObject does not exist on object<EmailReminder_NotificationSchedule>. 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...
476
477
            // Use StartsWith to match Date and DateTime fields
478
            $records = $className::get()->where($this->whereStatementForDays());
479
            //sample record
480
            $firstRecord = $records->first();
481
            if ($firstRecord && $firstRecord->exists()) {
482
                //methods
483
                $includeMethod = $this->Config()->get('include_method');
484
                $excludeMethod = $this->Config()->get('exclude_method');
485
486
                //included method?
487
                $hasIncludeMethod = false;
488
                if ($firstRecord->hasMethod($includeMethod)) {
489
                    $includedRecords = [0 => 0];
490
                    $hasIncludeMethod = true;
491
                }
492
493
                //excluded method?
494
                $hasExcludeMethod = false;
495
                if ($firstRecord->hasMethod($excludeMethod)) {
496
                    $excludedRecords = [0 => 0];
497
                    $hasExcludeMethod = true;
498
                }
499
500
                //see who is in and out
501
                if ($hasIncludeMethod || $hasExcludeMethod) {
502
                    foreach ($records as $record) {
503
                        if ($hasIncludeMethod) {
504
                            $in = $record->$includeMethod($this, $records);
505
                            if ($in == true) {
506
                                $includedRecords[$record->ID] = $record->ID;
0 ignored issues
show
Bug introduced by
The variable $includedRecords does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
507
                            }
508
                        }
509
                        if ($hasExcludeMethod) {
510
                            $out = $record->$excludeMethod($this, $records);
511
                            if ($out == true) {
512
                                $excludedRecords[$record->ID] = $record->ID;
0 ignored issues
show
Bug introduced by
The variable $excludedRecords does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
513
                            }
514
                        }
515
                    }
516
                }
517
518
                //apply inclusions and exclusions
519
                if ($hasIncludeMethod) {
520
                    $records = $className::get()->filter(['ID' => $includedRecords]);
521
                }
522
                if ($hasExcludeMethod) {
523
                    $records = $records->exclude(['ID' => $excludedRecords]);
524
                }
525
            }
526
            return $records;
527
        }
528
    }
529
530
    /**
531
     * BeforeAfter = 'after'
532
     * Days = 3
533
     * GraceDays = 2
534
     *  -> minDays = -5 days start of day
535
     *  -> maxDays = -3 days end of day
536
     *
537
     * @return string
538
     */
539
    protected function whereStatementForDays()
540
    {
541
        if ($this->hasValidFields()) {
542
            $sign = $this->BeforeAfter == 'before' ? '+' : '-';
0 ignored issues
show
Documentation introduced by
The property BeforeAfter does not exist on object<EmailReminder_NotificationSchedule>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
543
            $graceDays = 10; //Config::inst()->get('EmailReminder_NotificationSchedule', 'grace_days');
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
544
545
            if ($sign == '+') {
546
                $minDays = $sign . ($this->Days - $graceDays) . ' days';
0 ignored issues
show
Documentation introduced by
The property Days does not exist on object<EmailReminder_NotificationSchedule>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
547
                $maxDays = $sign . $this->Days . ' days';
0 ignored issues
show
Documentation introduced by
The property Days does not exist on object<EmailReminder_NotificationSchedule>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
548
                $minDate = date('Y-m-d', strtotime($minDays)).' 00:00:00';
549
                $maxDate = date('Y-m-d', strtotime($maxDays)).' 23:59:59';
550
            } else {
551
                $minDays = $sign . ($this->Days) . ' days';
0 ignored issues
show
Documentation introduced by
The property Days does not exist on object<EmailReminder_NotificationSchedule>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
552
                $maxDays = $sign . $this->Days - $graceDays . ' days';
0 ignored issues
show
Documentation introduced by
The property Days does not exist on object<EmailReminder_NotificationSchedule>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
553
                //we purposely change these days around here ...
554
                $minDate = date('Y-m-d', strtotime($maxDays)).' 00:00:00';
555
                $maxDate = date('Y-m-d', strtotime($minDays)).' 23:59:59';
556
            }
557
558
            return '("'. $this->DateField.'" BETWEEN \''.$minDate.'\' AND \''.$maxDate.'\')';
0 ignored issues
show
Documentation introduced by
The property DateField does not exist on object<EmailReminder_NotificationSchedule>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
559
        }
560
        return '1 == 2';
561
    }
562
}
563