Page MenuHomePhabricator

Add linter rule to prevent exceptions from being thrown in a __toString method
Closed, ResolvedPublic

Description

The following code is invalid:

<?php

class MyClass {
  public function __toString() {
    throw new Exception('oops');
  }
}

Attempting to run will code will result in a fatal error:

PHP Fatal error:  Method MyClass::__toString() must not throw an exception

We should be able to detect this with a linter rule.

Revisions and Commits

Restricted Differential Revision

Event Timeline

joshuaspence assigned this task to josh.
joshuaspence raised the priority of this task from to Wishlist.
joshuaspence updated the task description. (Show Details)
joshuaspence added a project: Lint.
joshuaspence added a subscriber: joshuaspence.
joshuaspence added a revision: Restricted Differential Revision.May 15 2015, 6:19 AM
joshuaspence closed this task as Resolved by committing Restricted Diffusion Commit.May 17 2015, 10:23 PM
joshuaspence added a commit: Restricted Diffusion Commit.