<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/using-non-breakable-spaces-in-test-method-names-zgkrhgv4r" -->

---
title: Using non-breakable spaces in test method names | daily.dev
description: An engineering team at Wizaplace shares an unusual but functional PHP test-naming convention: using non-breaking spaces (which PHP treats as valid identifier...
canonical: https://daily.dev/posts/using-non-breakable-spaces-in-test-method-names-zgkrhgv4r
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Using non-breakable spaces in test method names | daily.dev
og:description: An engineering team at Wizaplace shares an unusual but functional PHP test-naming convention: using non-breaking spaces (which PHP treats as valid identifier...
og:url: https://daily.dev/posts/using-non-breakable-spaces-in-test-method-names-zgkrhgv4r
og:image: https://api.daily.dev/og/posts/zGKRhGv4r.png
og:image:alt: Using non-breakable spaces in test method names
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Using non-breakable spaces in test method names

**[Lobsters](https://daily.dev/sources/lobsters)** · 5 min read · 1 upvotes · 0 comments

## Summary

An engineering team at Wizaplace shares an unusual but functional PHP test-naming convention: using non-breaking spaces (which PHP treats as valid identifier characters) instead of underscores or camelCase, so test method names read like full sentences, e.g. 'test a user can add a product to a wishlist()'. The post explains how to type non-breaking spaces on MacOS and Ubuntu, confirms compatibility with git, PhpStorm, Sublime Text, GitHub, and PHPUnit, notes minor syntax-highlighting issues in Atom and VS Code that were later patched, and discusses the social challenge of onboarding new developers to the convention. The author recommends the trick mainly for small, closed-source projects rather than open source ones due to the 'WTF' factor for new contributors.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://mnapoli.fr/using-non-breakable-spaces-in-test-method-names>

## Questions this post answers

### Can PHP method names contain spaces?

Yes, PHP allows non-breaking space characters (U+00A0) inside method names, so something like 'public function test a user can add a product to a wishlist()' is valid, executable PHP code. Non-breaking spaces look like normal spaces in most editors but are parsed as ordinary identifier characters rather than whitespace, unlike regular spaces.

_Developers experimenting with unconventional naming tricks can compare notes on PHP quirks via daily.dev._

### How do you type a non-breaking space on Mac or Ubuntu for use in code?

On MacOS, press Option (Alt) plus Space. On Ubuntu, press Alt Gr (the right Alt key) plus Space. These shortcuts insert a non-breaking space character that most editors render visually identically to a normal space, making it usable inside identifiers like PHP test method names.

_daily.dev helps developers track practical editor tricks like this one for writing tests._

### Do editors like Atom and VS Code support non-breaking spaces in code correctly?

Mostly yes, though early on Atom and Visual Studio Code had syntax highlighting issues when non-breaking spaces appeared inside identifiers. These were fixed via community pull requests atom/language-php#196 and Microsoft/vscode#26992, after which highlighting worked correctly alongside git, PhpStorm, Sublime Text, GitHub, and PHPUnit integrations.

_Teams weighing unusual naming conventions can check tool support history on daily.dev before adopting them._

## Community take

How the wider developer community reacted, aggregated from 1 discussion and 15 comments across lobsters (as of 2026-09-21).

**TL;DR:** Commenters are largely skeptical of the non-breaking-space trick, arguing it adds no real benefit over snake_case while introducing invisible-character pitfalls in grep and terminal workflows, though a few find the underlying quirk technically interesting.

**Sentiment:** 5% positive · 20% mixed · 75% skeptical

**The case for**

- Some editors can visually distinguish non-breaking spaces (e.g. as a grey joiner), making accidental use spotable for certain users.
- A few found the experiment itself an interesting technical curiosity worth discussing.

**The pushback**

- No real advantage over snake_case or camelCase naming conventions.
- Non-breaking spaces are invisible in terminals and break grep/text-processing workflows.
- The fact that syntax highlighting had to be patched in multiple editors is itself seen as evidence this is a bad idea.
- The trick doesn't work in most other languages that follow UAX #31 identifier syntax rules (JavaScript, C, C++, Rust, Go, Python).
- Accidentally typed non-breaking spaces (e.g. via AltGr key combinations) have historically caused confusing, hard-to-debug errors.

**By community**

- lobsters (skeptical): Most engage critically, questioning the practical value over standard naming conventions and highlighting the invisible-character and cross-language limitations.

**Hottest debate:** Whether accidentally-typed non-breaking spaces are actually easy to spot in practice, with people disagreeing based on their keyboard layout (AltGr usage) and editor.

**Open questions**

- Beyond PHP, which other languages could actually support this trick (Bash, Tcl, and a few others were mentioned but with uncertainty)?
- How widespread is the AltGr-related accidental non-breaking-space issue really?

**Highlights**

> It's an interesting idea, but I see no value added vs snake_case  > Q: How can you tell if you've typed a classic space by mistake? > > A: Don't worry, you'll see it immediately this doesn't resonate with me at all - difference will be invisible e.g. when `grep`ping or doing basically any other text processing in the terminal (not to mention lack of matches if I `grep "test some thing"` instead of version with nbsp)
> — [patryk on lobsters · 11 points, 3 comments](https://lobste.rs/s/bvsaiy/using_non_breakable_spaces_test_method#c_arjnvb)

> This confirms that it's really a bad idea and the fact they had issues with the syntax highlighting in various editors. But instead then went full on and published an article about it! The experiment is interesting but, honestly, only members of the PHP community could have think this should be something else than an experiment! I had to check the writing date for a "1 April" but nothing there :-)
> — [kototama on lobsters · 11 points](https://lobste.rs/s/bvsaiy/using_non_breakable_spaces_test_method#c_9bcrqa)

> This hack doesn’t work in languages that that follow [UAX #31](https://www.unicode.org/reports/tr31/) syntax (JavaScript, C, C++, Rust, Golang, Python) and many that don’t (Perl is close to UAX #31, Java and C# have older syntax using more basic character properties).
> — [fanf on lobsters · 4 points, 1 comments](https://lobste.rs/s/bvsaiy/using_non_breakable_spaces_test_method#c_qleemj)

> Haha, I vividly recall debugging issues with accidentally inserting a `&nbsp;`, I think I was using Sublime Text at the time, and then having a hell of a time tracking down the culprit because of bad compiler error messages (I cannot recall for certain whether the language I was using was PHP or C++, but just assume it was PHP, that'd be funnier). Since then, I've sworn by highlighting non-space-characters-that-look-like-space with a searing red color!
> — [madsmtm on lobsters · 1 points](https://lobste.rs/s/bvsaiy/using_non_breakable_spaces_test_method#c_xreg6v)

> I wouldn't despair: People with AlgGr keys will be familiar with spotting their own accidentally typed nonbreakable spaces in their editor. I do all my programming in Kate, and it makes nonbreakable spaces visible (as a grey joiner). The terminal admittedly won't, but it already doesn't show tabs or any other "nonprintable" chars. Grepping has its sides, though: You just gotta exercise your AltGr key instead of Shift for underscore. I can imagine you get a very precise search for the same number of keystrokes.
> — [anordal on lobsters · 2 points, 2 comments](https://lobste.rs/s/bvsaiy/using_non_breakable_spaces_test_method#c_swgkx3)

**Source threads**

- [lobsters](https://lobste.rs/s/bvsaiy/using_non_breakable_spaces_test_method) · 15 points · 15 comments

## Similar posts on daily.dev

- [Property-based testing: How to find bugs your unit tests miss](https://daily.dev/posts/property-based-testing-how-to-find-bugs-your-unit-tests-miss-kaogkw4ex) · CircleCI · 0 upvotes · 0 comments
- [Code without tests doesn’t go to production ‣ harasim.dev](https://daily.dev/posts/code-without-tests-doesn-t-go-to-production-harasim-dev-poatc5iii) · Harasim.dev · 0 upvotes · 1 comments
- [Programmers and software developers lost the plot on naming their tools](https://daily.dev/posts/programmers-and-software-developers-lost-the-plot-on-naming-their-tools-58qox9jao) · Hacker News · 15 upvotes · 4 comments
- [Naming Things Is the Hard Part, in Code and in Copy](https://daily.dev/posts/naming-things-is-the-hard-part-in-code-and-in-copy-lpavzrbpk) · Medium · 0 upvotes · 0 comments

---

Tags: [#testing](https://daily.dev/tags/testing), [#php](https://daily.dev/tags/php), [#phpunit](https://daily.dev/tags/phpunit)

[View this post on daily.dev](https://daily.dev/posts/using-non-breakable-spaces-in-test-method-names-zgkrhgv4r)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Using non-breakable spaces in test method names","url":"https://daily.dev/posts/using-non-breakable-spaces-in-test-method-names-zgkrhgv4r","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/using-non-breakable-spaces-in-test-method-names-zgkrhgv4r"},"datePublished":"2026-09-21T10:12:29.732Z","dateModified":"2026-09-21T17:43:15.102Z","description":"An engineering team at Wizaplace shares an unusual but functional PHP test-naming convention: using non-breaking spaces (which PHP treats as valid identifier...","image":"https://media.daily.dev/image/upload/s--ZrL_HSsR--/f_auto/v1722860399/public/Placeholder%2006","thumbnailUrl":"https://media.daily.dev/image/upload/s--ZrL_HSsR--/f_auto/v1722860399/public/Placeholder%2006","isAccessibleForFree":true,"articleSection":"Lobsters","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Lobsters","logo":"https://media.daily.dev/image/upload/s--tl8v_Fku--/f_auto,t_logo/v1698841318/logos/lobste.jpg","url":"https://daily.dev/sources/lobsters"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/using-non-breakable-spaces-in-test-method-names-zgkrhgv4r","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"testing,php,phpunit","timeRequired":"PT5M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Lobsters","item":"https://daily.dev/sources/lobsters"},{"@type":"ListItem","position":3,"name":"Using non-breakable spaces in test method names"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/using-non-breakable-spaces-in-test-method-names-zgkrhgv4r#faq","mainEntity":[{"@type":"Question","name":"Can PHP method names contain spaces?","acceptedAnswer":{"@type":"Answer","text":"Yes, PHP allows non-breaking space characters (U+00A0) inside method names, so something like 'public function test a user can add a product to a wishlist()' is valid, executable PHP code. Non-breaking spaces look like normal spaces in most editors but are parsed as ordinary identifier characters rather than whitespace, unlike regular spaces. Developers experimenting with unconventional naming tricks can compare notes on PHP quirks via daily.dev."}},{"@type":"Question","name":"How do you type a non-breaking space on Mac or Ubuntu for use in code?","acceptedAnswer":{"@type":"Answer","text":"On MacOS, press Option (Alt) plus Space. On Ubuntu, press Alt Gr (the right Alt key) plus Space. These shortcuts insert a non-breaking space character that most editors render visually identically to a normal space, making it usable inside identifiers like PHP test method names. daily.dev helps developers track practical editor tricks like this one for writing tests."}},{"@type":"Question","name":"Do editors like Atom and VS Code support non-breaking spaces in code correctly?","acceptedAnswer":{"@type":"Answer","text":"Mostly yes, though early on Atom and Visual Studio Code had syntax highlighting issues when non-breaking spaces appeared inside identifiers. These were fixed via community pull requests atom/language-php#196 and Microsoft/vscode#26992, after which highlighting worked correctly alongside git, PhpStorm, Sublime Text, GitHub, and PHPUnit integrations. Teams weighing unusual naming conventions can check tool support history on daily.dev before adopting them."}}]}
```

