Beyond the primitives
@konrad_126

@konrad_126


@konrad_126
class Flight {
// ...
public function bookSeat($seatNumber) {
// mark the seat as booked
}
// ...
}

@konrad_126
class Flight {
// ...
/** @var string $seatNumber **/
public function bookSeat($seatNumber) {
// mark the seat as booked
}
// ...
}

@konrad_126
class Flight {
// ...
public function bookSeat(string $seatNumber) {
// mark the seat as booked
}
// ...
}

@konrad_126
class Flight {
// ...
public function bookSeat(string $seatNumber) {
// mark the seat as booked
}
// ...
}

@konrad_126
class Flight {
// ...
public function bookSeat(string $seatNumber) {
// mark the seat as booked
}
// ...
}
$flight->bookSeat('A12');

@konrad_126
class Flight {
// ...
public function bookSeat(string $seatNumber) {
// mark the seat as booked
}
// ...
}
$flight->bookSeat('Z23');

@konrad_126
class Flight {
// ...
public function bookSeat(string $seatNumber) {
// mark the seat as booked
}
// ...
}
$flight->bookSeat('');

@konrad_126
class Flight {
// ...
public function bookSeat(string $seatNumber) {
// mark the seat as booked
if (preg_match('/[A-C][1-9]{2}/', $seatNumber){
throw new \Exception('Invalid seat number');
}
}
// ...
}
@konrad_126
class Flight {
// ...
public function bookSeat(string $seatNumber) {
// mark the seat as booked
if (preg_match('/[A-C][1-9]{2}/', $seatNumber){
throw new \Exception('Invalid seat number');
}
}
// ...
}
@konrad_126
class Flight {
// ...
public function bookSeat(string $seatNumber) {
if (preg_match('/[A-C][1-9]{2}/', $seatNumber){
throw new \Exception('Invalid seat number');
}
// mark the seat as booked
}
// ...
}
class Purchase {
// ...
public function bookSeat(string $seatNumber) {
if (preg_match('/[A-C][1-9]{2}/', $seatNumber){
throw new \Exception('Invalid seat number');
}
// mark the seat as booked
}
// ...
}
@konrad_126
mixed
@konrad_126

string
@konrad_126

?
@konrad_126

seat-number
@konrad_126

class Flight {
// ...
public function bookSeat(seat-number $seatNumber) {
// mark the seat as booked
}
}
@konrad_126

@konrad_126
@konrad_126
Beyond the primitives
By konrad 126
Beyond the primitives
- 565