-
Notifications
You must be signed in to change notification settings - Fork 1
List of PHP Kata to Update
PHP 8.0 with PHPUnit 9.5.2 was added. The kata on this page needs to be updated manually. Any help is appreciated!
-
Files are no longer concatenated, but it should work very similarly as before because solution and preloaded files are autoloaded
-
Accessing Global variables in the user's file (
_solution.php
):Since moving away from file concatenation, the preloaded section, the solution and the tests are split in 3 files, respectively:
/workspace/default/_preloaded.php
,/workspace/default/_solution.php
and/workspace/default/tests/{PHPUnit Test Class Name}.php
.While most kata ask the user to write a function or a class, some ask the user to define a global variable (for example Binary Multiple of 3 which asks for a regexp). Because the files are no longer concatenated, a
global
declaration is no longer sufficient to pull the user's global variables into the test suite's scope. One solution is to addrequire '_solution.php';
at the top level of the test suite as well (require_once
will not work). However, this will cause the user's file to be evaluated twice (once by the auto-loading and once byrequire
): for example if the user's file contains the lineecho "foo";
at the top-level,foo
will be printed twice to the console. Despite this caveat,require
still allows to upgrade those kata that only ask for one or several variables. But this will not work when the kata requires both global variables and functions / classes from the user, as the second evaluation caused by therequire
statement will trigger a duplicate declaration error, e.g.:Fatal error: Cannot redeclare foo() (previously declared in /workspace/default/_solution.php:3) in /workspace/default/_solution.php on line 1
Some kata seem impossible to upgrade due to this new runner behavior, see the list below. If you know a way to solve this problem, please get in touch !
-
-
The name of the test class now required to end with
Test
-
Solution and Preloaded file should have
<?php
- Runner prepends this if missing for backwards compatibility, but any new code should include it
-
Test file should have
<?php use PHPUnit\Framework\TestCase;
- Runner prepends this if
<?php
is missing for backwards compatibility, but any new code should include it
- Runner prepends this if
-
PHPUnit is updated to 9.5.2 so there are some breaking changes
-
Testing for exceptions:
PHPUnit 6 removed support for testing for exceptions with PHPDoc annotations:
/** * @expectedException InvalidArgumentException * @expectedExceptionMessage The argument was invalid! */ public function testForException() { functionThatShouldThrow(); }
new code should use
expectException()
:public function testForException() { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The argument was invalid!"); functionThatShouldThrow(); }
-
- 'Magic' recursion call depth number
- Brainfuck Translator
- Buddy Pairs
- Burrows-Wheeler-Transformation
- Buying a car
- Car Park Escape
- Catalog
- Challenge Fun #14: Target Game
- Check and Mate?
- Ciphers #1 - The 01 Cipher
- Color Choice
- Connect 4
- Creating a custom PHP stream wrapper
- Divide numbers as strings
- Domain name validator
-
Don't rely on luck. - Potentially impossible to upgrade since the solution and tests are no longer concatenated: calling
srand()
in the solution has no effect on the tests - Esolang Interpreters #1 - Introduction to Esolangs and My First Interpreter (MiniStringFuck)
- Esolang: InfiniTick
- Evaluate mathematical expression
- Experimenting with a sequence of complex numbers
- Factorial decomposition
- Family Gift Exchange / Names Out of a Hat
- Fibo akin
- Financing Plan on Planet XY140Z-n
- Fluent Calculator
- Functions of Integers on Cartesian Plane
- Generate keywords
- Get angle between hour and minute hands
- Going to the cinema
- Going to zero or to infinity?
- Good words
- Hofstadter Q
- How many dots are covered
- How Much?
- Human readable duration format
- Hungry Hippos
- Implement the (Unnormalized) Cardinal Sine
- Is my friend cheating?
- Is there an arrow missing ? (Relations - Part1: Reflexivity)
- John and Ann sign up for Codewars
- Largest Palindromic Product
- League Player Rank
- Linked Lists - Get Nth Node
- Linked Lists - Insert Nth Node
- List of all Rationals
- Make sets
- Mirrored Exponential Chunks
- Mystery Class
- Object-Oriented PHP #1 - Classes, Public Properties and Methods - Potentially impossible to upgrade as it requires the user to write both a class and 3 global variables, see above
- One Line Task: Largest Rectangle
- Pattern Generator
- Pattern Generator (mirrored)
- Perimeter of squares in a rectangle
- PHP Immutable
- PHP in Action #5 - PHPMailer Intro
- Pigs in a Pen
- Points in the circle
- Pokemon Damage Calculator
- Positions Average
- Product of two squares
- Pull your words together, man!
- Rectangle into Squares
- Reflection in PHP #3 - Using Reflection on Classes
- Reflection in PHP #4 - Puzzle Challenge [Assessment]
- RoboScript #4 - RS3 Patterns to the Rescue
- Roman Numerals Decoder
- Screen Locking Patterns
- Selective memory
- Shortest Distance to a Character
- Simple assembler interpreter
- Simple consecutive pairs
- Simplifying multilinear polynomials
- Smallest possible sum
- Snakes and Ladders
- Square Pi's
- String Scramble
- Sum Mixed Array
- Text align justify
- Texting with an old-school mobile phone
- The Skiponacci Sequence
- The Walker
- Wave Sorting
- We are Family
- Weight for weight
After changing assertEquals with assertSame to avoid this problem some katas failed the automatic change and require manual editing:
- A Rule of Divisibility by 7
- Area of an arrow
- Binary Genetic Algorithms
- Brainfuck Translator
- Buying a car
- Calculate mean and concatenate string
- Closest and Smallest
- Convert a String to a Number!
- Creating a custom PHP stream wrapper
- Disease Spread
- Driving School Series #2
- Easy Cyclist's Training
- Easy Line
- Euclidean distance in n dimensions
- Fibonacci, Tribonacci and friends
- Financing Plan on Planet XY140Z-n
- Find the Middle of the Product
- Find the area of the rectangle!
- FizzBuzz++
- Fun with lists: filter
- Fun with lists: map
- Functions of Integers on Cartesian Plane
- Heron's formula
- How good are you really?
- How many dots are covered
- League Player Rank
- Looking for a benefactor
- Molecule to atoms
- Mutual Recursion
- One Line Task: Largest Rectangle
- Ordered Count of Characters
- Parse a linked list from a string
- Pascal's Triangle
- Pattern Generator (mirrored)
- Program a Calculator #2 - 3D Vectors
- Quarter of the year
- Regex Tic Tac Toe Win Checker
- Regexp Basics - is it IPv4 address?
- Return the closest number multiple of 10
- Return the first M multiples of N
- Reverse polish notation calculator
- Screen Locking Patterns
- Send in the Clones
- Simple Fun #181: Rounding
- Simple Fun #74: Growing Plant
- Simple Fun #87: Shuffled Array
- Square Pi's
- Sum and Length
- Sum of Array Averages
- Sum of Intervals
- Sum of positive
- The Walker
- Tiny Three-Pass Compiler
- Tortoise racing
- Wave Sorting
- We are Family
- simple calculator
- Agda Kata that require rank adjustment
- List of Possible Duplicate Kata
- List of kata that are candidates to retirement
- List of Kata with font Tag in Description (possibly broken)
- Potentially Plagiarized Kata
- Tags and topics to assign to kata
- List of Agda Kata to Update
- List of C Kata to Update
- List of C++ Kata to Update
- List of COBOL Kata to Update
- List of Coq Kata to Update
- List of Crystal Kata to Update
- List of C# Kata to Update
- List of Dart Kata to Update
- List of Elixir Kata to Update
- List of Go Kata to Update
- List of Haskell Kata to Update
- List of Java Kata to Update
- List of JavaScript Kata to Update
- List of Kotlin Kata to Update
- List of Lean Kata to Update
- List of Nim Kata to Update
- List of PHP Kata to Update
- List of Python Kata to Update
- List of Racket Kata to Update
- List of Ruby Kata to Update
- List of Rust Kata to Update
- List of Scala Kata to Update
- List of Solidity Kata to Update
- List of Swift Kata to Update
- List of TypeScript Kata to Update