Real life example
Write and fix a function from inline chat
Here’s an example function that GitHub Copilot wrote for me:
I then modified the function to reduce the reading speed from 200 words per minute to 50 words just as an example.
I then asked Copilot to fix the function for me based on my prompt.
Fix a function from chat
We’ll use the same function as the previous example but we’ll just tell Copilot Chat to fix it with very few words.
As you can see, not only it figured out the time estimate fix but it also noticed there’s a phpcs error and recommended a fix with explanations. Keep in mind that Copilot wrote this entire function by itself so the phpcs error was also written by Copilot. This is why it is crucial to interpret the code that it gives you and make adjustments as needed.
Explain a function
You can ask Copilot to explain code to you. Here’s how it explains our example function.
Generate automated tests
You can even ask Copilot to create tests for you. Here’s how it creates a simple unit test for our PHP function.