Skip to content

fixed dynamically created properties#18

Closed
opitz wants to merge 3 commits intomainfrom
fixed-dynamic-properties
Closed

fixed dynamically created properties#18
opitz wants to merge 3 commits intomainfrom
fixed-dynamic-properties

Conversation

@opitz
Copy link
Contributor

@opitz opitz commented Jan 28, 2026

Dynamically created properties are deprecated.

@opitz opitz requested a review from aydevworks January 28, 2026 11:33
@opitz opitz self-assigned this Jan 28, 2026
Comment on lines +47 to +66
/** @var stdClass course1 */
private stdClass $course2;

/** @var stdClass course1 */
private stdClass $course3;

/** @var stdClass course1 */
private stdClass $course4;

/** @var stdClass course1 */
private stdClass $courseshouldbefrozen;

/** @var stdClass course1 */
private stdClass $coursewithoutacademicyear;

/** @var stdClass course1 */
private stdClass $coursewithfutureenddate;

/** @var stdClass course1 */
private stdClass $coursewithoutenddate;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc blocks content not matching the properties names.

Comment on lines 97 to 103
// Put 4 years in associative array.
$this->years = [
'previous_year' => date('Y', strtotime('-2 years')),
'last_year' => date('Y', strtotime('-1 years')),
'current_year' => date('Y'),
'next_year' => date('Y', strtotime('+1 years')),
];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The phpunit test error could be fixed by the following code:

        // Get the academic year start date config (default is 08-01).
        $academicyearstartdate = get_config('block_lifecycle', 'academic_year_start_date') ?: '08-01';
        // Determine current academic year based on whether we've passed the start date.
        $currentyear = date('Y');
        $academicyearstart = strtotime($currentyear . '-' . $academicyearstartdate);
        if (time() < $academicyearstart) {
            // We haven't reached the academic year start date yet, so current academic year is last year.
            $currentacademicyear = $currentyear - 1;
        } else {
            $currentacademicyear = $currentyear;
        }

        // Put 4 years in associative array.
        $this->years = [
            'previous_year' => (string)($currentacademicyear - 2),
            'last_year' => (string)($currentacademicyear - 1),
            'current_year' => (string)$currentacademicyear,
            'next_year' => (string)($currentacademicyear + 1),
        ];

@andrewhancox
Copy link
Contributor

Apologies - I didn't see this PR until I pushed mine up which (among other things) makes this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants