Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync clock #863

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

sync clock #863

wants to merge 8 commits into from

Conversation

tomasnorre
Copy link
Contributor

Resolves #845

Copy link

This PR touches files which potentially affect the outcome of the tests of an exercise. This will cause all students' solutions to affected exercises to be re-tested.

If this PR does not affect the result of the test (or, for example, adds an edge case that is not worth rerunning all tests for), please add the following to the merge-commit message which will stops student's tests from re-running. Please copy-paste to avoid typos.

[no important files changed]

For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping @exercism/maintainers-admin in a comment. Thank you!

@tomasnorre tomasnorre added x:action/sync Sync content with its latest version x:knowledge/elementary Little Exercism knowledge required x:module/practice-exercise Work on Practice Exercises x:type/content Work on content (e.g. exercises, concepts) x:size/small Small amount of work x:rep/small Small amount of reputation labels Nov 17, 2024
@tomasnorre tomasnorre marked this pull request as ready for review November 17, 2024 14:47
* fix: Ensure name_filter are local scoped

* fix test on macos
Copy link
Contributor

@mk-mxp mk-mxp left a comment

Choose a reason for hiding this comment

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

Also we should have a comment in the students stub that missing methods need to be added.

public function testOnTheHour(): void
{
$clock = new Clock(8);

$this->assertEquals('08:00', $clock->__toString());
$this->assertEquals('08:00', $clock);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is one of the magic tricks in PHP, but we currently have no concept (concept exercise) for students to learn this. So we should either explain the magic in the stub (for now) or explicitly call the method as done before:

Suggested change
$this->assertEquals('08:00', $clock);
$this->assertEquals('08:00', $clock->__toString());

or

Suggested change
$this->assertEquals('08:00', $clock);
$this->assertEquals('08:00', (string)$clock);
// plus use `implements Stringable` in the students stub
// plus a comment in the stub pointing to PHP docs on interface `Stringable`

@homersimpsons What do you think about this?

Copy link
Contributor

Choose a reason for hiding this comment

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

If we want to show magic methods with this exercise, I think I would prefer the explicit (string) cast, it has the advantages to clearly show that this method is magic.

But I do not know if we want to show those here.

I believe we could have a concept to show __toString, __set, __get which I think are rather "common". __construct is a magic method but I believe it is already being taught.

Copy link
Contributor

@mk-mxp mk-mxp left a comment

Choose a reason for hiding this comment

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

These changes are not connected to the discussion about the magic method usage.

Please add a comment to the students stub, that all missing methods need to be added by the student.

exercises/practice/clock/ClockTest.php Outdated Show resolved Hide resolved
exercises/practice/clock/ClockTest.php Outdated Show resolved Hide resolved
exercises/practice/clock/ClockTest.php Outdated Show resolved Hide resolved
exercises/practice/clock/ClockTest.php Outdated Show resolved Hide resolved
exercises/practice/clock/ClockTest.php Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
x:action/sync Sync content with its latest version x:knowledge/elementary Little Exercism knowledge required x:module/practice-exercise Work on Practice Exercises x:rep/small Small amount of reputation x:size/small Small amount of work x:type/content Work on content (e.g. exercises, concepts)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sync clock
3 participants