Skip to content

Commit

Permalink
Fix: Various spellchecks (exercism#835)
Browse files Browse the repository at this point in the history
[no important files changed]

---------

Co-authored-by: Tomas Norre Mikkelsen <[email protected]>
Co-authored-by: mk-mxp <[email protected]>
  • Loading branch information
3 people authored Nov 5, 2024
1 parent df2b442 commit 425903c
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 47 deletions.
5 changes: 2 additions & 3 deletions concepts/anonymous-functions-closures/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ $add5 = makeAdderFunction(5);
echo $add5(4); // echos 9
```

In the function `makeAdderFunction` above, the `$number` value that is passed in is "closed" over withing the internally defined anonymous function which is then returned. Then whenever that function is executed it knows the value of the `$number` that was passed in. If you were to call this function again with another number, that would return a completely different function. It would not change the values or the functionality returned by the first function call.

In the function `makeAdderFunction` above, the `$number` value that is passed in is "closed over" within the internally defined anonymous function which is then returned. Then whenever that function is executed it knows the value of the `$number` that was passed in. If you were to call this function again with another number, that would return a completely different function. It would not change the values or the functionality returned by the first function call.
If you need to close over more than one variable, they can be added into the `use` keyword separated by a comma.

PHP also has a shorter function syntax called `arrow functions`. They are required to be fairly simple. The basic form of these is:
Expand Down Expand Up @@ -63,7 +62,7 @@ function positiveAverage(array $numbers): float
$total = 0;
$count = 0;
return array_walk(
$numbers,
$numbers,
function($num) use (&$count, &$total) {
$total += abs($num);
$count++;
Expand Down
10 changes: 5 additions & 5 deletions concepts/arithmetic-operators/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ $yourApples = $yourApples + 2; 2

## Division (/)

The division operator gives the result of dividing the left value by the right value. If the right value is 0, it will cause a `DivisionByZeroError` error.
The division operator gives the result of dividing the left value by the right value. If the right value is 0, it will cause a `DivisionByZeroError` error.

```php
$slicesOfPizza = 8;
Expand Down Expand Up @@ -79,7 +79,7 @@ if ($isOdd === 1) {

## Exponentiation (**)

The exponentiation operator is used to raise the left value to the power of the right value. Prior to PHP 5.6 you would need to use the `pow` function to perform the same thing.
The exponentiation operator is used to raise the left value to the power of the right value. Prior to PHP 5.6 you would need to use the `pow` function to perform the same thing.

```php
$sideLength = 13;
Expand All @@ -95,19 +95,19 @@ $side = $squareArea ** .5; // 12

## Order of Operations

PHP follows the standard order of operations for math. This means that rather that performing operations left to right, each operator has a precedence and the operations are resolved according to their precedence. The order of oeprations is:
PHP follows the standard order of operations for math. This means that rather that performing operations left to right, each operator has a precedence and the operations are resolved according to their precedence. The order of operations is:

* parentheses
* exponentiation
* multiplication, division
* addition, subtraction

Multiplication and division are at the same level of precedence as each other. Similarly, addition and subtraction are at the same level of precence.
Multiplication and division are at the same level of precedence as each other. Similarly, addition and subtraction are at the same level of precedence.

This means the value below would be 17 instead of 10, since multiplication has a higher precedence than addition:

```php
$value = 2 + 3 * 5;
```

PHP also provides a number of helpful assignment operators that combine arithmetic operators with assigment when you are perfoming an operation on a variable and assigning the result back to itself. These will be covered in the `Assignment Operators` concept.
PHP also provides a number of helpful assignment operators that combine arithmetic operators with assignment when you are performing an operation on a variable and assigning the result back to itself. These will be covered in the `Assignment Operators` concept.
2 changes: 1 addition & 1 deletion concepts/basic-syntax/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function window_height()
```

Functions inside classes and their instances are called methods.
To call a method, the name is preceeded by the instance and `->`.
To call a method, the name is preceded by the instance and `->`.
A class instance is created by the `new` operation.
Methods have access to the special variable `$this`, which refers to the current instance.

Expand Down
2 changes: 1 addition & 1 deletion concepts/basic-syntax/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ window_height(100);
```

Functions inside classes and their instances are called methods.
To call a method, the name is preceeded by the instance and `->`.
To call a method, the name is preceded by the instance and `->`.
Methods have access to the special variable `$this`, which refers to the current instance.

```php
Expand Down
2 changes: 1 addition & 1 deletion concepts/type-declaration/.meta/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"blurb": "Type declation in PHP",
"blurb": "Type declaration in PHP",
"authors": ["neenjaw"],
"contributors": []
}
2 changes: 1 addition & 1 deletion exercises/concept/lasagna/.docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ window_height(100);
```

Functions inside classes and their instances are called methods.
To call a method, the name is preceeded by the instance and `->`.
To call a method, the name is preceded by the instance and `->`.
Methods have access to the special variable `$this`, which refers to the current instance.

```php
Expand Down
6 changes: 3 additions & 3 deletions exercises/concept/windowing-system/.meta/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
## Learning objectives

- Reference to OOP
- PHP is a multi-paradign general purpose language with OOP features, what does that mean?
- How to use a constructor function
- PHP is a multi-paradigm general purpose language with OOP features, what does that mean?
- How to use a constructor function
- What does `$this` mean/do
- How to create a new instance with `new`

Expand All @@ -23,7 +23,7 @@ The Concept this exercise unlocks is:

## Prerequisites

- `funtions` as they are the basis for classes and are needed in the exercise
- `functions` as they are the basis for classes and are needed in the exercise
- `integers` as they are the basis for the properties underlying type

## Analyzer
Expand Down
64 changes: 32 additions & 32 deletions exercises/practice/protein-translation/ProteinTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class ProteinTranslationTest extends PHPUnit\Framework\TestCase
{
private ProteinTranslation $translater;
private ProteinTranslation $translator;

public static function setUpBeforeClass(): void
{
Expand All @@ -13,7 +13,7 @@ public static function setUpBeforeClass(): void

public function setUp(): void
{
$this->translater = new ProteinTranslation();
$this->translator = new ProteinTranslation();
}

/**
Expand All @@ -22,7 +22,7 @@ public function setUp(): void
*/
public function testEmptyRnaSequence(): void
{
$this->assertEquals([], $this->translater->getProteins(''));
$this->assertEquals([], $this->translator->getProteins(''));
}

/**
Expand All @@ -31,7 +31,7 @@ public function testEmptyRnaSequence(): void
*/
public function testMethionineRnaSequence(): void
{
$this->assertEquals(['Methionine'], $this->translater->getProteins('AUG'));
$this->assertEquals(['Methionine'], $this->translator->getProteins('AUG'));
}

/**
Expand All @@ -40,7 +40,7 @@ public function testMethionineRnaSequence(): void
*/
public function testPhenylalanineRnaSequenceOne(): void
{
$this->assertEquals(['Phenylalanine'], $this->translater->getProteins('UUU'));
$this->assertEquals(['Phenylalanine'], $this->translator->getProteins('UUU'));
}

/**
Expand All @@ -49,7 +49,7 @@ public function testPhenylalanineRnaSequenceOne(): void
*/
public function testPhenylalanineRnaSequenceTwo(): void
{
$this->assertEquals(['Phenylalanine'], $this->translater->getProteins('UUC'));
$this->assertEquals(['Phenylalanine'], $this->translator->getProteins('UUC'));
}

/**
Expand All @@ -58,7 +58,7 @@ public function testPhenylalanineRnaSequenceTwo(): void
*/
public function testLeucineRnaSequenceOne(): void
{
$this->assertEquals(['Leucine'], $this->translater->getProteins('UUA'));
$this->assertEquals(['Leucine'], $this->translator->getProteins('UUA'));
}

/**
Expand All @@ -67,7 +67,7 @@ public function testLeucineRnaSequenceOne(): void
*/
public function testLeucineRnaSequenceTwo(): void
{
$this->assertEquals(['Leucine'], $this->translater->getProteins('UUG'));
$this->assertEquals(['Leucine'], $this->translator->getProteins('UUG'));
}

/**
Expand All @@ -76,7 +76,7 @@ public function testLeucineRnaSequenceTwo(): void
*/
public function testSerineRnaSequenceOne(): void
{
$this->assertEquals(['Serine'], $this->translater->getProteins('UCU'));
$this->assertEquals(['Serine'], $this->translator->getProteins('UCU'));
}

/**
Expand All @@ -85,7 +85,7 @@ public function testSerineRnaSequenceOne(): void
*/
public function testSerineRnaSequenceTwo(): void
{
$this->assertEquals(['Serine'], $this->translater->getProteins('UCC'));
$this->assertEquals(['Serine'], $this->translator->getProteins('UCC'));
}

/**
Expand All @@ -94,7 +94,7 @@ public function testSerineRnaSequenceTwo(): void
*/
public function testSerineRnaSequenceThree(): void
{
$this->assertEquals(['Serine'], $this->translater->getProteins('UCA'));
$this->assertEquals(['Serine'], $this->translator->getProteins('UCA'));
}

/**
Expand All @@ -103,7 +103,7 @@ public function testSerineRnaSequenceThree(): void
*/
public function testSerineRnaSequenceFour(): void
{
$this->assertEquals(['Serine'], $this->translater->getProteins('UCG'));
$this->assertEquals(['Serine'], $this->translator->getProteins('UCG'));
}

/**
Expand All @@ -112,7 +112,7 @@ public function testSerineRnaSequenceFour(): void
*/
public function testTyrosineRnaSequenceOne(): void
{
$this->assertEquals(['Tyrosine'], $this->translater->getProteins('UAU'));
$this->assertEquals(['Tyrosine'], $this->translator->getProteins('UAU'));
}

/**
Expand All @@ -121,7 +121,7 @@ public function testTyrosineRnaSequenceOne(): void
*/
public function testTyrosineRnaSequenceTwo(): void
{
$this->assertEquals(['Tyrosine'], $this->translater->getProteins('UAC'));
$this->assertEquals(['Tyrosine'], $this->translator->getProteins('UAC'));
}

/**
Expand All @@ -130,7 +130,7 @@ public function testTyrosineRnaSequenceTwo(): void
*/
public function testCysteineRnaSequenceOne(): void
{
$this->assertEquals(['Cysteine'], $this->translater->getProteins('UGU'));
$this->assertEquals(['Cysteine'], $this->translator->getProteins('UGU'));
}

/**
Expand All @@ -139,7 +139,7 @@ public function testCysteineRnaSequenceOne(): void
*/
public function testCysteineRnaSequenceTwo(): void
{
$this->assertEquals(['Cysteine'], $this->translater->getProteins('UGC'));
$this->assertEquals(['Cysteine'], $this->translator->getProteins('UGC'));
}

/**
Expand All @@ -148,7 +148,7 @@ public function testCysteineRnaSequenceTwo(): void
*/
public function testTryptophanRnaSequence(): void
{
$this->assertEquals(['Tryptophan'], $this->translater->getProteins('UGG'));
$this->assertEquals(['Tryptophan'], $this->translator->getProteins('UGG'));
}

/**
Expand All @@ -157,7 +157,7 @@ public function testTryptophanRnaSequence(): void
*/
public function testStopCodonRnaSequenceOne(): void
{
$this->assertEquals([], $this->translater->getProteins('UAA'));
$this->assertEquals([], $this->translator->getProteins('UAA'));
}

/**
Expand All @@ -166,7 +166,7 @@ public function testStopCodonRnaSequenceOne(): void
*/
public function testStopCodonRnaSequenceTwo(): void
{
$this->assertEquals([], $this->translater->getProteins('UAG'));
$this->assertEquals([], $this->translator->getProteins('UAG'));
}

/**
Expand All @@ -175,7 +175,7 @@ public function testStopCodonRnaSequenceTwo(): void
*/
public function testStopCodonRnaSequenceThree(): void
{
$this->assertEquals([], $this->translater->getProteins('UGA'));
$this->assertEquals([], $this->translator->getProteins('UGA'));
}

/**
Expand All @@ -184,7 +184,7 @@ public function testStopCodonRnaSequenceThree(): void
*/
public function testToCodonsTranslateToProteins(): void
{
$this->assertEquals(['Phenylalanine', 'Phenylalanine'], $this->translater->getProteins('UUUUUU'));
$this->assertEquals(['Phenylalanine', 'Phenylalanine'], $this->translator->getProteins('UUUUUU'));
}

/**
Expand All @@ -193,18 +193,18 @@ public function testToCodonsTranslateToProteins(): void
*/
public function testToDifferentCodonsTranslateToProteins(): void
{
$this->assertEquals(['Leucine', 'Leucine'], $this->translater->getProteins('UUAUUG'));
$this->assertEquals(['Leucine', 'Leucine'], $this->translator->getProteins('UUAUUG'));
}

/**
* uuid d0f295df-fb70-425c-946c-ec2ec185388e
* @testdox Translate RNA strand into correct protein list
*/
public function testTranslateRnaStrandToCorrectProteinList(): void
public function testTranslateRnaStrandIntoCorrectProteinList(): void
{
$this->assertEquals(
['Methionine', 'Phenylalanine', 'Tryptophan'],
$this->translater->getProteins('AUGUUUUGG')
$this->translator->getProteins('AUGUUUUGG')
);
}

Expand All @@ -214,7 +214,7 @@ public function testTranslateRnaStrandToCorrectProteinList(): void
*/
public function testTranslationStopsIfStopCodonAtBeginningOfSequence(): void
{
$this->assertEquals([], $this->translater->getProteins('UAGUGG'));
$this->assertEquals([], $this->translator->getProteins('UAGUGG'));
}

/**
Expand All @@ -223,7 +223,7 @@ public function testTranslationStopsIfStopCodonAtBeginningOfSequence(): void
*/
public function testTranslationStopsIfStopCodonAtEndOfTwoCodonSequence(): void
{
$this->assertEquals(['Tryptophan'], $this->translater->getProteins('UGGUAG'));
$this->assertEquals(['Tryptophan'], $this->translator->getProteins('UGGUAG'));
}

/**
Expand All @@ -232,7 +232,7 @@ public function testTranslationStopsIfStopCodonAtEndOfTwoCodonSequence(): void
*/
public function testTranslationStopsIfStopCodonAtEndOfThreeCodonSequence(): void
{
$this->assertEquals(['Methionine', 'Phenylalanine'], $this->translater->getProteins('AUGUUUUAA'));
$this->assertEquals(['Methionine', 'Phenylalanine'], $this->translator->getProteins('AUGUUUUAA'));
}

/**
Expand All @@ -241,7 +241,7 @@ public function testTranslationStopsIfStopCodonAtEndOfThreeCodonSequence(): void
*/
public function testTranslationStopsIfStopCodonInMiddleOfThreeCodonSequence(): void
{
$this->assertEquals(['Tryptophan'], $this->translater->getProteins('UGGUAGUGG'));
$this->assertEquals(['Tryptophan'], $this->translator->getProteins('UGGUAGUGG'));
}

/**
Expand All @@ -252,7 +252,7 @@ public function testTranslationStopsIfStopCodonInMiddleOfSixCodonSequence(): voi
{
$this->assertEquals(
['Tryptophan', 'Cysteine', 'Tyrosine'],
$this->translater->getProteins('UGGUGUUAUUAAUGGUUU')
$this->translator->getProteins('UGGUGUUAUUAAUGGUUU')
);
}

Expand All @@ -264,7 +264,7 @@ public function testUnknownAminoAcidsCantTranslate(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid codon');
$this->translater->getProteins('XYZ');
$this->translator->getProteins('XYZ');
}


Expand All @@ -276,7 +276,7 @@ public function testIncompleteRnaSequenceCantTranslate(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid codon');
$this->translater->getProteins('AUGU');
$this->translator->getProteins('AUGU');
}

/**
Expand All @@ -285,6 +285,6 @@ public function testIncompleteRnaSequenceCantTranslate(): void
*/
public function testIncompleteRnaSequenceCanTranslateIfValidUntilStop(): void
{
$this->assertEquals(['Phenylalanine', 'Phenylalanine'], $this->translater->getProteins('UUCUUCUAAUGGU'));
$this->assertEquals(['Phenylalanine', 'Phenylalanine'], $this->translator->getProteins('UUCUUCUAAUGGU'));
}
}

0 comments on commit 425903c

Please sign in to comment.