From da6c58fc27ce0f703d27d40300fc8e29f1647bc2 Mon Sep 17 00:00:00 2001
From: Andrew Davis
Date: Sat, 5 Jan 2019 15:31:14 -0600
Subject: [PATCH 1/5] Proofreading and code blocking keywords
---
chapters/abstract.md | 4 ++--
chapters/basics.md | 6 ++++--
chapters/boolean-logic.md | 35 ++++++++-------------------------
chapters/classes-constructor.md | 2 +-
chapters/classes-inheritance.md | 8 ++++----
chapters/classes-visibility.md | 12 +++++------
chapters/classes.md | 13 ++++++------
chapters/comparisons.md | 5 ++---
chapters/conditionals.md | 7 +++----
chapters/exceptions.md | 14 ++++++-------
chapters/functions.md | 4 ++--
chapters/interfaces.md | 8 ++++----
chapters/loops.md | 18 ++++++++---------
chapters/static.md | 6 +++---
chapters/strings.md | 2 +-
chapters/variables.md | 1 -
16 files changed, 62 insertions(+), 83 deletions(-)
diff --git a/chapters/abstract.md b/chapters/abstract.md
index eda14a6..99b4b6b 100644
--- a/chapters/abstract.md
+++ b/chapters/abstract.md
@@ -1,5 +1,5 @@
Abstract classes are similar to interfaces in that they define methods that a sub-class must implement.
-However, an abstract class can also have normal methods. To create an abstract class, use the "abstract"
+However, an abstract class can also have normal methods. To create an abstract class, use the `abstract`
keyword followed by class and the name of the class.
```php
turnOn();
diff --git a/chapters/basics.md b/chapters/basics.md
index 2ac6b16..3a2036a 100644
--- a/chapters/basics.md
+++ b/chapters/basics.md
@@ -1,6 +1,6 @@
In the tradition of our ancestors, let's start with a hello world program.
-All PHP files must start with a drive();
```
-A class can use a parent's property or method from the "$this" variable.
+A class can use a parent's property or method from the `$this` variable.
```php
class Motorcycle extends Vehicle
{
@@ -56,9 +56,9 @@ $cycle = new Motorcycle();
$cycle->pushPedal();
```
-If you override a parent's property or method, the "$this" variable will refer to the child's
+If you override a parent's property or method, the `$this` variable will refer to the child's
implementation of the property or method. To call the parent's property or method explicity,
-use the "parent" keyword.
+use the `parent` keyword.
```php
class Racecar extends Vehicle
{
diff --git a/chapters/classes-visibility.md b/chapters/classes-visibility.md
index f24524d..ff36fb6 100644
--- a/chapters/classes-visibility.md
+++ b/chapters/classes-visibility.md
@@ -1,5 +1,5 @@
In the last chapter, we defined properties and methods on the class using the public keyword.
-You can also define them using the "protected" and "private" keywords.
+You can also define them using the `protected` and `private` keywords.
Both keywords prevent the properties and functions from being accessible outside the object.
Only the object itself can use each.
```php
@@ -16,7 +16,7 @@ class Phone
}
```
-We cannot set the number using "$phone->number = '123-456-7890'".
+We cannot set the number using `$phone->number = '123-456-7890'`.
Instead, we can use the public method.
```php
$phone = new Phone();
@@ -39,9 +39,9 @@ class Phone2
}
```
-The "protected" and "private" keywords work a little differently.
+The `protected` and `private` keywords work a little differently.
They both prevent functions and properties from being accessed outside an object.
-However, a method or property marked "protected" can still be accessed by a child class.
+However, a method or property marked `protected` can still be accessed by a child class.
```php
class Phone3
{
@@ -56,8 +56,8 @@ class Phone3
}
```
-In class "Smartphone", the "caller" property is accessible because the parent class
-has it marked as "protected". However, "Smartphone" cannot access the "number" property
+In class `Smartphone`, the `caller` property is accessible because the parent class
+has it marked as `protected`. However, `Smartphone` cannot access the `number` property
because it is still listed as private.
```php
class Smartphone extends Phone3
diff --git a/chapters/classes.md b/chapters/classes.md
index 413c688..8e7fa5e 100644
--- a/chapters/classes.md
+++ b/chapters/classes.md
@@ -1,4 +1,3 @@
-
Classes allow you to define your own data types. All classes start with the
class keyword followed by the name of the class and opening and closing curly braces.
```php
@@ -9,7 +8,7 @@ class Car
}
```
-To create an instance of a class, you use the "new" keyword in front of the class name
+To create an instance of a class, you use the `new` keyword in front of the class name
with parentheses.
```php
$car = new Car();
@@ -17,7 +16,7 @@ $car = new Car();
A class can define attributes and methods. An attribute is a piece of data
stored on the class instance. You can define an attribute by adding the
-word "public" and a variable name inside the class definition.
+word `public` and a variable name inside the class definition.
```php
class Bicycle
{
@@ -26,7 +25,7 @@ class Bicycle
```
Then, when you create an instance of the class, you can set and use
-the color attribute on the bicycle using "->".
+the color attribute on the bicycle using `->`.
```php
$bike = new Bicycle();
$bike->color = 'Blue';
@@ -42,8 +41,8 @@ echo $redBike->color . " Bike Object\n";
```
A method is a function attached to the class. You can add a method
-to a class by using the "public" keyword followed by the function. A method
-can access the attributes and methods of an object instance using the "$this" variable.
+to a class by using the `public` keyword followed by the function. A method
+can access the attributes and methods of an object instance using the `$this` variable.
```php
class Tricycle
{
@@ -56,7 +55,7 @@ class Tricycle
}
```
-You can execute a method on an object using the same "->" arrow characters.
+You can execute a method on an object using the same `->` arrow characters.
```php
$bike = new Tricycle();
$bike->color = 'Red';
diff --git a/chapters/comparisons.md b/chapters/comparisons.md
index dfb45cf..f29dd11 100644
--- a/chapters/comparisons.md
+++ b/chapters/comparisons.md
@@ -1,4 +1,3 @@
-
A boolean is a value that is always 0 or 1, yes or no, on or off.
In PHP, a boolean is represented by the words true and false.
While programming, you will often want to know if something is positive or negative.
@@ -48,7 +47,7 @@ $one >= $two;
You can also check that two values are equal and of the same type
by using three equal signs.
-This returns true.
+The following comparisons return true.
```php
1 == 1;
1 == '1';
@@ -57,7 +56,7 @@ This returns true.
1 === 1;
```
-This returns false.
+These return false.
```php
1 === '1';
1 === true;
diff --git a/chapters/conditionals.md b/chapters/conditionals.md
index 712cf04..3c28948 100644
--- a/chapters/conditionals.md
+++ b/chapters/conditionals.md
@@ -1,4 +1,3 @@
-
When writing code, there will be times when you need to perform actions only under certain circumstances.
There are several ways to control execution in PHP.
We will start with an if statement.
@@ -12,10 +11,10 @@ if ($animal == 'cow') {
```
All conditionals check to see if a statement evaluates to true or false.
-In the case above, since $animal equals 'cow', the statement returns true and the contents of the if statement are executed.
+In the case above, since `$animal` equals 'cow', the statement returns true and the contents of the if statement are executed.
An if statement can have multiple conditions chained together.
-If the first if statement returns false, then PHP will check each elseif.
+If the first if statement returns false, then PHP will check each `elseif`.
If none of the checks return true, then the else block will be executed.
```php
$animal = 'bird';
@@ -32,7 +31,7 @@ if ($animal == 'dog') {
An alternative to the if statement is the switch.
A switch statement has multiple cases to check if the value in parentheses equals something.
-In this statement, since $food equals 'apples', the switch will echo "Eating an apple".
+In this statement, since `$food` equals 'apples', the switch will echo "Eating an apple".
The default case will be run if no other case evaluates to true, like an else statement.
```php
$food = 'apples';
diff --git a/chapters/exceptions.md b/chapters/exceptions.md
index 90c7e05..9cef6bf 100644
--- a/chapters/exceptions.md
+++ b/chapters/exceptions.md
@@ -1,5 +1,5 @@
Sometimes things go wrong when someone uses your code. How do we handle this situation?
-PHP has Exceptions to define errors and the ability to "throw" them to stop code
+PHP has Exceptions to define errors and the ability to `throw` them to stop code
execution and tell the user of your code that something is wrong.
```php
charge('1234');
A developer who wants to prevent an exception from stopping code execution
can catch the exception and use it for logging or display the error to a user.
-Just wrap the code that might throw an exception with the keyword "try" and brackets
-followed by "catch", the exception type in parentheses and more brackets.
+Just wrap the code that might throw an exception with the keyword `try` and brackets
+followed by `catch`, the exception type in parentheses and more brackets.
```php
try {
$processor->charge('1234');
@@ -37,7 +37,7 @@ try {
```
You can make your own custom exceptions as well. They are just classes
-that extend Exception.
+that extend the `Exception` class.
```php
class MyCustomException extends Exception {}
```
@@ -51,8 +51,8 @@ try {
}
```
-Since all exceptions inherit from Exception, catching
-Exception will catch any and all exceptions that might be thrown.
+Since all exceptions inherit from `Exception`, catching
+`Exception` will catch any and all exceptions that might be thrown.
```php
try {
throw new MyCustomException('I inherit from Exception');
diff --git a/chapters/functions.md b/chapters/functions.md
index 6aaa8ac..6e6fa85 100644
--- a/chapters/functions.md
+++ b/chapters/functions.md
@@ -27,8 +27,8 @@ function greet($firstname, $lastname) {
```
Then, you can pass in values when calling a function. In the greet function,
-'John' is assigned to $firstname and 'Smith' is assigned to
-$lastname.
+'John' is assigned to `$firstname` and 'Smith' is assigned to
+`$lastname`.
```php
greet('John', 'Smith');
```
diff --git a/chapters/interfaces.md b/chapters/interfaces.md
index ae0f646..9d72f83 100644
--- a/chapters/interfaces.md
+++ b/chapters/interfaces.md
@@ -1,4 +1,4 @@
-The word "interface" is a confusing term because it is used for so many different concepts.
+The word `interface` is a confusing term because it is used for so many different concepts.
Most often, we use it to describe the appearance of an app and how a user interacts with it.
However, in PHP, an interface is a special construct that acts as a contract for classes.
An interface defines what methods a class should have.
@@ -12,8 +12,8 @@ interface Chair
}
```
-To use an interface with a class, you use the "implements" keyword after the class name.
-Now, the Recliner class must have a setColor method and a setLegs method.
+To use an interface with a class, you use the `implements` keyword after the class name.
+Now, the `Recliner` class must have a `setColor` method and a setLegs method.
If you do not create the required methods on the class, PHP will throw an error.
```php
class Recliner implements Chair
@@ -53,7 +53,7 @@ class CreditCard
}
```
-Since CreditCard implements Payment, other developers can use the charge method, knowing it exists on the class.
+Since `CreditCard` implements `Payment`, other developers can use the charge method, knowing it exists on the class.
```php
$creditCard = new CreditCard();
$creditCard->charge(25);
diff --git a/chapters/loops.md b/chapters/loops.md
index b4eabfc..3a4f84d 100644
--- a/chapters/loops.md
+++ b/chapters/loops.md
@@ -1,6 +1,6 @@
A loop tells PHP to run a block of code more than once.
A classic loop is a while loop.
-A "while" loop will continue to run the block of code as long as the value in parentheses is true.
+A `while` loop will continue to run the block of code as long as the value in parentheses is true.
```php
0) {
}
```
-A "do while" loop is similar to a "while" loop except it always runs at least
-one iteration. In a classic "while" loop, no iterations may be executed if
-the value in parentheses is false. In a "do while", the boolean check
+A `do while` loop is similar to a `while` loop except it always runs at least
+one iteration. In a classic `while` loop, no iterations may be executed if
+the value in parentheses is false. In a `do while`, the boolean check
is not done until after the execution of an iteration.
```php
$num = 0;
@@ -23,7 +23,7 @@ do {
} while ($num < 5);
```
-"for" loops allow you to create a more concise while loop.
+`for` loops allow you to create a more concise while loop.
Inside the parentheses, the left section creates a variable before the loop
starts, the middle section is the check that is done at the beginning of each loop
and the third section is executed after each loop.
@@ -33,9 +33,9 @@ for ($i = 0; $i < 10; $i++) {
}
```
-A "foreach" loop allows you to easily loop over an array.
+A `foreach` loop allows you to easily loop over an array.
An array is a list of data stored together.
-The "as" keyword lets you assign a variable to the value
+The `as` keyword lets you assign a variable to the value
in the array for the current iteration of the loop.
```php
$set = [1, 2, 3, 4, 5];
@@ -44,7 +44,7 @@ foreach ($set as $num) {
}
```
-In loops, you can use the keyword "break" to stop the loop execution
+In loops, you can use the keyword `break` to stop the loop execution
no matter how many more iterations should run.
```php
$values = ['one', 'two', 'three'];
@@ -56,7 +56,7 @@ foreach ($values as $value) {
}
```
-The "continue" keyword stops executing the current loop iteration,
+The `continue` keyword stops executing the current loop iteration,
but then allows the loop to continue with other iterations.
```php
$values = ['one', 'skip', 'three'];
diff --git a/chapters/static.md b/chapters/static.md
index 3afdfc7..f2b33da 100644
--- a/chapters/static.md
+++ b/chapters/static.md
@@ -22,7 +22,7 @@ $house = new House('Green');
```
However, what if you want the blueprint to have properties and methods?
-That is when you use the "static" keyword. In this class, we will define a default color
+That is when you use the `static` keyword. In this class, we will define a default color
on the class itself and then use it when creating a new object.
```php
class Skyscraper
@@ -42,7 +42,7 @@ class Skyscraper
}
```
-You can access static methods and properties using double colons on "self" inside the object
+You can access static methods and properties using double colons on `self` inside the object
or on the class name outside of the object. Static methods and properties can only access
other static methods and properties.
```php
@@ -75,7 +75,7 @@ class TinyHouse
}
```
-Using "build" can make more sense than "new", but it is ultimately a personal preference.
+Using `build` can make more sense than `new`, but it is ultimately a personal preference.
```php
$house = TinyHouse::build('Blue', 4, true);
```
diff --git a/chapters/strings.md b/chapters/strings.md
index cdc70b7..0c78b07 100644
--- a/chapters/strings.md
+++ b/chapters/strings.md
@@ -8,7 +8,7 @@ $lastname = "Johnson";
```
A double quoted string can interpret special characters starting
-with a back slash to create formatting. The \n creates a newline
+with a back slash to create formatting. The `\n` creates a newline
between the names and after them.
```php
echo "Jacob\nJones\n";
diff --git a/chapters/variables.md b/chapters/variables.md
index f7659e1..43a57e7 100644
--- a/chapters/variables.md
+++ b/chapters/variables.md
@@ -1,4 +1,3 @@
-
The variable is the basic building block of any programming language.
In PHP, all variables start with a dollar sign.
```php
From c8f57c8d7b066b69c4264d4cd6853c53aad8f606 Mon Sep 17 00:00:00 2001
From: Andrew Davis
Date: Sun, 6 Jan 2019 20:30:12 -0600
Subject: [PATCH 2/5] Added parsedown to credits
---
assets/templates/credits.phtml | 1 +
1 file changed, 1 insertion(+)
diff --git a/assets/templates/credits.phtml b/assets/templates/credits.phtml
index 3e48fe4..5cb59d6 100644
--- a/assets/templates/credits.phtml
+++ b/assets/templates/credits.phtml
@@ -31,6 +31,7 @@
PostCSS
Symfony CLI
Symfony Encore
+ Parsedown
From c35d9a30e3a47f2e1dd9bc8a86a3b55f5bbba78e Mon Sep 17 00:00:00 2001
From: Andrew Davis
Date: Sun, 6 Jan 2019 20:37:13 -0600
Subject: [PATCH 3/5] Updated code tag styling in paragraphs
---
assets/css/site.css | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/assets/css/site.css b/assets/css/site.css
index e232d05..ed104ba 100644
--- a/assets/css/site.css
+++ b/assets/css/site.css
@@ -12,13 +12,19 @@ body {
padding-top: 1em;
padding-bottom: 1em;
}
-pre, code {
+code {
+ background-color: #F0F0F0;
+ font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
+ font-size: 14px;
+ padding: 0.10em 0.25em;
+}
+pre, pre code {
+ background-color: transparent;
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
font-size: 14px;
margin: 0 !important;
border-radius: 0 !important;
- padding-top: 0.5em !important;
- padding-bottom: 0.5em !important;
+ padding: 0.5em 0 0.5em 0;
}
a {
color: $primary-color; /* #4078f2 */
From 9d37cb55fa9007223c75606c7b7af392c3165102 Mon Sep 17 00:00:00 2001
From: Andrew Davis
Date: Sun, 6 Jan 2019 20:56:31 -0600
Subject: [PATCH 4/5] Updating elephant logo
---
assets/icons/elephant.svg | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/assets/icons/elephant.svg b/assets/icons/elephant.svg
index b6123ca..d0edf95 100644
--- a/assets/icons/elephant.svg
+++ b/assets/icons/elephant.svg
@@ -4,7 +4,7 @@
elephant
Created with Sketch.
-
+
@@ -24,8 +24,8 @@
-
-
+
+
From 504fd005bbd90ec74b16b460264e09d665bf99f7 Mon Sep 17 00:00:00 2001
From: Andrew Davis
Date: Sun, 6 Jan 2019 20:56:50 -0600
Subject: [PATCH 5/5] More editing of chapters
---
chapters/abstract.md | 4 ++--
chapters/arrays.md | 4 ++--
chapters/classes-constructor.md | 2 +-
chapters/classes-inheritance.md | 2 +-
chapters/exceptions.md | 8 ++++----
chapters/interfaces.md | 2 +-
6 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/chapters/abstract.md b/chapters/abstract.md
index 99b4b6b..4b8d986 100644
--- a/chapters/abstract.md
+++ b/chapters/abstract.md
@@ -1,6 +1,6 @@
Abstract classes are similar to interfaces in that they define methods that a sub-class must implement.
However, an abstract class can also have normal methods. To create an abstract class, use the `abstract`
-keyword followed by class and the name of the class.
+keyword followed by `class` and the name of the class.
```php
unlock();
Lastly, you cannot create an instance of an abstract class. PHP would not know how to use the abstract methods
so when you try to create an abstract instance you will get an error.
```php
-$cellPhone = new CellPhone();
+$cellPhone = new CellPhone(); // causes an error
```
diff --git a/chapters/arrays.md b/chapters/arrays.md
index 5821a02..f1caf9c 100644
--- a/chapters/arrays.md
+++ b/chapters/arrays.md
@@ -1,7 +1,7 @@
In PHP, arrays are used to store a list of items in a single variable.
There are two ways to create an array.
-First, you can use the array construct to pass in values separated by commas
+First, you can use the `array` construct to pass in values separated by commas
and it will return an array.
```php
'Toyota', 'model' => 'Camry'];
diff --git a/chapters/classes-constructor.md b/chapters/classes-constructor.md
index a81c680..3907bdc 100644
--- a/chapters/classes-constructor.md
+++ b/chapters/classes-constructor.md
@@ -53,7 +53,7 @@ class Tophat
}
```
-`$tophat` now holds an instance of `Tophat`, not the color "Grey".
+`$tophat` now holds an instance of `Tophat`, not the string "Grey".
```php
$tophat = new Tophat('Grey');
```
diff --git a/chapters/classes-inheritance.md b/chapters/classes-inheritance.md
index d9a5c53..27a6fe5 100644
--- a/chapters/classes-inheritance.md
+++ b/chapters/classes-inheritance.md
@@ -15,7 +15,7 @@ class Vehicle
class Truck extends Vehicle {}
```
-The `Truck` class does not error because `Truck` extends `Vehicle`.
+Using the `drive` method on the `Truck` class does not cause an error because `Truck` extends `Vehicle`.
```php
$truck = new Truck();
$truck->drive();
diff --git a/chapters/exceptions.md b/chapters/exceptions.md
index 9cef6bf..5685542 100644
--- a/chapters/exceptions.md
+++ b/chapters/exceptions.md
@@ -17,7 +17,7 @@ class Processor
In this case, if someone tried to use the `Processor` class
to charge a credit card number that is not 16 characters long, an
-exception will be thrown which stops the rest of the code from running.
+`Exception` will be thrown which stops the rest of the code from running.
```php
$processor = new Processor();
$processor->charge('1234');
@@ -26,8 +26,8 @@ $processor->charge('1234');
A developer who wants to prevent an exception from stopping code execution
can catch the exception and use it for logging or display the error to a user.
-Just wrap the code that might throw an exception with the keyword `try` and brackets
-followed by `catch`, the exception type in parentheses and more brackets.
+Just wrap the code that might throw an exception with the keyword `try` and braces
+followed by `catch`, the exception type in parentheses and more braces.
```php
try {
$processor->charge('1234');
@@ -47,7 +47,7 @@ Then, you can try to catch your exception instead of the base exception.
try {
throw new MyCustomException('I am a custom exception');
} catch (MyCustomException $e) {
- echo "Cauth MyCustomException\n";
+ echo "Caught MyCustomException\n";
}
```
diff --git a/chapters/interfaces.md b/chapters/interfaces.md
index 9d72f83..9b198a9 100644
--- a/chapters/interfaces.md
+++ b/chapters/interfaces.md
@@ -13,7 +13,7 @@ interface Chair
```
To use an interface with a class, you use the `implements` keyword after the class name.
-Now, the `Recliner` class must have a `setColor` method and a setLegs method.
+Now, the `Recliner` class must have a `setColor` method and a `setLegs` method.
If you do not create the required methods on the class, PHP will throw an error.
```php
class Recliner implements Chair